syntax = "proto3";

package it0.agent;

service AgentService {
  rpc ExecuteTask (ExecuteTaskRequest) returns (stream EngineStreamEvent);
  rpc CancelTask (CancelTaskRequest) returns (CancelTaskResponse);
  rpc ContinueSession (ContinueSessionRequest) returns (stream EngineStreamEvent);
  rpc GetSessionHistory (GetSessionHistoryRequest) returns (SessionHistoryResponse);
}

message ExecuteTaskRequest {
  string session_id = 1;
  string prompt = 2;
  string system_prompt = 3;
  repeated string allowed_tools = 4;
  int32 max_turns = 5;
  double max_budget_usd = 6;
  map<string, string> context = 7;
}

message CancelTaskRequest {
  string session_id = 1;
}

message CancelTaskResponse {
  bool success = 1;
}

message ContinueSessionRequest {
  string session_id = 1;
  string message = 2;
}

message GetSessionHistoryRequest {
  string session_id = 1;
}

message SessionHistoryResponse {
  repeated SessionMessage messages = 1;
}

message SessionMessage {
  string role = 1;
  string content = 2;
  string timestamp = 3;
}

message EngineStreamEvent {
  string type = 1;
  string content = 2;
  string tool_name = 3;
  string tool_input = 4;
  string tool_output = 5;
  bool is_error = 6;
  string command = 7;
  int32 risk_level = 8;
  string task_id = 9;
  string summary = 10;
  string error_code = 11;
  int32 tokens_used = 12;
}
