// Generated by `bun run gen:rpc` from src/modes/rpc/wire. Do not edit. /** Who initiated a message, for billing and attribution. */ export type Attribution = "user" | "agent"; export type StopReason = "stop" | "length" | "toolUse" | "error" | "aborted"; export interface TextContent { type: "text"; text: string; textSignature?: string; } export interface ThinkingContent { type: "thinking"; thinking: string; thinkingSignature?: string; itemId?: string; /** Prose the model addressed to the user, returned by the provider as thinking; present it as answer text. */ narration?: boolean; } export interface RedactedThinkingContent { type: "redactedThinking"; data: string; } /** Inline image; also the shape hosts send with prompts. */ export interface ImageContent { type: "image"; /** Base64-encoded image bytes. */ data: string; mimeType: string; detail?: "auto" | "low" | "high" | "original"; url?: string; providerFile?: Record; } export interface ToolCall { type: "toolCall"; id: string; name: string; arguments: Record; thoughtSignature?: string; intent?: string; rawBlock?: string; customWireName?: string; providerMetadata?: Record; } /** Anthropic server-side fallback boundary marker; consumers other than Anthropic ignore it. */ export interface FallbackContent { type: "fallback"; from: Record; to: Record; } export interface AnthropicServerToolContent { type: "anthropicServerTool"; block: Record; } export type UserContent = TextContent | ImageContent; /** Message content: plain text or content blocks. */ export type MessageContent = string | UserContent[]; export type AssistantContent = TextContent | ThinkingContent | RedactedThinkingContent | FallbackContent | AnthropicServerToolContent | ImageContent | ToolCall; export interface UsageCost { input: number; output: number; cacheRead: number; cacheWrite: number; total: number; } export interface Usage { input: number; output: number; cacheRead: number; cacheWrite: number; totalTokens: number; cost: UsageCost; contextTokens?: number; premiumRequests?: number; reasoningTokens?: number; orchestration?: Record; cttl?: Record; server?: Record; credits?: Record; } /** Parent-agent IRC message carried by a steer; render it instead of the model-facing `content` envelope. */ export interface ParentIrc { /** Sending parent agent id. */ from: string; /** Message body as the parent wrote it. */ body: string; } export interface UserMessage { role: "user"; content: MessageContent; timestamp: number; parentIrc?: ParentIrc; synthetic?: boolean; steering?: boolean; liveSteered?: boolean; historyRewriteAt?: number; attribution?: Attribution; providerPayload?: Record; } export interface DeveloperMessage { role: "developer"; content: MessageContent; timestamp: number; attribution?: Attribution; synthetic?: boolean; userInitiated?: boolean; providerPayload?: Record; } export interface AssistantMessage { role: "assistant"; content: AssistantContent[]; api: string; provider: string; model: string; usage: Usage; stopReason: StopReason; timestamp: number; responseId?: string; upstreamProvider?: string; upstreamModel?: string; errorMessage?: string; errorStatus?: number; errorId?: number; providerPayload?: Record; duration?: number; ttft?: number; completedAt?: number; } export interface ToolResultMessage { role: "toolResult"; toolCallId: string; toolName: string; content: UserContent[]; isError: boolean; timestamp: number; details?: unknown; attribution?: Attribution; prunedAt?: number; useless?: boolean; } export interface BashExecutionMessage { role: "bashExecution"; command: string; output: string; cancelled: boolean; truncated: boolean; timestamp: number; exitCode?: number; images?: ImageContent[]; meta?: Record; excludeFromContext?: boolean; } export interface PythonExecutionMessage { role: "pythonExecution"; code: string; output: string; cancelled: boolean; truncated: boolean; timestamp: number; exitCode?: number; meta?: Record; excludeFromContext?: boolean; } export interface CustomMessage { role: "custom"; customType: string; content: MessageContent; display: boolean; timestamp: number; details?: unknown; attribution?: Attribution; } export interface HookMessage { role: "hookMessage"; customType: string; content: MessageContent; display: boolean; timestamp: number; details?: unknown; attribution?: Attribution; } export interface BranchSummaryMessage { role: "branchSummary"; summary: string; fromId: string; timestamp: number; } export interface CompactionSummaryMessage { role: "compactionSummary"; summary: string; tokensBefore: number; timestamp: number; shortSummary?: string; tokensAfter?: number; method?: string; providerPayload?: Record; } export interface FileMentionItem { path: string; content: string; lineCount?: number; byteSize?: number; skippedReason?: "tooLarge" | "binary"; image?: ImageContent; } export interface FileMentionMessage { role: "fileMention"; files: FileMentionItem[]; timestamp: number; } /** A transcript message, discriminated by `role`. */ export type AgentMessage = UserMessage | DeveloperMessage | AssistantMessage | ToolResultMessage | BashExecutionMessage | PythonExecutionMessage | CustomMessage | HookMessage | BranchSummaryMessage | CompactionSummaryMessage | FileMentionMessage; export interface AssistantStartEvent { type: "start"; partial: AssistantMessage; } export interface AssistantTextStartEvent { type: "text_start"; contentIndex: number; partial: AssistantMessage; } export interface AssistantTextDeltaEvent { type: "text_delta"; contentIndex: number; delta: string; partial: AssistantMessage; } export interface AssistantTextEndEvent { type: "text_end"; contentIndex: number; content: string; partial: AssistantMessage; } export interface AssistantThinkingStartEvent { type: "thinking_start"; contentIndex: number; partial: AssistantMessage; } export interface AssistantThinkingDeltaEvent { type: "thinking_delta"; contentIndex: number; delta: string; partial: AssistantMessage; } export interface AssistantThinkingEndEvent { type: "thinking_end"; contentIndex: number; content: string; partial: AssistantMessage; } export interface AssistantImageEndEvent { type: "image_end"; contentIndex: number; content: ImageContent; partial: AssistantMessage; } export interface AssistantToolCallStartEvent { type: "toolcall_start"; contentIndex: number; partial: AssistantMessage; } export interface AssistantToolCallDeltaEvent { type: "toolcall_delta"; contentIndex: number; delta: string; partial: AssistantMessage; } export interface AssistantToolCallEndEvent { type: "toolcall_end"; contentIndex: number; toolCall: ToolCall; partial: AssistantMessage; } export interface AssistantDoneEvent { type: "done"; reason: "stop" | "length" | "toolUse"; message: AssistantMessage; } export interface AssistantErrorEvent { type: "error"; reason: "aborted" | "error"; error: AssistantMessage; } /** Streaming update for one assistant message, discriminated by `type`. */ export type AssistantMessageEvent = AssistantStartEvent | AssistantTextStartEvent | AssistantTextDeltaEvent | AssistantTextEndEvent | AssistantThinkingStartEvent | AssistantThinkingDeltaEvent | AssistantThinkingEndEvent | AssistantImageEndEvent | AssistantToolCallStartEvent | AssistantToolCallDeltaEvent | AssistantToolCallEndEvent | AssistantDoneEvent | AssistantErrorEvent; export type Effort = "minimal" | "low" | "medium" | "high" | "xhigh" | "max"; /** Thinking selector; `inherit` defers to a higher-level selector. */ export type ThinkingLevel = "inherit" | "off" | "minimal" | "low" | "medium" | "high" | "xhigh" | "max"; /** User-configured thinking selector, including automatic selection. */ export type ConfiguredThinkingLevel = "auto" | "inherit" | "off" | "minimal" | "low" | "medium" | "high" | "xhigh" | "max"; /** Per-million-token USD rates. */ export interface ModelCost { input: number; output: number; cacheRead: number; cacheWrite: number; } export interface ThinkingConfig { mode: string; efforts: Effort[]; defaultLevel?: Effort; effortMap?: Record; supportsDisplay?: boolean; prefixBinding?: boolean; effortRouting?: Record; effortBudgets?: Record; suppressWhenOff?: boolean; requiresEffort?: boolean; } /** Model descriptor: the client-relevant subset of the server's model record. */ export interface ModelInfo { id: string; name: string; api: string; provider: string; baseUrl: string; reasoning: boolean; /** Accepted input modalities, e.g. `text`, `image`. */ input: string[]; cost: ModelCost; /** Null when the provider does not report a limit. */ contextWindow: number | null; /** Null when the provider does not report a limit. */ maxTokens: number | null; headers?: Record; premiumMultiplier?: number; preferWebsockets?: boolean; contextPromotionTarget?: string; priority?: number; thinking?: ThinkingConfig; compat?: Record; } export type QueueMode = "all" | "one-at-a-time"; export type InterruptMode = "immediate" | "wait"; export type StreamingBehavior = "steer" | "followUp"; export type QueuedMessageQueue = "steering" | "followUp"; export type CacheWarmingMode = "off" | "streaming" | "idle"; /** `set_event_filter` projection: `delta` replaces the accumulated snapshots with the block a start/end event touches. */ export type MessageUpdates = "full" | "delta"; export type TodoStatus = "pending" | "in_progress" | "completed" | "abandoned" | "blocked"; export type GoalOp = "get" | "create" | "resume" | "pause" | "drop"; export type GoalStatus = "active" | "paused" | "budget-limited" | "complete" | "dropped"; export type SlashCommandSource = "builtin" | "skill" | "extension" | "custom" | "mcp_prompt" | "file"; /** Forwarded subagent frames: none, lifecycle and progress, or also raw session events. */ export type SubagentSubscriptionLevel = "off" | "progress" | "events"; export type AgentSource = "bundled" | "user" | "project"; export type SubagentStatus = "pending" | "running" | "completed" | "failed" | "aborted"; export interface TodoItem { content: string; status: TodoStatus; /** What a `blocked` task is waiting on. */ blocker?: string; details?: string; notes?: string[]; } export interface TodoPhase { name: string; tasks: TodoItem[]; } export interface ContextUsage { tokens: number; contextWindow: number; percent: number; } /** Displayable queue-chip text for pending user-authored messages; accepted verbatim by `remove_queued_message`. */ export interface QueuedMessagesState { steering: string[]; followUp: string[]; /** Leading `steering` entries are live steering already sent into the streaming response; `remove_queued_message` cannot reach them. */ liveSteered?: number; } export interface ToolDescriptor { name: string; description: string; parameters?: unknown; examples?: unknown[]; } /** A tracked goal: its objective, lifecycle status, and resource accounting. */ export interface Goal { id: string; objective: string; status: GoalStatus; tokensUsed: number; timeUsedSeconds: number; createdAt: number; updatedAt: number; tokenBudget?: number; } /** Session goal mode; `mode` is `"exiting"` while a completed goal unwinds. */ export interface GoalModeState { enabled: boolean; mode: "active" | "exiting"; goal: Goal; reason?: "completed"; } /** Outcome of every `goal` op; both fields are null when the session has no goal. */ export interface GoalResult { goal: Goal | null; state: GoalModeState | null; } /** Where `/slow` lives: persisted config shared by every session, or this session's flex tier. */ export type SlowModeScope = "session" | "global"; /** Requests are served on the provider's low-priority (slow) lane. */ export interface UsageLimitLowPriority { stage: "low_priority"; /** Epoch seconds when the limit that was hit resets. */ resetsAtSec: number; /** Percent of the low-priority allowance still available, when reported. */ allowanceLeftPercent?: number; } /** Requests run on a short wrap-up allowance past the limit. */ export interface UsageLimitWrapUp { stage: "wrap_up"; /** Whether paid extra usage serves requests once the allowance is spent. */ extraUsage: boolean; /** Epoch seconds when the limit that was hit resets, if reported. */ resetsAtSec?: number; } /** Provider-neutral state of an account past its usage limit, discriminated by `stage`. */ export type UsageLimitState = UsageLimitLowPriority | UsageLimitWrapUp; export interface SessionState { sessionId: string; model?: ModelInfo; thinkingLevel?: ThinkingLevel; isStreaming?: boolean; isCompacting?: boolean; steeringMode?: QueueMode; followUpMode?: QueueMode; interruptMode?: InterruptMode; sessionFile?: string; sessionName?: string; autoCompactionEnabled?: boolean; fastModeEnabled?: boolean; fastModeActive?: boolean; /** `/slow` applies to the active model. */ slowModeSupported?: boolean; /** `/slow` is on for the active model; always `false` when `slowModeSupported` is `false`. */ slowModeEnabled?: boolean; /** Where the active model's `/slow` lives; absent when unsupported. */ slowModeScope?: SlowModeScope; /** Usage-limit stage of the active model's account; absent outside wrap-up and low priority. */ usageLimit?: UsageLimitState; tokensPerSecond?: number | null; messageCount?: number; queuedMessageCount?: number; /** Background jobs or deliveries can still inject a follow-up and wake the session. */ hasPendingAsyncWork?: boolean; /** Idle with nothing queued or pending; same predicate as `session_settled`. */ isSettled?: boolean; queuedMessages?: QueuedMessagesState; todoPhases?: TodoPhase[]; /** System prompt sections, for session dumps. */ systemPrompt?: string[]; dumpTools?: ToolDescriptor[]; contextUsage?: ContextUsage; /** Current goal mode; null when the session has no goal. */ goal?: GoalModeState | null; } export interface BashResult { output: string; cancelled: boolean; truncated: boolean; totalLines: number; totalBytes: number; outputLines: number; outputBytes: number; exitCode?: number; timedOut?: boolean; artifactId?: string; artifactElidedBytes?: number; /** Bytes dropped from the middle of `output`, which keeps the head and tail. */ elidedBytes?: number; /** Lines dropped from the middle of `output`. */ elidedLines?: number; /** Bytes the per-line column cap cut from `output`, across all lines. */ columnDroppedBytes?: number; /** Lines of `output` the per-line column cap cut; the artifact holds them whole. */ columnTruncatedLines?: number; /** First and last lines the column cap cut, numbered as in the artifact; absent when the numbering cannot match it. */ columnTruncatedRange?: LineRange; /** The per-line column cap in UTF-8 bytes, set when it cut a line. */ columnMax?: number; artifactError?: Record; minimized?: Record; workingDir?: string; images?: ImageContent[]; /** The embedded shell's final `ShellTrace` of the run; only when the caller asked for one. */ trace?: Record; } export interface LineRange { first: number; last: number; } export interface FastModeResult { enabled: boolean; active: boolean; } export interface CompactionResult { summary: string; firstKeptEntryId: string; tokensBefore: number; shortSummary?: string; details?: unknown; preserveData?: Record; providerReplayThroughEntryId?: string; } export interface ModelCycleResult { model: ModelInfo; isScoped: boolean; thinkingLevel?: ThinkingLevel; } export interface ThinkingLevelCycleResult { level: Effort; } export interface CancellationResult { cancelled: boolean; } /** `open_session` outcome; `resumed` is false when a fresh session was started. */ export interface OpenSessionResult { cancelled: boolean; resumed: boolean; sessionId: string; sessionFile?: string; } export interface RemoveQueuedMessageResult { removed: boolean; /** The removed message's images, so the client can restore them with its text. */ images?: ImageContent[]; /** Only ever `true`: the images exceeded the transport limit and were omitted; the removal still happened. */ imagesDropped?: boolean; } export interface PromoteQueuedMessageResult { promoted: boolean; } /** Queued user content withdrawn from the queue, as the editor would restore it. */ export interface RestoredQueuedMessage { text: string; images?: ImageContent[]; } /** User-authored queued input withdrawn before the abort, oldest first. */ export interface AbortAndRestoreQueueResult { steering: RestoredQueuedMessage[]; followUp: RestoredQueuedMessage[]; /** Only ever `true`: the full result exceeded the transport limit and every `images` was omitted. */ imagesDropped?: boolean; /** Only ever `true`: even the text-only result exceeded the limit, so only an oldest-first prefix is listed. */ truncated?: boolean; } export interface BranchMessage { entryId: string; text: string; } export interface BranchResult { text: string; cancelled: boolean; } export interface NavigateTreeResult { cancelled: boolean; /** Only ever `true`: `abort_branch_summary` stopped the summary; nothing moved. */ aborted?: boolean; /** The target was a user message: its text, for the editor; the leaf moved to its parent. */ editorText?: string; } export interface TokenUsage { input: number; output: number; cacheRead: number; cacheWrite: number; total: number; reasoning?: number; } export interface SessionCredits { cost: number; committedCost: number; acuCost: number; } export interface SessionStats { sessionId: string; userMessages: number; assistantMessages: number; toolCalls: number; toolResults: number; totalMessages: number; tokens: TokenUsage; premiumRequests: number; cost: number; sessionFile?: string; credits?: SessionCredits; routedModels?: Record; /** Failed edits by the engine's `errorKind`. */ editRejections?: Record; contextUsage?: ContextUsage; } export interface MessagesPage { messages: AgentMessage[]; totalMessages: number; /** Opaque cursor for the next page; absent on the last page. */ nextCursor?: string; } export interface SlashCommandInput { hint?: string; } export interface SlashSubcommand { name: string; description?: string; usage?: string; } export interface AvailableSlashCommand { name: string; source: SlashCommandSource; aliases?: string[]; description?: string; input?: SlashCommandInput; subcommands?: SlashSubcommand[]; } /** OMP-native session entries in append order. */ export interface SessionEntries { entries: Record[]; leafId: string | null; } /** Raw session tree roots. */ export interface SessionTree { tree: Record[]; leafId: string | null; } export interface SubagentSnapshot { id: string; index: number; agent: string; agentSource: AgentSource; status: SubagentStatus; lastUpdate: number; description?: string; task?: string; assignment?: string; sessionFile?: string; /** Raw `AgentProgress` record. */ progress?: Record; parentToolCallId?: string; } /** Incremental subagent transcript read. */ export interface SubagentMessages { sessionFile: string; fromByte: number; /** Pass as the next `fromByte` to read incrementally. */ nextByte: number; /** `fromByte` exceeded the file size and reading restarted at zero. */ reset: boolean; entries: Record[]; messages: AgentMessage[]; } /** Side-question turn lifecycle; `interrupted` marks a turn whose process died while it ran. */ export type BtwStatus = "running" | "complete" | "cancelled" | "error" | "interrupted"; /** One question and its answer within a side-question topic. */ export interface BtwHistoryTurn { question: string; answer: string; status: BtwStatus; createdAt: number; updatedAt: number; /** Images attached to the question. */ images?: ImageContent[]; error?: string; } /** A side-question topic: its first turn's fields plus follow-ups; the latest turn is the last follow-up, else the record. */ export interface BtwHistoryRecord { question: string; answer: string; status: BtwStatus; createdAt: number; updatedAt: number; id: string; leafId: string | null; /** Images attached to the question. */ images?: ImageContent[]; error?: string; followUps?: BtwHistoryTurn[]; } export interface LoginProvider { id: string; name: string; available: boolean; authenticated: boolean; } /** A stored credential `logout` can remove; `active` marks credentials the session may be using. */ export interface LogoutAccount { credentialId: number; provider: string; label: string; detail: string; type: "api_key" | "oauth"; active: boolean; } export interface HandoffResult { savedPath?: string; } /** `agentInvoked: false` means the prompt completed locally and no `prompt_result` follows. */ export interface PromptAck { agentInvoked?: boolean; } export type AutoCompactionReason = "threshold" | "overflow" | "idle" | "incomplete"; export type AutoCompactionAction = "context-full" | "remote" | "handoff" | "shake" | "snapcompact"; export type CacheWarmingPhase = "streaming" | "idle"; export type CacheWarmingOutcome = "hit" | "miss" | "error" | "aborted"; export type NotifyType = "info" | "warning" | "error"; export interface AgentStartEvent { type: "agent_start"; /** Calls of an unpaired assistant tail a continued run executes before its first model request. */ resumedToolCallIds?: string[]; } export interface AgentEndEvent { type: "agent_end"; /** Messages of the run; an oversized frame drops a prefix already delivered by `message_end` (see `messageCount`). */ messages: AgentMessage[]; /** Original message count when the frame was compacted. */ messageCount?: number; /** False when a continuation or async delivery remains. */ isTerminal?: boolean; /** The agent finished its turn and resumes only for queued input or background-job results. */ yielded?: boolean; /** Non-terminal end whose only possible resume is a background-job result. */ awaitingAsyncWork?: boolean; telemetry?: Record; coverage?: Record; } export interface TurnStartEvent { type: "turn_start"; } export interface TurnEndEvent { type: "turn_end"; message: AgentMessage; toolResults: ToolResultMessage[]; } export interface MessageStartEvent { type: "message_start"; message: AgentMessage; /** Shared by the start, updates, and end of one message; unique per process. */ messageId?: string; } export interface MessageUpdateEvent { type: "message_update"; message: AgentMessage; assistantMessageEvent: AssistantMessageEvent; /** Shared by the start, updates, and end of one message; unique per process. */ messageId?: string; } export interface MessageEndEvent { type: "message_end"; message: AgentMessage; /** Shared by the start, updates, and end of one message; unique per process. */ messageId?: string; } export interface ToolExecutionStartEvent { type: "tool_execution_start"; toolCallId: string; toolName: string; args?: unknown; intent?: string; } export interface ToolExecutionUpdateEvent { type: "tool_execution_update"; toolCallId: string; toolName: string; args?: unknown; partialResult?: unknown; } export interface ToolStreamUpdateEvent { type: "tool_stream_update"; toolCallId: string; toolName: string; update?: unknown; } export interface ToolExecutionEndEvent { type: "tool_execution_end"; toolCallId: string; toolName: string; result?: unknown; isError?: boolean; } export interface AutoCompactionStartEvent { type: "auto_compaction_start"; reason: AutoCompactionReason; action: AutoCompactionAction; } export interface AutoCompactionEndEvent { type: "auto_compaction_end"; action: AutoCompactionAction; aborted: boolean; willRetry: boolean; result?: CompactionResult; errorMessage?: string; /** Compaction was skipped for a benign reason. */ skipped?: boolean; } /** A manual compaction (`compact` command, `/compact`, extension `ctx.compact()`) began; the live turn is already aborted. */ export interface ManualCompactionStartEvent { type: "manual_compaction_start"; /** The `/compact ` subcommand, when one was given. */ mode?: string; } /** Outcome of the compaction announced by the matching `manual_compaction_start`. */ export interface ManualCompactionEndEvent { type: "manual_compaction_end"; /** The compaction was cancelled (abort, or a `session_before_compact` hook). */ aborted: boolean; /** Present when the compaction committed. */ result?: CompactionResult; /** There was nothing to compact; `errorMessage` says why. */ skipped?: boolean; errorMessage?: string; } export interface AutoRetryStartEvent { type: "auto_retry_start"; attempt: number; maxAttempts: number; delayMs: number; errorMessage: string; errorId?: number; } export interface AutoRetryEndEvent { type: "auto_retry_end"; success: boolean; attempt: number; finalError?: string; /** Persisted retry errors whose presentation changed when the retry settled. */ retryErrors?: Record[]; } /** A prompt-cache refresh was handed to the provider. */ export interface CacheWarmingStartEvent { type: "cache_warming_start"; phase: CacheWarmingPhase; provider: string; model: string; } /** Outcome of the refresh announced by the matching `cache_warming_start`. */ export interface CacheWarmingEndEvent { type: "cache_warming_end"; phase: CacheWarmingPhase; provider: string; model: string; outcome: CacheWarmingOutcome; /** Present only when the refresh was billed. */ usage?: Usage; /** Why warming stopped; absent while it continues. */ warmingStopReason?: string; } export interface RetryFallbackAppliedEvent { type: "retry_fallback_applied"; from: string; to: string; role: string; reason?: string; } export interface RetryFallbackSucceededEvent { type: "retry_fallback_succeeded"; model: string; role: string; } export interface ModelChangedEvent { type: "model_changed"; } export interface ConfigWarningsChangedEvent { type: "config_warnings_changed"; } export interface AdvisorCostChangedEvent { type: "advisor_cost_changed"; } export interface AdvisorYieldedEvent { type: "advisor_yielded"; } /** Rule injection: a TTSR rule matched the stream and its text was injected. Each rule carries at least `name`, `path`, and `content`. */ export interface TtsrTriggeredEvent { type: "ttsr_triggered"; rules: Record[]; } export interface TodoReminderEvent { type: "todo_reminder"; todos: TodoItem[]; attempt: number; maxAttempts: number; } export interface TodoAutoClearEvent { type: "todo_auto_clear"; } export interface IrcMessageEvent { type: "irc_message"; message: CustomMessage; } export interface NoticeEvent { type: "notice"; level: NotifyType; message: string; source?: string; } /** The effective thinking level changed. */ export interface ThinkingLevelChangedEvent { type: "thinking_level_changed"; thinkingLevel?: ThinkingLevel; /** The user's selector when it differs from the effective level. */ configured?: ConfiguredThinkingLevel; /** The level `auto` resolved to this turn, once classified. */ resolved?: Effort; } /** Goal mode changed, by a host `goal` command or the agent's `goal` tool. */ export interface GoalUpdatedEvent { type: "goal_updated"; goal: Goal | null; state?: GoalModeState; } /** Coalesced snapshot of the displayable steering/follow-up queue, sent whenever it changes. */ export interface QueueUpdateEvent { type: "queue_update"; steering: string[]; followUp: string[]; /** Leading `steering` entries are live steering already sent into the streaming response; `remove_queued_message` cannot reach them. */ liveSteered?: number; } /** A session event, discriminated by `type`; `set_event_filter` selects which are sent. */ export type RpcAgentEvent = AgentStartEvent | AgentEndEvent | TurnStartEvent | TurnEndEvent | MessageStartEvent | MessageUpdateEvent | MessageEndEvent | ToolExecutionStartEvent | ToolExecutionUpdateEvent | ToolStreamUpdateEvent | ToolExecutionEndEvent | AutoCompactionStartEvent | AutoCompactionEndEvent | ManualCompactionStartEvent | ManualCompactionEndEvent | AutoRetryStartEvent | AutoRetryEndEvent | CacheWarmingStartEvent | CacheWarmingEndEvent | RetryFallbackAppliedEvent | RetryFallbackSucceededEvent | ModelChangedEvent | ConfigWarningsChangedEvent | AdvisorCostChangedEvent | AdvisorYieldedEvent | TtsrTriggeredEvent | TodoReminderEvent | TodoAutoClearEvent | IrcMessageEvent | NoticeEvent | ThinkingLevelChangedEvent | GoalUpdatedEvent | QueueUpdateEvent; /** First frame after startup; transport fields are absent on servers without protocol v2. */ export interface ReadyEvent { type: "ready"; protocolVersion?: number; supportedProtocolVersions?: number[]; maxFrameBytes?: number; maxReassembledFrameBytes?: number; /** `bash` accepts `excludeFromContext`; require exactly true before sending excluded commands. */ supportsBashExcludeFromContext?: boolean; } export type PromptStatus = "completed" | "aborted" | "error"; /** Failure detail of a `prompt_result` with `status: "error"`. */ export interface PromptError { message: string; /** Transient: resubmitting later may succeed (omp's own retries are exhausted). */ retryable: boolean; provider?: string; model?: string; httpStatus?: number; /** `cost_cap`: the session reached `session.maxCost` (`--max-cost`) and omp did not send the next request. */ code?: "cost_cap"; } /** Terminal outcome of one accepted `prompt` / `abort_and_prompt`, keyed by request `id`. */ export interface PromptResultEvent { type: "prompt_result"; agentInvoked: boolean; status: PromptStatus; /** Nothing will wake the session again; when false a `session_settled` follows once background work drains. */ sessionSettled: boolean; id?: string; error?: PromptError; } /** The session went quiet: the last run yielded and no background work can wake it. */ export interface SessionSettledEvent { type: "session_settled"; } export interface ExtensionError { type: "extension_error"; extensionPath: string; event: string; error: string; } /** Slash-command catalog, pushed at startup and whenever command metadata changes. */ export interface AvailableCommandsUpdateEvent { type: "available_commands_update"; commands: AvailableSlashCommand[]; } export type SubagentLifecycleStatus = "started" | "completed" | "failed" | "aborted"; export interface SubagentLifecyclePayload { id: string; agent: string; agentSource: AgentSource; status: SubagentLifecycleStatus; index: number; description?: string; sessionFile?: string; parentToolCallId?: string; /** The subagent runs as a detached background job. */ detached?: boolean; } export interface SubagentProgressPayload { index: number; agent: string; agentSource: AgentSource; task: string; /** Raw `AgentProgress` record. */ progress: Record; parentToolCallId?: string; assignment?: string; sessionFile?: string; detached?: boolean; } export interface SubagentEventPayload { id: string; event: RpcAgentEvent; } /** A subagent started or ended; sent at subscription level "progress" or "events". */ export interface SubagentLifecycleEvent { type: "subagent_lifecycle"; payload: SubagentLifecyclePayload; } /** Aggregated subagent progress; sent at subscription level "progress" or "events". */ export interface SubagentProgressEvent { type: "subagent_progress"; payload: SubagentProgressPayload; } /** A subagent's own session event; sent only at subscription level "events". */ export interface SubagentEvent { type: "subagent_event"; payload: SubagentEventPayload; } export type LivePhase = "connecting" | "listening" | "working" | "speaking" | "muted" | "error"; export type LiveRole = "user" | "assistant"; export interface LivePhaseEvent { type: "live_phase"; phase: LivePhase; } /** Microphone (`input`) and speaker (`output`) RMS in [0, 1], at most every 100 ms. */ export interface LiveLevelsEvent { type: "live_levels"; input: number; output: number; } /** Accumulated text of one realtime turn; replaces earlier frames with the same `role` and `turn`. */ export interface LiveTranscriptEvent { type: "live_transcript"; role: LiveRole; turn: number; text: string; final: boolean; } /** Sent exactly once when a live session ends; `error` carries the failure cause. */ export interface LiveEndEvent { type: "live_end"; error?: string; } /** State of one draft-only microphone capture. */ export interface DictationStateEvent { type: "dictation_state"; captureId: string; state: "starting" | "recording" | "transcribing"; } /** Full accumulated draft preview; replaces the previous preview for this capture. */ export interface DictationTranscriptEvent { type: "dictation_transcript"; captureId: string; text: string; } /** Exactly one terminal frame per capture; text is the accumulated result. */ export interface DictationEndEvent { type: "dictation_end"; captureId: string; text: string; error?: string; } /** Text appended to the running side question's latest answer. */ export interface BtwDeltaEvent { type: "btw_delta"; recordId: string; delta: string; } /** Full side-question record on every lifecycle change (started, complete, cancelled, error); the last one per id wins. */ export interface BtwRecordEvent { type: "btw_record"; record: BtwHistoryRecord; } /** Output of a builtin slash command. */ export interface CommandOutputEvent { type: "command_output"; text: string; } /** A builtin slash command changed the session title. */ export interface SessionInfoUpdateEvent { type: "session_info_update"; sessionId: string; title?: string; } /** A builtin slash command changed the model configuration. */ export interface ConfigUpdateEvent { type: "config_update"; model?: ModelInfo; thinkingLevel?: ThinkingLevel; } /** An event could not fit within the transport limits and was dropped. */ export interface RpcFrameErrorEvent { type: "rpc_frame_error"; error: string; originalType?: string; } export type WidgetPlacement = "aboveEditor" | "belowEditor"; /** Presentation metadata aligned positionally with `options`. */ export interface SelectOptionDetail { description?: string; } export interface AskOption { label: string; description?: string; preview?: string; } /** One question of an `ask` request; hosts always offer free text besides `options`. */ export interface AskQuestion { id: string; question: string; options: AskOption[]; header?: string; multi?: boolean; /** Index into `options` of the recommended choice. */ recommended?: number; } export interface SelectUiRequest { type: "extension_ui_request"; id: string; method: "select"; title: string; options: string[]; optionDetails?: SelectOptionDetail[]; timeout?: number; } export interface ConfirmUiRequest { type: "extension_ui_request"; id: string; method: "confirm"; title: string; message: string; timeout?: number; } export interface InputUiRequest { type: "extension_ui_request"; id: string; method: "input"; title: string; placeholder?: string; timeout?: number; secret?: boolean; } export interface EditorUiRequest { type: "extension_ui_request"; id: string; method: "editor"; title: string; prefill?: string; promptStyle?: boolean; } /** Every question of one `ask` tool call; sent only after `set_ask_dialog` enables it. */ export interface AskUiRequest { type: "extension_ui_request"; id: string; method: "ask"; questions: AskQuestion[]; timeout?: number; } /** Close the dialog opened by request `targetId`; a later answer to it is ignored. */ export interface CancelUiRequest { type: "extension_ui_request"; id: string; method: "cancel"; targetId: string; } export interface NotifyUiRequest { type: "extension_ui_request"; id: string; method: "notify"; message: string; notifyType?: NotifyType; } export interface SetStatusUiRequest { type: "extension_ui_request"; id: string; method: "setStatus"; statusKey: string; statusText?: string; } export interface SetWidgetUiRequest { type: "extension_ui_request"; id: string; method: "setWidget"; widgetKey: string; widgetLines?: string[]; widgetPlacement?: WidgetPlacement; } export interface SetTitleUiRequest { type: "extension_ui_request"; id: string; method: "setTitle"; title: string; } export interface SetEditorTextUiRequest { type: "extension_ui_request"; id: string; method: "set_editor_text"; text: string; } export interface OpenUrlUiRequest { type: "extension_ui_request"; id: string; method: "open_url"; url: string; /** Short loopback redirect to `url`; the truncation-safe copy target. */ launchUrl?: string; instructions?: string; } /** Extension UI request, discriminated by `method`. */ export type ExtensionUiRequest = SelectUiRequest | ConfirmUiRequest | InputUiRequest | EditorUiRequest | AskUiRequest | CancelUiRequest | NotifyUiRequest | SetStatusUiRequest | SetWidgetUiRequest | SetTitleUiRequest | SetEditorTextUiRequest | OpenUrlUiRequest; /** Answer to one `ask` question: exact option labels, plus optional free text. */ export interface AskAnswer { id: string; selectedOptions: string[]; customInput?: string; } /** Answers a `select`, `input`, or `editor` request. */ export interface ValueUiResponse { type: "extension_ui_response"; id: string; value: string; } /** Answers a `confirm` request. */ export interface ConfirmUiResponse { type: "extension_ui_response"; id: string; confirmed: boolean; } /** Dismisses a dialog; `timedOut` reports the host's own deadline (an `ask` then takes its recommended answers). */ export interface CancelUiResponse { type: "extension_ui_response"; id: string; cancelled: true; timedOut?: boolean; } /** Answers an `ask` request: one `AskAnswer` per question, in question order. */ export interface AnswersUiResponse { type: "extension_ui_response"; id: string; answers: AskAnswer[]; } /** Host reply to an extension UI request; variants share `type` and differ by their payload key. */ export type ExtensionUiResponse = ValueUiResponse | ConfirmUiResponse | CancelUiResponse | AnswersUiResponse; export interface HostToolCallRequest { type: "host_tool_call"; id: string; toolCallId: string; toolName: string; arguments: Record; } export interface HostToolCancelRequest { type: "host_tool_cancel"; id: string; targetId: string; } /** Tool output: content blocks plus optional details. */ export interface HostToolResultPayload { content: UserContent[]; details?: unknown; isError?: boolean; useless?: boolean; providerMetadata?: Record; } /** Streams partial output of a pending host tool call. */ export interface HostToolUpdate { type: "host_tool_update"; id: string; partialResult: HostToolResultPayload; } /** Completes a pending host tool call; `isError` surfaces the content as a tool error. */ export interface HostToolResult { type: "host_tool_result"; id: string; result: HostToolResultPayload; isError?: boolean; } export type HostUriOperation = "read" | "write"; export interface HostUriRequest { type: "host_uri_request"; id: string; operation: HostUriOperation; url: string; /** Present for write operations. */ content?: string; } export interface HostUriCancelRequest { type: "host_uri_cancel"; id: string; targetId: string; } /** Completes a pending host URI request. */ export interface HostUriResult { type: "host_uri_result"; id: string; /** Required for a successful read. */ content?: string; contentType?: "text/markdown" | "application/json" | "text/plain"; notes?: string[]; immutable?: boolean; isError?: boolean; error?: string; } /** Server request for host-owned tools and URI schemes, discriminated by `type`. */ export type RpcHostRequest = HostToolCallRequest | HostToolCancelRequest | HostUriRequest | HostUriCancelRequest; /** Non-command frame the host sends, discriminated by `type`. */ export type RpcInbound = ExtensionUiResponse | HostToolUpdate | HostToolResult | HostUriResult; /** Response to a command, correlated by `id`. */ export interface RpcResponse { type: "response"; command: string; success: boolean; /** The command's `id`; absent for failures the server could not correlate. */ id?: string; /** Command result on success; its shape is the command's `result`. */ data?: unknown; /** Failure message when `success` is false. */ error?: string; /** Machine-readable failure reason, when one applies. */ code?: string; } export type ToolLoadMode = "essential" | "discoverable"; export interface HostToolDefinition { name: string; description: string; parameters: Record; label?: string; hidden?: boolean; loadMode?: ToolLoadMode; readsSkillUris?: boolean; } export interface HostUriSchemeDefinition { scheme: string; description?: string; writable?: boolean; immutable?: boolean; } /** Unsolicited outbound frame (everything except responses and host tool/URI requests), discriminated by `type`. */ export type RpcNotification = ReadyEvent | PromptResultEvent | SessionSettledEvent | ExtensionError | ExtensionUiRequest | AvailableCommandsUpdateEvent | SubagentLifecycleEvent | SubagentProgressEvent | SubagentEvent | LivePhaseEvent | LiveLevelsEvent | LiveTranscriptEvent | LiveEndEvent | DictationStateEvent | DictationTranscriptEvent | DictationEndEvent | BtwDeltaEvent | BtwRecordEvent | CommandOutputEvent | SessionInfoUpdateEvent | ConfigUpdateEvent | RpcFrameErrorEvent | RpcAgentEvent; /** Any frame the server writes to stdout (after reassembling `rpc_chunk` sequences), discriminated by `type`. */ export type RpcServerFrame = RpcResponse | RpcHostRequest | RpcNotification; export interface NegotiateProtocolParams { protocolVersion: number; } export interface NegotiateProtocolResult { protocolVersion: number; } export interface PromptParams { message: string; /** Images attached to the message. */ images?: ImageContent[]; streamingBehavior?: StreamingBehavior; } export interface SteerParams { message: string; /** Images attached to the message. */ images?: ImageContent[]; } export interface FollowUpParams { message: string; /** Images attached to the message. */ images?: ImageContent[]; } export interface RemoveQueuedMessageParams { message: string; queue: QueuedMessageQueue; } export interface PromoteQueuedMessageParams { message: string; } export interface AbortAndPromptParams { message: string; /** Images attached to the message. */ images?: ImageContent[]; } export interface NewSessionParams { parentSession?: string; } export interface OpenSessionParams { sessionDir: string; provider?: string; modelId?: string; } export interface SetFastModeParams { enabled: boolean; } export interface SetSlowModeParams { enabled: boolean; } export interface SetSlowModeResult { enabled: boolean; } export interface GoalParams { op: GoalOp; objective?: string; token_budget?: number; } export interface SetAskDialogParams { enabled: boolean; } export interface SetAskDialogResult { enabled: boolean; } export interface GetAvailableCommandsResult { commands: AvailableSlashCommand[]; } export interface GetEntriesParams { since?: string; } export interface SetTodosParams { phases: TodoPhase[]; } export interface SetTodosResult { todoPhases: TodoPhase[]; } export interface SetHostToolsParams { tools: HostToolDefinition[]; } export interface SetHostToolsResult { toolNames: string[]; } export interface SetHostUriSchemesParams { schemes: HostUriSchemeDefinition[]; } export interface SetHostUriSchemesResult { schemes: string[]; } export interface SetSubagentSubscriptionParams { level: SubagentSubscriptionLevel; } export interface SetSubagentSubscriptionResult { level: SubagentSubscriptionLevel; } export interface SetEventFilterParams { events: string[] | null; messageUpdates?: MessageUpdates; } export interface SetEventFilterResult { events: string[] | null; messageUpdates?: MessageUpdates; } export interface GetSubagentsResult { subagents: SubagentSnapshot[]; } export interface GetSubagentMessagesParams { subagentId?: string; sessionFile?: string; fromByte?: number; } export interface CancelSubagentParams { subagentId: string; } export interface CancelSubagentResult { cancelled: boolean; } export interface SteerSubagentParams { subagentId: string; message: string; } export interface LiveStartParams { voice?: string; instructions?: string; } export interface LiveStartResult { voice: string; } export interface LiveConnectParams { sdpOffer: string; voice?: string; instructions?: string; } export interface LiveConnectResult { voice: string; sdpAnswer: string; } export interface LiveMuteParams { muted?: boolean; } export interface LiveMuteResult { muted: boolean; } export interface DictationStartParams { captureId: string; } export interface DictationStopResult { text: string; } export interface SetModelParams { provider: string; modelId: string; } export interface GetAvailableModelsResult { models: ModelInfo[]; } export interface SetThinkingLevelParams { level: ThinkingLevel; } export interface GetAvailableThinkingLevelsResult { levels: ThinkingLevel[]; } export interface SetSteeringModeParams { mode: QueueMode; } export interface SetFollowUpModeParams { mode: QueueMode; } export interface SetInterruptModeParams { mode: InterruptMode; } export interface CompactParams { customInstructions?: string; } export interface SetAutoCompactionParams { enabled: boolean; } export interface SetCacheWarmingParams { mode: CacheWarmingMode; } export interface SetCacheWarmingResult { mode: CacheWarmingMode; } export interface SetAutoRetryParams { enabled: boolean; } export interface BashParams { command: string; excludeFromContext?: boolean; } export interface GetSessionLeaseParams { sessionIds: string[]; } export interface GetSessionLeaseResult { held: string[]; unknown: string[]; } export interface ExportHtmlParams { outputPath?: string; } export interface ExportHtmlResult { path: string; } export interface SwitchSessionParams { sessionPath: string; provider?: string; modelId?: string; } export interface BranchParams { entryId: string; } export interface ForkParams { entryId?: string; } export interface NavigateTreeParams { entryId: string; /** Summarize the abandoned branch at the target. */ summarize?: boolean; /** Instructions for the summarizer. */ customInstructions?: string; } export interface SetLabelParams { entryId: string; label?: string; } export interface GetBranchMessagesResult { messages: BranchMessage[]; } export interface GetLastAssistantTextResult { text: string | null; } export interface SetSessionNameParams { name: string; } export interface HandoffParams { customInstructions?: string; } export interface GetMessagesResult { messages: AgentMessage[]; } export interface GetMessagesPageParams { cursor?: string; limit?: number; } export interface GetLoginProvidersResult { providers: LoginProvider[]; } export interface LoginParams { providerId: string; } export interface LoginResult { providerId: string; } export interface GetLogoutAccountsParams { providerId: string; } export interface GetLogoutAccountsResult { accounts: LogoutAccount[]; } export interface LogoutParams { providerId: string; credentialId: number; } export interface LogoutResult { remainingSource?: string; } export interface PredictWordParams { text: string; cursor: number; } export interface PredictWordResult { suffix: string | null; } export interface PredictWordFeedbackParams { text: string; cursor: number; suggestion: string; accepted: boolean; } export interface BtwParams { question: string; recordId?: string; } export interface BtwResult { record: BtwHistoryRecord; } export interface BtwCancelParams { recordId?: string; } export interface BtwCancelResult { cancelled: boolean; } export interface GetBtwHistoryResult { records: BtwHistoryRecord[]; } /** Every RPC command's parameters and successful response `data`. */ export interface RpcWireCommands { negotiate_protocol: { params: NegotiateProtocolParams; result: NegotiateProtocolResult }; prompt: { params: PromptParams; result: PromptAck }; steer: { params: SteerParams; result: undefined }; follow_up: { params: FollowUpParams; result: undefined }; remove_queued_message: { params: RemoveQueuedMessageParams; result: RemoveQueuedMessageResult }; promote_queued_message: { params: PromoteQueuedMessageParams; result: PromoteQueuedMessageResult }; abort: { params: undefined; result: undefined }; abort_and_prompt: { params: AbortAndPromptParams; result: undefined }; abort_and_restore_queue: { params: undefined; result: AbortAndRestoreQueueResult }; new_session: { params: NewSessionParams; result: CancellationResult }; open_session: { params: OpenSessionParams; result: OpenSessionResult }; get_state: { params: undefined; result: SessionState }; set_fast_mode: { params: SetFastModeParams; result: FastModeResult }; set_slow_mode: { params: SetSlowModeParams; result: SetSlowModeResult }; goal: { params: GoalParams; result: GoalResult }; set_ask_dialog: { params: SetAskDialogParams; result: SetAskDialogResult }; get_available_commands: { params: undefined; result: GetAvailableCommandsResult }; get_entries: { params: GetEntriesParams; result: SessionEntries }; get_tree: { params: undefined; result: SessionTree }; set_todos: { params: SetTodosParams; result: SetTodosResult }; set_host_tools: { params: SetHostToolsParams; result: SetHostToolsResult }; set_host_uri_schemes: { params: SetHostUriSchemesParams; result: SetHostUriSchemesResult }; set_subagent_subscription: { params: SetSubagentSubscriptionParams; result: SetSubagentSubscriptionResult }; set_event_filter: { params: SetEventFilterParams; result: SetEventFilterResult }; get_subagents: { params: undefined; result: GetSubagentsResult }; get_subagent_messages: { params: GetSubagentMessagesParams; result: SubagentMessages }; cancel_subagent: { params: CancelSubagentParams; result: CancelSubagentResult }; steer_subagent: { params: SteerSubagentParams; result: undefined }; live_start: { params: LiveStartParams; result: LiveStartResult }; live_connect: { params: LiveConnectParams; result: LiveConnectResult }; live_stop: { params: undefined; result: undefined }; live_mute: { params: LiveMuteParams; result: LiveMuteResult }; dictation_start: { params: DictationStartParams; result: undefined }; dictation_stop: { params: undefined; result: DictationStopResult }; set_model: { params: SetModelParams; result: ModelInfo }; cycle_model: { params: undefined; result: ModelCycleResult | null }; get_available_models: { params: undefined; result: GetAvailableModelsResult }; set_thinking_level: { params: SetThinkingLevelParams; result: undefined }; cycle_thinking_level: { params: undefined; result: ThinkingLevelCycleResult | null }; get_available_thinking_levels: { params: undefined; result: GetAvailableThinkingLevelsResult }; set_steering_mode: { params: SetSteeringModeParams; result: undefined }; set_follow_up_mode: { params: SetFollowUpModeParams; result: undefined }; set_interrupt_mode: { params: SetInterruptModeParams; result: undefined }; compact: { params: CompactParams; result: CompactionResult }; set_auto_compaction: { params: SetAutoCompactionParams; result: undefined }; set_cache_warming: { params: SetCacheWarmingParams; result: SetCacheWarmingResult }; set_auto_retry: { params: SetAutoRetryParams; result: undefined }; abort_retry: { params: undefined; result: undefined }; bash: { params: BashParams; result: BashResult }; abort_bash: { params: undefined; result: undefined }; get_session_stats: { params: undefined; result: SessionStats }; get_session_lease: { params: GetSessionLeaseParams; result: GetSessionLeaseResult }; export_html: { params: ExportHtmlParams; result: ExportHtmlResult }; switch_session: { params: SwitchSessionParams; result: CancellationResult }; branch: { params: BranchParams; result: BranchResult }; fork: { params: ForkParams; result: CancellationResult }; navigate_tree: { params: NavigateTreeParams; result: NavigateTreeResult }; abort_branch_summary: { params: undefined; result: undefined }; set_label: { params: SetLabelParams; result: undefined }; get_branch_messages: { params: undefined; result: GetBranchMessagesResult }; get_last_assistant_text: { params: undefined; result: GetLastAssistantTextResult }; set_session_name: { params: SetSessionNameParams; result: undefined }; handoff: { params: HandoffParams; result: HandoffResult | null }; get_messages: { params: undefined; result: GetMessagesResult }; get_messages_page: { params: GetMessagesPageParams; result: MessagesPage }; get_login_providers: { params: undefined; result: GetLoginProvidersResult }; login: { params: LoginParams; result: LoginResult }; get_logout_accounts: { params: GetLogoutAccountsParams; result: GetLogoutAccountsResult }; logout: { params: LogoutParams; result: LogoutResult }; predict_word: { params: PredictWordParams; result: PredictWordResult }; predict_word_feedback: { params: PredictWordFeedbackParams; result: undefined }; btw: { params: BtwParams; result: BtwResult }; btw_cancel: { params: BtwCancelParams; result: BtwCancelResult }; get_btw_history: { params: undefined; result: GetBtwHistoryResult }; }