Skip to content

The agent that grows with you

fix(gateway): validate canonical shared-method wire contracts

David Dudok de Wit4d959d872650
diff --git a/apps/shared/src/gateway-contract.generated.ts b/apps/shared/src/gateway-contract.generated.ts
index d4d5bec3026..3672d3b4a96 100644
--- a/apps/shared/src/gateway-contract.generated.ts
+++ b/apps/shared/src/gateway-contract.generated.ts
@@ -4681,6 +4681,289 @@ export interface GroupsDiscardResult {
discarded?: boolean
task: RoomTaskReceipt
}
+export interface CanonicalCreateParams {
+ profile?: string | null
+ request_id?: string | null
+ source?: 'cli' | 'tui' | 'gui' | 'acp'
+ cwd?: string | null
+ model?: string | null
+ provider?: string | null
+ base_url?: string | null
+ api_key?: string | null
+ toolsets?: string[] | null
+ reasoning?: string | null
+ max_turns?: number | string | null
+ ignore_rules?: boolean
+ yolo?: boolean
+ safe_mode?: boolean
+ ignore_user_config?: boolean
+ editor?: Record<string, unknown> | null
+ title?: string | null
+ hidden?: boolean
+ follow_profile_config?: boolean | null
+}
+export interface CanonicalSnapshot {
+ session_id: string
+ stored_session_id: string
+ messages: TranscriptMessage[]
+ message_count: number
+ running: boolean
+ authority_epoch: number
+ replay_epoch: string
+ last_sequence: number
+ subscription_id: string
+ revision: number
+ execution_generation: number
+ pending: CanonicalPendingAdmission[]
+ prompts: CanonicalPendingPrompt[]
+ info: CanonicalSnapshotInfo
+}
+export interface CanonicalPendingAdmission {
+ admission_id: string
+ ref: CanonicalSessionRef
+ sequence: number
+ status: 'queued' | 'started' | 'unknown' | 'terminal'
+ outcome: string | null
+ authority_epoch: number
+ execution_generation: number | null
+ input_id: string
+ text: string
+}
+export interface CanonicalPendingPrompt {
+ kind: 'approval' | 'clarify'
+ prompt_id: string
+ execution_generation: number
+ choices: string[]
+ command?: string | null
+ description?: string | null
+ edit?: Record<string, unknown> | null
+ question?: string | null
+ multi_select?: boolean | null
+}
+export interface CanonicalSnapshotInfo {
+ desktop_protocol: 'hermes-gateway-v1'
+ source?: string | null
+ model?: string | null
+ lazy?: boolean | null
+ profile_id?: string | null
+ profile_name?: string | null
+ cwd?: string | null
+ launch_request?: Record<string, unknown> | null
+}
+export interface CanonicalResumeParams {
+ profile?: string | null
+ session_id?: string
+ title?: string | null
+ source?: string | null
+ editor?: Record<string, unknown> | null
+ defer_history?: boolean
+ omit_messages?: boolean
+ cols?: number | null
+}
+export interface CanonicalListParams {
+ profile?: string | null
+ limit?: number
+ title?: string | null
+ include_hidden?: boolean
+}
+export interface CanonicalListResult {
+ sessions: CanonicalSessionListRow[]
+ scope: 'stored' | 'live'
+}
+export interface CanonicalSessionListRow {
+ session_id: string
+ id: string
+ title: string
+ source: string | null
+ started_at: number | null
+ message_count: number
+ running: boolean
+ resolved_id?: string | null
+ root_title?: string | null
+}
+export interface CanonicalControlParams {
+ profile?: string | null
+ session_id: string
+ execution_generation: number
+}
+export interface CanonicalSessionHandle {
+ ref: CanonicalSessionRef
+ instance_id: string
+ authority_epoch: number
+ revision: number
+ execution_generation: number
+ execution_state: 'idle' | 'running' | 'waiting' | 'unknown' | 'terminal'
+}
+export interface CanonicalCorrectionParams {
+ profile?: string | null
+ session_id: string
+ execution_generation: number
+ text: string
+}
+export interface CanonicalCorrectionResult {
+ status: 'queued' | 'redirected' | 'rejected'
+ text: string
+ execution_generation: number
+ authority_epoch: number
+}
+export interface CanonicalEventsParams {
+ profile?: string | null
+ session_id: string
+ last_sequence?: number
+ last_seen?: number
+ replay_epoch?: string | null
+}
+export interface CanonicalEventsResult {
+ events: CanonicalReplayEvent[]
+ latest_seq: number
+ last_sequence: number
+ epoch: string
+ replay_epoch: string
+ truncated: boolean
+ snapshot_required: boolean
+ count: number
+}
+export interface CanonicalReplayEvent {
+ type: string
+ session_id: string
+ payload: Record<string, unknown>
+ replay_epoch: string
+ seq: number
+ authority_epoch?: number | null
+ execution_generation?: number | null
+ admission_id?: string | null
+}
+export interface CanonicalSubmitParams {
+ profile?: string | null
+ session_id: string
+ text: string
+ submission_id?: string | null
+ input_id?: string | null
+ queued?: boolean
+ attachments?: CanonicalAttachment[] | null
+ finite?: boolean
+ unattended?: boolean
+ surface?: string | null
+ voice_context?: string | null
+ interrupted?: boolean
+ voice_turn?: boolean
+}
+export interface CanonicalAttachment {
+ path: string
+ mime: string
+}
+export interface CanonicalApprovalParams {
+ profile?: string | null
+ session_id: string
+ execution_generation: number
+ prompt_id: string
+ choice: string
+}
+export interface CanonicalConfigGetResult {
+ value?: string | null
+ display?: string | null
+ tool_progress?: string | null
+ model?: string | null
+ provider?: string | null
+ providers?: ConfigProviderRef[] | null
+ home?: string | null
+ cwd?: string | null
+ branch?: string | null
+ config?: Record<string, unknown> | null
+ prompt?: string | null
+ mtime?: number | null
+ mcp_rev?: string | null
+ key?: string | null
+ scope?: string | null
+}
+export interface CanonicalConfigSetParams {
+ profile?: string | null
+ session_id: string
+ key: 'busy' | 'verbose' | 'yolo'
+ value?: unknown
+}
+export interface CanonicalProfilesParams {
+ profile?: string | null
+ include_sessions?: boolean
+}
+export interface CanonicalProfilesResult {
+ profiles: CanonicalProfileRow[]
+ bot_mode_protocol?: boolean
+ install_id?: string
+}
+export interface CanonicalProfileRow {
+ name: string
+ path: string
+ is_default?: boolean
+ model?: string | null
+ provider?: string | null
+ description?: string
+ display_name?: string
+ skill_count?: number
+ previous_names?: string[]
+ last_session?: ProfileCanonicalSession | null
+ worker_session?: ProfileWorkerSession | null
+ canonical_session?: ProfileCanonicalSession | null
+ ui_meta_revisions?: Record<string, number>
+ ui_meta?: Record<string, unknown> | null
+ has_avatar?: boolean
+}
+export interface CanonicalAttachedImageResult {
+ name?: string | null
+ width?: number | null
+ height?: number | null
+ token_estimate?: number | null
+ attached: boolean
+ path?: string | null
+ count?: number | null
+ remainder?: string | null
+ text?: string | null
+ bytes?: number | null
+ message?: string | null
+ mime: string
+}
+export interface CanonicalRoomAttemptParams {
+ profile?: string | null
+ room_id: string
+ member_id: string
+ task_id: string
+ execution_generation: number
+}
+export interface CanonicalRoomCreateParams {
+ profile?: string | null
+ room_id: string
+ name: string
+ members: RoomMemberInput[]
+}
+export interface CanonicalRoomApproveParams {
+ profile?: string | null
+ room_id: string
+ member_id: string
+ task_id: string
+ execution_generation: number
+ choice: 'once' | 'deny'
+ request_id: string
+}
+export interface CanonicalBotDeliverParams {
+ profile?: string | null
+ message: string
+ id: string
+ session_id?: string | null
+ author?: Record<string, unknown> | null
+ notification_category?: string | null
+}
+export interface CanonicalBotDeliverResult {
+ status: string
+ delivery_id: string
+ profile_home: string
+ session_id: string
+ admission_id: string
+ message: string
+ reply?: string | null
+ retry_admission_id?: string | null
+ error?: string | null
+ reason?: string | null
+}
/** ``answers`` rides only on a reconnect replay (locks the server already accepted; null = skipped). */
export interface ClarifyRequestParams {
session_id: string
@@ -6033,8 +6316,12 @@ export const RPC_METHODS = [
export interface CanonicalRpcMethods {
/** Forward one A2A input into the conversation its identity tuple names. */
'a2a.forward': { params: A2aForwardParams; result: A2aForwardResult }
+ 'approval.respond': { params: CanonicalApprovalParams; result: PromptResponseResult }
+ 'bot_relay.deliver': { params: CanonicalBotDeliverParams; result: CanonicalBotDeliverResult }
/** Generation-fenced answer to a pending clarify prompt (empty answer = skipped). */
'clarify.respond': { params: ClarifyRespondParams; result: PromptResponseResult }
+ 'config.get': { params: ConfigGetParams; result: CanonicalConfigGetResult }
+ 'config.set': { params: CanonicalConfigSetParams; result: ConfigSetResult }
/** Cancel a queued cron admission or latch cancellation on a started one. */
'cron.cancel': { params: CronAdmissionParams; result: CronCancelResult }
/** Re-observe a firing after a scheduler restart (same request identity). */
@@ -6043,28 +6330,41 @@ export interface CanonicalRpcMethods {
'cron.status': { params: CronAdmissionParams; result: CronStatusResult }
/** Admit one cron firing into the owning profile's durable FIFO. */
'cron.submit': { params: CronRunParams; result: CronSubmitResult }
+ 'groups.approve': { params: CanonicalRoomApproveParams; result: GroupsApproveResult }
/** Read one committed attachment for a live room viewer. */
'groups.attachment.download': { params: GroupsAttachmentDownloadParams; result: RoomAttachmentBytes }
/** Store one attachment for a later groups.send manifest (idempotent per upload_id). */
'groups.attachment.upload': { params: GroupsAttachmentUploadParams; result: RoomAttachment }
+ 'groups.create': { params: CanonicalRoomCreateParams; result: GroupsCreateResult }
/** Discard one indeterminate room task after explicit user confirmation. */
'groups.discard': { params: GroupsDiscardParams; result: GroupsDiscardResult }
+ 'groups.retry': { params: CanonicalRoomAttemptParams; result: GroupsRetryResult }
+ 'image.attach_bytes': { params: ImageAttachBytesParams; result: CanonicalAttachedImageResult }
/** Native-owner only: admit the dispatcher's current claim on a kanban task. */
'kanban.run': { params: KanbanRunParams; result: KanbanRunResult }
+ 'profiles.list': { params: CanonicalProfilesParams; result: CanonicalProfilesResult }
/** Retire a still-queued admission; a started one is unaffected. */
'prompt.cancel': { params: PromptCancelParams; result: AdmissionStatus }
/** Current receipt of one admission the caller submitted (or controls). */
'prompt.receipt': { params: PromptReceiptParams; result: PromptReceiptResult }
/** Acknowledge a turn lost across an owner restart; the FIFO behind it resumes. Never requeues the lost input. */
'prompt.resolve_unknown': { params: PromptResolveUnknownParams; result: AdmissionStatus }
+ 'prompt.submit': { params: CanonicalSubmitParams; result: AdmissionStatus }
/** Owner identity and the canonical capabilities a client may rely on. */
'runtime.describe': { params: RuntimeDescribeParams; result: RuntimeDescribeResult }
+ 'session.create': { params: CanonicalCreateParams; result: CanonicalSnapshot }
/** Drop this connection's subscription; a stale subscription id answers detached=false. */
'session.detach': { params: SessionDetachParams; result: SessionDetachResult }
+ 'session.events.since': { params: CanonicalEventsParams; result: CanonicalEventsResult }
/** Frozen launch policy projection of one local session. */
'session.info': { params: CanonicalSessionInfoParams; result: CanonicalSessionInfo }
+ 'session.interrupt': { params: CanonicalControlParams; result: CanonicalSessionHandle }
+ 'session.list': { params: CanonicalListParams; result: CanonicalListResult }
/** Revision-fenced, retry-idempotent session edit (rename, archive, sidebar, branch, delete, rewind, reset, model, compress, import). */
'session.mutate': { params: SessionMutateParams; result: SessionMutateResult }
+ 'session.redirect': { params: CanonicalCorrectionParams; result: CanonicalCorrectionResult }
+ 'session.resume': { params: CanonicalResumeParams; result: CanonicalSnapshot }
+ 'session.steer': { params: CanonicalCorrectionParams; result: CanonicalCorrectionResult }
/** Adopt a registered execution after verifying the live producer claim. */
'worker.adopt': { params: WorkerScopeParams; result: WorkerExecution }
/** Sequence-fenced typed persistence write from an adopted worker. */
@@ -6075,22 +6375,39 @@ export interface CanonicalRpcMethods {
export type CanonicalRpcMethod = keyof CanonicalRpcMethods
export const CANONICAL_RPC_METHODS = [
'a2a.forward',
+ 'approval.respond',
+ 'bot_relay.deliver',
'clarify.respond',
+ 'config.get',
+ 'config.set',
'cron.cancel',
'cron.recover',
'cron.status',
'cron.submit',
+ 'groups.approve',
'groups.attachment.download',
'groups.attachment.upload',
+ 'groups.create',
'groups.discard',
+ 'groups.retry',
+ 'image.attach_bytes',
'kanban.run',
+ 'profiles.list',
'prompt.cancel',
'prompt.receipt',
'prompt.resolve_unknown',
+ 'prompt.submit',
'runtime.describe',
+ 'session.create',
'session.detach',
+ 'session.events.since',
'session.info',
+ 'session.interrupt',
+ 'session.list',
'session.mutate',
+ 'session.redirect',
+ 'session.resume',
+ 'session.steer',
'worker.adopt',
'worker.persist',
'worker.register'
diff --git a/apps/shared/src/gateway-contract.openrpc.json b/apps/shared/src/gateway-contract.openrpc.json
index 7dfe0bde6eb..8778cb36e8b 100644
--- a/apps/shared/src/gateway-contract.openrpc.json
+++ b/apps/shared/src/gateway-contract.openrpc.json
@@ -7800,6 +7800,1748 @@
"title": "BrowserProgressPayload",
"type": "object"
},
+ "CanonicalApprovalParams": {
+ "additionalProperties": false,
+ "properties": {
+ "profile": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "default": null,
+ "title": "Profile"
+ },
+ "session_id": {
+ "title": "Session Id",
+ "type": "string"
+ },
+ "execution_generation": {
+ "title": "Execution Generation",
+ "type": "integer"
+ },
+ "prompt_id": {
+ "title": "Prompt Id",
+ "type": "string"
+ },
+ "choice": {
+ "title": "Choice",
+ "type": "string"
+ }
+ },
+ "required": [
+ "session_id",
+ "execution_generation",
+ "prompt_id",
+ "choice"
+ ],
+ "title": "CanonicalApprovalParams",
+ "type": "object"
+ },
+ "CanonicalAttachedImageResult": {
+ "additionalProperties": false,
+ "properties": {
+ "name": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "default": null,
+ "title": "Name"
+ },
+ "width": {
+ "anyOf": [
+ {
+ "type": "integer"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "default": null,
+ "title": "Width"
+ },
+ "height": {
+ "anyOf": [
+ {
+ "type": "integer"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "default": null,
+ "title": "Height"
+ },
+ "token_estimate": {
+ "anyOf": [
+ {
+ "type": "integer"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "default": null,
+ "title": "Token Estimate"
+ },
+ "attached": {
+ "title": "Attached",
+ "type": "boolean"
+ },
+ "path": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "default": null,
+ "title": "Path"
+ },
+ "count": {
+ "anyOf": [
+ {
+ "type": "integer"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "default": null,
+ "title": "Count"
+ },
+ "remainder": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "default": null,
+ "title": "Remainder"
+ },
+ "text": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "default": null,
+ "title": "Text"
+ },
+ "bytes": {
+ "anyOf": [
+ {
+ "type": "integer"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "default": null,
+ "title": "Bytes"
+ },
+ "message": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "default": null,
+ "title": "Message"
+ },
+ "mime": {
+ "title": "Mime",
+ "type": "string"
+ }
+ },
+ "required": [
+ "attached",
+ "mime"
+ ],
+ "title": "CanonicalAttachedImageResult",
+ "type": "object"
+ },
+ "CanonicalAttachment": {
+ "additionalProperties": false,
+ "properties": {
+ "path": {
+ "title": "Path",
+ "type": "string"
+ },
+ "mime": {
+ "title": "Mime",
+ "type": "string"
+ }
+ },
+ "required": [
+ "path",
+ "mime"
+ ],
+ "title": "CanonicalAttachment",
+ "type": "object"
+ },
+ "CanonicalBotDeliverParams": {
+ "additionalProperties": false,
+ "properties": {
+ "profile": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "default": null,
+ "title": "Profile"
+ },
+ "message": {
+ "title": "Message",
+ "type": "string"
+ },
+ "id": {
+ "title": "Id",
+ "type": "string"
+ },
+ "session_id": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "default": null,
+ "title": "Session Id"
+ },
+ "author": {
+ "anyOf": [
+ {
+ "additionalProperties": true,
+ "type": "object"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "default": null,
+ "title": "Author"
+ },
+ "notification_category": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "default": null,
+ "title": "Notification Category"
+ }
+ },
+ "required": [
+ "message",
+ "id"
+ ],
+ "title": "CanonicalBotDeliverParams",
+ "type": "object"
+ },
+ "CanonicalBotDeliverResult": {
+ "additionalProperties": false,
+ "properties": {
+ "status": {
+ "title": "Status",
+ "type": "string"
+ },
+ "delivery_id": {
+ "title": "Delivery Id",
+ "type": "string"
+ },
+ "profile_home": {
+ "title": "Profile Home",
+ "type": "string"
+ },
+ "session_id": {
+ "title": "Session Id",
+ "type": "string"
+ },
+ "admission_id": {
+ "title": "Admission Id",
+ "type": "string"
+ },
+ "message": {
+ "title": "Message",
+ "type": "string"
+ },
+ "reply": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "default": null,
+ "title": "Reply"
+ },
+ "retry_admission_id": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "default": null,
+ "title": "Retry Admission Id"
+ },
+ "error": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "default": null,
+ "title": "Error"
+ },
+ "reason": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "default": null,
+ "title": "Reason"
+ }
+ },
+ "required": [
+ "status",
+ "delivery_id",
+ "profile_home",
+ "session_id",
+ "admission_id",
+ "message"
+ ],
+ "title": "CanonicalBotDeliverResult",
+ "type": "object"
+ },
+ "CanonicalConfigGetResult": {
+ "additionalProperties": false,
+ "properties": {
+ "value": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "default": null,
+ "title": "Value"
+ },
+ "display": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "default": null,
+ "title": "Display"
+ },
+ "tool_progress": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "default": null,
+ "title": "Tool Progress"
+ },
+ "model": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "default": null,
+ "title": "Model"
+ },
+ "provider": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "default": null,
+ "title": "Provider"
+ },
+ "providers": {
+ "anyOf": [
+ {
+ "items": {
+ "$ref": "#/components/schemas/ConfigProviderRef"
+ },
+ "type": "array"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "default": null,
+ "title": "Providers"
+ },
+ "home": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "default": null,
+ "title": "Home"
+ },
+ "cwd": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "default": null,
+ "title": "Cwd"
+ },
+ "branch": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "default": null,
+ "title": "Branch"
+ },
+ "config": {
+ "anyOf": [
+ {
+ "additionalProperties": true,
+ "type": "object"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "default": null,
+ "title": "Config"
+ },
+ "prompt": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "default": null,
+ "title": "Prompt"
+ },
+ "mtime": {
+ "anyOf": [
+ {
+ "type": "number"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "default": null,
+ "title": "Mtime"
+ },
+ "mcp_rev": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "default": null,
+ "title": "Mcp Rev"
+ },
+ "key": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "default": null,
+ "title": "Key"
+ },
+ "scope": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "default": null,
+ "title": "Scope"
+ }
+ },
+ "title": "CanonicalConfigGetResult",
+ "type": "object"
+ },
+ "CanonicalConfigSetParams": {
+ "additionalProperties": false,
+ "properties": {
+ "profile": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "default": null,
+ "title": "Profile"
+ },
+ "session_id": {
+ "title": "Session Id",
+ "type": "string"
+ },
+ "key": {
+ "enum": [
+ "busy",
+ "verbose",
+ "yolo"
+ ],
+ "title": "Key",
+ "type": "string"
+ },
+ "value": {
+ "default": null,
+ "title": "Value"
+ }
+ },
+ "required": [
+ "session_id",
+ "key"
+ ],
+ "title": "CanonicalConfigSetParams",
+ "type": "object"
+ },
+ "CanonicalControlParams": {
+ "additionalProperties": false,
+ "properties": {
+ "profile": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "default": null,
+ "title": "Profile"
+ },
+ "session_id": {
+ "title": "Session Id",
+ "type": "string"
+ },
+ "execution_generation": {
+ "title": "Execution Generation",
+ "type": "integer"
+ }
+ },
+ "required": [
+ "session_id",
+ "execution_generation"
+ ],
+ "title": "CanonicalControlParams",
+ "type": "object"
+ },
+ "CanonicalCorrectionParams": {
+ "additionalProperties": false,
+ "properties": {
+ "profile": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "default": null,
+ "title": "Profile"
+ },
+ "session_id": {
+ "title": "Session Id",
+ "type": "string"
+ },
+ "execution_generation": {
+ "title": "Execution Generation",
+ "type": "integer"
+ },
+ "text": {
+ "title": "Text",
+ "type": "string"
+ }
+ },
+ "required": [
+ "session_id",
+ "execution_generation",
+ "text"
+ ],
+ "title": "CanonicalCorrectionParams",
+ "type": "object"
+ },
+ "CanonicalCorrectionResult": {
+ "additionalProperties": false,
+ "properties": {
+ "status": {
+ "enum": [
+ "queued",
+ "redirected",
+ "rejected"
+ ],
+ "title": "Status",
+ "type": "string"
+ },
+ "text": {
+ "title": "Text",
+ "type": "string"
+ },
+ "execution_generation": {
+ "title": "Execution Generation",
+ "type": "integer"
+ },
+ "authority_epoch": {
+ "title": "Authority Epoch",
+ "type": "integer"
+ }
+ },
+ "required": [
+ "status",
+ "text",
+ "execution_generation",
+ "authority_epoch"
+ ],
+ "title": "CanonicalCorrectionResult",
+ "type": "object"
+ },
+ "CanonicalCreateParams": {
+ "additionalProperties": false,
+ "properties": {
+ "profile": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "default": null,
+ "title": "Profile"
+ },
+ "request_id": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "default": null,
+ "title": "Request Id"
+ },
+ "source": {
+ "default": "cli",
+ "enum": [
+ "cli",
+ "tui",
+ "gui",
+ "acp"
+ ],
+ "title": "Source",
+ "type": "string"
+ },
+ "cwd": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "default": null,
+ "title": "Cwd"
+ },
+ "model": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "default": null,
+ "title": "Model"
+ },
+ "provider": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "default": null,
+ "title": "Provider"
+ },
+ "base_url": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "default": null,
+ "title": "Base Url"
+ },
+ "api_key": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "default": null,
+ "title": "Api Key"
+ },
+ "toolsets": {
+ "anyOf": [
+ {
+ "items": {
+ "type": "string"
+ },
+ "type": "array"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "default": null,
+ "title": "Toolsets"
+ },
+ "reasoning": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "default": null,
+ "title": "Reasoning"
+ },
+ "max_turns": {
+ "anyOf": [
+ {
+ "type": "integer"
+ },
+ {
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "default": null,
+ "title": "Max Turns"
+ },
+ "ignore_rules": {
+ "default": false,
+ "title": "Ignore Rules",
+ "type": "boolean"
+ },
+ "yolo": {
+ "default": false,
+ "title": "Yolo",
+ "type": "boolean"
+ },
+ "safe_mode": {
+ "default": false,
+ "title": "Safe Mode",
+ "type": "boolean"
+ },
+ "ignore_user_config": {
+ "default": false,
+ "title": "Ignore User Config",
+ "type": "boolean"
+ },
+ "editor": {
+ "anyOf": [
+ {
+ "additionalProperties": true,
+ "type": "object"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "default": null,
+ "title": "Editor"
+ },
+ "title": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "default": null,
+ "title": "Title"
+ },
+ "hidden": {
+ "default": false,
+ "title": "Hidden",
+ "type": "boolean"
+ },
+ "follow_profile_config": {
+ "anyOf": [
+ {
+ "type": "boolean"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "default": null,
+ "title": "Follow Profile Config"
+ }
+ },
+ "title": "CanonicalCreateParams",
+ "type": "object"
+ },
+ "CanonicalEventsParams": {
+ "additionalProperties": false,
+ "properties": {
+ "profile": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "default": null,
+ "title": "Profile"
+ },
+ "session_id": {
+ "title": "Session Id",
+ "type": "string"
+ },
+ "last_sequence": {
+ "default": 0,
+ "title": "Last Sequence",
+ "type": "integer"
+ },
+ "last_seen": {
+ "default": 0,
+ "title": "Last Seen",
+ "type": "integer"
+ },
+ "replay_epoch": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "default": null,
+ "title": "Replay Epoch"
+ }
+ },
+ "required": [
+ "session_id"
+ ],
+ "title": "CanonicalEventsParams",
+ "type": "object"
+ },
+ "CanonicalEventsResult": {
+ "additionalProperties": false,
+ "properties": {
+ "events": {
+ "items": {
+ "$ref": "#/components/schemas/CanonicalReplayEvent"
+ },
+ "title": "Events",
+ "type": "array"
+ },
+ "latest_seq": {
+ "title": "Latest Seq",
+ "type": "integer"
+ },
+ "last_sequence": {
+ "title": "Last Sequence",
+ "type": "integer"
+ },
+ "epoch": {
+ "title": "Epoch",
+ "type": "string"
+ },
+ "replay_epoch": {
+ "title": "Replay Epoch",
+ "type": "string"
+ },
+ "truncated": {
+ "title": "Truncated",
+ "type": "boolean"
+ },
+ "snapshot_required": {
+ "title": "Snapshot Required",
+ "type": "boolean"
+ },
+ "count": {
+ "title": "Count",
+ "type": "integer"
+ }
+ },
+ "required": [
+ "events",
+ "latest_seq",
+ "last_sequence",
+ "epoch",
+ "replay_epoch",
+ "truncated",
+ "snapshot_required",
+ "count"
+ ],
+ "title": "CanonicalEventsResult",
+ "type": "object"
+ },
+ "CanonicalListParams": {
+ "additionalProperties": false,
+ "properties": {
+ "profile": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "default": null,
+ "title": "Profile"
+ },
+ "limit": {
+ "default": 200,
+ "title": "Limit",
+ "type": "integer"
+ },
+ "title": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "default": null,
+ "title": "Title"
+ },
+ "include_hidden": {
+ "default": false,
+ "title": "Include Hidden",
+ "type": "boolean"
+ }
+ },
+ "title": "CanonicalListParams",
+ "type": "object"
+ },
+ "CanonicalListResult": {
+ "additionalProperties": false,
+ "properties": {
+ "sessions": {
+ "items": {
+ "$ref": "#/components/schemas/CanonicalSessionListRow"
+ },
+ "title": "Sessions",
+ "type": "array"
+ },
+ "scope": {
+ "enum": [
+ "stored",
+ "live"
+ ],
+ "title": "Scope",
+ "type": "string"
+ }
+ },
+ "required": [
+ "sessions",
+ "scope"
+ ],
+ "title": "CanonicalListResult",
+ "type": "object"
+ },
+ "CanonicalPendingAdmission": {
+ "additionalProperties": false,
+ "properties": {
+ "admission_id": {
+ "title": "Admission Id",
+ "type": "string"
+ },
+ "ref": {
+ "$ref": "#/components/schemas/CanonicalSessionRef"
+ },
+ "sequence": {
+ "title": "Sequence",
+ "type": "integer"
+ },
+ "status": {
+ "enum": [
+ "queued",
+ "started",
+ "unknown",
+ "terminal"
+ ],
+ "title": "Status",
+ "type": "string"
+ },
+ "outcome": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "title": "Outcome"
+ },
+ "authority_epoch": {
+ "title": "Authority Epoch",
+ "type": "integer"
+ },
+ "execution_generation": {
+ "anyOf": [
+ {
+ "type": "integer"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "title": "Execution Generation"
+ },
+ "input_id": {
+ "title": "Input Id",
+ "type": "string"
+ },
+ "text": {
+ "title": "Text",
+ "type": "string"
+ }
+ },
+ "required": [
+ "admission_id",
+ "ref",
+ "sequence",
+ "status",
+ "outcome",
+ "authority_epoch",
+ "execution_generation",
+ "input_id",
+ "text"
+ ],
+ "title": "CanonicalPendingAdmission",
+ "type": "object"
+ },
+ "CanonicalPendingPrompt": {
+ "additionalProperties": false,
+ "properties": {
+ "kind": {
+ "enum": [
+ "approval",
+ "clarify"
+ ],
+ "title": "Kind",
+ "type": "string"
+ },
+ "prompt_id": {
+ "title": "Prompt Id",
+ "type": "string"
+ },
+ "execution_generation": {
+ "title": "Execution Generation",
+ "type": "integer"
+ },
+ "choices": {
+ "items": {
+ "type": "string"
+ },
+ "title": "Choices",
+ "type": "array"
+ },
+ "command": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "default": null,
+ "title": "Command"
+ },
+ "description": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "default": null,
+ "title": "Description"
+ },
+ "edit": {
+ "anyOf": [
+ {
+ "additionalProperties": true,
+ "type": "object"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "default": null,
+ "title": "Edit"
+ },
+ "question": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "default": null,
+ "title": "Question"
+ },
+ "multi_select": {
+ "anyOf": [
+ {
+ "type": "boolean"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "default": null,
+ "title": "Multi Select"
+ }
+ },
+ "required": [
+ "kind",
+ "prompt_id",
+ "execution_generation",
+ "choices"
+ ],
+ "title": "CanonicalPendingPrompt",
+ "type": "object"
+ },
+ "CanonicalProfileRow": {
+ "additionalProperties": false,
+ "properties": {
+ "name": {
+ "title": "Name",
+ "type": "string"
+ },
+ "path": {
+ "title": "Path",
+ "type": "string"
+ },
+ "is_default": {
+ "default": false,
+ "title": "Is Default",
+ "type": "boolean"
+ },
+ "model": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "default": null,
+ "title": "Model"
+ },
+ "provider": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "default": null,
+ "title": "Provider"
+ },
+ "description": {
+ "default": "",
+ "title": "Description",
+ "type": "string"
+ },
+ "display_name": {
+ "default": "",
+ "title": "Display Name",
+ "type": "string"
+ },
+ "skill_count": {
+ "default": 0,
+ "title": "Skill Count",
+ "type": "integer"
+ },
+ "previous_names": {
+ "items": {
+ "type": "string"
+ },
+ "title": "Previous Names",
+ "type": "array"
+ },
+ "last_session": {
+ "anyOf": [
+ {
+ "$ref": "#/components/schemas/ProfileCanonicalSession"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "default": null
+ },
+ "worker_session": {
+ "anyOf": [
+ {
+ "$ref": "#/components/schemas/ProfileWorkerSession"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "default": null
+ },
+ "canonical_session": {
+ "anyOf": [
+ {
+ "$ref": "#/components/schemas/ProfileCanonicalSession"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "default": null
+ },
+ "ui_meta_revisions": {
+ "additionalProperties": {
+ "type": "integer"
+ },
+ "title": "Ui Meta Revisions",
+ "type": "object"
+ },
+ "ui_meta": {
+ "anyOf": [
+ {
+ "additionalProperties": true,
+ "type": "object"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "default": null,
+ "title": "Ui Meta"
+ },
+ "has_avatar": {
+ "default": false,
+ "title": "Has Avatar",
+ "type": "boolean"
+ }
+ },
+ "required": [
+ "name",
+ "path"
+ ],
+ "title": "CanonicalProfileRow",
+ "type": "object"
+ },
+ "CanonicalProfilesParams": {
+ "additionalProperties": false,
+ "properties": {
+ "profile": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "default": null,
+ "title": "Profile"
+ },
+ "include_sessions": {
+ "default": true,
+ "title": "Include Sessions",
+ "type": "boolean"
+ }
+ },
+ "title": "CanonicalProfilesParams",
+ "type": "object"
+ },
+ "CanonicalProfilesResult": {
+ "additionalProperties": false,
+ "properties": {
+ "profiles": {
+ "items": {
+ "$ref": "#/components/schemas/CanonicalProfileRow"
+ },
+ "title": "Profiles",
+ "type": "array"
+ },
+ "bot_mode_protocol": {
+ "default": true,
+ "title": "Bot Mode Protocol",
+ "type": "boolean"
+ },
+ "install_id": {
+ "default": "",
+ "title": "Install Id",
+ "type": "string"
+ }
+ },
+ "required": [
+ "profiles"
+ ],
+ "title": "CanonicalProfilesResult",
+ "type": "object"
+ },
+ "CanonicalReplayEvent": {
+ "additionalProperties": false,
+ "properties": {
+ "type": {
+ "title": "Type",
+ "type": "string"
+ },
+ "session_id": {
+ "title": "Session Id",
+ "type": "string"
+ },
+ "payload": {
+ "additionalProperties": true,
+ "title": "Payload",
+ "type": "object"
+ },
+ "replay_epoch": {
+ "title": "Replay Epoch",
+ "type": "string"
+ },
+ "seq": {
+ "title": "Seq",
+ "type": "integer"
+ },
+ "authority_epoch": {
+ "anyOf": [
+ {
+ "type": "integer"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "default": null,
+ "title": "Authority Epoch"
+ },
+ "execution_generation": {
+ "anyOf": [
+ {
+ "type": "integer"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "default": null,
+ "title": "Execution Generation"
+ },
+ "admission_id": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "default": null,
+ "title": "Admission Id"
+ }
+ },
+ "required": [
+ "type",
+ "session_id",
+ "payload",
+ "replay_epoch",
+ "seq"
+ ],
+ "title": "CanonicalReplayEvent",
+ "type": "object"
+ },
+ "CanonicalResumeParams": {
+ "additionalProperties": false,
+ "properties": {
+ "profile": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "default": null,
+ "title": "Profile"
+ },
+ "session_id": {
+ "default": "",
+ "title": "Session Id",
+ "type": "string"
+ },
+ "title": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "default": null,
+ "title": "Title"
+ },
+ "source": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "default": null,
+ "title": "Source"
+ },
+ "editor": {
+ "anyOf": [
+ {
+ "additionalProperties": true,
+ "type": "object"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "default": null,
+ "title": "Editor"
+ },
+ "defer_history": {
+ "default": false,
+ "title": "Defer History",
+ "type": "boolean"
+ },
+ "omit_messages": {
+ "default": false,
+ "title": "Omit Messages",
+ "type": "boolean"
+ },
+ "cols": {
+ "anyOf": [
+ {
+ "type": "integer"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "default": null,
+ "title": "Cols"
+ }
+ },
+ "title": "CanonicalResumeParams",
+ "type": "object"
+ },
+ "CanonicalRoomApproveParams": {
+ "additionalProperties": false,
+ "properties": {
+ "profile": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "default": null,
+ "title": "Profile"
+ },
+ "room_id": {
+ "title": "Room Id",
+ "type": "string"
+ },
+ "member_id": {
+ "title": "Member Id",
+ "type": "string"
+ },
+ "task_id": {
+ "title": "Task Id",
+ "type": "string"
+ },
+ "execution_generation": {
+ "title": "Execution Generation",
+ "type": "integer"
+ },
+ "choice": {
+ "enum": [
+ "once",
+ "deny"
+ ],
+ "title": "Choice",
+ "type": "string"
+ },
+ "request_id": {
+ "title": "Request Id",
+ "type": "string"
+ }
+ },
+ "required": [
+ "room_id",
+ "member_id",
+ "task_id",
+ "execution_generation",
+ "choice",
+ "request_id"
+ ],
+ "title": "CanonicalRoomApproveParams",
+ "type": "object"
+ },
+ "CanonicalRoomAttemptParams": {
+ "additionalProperties": false,
+ "properties": {
+ "profile": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "default": null,
+ "title": "Profile"
+ },
+ "room_id": {
+ "title": "Room Id",
+ "type": "string"
+ },
+ "member_id": {
+ "title": "Member Id",
+ "type": "string"
+ },
+ "task_id": {
+ "title": "Task Id",
+ "type": "string"
+ },
+ "execution_generation": {
+ "title": "Execution Generation",
+ "type": "integer"
+ }
+ },
+ "required": [
+ "room_id",
+ "member_id",
+ "task_id",
+ "execution_generation"
+ ],
+ "title": "CanonicalRoomAttemptParams",
+ "type": "object"
+ },
+ "CanonicalRoomCreateParams": {
+ "additionalProperties": false,
+ "properties": {
+ "profile": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "default": null,
+ "title": "Profile"
+ },
+ "room_id": {
+ "title": "Room Id",
+ "type": "string"
+ },
+ "name": {
+ "title": "Name",
+ "type": "string"
+ },
+ "members": {
+ "items": {
+ "$ref": "#/components/schemas/RoomMemberInput"
+ },
+ "title": "Members",
+ "type": "array"
+ }
+ },
+ "required": [
+ "room_id",
+ "name",
+ "members"
+ ],
+ "title": "CanonicalRoomCreateParams",
+ "type": "object"
+ },
+ "CanonicalSessionHandle": {
+ "additionalProperties": false,
+ "properties": {
+ "ref": {
+ "$ref": "#/components/schemas/CanonicalSessionRef"
+ },
+ "instance_id": {
+ "title": "Instance Id",
+ "type": "string"
+ },
+ "authority_epoch": {
+ "title": "Authority Epoch",
+ "type": "integer"
+ },
+ "revision": {
+ "title": "Revision",
+ "type": "integer"
+ },
+ "execution_generation": {
+ "title": "Execution Generation",
+ "type": "integer"
+ },
+ "execution_state": {
+ "enum": [
+ "idle",
+ "running",
+ "waiting",
+ "unknown",
+ "terminal"
+ ],
+ "title": "Execution State",
+ "type": "string"
+ }
+ },
+ "required": [
+ "ref",
+ "instance_id",
+ "authority_epoch",
+ "revision",
+ "execution_generation",
+ "execution_state"
+ ],
+ "title": "CanonicalSessionHandle",
+ "type": "object"
+ },
"CanonicalSessionInfo": {
"additionalProperties": true,
"description": "``gateway/session_local.py::local_session_info``.",
@@ -7886,6 +9628,88 @@
"title": "CanonicalSessionInfoParams",
"type": "object"
},
+ "CanonicalSessionListRow": {
+ "additionalProperties": false,
+ "properties": {
+ "session_id": {
+ "title": "Session Id",
+ "type": "string"
+ },
+ "id": {
+ "title": "Id",
+ "type": "string"
+ },
+ "title": {
+ "title": "Title",
+ "type": "string"
+ },
+ "source": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "title": "Source"
+ },
+ "started_at": {
+ "anyOf": [
+ {
+ "type": "number"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "title": "Started At"
+ },
+ "message_count": {
+ "title": "Message Count",
+ "type": "integer"
+ },
+ "running": {
+ "title": "Running",
+ "type": "boolean"
+ },
+ "resolved_id": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "default": null,
+ "title": "Resolved Id"
+ },
+ "root_title": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "default": null,
+ "title": "Root Title"
+ }
+ },
+ "required": [
+ "session_id",
+ "id",
+ "title",
+ "source",
+ "started_at",
+ "message_count",
+ "running"
+ ],
+ "title": "CanonicalSessionListRow",
+ "type": "object"
+ },
"CanonicalSessionRef": {
"additionalProperties": false,
"properties": {
@@ -7905,6 +9729,312 @@
"title": "CanonicalSessionRef",
"type": "object"
},
+ "CanonicalSnapshot": {
+ "additionalProperties": false,
+ "properties": {
+ "session_id": {
+ "title": "Session Id",
+ "type": "string"
+ },
+ "stored_session_id": {
+ "title": "Stored Session Id",
+ "type": "string"
+ },
+ "messages": {
+ "items": {
+ "$ref": "#/components/schemas/TranscriptMessage"
+ },
+ "title": "Messages",
+ "type": "array"
+ },
+ "message_count": {
+ "title": "Message Count",
+ "type": "integer"
+ },
+ "running": {
+ "title": "Running",
+ "type": "boolean"
+ },
+ "authority_epoch": {
+ "title": "Authority Epoch",
+ "type": "integer"
+ },
+ "replay_epoch": {
+ "title": "Replay Epoch",
+ "type": "string"
+ },
+ "last_sequence": {
+ "title": "Last Sequence",
+ "type": "integer"
+ },
+ "subscription_id": {
+ "title": "Subscription Id",
+ "type": "string"
+ },
+ "revision": {
+ "title": "Revision",
+ "type": "integer"
+ },
+ "execution_generation": {
+ "title": "Execution Generation",
+ "type": "integer"
+ },
+ "pending": {
+ "items": {
+ "$ref": "#/components/schemas/CanonicalPendingAdmission"
+ },
+ "title": "Pending",
+ "type": "array"
+ },
+ "prompts": {
+ "items": {
+ "$ref": "#/components/schemas/CanonicalPendingPrompt"
+ },
+ "title": "Prompts",
+ "type": "array"
+ },
+ "info": {
+ "$ref": "#/components/schemas/CanonicalSnapshotInfo"
+ }
+ },
+ "required": [
+ "session_id",
+ "stored_session_id",
+ "messages",
+ "message_count",
+ "running",
+ "authority_epoch",
+ "replay_epoch",
+ "last_sequence",
+ "subscription_id",
+ "revision",
+ "execution_generation",
+ "pending",
+ "prompts",
+ "info"
+ ],
+ "title": "CanonicalSnapshot",
+ "type": "object"
+ },
+ "CanonicalSnapshotInfo": {
+ "additionalProperties": false,
+ "properties": {
+ "desktop_protocol": {
+ "const": "hermes-gateway-v1",
+ "title": "Desktop Protocol",
+ "type": "string"
+ },
+ "source": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "default": null,
+ "title": "Source"
+ },
+ "model": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "default": null,
+ "title": "Model"
+ },
+ "lazy": {
+ "anyOf": [
+ {
+ "type": "boolean"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "default": null,
+ "title": "Lazy"
+ },
+ "profile_id": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "default": null,
+ "title": "Profile Id"
+ },
+ "profile_name": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "default": null,
+ "title": "Profile Name"
+ },
+ "cwd": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "default": null,
+ "title": "Cwd"
+ },
+ "launch_request": {
+ "anyOf": [
+ {
+ "additionalProperties": true,
+ "type": "object"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "default": null,
+ "title": "Launch Request"
+ }
+ },
+ "required": [
+ "desktop_protocol"
+ ],
+ "title": "CanonicalSnapshotInfo",
+ "type": "object"
+ },
+ "CanonicalSubmitParams": {
+ "additionalProperties": false,
+ "properties": {
+ "profile": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "default": null,
+ "title": "Profile"
+ },
+ "session_id": {
+ "title": "Session Id",
+ "type": "string"
+ },
+ "text": {
+ "title": "Text",
+ "type": "string"
+ },
+ "submission_id": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "default": null,
+ "title": "Submission Id"
+ },
+ "input_id": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "default": null,
+ "title": "Input Id"
+ },
+ "queued": {
+ "default": false,
+ "title": "Queued",
+ "type": "boolean"
+ },
+ "attachments": {
+ "anyOf": [
+ {
+ "items": {
+ "$ref": "#/components/schemas/CanonicalAttachment"
+ },
+ "type": "array"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "default": null,
+ "title": "Attachments"
+ },
+ "finite": {
+ "default": false,
+ "title": "Finite",
+ "type": "boolean"
+ },
+ "unattended": {
+ "default": false,
+ "title": "Unattended",
+ "type": "boolean"
+ },
+ "surface": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "default": null,
+ "title": "Surface"
+ },
+ "voice_context": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "default": null,
+ "title": "Voice Context"
+ },
+ "interrupted": {
+ "default": false,
+ "title": "Interrupted",
+ "type": "boolean"
+ },
+ "voice_turn": {
+ "default": false,
+ "title": "Voice Turn",
+ "type": "boolean"
+ }
+ },
+ "required": [
+ "session_id",
+ "text"
+ ],
+ "title": "CanonicalSubmitParams",
+ "type": "object"
+ },
"CapabilityEntry": {
"additionalProperties": false,
"properties": {
@@ -41461,6 +43591,42 @@
}
}
},
+ {
+ "name": "approval.respond",
+ "summary": "",
+ "params": [
+ {
+ "name": "params",
+ "schema": {
+ "$ref": "#/components/schemas/CanonicalApprovalParams"
+ }
+ }
+ ],
+ "result": {
+ "name": "result",
+ "schema": {
+ "$ref": "#/components/schemas/PromptResponseResult"
+ }
+ }
+ },
+ {
+ "name": "bot_relay.deliver",
+ "summary": "",
+ "params": [
+ {
+ "name": "params",
+ "schema": {
+ "$ref": "#/components/schemas/CanonicalBotDeliverParams"
+ }
+ }
+ ],
+ "result": {
+ "name": "result",
+ "schema": {
+ "$ref": "#/components/schemas/CanonicalBotDeliverResult"
+ }
+ }
+ },
{
"name": "clarify.respond",
"summary": "Generation-fenced answer to a pending clarify prompt (empty answer = skipped).",
@@ -41479,6 +43645,42 @@
}
}
},
+ {
+ "name": "config.get",
+ "summary": "",
+ "params": [
+ {
+ "name": "params",
+ "schema": {
+ "$ref": "#/components/schemas/ConfigGetParams"
+ }
+ }
+ ],
+ "result": {
+ "name": "result",
+ "schema": {
+ "$ref": "#/components/schemas/CanonicalConfigGetResult"
+ }
+ }
+ },
+ {
+ "name": "config.set",
+ "summary": "",
+ "params": [
+ {
+ "name": "params",
+ "schema": {
+ "$ref": "#/components/schemas/CanonicalConfigSetParams"
+ }
+ }
+ ],
+ "result": {
+ "name": "result",
+ "schema": {
+ "$ref": "#/components/schemas/ConfigSetResult"
+ }
+ }
+ },
{
"name": "cron.cancel",
"summary": "Cancel a queued cron admission or latch cancellation on a started one.",
@@ -41551,6 +43753,24 @@
}
}
},
+ {
+ "name": "groups.approve",
+ "summary": "",
+ "params": [
+ {
+ "name": "params",
+ "schema": {
+ "$ref": "#/components/schemas/CanonicalRoomApproveParams"
+ }
+ }
+ ],
+ "result": {
+ "name": "result",
+ "schema": {
+ "$ref": "#/components/schemas/GroupsApproveResult"
+ }
+ }
+ },
{
"name": "groups.attachment.download",
"summary": "Read one committed attachment for a live room viewer.",
@@ -41587,6 +43807,24 @@
}
}
},
+ {
+ "name": "groups.create",
+ "summary": "",
+ "params": [
+ {
+ "name": "params",
+ "schema": {
+ "$ref": "#/components/schemas/CanonicalRoomCreateParams"
+ }
+ }
+ ],
+ "result": {
+ "name": "result",
+ "schema": {
+ "$ref": "#/components/schemas/GroupsCreateResult"
+ }
+ }
+ },
{
"name": "groups.discard",
"summary": "Discard one indeterminate room task after explicit user confirmation.",
@@ -41605,6 +43843,42 @@
}
}
},
+ {
+ "name": "groups.retry",
+ "summary": "",
+ "params": [
+ {
+ "name": "params",
+ "schema": {
+ "$ref": "#/components/schemas/CanonicalRoomAttemptParams"
+ }
+ }
+ ],
+ "result": {
+ "name": "result",
+ "schema": {
+ "$ref": "#/components/schemas/GroupsRetryResult"
+ }
+ }
+ },
+ {
+ "name": "image.attach_bytes",
+ "summary": "",
+ "params": [
+ {
+ "name": "params",
+ "schema": {
+ "$ref": "#/components/schemas/ImageAttachBytesParams"
+ }
+ }
+ ],
+ "result": {
+ "name": "result",
+ "schema": {
+ "$ref": "#/components/schemas/CanonicalAttachedImageResult"
+ }
+ }
+ },
{
"name": "kanban.run",
"summary": "Native-owner only: admit the dispatcher's current claim on a kanban task.",
@@ -41623,6 +43897,24 @@
}
}
},
+ {
+ "name": "profiles.list",
+ "summary": "",
+ "params": [
+ {
+ "name": "params",
+ "schema": {
+ "$ref": "#/components/schemas/CanonicalProfilesParams"
+ }
+ }
+ ],
+ "result": {
+ "name": "result",
+ "schema": {
+ "$ref": "#/components/schemas/CanonicalProfilesResult"
+ }
+ }
+ },
{
"name": "prompt.cancel",
"summary": "Retire a still-queued admission; a started one is unaffected.",
@@ -41677,6 +43969,24 @@
}
}
},
+ {
+ "name": "prompt.submit",
+ "summary": "",
+ "params": [
+ {
+ "name": "params",
+ "schema": {
+ "$ref": "#/components/schemas/CanonicalSubmitParams"
+ }
+ }
+ ],
+ "result": {
+ "name": "result",
+ "schema": {
+ "$ref": "#/components/schemas/AdmissionStatus"
+ }
+ }
+ },
{
"name": "runtime.describe",
"summary": "Owner identity and the canonical capabilities a client may rely on.",
@@ -41695,6 +44005,24 @@
}
}
},
+ {
+ "name": "session.create",
+ "summary": "",
+ "params": [
+ {
+ "name": "params",
+ "schema": {
+ "$ref": "#/components/schemas/CanonicalCreateParams"
+ }
+ }
+ ],
+ "result": {
+ "name": "result",
+ "schema": {
+ "$ref": "#/components/schemas/CanonicalSnapshot"
+ }
+ }
+ },
{
"name": "session.detach",
"summary": "Drop this connection's subscription; a stale subscription id answers detached=false.",
@@ -41713,6 +44041,24 @@
}
}
},
+ {
+ "name": "session.events.since",
+ "summary": "",
+ "params": [
+ {
+ "name": "params",
+ "schema": {
+ "$ref": "#/components/schemas/CanonicalEventsParams"
+ }
+ }
+ ],
+ "result": {
+ "name": "result",
+ "schema": {
+ "$ref": "#/components/schemas/CanonicalEventsResult"
+ }
+ }
+ },
{
"name": "session.info",
"summary": "Frozen launch policy projection of one local session.",
@@ -41731,6 +44077,42 @@
}
}
},
+ {
+ "name": "session.interrupt",
+ "summary": "",
+ "params": [
+ {
+ "name": "params",
+ "schema": {
+ "$ref": "#/components/schemas/CanonicalControlParams"
+ }
+ }
+ ],
+ "result": {
+ "name": "result",
+ "schema": {
+ "$ref": "#/components/schemas/CanonicalSessionHandle"
+ }
+ }
+ },
+ {
+ "name": "session.list",
+ "summary": "",
+ "params": [
+ {
+ "name": "params",
+ "schema": {
+ "$ref": "#/components/schemas/CanonicalListParams"
+ }
+ }
+ ],
+ "result": {
+ "name": "result",
+ "schema": {
+ "$ref": "#/components/schemas/CanonicalListResult"
+ }
+ }
+ },
{
"name": "session.mutate",
"summary": "Revision-fenced, retry-idempotent session edit (rename, archive, sidebar, branch, delete, rewind, reset, model, compress, import).",
@@ -41749,6 +44131,60 @@
}
}
},
+ {
+ "name": "session.redirect",
+ "summary": "",
+ "params": [
+ {
+ "name": "params",
+ "schema": {
+ "$ref": "#/components/schemas/CanonicalCorrectionParams"
+ }
+ }
+ ],
+ "result": {
+ "name": "result",
+ "schema": {
+ "$ref": "#/components/schemas/CanonicalCorrectionResult"
+ }
+ }
+ },
+ {
+ "name": "session.resume",
+ "summary": "",
+ "params": [
+ {
+ "name": "params",
+ "schema": {
+ "$ref": "#/components/schemas/CanonicalResumeParams"
+ }
+ }
+ ],
+ "result": {
+ "name": "result",
+ "schema": {
+ "$ref": "#/components/schemas/CanonicalSnapshot"
+ }
+ }
+ },
+ {
+ "name": "session.steer",
+ "summary": "",
+ "params": [
+ {
+ "name": "params",
+ "schema": {
+ "$ref": "#/components/schemas/CanonicalCorrectionParams"
+ }
+ }
+ ],
+ "result": {
+ "name": "result",
+ "schema": {
+ "$ref": "#/components/schemas/CanonicalCorrectionResult"
+ }
+ }
+ },
{
"name": "worker.adopt",
"summary": "Adopt a registered execution after verifying the live producer claim.",
diff --git a/gateway/session_controls.py b/gateway/session_controls.py
index aaf2ee09aa6..eed4ebc9955 100644
--- a/gateway/session_controls.py
+++ b/gateway/session_controls.py
@@ -117,13 +117,17 @@ class AuthorityConnection:
if method in _PROFILE_IMPLICIT:
params = {key: value for key, value in params.items() if key != 'profile'}
ref = SessionRef(self.actor.profile_id, params.get('session_id', ''))
- from tui_gateway.contracts.registry import CANONICAL_METHODS, canonical_param_problems
+ from tui_gateway.contracts.registry import (
+ CANONICAL_METHODS, METHODS, canonical_param_problems, check_params_accepted, check_result,
+ )
contract = CANONICAL_METHODS.get(method)
if contract is not None and (problems := canonical_param_problems(contract, params)):
# The declared wire contract (``tui_gateway/contracts/canonical.py``) is the closed
# key set: an unknown or missing key never reaches the handler.
return {'jsonrpc': '2.0', 'id': rid, 'error': {
'code': 4001, 'message': 'invalid_params', 'data': {'reason': 'invalid_params', 'fields': problems}}}
+ original_params = dict(params)
+ contract = contract or METHODS.get(method)
handlers = self.handlers()
try:
from gateway.session_group_controls import GROUP_METHODS, dispatch_group_control
@@ -135,14 +139,16 @@ class AuthorityConnection:
with owner_scope(self.authority):
if method in GROUP_METHODS or method == 'profiles.list':
result = await dispatch_group_control(self, method, params)
- return {'jsonrpc': '2.0', 'id': rid, 'result': result}
- if method not in handlers:
+ elif method not in handlers:
# JSON-RPC's own verdict: clients key compat fallbacks on -32601, and a
# 4001 'invalid_params' would read as a bad argument on a method that exists.
return {'jsonrpc': '2.0', 'id': rid, 'error': {
'code': -32601, 'message': f'unknown method: {method}',
'data': {'reason': 'unknown_method'}}}
- result = await handlers[method](ref, params)
+ else:
+ result = await handlers[method](ref, params)
+ check_params_accepted(contract, original_params)
+ check_result(contract, result)
return {'jsonrpc': '2.0', 'id': rid, 'result': result}
except RuntimeStoreError as exc:
return {'jsonrpc': '2.0', 'id': rid, 'error': {
diff --git a/tests/gateway/test_canonical_wire_contracts.py b/tests/gateway/test_canonical_wire_contracts.py
new file mode 100644
index 00000000000..78364e99862
--- /dev/null
+++ b/tests/gateway/test_canonical_wire_contracts.py
@@ -0,0 +1,72 @@
+"""Canonical RPC validation must not reuse the independently shipped serve wire."""
+from types import SimpleNamespace
+
+import pytest
+
+from gateway.session_authority import LiveSession, SessionAuthority
+from gateway.session_controls import AuthorityConnection
+from hermes_state import SessionDB
+from hermes_state_runtime import begin_runtime_epoch
+from tui_gateway.contracts.registry import CANONICAL_METHODS, METHODS, ContractViolation, validate_params
+
+
+async def test_canonical_resume_rejects_unknown_keys_and_validates_real_snapshot(tmp_path):
+ db = SessionDB(db_path=tmp_path / 'state.db')
+ viewer = None
+ try:
+ db.create_session('s', source='test')
+ epoch = begin_runtime_epoch(db, instance_id='test')
+ authority = SessionAuthority(SimpleNamespace(), profile_id='test', instance_id='test', db=db, epoch=epoch)
+ authority.sessions['s'] = LiveSession(None, 'route')
+ viewer = AuthorityConnection(authority, object(), {'user_id': 'human'})
+ from gateway.session_group_controls import GROUP_METHODS
+ assert set(viewer.handlers()) | set(GROUP_METHODS) | {'profiles.list'} <= set(METHODS) | set(CANONICAL_METHODS)
+ refused = await viewer.dispatch({'id': 1, 'method': 'session.resume', 'params': {
+ 'session_id': 's', 'execution_generaton': 100}})
+ assert refused['error']['data']['reason'] == 'invalid_params'
+ malformed = await viewer.dispatch({'id': 1, 'method': 'session.resume', 'params': {'session_id': ['s']}})
+ assert malformed['error']['data']['reason'] == 'invalid_params'
+ assert viewer.subscriptions == {}
+ result = await viewer.dispatch({'id': 2, 'method': 'session.resume', 'params': {'session_id': 's'}})
+ snapshot = CANONICAL_METHODS['session.resume'].result.model_validate(result['result'])
+ assert snapshot.subscription_id == viewer.subscriptions['s']
+ assert snapshot.revision == 0 and snapshot.pending == []
+ assert snapshot.info.desktop_protocol == 'hermes-gateway-v1'
+ finally:
+ if viewer is not None:
+ await viewer.close()
+ db.close()
+
+
+def test_canonical_admission_and_creation_models_leave_legacy_wire_unchanged():
+ canonical = CANONICAL_METHODS['prompt.submit']
+ params = {'session_id': 's', 'input_id': 'input', 'text': 'hello', 'finite': True}
+ assert validate_params(canonical, params)[1] is None
+ assert validate_params(METHODS['prompt.submit'], params)[1] is not None
+ legacy_edit = {'session_id': 's', 'text': 'edit', 'truncate_before_row_id': 3, 'confirm_truncate': True}
+ assert validate_params(METHODS['prompt.submit'], legacy_edit)[1] is None
+ assert validate_params(canonical, legacy_edit)[1] is not None
+ assert 'execution_generation' in CANONICAL_METHODS['approval.respond'].params.model_fields
+ assert 'execution_generation' not in METHODS['approval.respond'].params.model_fields
+ assert CANONICAL_METHODS['session.create'].params.model_validate({'ignore_rules': True}).ignore_rules
+
+
+async def test_canonical_result_validation_catches_a_handler_contract_violation(tmp_path, monkeypatch):
+ from tui_gateway.contracts import registry
+ monkeypatch.setattr(registry, 'STRICT', True)
+ db = SessionDB(db_path=tmp_path / 'state.db')
+ try:
+ authority = SessionAuthority(SimpleNamespace(), profile_id='test', instance_id='test', db=db,
+ epoch=begin_runtime_epoch(db, instance_id='test'))
+ viewer = AuthorityConnection(authority, object(), {'user_id': 'human'})
+
+ async def broken_ping(ref, params):
+ return {'not_pong': True}
+
+ monkeypatch.setattr(viewer, 'ping', broken_ping)
+ with pytest.raises(ContractViolation, match='ping'):
+ await viewer.dispatch({'id': 1, 'method': 'ping', 'params': {}})
+ finally:
+ db.close()
diff --git a/tests/gateway/test_session_group_execution_controls.py b/tests/gateway/test_session_group_execution_controls.py
index 11ce6ef259b..8d3a8cee50d 100644
--- a/tests/gateway/test_session_group_execution_controls.py
+++ b/tests/gateway/test_session_group_execution_controls.py
@@ -25,14 +25,19 @@ class RoomService:
authority_gateway_id=local_authority_gateway_id())
def status(self, room_id):
- return {'room_id': room_id, 'pending_actions': [{'kind': 'retry', 'task_id': 'task'}]}
+ return {'running': True, 'working': False, 'blocked': True, 'counts': {}, 'peer_routes': [],
+ 'pending_actions': [{'kind': 'retry', 'task_id': 'task'}]}
def revoke_room_routes(self, room_id):
self.calls.append(('revoke', room_id))
def send(self, *, room_id, event_id, payload):
+ from gateway.hosted_rooms import append_event, room_state
self.calls.append(('send', room_id, event_id, payload))
- return {'event_id': event_id, 'payload': payload}
+ room = room_state(self.db_path, room_id=room_id)
+ return append_event(self.db_path, room_id=room_id, event_id=event_id, kind='message.user',
+ actor={'kind': 'user', 'id': 'desktop'}, payload=payload,
+ authority_gateway_id=room['authority_gateway_id'], authority_epoch=room['authority_epoch'])
def stop_room(self, room_id, *, cancel_id, require_acknowledged=False):
self.calls.append(('stop', room_id, cancel_id, require_acknowledged))
diff --git a/tui_gateway/AGENTS.md b/tui_gateway/AGENTS.md
index 1643babfa31..80c054af8a3 100644
--- a/tui_gateway/AGENTS.md
+++ b/tui_gateway/AGENTS.md
@@ -44,10 +44,13 @@ shape) and `gateway-contract.openrpc.json` are rendered by `scripts/gen_gateway_
`tests/tui_gateway/contracts/test_generated.py` fails when they are stale, so the loop is: change the model →
regenerate → `tsc` shows every consumer the field moved. `apps/shared/src/gateway-events.ts` only adds
the client-local synthetic events and the `GatewayEvent` envelope on top.
-Verbs only the session authority serves (`hermes-gateway-v1`, `gateway/session_controls.py::
-AuthorityConnection`) are `canonical_method(...)` in `contracts/canonical.py` (`CANONICAL_METHODS` →
-TS `CanonicalRpcMethods`); `dispatch` refuses an unknown/missing key with `4001 invalid_params`, and
-`tests/gateway/test_canonical_wire_contract.py` fails when a handler name has no declaration.
+The native `hermes-gateway-v1` transport has a separate `CANONICAL_METHODS` catalog in
+`contracts/canonical*.py`, declared with `canonical_method(...)`. `gateway/session_controls.py::
+AuthorityConnection` validates parameters and successful results against it; unknown/missing
+parameter keys return `4001 invalid_params`. Reuse a standalone model only when its wire is
+identical: shared method names can carry different snapshots, admission receipts and producer
+results. The same generator emits `CanonicalRpcMethods` and OpenRPC `x-canonical-methods` without
+widening `RpcMethods`. `tests/gateway/test_canonical_wire_contract.py` checks handler coverage.
New question for the user = `_ask("<method>", sid, params, timeout)` in the emitter, a handler in
`apps/desktop/.../gateway-event/server-requests.ts` and `ui-tui/src/app/createServerRequestHandler.ts`,
and a `server_request(...)` in `contracts/server_requests.py`.
diff --git a/tui_gateway/contracts/canonical.py b/tui_gateway/contracts/canonical.py
index 9510cc6fe0e..5c58351c28e 100644
--- a/tui_gateway/contracts/canonical.py
+++ b/tui_gateway/contracts/canonical.py
@@ -2,8 +2,8 @@
``gateway/session_controls.py::AuthorityConnection.dispatch`` answers these on the authenticated
native socket; the TUI sidecar (``server._methods``) never registers them, so they live in
-``CANONICAL_METHODS`` rather than ``METHODS``. Names both dispatchers serve keep their ``METHODS``
-contract. The dispatcher refuses an unknown or missing key with ``4001 invalid_params`` before the
+``CANONICAL_METHODS`` rather than ``METHODS``. Shared names with different authority semantics are overridden in
+``canonical_sessions`` / ``canonical_projections``; unchanged names reuse ``METHODS``. The dispatcher refuses an unknown or missing key with ``4001 invalid_params`` before the
handler runs; value checks stay in the handlers, which own their domain reasons.
"""
@@ -367,3 +367,7 @@ class GroupsDiscardResult(Result):
canonical_method("groups.discard", params=GroupsDiscardParams, result=GroupsDiscardResult,
doc="Discard one indeterminate room task after explicit user confirmation.")
+
+
+# Shared-name overrides load after the authority-only value shapes above.
+from . import canonical_sessions, canonical_projections # noqa: F401,E402
diff --git a/tui_gateway/contracts/canonical_projections.py b/tui_gateway/contracts/canonical_projections.py
new file mode 100644
index 00000000000..83d6e6c5de2
--- /dev/null
+++ b/tui_gateway/contracts/canonical_projections.py
@@ -0,0 +1,88 @@
+"""Canonical projections with demonstrated differences from standalone wire."""
+from typing import Literal
+
+from .base import JsonValue, Params, Result
+from .common import ProfileParams
+from .canonical_sessions import CanonicalSessionParams
+from .config_free_tier_control import ConfigGetParams, ConfigGetResult, ConfigSetResult
+from .groups_bot_relay import GroupsApproveResult, GroupsCreateResult, GroupsRetryResult, RoomMemberInput, RoomParams
+from .prompt_voice import AttachedImageResult, ImageAttachBytesParams
+from .profiles_vault_complete_foreign_subagents import ProfileCanonicalSession, ProfileRow, ProfilesListResult
+from .registry import canonical_method
+
+
+class CanonicalConfigGetResult(ConfigGetResult):
+ key: str | None = None
+ scope: str | None = None
+
+
+class CanonicalConfigSetParams(CanonicalSessionParams):
+ key: Literal['busy', 'verbose', 'yolo']
+ value: JsonValue = None
+
+
+class CanonicalAttachedImageResult(AttachedImageResult):
+ mime: str
+
+
+class CanonicalProfileRow(ProfileRow):
+ last_session: ProfileCanonicalSession | None = None
+
+
+class CanonicalProfilesResult(ProfilesListResult):
+ profiles: list[CanonicalProfileRow]
+
+
+class CanonicalProfilesParams(ProfileParams):
+ include_sessions: bool = True
+
+
+class CanonicalRoomCreateParams(RoomParams):
+ name: str
+ members: list[RoomMemberInput]
+
+
+class CanonicalRoomAttemptParams(RoomParams):
+ member_id: str
+ task_id: str
+ execution_generation: int
+
+
+class CanonicalRoomApproveParams(CanonicalRoomAttemptParams):
+ choice: Literal['once', 'deny']
+ request_id: str
+
+
+class CanonicalBotDeliverParams(Params):
+ profile: str | None = None
+ message: str
+ id: str
+ session_id: str | None = None
+ author: dict[str, JsonValue] | None = None
+ notification_category: str | None = None
+
+
+class CanonicalBotDeliverResult(Result):
+ status: str
+ delivery_id: str
+ profile_home: str
+ session_id: str
+ admission_id: str
+ message: str
+ reply: str | None = None
+ retry_admission_id: str | None = None
+ error: str | None = None
+ reason: str | None = None
+
+
+for _name, _params, _result in (
+ ('config.get', ConfigGetParams, CanonicalConfigGetResult),
+ ('config.set', CanonicalConfigSetParams, ConfigSetResult),
+ ('profiles.list', CanonicalProfilesParams, CanonicalProfilesResult),
+ ('image.attach_bytes', ImageAttachBytesParams, CanonicalAttachedImageResult),
+ ('groups.retry', CanonicalRoomAttemptParams, GroupsRetryResult),
+ ('groups.create', CanonicalRoomCreateParams, GroupsCreateResult),
+ ('groups.approve', CanonicalRoomApproveParams, GroupsApproveResult),
+ ('bot_relay.deliver', CanonicalBotDeliverParams, CanonicalBotDeliverResult),
+):
+ canonical_method(_name, params=_params, result=_result)
diff --git a/tui_gateway/contracts/canonical_sessions.py b/tui_gateway/contracts/canonical_sessions.py
new file mode 100644
index 00000000000..c4fa6a88156
--- /dev/null
+++ b/tui_gateway/contracts/canonical_sessions.py
@@ -0,0 +1,203 @@
+"""Shared method names whose canonical session wire differs from standalone serve.
+
+Reuse upstream authority-only value shapes; these overrides do not widen METHODS.
+"""
+from typing import Literal
+
+from .base import JsonValue, Params, Result
+from .common import ProfileParams, TranscriptMessage
+from .canonical import AdmissionStatus, CanonicalSessionRef, PromptResponseResult
+from .registry import canonical_method
+
+
+class CanonicalSessionParams(ProfileParams):
+ session_id: str
+
+
+class CanonicalCreateParams(ProfileParams):
+ request_id: str | None = None
+ source: Literal['cli', 'tui', 'gui', 'acp'] = 'cli'
+ cwd: str | None = None
+ model: str | None = None
+ provider: str | None = None
+ base_url: str | None = None
+ api_key: str | None = None
+ toolsets: list[str] | None = None
+ reasoning: str | None = None
+ max_turns: int | str | None = None
+ ignore_rules: bool = False
+ yolo: bool = False
+ safe_mode: bool = False
+ ignore_user_config: bool = False
+ editor: dict[str, JsonValue] | None = None
+ title: str | None = None
+ hidden: bool = False
+ follow_profile_config: bool | None = None
+
+
+class CanonicalResumeParams(ProfileParams):
+ session_id: str = ''
+ title: str | None = None
+ source: str | None = None
+ editor: dict[str, JsonValue] | None = None
+ defer_history: bool = False
+ omit_messages: bool = False
+ cols: int | None = None
+
+
+class CanonicalSessionHandle(Result):
+ ref: CanonicalSessionRef
+ instance_id: str
+ authority_epoch: int
+ revision: int
+ execution_generation: int
+ execution_state: Literal['idle', 'running', 'waiting', 'unknown', 'terminal']
+
+
+class CanonicalPendingAdmission(AdmissionStatus):
+ input_id: str
+ text: str
+
+
+class CanonicalPendingPrompt(Result):
+ kind: Literal['approval', 'clarify']
+ prompt_id: str
+ execution_generation: int
+ choices: list[str]
+ command: str | None = None
+ description: str | None = None
+ edit: dict[str, JsonValue] | None = None
+ question: str | None = None
+ multi_select: bool | None = None
+
+
+class CanonicalSnapshotInfo(Result):
+ desktop_protocol: Literal['hermes-gateway-v1']
+ source: str | None = None
+ model: str | None = None
+ lazy: bool | None = None
+ profile_id: str | None = None
+ profile_name: str | None = None
+ cwd: str | None = None
+ launch_request: dict[str, JsonValue] | None = None
+
+
+class CanonicalSnapshot(Result):
+ session_id: str
+ stored_session_id: str
+ messages: list[TranscriptMessage]
+ message_count: int
+ running: bool
+ authority_epoch: int
+ replay_epoch: str
+ last_sequence: int
+ subscription_id: str
+ revision: int
+ execution_generation: int
+ pending: list[CanonicalPendingAdmission]
+ prompts: list[CanonicalPendingPrompt]
+ info: CanonicalSnapshotInfo
+
+
+class CanonicalListParams(ProfileParams):
+ limit: int = 200
+ title: str | None = None
+ include_hidden: bool = False
+
+
+class CanonicalSessionListRow(Result):
+ session_id: str
+ id: str
+ title: str
+ source: str | None
+ started_at: float | None
+ message_count: int
+ running: bool
+ resolved_id: str | None = None
+ root_title: str | None = None
+
+
+class CanonicalListResult(Result):
+ sessions: list[CanonicalSessionListRow]
+ scope: Literal['stored', 'live']
+
+
+class CanonicalAttachment(Params):
+ path: str
+ mime: str
+
+
+class CanonicalSubmitParams(CanonicalSessionParams):
+ text: str
+ submission_id: str | None = None
+ input_id: str | None = None
+ queued: bool = False
+ attachments: list[CanonicalAttachment] | None = None
+ finite: bool = False
+ unattended: bool = False
+ surface: str | None = None
+ voice_context: str | None = None
+ interrupted: bool = False
+ voice_turn: bool = False
+
+
+class CanonicalControlParams(CanonicalSessionParams):
+ execution_generation: int
+
+
+class CanonicalCorrectionParams(CanonicalControlParams):
+ text: str
+
+
+class CanonicalCorrectionResult(Result):
+ status: Literal['queued', 'redirected', 'rejected']
+ text: str
+ execution_generation: int
+ authority_epoch: int
+
+
+class CanonicalApprovalParams(CanonicalControlParams):
+ prompt_id: str
+ choice: str
+
+
+class CanonicalEventsParams(CanonicalSessionParams):
+ last_sequence: int = 0
+ last_seen: int = 0
+ replay_epoch: str | None = None
+
+
+class CanonicalReplayEvent(Result):
+ type: str
+ session_id: str
+ payload: dict[str, JsonValue]
+ replay_epoch: str
+ seq: int
+ authority_epoch: int | None = None
+ execution_generation: int | None = None
+ admission_id: str | None = None
+
+
+class CanonicalEventsResult(Result):
+ events: list[CanonicalReplayEvent]
+ latest_seq: int
+ last_sequence: int
+ epoch: str
+ replay_epoch: str
+ truncated: bool
+ snapshot_required: bool
+ count: int
+
+
+for _name, _params, _result in (
+ ('session.create', CanonicalCreateParams, CanonicalSnapshot),
+ ('session.resume', CanonicalResumeParams, CanonicalSnapshot),
+ ('session.list', CanonicalListParams, CanonicalListResult),
+ ('session.interrupt', CanonicalControlParams, CanonicalSessionHandle),
+ ('session.steer', CanonicalCorrectionParams, CanonicalCorrectionResult),
+ ('session.redirect', CanonicalCorrectionParams, CanonicalCorrectionResult),
+ ('session.events.since', CanonicalEventsParams, CanonicalEventsResult),
+ ('prompt.submit', CanonicalSubmitParams, AdmissionStatus),
+ ('approval.respond', CanonicalApprovalParams, PromptResponseResult),
+):
+ canonical_method(_name, params=_params, result=_result)
diff --git a/tui_gateway/contracts/registry.py b/tui_gateway/contracts/registry.py
index 0ee28a01435..1dd69d184b4 100644
--- a/tui_gateway/contracts/registry.py
+++ b/tui_gateway/contracts/registry.py
@@ -46,15 +46,16 @@ class EventContract:
METHODS: dict[str, MethodContract] = {}
# ``hermes-gateway-v1`` verbs only ``gateway/session_controls.py::AuthorityConnection`` serves
-# (``contracts/canonical.py``); a name both dispatchers serve keeps its one ``METHODS`` entry.
+# (``contracts/canonical.py``), plus explicit overrides where a shared name has a different wire.
CANONICAL_METHODS: dict[str, MethodContract] = {}
SERVER_REQUESTS: dict[str, ServerRequestContract] = {}
EVENTS: dict[str, EventContract] = {}
def _declare(table: dict, entry) -> None:
- if entry.name in table or (table in (METHODS, CANONICAL_METHODS)
- and entry.name in (METHODS.keys() | CANONICAL_METHODS.keys())):
+ # Method names may have different envelopes on independently shipped
+ # transports. Duplicates within one transport's catalog are still errors.
+ if entry.name in table:
raise RuntimeError(f"contract declared twice: {entry.name}")
table[entry.name] = entry
@@ -126,8 +127,11 @@ def canonical_param_problems(contract: MethodContract, params: dict) -> list[str
try:
contract.params.model_validate(params)
except ValidationError as exc:
+ # Shared methods preserve handler-owned missing-field/permission refusals,
+ # while refusing malformed values before the handler indexes them.
return [".".join(str(p) for p in err.get("loc", ())) or "params" for err in exc.errors()
- if err.get("type") in ("extra_forbidden", "missing")]
+ if (err.get("type") != "missing" if contract.name in METHODS
+ else err.get("type") in ("extra_forbidden", "missing"))]
return []
diff --git a/website/docs/developer-guide/gateway-internals.md b/website/docs/developer-guide/gateway-internals.md
index 1e4d1b923f2..d59a9e5aaa2 100644
--- a/website/docs/developer-guide/gateway-internals.md
+++ b/website/docs/developer-guide/gateway-internals.md
@@ -219,6 +219,10 @@ session registration before routing or transcript creation. These edits
do not interrupt a running turn. This RPC does not yet migrate legacy direct
writers, expose arbitrary SQL, or implement reset, delete, or rewind.
+Canonical wire models live in `tui_gateway/contracts/canonical*.py` and generate
+`CanonicalRpcMethods` plus the OpenRPC `x-canonical-methods` catalog, separately
+from the standalone protocol. Both parameters and successful results are checked.
+
## Private native HTTP authentication
The authoritative daemon accepts a **fresh, one-use HTTP grant per request** from