Newer
Older
cortex-hub / poc-grpc-agent / protos / agent.proto
syntax = "proto3";

package agent;

// The Cortex Server exposes this service
service AgentOrchestrator {
  // 1. Control Channel: Sync policies and settings (Unary)
  rpc SyncConfiguration(RegistrationRequest) returns (RegistrationResponse);

  // 2. Task Channel: Bidirectional work dispatch and reporting (Persistent)
  rpc TaskStream(stream ClientTaskMessage) returns (stream ServerTaskMessage);

  // 3. Health Channel: Dedicated Ping-Pong / Heartbeat (Persistent)
  rpc ReportHealth(stream Heartbeat) returns (stream HealthCheckResponse);
}

// --- Channel 1: Registration & Policy ---
message RegistrationRequest {
  string node_id = 1;
  string version = 2;
  string auth_token = 3;
  string node_description = 4; // AI-readable description of this node's role
  map<string, string> capabilities = 5; // e.g. "gpu": "nvidia-3080", "os": "ubuntu-22.04"
}

message SandboxPolicy {
  enum Mode {
    STRICT = 0;
    PERMISSIVE = 1;
  }
  Mode mode = 1;
  repeated string allowed_commands = 2;
  repeated string denied_commands = 3;
  repeated string sensitive_commands = 4;
  string working_dir_jail = 5;
}

message RegistrationResponse {
  bool success = 1;
  string error_message = 2;
  string session_id = 3;
  SandboxPolicy policy = 4;
}

// --- Channel 2: Tasks & Collaboration ---
message ClientTaskMessage {
  oneof payload {
      TaskResponse task_response = 1;
      TaskClaimRequest task_claim = 2;
  }
}

message ServerTaskMessage {
  oneof payload {
      TaskRequest task_request = 1;    
      WorkPoolUpdate work_pool_update = 2; 
      TaskClaimResponse claim_status = 3;
      TaskCancelRequest task_cancel = 4;
  }
}

message TaskCancelRequest {
    string task_id = 1;
}

message TaskRequest {
  string task_id = 1;
  string task_type = 2; 
  oneof payload {
      string payload_json = 3;     // For legacy shell/fallback
      BrowserAction browser_action = 7; // NEW: Structured Browser Skill
  }
  int32 timeout_ms = 4;
  string trace_id = 5;
  string signature = 6;
}

message BrowserAction {
    enum ActionType {
        NAVIGATE = 0;
        CLICK = 1;
        TYPE = 2;
        SCREENSHOT = 3;
        GET_DOM = 4;
        CLOSE = 7;
    }
    ActionType action = 1;
    string url = 2;
    string selector = 3;
    string text = 4;
    string session_id = 5; // For persistent "Antigravity Bridge" continuity
}

message TaskResponse {
  string task_id = 1;
  enum Status {
    SUCCESS = 0;
    ERROR = 1;
    TIMEOUT = 2;
    CANCELLED = 3;
  }
  Status status = 2;
  string stdout = 3;
  string stderr = 4;
  string trace_id = 5;
  map<string, bytes> artifacts = 6;
  
  // NEW: Structured Skill Results
  oneof result {
      BrowserResponse browser_result = 7;
  }
}

message BrowserResponse {
    string url = 1;
    string title = 2;
    bytes snapshot = 3; // Small snapshots; large ones use 'artifacts' chunking
    string dom_content = 4;
}

message WorkPoolUpdate {
  repeated string available_task_ids = 1;
}

message TaskClaimRequest {
  string task_id = 1;
  string node_id = 2;
}

message TaskClaimResponse {
  string task_id = 1;
  bool granted = 2;
  string reason = 3;
}

// --- Channel 3: Health & Observation ---
message Heartbeat {
  string node_id = 1;
  float cpu_usage_percent = 2;
  float memory_usage_percent = 3;
  int32 active_worker_count = 4;
  int32 max_worker_capacity = 5;
  string status_message = 6;
  repeated string running_task_ids = 7;
}

message HealthCheckResponse {
  int64 server_time_ms = 1;
}