Path: blob/main/src/vs/platform/agentHost/common/state/protocol/actions.ts
13405 views
/*---------------------------------------------------------------------------------------------1* Copyright (c) Microsoft Corporation. All rights reserved.2* Licensed under the MIT License. See License.txt in the project root for license information.3*--------------------------------------------------------------------------------------------*/45// allow-any-unicode-comment-file6// DO NOT EDIT -- auto-generated by scripts/sync-agent-host-protocol.ts78import { ToolCallConfirmationReason, ToolCallCancellationReason, PendingMessageKind, type URI, type StringOrMarkdown, type AgentInfo, type ErrorInfo, type ModelSelection, type UserMessage, type ResponsePart, type ToolCallResult, type ToolResultContent, type ToolDefinition, type SessionActiveClient, type UsageInfo, type SessionCustomization, type FileEdit, type SessionInputAnswer, type SessionInputRequest, type TerminalInfo, type TerminalClaim, type SessionInputResponseKind, type ConfirmationOption } from './state.js';91011// ─── Action Type Enum ────────────────────────────────────────────────────────1213/**14* Discriminant values for all state actions.15*16* @category Actions17*/18export const enum ActionType {19RootAgentsChanged = 'root/agentsChanged',20RootActiveSessionsChanged = 'root/activeSessionsChanged',21SessionReady = 'session/ready',22SessionCreationFailed = 'session/creationFailed',23SessionTurnStarted = 'session/turnStarted',24SessionDelta = 'session/delta',25SessionResponsePart = 'session/responsePart',26SessionToolCallStart = 'session/toolCallStart',27SessionToolCallDelta = 'session/toolCallDelta',28SessionToolCallReady = 'session/toolCallReady',29SessionToolCallConfirmed = 'session/toolCallConfirmed',30SessionToolCallComplete = 'session/toolCallComplete',31SessionToolCallResultConfirmed = 'session/toolCallResultConfirmed',32SessionToolCallContentChanged = 'session/toolCallContentChanged',33SessionTurnComplete = 'session/turnComplete',34SessionTurnCancelled = 'session/turnCancelled',35SessionError = 'session/error',36SessionTitleChanged = 'session/titleChanged',37SessionUsage = 'session/usage',38SessionReasoning = 'session/reasoning',39SessionModelChanged = 'session/modelChanged',40SessionServerToolsChanged = 'session/serverToolsChanged',41SessionActiveClientChanged = 'session/activeClientChanged',42SessionActiveClientToolsChanged = 'session/activeClientToolsChanged',43SessionPendingMessageSet = 'session/pendingMessageSet',44SessionPendingMessageRemoved = 'session/pendingMessageRemoved',45SessionQueuedMessagesReordered = 'session/queuedMessagesReordered',46SessionInputRequested = 'session/inputRequested',47SessionInputAnswerChanged = 'session/inputAnswerChanged',48SessionInputCompleted = 'session/inputCompleted',49SessionCustomizationsChanged = 'session/customizationsChanged',50SessionCustomizationToggled = 'session/customizationToggled',51SessionTruncated = 'session/truncated',52SessionIsReadChanged = 'session/isReadChanged',53SessionIsArchivedChanged = 'session/isArchivedChanged',54SessionActivityChanged = 'session/activityChanged',55SessionDiffsChanged = 'session/diffsChanged',56SessionConfigChanged = 'session/configChanged',57SessionMetaChanged = 'session/metaChanged',58RootTerminalsChanged = 'root/terminalsChanged',59RootConfigChanged = 'root/configChanged',60TerminalData = 'terminal/data',61TerminalInput = 'terminal/input',62TerminalResized = 'terminal/resized',63TerminalClaimed = 'terminal/claimed',64TerminalTitleChanged = 'terminal/titleChanged',65TerminalCwdChanged = 'terminal/cwdChanged',66TerminalExited = 'terminal/exited',67TerminalCleared = 'terminal/cleared',68TerminalCommandDetectionAvailable = 'terminal/commandDetectionAvailable',69TerminalCommandExecuted = 'terminal/commandExecuted',70TerminalCommandFinished = 'terminal/commandFinished',71}7273// ─── Action Envelope ─────────────────────────────────────────────────────────7475/**76* Identifies the client that originally dispatched an action.77*/78export interface ActionOrigin {79clientId: string;80clientSeq: number;81}8283/**84* Every action is wrapped in an `ActionEnvelope`.85*/86export interface ActionEnvelope {87readonly action: StateAction;88readonly serverSeq: number;89readonly origin: ActionOrigin | undefined;90readonly rejectionReason?: string;91}9293// ─── Root Actions ────────────────────────────────────────────────────────────9495/**96* Base interface for all tool-call-scoped actions, carrying the common97* session, turn, and tool call identifiers.98*99* @category Session Actions100*/101interface ToolCallActionBase {102/** Session URI */103session: URI;104/** Turn identifier */105turnId: string;106/** Tool call identifier */107toolCallId: string;108/**109* Additional provider-specific metadata for this tool call.110*111* Clients MAY look for well-known keys here to provide enhanced UI.112* For example, a `ptyTerminal` key with `{ input: string; output: string }`113* indicates the tool operated on a terminal (both `input` and `output` may114* contain escape sequences).115*/116_meta?: Record<string, unknown>;117}118119/**120* Fired when available agent backends or their models change.121*122* @category Root Actions123* @version 1124*/125export interface RootAgentsChangedAction {126type: ActionType.RootAgentsChanged;127/** Updated agent list */128agents: AgentInfo[];129}130131/**132* Fired when the number of active sessions changes.133*134* @category Root Actions135* @version 1136*/137export interface RootActiveSessionsChangedAction {138type: ActionType.RootActiveSessionsChanged;139/** Current count of active sessions */140activeSessions: number;141}142143/**144* Fired when the list of known terminals changes.145*146* Full-replacement semantics: the `terminals` array replaces the previous147* `terminals` entirely.148*149* @category Root Actions150* @version 1151*/152export interface RootTerminalsChangedAction {153type: ActionType.RootTerminalsChanged;154/** Updated terminal list (full replacement) */155terminals: TerminalInfo[];156}157158/**159* Fired when agent-host configuration values change.160*161* By default, the reducer merges the new values into `state.config.values`.162* Set `replace` to `true` to replace all values instead of merging.163*164* @category Root Actions165* @version 1166* @clientDispatchable167*/168export interface RootConfigChangedAction {169type: ActionType.RootConfigChanged;170/** Updated config values */171config: Record<string, unknown>;172/** When `true`, replaces all config values instead of merging */173replace?: boolean;174}175176// ─── Session Actions ─────────────────────────────────────────────────────────177178/**179* Session backend initialized successfully.180*181* @category Session Actions182* @version 1183*/184export interface SessionReadyAction {185type: ActionType.SessionReady;186/** Session URI */187session: URI;188}189190/**191* Session backend failed to initialize.192*193* @category Session Actions194* @version 1195*/196export interface SessionCreationFailedAction {197type: ActionType.SessionCreationFailed;198/** Session URI */199session: URI;200/** Error details */201error: ErrorInfo;202}203204/**205* User sent a message; server starts agent processing.206*207* @category Session Actions208* @version 1209* @clientDispatchable210*/211export interface SessionTurnStartedAction {212type: ActionType.SessionTurnStarted;213/** Session URI */214session: URI;215/** Turn identifier */216turnId: string;217/** User's message */218userMessage: UserMessage;219/** If this turn was auto-started from a queued message, the ID of that message */220queuedMessageId?: string;221}222223/**224* Streaming text chunk from the assistant, appended to a specific response part.225*226* The server MUST first emit a `session/responsePart` to create the target227* part (markdown or reasoning), then use this action to append text to it.228*229* @category Session Actions230* @version 1231*/232export interface SessionDeltaAction {233type: ActionType.SessionDelta;234/** Session URI */235session: URI;236/** Turn identifier */237turnId: string;238/** Identifier of the response part to append to */239partId: string;240/** Text chunk */241content: string;242}243244/**245* Structured content appended to the response.246*247* @category Session Actions248* @version 1249*/250export interface SessionResponsePartAction {251type: ActionType.SessionResponsePart;252/** Session URI */253session: URI;254/** Turn identifier */255turnId: string;256/** Response part (markdown or content ref) */257part: ResponsePart;258}259260/**261* A tool call begins — parameters are streaming from the LM.262*263* For client-provided tools, the server sets `toolClientId` to identify the264* owning client. That client is responsible for executing the tool once it265* reaches the `running` state and dispatching `session/toolCallComplete`.266*267* @category Session Actions268* @version 1269*/270export interface SessionToolCallStartAction extends ToolCallActionBase {271type: ActionType.SessionToolCallStart;272/** Internal tool name (for debugging/logging) */273toolName: string;274/** Human-readable tool name */275displayName: string;276/**277* If this tool is provided by a client, the `clientId` of the owning client.278* Absent for server-side tools.279*/280toolClientId?: string;281}282283/**284* Streaming partial parameters for a tool call.285*286* @category Session Actions287* @version 1288*/289export interface SessionToolCallDeltaAction extends ToolCallActionBase {290type: ActionType.SessionToolCallDelta;291/** Partial parameter content to append */292content: string;293/** Updated progress message */294invocationMessage?: StringOrMarkdown;295}296297/**298* Tool call parameters are complete, or a running tool requires re-confirmation.299*300* When dispatched for a `streaming` tool call, transitions to `pending-confirmation`301* or directly to `running` if `confirmed` is set.302*303* When dispatched for a `running` tool call (e.g. mid-execution permission needed),304* transitions back to `pending-confirmation`. The `invocationMessage` and `_meta`305* SHOULD be updated to describe the specific confirmation needed. Clients use the306* standard `session/toolCallConfirmed` flow to approve or deny.307*308* For client-provided tools, the server typically sets `confirmed` to309* `'not-needed'` so the tool transitions directly to `running`, where the310* owning client can begin execution immediately.311*312* @category Session Actions313* @version 1314*/315export interface SessionToolCallReadyAction extends ToolCallActionBase {316type: ActionType.SessionToolCallReady;317/** Message describing what the tool will do or what confirmation is needed */318invocationMessage: StringOrMarkdown;319/** Raw tool input */320toolInput?: string;321/** Short title for the confirmation prompt (e.g. `"Run in terminal"`, `"Write file"`) */322confirmationTitle?: StringOrMarkdown;323/** File edits that this tool call will perform, for preview before confirmation */324edits?: { items: FileEdit[] };325/** Whether the agent host allows the client to edit the tool's input parameters before confirming */326editable?: boolean;327/** If set, the tool was auto-confirmed and transitions directly to `running` */328confirmed?: ToolCallConfirmationReason;329/**330* Options the server offers for this confirmation. When present, the client331* SHOULD render these instead of a plain approve/deny UI. Each option332* belongs to a {@link ConfirmationOptionGroup} so the client can still333* categorise the choices.334*/335options?: ConfirmationOption[];336}337338/**339* Client approves a pending tool call. The tool transitions to `running`.340*341* @category Session Actions342* @version 1343* @clientDispatchable344*/345export interface SessionToolCallApprovedAction extends ToolCallActionBase {346type: ActionType.SessionToolCallConfirmed;347/** The tool call was approved */348approved: true;349/** How the tool was confirmed */350confirmed: ToolCallConfirmationReason;351/** Edited tool input parameters, if the client modified them before confirming */352editedToolInput?: string;353/** ID of the selected confirmation option, if the server provided options */354selectedOptionId?: string;355}356357/**358* Client denies a pending tool call. The tool transitions to `cancelled`.359*360* For client-provided tools, the owning client MUST dispatch this if it does361* not recognize the tool or cannot execute it.362*363* @category Session Actions364* @version 1365* @clientDispatchable366*/367export interface SessionToolCallDeniedAction extends ToolCallActionBase {368type: ActionType.SessionToolCallConfirmed;369/** The tool call was denied */370approved: false;371/** Why the tool was cancelled */372reason: ToolCallCancellationReason.Denied | ToolCallCancellationReason.Skipped;373/** What the user suggested doing instead */374userSuggestion?: UserMessage;375/** Optional explanation for the denial */376reasonMessage?: StringOrMarkdown;377/** ID of the selected confirmation option, if the server provided options */378selectedOptionId?: string;379}380381/**382* Client confirms or denies a pending tool call.383*384* @category Session Actions385* @version 1386* @clientDispatchable387*/388export type SessionToolCallConfirmedAction =389| SessionToolCallApprovedAction390| SessionToolCallDeniedAction;391392/**393* Tool execution finished. Transitions to `completed` or `pending-result-confirmation`394* if `requiresResultConfirmation` is `true`.395*396* For client-provided tools (where `toolClientId` is set on the tool call state),397* the owning client dispatches this action with the execution result. The server398* SHOULD reject this action if the dispatching client does not match `toolClientId`.399*400* Servers waiting on a client tool call MAY time out after a reasonable duration401* if the implementing client disconnects or becomes unresponsive, and dispatch402* this action with `result.success = false` and an appropriate error.403*404* @category Session Actions405* @version 1406* @clientDispatchable407*/408export interface SessionToolCallCompleteAction extends ToolCallActionBase {409type: ActionType.SessionToolCallComplete;410/** Execution result */411result: ToolCallResult;412/** If true, the result requires client approval before finalizing */413requiresResultConfirmation?: boolean;414}415416/**417* Client approves or denies a tool's result.418*419* If `approved` is `false`, the tool transitions to `cancelled` with reason `result-denied`.420*421* @category Session Actions422* @version 1423* @clientDispatchable424*/425export interface SessionToolCallResultConfirmedAction extends ToolCallActionBase {426type: ActionType.SessionToolCallResultConfirmed;427/** Whether the result was approved */428approved: boolean;429}430431/**432* Partial content produced while a tool is still executing.433*434* Replaces the `content` array on the running tool call state. Clients can435* use this to display live feedback (e.g. a terminal reference) before the436* tool completes.437*438* For client-provided tools (where `toolClientId` is set on the tool call state),439* the owning client dispatches this action to stream intermediate content while440* executing. The server SHOULD reject this action if the dispatching client does441* not match `toolClientId`.442*443* @category Session Actions444* @version 1445* @clientDispatchable446*/447export interface SessionToolCallContentChangedAction extends ToolCallActionBase {448type: ActionType.SessionToolCallContentChanged;449/** The current partial content for the running tool call */450content: ToolResultContent[];451}452453/**454* Turn finished — the assistant is idle.455*456* @category Session Actions457* @version 1458*/459export interface SessionTurnCompleteAction {460type: ActionType.SessionTurnComplete;461/** Session URI */462session: URI;463/** Turn identifier */464turnId: string;465}466467/**468* Turn was aborted; server stops processing.469*470* @category Session Actions471* @version 1472* @clientDispatchable473*/474export interface SessionTurnCancelledAction {475type: ActionType.SessionTurnCancelled;476/** Session URI */477session: URI;478/** Turn identifier */479turnId: string;480}481482/**483* Error during turn processing.484*485* @category Session Actions486* @version 1487*/488export interface SessionErrorAction {489type: ActionType.SessionError;490/** Session URI */491session: URI;492/** Turn identifier */493turnId: string;494/** Error details */495error: ErrorInfo;496}497498/**499* Session title updated. Fired by the server when the title is auto-generated500* from conversation, or dispatched by a client to rename a session.501*502* @category Session Actions503* @clientDispatchable504* @version 1505*/506export interface SessionTitleChangedAction {507type: ActionType.SessionTitleChanged;508/** Session URI */509session: URI;510/** New title */511title: string;512}513514/**515* Token usage report for a turn.516*517* @category Session Actions518* @version 1519*/520export interface SessionUsageAction {521type: ActionType.SessionUsage;522/** Session URI */523session: URI;524/** Turn identifier */525turnId: string;526/** Token usage data */527usage: UsageInfo;528}529530/**531* Reasoning/thinking text from the model, appended to a specific reasoning response part.532*533* The server MUST first emit a `session/responsePart` to create the target534* reasoning part, then use this action to append text to it.535*536* @category Session Actions537* @version 1538*/539export interface SessionReasoningAction {540type: ActionType.SessionReasoning;541/** Session URI */542session: URI;543/** Turn identifier */544turnId: string;545/** Identifier of the reasoning response part to append to */546partId: string;547/** Reasoning text chunk */548content: string;549}550551/**552* Model changed for this session.553*554* @category Session Actions555* @version 1556* @clientDispatchable557*/558export interface SessionModelChangedAction {559type: ActionType.SessionModelChanged;560/** Session URI */561session: URI;562/** New model selection */563model: ModelSelection;564}565566/**567* The read state of the session changed.568*569* Dispatched by a client to mark a session as read (e.g. after viewing it)570* or unread (e.g. after new activity since the client last looked at it).571*572* @category Session Actions573* @version 1574* @clientDispatchable575*/576export interface SessionIsReadChangedAction {577type: ActionType.SessionIsReadChanged;578/** Session URI */579session: URI;580/** Whether the session has been read */581isRead: boolean;582}583584/**585* The archived state of the session changed.586*587* Dispatched by a client to archive a session (e.g. the task is588* complete) or to unarchive it.589*590* @category Session Actions591* @version 1592* @clientDispatchable593*/594export interface SessionIsArchivedChangedAction {595type: ActionType.SessionIsArchivedChanged;596/** Session URI */597session: URI;598/** Whether the session is archived */599isArchived: boolean;600}601602/**603* The activity description of the session changed.604*605* Dispatched by the server to indicate what the session is currently doing606* (e.g. running a tool, thinking). Clear activity by setting it to `undefined`.607*608* @category Session Actions609* @version 1610*/611export interface SessionActivityChangedAction {612type: ActionType.SessionActivityChanged;613/** Session URI */614session: URI;615/** Human-readable description of current activity, or `undefined` to clear */616activity: string | undefined;617}618619/**620* The file diffs for the session changed.621*622* Full-replacement semantics: the `diffs` array replaces the previous623* `summary.diffs` entirely.624*625* @category Session Actions626* @version 1627*/628export interface SessionDiffsChangedAction {629type: ActionType.SessionDiffsChanged;630/** Session URI */631session: URI;632/** Updated file diffs for the session */633diffs: FileEdit[];634}635636/**637* Server tools for this session have changed.638*639* Full-replacement semantics: the `tools` array replaces the previous `serverTools` entirely.640*641* @category Session Actions642* @version 1643*/644export interface SessionServerToolsChangedAction {645type: ActionType.SessionServerToolsChanged;646/** Session URI */647session: URI;648/** Updated server tools list (full replacement) */649tools: ToolDefinition[];650}651652/**653* The active client for this session has changed.654*655* A client dispatches this action with its own `SessionActiveClient` to claim656* the active role, or with `null` to release it. The server SHOULD reject if657* another client is already active. The server SHOULD automatically dispatch658* this action with `activeClient: null` when the active client disconnects.659*660* @category Session Actions661* @version 1662* @clientDispatchable663*/664export interface SessionActiveClientChangedAction {665type: ActionType.SessionActiveClientChanged;666/** Session URI */667session: URI;668/** The new active client, or `null` to unset */669activeClient: SessionActiveClient | null;670}671672/**673* The active client's tool list has changed.674*675* Full-replacement semantics: the `tools` array replaces the active client's676* previous tools entirely. The server SHOULD reject if the dispatching client677* is not the current active client.678*679* @category Session Actions680* @version 1681* @clientDispatchable682*/683export interface SessionActiveClientToolsChangedAction {684type: ActionType.SessionActiveClientToolsChanged;685/** Session URI */686session: URI;687/** Updated client tools list (full replacement) */688tools: ToolDefinition[];689}690691// ─── Customization Actions ───────────────────────────────────────────────────692693/**694* The session's customizations have changed.695*696* Full-replacement semantics: the `customizations` array replaces the697* previous `customizations` entirely.698*699* @category Session Actions700* @version 1701*/702export interface SessionCustomizationsChangedAction {703type: ActionType.SessionCustomizationsChanged;704/** Session URI */705session: URI;706/** Updated customization list (full replacement) */707customizations: SessionCustomization[];708}709710/**711* A client toggled a customization on or off.712*713* The server locates the customization by `uri` in the session's714* customization list and sets its `enabled` flag.715*716* @category Session Actions717* @version 1718* @clientDispatchable719*/720export interface SessionCustomizationToggledAction {721type: ActionType.SessionCustomizationToggled;722/** Session URI */723session: URI;724/** The URI of the customization to toggle */725uri: URI;726/** Whether to enable or disable the customization */727enabled: boolean;728}729730// ─── Config Actions ──────────────────────────────────────────────────────────731732/**733* Client changed a mutable config value mid-session.734*735* Only properties with `sessionMutable: true` in the config schema may be736* changed. The server validates and broadcasts the action; the reducer merges737* the new values into `state.config.values`.738*739* @category Session Actions740* @version 1741* @clientDispatchable742*/743export interface SessionConfigChangedAction {744type: ActionType.SessionConfigChanged;745/** Session URI */746session: URI;747/** Updated config values */748config: Record<string, unknown>;749/** When `true`, replaces all config values instead of merging */750replace?: boolean;751}752753/**754* The session's `_meta` side-channel changed. Replaces `state._meta`755* entirely (full-replacement semantics). Producers SHOULD merge any756* keys they wish to preserve into the new value before dispatching.757*758* @category Session Actions759* @version 1760*/761export interface SessionMetaChangedAction {762type: ActionType.SessionMetaChanged;763/** Session URI */764session: URI;765/** New `_meta` payload, or `undefined` to clear it */766_meta: Record<string, unknown> | undefined;767}768769// ─── Truncation ──────────────────────────────────────────────────────────────770771/**772* Truncates a session's history. If `turnId` is provided, all turns after that773* turn are removed and the specified turn is kept. If `turnId` is omitted, all774* turns are removed.775*776* If there is an active turn it is silently dropped and the session status777* returns to `idle`.778*779* Common use-case: truncate old data then dispatch a new780* `session/turnStarted` with an edited message.781*782* @category Session Actions783* @version 1784* @clientDispatchable785*/786export interface SessionTruncatedAction {787type: ActionType.SessionTruncated;788/** Session URI */789session: URI;790/** Keep turns up to and including this turn. Omit to clear all turns. */791turnId?: string;792}793794// ─── Pending Message Actions ─────────────────────────────────────────────────795796/**797* A pending message was set (upsert semantics: creates or replaces).798*799* For steering messages, this always replaces the single steering message.800* For queued messages, if a message with the given `id` already exists it is801* updated in place; otherwise it is appended to the queue. If the session is802* idle when a queued message is set, the server SHOULD immediately consume it803* and start a new turn.804*805* @category Session Actions806* @version 1807* @clientDispatchable808*/809export interface SessionPendingMessageSetAction {810type: ActionType.SessionPendingMessageSet;811/** Session URI */812session: URI;813/** Whether this is a steering or queued message */814kind: PendingMessageKind;815/** Unique identifier for this pending message */816id: string;817/** The message content */818userMessage: UserMessage;819}820821/**822* A pending message was removed (steering or queued).823*824* Dispatched by clients to cancel a pending message, or by the server when825* it consumes a message (e.g. starting a turn from a queued message or826* injecting a steering message into the current turn).827*828* @category Session Actions829* @version 1830* @clientDispatchable831*/832export interface SessionPendingMessageRemovedAction {833type: ActionType.SessionPendingMessageRemoved;834/** Session URI */835session: URI;836/** Whether this is a steering or queued message */837kind: PendingMessageKind;838/** Identifier of the pending message to remove */839id: string;840}841842/**843* Reorder the queued messages.844*845* The `order` array contains the IDs of queued messages in their new846* desired order. IDs not present in the current queue are ignored.847* Queued messages whose IDs are absent from `order` are appended at848* the end in their original relative order (so a client with a stale849* view of the queue never silently drops messages).850*851* @category Session Actions852* @version 1853* @clientDispatchable854*/855export interface SessionQueuedMessagesReorderedAction {856type: ActionType.SessionQueuedMessagesReordered;857/** Session URI */858session: URI;859/** Queued message IDs in the desired order */860order: string[];861}862863// ─── Session Input Actions ──────────────────────────────────────────────────864865/**866* A session requested input from the user.867*868* Full-request upsert semantics: the `request` replaces any existing request869* with the same `id`, or is appended if it is new. Answer drafts are preserved870* unless `request.answers` is provided.871*872* @category Session Actions873* @version 1874*/875export interface SessionInputRequestedAction {876type: ActionType.SessionInputRequested;877/** Session URI */878session: URI;879/** Input request to create or replace */880request: SessionInputRequest;881}882883/**884* A client updated, submitted, skipped, or removed a single in-progress answer.885*886* Dispatching with `answer: undefined` removes that question's answer draft.887*888* @category Session Actions889* @version 1890* @clientDispatchable891*/892export interface SessionInputAnswerChangedAction {893type: ActionType.SessionInputAnswerChanged;894/** Session URI */895session: URI;896/** Input request identifier */897requestId: string;898/** Question identifier within the input request */899questionId: string;900/** Updated answer, or `undefined` to clear an answer draft */901answer?: SessionInputAnswer;902}903904/**905* A client accepted, declined, or cancelled a session input request.906*907* If accepted, the server uses `answers` (when provided) plus the request's908* synced answer state to resume the blocked operation.909*910* @category Session Actions911* @version 1912* @clientDispatchable913*/914export interface SessionInputCompletedAction {915type: ActionType.SessionInputCompleted;916/** Session URI */917session: URI;918/** Input request identifier */919requestId: string;920/** Completion outcome */921response: SessionInputResponseKind;922/** Optional final answer replacement, keyed by question ID */923answers?: Record<string, SessionInputAnswer>;924}925926// ─── Terminal Actions ────────────────────────────────────────────────────────927928/**929* Terminal output data (pty → client direction).930*931* Appends `data` to the terminal's `content` in the reducer.932*933* `terminal/data` and `terminal/input` are intentionally separate actions934* because standard write-ahead reconciliation is not safe for terminal I/O.935* A pty is a stateful, mutable process — optimistically applying input or936* predicting output would produce incorrect state. Instead, `terminal/input`937* is a side-effect-only action (client → server → pty), and `terminal/data`938* is server-authoritative output (pty → server → client).939*940* @category Terminal Actions941* @version 1942*/943export interface TerminalDataAction {944type: ActionType.TerminalData;945/** Terminal URI */946terminal: URI;947/** Output data (may contain ANSI escape sequences) */948data: string;949}950951/**952* Keyboard input sent to the terminal process (client → pty direction).953*954* This is a side-effect-only action: the server forwards the data to the955* terminal's pty. The reducer treats this as a no-op since `terminal/data`956* actions will reflect any resulting output.957*958* See `terminal/data` for why these two actions are kept separate.959*960* @category Terminal Actions961* @version 1962* @clientDispatchable963*/964export interface TerminalInputAction {965type: ActionType.TerminalInput;966/** Terminal URI */967terminal: URI;968/** Input data to send to the pty */969data: string;970}971972/**973* Terminal dimensions changed.974*975* Dispatchable by clients to request a resize, or by the server to inform976* clients of the actual terminal dimensions.977*978* @category Terminal Actions979* @version 1980* @clientDispatchable981*/982export interface TerminalResizedAction {983type: ActionType.TerminalResized;984/** Terminal URI */985terminal: URI;986/** Terminal width in columns */987cols: number;988/** Terminal height in rows */989rows: number;990}991992/**993* Terminal claim changed. A client or session transfers ownership of the terminal.994*995* The server SHOULD reject if the dispatching client does not currently hold996* the claim.997*998* @category Terminal Actions999* @version 11000* @clientDispatchable1001*/1002export interface TerminalClaimedAction {1003type: ActionType.TerminalClaimed;1004/** Terminal URI */1005terminal: URI;1006/** The new claim */1007claim: TerminalClaim;1008}10091010/**1011* Terminal title changed.1012*1013* Fired by the server when the terminal process updates its title (e.g. via1014* escape sequences), or dispatched by a client to rename a terminal.1015*1016* @category Terminal Actions1017* @version 11018* @clientDispatchable1019*/1020export interface TerminalTitleChangedAction {1021type: ActionType.TerminalTitleChanged;1022/** Terminal URI */1023terminal: URI;1024/** New terminal title */1025title: string;1026}10271028/**1029* Terminal working directory changed.1030*1031* @category Terminal Actions1032* @version 11033*/1034export interface TerminalCwdChangedAction {1035type: ActionType.TerminalCwdChanged;1036/** Terminal URI */1037terminal: URI;1038/** New working directory */1039cwd: URI;1040}10411042/**1043* Terminal process exited.1044*1045* @category Terminal Actions1046* @version 11047*/1048export interface TerminalExitedAction {1049type: ActionType.TerminalExited;1050/** Terminal URI */1051terminal: URI;1052/** Process exit code. `undefined` if the process was killed without an exit code. */1053exitCode?: number;1054}10551056/**1057* Terminal scrollback buffer cleared.1058*1059* @category Terminal Actions1060* @version 11061* @clientDispatchable1062*/1063export interface TerminalClearedAction {1064type: ActionType.TerminalCleared;1065/** Terminal URI */1066terminal: URI;1067}10681069/**1070* Shell integration has loaded and the terminal now supports command1071* detection. The server dispatches this when shell integration becomes1072* available (which may happen asynchronously after the terminal is created).1073*1074* Clients MUST NOT assume command detection is available until this action1075* (or `terminal/commandExecuted`) has been received.1076*1077* @category Terminal Actions1078* @version 11079*/1080export interface TerminalCommandDetectionAvailableAction {1081type: ActionType.TerminalCommandDetectionAvailable;1082/** Terminal URI */1083terminal: URI;1084}10851086/**1087* A command has been submitted to the shell and is now executing.1088* All subsequent `terminal/data` actions (until the matching1089* `terminal/commandFinished`) constitute this command's output.1090*1091* @category Terminal Actions1092* @version 11093*/1094export interface TerminalCommandExecutedAction {1095type: ActionType.TerminalCommandExecuted;1096/** Terminal URI */1097terminal: URI;1098/**1099* Stable identifier for this command, scoped to the terminal URI.1100* Allows correlating `commandExecuted` → `commandFinished` pairs.1101*/1102commandId: string;1103/** The command line text that was submitted */1104commandLine: string;1105/**1106* Unix timestamp (ms) of when the command started executing, as measured1107* on the server.1108*/1109timestamp: number;1110}11111112/**1113* A command has finished executing.1114*1115* The sequence of `terminal/data` actions between the preceding1116* `terminal/commandExecuted` (same `commandId`) and this action constitutes1117* the complete output of the command.1118*1119* @category Terminal Actions1120* @version 11121*/1122export interface TerminalCommandFinishedAction {1123type: ActionType.TerminalCommandFinished;1124/** Terminal URI */1125terminal: URI;1126/** Matches the `commandId` from the corresponding `commandExecuted` */1127commandId: string;1128/** Shell exit code. `undefined` if the shell did not report one. */1129exitCode?: number;1130/**1131* Wall-clock duration of the command in milliseconds, as measured by the1132* shell integration script on the server side.1133*/1134durationMs?: number;1135}11361137// ─── Discriminated Union ─────────────────────────────────────────────────────11381139/**1140* Discriminated union of all state actions.1141*/1142export type StateAction =1143| RootAgentsChangedAction1144| RootActiveSessionsChangedAction1145| RootTerminalsChangedAction1146| RootConfigChangedAction1147| SessionReadyAction1148| SessionCreationFailedAction1149| SessionTurnStartedAction1150| SessionDeltaAction1151| SessionResponsePartAction1152| SessionToolCallStartAction1153| SessionToolCallDeltaAction1154| SessionToolCallReadyAction1155| SessionToolCallConfirmedAction1156| SessionToolCallCompleteAction1157| SessionToolCallResultConfirmedAction1158| SessionToolCallContentChangedAction1159| SessionTurnCompleteAction1160| SessionTurnCancelledAction1161| SessionErrorAction1162| SessionTitleChangedAction1163| SessionUsageAction1164| SessionReasoningAction1165| SessionModelChangedAction1166| SessionServerToolsChangedAction1167| SessionActiveClientChangedAction1168| SessionActiveClientToolsChangedAction1169| SessionPendingMessageSetAction1170| SessionPendingMessageRemovedAction1171| SessionQueuedMessagesReorderedAction1172| SessionInputRequestedAction1173| SessionInputAnswerChangedAction1174| SessionInputCompletedAction1175| SessionCustomizationsChangedAction1176| SessionCustomizationToggledAction1177| SessionTruncatedAction1178| SessionIsReadChangedAction1179| SessionIsArchivedChangedAction1180| SessionActivityChangedAction1181| SessionDiffsChangedAction1182| SessionConfigChangedAction1183| SessionMetaChangedAction1184| TerminalDataAction1185| TerminalInputAction1186| TerminalResizedAction1187| TerminalClaimedAction1188| TerminalTitleChangedAction1189| TerminalCwdChangedAction1190| TerminalExitedAction1191| TerminalClearedAction1192| TerminalCommandDetectionAvailableAction1193| TerminalCommandExecutedAction1194| TerminalCommandFinishedAction;119511961197