muse-code-msp 1.3.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,2293 @@
1
+ # GENERATED by scripts/gen-msp-py.sh -- DO NOT EDIT.
2
+ # A hand edit or a stale rendering reds the required regen test
3
+ # (crates/devtools/tests/msp_py_codegen.rs); rerun scripts/gen-msp-py.sh.
4
+ """Generated MSP wire types, EXPERIMENTAL surface. Explicit opt-in import only; nothing here carries a stability promise (spec 638 FR-638-004)."""
5
+
6
+ from __future__ import annotations
7
+
8
+ from typing import Any, Final, Literal, TypedDict
9
+
10
+ SCHEMA_FINGERPRINT: Final[str] = "sha256:3ebfa82522616e8bef05585ee0c9c84263956b95fa991d45f5b05ed93e3ea9a3"
11
+ SCHEMA_VERSION: Final[int] = 1
12
+ EXPERIMENTAL: Final[bool] = True
13
+ REQUIRED_HOST_VERSION: Final[str] = "1.3.0"
14
+
15
+ # How a login flow ended (spec 28091 FR-29535-4). Server-produced, so the vocabulary is open per the #22785 E2 rule — a future flow may end in a new way additively.
16
+ AccountLoginOutcome = str # open enum (SS1.5.4): unknown values stay representable
17
+ ACCOUNT_LOGIN_OUTCOME_KNOWN_VALUES: Final[tuple[str, ...]] = ("granted", "denied", "expired", "cancelled", "failed",)
18
+
19
+ # Which login flow `account/loginStart` runs (spec 28091 FR-29535-1; ADR D3). Client-produced, so the vocabulary is CLOSED: an unknown `type` fails deserialization into the standard invalid-params error (FM-29535-1).
20
+ AccountLoginType = Literal["deviceCode", "apiKey"]
21
+
22
+ # The projected credential state (spec 28091 FR-001; ADR 28091 D2): `EnvKey → envKey`, `StoredKey → apiKey`, `LoginMint → accountLogin`, and the absent lane as `loggedOut`. Open per the #22785 E2 rule — server-produced result vocabularies are open — so a future credential lane can project additively.
23
+ AccountStateKind = str # open enum (SS1.5.4): unknown values stay representable
24
+ ACCOUNT_STATE_KIND_KNOWN_VALUES: Final[tuple[str, ...]] = ("loggedOut", "envKey", "apiKey", "accountLogin",)
25
+
26
+ ApprovalAmendmentDurability = str # open enum (SS1.5.4): unknown values stay representable
27
+ APPROVAL_AMENDMENT_DURABILITY_KNOWN_VALUES: Final[tuple[str, ...]] = ("session", "localPersistent",)
28
+
29
+ ApprovalChoiceScope = str # open enum (SS1.5.4): unknown values stay representable
30
+ APPROVAL_CHOICE_SCOPE_KNOWN_VALUES: Final[tuple[str, ...]] = ("once", "session", "localPersistent",)
31
+
32
+ ApprovalDecision = str # open enum (SS1.5.4): unknown values stay representable
33
+ APPROVAL_DECISION_KNOWN_VALUES: Final[tuple[str, ...]] = ("approved", "approvedForSession", "approvedPolicyAmendment", "denied", "deniedPolicyAmendment", "timedOut", "abort",)
34
+
35
+ # The approval enforcement modes (tdd SS5.12, camelCased `ApprovalBackendMode`). **Closed** by design (D-006, select-never-create): a client selects a preconfigured mode and can never construct one; widening this enum is a deliberate, gate-visible protocol change.
36
+ ApprovalMode = Literal["allowAll", "promptUnmatched", "onRequest", "denyUnmatched"]
37
+
38
+ # Whether a mode change did anything (tdd SS5.12), mirroring `ApprovalReconfigureApplyOutcome`. Apply failures are `commandRejected`.
39
+ ApprovalModeApplyOutcome = str # open enum (SS1.5.4): unknown values stay representable
40
+ APPROVAL_MODE_APPLY_OUTCOME_KNOWN_VALUES: Final[tuple[str, ...]] = ("completed", "noop",)
41
+
42
+ # How an approval mode took effect (tdd SS5.12, the effective-mode projection's `source` vocabulary). Open.
43
+ ApprovalModeSource = str # open enum (SS1.5.4): unknown values stay representable
44
+ APPROVAL_MODE_SOURCE_KNOWN_VALUES: Final[tuple[str, ...]] = ("startup", "replay", "approvalReconfigure",)
45
+
46
+ ApprovalPersistenceStatus = str # open enum (SS1.5.4): unknown values stay representable
47
+ APPROVAL_PERSISTENCE_STATUS_KNOWN_VALUES: Final[tuple[str, ...]] = ("succeeded", "failed",)
48
+
49
+ ApprovalPolicyResult = str # open enum (SS1.5.4): unknown values stay representable
50
+ APPROVAL_POLICY_RESULT_KNOWN_VALUES: Final[tuple[str, ...]] = ("allow", "deny",)
51
+
52
+ ApprovalResolvedBy = str # open enum (SS1.5.4): unknown values stay representable
53
+ APPROVAL_RESOLVED_BY_KNOWN_VALUES: Final[tuple[str, ...]] = ("user", "policy", "llmJudge",)
54
+
55
+ # One attention flag (tdd SS2.4, ADR 31983 D3): a pending server-initiated request class parked on the session. Open on the wire — clients MUST ignore unknown values; future attention kinds are additive.
56
+ AttentionFlag = str # open enum (SS1.5.4): unknown values stay representable
57
+ ATTENTION_FLAG_KNOWN_VALUES: Final[tuple[str, ...]] = ("approvalPending", "inputPending",)
58
+
59
+ # Who durably backgrounded a task (tdd SS4.5.5, `TaskBackgroundedInitiator`). Open — runtime vocabulary.
60
+ BackgroundInitiator = str # open enum (SS1.5.4): unknown values stay representable
61
+ BACKGROUND_INITIATOR_KNOWN_VALUES: Final[tuple[str, ...]] = ("user", "timeout",)
62
+
63
+ # A grantable capability name (SS1.4.4). Open: the reserved `rawLog` entry joins this domain as an additive open-enum extension when SS6 un-defers (#13929, Scenario 5 AS-3) — closed would make that a retype.
64
+ CapabilityName = str # open enum (SS1.5.4): unknown values stay representable
65
+ CAPABILITY_NAME_KNOWN_VALUES: Final[tuple[str, ...]] = ("userShell", "sessionMcp",)
66
+
67
+ # The ack-status vocabulary (`tdd.md` SS3.1/SS3.1.2): `"accepted"` for every admitted command; `session/compact` alone may answer `"noop"`. Closed: SS3.1.2 names exactly these two values, so SDK clients get a discriminated type and validation catches a wrong status (PR #21550 review) — and a client that received a third value would have been told nothing it can act on, unlike [`TurnStartDisposition`], where "acked, not otherwise classified" is a usable reading.
68
+ CommandAckStatus = Literal["accepted", "noop"]
69
+
70
+ # The SS3.1.2 ack `status`: `accepted` for every admitted command. `session/compact` is the one method that may additionally answer `noop` ([`crate::method::runtime::CompactStatus`]); no other command uses another status (tdd SS3.1.2).
71
+ CommandStatus = str # open enum (SS1.5.4): unknown values stay representable
72
+ COMMAND_STATUS_KNOWN_VALUES: Final[tuple[str, ...]] = ("accepted",)
73
+
74
+ # `session/compact`'s ack status (tdd SS3.7): the one method that may answer `noop` in addition to the SS3.1.2 `accepted`. A noop is a success, not an error, and it is durably settled like any other outcome.
75
+ CompactStatus = str # open enum (SS1.5.4): unknown values stay representable
76
+ COMPACT_STATUS_KNOWN_VALUES: Final[tuple[str, ...]] = ("accepted", "noop",)
77
+
78
+ # Compaction outcome (tdd SS4.5.10, the SS3.7 vocabulary). Open.
79
+ CompactionOutcome = str # open enum (SS1.5.4): unknown values stay representable
80
+ COMPACTION_OUTCOME_KNOWN_VALUES: Final[tuple[str, ...]] = ("compacted", "noop", "failed", "cancelled",)
81
+
82
+ # What initiated a compaction (tdd SS4.5.10). Open.
83
+ CompactionTrigger = str # open enum (SS1.5.4): unknown values stay representable
84
+ COMPACTION_TRIGGER_KNOWN_VALUES: Final[tuple[str, ...]] = ("manual", "auto",)
85
+
86
+ # Context pressure level (tdd SS4.6.6): hard threshold first, both inclusive `>=`. Open.
87
+ ContextPressureLevel = str # open enum (SS1.5.4): unknown values stay representable
88
+ CONTEXT_PRESSURE_LEVEL_KNOWN_VALUES: Final[tuple[str, ...]] = ("normal", "warning", "blocked",)
89
+
90
+ # A stable `error.data.kind` category (SS1.6): camelCase, the value clients branch on. Open: SS2–SS5 lanes add kinds additively as their methods land (Appendix B already registers them), and the spec's edge-case rule makes a new `kind` additive only because this domain is declared open.
91
+ ErrorKind = str # open enum (SS1.5.4): unknown values stay representable
92
+ ERROR_KIND_KNOWN_VALUES: Final[tuple[str, ...]] = ("parseError", "invalidRequest", "notInitialized", "alreadyInitialized", "methodNotFound", "invalidParams", "experimentalRequired", "internal", "pageEventTooLarge", "outputResultTooLarge", "overloaded", "inputTooLarge", "capabilityRequired", "notFound", "interrupted", "cancelled", "sessionNotFound", "sessionInUse", "sessionAmbiguous", "forkBoundaryInvalid", "sessionNotLoaded", "sessionStreamMismatch", "commandRejected", "backpressured", "skillNotFound", "viewTruncated", "outputUnavailable", "boundaryPruned", "boundaryUnusable", "noBoundary", "approvalNotFound", "approvalAlreadyResolved", "approvalChoiceInvalid", "approvalRequirementStale", "approvalReviewerUnavailable", "userInputNotFound", "userInputAlreadySettled", "userInputAnswerInvalid",)
93
+
94
+ # What history a lifecycle result actually served (tdd SS2.5.2). Open on the client side: report-what-was-served means a client treats an unknown mode as "page it yourself".
95
+ HistoryMode = str # open enum (SS1.5.4): unknown values stay representable
96
+ HISTORY_MODE_KNOWN_VALUES: Final[tuple[str, ...]] = ("anchoredSnapshot", "inline", "snapshot", "none",)
97
+
98
+ # Why a result served `history.mode: "none"` — spec 208 FM-005's typed unavailability (tdd SS2.5.2; D-050). Open on the client side: an absent (older server) or unknown (newer server) value decodes conservatively as an unknown reason, and `viewCursor` text never substitutes for it (spec 208 INV-19734-1).
99
+ HistoryNoneReason = str # open enum (SS1.5.4): unknown values stay representable
100
+ HISTORY_NONE_REASON_KNOWN_VALUES: Final[tuple[str, ...]] = ("excluded", "cursorSuffix", "historyBudget", "projectionUnavailable", "projectionReadLimit",)
101
+
102
+ # The `history` request preference of `session/resume` (tdd SS2.5.2). The forced values downgrade `anchored` → `inline` → `snapshot` → `none`; under `auto` the full rung order is anchoredSnapshot → inline → snapshot → elided snapshot → none.
103
+ HistoryPreference = Literal["auto", "inline", "snapshot", "anchored"]
104
+
105
+ # Disposition when a turn is already running (tdd SS3.2). The wire default is `queue`: an SDK caller who has not looked at session state should not silently mutate an in-flight turn.
106
+ IfBusy = Literal["queue", "steer", "replace"]
107
+
108
+ # The nine v1 item kinds (tdd SS4.5.2–4.5.10). Open: a new kind is additive evolution, and clients MUST render unknown kinds generically (tdd SS4.10).
109
+ ItemKind = str # open enum (SS1.5.4): unknown values stay representable
110
+ ITEM_KIND_KNOWN_VALUES: Final[tuple[str, ...]] = ("userMessage", "agentMessage", "reasoning", "toolCall", "userShell", "subagent", "workflow", "reminderChild", "compaction",)
111
+
112
+ # The `item/readOutput` content encoding (tdd SS4.7.4). Closed: text media is ALWAYS `utf8` and binary media `base64`; a third value would change the client's decode contract.
113
+ ItemReadOutputEncoding = Literal["utf8", "base64"]
114
+
115
+ # Item status (tdd SS4.4.1). Open; terminal = anything other than `"inProgress"`, and unknown values are terminal-unknown, rendered generically.
116
+ ItemStatus = str # open enum (SS1.5.4): unknown values stay representable
117
+ ITEM_STATUS_KNOWN_VALUES: Final[tuple[str, ...]] = ("inProgress", "completed", "failed", "cancelled", "rejected", "timedOut",)
118
+
119
+ # The literal `"2.0"` every frame carries (SS1.2).
120
+ JsonRpcVersion = Literal["2.0"]
121
+
122
+ # Where a model catalog came from (tdd SS3.10). **Open**: an unrecognized value is an unknown source, not an error.
123
+ ModelCatalogSource = str # open enum (SS1.5.4): unknown values stay representable
124
+ MODEL_CATALOG_SOURCE_KNOWN_VALUES: Final[tuple[str, ...]] = ("providerCatalog", "fakeCatalog", "unresolvedCatalog", "bundledCatalog", "configCatalog",)
125
+
126
+ # What drove a model selection (tdd SS4.6.1). Open.
127
+ ModelChangeSource = str # open enum (SS1.5.4): unknown values stay representable
128
+ MODEL_CHANGE_SOURCE_KNOWN_VALUES: Final[tuple[str, ...]] = ("user", "default", "policy",)
129
+
130
+ # Whether a stored output's bytes are servable (tdd SS4.5.5). Open — durable runtime vocabulary may grow additively.
131
+ OutputRefAvailability = str # open enum (SS1.5.4): unknown values stay representable
132
+ OUTPUT_REF_AVAILABILITY_KNOWN_VALUES: Final[tuple[str, ...]] = ("available", "missing", "unsupported", "accessFailed",)
133
+
134
+ # The `pendingRequests` discriminator (tdd SS2.5.2). Open enum, v1 values `approval` and `userInput`.
135
+ PendingRequestKind = str # open enum (SS1.5.4): unknown values stay representable
136
+ PENDING_REQUEST_KIND_KNOWN_VALUES: Final[tuple[str, ...]] = ("approval", "userInput",)
137
+
138
+ # The server runtime's platform family (SS1.4.1); may differ from the client's. Closed: SS1.4.1 fixes the value set, so widening it is a deliberate, gate-visible protocol change rather than a silent addition (a later `Closed`→`Open` flip is itself additive, data-model.md §5.2).
139
+ PlatformFamily = Literal["unix", "windows"]
140
+
141
+ # The server's operating system (SS1.4.1). Closed, for the same reason as [`PlatformFamily`].
142
+ PlatformOs = Literal["macos", "linux", "windows"]
143
+
144
+ # The reasoning-effort tier sampled at submission (tdd SS3.2, SS3.3). The **same closed tier vocabulary** on both the fresh-turn and steer lanes, spelled identically; invalid tiers are invalid params. `none` is a tier of the vocabulary (ask for no reasoning), not a way to say "unset".
145
+ ReasoningEffort = Literal["none", "minimal", "low", "medium", "high", "xhigh", "max", "ultra"]
146
+
147
+ # What drove a reasoning-effort default change (tdd SS4.6.9). Open; v1's only producer is `user` (an accepted `session/setReasoningEffort`).
148
+ ReasoningEffortChangeSource = str # open enum (SS1.5.4): unknown values stay representable
149
+ REASONING_EFFORT_CHANGE_SOURCE_KNOWN_VALUES: Final[tuple[str, ...]] = ("user", "default", "policy",)
150
+
151
+ # A request id (SS1.3): client-chosen string or integer. `1` and `"1"` do not compare equal; each direction owns its own id space.
152
+ RequestId = int | str
153
+
154
+ # Whether this host writes its sessions to disk (SS1.4.1, SS2.13). A property of the host process, fixed at construction and identical for every session and every connection it serves — never requested, granted, or negotiated, which is why it is not a capability. Open: the unrepresented degraded state (#14401) has candidate resolutions that add a third value here, so closed would make that a breaking change.
155
+ SessionDurability = str # open enum (SS1.5.4): unknown values stay representable
156
+ SESSION_DURABILITY_KNOWN_VALUES: Final[tuple[str, ...]] = ("durable", "ephemeral",)
157
+
158
+ # Startup failure posture for a session MCP server.
159
+ SessionMcpServerMode = Literal["required", "optional"]
160
+
161
+ # Stdio framing choices exposed by session MCP configuration.
162
+ SessionMcpStdioFraming = Literal["auto", "contentLength", "lineDelimitedJson"]
163
+
164
+ # A session's load state (tdd SS2.4).
165
+ SessionStatus = str # open enum (SS1.5.4): unknown values stay representable
166
+ SESSION_STATUS_KNOWN_VALUES: Final[tuple[str, ...]] = ("notLoaded", "idle", "running",)
167
+
168
+ # The view-health state (tdd SS2.5.2 companion). Open enum (`x-msp-openness: open`): a client MUST ignore an unrecognized value. v1 emits only `Unavailable`; openness itself reserves additive room for a future re-arm (ADR 32557 D1 names it `healthy`) and for the #14401 durable-degraded axis, so no never-emitted token is baked onto the stable surface now.
169
+ SessionViewHealth = str # open enum (SS1.5.4): unknown values stay representable
170
+ SESSION_VIEW_HEALTH_KNOWN_VALUES: Final[tuple[str, ...]] = ("unavailable",)
171
+
172
+ # A skill row's source scope (tdd SS3.22.1): the projection of the skills crate's `SkillsSourceScope`. Open (server-produced result vocabulary, the #22785 enum-openness rule): a future scope value is additive.
173
+ SkillSource = str # open enum (SS1.5.4): unknown values stay representable
174
+ SKILL_SOURCE_KNOWN_VALUES: Final[tuple[str, ...]] = ("bundled", "user", "project", "plugin",)
175
+
176
+ # Subagent control status (tdd SS4.5.7, camelCased `SubagentControlStatus`). Open; the generic item `status` is the terminal authority.
177
+ SubagentControlStatus = str # open enum (SS1.5.4): unknown values stay representable
178
+ SUBAGENT_CONTROL_STATUS_KNOWN_VALUES: Final[tuple[str, ...]] = ("accepted", "starting", "running", "resultReady", "closing", "closed", "recoveryPending", "manualReconciliation",)
179
+
180
+ # Todo status (tdd SS4.6.3): closed in the runtime, wire-open.
181
+ TodoStatus = str # open enum (SS1.5.4): unknown values stay representable
182
+ TODO_STATUS_KNOWN_VALUES: Final[tuple[str, ...]] = ("pending", "inProgress", "completed", "cancelled",)
183
+
184
+ # Turn failure classes (tdd SS4.5.1, `TerminalErrorKind` plus the model-task failure class). Open.
185
+ TurnErrorKind = str # open enum (SS1.5.4): unknown values stay representable
186
+ TURN_ERROR_KIND_KNOWN_VALUES: Final[tuple[str, ...]] = ("stepLimit", "configError", "projectionError", "logError", "workflowLaunchError", "environmentError", "modelError", "launchError", "authRequired",)
187
+
188
+ # The `type` discriminator of a turn input part (tdd SS3.2). Closed: an unknown part type is `invalidParams` (tdd SS3.1.2).
189
+ TurnInputPartType = Literal["text", "image", "skill"]
190
+
191
+ # What `turn/start` did with the input (tdd SS3.2). Resolves OQ-H in v1: since `queue` is the default `ifBusy`, clients need to distinguish these without folding history.
192
+ TurnStartDisposition = str # open enum (SS1.5.4): unknown values stay representable
193
+ TURN_START_DISPOSITION_KNOWN_VALUES: Final[tuple[str, ...]] = ("started", "queued", "steered",)
194
+
195
+ # Turn terminal vocabulary (tdd SS4.5.1): exactly the runtime's `RunTerminalKind` — closed in the runtime, wire-open for evolution.
196
+ TurnTerminal = str # open enum (SS1.5.4): unknown values stay representable
197
+ TURN_TERMINAL_KNOWN_VALUES: Final[tuple[str, ...]] = ("completed", "failed", "cancelled",)
198
+
199
+ UserInputOutcome = str # open enum (SS1.5.4): unknown values stay representable
200
+ USER_INPUT_OUTCOME_KNOWN_VALUES: Final[tuple[str, ...]] = ("answered", "cancelled", "interrupted", "clarified", "timedOut", "aborted",)
201
+
202
+ UserInputSelectionMode = Literal["single", "multiple"]
203
+
204
+ # Version-control system of a branch observation (tdd SS4.6.4). Open.
205
+ Vcs = str # open enum (SS1.5.4): unknown values stay representable
206
+ VCS_KNOWN_VALUES: Final[tuple[str, ...]] = ("git", "sapling",)
207
+
208
+ # The `view/page` request-mode anchor (tdd SS4.7.3). Declared **open**: the tdd spells it "open string enum, v1 value `latestCompaction`".
209
+ ViewPageAnchor = str # open enum (SS1.5.4): unknown values stay representable
210
+ VIEW_PAGE_ANCHOR_KNOWN_VALUES: Final[tuple[str, ...]] = ("latestCompaction",)
211
+
212
+ # The `view/page` paging direction (tdd SS4.7.3). Closed: the tdd spells exactly two values and a third would change the paging contract.
213
+ ViewPageDirection = Literal["forward", "backward"]
214
+
215
+ # Which control to apply to the child's current attempt (tdd SS3.20). Closed on the wire: an unknown value is `-32602 invalidParams`.
216
+ WorkflowChildAction = Literal["skip", "retry"]
217
+
218
+ class AccountLoginCancelResult(TypedDict):
219
+ """`account/loginCancel` result: exactly `{cancelled}` — `true` iff a pending flow existed and was cancelled (spec 28091 FR-29535-5)."""
220
+
221
+ cancelled: bool
222
+
223
+
224
+ class _AccountLoginCompletedParamsBase(TypedDict):
225
+ outcome: AccountLoginOutcome
226
+
227
+
228
+ class AccountLoginCompletedParams(_AccountLoginCompletedParamsBase, total=False):
229
+ """`account/loginCompleted` params: exactly `{outcome, message?}` (spec 28091 FR-29535-4). `message` is a display string from the typed error vocabulary — never key material, store content, or an echo of the raw params (FM-29535-4)."""
230
+
231
+ message: str
232
+
233
+
234
+ class _AccountLoginStartParamsBase(TypedDict):
235
+ type: AccountLoginType
236
+
237
+
238
+ class AccountLoginStartParams(_AccountLoginStartParamsBase, total=False):
239
+ """`account/loginStart` params: exactly `{type, apiKey?}` (spec 28091 FR-29535-1). `apiKey` is required non-empty for [`AccountLoginType::ApiKey`] and forbidden for [`AccountLoginType::DeviceCode`]; both violations are invalid-params errors (FM-29535-1), enforced by the handler so the error never echoes the raw params (FM-29535-4). `Debug` is hand-written: the derive would print the raw key bytes into any `{:?}` context (a tracing line, an error, a test assert), the exact leak INV-29535-1 forbids — the `McpOAuthRecordV1` posture."""
240
+
241
+ apiKey: str
242
+
243
+
244
+ class AccountLoginStartResult(TypedDict, total=False):
245
+ """`account/loginStart` result: exactly `{verificationUrl?, userCode?}` — both present for a started device-code flow, both absent for the synchronous `apiKey` type (spec 28091 FR-29535-1). The device-code artifacts travel ONLY here, to the requesting connection; completion notifications never carry them (INV-29535-2)."""
246
+
247
+ userCode: str
248
+ verificationUrl: str
249
+
250
+
251
+ class _AccountStateBase(TypedDict):
252
+ credentialRequired: bool
253
+ state: AccountStateKind
254
+
255
+
256
+ class AccountState(_AccountStateBase, total=False):
257
+ """The one account payload shape: the `account/read` result and the `account/changed` params (spec 28091 FR-001/FR-002). Closed vocabulary (INV-002); `label` is a display string that never carries key material (FR-004) and is omitted, never `null`, when absent."""
258
+
259
+ label: str
260
+
261
+
262
+ class ApprovalAmendment(TypedDict):
263
+ durability: ApprovalAmendmentDurability
264
+ rulePreview: str
265
+
266
+
267
+ class _ApprovalChangeBase(TypedDict):
268
+ kind: str
269
+
270
+
271
+ class ApprovalChange(_ApprovalChangeBase, total=False):
272
+ choiceId: str
273
+ decision: ApprovalDecision
274
+ executable: bool
275
+ reason: str
276
+ reparsed: bool
277
+ requirementId: ApprovalRequirementRef
278
+ status: ApprovalPersistenceStatus
279
+
280
+
281
+ class _ApprovalChoiceBase(TypedDict):
282
+ choiceId: str
283
+ decision: ApprovalDecision
284
+ label: str
285
+ scope: ApprovalChoiceScope
286
+
287
+
288
+ class ApprovalChoice(_ApprovalChoiceBase, total=False):
289
+ acceptsFeedback: bool
290
+ rulePreview: str
291
+
292
+
293
+ class _ApprovalDecideParamsBase(TypedDict):
294
+ approvalId: str
295
+ choiceId: str
296
+ commandId: str
297
+ requirementId: ApprovalRequirementRef
298
+ sessionId: str
299
+
300
+
301
+ class ApprovalDecideParams(_ApprovalDecideParamsBase, total=False):
302
+ """`approval/decide` params (tdd SS5.4): the decision. A standard SS3 command — requires the session loaded on this host, requires `commandId`, durable intake before ack, value-identical replay."""
303
+
304
+ feedback: str | None
305
+
306
+
307
+ class ApprovalDecideResult(TypedDict):
308
+ """`approval/decide` result (tdd SS5.4). Admission-ack rules still apply: the authoritative outcome is `approval/resolved` / `approval/updated` on the view stream."""
309
+
310
+ approvalId: str
311
+ commandId: str
312
+ status: CommandStatus
313
+ terminal: bool
314
+
315
+
316
+ class ApprovalListPendingParams(TypedDict):
317
+ """`approval/listPending` params (tdd SS5.7): the pull dual of the re-issued requests. A log-fold read — no lease, works on loaded and unloaded sessions, never subscribes."""
318
+
319
+ sessionId: str
320
+
321
+
322
+ class ApprovalListPendingResult(TypedDict):
323
+ """`approval/listPending` result (tdd SS5.7). Ordering is by opening `viewCursor`; empty arrays when nothing is pending. The result is point-in-time — to act on it race-safely, `approval/decide` carries the `requirementId` guard regardless of how the client learned the state."""
324
+
325
+ approvals: list[ApprovalRequestParams]
326
+ userInputs: list[UserInputRequestParams]
327
+
328
+
329
+ class _ApprovalOriginBase(TypedDict):
330
+ kind: str
331
+
332
+
333
+ class ApprovalOrigin(_ApprovalOriginBase, total=False):
334
+ command: str
335
+ url: str
336
+
337
+
338
+ class ApprovalRequestParams(TypedDict):
339
+ """Full params shared by `approval/request` and `approval/requested`."""
340
+
341
+ approvalId: str
342
+ availableChoices: list[ApprovalChoice]
343
+ currentRequirementId: ApprovalRequirementRef
344
+ itemId: str
345
+ judgeEscalated: bool
346
+ protectedWrite: bool
347
+ rawArgs: str
348
+ sessionId: str
349
+ sourceRange: SourceRange
350
+ subject: ApprovalSubject
351
+ taskId: str
352
+ toolCallId: str
353
+ toolName: str
354
+ turnId: str
355
+ viewCursor: str
356
+
357
+
358
+ class ApprovalRequirementRef(TypedDict):
359
+ """Approval-stage token carried in SS5 params and stale-requirement errors."""
360
+
361
+ approvalId: str
362
+ sourceIndex: int
363
+
364
+
365
+ class ApprovalResolutionSummary(TypedDict):
366
+ """Winning terminal returned to a losing `approval/decide` command."""
367
+
368
+ decision: str
369
+ resolvedBy: str
370
+ viewCursor: str
371
+
372
+
373
+ class _ApprovalResolvedParamsBase(TypedDict):
374
+ approvalId: str
375
+ decision: ApprovalDecision
376
+ itemId: str
377
+ policyResult: ApprovalPolicyResult
378
+ resolvedBy: ApprovalResolvedBy
379
+ sessionId: str
380
+ sourceRange: SourceRange
381
+ stageEvidence: list[ApprovalStageEvidence]
382
+ turnId: str
383
+ viewCursor: str
384
+
385
+
386
+ class ApprovalResolvedParams(_ApprovalResolvedParamsBase, total=False):
387
+ """`approval/resolved` params: the first durable terminal decision."""
388
+
389
+ amendment: ApprovalAmendment
390
+ decidedByCommandId: str
391
+
392
+
393
+ class _ApprovalStageBase(TypedDict):
394
+ argv: list[str]
395
+ argvComplete: bool
396
+ position: int
397
+ requirementId: ApprovalRequirementRef
398
+ resolution: ApprovalStageResolution
399
+ totalStages: int
400
+
401
+
402
+ class ApprovalStage(_ApprovalStageBase, total=False):
403
+ suggestedPrefix: ApprovalSuggestedPrefix
404
+
405
+
406
+ class ApprovalStageEvidence(TypedDict):
407
+ argv: list[str]
408
+ position: int
409
+ requirementId: ApprovalRequirementRef
410
+ resolution: ApprovalStageResolution
411
+ totalStages: int
412
+
413
+
414
+ class _ApprovalStageResolutionBase(TypedDict):
415
+ kind: str
416
+
417
+
418
+ class ApprovalStageResolution(_ApprovalStageResolutionBase, total=False):
419
+ argvPrefix: list[str]
420
+ diagnostic: str
421
+
422
+
423
+ class _ApprovalSubjectBase(TypedDict):
424
+ kind: str
425
+
426
+
427
+ class ApprovalSubject(_ApprovalSubjectBase, total=False):
428
+ """Open approval subject union. Unknown kinds are rendered generically and never auto-approved by clients (tdd SS5.2)."""
429
+
430
+ access: str
431
+ command: str
432
+ host: str
433
+ origin: ApprovalOrigin
434
+ path: str
435
+ port: int
436
+ protocol: str
437
+ stages: list[ApprovalStage]
438
+ target: str
439
+ toolName: str
440
+ workspaceRoot: str
441
+
442
+
443
+ class ApprovalSuggestedPrefix(TypedDict):
444
+ argvPrefix: list[str]
445
+ label: str
446
+
447
+
448
+ class ApprovalUpdatedParams(TypedDict):
449
+ """`approval/updated` params: the refreshed pending view plus one change."""
450
+
451
+ approvalId: str
452
+ availableChoices: list[ApprovalChoice]
453
+ change: ApprovalChange
454
+ currentRequirementId: ApprovalRequirementRef
455
+ sessionId: str
456
+ sourceRange: SourceRange
457
+ subject: ApprovalSubject
458
+ viewCursor: str
459
+
460
+
461
+ class _BranchStateBase(TypedDict):
462
+ branch: str | None
463
+ workspaceRoot: str
464
+
465
+
466
+ class BranchState(_BranchStateBase, total=False):
467
+ """The latest branch observation in the snapshot (tdd SS4.6.4, SS4.9.1)."""
468
+
469
+ vcs: Vcs
470
+
471
+
472
+ class ClientCapabilities(TypedDict, total=False):
473
+ """The client's requested capability posture (SS1.4.1). Every member defaults; an absent `capabilities` object means all defaults."""
474
+
475
+ experimentalApi: bool
476
+ optOutNotificationMethods: list[str]
477
+ requestedCapabilities: list[str]
478
+ userInputDialogs: bool
479
+
480
+
481
+ class _ClientInfoBase(TypedDict):
482
+ name: str
483
+ version: str
484
+
485
+
486
+ class ClientInfo(_ClientInfoBase, total=False):
487
+ """Client identification inside `initialize` params (SS1.4.1). Diagnostics and telemetry attribution only; never an authority claim (SS1.10)."""
488
+
489
+ title: str
490
+
491
+
492
+ class CommandAcceptedResult(TypedDict):
493
+ """The uniform SS3.1.2 command acknowledgement: admission only, never an outcome. `session/compact` alone may answer `\"noop\"`; every other command answers `\"accepted\"`."""
494
+
495
+ commandId: str
496
+ status: CommandAckStatus
497
+
498
+
499
+ class _ContextUsageBase(TypedDict):
500
+ pressure: ContextPressureLevel
501
+ usedTokens: int
502
+
503
+
504
+ class ContextUsage(_ContextUsageBase, total=False):
505
+ """The SS4.9.1 snapshot `contextUsage` block: the latest `(windowTokens, usedTokens, pressure)` triple; the snapshot member is `null` until the fold's generation chain holds a tracked anchor AND the current basis is present (absent is never fabricated)."""
506
+
507
+ windowTokens: int
508
+
509
+
510
+ class CumulativeTokenUsage(TypedDict):
511
+ """Session running totals of counted-once usage (tdd SS4.6.5)."""
512
+
513
+ outputTokens: int
514
+ promptTokens: int
515
+ totalTokens: int
516
+
517
+
518
+ class EffectiveApprovalModeState(TypedDict):
519
+ """The effective approval-mode projection (`EffectiveApprovalModeState`, tdd SS5.12): the same object `session/setApprovalMode` returns as `effectiveMode` and the `Session` object carries as `approvalMode`."""
520
+
521
+ lastCommandId: str | None
522
+ mode: ApprovalMode
523
+ source: ApprovalModeSource
524
+
525
+
526
+ class EffectiveModel(TypedDict):
527
+ """The latest effective-model fact in the snapshot (tdd SS4.9.1)."""
528
+
529
+ modelId: str
530
+ providerId: str | None
531
+ source: ModelChangeSource
532
+
533
+
534
+ class _ErrorDataBase(TypedDict):
535
+ kind: ErrorKind
536
+
537
+
538
+ class ErrorData(_ErrorDataBase, total=False):
539
+ """The optional `error.data` object (SS1.6). All members additive-optional; `kind` is always present when `data` is."""
540
+
541
+ alignedNextOffset: int
542
+ anchor: str | None
543
+ approvalId: str
544
+ availability: str
545
+ capability: CapabilityName
546
+ capacity: int
547
+ choiceId: str
548
+ commandId: str
549
+ currentRequirementId: ApprovalRequirementRef
550
+ descriptor: str
551
+ details: dict[str, Any]
552
+ earliestCursor: str | None
553
+ itemId: str
554
+ lastTurnId: str
555
+ latestBoundaryCursor: str | None
556
+ limitBytes: int
557
+ outputRef: str
558
+ paths: list[str]
559
+ reason: str
560
+ resolution: ApprovalResolutionSummary
561
+ retryable: bool
562
+ selector: str
563
+ sessionId: str
564
+ settlement: UserInputSettlementSummary
565
+ userInputId: str
566
+ viewCursor: str
567
+
568
+
569
+ class _ErrorObjectBase(TypedDict):
570
+ code: int
571
+ message: str
572
+
573
+
574
+ class ErrorObject(_ErrorObjectBase, total=False):
575
+ """The `error` member of an error response (SS1.2 §2.4)."""
576
+
577
+ data: ErrorData
578
+
579
+
580
+ class ErrorResponse(TypedDict):
581
+ """An error response frame (SS1.2 §2.4). Exactly one of `result` or `error` appears on a response; this type is the `error` half."""
582
+
583
+ error: ErrorObject
584
+ id: RequestId | None
585
+ jsonrpc: JsonRpcVersion
586
+
587
+
588
+ class ForkCutPoint(TypedDict):
589
+ """Where a fork cuts the source history (tdd SS2.5.3). Turn ids are used instead of counts because ids stay stable across compaction and concurrent appends while indices do not."""
590
+
591
+ lastTurnId: str
592
+
593
+
594
+ class ForkProvenance(TypedDict):
595
+ """Fork provenance folded from the durable `session.fork.created` record (`ForkProvenance`, tdd SS2.4)."""
596
+
597
+ commandId: str
598
+ cutCursor: str
599
+ cutExplicit: bool
600
+ sessionId: str
601
+
602
+
603
+ class _GoalBase(TypedDict):
604
+ objective: str
605
+ percentComplete: int
606
+ status: str
607
+
608
+
609
+ class Goal(_GoalBase, total=False):
610
+ """The session goal block (tdd SS4.6.2, mirrors the runtime's goal state, camelCased). `status` and `percentComplete` are carried **verbatim** — out-of-contract status strings and >100 percents pass through; display clamping is the renderer's job."""
611
+
612
+ currentWork: str
613
+ nextWork: str
614
+
615
+
616
+ class GoalClearParams(TypedDict):
617
+ """`goal/clear` params (tdd SS3.18). An `objective` here is an unknown field and rejects `-32602 invalidParams` — the bare verbs carry exactly this pair."""
618
+
619
+ commandId: str
620
+ sessionId: str
621
+
622
+
623
+ class _GoalCommandResultBase(TypedDict):
624
+ commandId: str
625
+ status: CommandStatus
626
+
627
+
628
+ class GoalCommandResult(_GoalCommandResultBase, total=False):
629
+ """The shared SS3.18 goal ack, admission-only: all five verbs answer this one shape (the tdd's \"Shared contract\"), differing only in when `turnId` is present."""
630
+
631
+ turnId: str
632
+
633
+
634
+ class GoalEditParams(TypedDict):
635
+ """`goal/edit` params (tdd SS3.18): replace the current goal's objective. Same shape as `goal/set`; the verbs differ in their `missing_goal` precondition, not their payload."""
636
+
637
+ commandId: str
638
+ objective: str
639
+ sessionId: str
640
+
641
+
642
+ class GoalPauseParams(TypedDict):
643
+ """`goal/pause` params (tdd SS3.18); shape as `goal/clear`."""
644
+
645
+ commandId: str
646
+ sessionId: str
647
+
648
+
649
+ class GoalResumeParams(TypedDict):
650
+ """`goal/resume` params (tdd SS3.18); shape as `goal/clear`."""
651
+
652
+ commandId: str
653
+ sessionId: str
654
+
655
+
656
+ class GoalSetParams(TypedDict):
657
+ """`goal/set` params (tdd SS3.18): set the session's goal objective."""
658
+
659
+ commandId: str
660
+ objective: str
661
+ sessionId: str
662
+
663
+
664
+ class _InitializeParamsBase(TypedDict):
665
+ clientInfo: ClientInfo
666
+
667
+
668
+ class InitializeParams(_InitializeParamsBase, total=False):
669
+ """`initialize` request params (SS1.4.1)."""
670
+
671
+ capabilities: ClientCapabilities
672
+
673
+
674
+ class _InitializeResultBase(TypedDict):
675
+ experimentalApi: bool
676
+ grantedCapabilities: list[CapabilityName]
677
+ museHome: str
678
+ platformFamily: PlatformFamily
679
+ platformOs: PlatformOs
680
+ schema: SchemaInfo
681
+ serverInfo: ServerInfo
682
+ userAgent: str
683
+
684
+
685
+ class InitializeResult(_InitializeResultBase, total=False):
686
+ """The `initialize` result (SS1.4.1)."""
687
+
688
+ sessionDurability: SessionDurability
689
+
690
+
691
+ class _ItemBase(TypedDict):
692
+ itemId: str
693
+ kind: ItemKind
694
+ revision: int
695
+ status: ItemStatus
696
+
697
+
698
+ class Item(_ItemBase, total=False):
699
+ """One transcript item at one revision (tdd SS4.4.1 common fields plus the per-kind fields of SS4.5.2–4.5.10, all optional and owned by the kind their doc names). `item/started`, `item/updated`, and `item/completed` carry the full object; `item/delta` appends to it by field path."""
700
+
701
+ agentPath: str
702
+ approvalId: str
703
+ args: str
704
+ attachments: list[MessageAttachment]
705
+ background: bool
706
+ backgroundInitiator: BackgroundInitiator
707
+ callId: str
708
+ childSessionId: str
709
+ childSessionLogPath: str
710
+ children: list[WorkflowChild]
711
+ commandId: str
712
+ commandText: str
713
+ controlStatus: SubagentControlStatus
714
+ depth: int
715
+ displayText: str
716
+ durationMs: int
717
+ entryId: str
718
+ exitCode: int
719
+ exitSignal: int
720
+ failureKind: str
721
+ failureReason: str
722
+ fallbackText: str
723
+ generationId: int
724
+ message: str
725
+ modelVisibleContent: list[ModelVisibleContent]
726
+ objective: str
727
+ outcome: CompactionOutcome
728
+ outputRef: OutputRef
729
+ patchRef: OutputRef
730
+ patchSummary: PatchSummary
731
+ providerItemId: str
732
+ reason: str
733
+ recordedAt: str
734
+ reminderAgentId: str
735
+ result: SubagentResult
736
+ resumeFromRunId: str
737
+ retracted: bool
738
+ role: str
739
+ scriptId: str
740
+ steered: bool
741
+ strategyId: str
742
+ subagentId: str
743
+ summarizedThrough: str
744
+ summary: list[str]
745
+ taskId: str
746
+ text: str
747
+ tokensAfter: int
748
+ tokensBefore: int
749
+ tool: str
750
+ trigger: CompactionTrigger
751
+ triggerSource: str
752
+ truncated: bool
753
+ turnId: str | None
754
+ usage: TokenUsage
755
+ visibleOutput: str
756
+ workflowRunId: str
757
+
758
+
759
+ class ItemCompletedParams(TypedDict):
760
+ """`item/completed` params (tdd SS4.3): the item reached its terminal state — the authoritative final object. Always cites a durable `sourceRange` (tdd SS4.2). Clients MUST accept `item/completed` for an `itemId` they never saw `item/started` for (single-shot kinds; after a gap fill; tdd SS4.4.1)."""
761
+
762
+ item: Item
763
+ sessionId: str
764
+ sourceRange: SourceRange
765
+ viewCursor: str
766
+
767
+
768
+ class _ItemDeltaParamsBase(TypedDict):
769
+ delta: str
770
+ itemId: str
771
+ sessionId: str
772
+ viewCursor: str
773
+
774
+
775
+ class ItemDeltaParams(_ItemDeltaParamsBase, total=False):
776
+ """`item/delta` params (tdd SS4.3.1): a UTF-8-safe streaming append to an open item's field. Ephemeral-sourced by definition: this params object has **no** `sourceRange` member at all (spec 14653 INV-009 — the schema enforces the exemption). Deltas never bump `revision`."""
777
+
778
+ field: str
779
+
780
+
781
+ class _ItemReadOutputParamsBase(TypedDict):
782
+ itemId: str
783
+ outputRef: str
784
+ sessionId: str
785
+
786
+
787
+ class ItemReadOutputParams(_ItemReadOutputParamsBase, total=False):
788
+ """`item/readOutput` params (tdd SS4.7.4): byte-ranged fetch of stored full output that the view truncated — the `outputRef` fetch path SS3.9 and SS4.5.5 owe. Read-only; works on loaded and unloaded sessions; no lease."""
789
+
790
+ lengthBytes: int
791
+ offsetBytes: int
792
+
793
+
794
+ class ItemReadOutputResult(TypedDict):
795
+ """`item/readOutput` result (tdd SS4.7.4): one stored-byte page."""
796
+
797
+ byteLen: int
798
+ content: str
799
+ encoding: ItemReadOutputEncoding
800
+ eof: bool
801
+ mediaType: str
802
+ offsetBytes: int
803
+
804
+
805
+ class _ItemStartedParamsBase(TypedDict):
806
+ item: Item
807
+ sessionId: str
808
+ viewCursor: str
809
+
810
+
811
+ class ItemStartedParams(_ItemStartedParamsBase, total=False):
812
+ """`item/started` params (tdd SS4.3): a new item opened on the transcript. `sourceRange` is absent when the item opens on an ephemeral record (the delta-streamed kinds); the item's authoritative open is re-stated by its durable-sourced `item/completed` (tdd SS4.2)."""
813
+
814
+ sourceRange: SourceRange
815
+
816
+
817
+ class ItemUpdatedParams(TypedDict):
818
+ """`item/updated` params (tdd SS4.4.2): an open item changed non-terminally in a way deltas cannot express — the full item re-emitted at a higher revision (apply rule: replace iff higher)."""
819
+
820
+ item: Item
821
+ sessionId: str
822
+ sourceRange: SourceRange
823
+ viewCursor: str
824
+
825
+
826
+ class _MessageAttachmentBase(TypedDict):
827
+ mediaType: str
828
+ type: str
829
+
830
+
831
+ class MessageAttachment(_MessageAttachmentBase, total=False):
832
+ """`userMessage` image attachment metadata (tdd SS4.5.2): metadata only — the durable bytes live in the log and are reachable on the raw altitude."""
833
+
834
+ height: int
835
+ width: int
836
+
837
+
838
+ class ModelCatalogEntry(TypedDict):
839
+ """One visible catalog row (tdd SS3.10). Catalog rows marked hidden never reach the wire, so a client cannot select one."""
840
+
841
+ contextLimit: int | None
842
+ cost: ModelCost | None
843
+ description: str | None
844
+ displayLabel: str
845
+ isActive: bool
846
+ isDefault: bool
847
+ modelId: str
848
+ outputLimit: int | None
849
+ profileId: str | None
850
+ providerId: str
851
+ releaseDate: str | None
852
+
853
+
854
+ class ModelCost(TypedDict):
855
+ """Per-1M-token catalog cost, carried **verbatim** for display and never rounded or re-formatted by the host (tdd SS3.10). Cost arithmetic stays client-local view math."""
856
+
857
+ cached: str
858
+ currency: str | None
859
+ input: str
860
+ output: str
861
+
862
+
863
+ class ModelListParams(TypedDict, total=False):
864
+ """`model/list` params (tdd SS3.10): the discovery half of the model-picker gesture. **A query, not a command** — no `commandId`, no durable intake record, no view event."""
865
+
866
+ sessionId: str
867
+
868
+
869
+ class ModelListResult(TypedDict):
870
+ """`model/list` result (tdd SS3.10). A snapshot at call time: v1 has no catalog subscription. `models` MAY be empty — a build shipped with no bundled models is a supported configuration."""
871
+
872
+ models: list[ModelCatalogEntry]
873
+ profileId: str | None
874
+ providerId: str
875
+ source: ModelCatalogSource
876
+
877
+
878
+ class _ModelSelectionBase(TypedDict):
879
+ modelId: str
880
+
881
+
882
+ class ModelSelection(_ModelSelectionBase, total=False):
883
+ """A model selection (tdd SS3.8). Empty strings are normalized to absent."""
884
+
885
+ displayLabel: str
886
+ profileId: str | None
887
+ providerId: str
888
+
889
+
890
+ class _ModelVisibleContentBase(TypedDict):
891
+ mediaType: str
892
+ path: str
893
+ sourceToolName: str
894
+ type: str
895
+
896
+
897
+ class ModelVisibleContent(_ModelVisibleContentBase, total=False):
898
+ """Rich content the model saw beyond text (tdd SS4.5.5, `ModelVisibleToolContent`): metadata only — fetch bytes via `item/readOutput` when an `outputRef` exists."""
899
+
900
+ height: int
901
+ width: int
902
+
903
+
904
+ class _NotificationBase(TypedDict):
905
+ jsonrpc: JsonRpcVersion
906
+ method: str
907
+
908
+
909
+ class Notification(_NotificationBase, total=False):
910
+ """A notification frame, either direction (SS1.2 §2.2). No `id`; a notification is never answered."""
911
+
912
+ emittedAtMs: int
913
+ params: dict[str, Any]
914
+
915
+
916
+ class _OutputRefBase(TypedDict):
917
+ availability: OutputRefAvailability
918
+ byteLen: int
919
+ id: str
920
+ kind: str
921
+ uri: str
922
+
923
+
924
+ class OutputRef(_OutputRefBase, total=False):
925
+ """Stored-output reference (tdd SS4.5.5): the camelCased fold of the durable `ToolOutputRef`. The fetch path is `item/readOutput` (#208)."""
926
+
927
+ digest: str
928
+ mediaType: str
929
+ path: str
930
+
931
+
932
+ class PatchSummary(TypedDict):
933
+ """Server-authored edit-family diff summary (tdd SS4.5.5, #33025): `files` counts the stored patch document's file entries; `added` and `removed` are the total `+`/`-` prefixed LINE counts summed over the stored patch's hunks across all files — line counts, never hunk or byte counts. Rides the `toolCall` item beside `patchRef`; the body is fetched via `item/readOutput` with `patchRef.id`."""
934
+
935
+ added: int
936
+ files: int
937
+ removed: int
938
+
939
+
940
+ class _PendingApprovalPointerBase(TypedDict):
941
+ approvalId: str
942
+ viewCursor: str
943
+
944
+
945
+ class PendingApprovalPointer(_PendingApprovalPointerBase, total=False):
946
+ """A pending approval in the snapshot: the SS2.5.2 pointer shape plus the gated `itemId` when one exists (tdd SS4.9.1)."""
947
+
948
+ itemId: str
949
+
950
+
951
+ class _PendingRequestPointerBase(TypedDict):
952
+ kind: PendingRequestKind
953
+ viewCursor: str
954
+
955
+
956
+ class PendingRequestPointer(_PendingRequestPointerBase, total=False):
957
+ """A late-joiner pointer at an unsettled server-initiated request (tdd SS2.5.2, SS2.2.1). The full payloads arrive as re-issued server-to-client requests right after a `session/resume` response (tdd SS5.6); `session/read` never re-issues them (tdd SS2.5.5). **A second E4 instance, RULED with E4 (#22785, owner, 2026-08-26): the flat discriminated-object precedent is accepted for this type too, on the `ApprovalSubject` precedent, with the serialized JSON unchanged. A strict union node kind may be funded later; if it is, it must cover both this type and `TurnInputPart`.** SS2.5.2 ratifies two kind-discriminated entry shapes (`{kind: \"approval\", approvalId, viewCursor}` / `{kind: \"userInput\", userInputId, viewCursor}`); this is one flat object with both ids optional, so the published schema accepts `{\"kind\":\"approval\",\"userInputId\":…}` and an entry carrying no id at all. The v1 model names no object-variant union (the `ApprovalSubject` precedent, followed for `TurnInputPart`), and this instance differs from that one in a way the ruling should see: `kind` here is an OPEN enum, where `TurnInputPart.type` is closed."""
958
+
959
+ approvalId: str
960
+ userInputId: str
961
+
962
+
963
+ class _PendingUserInputPointerBase(TypedDict):
964
+ userInputId: str
965
+ viewCursor: str
966
+
967
+
968
+ class PendingUserInputPointer(_PendingUserInputPointerBase, total=False):
969
+ """A pending user-input prompt in the snapshot (tdd SS4.9.1, SS5.10)."""
970
+
971
+ itemId: str
972
+
973
+
974
+ class ReasoningEffortState(TypedDict):
975
+ """The snapshot's standing session-default reasoning effort (tdd SS4.9.1, ADR 31255 D1): the fold of the latest completed `runtime.reasoning_effort_reconfigure` fact — the same pair `session/reasoningEffortChanged` carries."""
976
+
977
+ reasoningEffort: ReasoningEffort
978
+ source: ReasoningEffortChangeSource
979
+
980
+
981
+ class RecordPosition(TypedDict):
982
+ """One end of a [`SourceRange`]: a record's event id and its sequence number within the stream (tdd SS4.2)."""
983
+
984
+ id: str
985
+ sequence: int
986
+
987
+
988
+ class _RequestBase(TypedDict):
989
+ id: RequestId
990
+ jsonrpc: JsonRpcVersion
991
+ method: str
992
+
993
+
994
+ class Request(_RequestBase, total=False):
995
+ """A request frame, either direction (SS1.2 §2.1)."""
996
+
997
+ params: dict[str, Any]
998
+ trace: TraceContext
999
+
1000
+
1001
+ class RequestReceipt(TypedDict):
1002
+ """The SS5.3.3 presentation receipt — the client's response to a server-initiated request (`approval/request`, `userInput/request`). The response acknowledges presentation only (\"a surface showed or will show this\"): it changes no state, the server uses it for diagnostics alone, and the decision/answer travels as a command (`approval/decide`, `userInput/answer`). An error response or a dropped connection means this connection could not present the request; the approval or prompt stays pending and the request is re-issued on the next subscribe (SS5.6). There is no dismiss-without-deciding on the wire."""
1003
+
1004
+ pass
1005
+
1006
+
1007
+ class SchemaInfo(TypedDict):
1008
+ """The `schema` pair in [`InitializeResult`] (SS1.4.1, SS1.5.3). `version` is the wire **envelope** schema version — distinct from the session-view `schemaVersion`, the raw-log `schema_version`, and the 0.x/1.0 stability posture, which is not on the wire at all (INV-006a)."""
1009
+
1010
+ fingerprint: str
1011
+ version: int
1012
+
1013
+
1014
+ class ServerInfo(TypedDict):
1015
+ """Server identification inside [`InitializeResult`]."""
1016
+
1017
+ name: str
1018
+ version: str
1019
+
1020
+
1021
+ class _SessionBase(TypedDict):
1022
+ activeTurnId: str | None
1023
+ createdAt: str
1024
+ forkedFrom: ForkProvenance | None
1025
+ modelId: str | None
1026
+ path: str
1027
+ providerId: str | None
1028
+ sessionId: str
1029
+ status: SessionStatus
1030
+ turnCount: int
1031
+ updatedAt: str
1032
+ workspaceRoot: str | None
1033
+
1034
+
1035
+ class Session(_SessionBase, total=False):
1036
+ """The session object every lifecycle method returns or lists (tdd SS2.4). Additive-optional evolution applies: clients must ignore unknown fields."""
1037
+
1038
+ approvalMode: EffectiveApprovalModeState
1039
+ attention: list[AttentionFlag]
1040
+ branch: str
1041
+ firstUserPrompt: str
1042
+ lastActivityAt: str
1043
+ name: str
1044
+ title: str
1045
+
1046
+
1047
+ class SessionApprovalModeChangedParams(TypedDict):
1048
+ """`session/approvalModeChanged` params (tdd SS5.12): the fold of the durable approval-mode reconfigure audit fact — every accepted change writes one; a mode flip without an audit fact is a runtime bug by design."""
1049
+
1050
+ clientName: str
1051
+ commandId: str
1052
+ mode: ApprovalMode
1053
+ sessionId: str
1054
+ source: ApprovalModeSource
1055
+ sourceRange: SourceRange
1056
+ viewCursor: str
1057
+
1058
+
1059
+ class _SessionBranchChangedParamsBase(TypedDict):
1060
+ sessionId: str
1061
+ sourceRange: SourceRange
1062
+ viewCursor: str
1063
+ workspaceRoot: str
1064
+
1065
+
1066
+ class SessionBranchChangedParams(_SessionBranchChangedParamsBase, total=False):
1067
+ """`session/branchChanged` params (tdd SS4.6.4): a durable workspace-branch observation landed."""
1068
+
1069
+ branch: str
1070
+ vcs: Vcs
1071
+
1072
+
1073
+ class _SessionCompactParamsBase(TypedDict):
1074
+ commandId: str
1075
+ sessionId: str
1076
+
1077
+
1078
+ class SessionCompactParams(_SessionCompactParamsBase, total=False):
1079
+ """`session/compact` params (tdd SS3.7): manually compact the session's conversation context — the `/compact` gesture. Compaction runs asynchronously; the ack is admission only."""
1080
+
1081
+ turnId: str
1082
+
1083
+
1084
+ class _SessionCompactResultBase(TypedDict):
1085
+ commandId: str
1086
+ status: CompactStatus
1087
+
1088
+
1089
+ class SessionCompactResult(_SessionCompactResultBase, total=False):
1090
+ """`session/compact` result (tdd SS3.7). Failures *after* admission (`summarizer_failed`, `install_rejected`, `cancelled`) are not wire errors — they arrive as the compaction's terminal view event."""
1091
+
1092
+ reason: str
1093
+
1094
+
1095
+ class SessionConfig(TypedDict, total=False):
1096
+ """The open configuration extension object shared by `session/start` and `session/resume` (ADR 32760 D1). Unknown keys are ignored on the wire, never rejected (tdd SS1.5.4, spec 206 INV-015; D-052 resolving [#23456](https://github.com/mslsrc/tbh/issues/23456)): the live decoder is D-042's tolerant path, and TEST-024 keeps every exported bundle free of `additionalProperties: false`. The Rust typed model's `deny_unknown_fields` is internal and never exported — the #22785 E6b closedness export applies nowhere, and the `x-msp-closed` opt-in mechanism stays inert. Recognized `mcpServers` values are typed and validated before they leave the wire boundary."""
1097
+
1098
+ mcpServers: dict[str, SessionMcpServerConfig]
1099
+
1100
+
1101
+ class _SessionContextUsageParamsBase(TypedDict):
1102
+ pressure: ContextPressureLevel
1103
+ sessionId: str
1104
+ sourceRange: SourceRange
1105
+ usedTokens: int
1106
+ viewCursor: str
1107
+
1108
+
1109
+ class SessionContextUsageParams(_SessionContextUsageParamsBase, total=False):
1110
+ """`session/contextUsage` params (tdd SS4.6.6, #14405): context-window pressure — the counted-once occupancy at the latest provider-reported durable fact, joined with the host's pressure basis. Replace wholesale; emitted only when the `(windowTokens, usedTokens, pressure)` triple changes value (identical adoptions emit nothing)."""
1111
+
1112
+ windowTokens: int
1113
+
1114
+
1115
+ class _SessionForkParamsBase(TypedDict):
1116
+ commandId: str
1117
+ sessionId: str
1118
+
1119
+
1120
+ class SessionForkParams(_SessionForkParamsBase, total=False):
1121
+ """`session/fork` params (tdd SS2.5.3)."""
1122
+
1123
+ cutPoint: ForkCutPoint
1124
+ excludeItems: bool
1125
+
1126
+
1127
+ class SessionForkResult(TypedDict):
1128
+ """`session/fork` result (tdd SS2.5.3): the `session/resume` envelope for the **new** session, whose `session.forkedFrom` carries the provenance."""
1129
+
1130
+ history: SessionHistory
1131
+ pendingRequests: list[PendingRequestPointer]
1132
+ session: Session
1133
+ viewCursor: str
1134
+
1135
+
1136
+ class _SessionGoalChangedParamsBase(TypedDict):
1137
+ sessionId: str
1138
+ sourceRange: SourceRange
1139
+ viewCursor: str
1140
+
1141
+
1142
+ class SessionGoalChangedParams(_SessionGoalChangedParamsBase, total=False):
1143
+ """`session/goalChanged` params (tdd SS4.6.2): the projected goal block's value changed — identical adoptions emit nothing (the change gate), and an explicit `null` clears. Replace wholesale; `null` never means unchanged."""
1144
+
1145
+ goal: Goal
1146
+
1147
+
1148
+ class _SessionHistoryBase(TypedDict):
1149
+ items: list[Item] | None
1150
+ mode: HistoryMode
1151
+ snapshot: ViewSnapshot | None
1152
+
1153
+
1154
+ class SessionHistory(_SessionHistoryBase, total=False):
1155
+ """The `history` envelope shared by `session/resume`, `session/fork`, and `session/read` (tdd SS2.5.2)."""
1156
+
1157
+ noneReason: HistoryNoneReason
1158
+
1159
+
1160
+ class SessionListParams(TypedDict, total=False):
1161
+ """`session/list` params (tdd SS2.5.4). Read-only; never touches leases."""
1162
+
1163
+ cursor: str | None
1164
+ limit: int
1165
+ updatedAfter: str
1166
+ workspaceRoot: str
1167
+
1168
+
1169
+ class SessionListResult(TypedDict):
1170
+ """`session/list` result (tdd SS2.5.4). Ordering is `updatedAt` descending."""
1171
+
1172
+ nextCursor: str | None
1173
+ sessions: list[Session]
1174
+
1175
+
1176
+ class _SessionModelChangedParamsBase(TypedDict):
1177
+ modelId: str
1178
+ sessionId: str
1179
+ source: ModelChangeSource
1180
+ sourceRange: SourceRange
1181
+ viewCursor: str
1182
+
1183
+
1184
+ class SessionModelChangedParams(_SessionModelChangedParamsBase, total=False):
1185
+ """`session/modelChanged` params (tdd SS4.6.1): a durable model-selection record landed (tdd SS3.8)."""
1186
+
1187
+ providerId: str
1188
+
1189
+
1190
+ class _SessionModelRouteUnservedParamsBase(TypedDict):
1191
+ commandId: str
1192
+ installedProviderId: str
1193
+ modelId: str
1194
+ sessionId: str
1195
+ sourceRange: SourceRange
1196
+ viewCursor: str
1197
+
1198
+
1199
+ class SessionModelRouteUnservedParams(_SessionModelRouteUnservedParamsBase, total=False):
1200
+ """`session/modelRouteUnserved` params (#25603, ADR 25603 D1, spec 5469 Amendment 16): an accepted `login.credential_update` installed a provider that cannot serve the session's STANDING model route. Disclosure only — the standing selection is unchanged (no `session/modelChanged` fires) and the repair path is a routable `session/setModel`. Folded from the durable `runtime.provider_reconfigure.standing_route_unserved` record; additive — clients that predate it skip the unknown method."""
1201
+
1202
+ providerId: str
1203
+
1204
+
1205
+ class SessionNameChangedParams(TypedDict):
1206
+ """`session/nameChanged` params (tdd SS4.6.7, #27598): the fold of ANY durable session-name record — the FIRST-NAMING automatic allocate as well as an accepted `session/rename` (or the same in-process runtime command). Replace-wholesale like every SS4.6 sibling."""
1207
+
1208
+ name: str
1209
+ sessionId: str
1210
+ sourceRange: SourceRange
1211
+ viewCursor: str
1212
+
1213
+
1214
+ class _SessionReadParamsBase(TypedDict):
1215
+ sessionId: str
1216
+
1217
+
1218
+ class SessionReadParams(_SessionReadParamsBase, total=False):
1219
+ """`session/read` params (tdd SS2.5.5): read one stored session **without attaching** — no writer lease, no load, no subscription, no `SessionResumed` record."""
1220
+
1221
+ excludeItems: bool
1222
+
1223
+
1224
+ class SessionReadResult(TypedDict):
1225
+ """`session/read` result (tdd SS2.5.5). The `viewCursor` is the fold head at read time — a point-in-time read, immediately stale if a foreign host is appending."""
1226
+
1227
+ history: SessionHistory
1228
+ pendingRequests: list[PendingRequestPointer]
1229
+ session: Session
1230
+ viewCursor: str
1231
+
1232
+
1233
+ class SessionReasoningEffortChangedParams(TypedDict):
1234
+ """`session/reasoningEffortChanged` params (tdd SS4.6.9, ADR 31255 D1): a durable reasoning-effort reconfigure record landed (tdd SS3.21). Replace wholesale, latest wins; the snapshot carries the latest value (SS4.9.1)."""
1235
+
1236
+ reasoningEffort: ReasoningEffort
1237
+ sessionId: str
1238
+ source: ReasoningEffortChangeSource
1239
+ sourceRange: SourceRange
1240
+ viewCursor: str
1241
+
1242
+
1243
+ class SessionRenameParams(TypedDict):
1244
+ """`session/rename` params (tdd SS2.14.2, #27598): set or change the durable allocated session name through the runtime `session_name` command. One writer; withheld under the ephemeral profile."""
1245
+
1246
+ commandId: str
1247
+ name: str
1248
+ sessionId: str
1249
+
1250
+
1251
+ class _SessionRenameResultBase(TypedDict):
1252
+ commandId: str
1253
+ status: CommandStatus
1254
+
1255
+
1256
+ class SessionRenameResult(_SessionRenameResultBase, total=False):
1257
+ """`session/rename` result (tdd SS2.14.2, #27598): `name` is the canonical (normalized) name the durable record settled."""
1258
+
1259
+ name: str
1260
+
1261
+
1262
+ class _SessionResumeParamsBase(TypedDict):
1263
+ commandId: str
1264
+ sessionId: str
1265
+
1266
+
1267
+ class SessionResumeParams(_SessionResumeParamsBase, total=False):
1268
+ """`session/resume` params (tdd SS2.5.2)."""
1269
+
1270
+ config: SessionConfig
1271
+ cursor: str | None
1272
+ excludeItems: bool
1273
+ history: HistoryPreference
1274
+
1275
+
1276
+ class SessionResumeResult(TypedDict):
1277
+ """`session/resume` result (tdd SS2.5.2)."""
1278
+
1279
+ history: SessionHistory
1280
+ pendingRequests: list[PendingRequestPointer]
1281
+ session: Session
1282
+ viewCursor: str
1283
+
1284
+
1285
+ class SessionSetApprovalModeParams(TypedDict):
1286
+ """`session/setApprovalMode` params (tdd SS5.12): switch the session's approval enforcement mode mid-session. A standard SS3 command. **Select, never create.** A client may *select* a mode the host's configuration already defines; it may not construct one, supply inline rules, or otherwise describe a policy on the wire — which is why [`ApprovalMode`] is closed."""
1287
+
1288
+ commandId: str
1289
+ mode: ApprovalMode
1290
+ sessionId: str
1291
+
1292
+
1293
+ class SessionSetApprovalModeResult(TypedDict):
1294
+ """`session/setApprovalMode` result (tdd SS5.12). Applies next-action — an in-flight tool action's pending approval is not retroactively decided by a mode change."""
1295
+
1296
+ applyOutcome: ApprovalModeApplyOutcome
1297
+ commandId: str
1298
+ effectiveMode: EffectiveApprovalModeState
1299
+ status: CommandStatus
1300
+
1301
+
1302
+ class SessionSetModelParams(TypedDict):
1303
+ """`session/setModel` params (tdd SS3.8): the model-picker gesture. The selection is durable and applies to subsequent model calls."""
1304
+
1305
+ commandId: str
1306
+ model: ModelSelection
1307
+ sessionId: str
1308
+
1309
+
1310
+ class SessionSetModelResult(TypedDict):
1311
+ """`session/setModel` result (tdd SS3.8). If a turn is running the selection is admitted now and applied at the next model-call boundary; the ack does not wait for that boundary."""
1312
+
1313
+ commandId: str
1314
+ status: CommandStatus
1315
+
1316
+
1317
+ class SessionSetReasoningEffortParams(TypedDict):
1318
+ """`session/setReasoningEffort` params (tdd SS3.21, ADR 31255 D1): set the session's standing reasoning-effort default. A turn carrying its own `reasoningEffort` overrides it for that turn only; the default overrides the host's configured default. Same accept/reject and `commandId` idempotency shape as `session/setModel` (SS3.8)."""
1319
+
1320
+ commandId: str
1321
+ reasoningEffort: ReasoningEffort
1322
+ sessionId: str
1323
+
1324
+
1325
+ class SessionSetReasoningEffortResult(TypedDict):
1326
+ """`session/setReasoningEffort` result (tdd SS3.21). The default is durable on ack and applies to turns launched after admission; a running turn keeps the request options it already resolved."""
1327
+
1328
+ commandId: str
1329
+ status: CommandStatus
1330
+
1331
+
1332
+ class _SessionStartParamsBase(TypedDict):
1333
+ commandId: str
1334
+
1335
+
1336
+ class SessionStartParams(_SessionStartParamsBase, total=False):
1337
+ """`session/start` params (tdd SS2.5.1)."""
1338
+
1339
+ approvalMode: ApprovalMode | None
1340
+ config: SessionConfig
1341
+ modelId: str
1342
+ providerId: str | None
1343
+ sessionId: str
1344
+ workspaceRoot: str
1345
+
1346
+
1347
+ class SessionStartResult(TypedDict):
1348
+ """`session/start` result (tdd SS2.5.1)."""
1349
+
1350
+ session: Session
1351
+ viewCursor: str
1352
+
1353
+
1354
+ class _SessionStatusChangedParamsBase(TypedDict):
1355
+ sessionId: str
1356
+ status: SessionStatus
1357
+ viewCursor: str | None
1358
+
1359
+
1360
+ class SessionStatusChangedParams(_SessionStatusChangedParamsBase, total=False):
1361
+ """`session/statusChanged` params (tdd SS4.6.10, ADR 31983 D2): a loaded session's projected `(status, attention)` value flipped. A command-plane broadcast — delivered to every connection regardless of its view subscription set, never gated, no `sourceRange`; the same facts live on the Session object, which is how a client seeds its table (no initial burst on connect)."""
1362
+
1363
+ attention: list[AttentionFlag]
1364
+
1365
+
1366
+ class SessionTodoListChangedParams(TypedDict):
1367
+ """`session/todoListChanged` params (tdd SS4.6.3): a `TodoSnapshotUpdated` record landed. Replace the whole list on every event; an empty `items` array is a cleared list, not a no-op."""
1368
+
1369
+ items: list[TodoItem]
1370
+ revision: int
1371
+ sessionId: str
1372
+ sourceRange: SourceRange
1373
+ sourceTool: str
1374
+ viewCursor: str
1375
+
1376
+
1377
+ class _SessionTokenUsageParamsBase(TypedDict):
1378
+ cumulative: CumulativeTokenUsage
1379
+ promptTokens: int
1380
+ sessionId: str
1381
+ sourceRange: SourceRange
1382
+ totalTokens: int
1383
+ turnId: str
1384
+ usage: TokenUsage
1385
+ viewCursor: str
1386
+
1387
+
1388
+ class SessionTokenUsageParams(_SessionTokenUsageParamsBase, total=False):
1389
+ """`session/tokenUsage` params (tdd SS4.6.5): one per model completion that reports usage. Carries the raw counters verbatim plus the server-derived counted-once `promptTokens`/`totalTokens` (#8803: clients display and sum these and never re-derive the provider's cache convention) and the session `cumulative` block. Accumulate-only: `cumulative` never goes backward."""
1390
+
1391
+ durationMs: int
1392
+ finishReason: str
1393
+ modelId: str
1394
+
1395
+
1396
+ class SessionUserShellParams(TypedDict):
1397
+ """`session/userShell` params (tdd SS3.9): run a user-initiated shell command in the session's workspace — the TUI's `!` escape hatch. **Capability-gated**: the connection must negotiate `userShell` at `initialize`, and the whole justification is the SS1.10 spawn boundary."""
1398
+
1399
+ commandId: str
1400
+ commandText: str
1401
+ sessionId: str
1402
+
1403
+
1404
+ class SessionUserShellResult(TypedDict):
1405
+ """`session/userShell` result (tdd SS3.9): immediate. The shell runs off the command worker so a long command cannot stall the command plane; the output arrives as the `userShell` item's terminal view event."""
1406
+
1407
+ commandId: str
1408
+ status: CommandStatus
1409
+
1410
+
1411
+ class _SessionViewHealthChangedParamsBase(TypedDict):
1412
+ health: SessionViewHealth
1413
+ sessionId: str
1414
+
1415
+
1416
+ class SessionViewHealthChangedParams(_SessionViewHealthChangedParamsBase, total=False):
1417
+ """`session/viewHealthChanged` params (ADR 32557; #32557): the named session's live view stream became unavailable, and why. Best-effort: ordered after already-queued view frames and may be dropped (for example when the connection is closing), so a client MUST NOT assume a guaranteed push and still reads `history.noneReason` on its next resume/read (FM-005)."""
1418
+
1419
+ noneReason: HistoryNoneReason
1420
+
1421
+
1422
+ class _SkillCatalogEntryBase(TypedDict):
1423
+ description: str
1424
+ displayName: str
1425
+ selector: str
1426
+ source: SkillSource
1427
+
1428
+
1429
+ class SkillCatalogEntry(_SkillCatalogEntryBase, total=False):
1430
+ """One typed-invocable shortcut spelling (tdd SS3.22.1). A plugin skill may contribute two rows: its bare-name winner and its qualified `<pluginId>:<skillId>` form."""
1431
+
1432
+ argumentHint: str
1433
+ pluginId: str
1434
+
1435
+
1436
+ class SkillChangedParams(TypedDict):
1437
+ """`skill/changed` params (tdd SS3.22.2): the session's user-invocable set changed; clients re-issue `skill/list`. Advisory — the host may coalesce bursts and guarantees no ordering relative to view events (ADR 32471 D3)."""
1438
+
1439
+ sessionId: str
1440
+
1441
+
1442
+ class SkillListParams(TypedDict):
1443
+ """`skill/list` params (tdd SS3.22.1). Per-session because skill scope follows the session's workspace and plugin state."""
1444
+
1445
+ sessionId: str
1446
+
1447
+
1448
+ class SkillListResult(TypedDict):
1449
+ """`skill/list` result (tdd SS3.22.1): one row per typed-invocable shortcut spelling — exactly the invocations the first-party typed dispatch accepts (spec 11352 INV-007 predicate and the shared shortcut layer's name resolution, both by call-through; ADR 32471 D2)."""
1450
+
1451
+ skills: list[SkillCatalogEntry]
1452
+
1453
+
1454
+ class SnapshotAnchor(TypedDict):
1455
+ """The compaction boundary an anchored snapshot is anchored at (tdd SS2.5.2)."""
1456
+
1457
+ boundaryCursor: str
1458
+ summarizedThrough: str
1459
+
1460
+
1461
+ class _SnapshotStateBase(TypedDict):
1462
+ activeTurn: TurnRef | None
1463
+ approvalMode: EffectiveApprovalModeState
1464
+ branch: BranchState | None
1465
+ effectiveModel: EffectiveModel | None
1466
+ goal: Goal | None
1467
+ items: list[Item]
1468
+ pendingApprovals: list[PendingApprovalPointer]
1469
+ pendingUserInputs: list[PendingUserInputPointer]
1470
+ queuedTurns: list[TurnRef]
1471
+ todoList: TodoListState | None
1472
+ tokenUsage: CumulativeTokenUsage
1473
+ turnCount: int
1474
+
1475
+
1476
+ class SnapshotState(_SnapshotStateBase, total=False):
1477
+ """The complete folded view at the snapshot cursor (tdd SS4.9.1). Additive-optional evolution applies exactly as everywhere else; unknown members MUST be ignored, and preserved if re-serialized. **One served site does not satisfy this type today, escalated under #22785 (E8).** The genesis snapshot rung serves `state: {\"items\": [...]}` alone (`tbh-session-view-serve`'s `materialized_fold.rs`, the `select_genesis_history` call), while the anchored rung serves the full folded state. A schema-validating client resuming with `{\"history\": \"snapshot\"}` against the real fold therefore sees the other required members missing. The fix is a serving change in the #208/#14653 lane (serialize the `SessionViewState` the genesis path already folds, as the anchored path does) plus its own RED against the real fold; it is not a shape change here, because SS4.9.1 ratifies this shape."""
1478
+
1479
+ contextUsage: ContextUsage
1480
+ name: str
1481
+ reasoningEffort: ReasoningEffortState
1482
+
1483
+
1484
+ class SourceRange(TypedDict):
1485
+ """The inclusive raw-record range a durable-sourced view event folded from (tdd SS4.2) — the reconciliation token: re-folding the cited records from the canonical fold state immediately before `first` — appended host-death terminals seed from the end-of-records state — reproduces the event (tdd SS7.5; spec 14653 T041/INV-009). In v1 it is an **opaque provenance token**: no wire method reads what it points at (the SS6 raw-log altitude is deferred, #13929). Ephemeral-sourced events (`item/delta`, and an `item/started` that opens on an ephemeral record) carry no `sourceRange` — ephemeral records may be evicted by retention (tdd SS4.2; spec 14653 INV-009)."""
1486
+
1487
+ first: RecordPosition
1488
+ last: RecordPosition
1489
+ stream: StreamRef
1490
+
1491
+
1492
+ class StreamRef(TypedDict):
1493
+ """One raw stream named by a [`SourceRange`] (tdd SS4.2)."""
1494
+
1495
+ id: str
1496
+ kind: str
1497
+
1498
+
1499
+ class SubagentInputParams(TypedDict):
1500
+ """Params for `subagent/sendMessage` and `subagent/followupTask` (SS3.16): a child target plus the input body."""
1501
+
1502
+ body: str
1503
+ commandId: str
1504
+ sessionId: str
1505
+ subagentId: str
1506
+
1507
+
1508
+ class _SubagentOwnerReasonParamsBase(TypedDict):
1509
+ commandId: str
1510
+ sessionId: str
1511
+ subagentId: str
1512
+
1513
+
1514
+ class SubagentOwnerReasonParams(_SubagentOwnerReasonParamsBase, total=False):
1515
+ """Params for `subagent/interrupt`, `subagent/stop`, and `subagent/close` (SS3.16): a child target plus an optional human-readable reason that is preserved on the durable effect record."""
1516
+
1517
+ reason: str
1518
+
1519
+
1520
+ class _SubagentResultBase(TypedDict):
1521
+ artifactRefs: list[str]
1522
+ evidenceRefs: list[str]
1523
+ summary: str
1524
+
1525
+
1526
+ class SubagentResult(_SubagentResultBase, total=False):
1527
+ """A subagent's result envelope (tdd SS4.5.7, `SubagentResultEnvelope`)."""
1528
+
1529
+ errorKind: str
1530
+ structuredData: dict[str, Any]
1531
+ text: str
1532
+
1533
+
1534
+ class SubagentTargetParams(TypedDict):
1535
+ """Params for `subagent/resume`, `subagent/reopen`, and `subagent/readResult` (SS3.16): the bare child target."""
1536
+
1537
+ commandId: str
1538
+ sessionId: str
1539
+ subagentId: str
1540
+
1541
+
1542
+ class SubscriptionUsage(TypedDict):
1543
+ """The one usage payload shape: the `usage/read` result's `usage` member and the `usage/changed` params (ADR 32563 D2/D3). The numbers are point-in-time — `observedAtMs` is the host's arrival stamp, so a client renders \"as of\", never implies live data (spec 18742 US-FR-004)."""
1544
+
1545
+ observedAtMs: int
1546
+ tier: str
1547
+ weekly: SubscriptionUsageWeekly
1548
+ window: SubscriptionUsageWindow
1549
+
1550
+
1551
+ class SubscriptionUsageWeekly(TypedDict):
1552
+ """The rolling weekly block: same semantics as [`SubscriptionUsageWindow`] without a duration (ADR 32563 D2)."""
1553
+
1554
+ resetsAtMs: int
1555
+ usedPercent: int
1556
+
1557
+
1558
+ class SubscriptionUsageWindow(TypedDict):
1559
+ """The current usage window (the provider's 5-hour-class block): verbatim provider percentages with the reset stamp normalized to epoch milliseconds (ADR 32563 D2)."""
1560
+
1561
+ resetsAtMs: int
1562
+ usedPercent: int
1563
+ windowDurationMins: int
1564
+
1565
+
1566
+ class SuccessResponse(TypedDict):
1567
+ """A success response frame (SS1.2 §2.3)."""
1568
+
1569
+ id: RequestId
1570
+ jsonrpc: JsonRpcVersion
1571
+ result: dict[str, Any]
1572
+
1573
+
1574
+ class TaskBackgroundParams(TypedDict):
1575
+ """`task/background` params (tdd §3.13): durably send a running foreground tool task to the background."""
1576
+
1577
+ commandId: str
1578
+ sessionId: str
1579
+ taskId: str
1580
+
1581
+
1582
+ class TaskCommandResult(TypedDict):
1583
+ """The `task/background` / `task/stop` ack (tdd §3.13/§3.14): admission-only, echoing the targeted task."""
1584
+
1585
+ commandId: str
1586
+ status: CommandStatus
1587
+ taskId: str
1588
+
1589
+
1590
+ class TaskStopAllParams(TypedDict):
1591
+ """`task/stopAll` params (tdd §3.15): stop every stoppable background workload live at admission."""
1592
+
1593
+ commandId: str
1594
+ sessionId: str
1595
+
1596
+
1597
+ class TaskStopAllResult(TypedDict):
1598
+ """The `task/stopAll` ack (tdd §3.15): always `accepted`, including over an empty set — a blanket stop over nothing is a satisfied gesture. The ack deliberately carries no stopped-task list; count the kills from the view."""
1599
+
1600
+ commandId: str
1601
+ status: CommandStatus
1602
+
1603
+
1604
+ class TaskStopParams(TypedDict):
1605
+ """`task/stop` params (tdd §3.14): stop one named background task. Required target, never \"whichever is loudest\" — §3.15 is the blanket verb."""
1606
+
1607
+ commandId: str
1608
+ sessionId: str
1609
+ taskId: str
1610
+
1611
+
1612
+ class _TodoItemBase(TypedDict):
1613
+ status: TodoStatus
1614
+ text: str
1615
+
1616
+
1617
+ class TodoItem(_TodoItemBase, total=False):
1618
+ """One todo entry (tdd SS4.6.3)."""
1619
+
1620
+ activeForm: str
1621
+
1622
+
1623
+ class TodoListState(TypedDict):
1624
+ """The latest todo-list fact in the snapshot (tdd SS4.6.3, SS4.9.1)."""
1625
+
1626
+ items: list[TodoItem]
1627
+ revision: int
1628
+ sourceTool: str
1629
+
1630
+
1631
+ class _TokenUsageBase(TypedDict):
1632
+ cachedTokens: int
1633
+ inputTokens: int
1634
+ outputTokens: int
1635
+ reasoningTokens: int
1636
+
1637
+
1638
+ class TokenUsage(_TokenUsageBase, total=False):
1639
+ """Raw token counters, verbatim from the durable record (tdd SS4.6.5, the runtime's `Usage`, camelCased). Not directly summable across providers — sum the counted-once derivations instead (#8803)."""
1640
+
1641
+ cacheReadTokens: int
1642
+ cacheWriteTokens: int
1643
+
1644
+
1645
+ class TraceContext(TypedDict, total=False):
1646
+ """Optional W3C trace context, on requests in both directions only — never on responses or notifications (SS1.8)."""
1647
+
1648
+ traceparent: str
1649
+ tracestate: str
1650
+
1651
+
1652
+ class _TurnCancelParamsBase(TypedDict):
1653
+ commandId: str
1654
+ sessionId: str
1655
+
1656
+
1657
+ class TurnCancelParams(_TurnCancelParamsBase, total=False):
1658
+ """`turn/cancel` params (tdd SS3.5): plain cancellation on the normal command lane. Same shape as `turn/interrupt`, **without** `retract` — pairing a retract with a plain cancel is durably rejected `not_paired_interrupt`."""
1659
+
1660
+ turnId: str
1661
+
1662
+
1663
+ class TurnCancelResult(TypedDict):
1664
+ """`turn/cancel` result (tdd SS3.5): identical envelope to `turn/interrupt`."""
1665
+
1666
+ commandId: str
1667
+ status: CommandStatus
1668
+ turnId: str
1669
+
1670
+
1671
+ class _TurnCompletedParamsBase(TypedDict):
1672
+ sessionId: str
1673
+ sourceRange: SourceRange
1674
+ terminal: TurnTerminal
1675
+ turnId: str
1676
+ viewCursor: str
1677
+
1678
+
1679
+ class TurnCompletedParams(_TurnCompletedParamsBase, total=False):
1680
+ """`turn/completed` params (tdd SS4.5.1): the run's durable terminal record landed."""
1681
+
1682
+ durationMs: int
1683
+ error: TurnError
1684
+ reason: str
1685
+ timeToFirstTokenMs: int
1686
+ usage: TokenUsage
1687
+
1688
+
1689
+ class TurnError(TypedDict):
1690
+ """The settled turn-failure object (tdd SS4.5.1): `{kind, message, retryable}`."""
1691
+
1692
+ kind: TurnErrorKind
1693
+ message: str
1694
+ retryable: bool
1695
+
1696
+
1697
+ class _TurnInputPartBase(TypedDict):
1698
+ type: TurnInputPartType
1699
+
1700
+
1701
+ class TurnInputPart(_TurnInputPartBase, total=False):
1702
+ """One ordered content part of a turn submission (tdd SS3.2). File mentions are text, not a part type: write `@relative/path` in a text part. A structured `mention` part is reserved and currently rejected, and an unknown part type is `invalidParams` (tdd SS3.1.2, SS3.2) — which is what closes [`TurnInputPartType`]. Modelled as a discriminated flat object rather than a Rust `enum`, the convention [`crate::view::approval::ApprovalSubject`] already established for a wire union in this crate: the v1 schema model names no object-variant union shape and fails closed on one. The serialized JSON is the tdd shape either way; what a flat object cannot express is \"`mediaType` is required exactly when `type` is `image`\". **RULED (#22785 E4, owner, 2026-08-26): the precedent is accepted.** A strict union node kind may be funded later as a follow-up; if it is, it must cover [`crate::method::lifecycle::PendingRequestPointer`] too."""
1703
+
1704
+ arguments: str
1705
+ base64Data: str
1706
+ height: int
1707
+ mediaType: str
1708
+ selector: str
1709
+ text: str
1710
+ width: int
1711
+
1712
+
1713
+ class _TurnInterruptParamsBase(TypedDict):
1714
+ commandId: str
1715
+ sessionId: str
1716
+
1717
+
1718
+ class TurnInterruptParams(_TurnInterruptParamsBase, total=False):
1719
+ """`turn/interrupt` params (tdd SS3.4): the \"user pressed stop\" gesture, on the runtime's priority lane."""
1720
+
1721
+ retract: bool
1722
+ turnId: str
1723
+
1724
+
1725
+ class TurnInterruptResult(TypedDict):
1726
+ """`turn/interrupt` result (tdd SS3.4). Acceptance means the interrupt was admitted, **not** that the turn is already stopped: the turn is over when you fold its `turn/completed` with terminal `cancelled`."""
1727
+
1728
+ commandId: str
1729
+ status: CommandStatus
1730
+ turnId: str
1731
+
1732
+
1733
+ class TurnRef(TypedDict):
1734
+ """A turn named by the snapshot's active/queued lists (tdd SS4.9.1)."""
1735
+
1736
+ commandId: str
1737
+ turnId: str
1738
+
1739
+
1740
+ class TurnRetractedParams(TypedDict):
1741
+ """`turn/retracted` params (tdd SS4.5.1): an interrupt-paired retract was durably accepted. The retracted user-message item is re-emitted via `item/updated` with `retracted: true`."""
1742
+
1743
+ commandId: str
1744
+ sessionId: str
1745
+ sourceRange: SourceRange
1746
+ turnId: str
1747
+ viewCursor: str
1748
+
1749
+
1750
+ class TurnRetryScheduledParams(TypedDict):
1751
+ """`turn/retryScheduled` params (tdd SS4.5.1, spec 14412; D-026): a durable turn retry-scheduled fact folded — the failing model attempt's scheduled retry is observable BEFORE the turn terminates, so a streaming client can render \"attempt N/M · retrying in Ss · reason\" instead of dead air. Non-terminal: it never resolves a turn-wait (tdd SS3.1.4). The delay is the recorded scheduled backoff, never an absolute fire time — clients derive any countdown locally. `sourceRange` cites the session stream's mirror of the task-lifecycle record (tdd SS4.2)."""
1752
+
1753
+ attempt: int
1754
+ maxAttempts: int
1755
+ nextAttempt: int
1756
+ reason: str
1757
+ retryDelayMs: int
1758
+ sessionId: str
1759
+ sourceRange: SourceRange
1760
+ turnId: str
1761
+ viewCursor: str
1762
+
1763
+
1764
+ class _TurnStartParamsBase(TypedDict):
1765
+ commandId: str
1766
+ input: list[TurnInputPart]
1767
+ sessionId: str
1768
+
1769
+
1770
+ class TurnStartParams(_TurnStartParamsBase, total=False):
1771
+ """`turn/start.providerRequestOptions` is deliberately absent: **RULED (#22785 E3, owner, 2026-08-26) to stay off the published schema.** The schema is the contract, and a free-form-object node kind is revisited only if the experimental field graduates. `turn/start` params (tdd SS3.2)."""
1772
+
1773
+ displayText: str
1774
+ ifBusy: IfBusy
1775
+ reasoningEffort: ReasoningEffort
1776
+
1777
+
1778
+ class TurnStartResult(TypedDict):
1779
+ """`turn/start` result (tdd SS3.2)."""
1780
+
1781
+ commandId: str
1782
+ disposition: TurnStartDisposition
1783
+ startedNewTurn: bool
1784
+ status: CommandStatus
1785
+ turnId: str
1786
+
1787
+
1788
+ class TurnStartedParams(TypedDict):
1789
+ """`turn/started` params (tdd SS4.5.1): a foreground turn began running — fresh submits immediately, queued submits at their launch boundary, never steered submits."""
1790
+
1791
+ commandId: str
1792
+ sessionId: str
1793
+ sourceRange: SourceRange
1794
+ turnId: str
1795
+ viewCursor: str
1796
+
1797
+
1798
+ class _TurnSteerParamsBase(TypedDict):
1799
+ commandId: str
1800
+ expectedTurnId: str
1801
+ input: list[TurnInputPart]
1802
+ sessionId: str
1803
+
1804
+
1805
+ class TurnSteerParams(_TurnSteerParamsBase, total=False):
1806
+ """`turn/steer` params (tdd SS3.3): exact-target steering into the currently running turn."""
1807
+
1808
+ reasoningEffort: ReasoningEffort
1809
+
1810
+
1811
+ class TurnSteerResult(TypedDict):
1812
+ """`turn/steer` result (tdd SS3.3)."""
1813
+
1814
+ commandId: str
1815
+ status: CommandStatus
1816
+ turnId: str
1817
+
1818
+
1819
+ class TurnUnqueueParams(TypedDict):
1820
+ """`turn/unqueue` params (tdd SS3.6): reclaim a queued submit before it launches. It is **not** a stop — a reclaim that arrives after its target launched is durably rejected, never silently upgraded into a cancel."""
1821
+
1822
+ commandId: str
1823
+ sessionId: str
1824
+ turnId: str
1825
+
1826
+
1827
+ class TurnUnqueueResult(TypedDict):
1828
+ """`turn/unqueue` result (tdd SS3.6). Admission only — but for this command admission *is* the race: an admitted reclaim implies the turn will not launch. The authoritative removal is the `turn/unqueued` view event."""
1829
+
1830
+ commandId: str
1831
+ status: CommandStatus
1832
+ turnId: str
1833
+
1834
+
1835
+ class TurnUnqueuedParams(TypedDict):
1836
+ """`turn/unqueued` params (tdd SS3.6, SS4.5.1): a queued submit's reclaim durably won; its pre-minted turn never runs. Carries the reclaimed `turnId` and the `commandId` of the `turn/start` that queued it, so a client can restore the submission's text exactly as for `turn/retracted`. No `turn/started`/`turn/completed` is ever emitted for this `turnId` (SDK turn-waits settle on this event too, tdd SS3.1.4). `sourceRange` cites the SESSION stream's reclaim record — a reclaimed turn never had a run stream."""
1837
+
1838
+ commandId: str
1839
+ sessionId: str
1840
+ sourceRange: SourceRange
1841
+ turnId: str
1842
+ viewCursor: str
1843
+
1844
+
1845
+ class UnframedViewNotification(TypedDict):
1846
+ """One element of a `view/page` result's `events` array: an **unframed view notification** exactly as tdd SS4.2.1 defines it — the nested pair `{\"method\", \"params\"}`, which is the live notification minus `jsonrpc` and `emittedAtMs`, with nothing lifted out of `params` and nothing spliced into it. SS4.2.1 is the single normative definition; SS4.7.3 and SS7.4 both cite it, so the two surfaces cannot drift."""
1847
+
1848
+ method: str
1849
+ params: UnframedViewNotificationParams
1850
+
1851
+
1852
+ class UnframedViewNotificationParams(TypedDict):
1853
+ """The `params` of an unframed view notification (tdd SS4.2.1, SS4.2). Declares the SS4.2 base members every view notification carries, and stays **open** for the event-specific fields SS4.5/SS4.6/SS5 add per event type. The v1 schema model names no method-correlated union (the SS4.7.3 `events` element's `params` arm is selected by its sibling `method`), so the per-event arms cannot be expressed here without one; enumerating them as an uncorrelated union would additionally exclude `turn/unqueued`, whose notification row is another lane's ratified deferral (#207/#14407) — a published schema that rejects a real page element is the exact #19923 defect this PR exists to close. Recorded as a Design delta on #22785. `sourceRange` is required here and not optional: `view/page` serves durable-sourced events only (tdd SS4.7.3), and durable-sourced is *defined* as carrying a `sourceRange` — the SS4.2 ephemeral-sourced exemption applies to `item/delta`, which `view/page` never replays."""
1854
+
1855
+ sessionId: str
1856
+ sourceRange: SourceRange
1857
+ viewCursor: str
1858
+
1859
+
1860
+ class UsageReadResult(TypedDict, total=False):
1861
+ """`usage/read` result: `{usage?}` — omitted, never `null`, when the host has observed nothing (ADR 32563 D2: truthful absence, no \"nothing observed\" error)."""
1862
+
1863
+ usage: SubscriptionUsage
1864
+
1865
+
1866
+ class _UserInputAnswerBase(TypedDict):
1867
+ questionId: str
1868
+
1869
+
1870
+ class UserInputAnswer(_UserInputAnswerBase, total=False):
1871
+ freeText: str
1872
+ note: str
1873
+ selectedLabel: str
1874
+ selectedLabels: list[str]
1875
+
1876
+
1877
+ class UserInputAnswerParams(TypedDict):
1878
+ """`userInput/answer` params (tdd SS5.10.2): answer every question. Each answer carries `questionId` then exactly one of `selectedLabel` (single mode), `selectedLabels` (multiple mode, within min/max bounds), or `freeText` (<=500 chars); plus an optional `note` (<=500). Answers that do not match the prompt fail -32057 `userInputAnswerInvalid`. Image `attachments` are a **reserved** field in v1, rejected if sent, because the blob-upload path they reference is reserved in tdd SS3.2."""
1879
+
1880
+ answers: list[UserInputAnswer]
1881
+ commandId: str
1882
+ sessionId: str
1883
+ userInputId: str
1884
+
1885
+
1886
+ class UserInputAnswerResult(TypedDict):
1887
+ """`userInput/answer` result (tdd SS5.10.2)."""
1888
+
1889
+ commandId: str
1890
+ status: CommandStatus
1891
+ userInputId: str
1892
+
1893
+
1894
+ class _UserInputCancelParamsBase(TypedDict):
1895
+ commandId: str
1896
+ sessionId: str
1897
+ userInputId: str
1898
+
1899
+
1900
+ class UserInputCancelParams(_UserInputCancelParamsBase, total=False):
1901
+ """`userInput/cancel` params (tdd SS5.10.2): decline to answer; the tool call resolves with a cancelled result the model sees."""
1902
+
1903
+ reason: str
1904
+
1905
+
1906
+ class UserInputCancelResult(TypedDict):
1907
+ """`userInput/cancel` result (tdd SS5.10.2)."""
1908
+
1909
+ commandId: str
1910
+ status: CommandStatus
1911
+ userInputId: str
1912
+
1913
+
1914
+ class UserInputClarification(TypedDict):
1915
+ content: str
1916
+ format: str
1917
+
1918
+
1919
+ class UserInputClarifyParams(TypedDict):
1920
+ """`userInput/clarify` params (tdd SS5.10.2): answer with a free-form clarification instead of the structured options — the \"let me explain\" path; the model receives the clarification text and re-decides."""
1921
+
1922
+ clarification: UserInputClarification
1923
+ commandId: str
1924
+ sessionId: str
1925
+ userInputId: str
1926
+
1927
+
1928
+ class UserInputClarifyResult(TypedDict):
1929
+ """`userInput/clarify` result (tdd SS5.10.2)."""
1930
+
1931
+ commandId: str
1932
+ status: CommandStatus
1933
+ userInputId: str
1934
+
1935
+
1936
+ class _UserInputOptionBase(TypedDict):
1937
+ label: str
1938
+
1939
+
1940
+ class UserInputOption(_UserInputOptionBase, total=False):
1941
+ description: str
1942
+ preview: UserInputOptionPreview
1943
+
1944
+
1945
+ class UserInputOptionPreview(TypedDict):
1946
+ content: str
1947
+ format: str
1948
+
1949
+
1950
+ class UserInputQuestion(TypedDict):
1951
+ header: str
1952
+ id: str
1953
+ options: list[UserInputOption]
1954
+ question: str
1955
+ selection: UserInputSelection
1956
+
1957
+
1958
+ class _UserInputRequestParamsBase(TypedDict):
1959
+ itemId: str
1960
+ questions: list[UserInputQuestion]
1961
+ sessionId: str
1962
+ toolCallId: str
1963
+ toolName: str
1964
+ turnId: str
1965
+ userInputId: str
1966
+ viewCursor: str
1967
+
1968
+
1969
+ class UserInputRequestParams(_UserInputRequestParamsBase, total=False):
1970
+ """Full params shared by `userInput/request` and `userInput/requested`."""
1971
+
1972
+ autoResolutionMs: int
1973
+ sourceRange: SourceRange
1974
+
1975
+
1976
+ class _UserInputSelectionBase(TypedDict):
1977
+ mode: UserInputSelectionMode
1978
+
1979
+
1980
+ class UserInputSelection(_UserInputSelectionBase, total=False):
1981
+ maxSelections: int
1982
+ minSelections: int
1983
+
1984
+
1985
+ class UserInputSettledParams(TypedDict):
1986
+ """`userInput/settled` params: the first durable prompt settlement."""
1987
+
1988
+ answers: list[UserInputAnswer]
1989
+ clarification: UserInputClarification | None
1990
+ decidedByCommandId: str | None
1991
+ outcome: UserInputOutcome
1992
+ reason: str | None
1993
+ sessionId: str
1994
+ sourceRange: SourceRange
1995
+ userInputId: str
1996
+ viewCursor: str
1997
+
1998
+
1999
+ class UserInputSettlementSummary(TypedDict):
2000
+ """Winning terminal returned to a late user-input command."""
2001
+
2002
+ outcome: str
2003
+ viewCursor: str
2004
+
2005
+
2006
+ class ViewGapParams(TypedDict):
2007
+ """`view/gap` params (spec 208 SS4.8, FM-001): push delivery dropped events, and this names the hole. The bracket is deferred (D-16487-2): it flushes at the subscription's next ACCEPTED delivery, never at enqueue time, so `next` always names an event whose own delivery is proven. A run of consecutive undelivered events coalesces into one bracket keeping the FIRST range's `after` (D-16487-1). The gap rides the protected reserved queue, so no wire-interleaving order against neighbouring deliveries is promised — the cursors carry the semantics (INV-002, D-16487-3). On receipt a client may take either sanctioned recovery (D-030, FR-013): splice-fill — buffer live events at cursors >= `next`, page `(after, next)` forward, discard the overlap, splice — or re-anchor through the anchored read surface. The server requires neither, cannot distinguish clients by their choice, and holds no partial-fill state."""
2008
+
2009
+ after: str
2010
+ next: str
2011
+ sessionId: str
2012
+
2013
+
2014
+ class _ViewPageParamsBase(TypedDict):
2015
+ limit: int
2016
+ sessionId: str
2017
+
2018
+
2019
+ class ViewPageParams(_ViewPageParamsBase, total=False):
2020
+ """`view/page` params (tdd SS4.7.3): cursor-paged reads of the session view."""
2021
+
2022
+ anchor: ViewPageAnchor
2023
+ cursor: str
2024
+ direction: ViewPageDirection
2025
+
2026
+
2027
+ class ViewPageResolvedAnchor(TypedDict):
2028
+ """The `resolvedAnchor` echo (tdd SS4.7.3): subsequent pages pass ordinary cursors, so the anchor never needs re-resolving."""
2029
+
2030
+ boundaryCursor: str
2031
+
2032
+
2033
+ class _ViewPageResultBase(TypedDict):
2034
+ events: list[UnframedViewNotification]
2035
+ nextCursor: str | None
2036
+
2037
+
2038
+ class ViewPageResult(_ViewPageResultBase, total=False):
2039
+ """`view/page` result (tdd SS4.7.3)."""
2040
+
2041
+ resolvedAnchor: ViewPageResolvedAnchor
2042
+
2043
+
2044
+ class _ViewSnapshotBase(TypedDict):
2045
+ schemaVersion: int
2046
+ state: SnapshotState
2047
+ viewCursor: str
2048
+
2049
+
2050
+ class ViewSnapshot(_ViewSnapshotBase, total=False):
2051
+ """The `snapshot` object returned by `session/resume` / `session/read` (tdd SS4.9)."""
2052
+
2053
+ anchor: SnapshotAnchor
2054
+
2055
+
2056
+ class _ViewSubscribeParamsBase(TypedDict):
2057
+ sessionId: str
2058
+
2059
+
2060
+ class ViewSubscribeParams(_ViewSubscribeParamsBase, total=False):
2061
+ """`view/subscribe` params (tdd SS4.7.1): attach this connection's live view subscription for a session at an explicit cursor — the fine-grained counterpart of the SS2 auto-subscribe, and the gap-free re-attachment path after `view/unsubscribe`. It never loads a session, takes no lease, writes nothing."""
2062
+
2063
+ after: str
2064
+
2065
+
2066
+ class ViewSubscribeResult(TypedDict):
2067
+ """`view/subscribe` result (tdd SS4.7.1)."""
2068
+
2069
+ viewCursor: str
2070
+
2071
+
2072
+ class ViewUnsubscribeParams(TypedDict):
2073
+ """`view/unsubscribe` params (tdd SS4.7.2): remove this connection from the session's view subscription set — the protocol's single unsubscribe operation, at the altitude that owns subscriptions (tdd SS2.5.6 points here). It does not unload the session; unloading is the idle policy (tdd SS2.8)."""
2074
+
2075
+ sessionId: str
2076
+
2077
+
2078
+ class ViewUnsubscribeResult(TypedDict):
2079
+ """`view/unsubscribe` result (tdd SS4.7.2): the empty object. Idempotent — unsubscribing while not subscribed returns `{}`."""
2080
+
2081
+ pass
2082
+
2083
+
2084
+ class WorkflowCancelParams(TypedDict):
2085
+ """`workflow/cancel` params (tdd SS3.19): cancel a live workflow run."""
2086
+
2087
+ commandId: str
2088
+ sessionId: str
2089
+ workflowRunId: str
2090
+
2091
+
2092
+ class _WorkflowChildBase(TypedDict):
2093
+ attempt: int
2094
+ childId: str
2095
+ status: str
2096
+
2097
+
2098
+ class WorkflowChild(_WorkflowChildBase, total=False):
2099
+ """One workflow child's folded state (tdd SS4.5.8, `WorkflowChildLifecycleFact`), keyed by `(childId, attempt)`."""
2100
+
2101
+ durationMs: int
2102
+ label: str
2103
+ phase: str
2104
+ resultRef: str
2105
+ terminal: TurnTerminal
2106
+ usage: TokenUsage
2107
+
2108
+
2109
+ class WorkflowChildControlParams(TypedDict):
2110
+ """`workflow/childControl` params (tdd SS3.20): skip or retry one workflow child, keyed by the `(childId, attempt)` pair the `workflow` item's `children[]` carries."""
2111
+
2112
+ action: WorkflowChildAction
2113
+ attempt: int
2114
+ childId: str
2115
+ commandId: str
2116
+ sessionId: str
2117
+ workflowRunId: str
2118
+
2119
+
2120
+ class WorkflowControlResult(TypedDict):
2121
+ """The shared SS3.19/SS3.20 admission-only ack: deliberately bare `{commandId, status}` — settlement arrives as the workflow item's view events, never through the ack."""
2122
+
2123
+ commandId: str
2124
+ status: CommandStatus
2125
+
2126
+
2127
+ class __SessionMcpServerConfigStdioBase(TypedDict):
2128
+ command: str
2129
+ transport: Literal["stdio"]
2130
+
2131
+
2132
+ class _SessionMcpServerConfigStdio(__SessionMcpServerConfigStdioBase, total=False):
2133
+ args: list[str]
2134
+ env: dict[str, str]
2135
+ framing: SessionMcpStdioFraming
2136
+ mode: SessionMcpServerMode
2137
+
2138
+
2139
+ class __SessionMcpServerConfigStreamableHttpBase(TypedDict):
2140
+ transport: Literal["streamableHttp"]
2141
+ url: str
2142
+
2143
+
2144
+ class _SessionMcpServerConfigStreamableHttp(__SessionMcpServerConfigStreamableHttpBase, total=False):
2145
+ headers: dict[str, str]
2146
+ mode: SessionMcpServerMode
2147
+
2148
+
2149
+ # One native MCP server supplied at session construction (ADR 32760 D1). **Closed union** (#33295 owner ruling A1, extending D-033/D-050 to `oneOf`): a validator MUST reject an undeclared `transport` arm — the server fails `session/start` decode on an unknown transport, and a future transport arrives as an explicit schema addition.
2150
+ SessionMcpServerConfig = _SessionMcpServerConfigStdio | _SessionMcpServerConfigStreamableHttp
2151
+
2152
+ class MethodSpec(TypedDict):
2153
+ description: str
2154
+ params: str | None
2155
+ result: str | None
2156
+
2157
+
2158
+ class NotificationSpec(TypedDict):
2159
+ description: str
2160
+ params: str | None
2161
+
2162
+
2163
+ class ErrorSpec(TypedDict):
2164
+ code: int
2165
+ kind: str
2166
+ retryable: bool
2167
+ overrideKinds: tuple[str, ...]
2168
+
2169
+
2170
+ METHODS: Final[dict[str, MethodSpec]] = {
2171
+ "account/loginCancel": {"description": "Cancels the pending login flow, abandoning the device code to server-side expiry; cancelled is false when nothing was pending (spec 28091 FR-29535-5).", "params": None, "result": "AccountLoginCancelResult"},
2172
+ "account/loginStart": {"description": "Starts a host-owned login flow: the RFC 8628 device-code flow (result carries the verification URL and user code for native rendering) or the apiKey type (stores the carried key; completes synchronously). Supersedes a pending flow (spec 28091 FR-29535-1/INV-29535-2).", "params": "AccountLoginStartParams", "result": "AccountLoginStartResult"},
2173
+ "account/logout": {"description": "Clears the stored credential (with the best-effort pre-clear session revoke) and answers the fresh projected state (spec 28091 FR-29535-6).", "params": None, "result": "AccountState"},
2174
+ "account/read": {"description": "Reads the host's projected credential state: which credential lane is in effect, an optional display label, and whether the deployment needs a credential at all (spec 28091 FR-001).", "params": None, "result": "AccountState"},
2175
+ "approval/decide": {"description": "Decides a pending approval, guarded by the current requirement id against the multi-stage race (SS5.4).", "params": "ApprovalDecideParams", "result": "ApprovalDecideResult"},
2176
+ "approval/listPending": {"description": "Reads the full pending approval and user-input payloads for a session; a lease-free fold read (SS5.7).", "params": "ApprovalListPendingParams", "result": "ApprovalListPendingResult"},
2177
+ "goal/clear": {"description": "Clears the session goal; never wakes and its ack never names a turn (tdd SS3.18, spec 14408; enrolled by #33066).", "params": "GoalClearParams", "result": "GoalCommandResult"},
2178
+ "goal/edit": {"description": "Replaces the current goal's objective under the same wake gate as goal/set (tdd SS3.18, spec 14408; enrolled by #33066).", "params": "GoalEditParams", "result": "GoalCommandResult"},
2179
+ "goal/pause": {"description": "Pauses the session goal; never wakes and its ack never names a turn (tdd SS3.18, spec 14408; enrolled by #33066).", "params": "GoalPauseParams", "result": "GoalCommandResult"},
2180
+ "goal/resume": {"description": "Resumes a paused goal under the same wake gate as goal/set (tdd SS3.18, spec 14408; enrolled by #33066).", "params": "GoalResumeParams", "result": "GoalCommandResult"},
2181
+ "goal/set": {"description": "Sets the session goal objective; wakes a goal-driving turn iff idle and the resulting goal is unfinished (tdd SS3.18, spec 14408; enrolled by #33066).", "params": "GoalSetParams", "result": "GoalCommandResult"},
2182
+ "initialize": {"description": "Opens the connection: client identification, capability requests, and the experimental opt-in; the reply carries the envelope schema version and the stable-surface fingerprint (SS1.4.1).", "params": "InitializeParams", "result": "InitializeResult"},
2183
+ "item/readOutput": {"description": "Byte-ranged read of stored full output the view truncated; works on loaded and unloaded sessions and takes no lease (SS4.7.4).", "params": "ItemReadOutputParams", "result": "ItemReadOutputResult"},
2184
+ "model/list": {"description": "Reads the catalog of models the host will accept in `session/setModel`; a query, not a command (SS3.10).", "params": "ModelListParams", "result": "ModelListResult"},
2185
+ "session/compact": {"description": "Compacts the session's conversation context; runs asynchronously, so the ack is admission only (SS3.7).", "params": "SessionCompactParams", "result": "SessionCompactResult"},
2186
+ "session/fork": {"description": "Branches a session into a new id whose log copies the source through a cut point, with durable provenance (SS2.5.3).", "params": "SessionForkParams", "result": "SessionForkResult"},
2187
+ "session/list": {"description": "Pages through stored sessions under the sessions root for history and picker UIs; read-only, never touches leases (SS2.5.4).", "params": "SessionListParams", "result": "SessionListResult"},
2188
+ "session/read": {"description": "Reads one stored session without attaching: no lease, no load, no subscription, no resume record (SS2.5.5).", "params": "SessionReadParams", "result": "SessionReadResult"},
2189
+ "session/rename": {"description": "Sets or changes the durable allocated session name through the runtime session_name command; withheld under the ephemeral profile (SS2.14.2, #27598).", "params": "SessionRenameParams", "result": "SessionRenameResult"},
2190
+ "session/resume": {"description": "Loads a stored session on this host, auto-subscribes this connection, and returns the history needed to render it (SS2.5.2).", "params": "SessionResumeParams", "result": "SessionResumeResult"},
2191
+ "session/setApprovalMode": {"description": "Selects a preconfigured approval enforcement mode mid-session; select, never create (SS5.12).", "params": "SessionSetApprovalModeParams", "result": "SessionSetApprovalModeResult"},
2192
+ "session/setModel": {"description": "Reconfigures the session's model; the selection is durable and applies to subsequent model calls (SS3.8).", "params": "SessionSetModelParams", "result": "SessionSetModelResult"},
2193
+ "session/setReasoningEffort": {"description": "Sets the session's standing reasoning-effort default; a turn carrying its own tier overrides it for that turn only (SS3.21, ADR 31255 D1).", "params": "SessionSetReasoningEffortParams", "result": "SessionSetReasoningEffortResult"},
2194
+ "session/start": {"description": "Creates a brand-new session, loads it on this host, durably records the start, and auto-subscribes this connection (SS2.5.1).", "params": "SessionStartParams", "result": "SessionStartResult"},
2195
+ "session/userShell": {"description": "Runs a user-initiated shell command in the session's workspace; capability-gated on `userShell` (SS3.9).", "params": "SessionUserShellParams", "result": "SessionUserShellResult"},
2196
+ "skill/list": {"description": "Reads the session's user-invocable skill rows — one per typed-invocable shortcut spelling, the INV-007 predicate and shared name resolution by call-through; a query, not a command (SS3.22.1).", "params": "SkillListParams", "result": "SkillListResult"},
2197
+ "subagent/close": {"description": "Owner-close a child; the terminal mapping folds per SS4.5.7 (SS3.16).", "params": "SubagentOwnerReasonParams", "result": "CommandAcceptedResult"},
2198
+ "subagent/followupTask": {"description": "Queue a follow-up task for a child; admission-only ack, the task settles on the child session's view stream (SS3.16).", "params": "SubagentInputParams", "result": "CommandAcceptedResult"},
2199
+ "subagent/interrupt": {"description": "Ask a child to yield at its next boundary; outcome folds to the parent's subagent item (SS3.16, SS4.5.7).", "params": "SubagentOwnerReasonParams", "result": "CommandAcceptedResult"},
2200
+ "subagent/readResult": {"description": "Consume a ready child result (state-changing; the content is already the subagent item's result field) (SS3.16).", "params": "SubagentTargetParams", "result": "CommandAcceptedResult"},
2201
+ "subagent/reopen": {"description": "Reopen a stopped/closed child as a durable later attempt (SS3.16).", "params": "SubagentTargetParams", "result": "CommandAcceptedResult"},
2202
+ "subagent/resume": {"description": "Resume a paused/recoverable child as a durable later attempt (SS3.16).", "params": "SubagentTargetParams", "result": "CommandAcceptedResult"},
2203
+ "subagent/sendMessage": {"description": "Queue a user note into a running child; admission-only ack, the note settles on the child session's view stream (SS3.16).", "params": "SubagentInputParams", "result": "CommandAcceptedResult"},
2204
+ "subagent/stop": {"description": "Stop a running child; outcome folds to the parent's subagent item (SS3.16, SS4.5.7).", "params": "SubagentOwnerReasonParams", "result": "CommandAcceptedResult"},
2205
+ "task/background": {"description": "Durably sends a running foreground tool task to the background; the `TaskBackgrounded` record lands before the ack and the `toolCall` item's `item/updated` folds the flip (tdd §3.13, #14411; enrolled under the #33065 T1 ruling).", "params": "TaskBackgroundParams", "result": "TaskCommandResult"},
2206
+ "task/stop": {"description": "Stops one named background task; the kill settles durably and the item folds a terminal (tdd §3.14, #14411; enrolled under the #33065 T1 ruling).", "params": "TaskStopParams", "result": "TaskCommandResult"},
2207
+ "task/stopAll": {"description": "Stops every stoppable background workload live at admission; always accepted, one item terminal folds per stopped item-visible task (tdd §3.15, #14411; enrolled under the #33065 T1 ruling).", "params": "TaskStopAllParams", "result": "TaskStopAllResult"},
2208
+ "turn/cancel": {"description": "Cancels a turn on the normal command lane, recording no priority interrupt intent (SS3.5).", "params": "TurnCancelParams", "result": "TurnCancelResult"},
2209
+ "turn/interrupt": {"description": "Stops the running turn on the runtime's priority lane, optionally pairing a durable retract intent (SS3.4).", "params": "TurnInterruptParams", "result": "TurnInterruptResult"},
2210
+ "turn/start": {"description": "Submits user input to a session; the optional disposition controls queue, steer, or replace when a turn is already running (SS3.2).", "params": "TurnStartParams", "result": "TurnStartResult"},
2211
+ "turn/steer": {"description": "Injects input into the turn the caller names, failing if that turn is no longer active (SS3.3).", "params": "TurnSteerParams", "result": "TurnSteerResult"},
2212
+ "turn/unqueue": {"description": "Reclaims a queued submit before it launches; never upgrades into a cancel once the target is running (SS3.6).", "params": "TurnUnqueueParams", "result": "TurnUnqueueResult"},
2213
+ "usage/read": {"description": "Reads the host's last-observed subscription usage window (5h-class and weekly percent blocks, tier, arrival stamp) without a model call; the usage member is omitted when nothing has been observed (ADR 32563 D2).", "params": None, "result": "UsageReadResult"},
2214
+ "userInput/answer": {"description": "Answers every question of an open user-input prompt (SS5.10.2).", "params": "UserInputAnswerParams", "result": "UserInputAnswerResult"},
2215
+ "userInput/cancel": {"description": "Declines an open user-input prompt; the tool call resolves with a cancelled result the model sees (SS5.10.2).", "params": "UserInputCancelParams", "result": "UserInputCancelResult"},
2216
+ "userInput/clarify": {"description": "Answers an open user-input prompt with a free-form clarification the model re-decides against (SS5.10.2).", "params": "UserInputClarifyParams", "result": "UserInputClarifyResult"},
2217
+ "view/page": {"description": "Cursor-paged reads of the session view, forward or backward; each result element is an unframed view notification, the nested {method, params} pair of SS4.2.1 (SS4.7.3).", "params": "ViewPageParams", "result": "ViewPageResult"},
2218
+ "view/subscribe": {"description": "Attaches this connection's live view subscription for a session at an explicit cursor, replaying `(after, head]` before any live event; the re-attach path after `view/unsubscribe` (SS4.7.1).", "params": "ViewSubscribeParams", "result": "ViewSubscribeResult"},
2219
+ "view/unsubscribe": {"description": "Removes this connection from the session's view subscription set; does not unload the session (SS4.7.2).", "params": "ViewUnsubscribeParams", "result": "ViewUnsubscribeResult"},
2220
+ "workflow/cancel": {"description": "Cancels a live workflow run; admission-only bare ack, the cancellation's truth arrives as the workflow item's view events (tdd SS3.19, spec 14410; enrolled by the #33065 sweep).", "params": "WorkflowCancelParams", "result": "WorkflowControlResult"},
2221
+ "workflow/childControl": {"description": "Skips or retries one workflow child keyed by the item's (childId, attempt) pair; admission-only bare ack (tdd SS3.20, spec 14410; enrolled by the #33065 sweep).", "params": "WorkflowChildControlParams", "result": "WorkflowControlResult"},
2222
+ }
2223
+
2224
+ NOTIFICATIONS: Final[dict[str, NotificationSpec]] = {
2225
+ "account/changed": {"description": "The host's projected credential state changed — including out-of-band changes such as a terminal `muse logout` — with the same payload shape as account/read (spec 28091 FR-002).", "params": "AccountState"},
2226
+ "account/loginCompleted": {"description": "A login flow reached a terminal outcome (granted, denied, expired, cancelled, or failed); a granted flow's account/changed follows (spec 28091 FR-29535-4; ADR 28091 D3). Never carries the device-code artifacts or any key material.", "params": "AccountLoginCompletedParams"},
2227
+ "approval/requested": {"description": "An approval opened: the fold of its durable Requested record (SS5.5.1).", "params": "ApprovalRequestParams"},
2228
+ "approval/resolved": {"description": "The first durable approval terminal landed; protected delivery (SS5.5).", "params": "ApprovalResolvedParams"},
2229
+ "approval/updated": {"description": "A non-terminal approval record changed the pending view (SS5.5.1).", "params": "ApprovalUpdatedParams"},
2230
+ "initialized": {"description": "Client-to-server notification closing the handshake; no params (SS1.4.2).", "params": None},
2231
+ "item/completed": {"description": "An item reached its terminal state: the authoritative final object (SS4.3).", "params": "ItemCompletedParams"},
2232
+ "item/delta": {"description": "Streaming append to an open item's field path (ephemeral-sourced, no sourceRange; opt-out-able) (SS4.3.1).", "params": "ItemDeltaParams"},
2233
+ "item/started": {"description": "An item opened on the transcript (SS4.3).", "params": "ItemStartedParams"},
2234
+ "item/updated": {"description": "An open item changed non-terminally: full re-emission at a higher revision (SS4.4.2).", "params": "ItemUpdatedParams"},
2235
+ "session/approvalModeChanged": {"description": "The approval enforcement mode changed: the fold of the durable reconfigure audit fact (SS5.12).", "params": "SessionApprovalModeChangedParams"},
2236
+ "session/branchChanged": {"description": "A durable workspace-branch observation landed; null branch is a detached-HEAD fact (SS4.6.4).", "params": "SessionBranchChangedParams"},
2237
+ "session/contextUsage": {"description": "A provider-reported context-occupancy fact folded to a changed (windowTokens, usedTokens, pressure) triple (SS4.6.6).", "params": "SessionContextUsageParams"},
2238
+ "session/goalChanged": {"description": "The session's goal block changed value; replace wholesale, an explicit null clears (SS4.6.2).", "params": "SessionGoalChangedParams"},
2239
+ "session/modelChanged": {"description": "A durable model selection took effect (SS4.6.1).", "params": "SessionModelChangedParams"},
2240
+ "session/modelRouteUnserved": {"description": "An accepted login credential update installed a provider that cannot serve the session's standing model route; the standing selection is unchanged and a routable session/setModel repairs it (#25603, spec 5469 Amendment 16).", "params": "SessionModelRouteUnservedParams"},
2241
+ "session/nameChanged": {"description": "A durable session-name record landed (rename or first naming): the fold of the session_name record (SS4.6.7, #27598).", "params": "SessionNameChangedParams"},
2242
+ "session/reasoningEffortChanged": {"description": "A durable session-default reasoning-effort change took effect (SS4.6.9, ADR 31255 D1).", "params": "SessionReasoningEffortChangedParams"},
2243
+ "session/statusChanged": {"description": "A loaded session's (status, attention) flipped; command-plane broadcast, cursor-stamped, not subscription-gated (SS4.6.10, ADR 31983 D2).", "params": "SessionStatusChangedParams"},
2244
+ "session/todoListChanged": {"description": "The todo list was replaced wholesale; empty items is a cleared list (SS4.6.3).", "params": "SessionTodoListChangedParams"},
2245
+ "session/tokenUsage": {"description": "A model call completed with usage: raw counters plus counted-once derivations plus session cumulative (SS4.6.5).", "params": "SessionTokenUsageParams"},
2246
+ "session/viewHealthChanged": {"description": "A loaded session's live view stream became unavailable, and why: a command-plane push delivered independent of the view subscription set when the materialized projection fails closed (ADR 32557; #32557).", "params": "SessionViewHealthChangedParams"},
2247
+ "skill/changed": {"description": "The session's user-invocable skill set changed; clients re-issue skill/list. A live host-state projection, not a view event (SS3.22.2).", "params": "SkillChangedParams"},
2248
+ "turn/completed": {"description": "Turn terminal: completed | failed | cancelled, with usage and the settled error object (SS4.5.1).", "params": "TurnCompletedParams"},
2249
+ "turn/retracted": {"description": "An interrupt-paired retract was durably accepted (SS4.5.1).", "params": "TurnRetractedParams"},
2250
+ "turn/retryScheduled": {"description": "A failing model attempt's retry is scheduled and waiting out its backoff; observable mid-turn, non-terminal (SS4.5.1, D-026).", "params": "TurnRetryScheduledParams"},
2251
+ "turn/started": {"description": "A foreground turn began running (SS4.5.1).", "params": "TurnStartedParams"},
2252
+ "turn/unqueued": {"description": "A queued submit's reclaim durably won: its pre-minted turn never runs, and no turn/started or turn/completed will follow for that turnId (SS3.6, SS4.5.1).", "params": "TurnUnqueuedParams"},
2253
+ "usage/changed": {"description": "The host's last-observed subscription usage DATA changed (window, weekly, or tier — not a stamp-only refresh), with the same payload shape as usage/read's usage member; the absent-to-present first observation emits (ADR 32563 D3).", "params": "SubscriptionUsage"},
2254
+ "userInput/requested": {"description": "A user-input prompt opened: the fold of its durable Requested record (SS5.10.1).", "params": "UserInputRequestParams"},
2255
+ "userInput/settled": {"description": "The first durable user-input settlement landed; protected delivery (SS5.10.3).", "params": "UserInputSettledParams"},
2256
+ "view/gap": {"description": "Push delivery dropped events: `(after, next)` brackets the undelivered range and delivery continues from `next` (SS4.8; spec 208 FM-001).", "params": "ViewGapParams"},
2257
+ }
2258
+
2259
+ ERRORS: Final[tuple[ErrorSpec, ...]] = (
2260
+ {"code": -32700, "kind": "parseError", "retryable": False, "overrideKinds": ()},
2261
+ {"code": -32600, "kind": "invalidRequest", "retryable": False, "overrideKinds": ("notInitialized", "alreadyInitialized",)},
2262
+ {"code": -32601, "kind": "methodNotFound", "retryable": False, "overrideKinds": ("experimentalRequired",)},
2263
+ {"code": -32602, "kind": "invalidParams", "retryable": False, "overrideKinds": ("experimentalRequired",)},
2264
+ {"code": -32603, "kind": "internal", "retryable": False, "overrideKinds": ("pageEventTooLarge", "outputResultTooLarge",)},
2265
+ {"code": -32001, "kind": "overloaded", "retryable": True, "overrideKinds": ()},
2266
+ {"code": -32002, "kind": "inputTooLarge", "retryable": False, "overrideKinds": ()},
2267
+ {"code": -32010, "kind": "capabilityRequired", "retryable": False, "overrideKinds": ()},
2268
+ {"code": -32011, "kind": "notFound", "retryable": False, "overrideKinds": ()},
2269
+ {"code": -32013, "kind": "interrupted", "retryable": False, "overrideKinds": ()},
2270
+ {"code": -32014, "kind": "cancelled", "retryable": False, "overrideKinds": ()},
2271
+ {"code": -32020, "kind": "sessionNotFound", "retryable": False, "overrideKinds": ()},
2272
+ {"code": -32021, "kind": "sessionInUse", "retryable": False, "overrideKinds": ()},
2273
+ {"code": -32022, "kind": "sessionAmbiguous", "retryable": False, "overrideKinds": ()},
2274
+ {"code": -32023, "kind": "forkBoundaryInvalid", "retryable": False, "overrideKinds": ()},
2275
+ {"code": -32024, "kind": "sessionNotLoaded", "retryable": False, "overrideKinds": ()},
2276
+ {"code": -32025, "kind": "sessionStreamMismatch", "retryable": False, "overrideKinds": ()},
2277
+ {"code": -32030, "kind": "commandRejected", "retryable": False, "overrideKinds": ()},
2278
+ {"code": -32031, "kind": "backpressured", "retryable": True, "overrideKinds": ()},
2279
+ {"code": -32032, "kind": "skillNotFound", "retryable": False, "overrideKinds": ()},
2280
+ {"code": -32040, "kind": "viewTruncated", "retryable": False, "overrideKinds": ()},
2281
+ {"code": -32041, "kind": "outputUnavailable", "retryable": False, "overrideKinds": ()},
2282
+ {"code": -32042, "kind": "boundaryPruned", "retryable": False, "overrideKinds": ("boundaryUnusable", "noBoundary",)},
2283
+ {"code": -32050, "kind": "approvalNotFound", "retryable": False, "overrideKinds": ()},
2284
+ {"code": -32051, "kind": "approvalAlreadyResolved", "retryable": False, "overrideKinds": ()},
2285
+ {"code": -32052, "kind": "approvalChoiceInvalid", "retryable": False, "overrideKinds": ()},
2286
+ {"code": -32053, "kind": "approvalRequirementStale", "retryable": False, "overrideKinds": ()},
2287
+ {"code": -32054, "kind": "approvalReviewerUnavailable", "retryable": False, "overrideKinds": ()},
2288
+ {"code": -32055, "kind": "userInputNotFound", "retryable": False, "overrideKinds": ()},
2289
+ {"code": -32056, "kind": "userInputAlreadySettled", "retryable": False, "overrideKinds": ()},
2290
+ {"code": -32057, "kind": "userInputAnswerInvalid", "retryable": False, "overrideKinds": ()},
2291
+ )
2292
+
2293
+ GRANTABLE_CAPABILITIES: Final[tuple[str, ...]] = ("userShell", "sessionMcp",)