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

package agent;

// The Cortex Server exposes this service
service AgentOrchestrator {
  // Bi-directional stream for persistent connection (Phone Home Pattern)
  rpc Connect(stream NodeMessage) returns (stream ServerMessage);
}

// Sent from the Agent Node Client to the Cortex Server
message NodeMessage {
  oneof payload {
    RegistrationRequest registration = 1;
    Heartbeat heartbeat = 2;
    TaskResponse task_response = 3;
  }
}

// Sent from the Cortex Server to the Agent Node Client
message ServerMessage {
  oneof payload {
    RegistrationResponse registration_ack = 1;
    TaskRequest task_request = 2;
  }
}

message RegistrationRequest {
  string node_id = 1;
  string version = 2;
  string platform = 3;
  map<string, bool> capabilities = 4;
  // E.g., short-lived JWT for auth can be passed here or in metadata
}

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

message Heartbeat {
  string node_id = 1;
  float cpu_usage_percent = 2;
  float memory_usage_percent = 3;
  int32 active_task_count = 4;
}

message TaskRequest {
  string task_id = 1;
  string task_type = 2; // "shell", "browser_cdp"
  string payload_json = 3; 
  int32 timeout_ms = 4;
  bool cancellable = 5;
  string capability_required = 6;
  string idempotency_key = 7;
}

message TaskResponse {
  string task_id = 1;
  enum Status {
    UNKNOWN = 0;
    SUCCESS = 1;
    ERROR = 2;
    CANCELLED = 3;
    TIMEOUT = 4;
  }
  Status status = 2;
  string stdout = 3;
  string stderr = 4;
  string structured_output_json = 5;
  int32 duration_ms = 6;
}