syntax = "proto3"; package gateway.v1; import "logging/v1/logging.proto"; import "google/protobuf/timestamp.proto"; service ChatService { rpc RecentLogs(RecentLogsRequest) returns (RecentLogsResponse); rpc Snapshot(SnapshotRequest) returns (SnapshotResponse); rpc GetSession(GetSessionRequest) returns (GetSessionResponse); rpc RecentMessages(RecentMessagesRequest) returns (RecentMessagesResponse); rpc RecentTurns(RecentTurnsRequest) returns (RecentTurnsResponse); rpc Route(RouteRequest) returns (RouteResponse); rpc Stream(StreamRequest) returns (stream StreamResponse); rpc Answer(AnswerRequest) returns (AnswerResponse); rpc Cancel(CancelRequest) returns (CancelResponse); rpc StopTasks(StopTasksRequest) returns (StopTasksResponse); rpc ApplyTaskAction(ApplyTaskActionRequest) returns (ApplyTaskActionResponse); rpc ApplyOperatorTaskAction(ApplyOperatorTaskActionRequest) returns (ApplyOperatorTaskActionResponse); rpc SaveSession(SaveSessionRequest) returns (SaveSessionResponse); rpc GetSessionsByChannel(GetSessionsByChannelRequest) returns (GetSessionsByChannelResponse); rpc DeleteSession(DeleteSessionRequest) returns (DeleteSessionResponse); rpc TouchSession(TouchSessionRequest) returns (TouchSessionResponse); rpc ListSessions(ListSessionsRequest) returns (ListSessionsResponse); rpc SaveMessage(SaveMessageRequest) returns (SaveMessageResponse); rpc DeleteRecentMessages(DeleteRecentMessagesRequest) returns (DeleteRecentMessagesResponse); rpc MessageCount(MessageCountRequest) returns (MessageCountResponse); rpc SaveMessages(SaveMessagesRequest) returns (SaveMessagesResponse); rpc ReplaceMessages(ReplaceMessagesRequest) returns (ReplaceMessagesResponse); rpc SearchMessages(SearchMessagesRequest) returns (SearchMessagesResponse); rpc ListSkills(ListSkillsRequest) returns (ListSkillsResponse); rpc CuratorHealth(CuratorHealthRequest) returns (CuratorHealthResponse); rpc ReloadChannel(ReloadChannelRequest) returns (ReloadChannelResponse); // CheckSecret reports resolution in this process without returning a value. rpc CheckSecret(CheckSecretRequest) returns (CheckSecretResponse); } message CheckSecretRequest { string engine = 1; string key = 2; } message CheckSecretResponse { bool resolved = 1; } message Session { string session_id = 1; string platform = 2; string bot_user = 3; string channel_id = 4; string thread_id = 5; string title = 6; string parent_session_id = 7; string branch_name = 8; google.protobuf.Timestamp created_at = 9; google.protobuf.Timestamp last_active_at = 10; } message Message { string message_id = 1; string source_id = 2; string channel_id = 3; string thread_id = 4; string from = 5; string text = 6; string page = 7; google.protobuf.Timestamp at = 8; reserved 9; reserved "budget_key"; // platform is the channel that carried this message ("telegram", "email", // "web"), as the frontend that owns that channel knows it. It is // how the Gateway learns which channel it is serving: one Router serves every // channel, so its own name is "web" even for a Telegram turn, which made // Source.Platform -- the first component of the session natural key -- a // constant. Transport-only, never persisted: the session record keeps it. string platform = 10; // media carries attachment metadata for a message that arrived with a // file. The bytes ride only on the inbound request (see Media.data); a // stored Media with tool_name empty is a sender attachment, and the // tool_name on tool-produced events stays a stream-only field. repeated Media media = 11; // sender_id is the channel-native stable ID of the person who sent the // message; the Gateway keys per-person rate limits and slash access on it. string sender_id = 12; } message ToolCall { string id = 1; string name = 2; string parameters = 3; string output = 4; string error = 5; int64 duration_ms = 6; int32 text_offset = 7; } message Media { string tool_name = 1; string type = 2; string file_id = 3; string url = 4; string path = 5; string mime_type = 6; string file_name = 7; optional int64 file_size = 8; optional int64 width = 9; optional int64 height = 10; optional int64 duration = 11; // data carries a sender attachment's bytes on an inbound request. The // channel frontend downloads the file, but the Gateway process that runs // the turn never holds the platform credential, so this is the only way // the model can read a photo or document. It is empty on every other // direction: stored history and outbound media events carry metadata // only, and a persisted record strips the bytes. bytes data = 12; } message Turn { string turn_id = 1; string session_id = 2; string source_id = 3; string status = 4; int64 attempt = 5; string owner_id = 6; string input_message_id = 7; string assistant_message_id = 8; string partial_text = 9; string response_text = 10; repeated ToolCall tool_calls = 11; string error = 12; google.protobuf.Timestamp created_at = 13; google.protobuf.Timestamp updated_at = 14; } message StringList { repeated string values = 1; } message SnapshotRequest {} message SnapshotResponse { repeated Session sessions = 1; repeated string models = 2; map models_by_provider = 3; repeated string providers = 4; string active_model = 5; string active_provider = 6; reserved 7, 8, 11; reserved "personas", "active_personas", "personas_available"; bool restart_available = 9; bool cancellation_available = 10; string version = 12; bool voice_available = 13; } message GetSessionRequest { string session_id = 1; } message GetSessionResponse { Session session = 1; bool found = 2; } message RecentMessagesRequest { string session_id = 1; int64 limit = 2; } message RecentMessagesResponse { repeated Message messages = 1; } message RecentTurnsRequest { string session_id = 1; int64 limit = 2; } message RecentTurnsResponse { repeated Turn turns = 1; } message RouteRequest { Message message = 1; } message RouteResponse { string text = 1; string session_id = 2; // rate_limited marks text as the inbound rate-limit reply, not a dispatch // outcome. bool rate_limited = 3; } // The caller states which asks it can answer; the turn offers only those. message StreamRequest { Message message = 1; bool can_approve = 2; bool can_clarify = 3; bool can_pick = 4; bool can_question = 5; } // Ask is a question the turn blocks on until Answer names its id. message Ask { string id = 1; // approval, clarify or picker. string kind = 2; string prompt = 3; // Tool description, for an approval. string detail = 4; repeated Choice choices = 5; // The questions of a questionnaire, in order. repeated Question questions = 6; } message Choice { string id = 1; string label = 2; } message Question { // The key the answer is returned under. string name = 1; string title = 2; string description = 3; bool multiple = 4; bool required = 5; // Whether a value outside choices is an answer. bool allow_other = 6; repeated QuestionChoice choices = 7; } message QuestionChoice { string value = 1; string label = 2; string description = 3; } // For an approval, answer is approve, always or deny; for a picker, the // choice id; for a clarify, the reply text; for a questionnaire, a JSON object // of question name to the list of values given. message AnswerRequest { string ask_id = 1; string answer = 2; } message AnswerResponse { bool found = 1; } message StreamResponse { string kind = 1; string text = 2; string session_id = 3; ToolCall tool = 4; Media media = 5; Ask ask = 6; } message CancelRequest { string session_id = 1; } message CancelResponse { bool cancelled = 1; int64 dropped = 2; } // StopTasksRequest stops task_id, or with task_id zero every queued or running // task the conversation origin created. message StopTasksRequest { string origin = 1; int64 task_id = 2; } // error reports tasks that could not be stopped alongside those that were. message StopTasksResponse { repeated int64 stopped = 1; string error = 2; } message ApplyTaskActionRequest { string identity = 1; int64 task_id = 2; string action = 3; string instructions = 4; repeated string findings = 5; } message ApplyTaskActionResponse { int64 task_id = 1; string action = 2; string message = 3; } // An authenticated dashboard operator acts across identities, so this request // carries no identity to scope against -- the distinction the daemon's task // action service draws with a nil identity (internal/domain/taskactions). message ApplyOperatorTaskActionRequest { int64 task_id = 1; string action = 2; // actor_id is the identity that performed the action, as asserted by the // caller that verified the credential the request presented. actor_kind // travels beside it so the record can say an agent acted without a reader // resolving the identity. principal_id is the identity whose authority the // action used; empty means the action is recorded unattributed rather than // credited to the actor's own authority. All three are empty when the caller // has no verified identity, which is recorded as an unattributed action and // never as an operator's. string actor_id = 3; string actor_kind = 4; string principal_id = 5; // instructions and findings are the review gate answer payload // (taskactions.ActionPayload): the instructions a rereview requires, and // the finding keys an approve posts (empty means every offered finding). // They are empty for every other action. string instructions = 6; repeated string findings = 7; // retry_mode is the operator's worktree choice for a retry // (taskstate.RetryMode): refresh onto the base branch or continue the work // already pushed on the task's branch. It is empty for every other action, // and chat carries no mode syntax -- an empty value means refresh_onto_base. string retry_mode = 8; // resume_from is the stage a retry starts at; empty runs every stage. string resume_from = 9; // current_definition moves a retry onto the workflow's current stored // definition instead of the one the run is pinned to. bool current_definition = 10; } message ApplyOperatorTaskActionResponse { int64 task_id = 1; string action = 2; string message = 3; } message SaveSessionResponse {} message SaveSessionRequest { Session session = 1; } message GetSessionsByChannelRequest { string platform = 1; string channel_id = 2; } message GetSessionsByChannelResponse { repeated Session sessions = 1; } message ListSessionsResponse { repeated Session sessions = 1; } message DeleteSessionResponse {} message TouchSessionResponse {} message SaveMessageResponse {} message SaveMessagesResponse {} message ReplaceMessagesResponse {} message DeleteSessionRequest { string session_id = 1; } message TouchSessionRequest { string session_id = 1; } message ListSessionsRequest {} message SaveMessageRequest { string session_id = 1; Message message = 2; } message DeleteRecentMessagesRequest { string session_id = 1; int64 limit = 2; } message DeleteRecentMessagesResponse { int64 deleted = 1; } message MessageCountRequest { string session_id = 1; } message MessageCountResponse { int64 count = 1; } message SaveMessagesRequest { string session_id = 1; repeated Message messages = 2; } message ReplaceMessagesRequest { string session_id = 1; repeated Message messages = 2; repeated string superseded = 3; } message SearchMessagesRequest { string session_id = 1; string query = 2; int64 limit = 3; int64 offset = 4; } message SearchMessagesResponse { repeated Message messages = 1; int64 next_offset = 2; bool has_more = 3; bool truncated = 4; } // ListSkills reports the live skill catalogue the Gateway runs, as the // dashboard's Skills page shows it. source labels where each skill was // discovered (project, shared, user-global or stored). message ListSkillsRequest {} message ListSkillsResponse { repeated Skill skills = 1; } message Skill { string name = 1; string description = 2; string workflow = 3; string source = 4; } // CuratorHealth reports every registered curator's point-in-time health and // recent activity. last_run_at is absent for a curator that has never run. message CuratorHealthRequest {} message CuratorHealthResponse { repeated Curator curators = 1; } message Curator { string name = 1; string health_status = 2; string health_message = 3; optional google.protobuf.Timestamp last_run_at = 4; int64 last_run_actions = 5; repeated CuratorAction recent_actions = 6; } message CuratorAction { google.protobuf.Timestamp at = 1; string type = 2; string detail = 3; string reason = 4; } // ReloadChannel asks the process hosting a channel to re-read its // configuration. It is Unavailable from a Gateway that hosts no channels. message ReloadChannelRequest { string channel_id = 1; } message ReloadChannelResponse {} message RecentLogsRequest { logging.v1.LogQuery query = 1; string service = 2; } message RecentLogsResponse { logging.v1.LogSnapshot snapshot = 1; }