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,2232 @@
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, stable surface. Import surface: `muse_code_msp`. The experimental surface is NOT re-exported here; import `muse_code_msp.experimental` explicitly (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:ab69549a7ebb423fce94068762da0b5ff3cdec1f8fc263dcc17248eda117f852"
11
+ SCHEMA_VERSION: Final[int] = 1
12
+ EXPERIMENTAL: Final[bool] = False
13
+ REQUIRED_HOST_VERSION: Final[str] = "1.3.0"
14
+
15
+ ApprovalAmendmentDurability = str # open enum (SS1.5.4): unknown values stay representable
16
+ APPROVAL_AMENDMENT_DURABILITY_KNOWN_VALUES: Final[tuple[str, ...]] = ("session", "localPersistent",)
17
+
18
+ ApprovalChoiceScope = str # open enum (SS1.5.4): unknown values stay representable
19
+ APPROVAL_CHOICE_SCOPE_KNOWN_VALUES: Final[tuple[str, ...]] = ("once", "session", "localPersistent",)
20
+
21
+ ApprovalDecision = str # open enum (SS1.5.4): unknown values stay representable
22
+ APPROVAL_DECISION_KNOWN_VALUES: Final[tuple[str, ...]] = ("approved", "approvedForSession", "approvedPolicyAmendment", "denied", "deniedPolicyAmendment", "timedOut", "abort",)
23
+
24
+ # 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.
25
+ ApprovalMode = Literal["allowAll", "promptUnmatched", "onRequest", "denyUnmatched"]
26
+
27
+ # Whether a mode change did anything (tdd SS5.12), mirroring `ApprovalReconfigureApplyOutcome`. Apply failures are `commandRejected`.
28
+ ApprovalModeApplyOutcome = str # open enum (SS1.5.4): unknown values stay representable
29
+ APPROVAL_MODE_APPLY_OUTCOME_KNOWN_VALUES: Final[tuple[str, ...]] = ("completed", "noop",)
30
+
31
+ # How an approval mode took effect (tdd SS5.12, the effective-mode projection's `source` vocabulary). Open.
32
+ ApprovalModeSource = str # open enum (SS1.5.4): unknown values stay representable
33
+ APPROVAL_MODE_SOURCE_KNOWN_VALUES: Final[tuple[str, ...]] = ("startup", "replay", "approvalReconfigure",)
34
+
35
+ ApprovalPersistenceStatus = str # open enum (SS1.5.4): unknown values stay representable
36
+ APPROVAL_PERSISTENCE_STATUS_KNOWN_VALUES: Final[tuple[str, ...]] = ("succeeded", "failed",)
37
+
38
+ ApprovalPolicyResult = str # open enum (SS1.5.4): unknown values stay representable
39
+ APPROVAL_POLICY_RESULT_KNOWN_VALUES: Final[tuple[str, ...]] = ("allow", "deny",)
40
+
41
+ ApprovalResolvedBy = str # open enum (SS1.5.4): unknown values stay representable
42
+ APPROVAL_RESOLVED_BY_KNOWN_VALUES: Final[tuple[str, ...]] = ("user", "policy", "llmJudge",)
43
+
44
+ # 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.
45
+ AttentionFlag = str # open enum (SS1.5.4): unknown values stay representable
46
+ ATTENTION_FLAG_KNOWN_VALUES: Final[tuple[str, ...]] = ("approvalPending", "inputPending",)
47
+
48
+ # Who durably backgrounded a task (tdd SS4.5.5, `TaskBackgroundedInitiator`). Open — runtime vocabulary.
49
+ BackgroundInitiator = str # open enum (SS1.5.4): unknown values stay representable
50
+ BACKGROUND_INITIATOR_KNOWN_VALUES: Final[tuple[str, ...]] = ("user", "timeout",)
51
+
52
+ # 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.
53
+ CapabilityName = str # open enum (SS1.5.4): unknown values stay representable
54
+ CAPABILITY_NAME_KNOWN_VALUES: Final[tuple[str, ...]] = ("userShell", "sessionMcp",)
55
+
56
+ # 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.
57
+ CommandAckStatus = Literal["accepted", "noop"]
58
+
59
+ # 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).
60
+ CommandStatus = str # open enum (SS1.5.4): unknown values stay representable
61
+ COMMAND_STATUS_KNOWN_VALUES: Final[tuple[str, ...]] = ("accepted",)
62
+
63
+ # `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.
64
+ CompactStatus = str # open enum (SS1.5.4): unknown values stay representable
65
+ COMPACT_STATUS_KNOWN_VALUES: Final[tuple[str, ...]] = ("accepted", "noop",)
66
+
67
+ # Compaction outcome (tdd SS4.5.10, the SS3.7 vocabulary). Open.
68
+ CompactionOutcome = str # open enum (SS1.5.4): unknown values stay representable
69
+ COMPACTION_OUTCOME_KNOWN_VALUES: Final[tuple[str, ...]] = ("compacted", "noop", "failed", "cancelled",)
70
+
71
+ # What initiated a compaction (tdd SS4.5.10). Open.
72
+ CompactionTrigger = str # open enum (SS1.5.4): unknown values stay representable
73
+ COMPACTION_TRIGGER_KNOWN_VALUES: Final[tuple[str, ...]] = ("manual", "auto",)
74
+
75
+ # Context pressure level (tdd SS4.6.6): hard threshold first, both inclusive `>=`. Open.
76
+ ContextPressureLevel = str # open enum (SS1.5.4): unknown values stay representable
77
+ CONTEXT_PRESSURE_LEVEL_KNOWN_VALUES: Final[tuple[str, ...]] = ("normal", "warning", "blocked",)
78
+
79
+ # 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.
80
+ ErrorKind = str # open enum (SS1.5.4): unknown values stay representable
81
+ 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",)
82
+
83
+ # 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".
84
+ HistoryMode = str # open enum (SS1.5.4): unknown values stay representable
85
+ HISTORY_MODE_KNOWN_VALUES: Final[tuple[str, ...]] = ("anchoredSnapshot", "inline", "snapshot", "none",)
86
+
87
+ # 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).
88
+ HistoryNoneReason = str # open enum (SS1.5.4): unknown values stay representable
89
+ HISTORY_NONE_REASON_KNOWN_VALUES: Final[tuple[str, ...]] = ("excluded", "cursorSuffix", "historyBudget", "projectionUnavailable", "projectionReadLimit",)
90
+
91
+ # 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.
92
+ HistoryPreference = Literal["auto", "inline", "snapshot", "anchored"]
93
+
94
+ # 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.
95
+ IfBusy = Literal["queue", "steer", "replace"]
96
+
97
+ # 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).
98
+ ItemKind = str # open enum (SS1.5.4): unknown values stay representable
99
+ ITEM_KIND_KNOWN_VALUES: Final[tuple[str, ...]] = ("userMessage", "agentMessage", "reasoning", "toolCall", "userShell", "subagent", "workflow", "reminderChild", "compaction",)
100
+
101
+ # 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.
102
+ ItemReadOutputEncoding = Literal["utf8", "base64"]
103
+
104
+ # Item status (tdd SS4.4.1). Open; terminal = anything other than `"inProgress"`, and unknown values are terminal-unknown, rendered generically.
105
+ ItemStatus = str # open enum (SS1.5.4): unknown values stay representable
106
+ ITEM_STATUS_KNOWN_VALUES: Final[tuple[str, ...]] = ("inProgress", "completed", "failed", "cancelled", "rejected", "timedOut",)
107
+
108
+ # The literal `"2.0"` every frame carries (SS1.2).
109
+ JsonRpcVersion = Literal["2.0"]
110
+
111
+ # Where a model catalog came from (tdd SS3.10). **Open**: an unrecognized value is an unknown source, not an error.
112
+ ModelCatalogSource = str # open enum (SS1.5.4): unknown values stay representable
113
+ MODEL_CATALOG_SOURCE_KNOWN_VALUES: Final[tuple[str, ...]] = ("providerCatalog", "fakeCatalog", "unresolvedCatalog", "bundledCatalog", "configCatalog",)
114
+
115
+ # What drove a model selection (tdd SS4.6.1). Open.
116
+ ModelChangeSource = str # open enum (SS1.5.4): unknown values stay representable
117
+ MODEL_CHANGE_SOURCE_KNOWN_VALUES: Final[tuple[str, ...]] = ("user", "default", "policy",)
118
+
119
+ # Whether a stored output's bytes are servable (tdd SS4.5.5). Open — durable runtime vocabulary may grow additively.
120
+ OutputRefAvailability = str # open enum (SS1.5.4): unknown values stay representable
121
+ OUTPUT_REF_AVAILABILITY_KNOWN_VALUES: Final[tuple[str, ...]] = ("available", "missing", "unsupported", "accessFailed",)
122
+
123
+ # The `pendingRequests` discriminator (tdd SS2.5.2). Open enum, v1 values `approval` and `userInput`.
124
+ PendingRequestKind = str # open enum (SS1.5.4): unknown values stay representable
125
+ PENDING_REQUEST_KIND_KNOWN_VALUES: Final[tuple[str, ...]] = ("approval", "userInput",)
126
+
127
+ # 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).
128
+ PlatformFamily = Literal["unix", "windows"]
129
+
130
+ # The server's operating system (SS1.4.1). Closed, for the same reason as [`PlatformFamily`].
131
+ PlatformOs = Literal["macos", "linux", "windows"]
132
+
133
+ # 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".
134
+ ReasoningEffort = Literal["none", "minimal", "low", "medium", "high", "xhigh", "max", "ultra"]
135
+
136
+ # What drove a reasoning-effort default change (tdd SS4.6.9). Open; v1's only producer is `user` (an accepted `session/setReasoningEffort`).
137
+ ReasoningEffortChangeSource = str # open enum (SS1.5.4): unknown values stay representable
138
+ REASONING_EFFORT_CHANGE_SOURCE_KNOWN_VALUES: Final[tuple[str, ...]] = ("user", "default", "policy",)
139
+
140
+ # A request id (SS1.3): client-chosen string or integer. `1` and `"1"` do not compare equal; each direction owns its own id space.
141
+ RequestId = int | str
142
+
143
+ # 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.
144
+ SessionDurability = str # open enum (SS1.5.4): unknown values stay representable
145
+ SESSION_DURABILITY_KNOWN_VALUES: Final[tuple[str, ...]] = ("durable", "ephemeral",)
146
+
147
+ # Startup failure posture for a session MCP server.
148
+ SessionMcpServerMode = Literal["required", "optional"]
149
+
150
+ # Stdio framing choices exposed by session MCP configuration.
151
+ SessionMcpStdioFraming = Literal["auto", "contentLength", "lineDelimitedJson"]
152
+
153
+ # A session's load state (tdd SS2.4).
154
+ SessionStatus = str # open enum (SS1.5.4): unknown values stay representable
155
+ SESSION_STATUS_KNOWN_VALUES: Final[tuple[str, ...]] = ("notLoaded", "idle", "running",)
156
+
157
+ # 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.
158
+ SessionViewHealth = str # open enum (SS1.5.4): unknown values stay representable
159
+ SESSION_VIEW_HEALTH_KNOWN_VALUES: Final[tuple[str, ...]] = ("unavailable",)
160
+
161
+ # 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.
162
+ SkillSource = str # open enum (SS1.5.4): unknown values stay representable
163
+ SKILL_SOURCE_KNOWN_VALUES: Final[tuple[str, ...]] = ("bundled", "user", "project", "plugin",)
164
+
165
+ # Subagent control status (tdd SS4.5.7, camelCased `SubagentControlStatus`). Open; the generic item `status` is the terminal authority.
166
+ SubagentControlStatus = str # open enum (SS1.5.4): unknown values stay representable
167
+ SUBAGENT_CONTROL_STATUS_KNOWN_VALUES: Final[tuple[str, ...]] = ("accepted", "starting", "running", "resultReady", "closing", "closed", "recoveryPending", "manualReconciliation",)
168
+
169
+ # Todo status (tdd SS4.6.3): closed in the runtime, wire-open.
170
+ TodoStatus = str # open enum (SS1.5.4): unknown values stay representable
171
+ TODO_STATUS_KNOWN_VALUES: Final[tuple[str, ...]] = ("pending", "inProgress", "completed", "cancelled",)
172
+
173
+ # Turn failure classes (tdd SS4.5.1, `TerminalErrorKind` plus the model-task failure class). Open.
174
+ TurnErrorKind = str # open enum (SS1.5.4): unknown values stay representable
175
+ TURN_ERROR_KIND_KNOWN_VALUES: Final[tuple[str, ...]] = ("stepLimit", "configError", "projectionError", "logError", "workflowLaunchError", "environmentError", "modelError", "launchError", "authRequired",)
176
+
177
+ # The `type` discriminator of a turn input part (tdd SS3.2). Closed: an unknown part type is `invalidParams` (tdd SS3.1.2).
178
+ TurnInputPartType = Literal["text", "image", "skill"]
179
+
180
+ # 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.
181
+ TurnStartDisposition = str # open enum (SS1.5.4): unknown values stay representable
182
+ TURN_START_DISPOSITION_KNOWN_VALUES: Final[tuple[str, ...]] = ("started", "queued", "steered",)
183
+
184
+ # Turn terminal vocabulary (tdd SS4.5.1): exactly the runtime's `RunTerminalKind` — closed in the runtime, wire-open for evolution.
185
+ TurnTerminal = str # open enum (SS1.5.4): unknown values stay representable
186
+ TURN_TERMINAL_KNOWN_VALUES: Final[tuple[str, ...]] = ("completed", "failed", "cancelled",)
187
+
188
+ UserInputOutcome = str # open enum (SS1.5.4): unknown values stay representable
189
+ USER_INPUT_OUTCOME_KNOWN_VALUES: Final[tuple[str, ...]] = ("answered", "cancelled", "interrupted", "clarified", "timedOut", "aborted",)
190
+
191
+ UserInputSelectionMode = Literal["single", "multiple"]
192
+
193
+ # Version-control system of a branch observation (tdd SS4.6.4). Open.
194
+ Vcs = str # open enum (SS1.5.4): unknown values stay representable
195
+ VCS_KNOWN_VALUES: Final[tuple[str, ...]] = ("git", "sapling",)
196
+
197
+ # The `view/page` request-mode anchor (tdd SS4.7.3). Declared **open**: the tdd spells it "open string enum, v1 value `latestCompaction`".
198
+ ViewPageAnchor = str # open enum (SS1.5.4): unknown values stay representable
199
+ VIEW_PAGE_ANCHOR_KNOWN_VALUES: Final[tuple[str, ...]] = ("latestCompaction",)
200
+
201
+ # The `view/page` paging direction (tdd SS4.7.3). Closed: the tdd spells exactly two values and a third would change the paging contract.
202
+ ViewPageDirection = Literal["forward", "backward"]
203
+
204
+ # Which control to apply to the child's current attempt (tdd SS3.20). Closed on the wire: an unknown value is `-32602 invalidParams`.
205
+ WorkflowChildAction = Literal["skip", "retry"]
206
+
207
+ class ApprovalAmendment(TypedDict):
208
+ durability: ApprovalAmendmentDurability
209
+ rulePreview: str
210
+
211
+
212
+ class _ApprovalChangeBase(TypedDict):
213
+ kind: str
214
+
215
+
216
+ class ApprovalChange(_ApprovalChangeBase, total=False):
217
+ choiceId: str
218
+ decision: ApprovalDecision
219
+ executable: bool
220
+ reason: str
221
+ reparsed: bool
222
+ requirementId: ApprovalRequirementRef
223
+ status: ApprovalPersistenceStatus
224
+
225
+
226
+ class _ApprovalChoiceBase(TypedDict):
227
+ choiceId: str
228
+ decision: ApprovalDecision
229
+ label: str
230
+ scope: ApprovalChoiceScope
231
+
232
+
233
+ class ApprovalChoice(_ApprovalChoiceBase, total=False):
234
+ acceptsFeedback: bool
235
+ rulePreview: str
236
+
237
+
238
+ class _ApprovalDecideParamsBase(TypedDict):
239
+ approvalId: str
240
+ choiceId: str
241
+ commandId: str
242
+ requirementId: ApprovalRequirementRef
243
+ sessionId: str
244
+
245
+
246
+ class ApprovalDecideParams(_ApprovalDecideParamsBase, total=False):
247
+ """`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."""
248
+
249
+ feedback: str | None
250
+
251
+
252
+ class ApprovalDecideResult(TypedDict):
253
+ """`approval/decide` result (tdd SS5.4). Admission-ack rules still apply: the authoritative outcome is `approval/resolved` / `approval/updated` on the view stream."""
254
+
255
+ approvalId: str
256
+ commandId: str
257
+ status: CommandStatus
258
+ terminal: bool
259
+
260
+
261
+ class ApprovalListPendingParams(TypedDict):
262
+ """`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."""
263
+
264
+ sessionId: str
265
+
266
+
267
+ class ApprovalListPendingResult(TypedDict):
268
+ """`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."""
269
+
270
+ approvals: list[ApprovalRequestParams]
271
+ userInputs: list[UserInputRequestParams]
272
+
273
+
274
+ class _ApprovalOriginBase(TypedDict):
275
+ kind: str
276
+
277
+
278
+ class ApprovalOrigin(_ApprovalOriginBase, total=False):
279
+ command: str
280
+ url: str
281
+
282
+
283
+ class ApprovalRequestParams(TypedDict):
284
+ """Full params shared by `approval/request` and `approval/requested`."""
285
+
286
+ approvalId: str
287
+ availableChoices: list[ApprovalChoice]
288
+ currentRequirementId: ApprovalRequirementRef
289
+ itemId: str
290
+ judgeEscalated: bool
291
+ protectedWrite: bool
292
+ rawArgs: str
293
+ sessionId: str
294
+ sourceRange: SourceRange
295
+ subject: ApprovalSubject
296
+ taskId: str
297
+ toolCallId: str
298
+ toolName: str
299
+ turnId: str
300
+ viewCursor: str
301
+
302
+
303
+ class ApprovalRequirementRef(TypedDict):
304
+ """Approval-stage token carried in SS5 params and stale-requirement errors."""
305
+
306
+ approvalId: str
307
+ sourceIndex: int
308
+
309
+
310
+ class ApprovalResolutionSummary(TypedDict):
311
+ """Winning terminal returned to a losing `approval/decide` command."""
312
+
313
+ decision: str
314
+ resolvedBy: str
315
+ viewCursor: str
316
+
317
+
318
+ class _ApprovalResolvedParamsBase(TypedDict):
319
+ approvalId: str
320
+ decision: ApprovalDecision
321
+ itemId: str
322
+ policyResult: ApprovalPolicyResult
323
+ resolvedBy: ApprovalResolvedBy
324
+ sessionId: str
325
+ sourceRange: SourceRange
326
+ stageEvidence: list[ApprovalStageEvidence]
327
+ turnId: str
328
+ viewCursor: str
329
+
330
+
331
+ class ApprovalResolvedParams(_ApprovalResolvedParamsBase, total=False):
332
+ """`approval/resolved` params: the first durable terminal decision."""
333
+
334
+ amendment: ApprovalAmendment
335
+ decidedByCommandId: str
336
+
337
+
338
+ class _ApprovalStageBase(TypedDict):
339
+ argv: list[str]
340
+ argvComplete: bool
341
+ position: int
342
+ requirementId: ApprovalRequirementRef
343
+ resolution: ApprovalStageResolution
344
+ totalStages: int
345
+
346
+
347
+ class ApprovalStage(_ApprovalStageBase, total=False):
348
+ suggestedPrefix: ApprovalSuggestedPrefix
349
+
350
+
351
+ class ApprovalStageEvidence(TypedDict):
352
+ argv: list[str]
353
+ position: int
354
+ requirementId: ApprovalRequirementRef
355
+ resolution: ApprovalStageResolution
356
+ totalStages: int
357
+
358
+
359
+ class _ApprovalStageResolutionBase(TypedDict):
360
+ kind: str
361
+
362
+
363
+ class ApprovalStageResolution(_ApprovalStageResolutionBase, total=False):
364
+ argvPrefix: list[str]
365
+ diagnostic: str
366
+
367
+
368
+ class _ApprovalSubjectBase(TypedDict):
369
+ kind: str
370
+
371
+
372
+ class ApprovalSubject(_ApprovalSubjectBase, total=False):
373
+ """Open approval subject union. Unknown kinds are rendered generically and never auto-approved by clients (tdd SS5.2)."""
374
+
375
+ access: str
376
+ command: str
377
+ host: str
378
+ origin: ApprovalOrigin
379
+ path: str
380
+ port: int
381
+ protocol: str
382
+ stages: list[ApprovalStage]
383
+ target: str
384
+ toolName: str
385
+ workspaceRoot: str
386
+
387
+
388
+ class ApprovalSuggestedPrefix(TypedDict):
389
+ argvPrefix: list[str]
390
+ label: str
391
+
392
+
393
+ class ApprovalUpdatedParams(TypedDict):
394
+ """`approval/updated` params: the refreshed pending view plus one change."""
395
+
396
+ approvalId: str
397
+ availableChoices: list[ApprovalChoice]
398
+ change: ApprovalChange
399
+ currentRequirementId: ApprovalRequirementRef
400
+ sessionId: str
401
+ sourceRange: SourceRange
402
+ subject: ApprovalSubject
403
+ viewCursor: str
404
+
405
+
406
+ class _BranchStateBase(TypedDict):
407
+ branch: str | None
408
+ workspaceRoot: str
409
+
410
+
411
+ class BranchState(_BranchStateBase, total=False):
412
+ """The latest branch observation in the snapshot (tdd SS4.6.4, SS4.9.1)."""
413
+
414
+ vcs: Vcs
415
+
416
+
417
+ class ClientCapabilities(TypedDict, total=False):
418
+ """The client's requested capability posture (SS1.4.1). Every member defaults; an absent `capabilities` object means all defaults."""
419
+
420
+ experimentalApi: bool
421
+ optOutNotificationMethods: list[str]
422
+ requestedCapabilities: list[str]
423
+ userInputDialogs: bool
424
+
425
+
426
+ class _ClientInfoBase(TypedDict):
427
+ name: str
428
+ version: str
429
+
430
+
431
+ class ClientInfo(_ClientInfoBase, total=False):
432
+ """Client identification inside `initialize` params (SS1.4.1). Diagnostics and telemetry attribution only; never an authority claim (SS1.10)."""
433
+
434
+ title: str
435
+
436
+
437
+ class CommandAcceptedResult(TypedDict):
438
+ """The uniform SS3.1.2 command acknowledgement: admission only, never an outcome. `session/compact` alone may answer `\"noop\"`; every other command answers `\"accepted\"`."""
439
+
440
+ commandId: str
441
+ status: CommandAckStatus
442
+
443
+
444
+ class _ContextUsageBase(TypedDict):
445
+ pressure: ContextPressureLevel
446
+ usedTokens: int
447
+
448
+
449
+ class ContextUsage(_ContextUsageBase, total=False):
450
+ """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)."""
451
+
452
+ windowTokens: int
453
+
454
+
455
+ class CumulativeTokenUsage(TypedDict):
456
+ """Session running totals of counted-once usage (tdd SS4.6.5)."""
457
+
458
+ outputTokens: int
459
+ promptTokens: int
460
+ totalTokens: int
461
+
462
+
463
+ class EffectiveApprovalModeState(TypedDict):
464
+ """The effective approval-mode projection (`EffectiveApprovalModeState`, tdd SS5.12): the same object `session/setApprovalMode` returns as `effectiveMode` and the `Session` object carries as `approvalMode`."""
465
+
466
+ lastCommandId: str | None
467
+ mode: ApprovalMode
468
+ source: ApprovalModeSource
469
+
470
+
471
+ class EffectiveModel(TypedDict):
472
+ """The latest effective-model fact in the snapshot (tdd SS4.9.1)."""
473
+
474
+ modelId: str
475
+ providerId: str | None
476
+ source: ModelChangeSource
477
+
478
+
479
+ class _ErrorDataBase(TypedDict):
480
+ kind: ErrorKind
481
+
482
+
483
+ class ErrorData(_ErrorDataBase, total=False):
484
+ """The optional `error.data` object (SS1.6). All members additive-optional; `kind` is always present when `data` is."""
485
+
486
+ alignedNextOffset: int
487
+ anchor: str | None
488
+ approvalId: str
489
+ availability: str
490
+ capability: CapabilityName
491
+ capacity: int
492
+ choiceId: str
493
+ commandId: str
494
+ currentRequirementId: ApprovalRequirementRef
495
+ descriptor: str
496
+ details: dict[str, Any]
497
+ earliestCursor: str | None
498
+ itemId: str
499
+ lastTurnId: str
500
+ latestBoundaryCursor: str | None
501
+ limitBytes: int
502
+ outputRef: str
503
+ paths: list[str]
504
+ reason: str
505
+ resolution: ApprovalResolutionSummary
506
+ retryable: bool
507
+ selector: str
508
+ sessionId: str
509
+ settlement: UserInputSettlementSummary
510
+ userInputId: str
511
+ viewCursor: str
512
+
513
+
514
+ class _ErrorObjectBase(TypedDict):
515
+ code: int
516
+ message: str
517
+
518
+
519
+ class ErrorObject(_ErrorObjectBase, total=False):
520
+ """The `error` member of an error response (SS1.2 §2.4)."""
521
+
522
+ data: ErrorData
523
+
524
+
525
+ class ErrorResponse(TypedDict):
526
+ """An error response frame (SS1.2 §2.4). Exactly one of `result` or `error` appears on a response; this type is the `error` half."""
527
+
528
+ error: ErrorObject
529
+ id: RequestId | None
530
+ jsonrpc: JsonRpcVersion
531
+
532
+
533
+ class ForkCutPoint(TypedDict):
534
+ """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."""
535
+
536
+ lastTurnId: str
537
+
538
+
539
+ class ForkProvenance(TypedDict):
540
+ """Fork provenance folded from the durable `session.fork.created` record (`ForkProvenance`, tdd SS2.4)."""
541
+
542
+ commandId: str
543
+ cutCursor: str
544
+ cutExplicit: bool
545
+ sessionId: str
546
+
547
+
548
+ class _GoalBase(TypedDict):
549
+ objective: str
550
+ percentComplete: int
551
+ status: str
552
+
553
+
554
+ class Goal(_GoalBase, total=False):
555
+ """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."""
556
+
557
+ currentWork: str
558
+ nextWork: str
559
+
560
+
561
+ class GoalClearParams(TypedDict):
562
+ """`goal/clear` params (tdd SS3.18). An `objective` here is an unknown field and rejects `-32602 invalidParams` — the bare verbs carry exactly this pair."""
563
+
564
+ commandId: str
565
+ sessionId: str
566
+
567
+
568
+ class _GoalCommandResultBase(TypedDict):
569
+ commandId: str
570
+ status: CommandStatus
571
+
572
+
573
+ class GoalCommandResult(_GoalCommandResultBase, total=False):
574
+ """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."""
575
+
576
+ turnId: str
577
+
578
+
579
+ class GoalEditParams(TypedDict):
580
+ """`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."""
581
+
582
+ commandId: str
583
+ objective: str
584
+ sessionId: str
585
+
586
+
587
+ class GoalPauseParams(TypedDict):
588
+ """`goal/pause` params (tdd SS3.18); shape as `goal/clear`."""
589
+
590
+ commandId: str
591
+ sessionId: str
592
+
593
+
594
+ class GoalResumeParams(TypedDict):
595
+ """`goal/resume` params (tdd SS3.18); shape as `goal/clear`."""
596
+
597
+ commandId: str
598
+ sessionId: str
599
+
600
+
601
+ class GoalSetParams(TypedDict):
602
+ """`goal/set` params (tdd SS3.18): set the session's goal objective."""
603
+
604
+ commandId: str
605
+ objective: str
606
+ sessionId: str
607
+
608
+
609
+ class _InitializeParamsBase(TypedDict):
610
+ clientInfo: ClientInfo
611
+
612
+
613
+ class InitializeParams(_InitializeParamsBase, total=False):
614
+ """`initialize` request params (SS1.4.1)."""
615
+
616
+ capabilities: ClientCapabilities
617
+
618
+
619
+ class _InitializeResultBase(TypedDict):
620
+ experimentalApi: bool
621
+ grantedCapabilities: list[CapabilityName]
622
+ museHome: str
623
+ platformFamily: PlatformFamily
624
+ platformOs: PlatformOs
625
+ schema: SchemaInfo
626
+ serverInfo: ServerInfo
627
+ userAgent: str
628
+
629
+
630
+ class InitializeResult(_InitializeResultBase, total=False):
631
+ """The `initialize` result (SS1.4.1)."""
632
+
633
+ sessionDurability: SessionDurability
634
+
635
+
636
+ class _ItemBase(TypedDict):
637
+ itemId: str
638
+ kind: ItemKind
639
+ revision: int
640
+ status: ItemStatus
641
+
642
+
643
+ class Item(_ItemBase, total=False):
644
+ """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."""
645
+
646
+ agentPath: str
647
+ approvalId: str
648
+ args: str
649
+ attachments: list[MessageAttachment]
650
+ background: bool
651
+ backgroundInitiator: BackgroundInitiator
652
+ callId: str
653
+ childSessionId: str
654
+ childSessionLogPath: str
655
+ children: list[WorkflowChild]
656
+ commandId: str
657
+ commandText: str
658
+ controlStatus: SubagentControlStatus
659
+ depth: int
660
+ displayText: str
661
+ durationMs: int
662
+ entryId: str
663
+ exitCode: int
664
+ exitSignal: int
665
+ failureKind: str
666
+ failureReason: str
667
+ fallbackText: str
668
+ generationId: int
669
+ message: str
670
+ modelVisibleContent: list[ModelVisibleContent]
671
+ objective: str
672
+ outcome: CompactionOutcome
673
+ outputRef: OutputRef
674
+ patchRef: OutputRef
675
+ patchSummary: PatchSummary
676
+ providerItemId: str
677
+ reason: str
678
+ recordedAt: str
679
+ reminderAgentId: str
680
+ result: SubagentResult
681
+ resumeFromRunId: str
682
+ retracted: bool
683
+ role: str
684
+ scriptId: str
685
+ steered: bool
686
+ strategyId: str
687
+ subagentId: str
688
+ summarizedThrough: str
689
+ summary: list[str]
690
+ taskId: str
691
+ text: str
692
+ tokensAfter: int
693
+ tokensBefore: int
694
+ tool: str
695
+ trigger: CompactionTrigger
696
+ triggerSource: str
697
+ truncated: bool
698
+ turnId: str | None
699
+ usage: TokenUsage
700
+ visibleOutput: str
701
+ workflowRunId: str
702
+
703
+
704
+ class ItemCompletedParams(TypedDict):
705
+ """`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)."""
706
+
707
+ item: Item
708
+ sessionId: str
709
+ sourceRange: SourceRange
710
+ viewCursor: str
711
+
712
+
713
+ class _ItemDeltaParamsBase(TypedDict):
714
+ delta: str
715
+ itemId: str
716
+ sessionId: str
717
+ viewCursor: str
718
+
719
+
720
+ class ItemDeltaParams(_ItemDeltaParamsBase, total=False):
721
+ """`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`."""
722
+
723
+ field: str
724
+
725
+
726
+ class _ItemReadOutputParamsBase(TypedDict):
727
+ itemId: str
728
+ outputRef: str
729
+ sessionId: str
730
+
731
+
732
+ class ItemReadOutputParams(_ItemReadOutputParamsBase, total=False):
733
+ """`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."""
734
+
735
+ lengthBytes: int
736
+ offsetBytes: int
737
+
738
+
739
+ class ItemReadOutputResult(TypedDict):
740
+ """`item/readOutput` result (tdd SS4.7.4): one stored-byte page."""
741
+
742
+ byteLen: int
743
+ content: str
744
+ encoding: ItemReadOutputEncoding
745
+ eof: bool
746
+ mediaType: str
747
+ offsetBytes: int
748
+
749
+
750
+ class _ItemStartedParamsBase(TypedDict):
751
+ item: Item
752
+ sessionId: str
753
+ viewCursor: str
754
+
755
+
756
+ class ItemStartedParams(_ItemStartedParamsBase, total=False):
757
+ """`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)."""
758
+
759
+ sourceRange: SourceRange
760
+
761
+
762
+ class ItemUpdatedParams(TypedDict):
763
+ """`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)."""
764
+
765
+ item: Item
766
+ sessionId: str
767
+ sourceRange: SourceRange
768
+ viewCursor: str
769
+
770
+
771
+ class _MessageAttachmentBase(TypedDict):
772
+ mediaType: str
773
+ type: str
774
+
775
+
776
+ class MessageAttachment(_MessageAttachmentBase, total=False):
777
+ """`userMessage` image attachment metadata (tdd SS4.5.2): metadata only — the durable bytes live in the log and are reachable on the raw altitude."""
778
+
779
+ height: int
780
+ width: int
781
+
782
+
783
+ class ModelCatalogEntry(TypedDict):
784
+ """One visible catalog row (tdd SS3.10). Catalog rows marked hidden never reach the wire, so a client cannot select one."""
785
+
786
+ contextLimit: int | None
787
+ cost: ModelCost | None
788
+ description: str | None
789
+ displayLabel: str
790
+ isActive: bool
791
+ isDefault: bool
792
+ modelId: str
793
+ outputLimit: int | None
794
+ profileId: str | None
795
+ providerId: str
796
+ releaseDate: str | None
797
+
798
+
799
+ class ModelCost(TypedDict):
800
+ """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."""
801
+
802
+ cached: str
803
+ currency: str | None
804
+ input: str
805
+ output: str
806
+
807
+
808
+ class ModelListParams(TypedDict, total=False):
809
+ """`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."""
810
+
811
+ sessionId: str
812
+
813
+
814
+ class ModelListResult(TypedDict):
815
+ """`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."""
816
+
817
+ models: list[ModelCatalogEntry]
818
+ profileId: str | None
819
+ providerId: str
820
+ source: ModelCatalogSource
821
+
822
+
823
+ class _ModelSelectionBase(TypedDict):
824
+ modelId: str
825
+
826
+
827
+ class ModelSelection(_ModelSelectionBase, total=False):
828
+ """A model selection (tdd SS3.8). Empty strings are normalized to absent."""
829
+
830
+ displayLabel: str
831
+ profileId: str | None
832
+ providerId: str
833
+
834
+
835
+ class _ModelVisibleContentBase(TypedDict):
836
+ mediaType: str
837
+ path: str
838
+ sourceToolName: str
839
+ type: str
840
+
841
+
842
+ class ModelVisibleContent(_ModelVisibleContentBase, total=False):
843
+ """Rich content the model saw beyond text (tdd SS4.5.5, `ModelVisibleToolContent`): metadata only — fetch bytes via `item/readOutput` when an `outputRef` exists."""
844
+
845
+ height: int
846
+ width: int
847
+
848
+
849
+ class _NotificationBase(TypedDict):
850
+ jsonrpc: JsonRpcVersion
851
+ method: str
852
+
853
+
854
+ class Notification(_NotificationBase, total=False):
855
+ """A notification frame, either direction (SS1.2 §2.2). No `id`; a notification is never answered."""
856
+
857
+ emittedAtMs: int
858
+ params: dict[str, Any]
859
+
860
+
861
+ class _OutputRefBase(TypedDict):
862
+ availability: OutputRefAvailability
863
+ byteLen: int
864
+ id: str
865
+ kind: str
866
+ uri: str
867
+
868
+
869
+ class OutputRef(_OutputRefBase, total=False):
870
+ """Stored-output reference (tdd SS4.5.5): the camelCased fold of the durable `ToolOutputRef`. The fetch path is `item/readOutput` (#208)."""
871
+
872
+ digest: str
873
+ mediaType: str
874
+ path: str
875
+
876
+
877
+ class PatchSummary(TypedDict):
878
+ """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`."""
879
+
880
+ added: int
881
+ files: int
882
+ removed: int
883
+
884
+
885
+ class _PendingApprovalPointerBase(TypedDict):
886
+ approvalId: str
887
+ viewCursor: str
888
+
889
+
890
+ class PendingApprovalPointer(_PendingApprovalPointerBase, total=False):
891
+ """A pending approval in the snapshot: the SS2.5.2 pointer shape plus the gated `itemId` when one exists (tdd SS4.9.1)."""
892
+
893
+ itemId: str
894
+
895
+
896
+ class _PendingRequestPointerBase(TypedDict):
897
+ kind: PendingRequestKind
898
+ viewCursor: str
899
+
900
+
901
+ class PendingRequestPointer(_PendingRequestPointerBase, total=False):
902
+ """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."""
903
+
904
+ approvalId: str
905
+ userInputId: str
906
+
907
+
908
+ class _PendingUserInputPointerBase(TypedDict):
909
+ userInputId: str
910
+ viewCursor: str
911
+
912
+
913
+ class PendingUserInputPointer(_PendingUserInputPointerBase, total=False):
914
+ """A pending user-input prompt in the snapshot (tdd SS4.9.1, SS5.10)."""
915
+
916
+ itemId: str
917
+
918
+
919
+ class ReasoningEffortState(TypedDict):
920
+ """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."""
921
+
922
+ reasoningEffort: ReasoningEffort
923
+ source: ReasoningEffortChangeSource
924
+
925
+
926
+ class RecordPosition(TypedDict):
927
+ """One end of a [`SourceRange`]: a record's event id and its sequence number within the stream (tdd SS4.2)."""
928
+
929
+ id: str
930
+ sequence: int
931
+
932
+
933
+ class _RequestBase(TypedDict):
934
+ id: RequestId
935
+ jsonrpc: JsonRpcVersion
936
+ method: str
937
+
938
+
939
+ class Request(_RequestBase, total=False):
940
+ """A request frame, either direction (SS1.2 §2.1)."""
941
+
942
+ params: dict[str, Any]
943
+ trace: TraceContext
944
+
945
+
946
+ class RequestReceipt(TypedDict):
947
+ """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."""
948
+
949
+ pass
950
+
951
+
952
+ class SchemaInfo(TypedDict):
953
+ """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)."""
954
+
955
+ fingerprint: str
956
+ version: int
957
+
958
+
959
+ class ServerInfo(TypedDict):
960
+ """Server identification inside [`InitializeResult`]."""
961
+
962
+ name: str
963
+ version: str
964
+
965
+
966
+ class _SessionBase(TypedDict):
967
+ activeTurnId: str | None
968
+ createdAt: str
969
+ forkedFrom: ForkProvenance | None
970
+ modelId: str | None
971
+ path: str
972
+ providerId: str | None
973
+ sessionId: str
974
+ status: SessionStatus
975
+ turnCount: int
976
+ updatedAt: str
977
+ workspaceRoot: str | None
978
+
979
+
980
+ class Session(_SessionBase, total=False):
981
+ """The session object every lifecycle method returns or lists (tdd SS2.4). Additive-optional evolution applies: clients must ignore unknown fields."""
982
+
983
+ approvalMode: EffectiveApprovalModeState
984
+ attention: list[AttentionFlag]
985
+ branch: str
986
+ firstUserPrompt: str
987
+ lastActivityAt: str
988
+ name: str
989
+ title: str
990
+
991
+
992
+ class SessionApprovalModeChangedParams(TypedDict):
993
+ """`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."""
994
+
995
+ clientName: str
996
+ commandId: str
997
+ mode: ApprovalMode
998
+ sessionId: str
999
+ source: ApprovalModeSource
1000
+ sourceRange: SourceRange
1001
+ viewCursor: str
1002
+
1003
+
1004
+ class _SessionBranchChangedParamsBase(TypedDict):
1005
+ sessionId: str
1006
+ sourceRange: SourceRange
1007
+ viewCursor: str
1008
+ workspaceRoot: str
1009
+
1010
+
1011
+ class SessionBranchChangedParams(_SessionBranchChangedParamsBase, total=False):
1012
+ """`session/branchChanged` params (tdd SS4.6.4): a durable workspace-branch observation landed."""
1013
+
1014
+ branch: str
1015
+ vcs: Vcs
1016
+
1017
+
1018
+ class _SessionCompactParamsBase(TypedDict):
1019
+ commandId: str
1020
+ sessionId: str
1021
+
1022
+
1023
+ class SessionCompactParams(_SessionCompactParamsBase, total=False):
1024
+ """`session/compact` params (tdd SS3.7): manually compact the session's conversation context — the `/compact` gesture. Compaction runs asynchronously; the ack is admission only."""
1025
+
1026
+ turnId: str
1027
+
1028
+
1029
+ class _SessionCompactResultBase(TypedDict):
1030
+ commandId: str
1031
+ status: CompactStatus
1032
+
1033
+
1034
+ class SessionCompactResult(_SessionCompactResultBase, total=False):
1035
+ """`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."""
1036
+
1037
+ reason: str
1038
+
1039
+
1040
+ class SessionConfig(TypedDict, total=False):
1041
+ """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."""
1042
+
1043
+ mcpServers: dict[str, SessionMcpServerConfig]
1044
+
1045
+
1046
+ class _SessionContextUsageParamsBase(TypedDict):
1047
+ pressure: ContextPressureLevel
1048
+ sessionId: str
1049
+ sourceRange: SourceRange
1050
+ usedTokens: int
1051
+ viewCursor: str
1052
+
1053
+
1054
+ class SessionContextUsageParams(_SessionContextUsageParamsBase, total=False):
1055
+ """`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)."""
1056
+
1057
+ windowTokens: int
1058
+
1059
+
1060
+ class _SessionForkParamsBase(TypedDict):
1061
+ commandId: str
1062
+ sessionId: str
1063
+
1064
+
1065
+ class SessionForkParams(_SessionForkParamsBase, total=False):
1066
+ """`session/fork` params (tdd SS2.5.3)."""
1067
+
1068
+ cutPoint: ForkCutPoint
1069
+ excludeItems: bool
1070
+
1071
+
1072
+ class SessionForkResult(TypedDict):
1073
+ """`session/fork` result (tdd SS2.5.3): the `session/resume` envelope for the **new** session, whose `session.forkedFrom` carries the provenance."""
1074
+
1075
+ history: SessionHistory
1076
+ pendingRequests: list[PendingRequestPointer]
1077
+ session: Session
1078
+ viewCursor: str
1079
+
1080
+
1081
+ class _SessionGoalChangedParamsBase(TypedDict):
1082
+ sessionId: str
1083
+ sourceRange: SourceRange
1084
+ viewCursor: str
1085
+
1086
+
1087
+ class SessionGoalChangedParams(_SessionGoalChangedParamsBase, total=False):
1088
+ """`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."""
1089
+
1090
+ goal: Goal
1091
+
1092
+
1093
+ class _SessionHistoryBase(TypedDict):
1094
+ items: list[Item] | None
1095
+ mode: HistoryMode
1096
+ snapshot: ViewSnapshot | None
1097
+
1098
+
1099
+ class SessionHistory(_SessionHistoryBase, total=False):
1100
+ """The `history` envelope shared by `session/resume`, `session/fork`, and `session/read` (tdd SS2.5.2)."""
1101
+
1102
+ noneReason: HistoryNoneReason
1103
+
1104
+
1105
+ class SessionListParams(TypedDict, total=False):
1106
+ """`session/list` params (tdd SS2.5.4). Read-only; never touches leases."""
1107
+
1108
+ cursor: str | None
1109
+ limit: int
1110
+ updatedAfter: str
1111
+ workspaceRoot: str
1112
+
1113
+
1114
+ class SessionListResult(TypedDict):
1115
+ """`session/list` result (tdd SS2.5.4). Ordering is `updatedAt` descending."""
1116
+
1117
+ nextCursor: str | None
1118
+ sessions: list[Session]
1119
+
1120
+
1121
+ class _SessionModelChangedParamsBase(TypedDict):
1122
+ modelId: str
1123
+ sessionId: str
1124
+ source: ModelChangeSource
1125
+ sourceRange: SourceRange
1126
+ viewCursor: str
1127
+
1128
+
1129
+ class SessionModelChangedParams(_SessionModelChangedParamsBase, total=False):
1130
+ """`session/modelChanged` params (tdd SS4.6.1): a durable model-selection record landed (tdd SS3.8)."""
1131
+
1132
+ providerId: str
1133
+
1134
+
1135
+ class _SessionModelRouteUnservedParamsBase(TypedDict):
1136
+ commandId: str
1137
+ installedProviderId: str
1138
+ modelId: str
1139
+ sessionId: str
1140
+ sourceRange: SourceRange
1141
+ viewCursor: str
1142
+
1143
+
1144
+ class SessionModelRouteUnservedParams(_SessionModelRouteUnservedParamsBase, total=False):
1145
+ """`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."""
1146
+
1147
+ providerId: str
1148
+
1149
+
1150
+ class SessionNameChangedParams(TypedDict):
1151
+ """`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."""
1152
+
1153
+ name: str
1154
+ sessionId: str
1155
+ sourceRange: SourceRange
1156
+ viewCursor: str
1157
+
1158
+
1159
+ class _SessionReadParamsBase(TypedDict):
1160
+ sessionId: str
1161
+
1162
+
1163
+ class SessionReadParams(_SessionReadParamsBase, total=False):
1164
+ """`session/read` params (tdd SS2.5.5): read one stored session **without attaching** — no writer lease, no load, no subscription, no `SessionResumed` record."""
1165
+
1166
+ excludeItems: bool
1167
+
1168
+
1169
+ class SessionReadResult(TypedDict):
1170
+ """`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."""
1171
+
1172
+ history: SessionHistory
1173
+ pendingRequests: list[PendingRequestPointer]
1174
+ session: Session
1175
+ viewCursor: str
1176
+
1177
+
1178
+ class SessionReasoningEffortChangedParams(TypedDict):
1179
+ """`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)."""
1180
+
1181
+ reasoningEffort: ReasoningEffort
1182
+ sessionId: str
1183
+ source: ReasoningEffortChangeSource
1184
+ sourceRange: SourceRange
1185
+ viewCursor: str
1186
+
1187
+
1188
+ class SessionRenameParams(TypedDict):
1189
+ """`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."""
1190
+
1191
+ commandId: str
1192
+ name: str
1193
+ sessionId: str
1194
+
1195
+
1196
+ class _SessionRenameResultBase(TypedDict):
1197
+ commandId: str
1198
+ status: CommandStatus
1199
+
1200
+
1201
+ class SessionRenameResult(_SessionRenameResultBase, total=False):
1202
+ """`session/rename` result (tdd SS2.14.2, #27598): `name` is the canonical (normalized) name the durable record settled."""
1203
+
1204
+ name: str
1205
+
1206
+
1207
+ class _SessionResumeParamsBase(TypedDict):
1208
+ commandId: str
1209
+ sessionId: str
1210
+
1211
+
1212
+ class SessionResumeParams(_SessionResumeParamsBase, total=False):
1213
+ """`session/resume` params (tdd SS2.5.2)."""
1214
+
1215
+ config: SessionConfig
1216
+ cursor: str | None
1217
+ excludeItems: bool
1218
+ history: HistoryPreference
1219
+
1220
+
1221
+ class SessionResumeResult(TypedDict):
1222
+ """`session/resume` result (tdd SS2.5.2)."""
1223
+
1224
+ history: SessionHistory
1225
+ pendingRequests: list[PendingRequestPointer]
1226
+ session: Session
1227
+ viewCursor: str
1228
+
1229
+
1230
+ class SessionSetApprovalModeParams(TypedDict):
1231
+ """`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."""
1232
+
1233
+ commandId: str
1234
+ mode: ApprovalMode
1235
+ sessionId: str
1236
+
1237
+
1238
+ class SessionSetApprovalModeResult(TypedDict):
1239
+ """`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."""
1240
+
1241
+ applyOutcome: ApprovalModeApplyOutcome
1242
+ commandId: str
1243
+ effectiveMode: EffectiveApprovalModeState
1244
+ status: CommandStatus
1245
+
1246
+
1247
+ class SessionSetModelParams(TypedDict):
1248
+ """`session/setModel` params (tdd SS3.8): the model-picker gesture. The selection is durable and applies to subsequent model calls."""
1249
+
1250
+ commandId: str
1251
+ model: ModelSelection
1252
+ sessionId: str
1253
+
1254
+
1255
+ class SessionSetModelResult(TypedDict):
1256
+ """`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."""
1257
+
1258
+ commandId: str
1259
+ status: CommandStatus
1260
+
1261
+
1262
+ class SessionSetReasoningEffortParams(TypedDict):
1263
+ """`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)."""
1264
+
1265
+ commandId: str
1266
+ reasoningEffort: ReasoningEffort
1267
+ sessionId: str
1268
+
1269
+
1270
+ class SessionSetReasoningEffortResult(TypedDict):
1271
+ """`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."""
1272
+
1273
+ commandId: str
1274
+ status: CommandStatus
1275
+
1276
+
1277
+ class _SessionStartParamsBase(TypedDict):
1278
+ commandId: str
1279
+
1280
+
1281
+ class SessionStartParams(_SessionStartParamsBase, total=False):
1282
+ """`session/start` params (tdd SS2.5.1)."""
1283
+
1284
+ approvalMode: ApprovalMode | None
1285
+ config: SessionConfig
1286
+ modelId: str
1287
+ providerId: str | None
1288
+ sessionId: str
1289
+ workspaceRoot: str
1290
+
1291
+
1292
+ class SessionStartResult(TypedDict):
1293
+ """`session/start` result (tdd SS2.5.1)."""
1294
+
1295
+ session: Session
1296
+ viewCursor: str
1297
+
1298
+
1299
+ class _SessionStatusChangedParamsBase(TypedDict):
1300
+ sessionId: str
1301
+ status: SessionStatus
1302
+ viewCursor: str | None
1303
+
1304
+
1305
+ class SessionStatusChangedParams(_SessionStatusChangedParamsBase, total=False):
1306
+ """`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)."""
1307
+
1308
+ attention: list[AttentionFlag]
1309
+
1310
+
1311
+ class SessionTodoListChangedParams(TypedDict):
1312
+ """`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."""
1313
+
1314
+ items: list[TodoItem]
1315
+ revision: int
1316
+ sessionId: str
1317
+ sourceRange: SourceRange
1318
+ sourceTool: str
1319
+ viewCursor: str
1320
+
1321
+
1322
+ class _SessionTokenUsageParamsBase(TypedDict):
1323
+ cumulative: CumulativeTokenUsage
1324
+ promptTokens: int
1325
+ sessionId: str
1326
+ sourceRange: SourceRange
1327
+ totalTokens: int
1328
+ turnId: str
1329
+ usage: TokenUsage
1330
+ viewCursor: str
1331
+
1332
+
1333
+ class SessionTokenUsageParams(_SessionTokenUsageParamsBase, total=False):
1334
+ """`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."""
1335
+
1336
+ durationMs: int
1337
+ finishReason: str
1338
+ modelId: str
1339
+
1340
+
1341
+ class SessionUserShellParams(TypedDict):
1342
+ """`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."""
1343
+
1344
+ commandId: str
1345
+ commandText: str
1346
+ sessionId: str
1347
+
1348
+
1349
+ class SessionUserShellResult(TypedDict):
1350
+ """`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."""
1351
+
1352
+ commandId: str
1353
+ status: CommandStatus
1354
+
1355
+
1356
+ class _SessionViewHealthChangedParamsBase(TypedDict):
1357
+ health: SessionViewHealth
1358
+ sessionId: str
1359
+
1360
+
1361
+ class SessionViewHealthChangedParams(_SessionViewHealthChangedParamsBase, total=False):
1362
+ """`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)."""
1363
+
1364
+ noneReason: HistoryNoneReason
1365
+
1366
+
1367
+ class _SkillCatalogEntryBase(TypedDict):
1368
+ description: str
1369
+ displayName: str
1370
+ selector: str
1371
+ source: SkillSource
1372
+
1373
+
1374
+ class SkillCatalogEntry(_SkillCatalogEntryBase, total=False):
1375
+ """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."""
1376
+
1377
+ argumentHint: str
1378
+ pluginId: str
1379
+
1380
+
1381
+ class SkillChangedParams(TypedDict):
1382
+ """`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)."""
1383
+
1384
+ sessionId: str
1385
+
1386
+
1387
+ class SkillListParams(TypedDict):
1388
+ """`skill/list` params (tdd SS3.22.1). Per-session because skill scope follows the session's workspace and plugin state."""
1389
+
1390
+ sessionId: str
1391
+
1392
+
1393
+ class SkillListResult(TypedDict):
1394
+ """`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)."""
1395
+
1396
+ skills: list[SkillCatalogEntry]
1397
+
1398
+
1399
+ class SnapshotAnchor(TypedDict):
1400
+ """The compaction boundary an anchored snapshot is anchored at (tdd SS2.5.2)."""
1401
+
1402
+ boundaryCursor: str
1403
+ summarizedThrough: str
1404
+
1405
+
1406
+ class _SnapshotStateBase(TypedDict):
1407
+ activeTurn: TurnRef | None
1408
+ approvalMode: EffectiveApprovalModeState
1409
+ branch: BranchState | None
1410
+ effectiveModel: EffectiveModel | None
1411
+ goal: Goal | None
1412
+ items: list[Item]
1413
+ pendingApprovals: list[PendingApprovalPointer]
1414
+ pendingUserInputs: list[PendingUserInputPointer]
1415
+ queuedTurns: list[TurnRef]
1416
+ todoList: TodoListState | None
1417
+ tokenUsage: CumulativeTokenUsage
1418
+ turnCount: int
1419
+
1420
+
1421
+ class SnapshotState(_SnapshotStateBase, total=False):
1422
+ """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."""
1423
+
1424
+ contextUsage: ContextUsage
1425
+ name: str
1426
+ reasoningEffort: ReasoningEffortState
1427
+
1428
+
1429
+ class SourceRange(TypedDict):
1430
+ """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)."""
1431
+
1432
+ first: RecordPosition
1433
+ last: RecordPosition
1434
+ stream: StreamRef
1435
+
1436
+
1437
+ class StreamRef(TypedDict):
1438
+ """One raw stream named by a [`SourceRange`] (tdd SS4.2)."""
1439
+
1440
+ id: str
1441
+ kind: str
1442
+
1443
+
1444
+ class SubagentInputParams(TypedDict):
1445
+ """Params for `subagent/sendMessage` and `subagent/followupTask` (SS3.16): a child target plus the input body."""
1446
+
1447
+ body: str
1448
+ commandId: str
1449
+ sessionId: str
1450
+ subagentId: str
1451
+
1452
+
1453
+ class _SubagentOwnerReasonParamsBase(TypedDict):
1454
+ commandId: str
1455
+ sessionId: str
1456
+ subagentId: str
1457
+
1458
+
1459
+ class SubagentOwnerReasonParams(_SubagentOwnerReasonParamsBase, total=False):
1460
+ """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."""
1461
+
1462
+ reason: str
1463
+
1464
+
1465
+ class _SubagentResultBase(TypedDict):
1466
+ artifactRefs: list[str]
1467
+ evidenceRefs: list[str]
1468
+ summary: str
1469
+
1470
+
1471
+ class SubagentResult(_SubagentResultBase, total=False):
1472
+ """A subagent's result envelope (tdd SS4.5.7, `SubagentResultEnvelope`)."""
1473
+
1474
+ errorKind: str
1475
+ structuredData: dict[str, Any]
1476
+ text: str
1477
+
1478
+
1479
+ class SubagentTargetParams(TypedDict):
1480
+ """Params for `subagent/resume`, `subagent/reopen`, and `subagent/readResult` (SS3.16): the bare child target."""
1481
+
1482
+ commandId: str
1483
+ sessionId: str
1484
+ subagentId: str
1485
+
1486
+
1487
+ class SubscriptionUsage(TypedDict):
1488
+ """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)."""
1489
+
1490
+ observedAtMs: int
1491
+ tier: str
1492
+ weekly: SubscriptionUsageWeekly
1493
+ window: SubscriptionUsageWindow
1494
+
1495
+
1496
+ class SubscriptionUsageWeekly(TypedDict):
1497
+ """The rolling weekly block: same semantics as [`SubscriptionUsageWindow`] without a duration (ADR 32563 D2)."""
1498
+
1499
+ resetsAtMs: int
1500
+ usedPercent: int
1501
+
1502
+
1503
+ class SubscriptionUsageWindow(TypedDict):
1504
+ """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)."""
1505
+
1506
+ resetsAtMs: int
1507
+ usedPercent: int
1508
+ windowDurationMins: int
1509
+
1510
+
1511
+ class SuccessResponse(TypedDict):
1512
+ """A success response frame (SS1.2 §2.3)."""
1513
+
1514
+ id: RequestId
1515
+ jsonrpc: JsonRpcVersion
1516
+ result: dict[str, Any]
1517
+
1518
+
1519
+ class TaskBackgroundParams(TypedDict):
1520
+ """`task/background` params (tdd §3.13): durably send a running foreground tool task to the background."""
1521
+
1522
+ commandId: str
1523
+ sessionId: str
1524
+ taskId: str
1525
+
1526
+
1527
+ class TaskCommandResult(TypedDict):
1528
+ """The `task/background` / `task/stop` ack (tdd §3.13/§3.14): admission-only, echoing the targeted task."""
1529
+
1530
+ commandId: str
1531
+ status: CommandStatus
1532
+ taskId: str
1533
+
1534
+
1535
+ class TaskStopAllParams(TypedDict):
1536
+ """`task/stopAll` params (tdd §3.15): stop every stoppable background workload live at admission."""
1537
+
1538
+ commandId: str
1539
+ sessionId: str
1540
+
1541
+
1542
+ class TaskStopAllResult(TypedDict):
1543
+ """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."""
1544
+
1545
+ commandId: str
1546
+ status: CommandStatus
1547
+
1548
+
1549
+ class TaskStopParams(TypedDict):
1550
+ """`task/stop` params (tdd §3.14): stop one named background task. Required target, never \"whichever is loudest\" — §3.15 is the blanket verb."""
1551
+
1552
+ commandId: str
1553
+ sessionId: str
1554
+ taskId: str
1555
+
1556
+
1557
+ class _TodoItemBase(TypedDict):
1558
+ status: TodoStatus
1559
+ text: str
1560
+
1561
+
1562
+ class TodoItem(_TodoItemBase, total=False):
1563
+ """One todo entry (tdd SS4.6.3)."""
1564
+
1565
+ activeForm: str
1566
+
1567
+
1568
+ class TodoListState(TypedDict):
1569
+ """The latest todo-list fact in the snapshot (tdd SS4.6.3, SS4.9.1)."""
1570
+
1571
+ items: list[TodoItem]
1572
+ revision: int
1573
+ sourceTool: str
1574
+
1575
+
1576
+ class _TokenUsageBase(TypedDict):
1577
+ cachedTokens: int
1578
+ inputTokens: int
1579
+ outputTokens: int
1580
+ reasoningTokens: int
1581
+
1582
+
1583
+ class TokenUsage(_TokenUsageBase, total=False):
1584
+ """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)."""
1585
+
1586
+ cacheReadTokens: int
1587
+ cacheWriteTokens: int
1588
+
1589
+
1590
+ class TraceContext(TypedDict, total=False):
1591
+ """Optional W3C trace context, on requests in both directions only — never on responses or notifications (SS1.8)."""
1592
+
1593
+ traceparent: str
1594
+ tracestate: str
1595
+
1596
+
1597
+ class _TurnCancelParamsBase(TypedDict):
1598
+ commandId: str
1599
+ sessionId: str
1600
+
1601
+
1602
+ class TurnCancelParams(_TurnCancelParamsBase, total=False):
1603
+ """`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`."""
1604
+
1605
+ turnId: str
1606
+
1607
+
1608
+ class TurnCancelResult(TypedDict):
1609
+ """`turn/cancel` result (tdd SS3.5): identical envelope to `turn/interrupt`."""
1610
+
1611
+ commandId: str
1612
+ status: CommandStatus
1613
+ turnId: str
1614
+
1615
+
1616
+ class _TurnCompletedParamsBase(TypedDict):
1617
+ sessionId: str
1618
+ sourceRange: SourceRange
1619
+ terminal: TurnTerminal
1620
+ turnId: str
1621
+ viewCursor: str
1622
+
1623
+
1624
+ class TurnCompletedParams(_TurnCompletedParamsBase, total=False):
1625
+ """`turn/completed` params (tdd SS4.5.1): the run's durable terminal record landed."""
1626
+
1627
+ durationMs: int
1628
+ error: TurnError
1629
+ reason: str
1630
+ timeToFirstTokenMs: int
1631
+ usage: TokenUsage
1632
+
1633
+
1634
+ class TurnError(TypedDict):
1635
+ """The settled turn-failure object (tdd SS4.5.1): `{kind, message, retryable}`."""
1636
+
1637
+ kind: TurnErrorKind
1638
+ message: str
1639
+ retryable: bool
1640
+
1641
+
1642
+ class _TurnInputPartBase(TypedDict):
1643
+ type: TurnInputPartType
1644
+
1645
+
1646
+ class TurnInputPart(_TurnInputPartBase, total=False):
1647
+ """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."""
1648
+
1649
+ arguments: str
1650
+ base64Data: str
1651
+ height: int
1652
+ mediaType: str
1653
+ selector: str
1654
+ text: str
1655
+ width: int
1656
+
1657
+
1658
+ class _TurnInterruptParamsBase(TypedDict):
1659
+ commandId: str
1660
+ sessionId: str
1661
+
1662
+
1663
+ class TurnInterruptParams(_TurnInterruptParamsBase, total=False):
1664
+ """`turn/interrupt` params (tdd SS3.4): the \"user pressed stop\" gesture, on the runtime's priority lane."""
1665
+
1666
+ retract: bool
1667
+ turnId: str
1668
+
1669
+
1670
+ class TurnInterruptResult(TypedDict):
1671
+ """`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`."""
1672
+
1673
+ commandId: str
1674
+ status: CommandStatus
1675
+ turnId: str
1676
+
1677
+
1678
+ class TurnRef(TypedDict):
1679
+ """A turn named by the snapshot's active/queued lists (tdd SS4.9.1)."""
1680
+
1681
+ commandId: str
1682
+ turnId: str
1683
+
1684
+
1685
+ class TurnRetractedParams(TypedDict):
1686
+ """`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`."""
1687
+
1688
+ commandId: str
1689
+ sessionId: str
1690
+ sourceRange: SourceRange
1691
+ turnId: str
1692
+ viewCursor: str
1693
+
1694
+
1695
+ class TurnRetryScheduledParams(TypedDict):
1696
+ """`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)."""
1697
+
1698
+ attempt: int
1699
+ maxAttempts: int
1700
+ nextAttempt: int
1701
+ reason: str
1702
+ retryDelayMs: int
1703
+ sessionId: str
1704
+ sourceRange: SourceRange
1705
+ turnId: str
1706
+ viewCursor: str
1707
+
1708
+
1709
+ class _TurnStartParamsBase(TypedDict):
1710
+ commandId: str
1711
+ input: list[TurnInputPart]
1712
+ sessionId: str
1713
+
1714
+
1715
+ class TurnStartParams(_TurnStartParamsBase, total=False):
1716
+ """`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)."""
1717
+
1718
+ displayText: str
1719
+ ifBusy: IfBusy
1720
+ reasoningEffort: ReasoningEffort
1721
+
1722
+
1723
+ class TurnStartResult(TypedDict):
1724
+ """`turn/start` result (tdd SS3.2)."""
1725
+
1726
+ commandId: str
1727
+ disposition: TurnStartDisposition
1728
+ startedNewTurn: bool
1729
+ status: CommandStatus
1730
+ turnId: str
1731
+
1732
+
1733
+ class TurnStartedParams(TypedDict):
1734
+ """`turn/started` params (tdd SS4.5.1): a foreground turn began running — fresh submits immediately, queued submits at their launch boundary, never steered submits."""
1735
+
1736
+ commandId: str
1737
+ sessionId: str
1738
+ sourceRange: SourceRange
1739
+ turnId: str
1740
+ viewCursor: str
1741
+
1742
+
1743
+ class _TurnSteerParamsBase(TypedDict):
1744
+ commandId: str
1745
+ expectedTurnId: str
1746
+ input: list[TurnInputPart]
1747
+ sessionId: str
1748
+
1749
+
1750
+ class TurnSteerParams(_TurnSteerParamsBase, total=False):
1751
+ """`turn/steer` params (tdd SS3.3): exact-target steering into the currently running turn."""
1752
+
1753
+ reasoningEffort: ReasoningEffort
1754
+
1755
+
1756
+ class TurnSteerResult(TypedDict):
1757
+ """`turn/steer` result (tdd SS3.3)."""
1758
+
1759
+ commandId: str
1760
+ status: CommandStatus
1761
+ turnId: str
1762
+
1763
+
1764
+ class TurnUnqueueParams(TypedDict):
1765
+ """`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."""
1766
+
1767
+ commandId: str
1768
+ sessionId: str
1769
+ turnId: str
1770
+
1771
+
1772
+ class TurnUnqueueResult(TypedDict):
1773
+ """`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."""
1774
+
1775
+ commandId: str
1776
+ status: CommandStatus
1777
+ turnId: str
1778
+
1779
+
1780
+ class TurnUnqueuedParams(TypedDict):
1781
+ """`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."""
1782
+
1783
+ commandId: str
1784
+ sessionId: str
1785
+ sourceRange: SourceRange
1786
+ turnId: str
1787
+ viewCursor: str
1788
+
1789
+
1790
+ class UnframedViewNotification(TypedDict):
1791
+ """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."""
1792
+
1793
+ method: str
1794
+ params: UnframedViewNotificationParams
1795
+
1796
+
1797
+ class UnframedViewNotificationParams(TypedDict):
1798
+ """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."""
1799
+
1800
+ sessionId: str
1801
+ sourceRange: SourceRange
1802
+ viewCursor: str
1803
+
1804
+
1805
+ class UsageReadResult(TypedDict, total=False):
1806
+ """`usage/read` result: `{usage?}` — omitted, never `null`, when the host has observed nothing (ADR 32563 D2: truthful absence, no \"nothing observed\" error)."""
1807
+
1808
+ usage: SubscriptionUsage
1809
+
1810
+
1811
+ class _UserInputAnswerBase(TypedDict):
1812
+ questionId: str
1813
+
1814
+
1815
+ class UserInputAnswer(_UserInputAnswerBase, total=False):
1816
+ freeText: str
1817
+ note: str
1818
+ selectedLabel: str
1819
+ selectedLabels: list[str]
1820
+
1821
+
1822
+ class UserInputAnswerParams(TypedDict):
1823
+ """`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."""
1824
+
1825
+ answers: list[UserInputAnswer]
1826
+ commandId: str
1827
+ sessionId: str
1828
+ userInputId: str
1829
+
1830
+
1831
+ class UserInputAnswerResult(TypedDict):
1832
+ """`userInput/answer` result (tdd SS5.10.2)."""
1833
+
1834
+ commandId: str
1835
+ status: CommandStatus
1836
+ userInputId: str
1837
+
1838
+
1839
+ class _UserInputCancelParamsBase(TypedDict):
1840
+ commandId: str
1841
+ sessionId: str
1842
+ userInputId: str
1843
+
1844
+
1845
+ class UserInputCancelParams(_UserInputCancelParamsBase, total=False):
1846
+ """`userInput/cancel` params (tdd SS5.10.2): decline to answer; the tool call resolves with a cancelled result the model sees."""
1847
+
1848
+ reason: str
1849
+
1850
+
1851
+ class UserInputCancelResult(TypedDict):
1852
+ """`userInput/cancel` result (tdd SS5.10.2)."""
1853
+
1854
+ commandId: str
1855
+ status: CommandStatus
1856
+ userInputId: str
1857
+
1858
+
1859
+ class UserInputClarification(TypedDict):
1860
+ content: str
1861
+ format: str
1862
+
1863
+
1864
+ class UserInputClarifyParams(TypedDict):
1865
+ """`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."""
1866
+
1867
+ clarification: UserInputClarification
1868
+ commandId: str
1869
+ sessionId: str
1870
+ userInputId: str
1871
+
1872
+
1873
+ class UserInputClarifyResult(TypedDict):
1874
+ """`userInput/clarify` result (tdd SS5.10.2)."""
1875
+
1876
+ commandId: str
1877
+ status: CommandStatus
1878
+ userInputId: str
1879
+
1880
+
1881
+ class _UserInputOptionBase(TypedDict):
1882
+ label: str
1883
+
1884
+
1885
+ class UserInputOption(_UserInputOptionBase, total=False):
1886
+ description: str
1887
+ preview: UserInputOptionPreview
1888
+
1889
+
1890
+ class UserInputOptionPreview(TypedDict):
1891
+ content: str
1892
+ format: str
1893
+
1894
+
1895
+ class UserInputQuestion(TypedDict):
1896
+ header: str
1897
+ id: str
1898
+ options: list[UserInputOption]
1899
+ question: str
1900
+ selection: UserInputSelection
1901
+
1902
+
1903
+ class _UserInputRequestParamsBase(TypedDict):
1904
+ itemId: str
1905
+ questions: list[UserInputQuestion]
1906
+ sessionId: str
1907
+ toolCallId: str
1908
+ toolName: str
1909
+ turnId: str
1910
+ userInputId: str
1911
+ viewCursor: str
1912
+
1913
+
1914
+ class UserInputRequestParams(_UserInputRequestParamsBase, total=False):
1915
+ """Full params shared by `userInput/request` and `userInput/requested`."""
1916
+
1917
+ autoResolutionMs: int
1918
+ sourceRange: SourceRange
1919
+
1920
+
1921
+ class _UserInputSelectionBase(TypedDict):
1922
+ mode: UserInputSelectionMode
1923
+
1924
+
1925
+ class UserInputSelection(_UserInputSelectionBase, total=False):
1926
+ maxSelections: int
1927
+ minSelections: int
1928
+
1929
+
1930
+ class UserInputSettledParams(TypedDict):
1931
+ """`userInput/settled` params: the first durable prompt settlement."""
1932
+
1933
+ answers: list[UserInputAnswer]
1934
+ clarification: UserInputClarification | None
1935
+ decidedByCommandId: str | None
1936
+ outcome: UserInputOutcome
1937
+ reason: str | None
1938
+ sessionId: str
1939
+ sourceRange: SourceRange
1940
+ userInputId: str
1941
+ viewCursor: str
1942
+
1943
+
1944
+ class UserInputSettlementSummary(TypedDict):
1945
+ """Winning terminal returned to a late user-input command."""
1946
+
1947
+ outcome: str
1948
+ viewCursor: str
1949
+
1950
+
1951
+ class ViewGapParams(TypedDict):
1952
+ """`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."""
1953
+
1954
+ after: str
1955
+ next: str
1956
+ sessionId: str
1957
+
1958
+
1959
+ class _ViewPageParamsBase(TypedDict):
1960
+ limit: int
1961
+ sessionId: str
1962
+
1963
+
1964
+ class ViewPageParams(_ViewPageParamsBase, total=False):
1965
+ """`view/page` params (tdd SS4.7.3): cursor-paged reads of the session view."""
1966
+
1967
+ anchor: ViewPageAnchor
1968
+ cursor: str
1969
+ direction: ViewPageDirection
1970
+
1971
+
1972
+ class ViewPageResolvedAnchor(TypedDict):
1973
+ """The `resolvedAnchor` echo (tdd SS4.7.3): subsequent pages pass ordinary cursors, so the anchor never needs re-resolving."""
1974
+
1975
+ boundaryCursor: str
1976
+
1977
+
1978
+ class _ViewPageResultBase(TypedDict):
1979
+ events: list[UnframedViewNotification]
1980
+ nextCursor: str | None
1981
+
1982
+
1983
+ class ViewPageResult(_ViewPageResultBase, total=False):
1984
+ """`view/page` result (tdd SS4.7.3)."""
1985
+
1986
+ resolvedAnchor: ViewPageResolvedAnchor
1987
+
1988
+
1989
+ class _ViewSnapshotBase(TypedDict):
1990
+ schemaVersion: int
1991
+ state: SnapshotState
1992
+ viewCursor: str
1993
+
1994
+
1995
+ class ViewSnapshot(_ViewSnapshotBase, total=False):
1996
+ """The `snapshot` object returned by `session/resume` / `session/read` (tdd SS4.9)."""
1997
+
1998
+ anchor: SnapshotAnchor
1999
+
2000
+
2001
+ class _ViewSubscribeParamsBase(TypedDict):
2002
+ sessionId: str
2003
+
2004
+
2005
+ class ViewSubscribeParams(_ViewSubscribeParamsBase, total=False):
2006
+ """`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."""
2007
+
2008
+ after: str
2009
+
2010
+
2011
+ class ViewSubscribeResult(TypedDict):
2012
+ """`view/subscribe` result (tdd SS4.7.1)."""
2013
+
2014
+ viewCursor: str
2015
+
2016
+
2017
+ class ViewUnsubscribeParams(TypedDict):
2018
+ """`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)."""
2019
+
2020
+ sessionId: str
2021
+
2022
+
2023
+ class ViewUnsubscribeResult(TypedDict):
2024
+ """`view/unsubscribe` result (tdd SS4.7.2): the empty object. Idempotent — unsubscribing while not subscribed returns `{}`."""
2025
+
2026
+ pass
2027
+
2028
+
2029
+ class WorkflowCancelParams(TypedDict):
2030
+ """`workflow/cancel` params (tdd SS3.19): cancel a live workflow run."""
2031
+
2032
+ commandId: str
2033
+ sessionId: str
2034
+ workflowRunId: str
2035
+
2036
+
2037
+ class _WorkflowChildBase(TypedDict):
2038
+ attempt: int
2039
+ childId: str
2040
+ status: str
2041
+
2042
+
2043
+ class WorkflowChild(_WorkflowChildBase, total=False):
2044
+ """One workflow child's folded state (tdd SS4.5.8, `WorkflowChildLifecycleFact`), keyed by `(childId, attempt)`."""
2045
+
2046
+ durationMs: int
2047
+ label: str
2048
+ phase: str
2049
+ resultRef: str
2050
+ terminal: TurnTerminal
2051
+ usage: TokenUsage
2052
+
2053
+
2054
+ class WorkflowChildControlParams(TypedDict):
2055
+ """`workflow/childControl` params (tdd SS3.20): skip or retry one workflow child, keyed by the `(childId, attempt)` pair the `workflow` item's `children[]` carries."""
2056
+
2057
+ action: WorkflowChildAction
2058
+ attempt: int
2059
+ childId: str
2060
+ commandId: str
2061
+ sessionId: str
2062
+ workflowRunId: str
2063
+
2064
+
2065
+ class WorkflowControlResult(TypedDict):
2066
+ """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."""
2067
+
2068
+ commandId: str
2069
+ status: CommandStatus
2070
+
2071
+
2072
+ class __SessionMcpServerConfigStdioBase(TypedDict):
2073
+ command: str
2074
+ transport: Literal["stdio"]
2075
+
2076
+
2077
+ class _SessionMcpServerConfigStdio(__SessionMcpServerConfigStdioBase, total=False):
2078
+ args: list[str]
2079
+ env: dict[str, str]
2080
+ framing: SessionMcpStdioFraming
2081
+ mode: SessionMcpServerMode
2082
+
2083
+
2084
+ class __SessionMcpServerConfigStreamableHttpBase(TypedDict):
2085
+ transport: Literal["streamableHttp"]
2086
+ url: str
2087
+
2088
+
2089
+ class _SessionMcpServerConfigStreamableHttp(__SessionMcpServerConfigStreamableHttpBase, total=False):
2090
+ headers: dict[str, str]
2091
+ mode: SessionMcpServerMode
2092
+
2093
+
2094
+ # 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.
2095
+ SessionMcpServerConfig = _SessionMcpServerConfigStdio | _SessionMcpServerConfigStreamableHttp
2096
+
2097
+ class MethodSpec(TypedDict):
2098
+ description: str
2099
+ params: str | None
2100
+ result: str | None
2101
+
2102
+
2103
+ class NotificationSpec(TypedDict):
2104
+ description: str
2105
+ params: str | None
2106
+
2107
+
2108
+ class ErrorSpec(TypedDict):
2109
+ code: int
2110
+ kind: str
2111
+ retryable: bool
2112
+ overrideKinds: tuple[str, ...]
2113
+
2114
+
2115
+ METHODS: Final[dict[str, MethodSpec]] = {
2116
+ "approval/decide": {"description": "Decides a pending approval, guarded by the current requirement id against the multi-stage race (SS5.4).", "params": "ApprovalDecideParams", "result": "ApprovalDecideResult"},
2117
+ "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"},
2118
+ "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"},
2119
+ "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"},
2120
+ "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"},
2121
+ "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"},
2122
+ "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"},
2123
+ "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"},
2124
+ "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"},
2125
+ "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"},
2126
+ "session/compact": {"description": "Compacts the session's conversation context; runs asynchronously, so the ack is admission only (SS3.7).", "params": "SessionCompactParams", "result": "SessionCompactResult"},
2127
+ "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"},
2128
+ "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"},
2129
+ "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"},
2130
+ "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"},
2131
+ "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"},
2132
+ "session/setApprovalMode": {"description": "Selects a preconfigured approval enforcement mode mid-session; select, never create (SS5.12).", "params": "SessionSetApprovalModeParams", "result": "SessionSetApprovalModeResult"},
2133
+ "session/setModel": {"description": "Reconfigures the session's model; the selection is durable and applies to subsequent model calls (SS3.8).", "params": "SessionSetModelParams", "result": "SessionSetModelResult"},
2134
+ "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"},
2135
+ "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"},
2136
+ "session/userShell": {"description": "Runs a user-initiated shell command in the session's workspace; capability-gated on `userShell` (SS3.9).", "params": "SessionUserShellParams", "result": "SessionUserShellResult"},
2137
+ "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"},
2138
+ "subagent/close": {"description": "Owner-close a child; the terminal mapping folds per SS4.5.7 (SS3.16).", "params": "SubagentOwnerReasonParams", "result": "CommandAcceptedResult"},
2139
+ "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"},
2140
+ "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"},
2141
+ "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"},
2142
+ "subagent/reopen": {"description": "Reopen a stopped/closed child as a durable later attempt (SS3.16).", "params": "SubagentTargetParams", "result": "CommandAcceptedResult"},
2143
+ "subagent/resume": {"description": "Resume a paused/recoverable child as a durable later attempt (SS3.16).", "params": "SubagentTargetParams", "result": "CommandAcceptedResult"},
2144
+ "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"},
2145
+ "subagent/stop": {"description": "Stop a running child; outcome folds to the parent's subagent item (SS3.16, SS4.5.7).", "params": "SubagentOwnerReasonParams", "result": "CommandAcceptedResult"},
2146
+ "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"},
2147
+ "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"},
2148
+ "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"},
2149
+ "turn/cancel": {"description": "Cancels a turn on the normal command lane, recording no priority interrupt intent (SS3.5).", "params": "TurnCancelParams", "result": "TurnCancelResult"},
2150
+ "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"},
2151
+ "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"},
2152
+ "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"},
2153
+ "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"},
2154
+ "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"},
2155
+ "userInput/answer": {"description": "Answers every question of an open user-input prompt (SS5.10.2).", "params": "UserInputAnswerParams", "result": "UserInputAnswerResult"},
2156
+ "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"},
2157
+ "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"},
2158
+ "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"},
2159
+ "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"},
2160
+ "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"},
2161
+ "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"},
2162
+ "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"},
2163
+ }
2164
+
2165
+ NOTIFICATIONS: Final[dict[str, NotificationSpec]] = {
2166
+ "approval/requested": {"description": "An approval opened: the fold of its durable Requested record (SS5.5.1).", "params": "ApprovalRequestParams"},
2167
+ "approval/resolved": {"description": "The first durable approval terminal landed; protected delivery (SS5.5).", "params": "ApprovalResolvedParams"},
2168
+ "approval/updated": {"description": "A non-terminal approval record changed the pending view (SS5.5.1).", "params": "ApprovalUpdatedParams"},
2169
+ "initialized": {"description": "Client-to-server notification closing the handshake; no params (SS1.4.2).", "params": None},
2170
+ "item/completed": {"description": "An item reached its terminal state: the authoritative final object (SS4.3).", "params": "ItemCompletedParams"},
2171
+ "item/delta": {"description": "Streaming append to an open item's field path (ephemeral-sourced, no sourceRange; opt-out-able) (SS4.3.1).", "params": "ItemDeltaParams"},
2172
+ "item/started": {"description": "An item opened on the transcript (SS4.3).", "params": "ItemStartedParams"},
2173
+ "item/updated": {"description": "An open item changed non-terminally: full re-emission at a higher revision (SS4.4.2).", "params": "ItemUpdatedParams"},
2174
+ "session/approvalModeChanged": {"description": "The approval enforcement mode changed: the fold of the durable reconfigure audit fact (SS5.12).", "params": "SessionApprovalModeChangedParams"},
2175
+ "session/branchChanged": {"description": "A durable workspace-branch observation landed; null branch is a detached-HEAD fact (SS4.6.4).", "params": "SessionBranchChangedParams"},
2176
+ "session/contextUsage": {"description": "A provider-reported context-occupancy fact folded to a changed (windowTokens, usedTokens, pressure) triple (SS4.6.6).", "params": "SessionContextUsageParams"},
2177
+ "session/goalChanged": {"description": "The session's goal block changed value; replace wholesale, an explicit null clears (SS4.6.2).", "params": "SessionGoalChangedParams"},
2178
+ "session/modelChanged": {"description": "A durable model selection took effect (SS4.6.1).", "params": "SessionModelChangedParams"},
2179
+ "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"},
2180
+ "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"},
2181
+ "session/reasoningEffortChanged": {"description": "A durable session-default reasoning-effort change took effect (SS4.6.9, ADR 31255 D1).", "params": "SessionReasoningEffortChangedParams"},
2182
+ "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"},
2183
+ "session/todoListChanged": {"description": "The todo list was replaced wholesale; empty items is a cleared list (SS4.6.3).", "params": "SessionTodoListChangedParams"},
2184
+ "session/tokenUsage": {"description": "A model call completed with usage: raw counters plus counted-once derivations plus session cumulative (SS4.6.5).", "params": "SessionTokenUsageParams"},
2185
+ "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"},
2186
+ "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"},
2187
+ "turn/completed": {"description": "Turn terminal: completed | failed | cancelled, with usage and the settled error object (SS4.5.1).", "params": "TurnCompletedParams"},
2188
+ "turn/retracted": {"description": "An interrupt-paired retract was durably accepted (SS4.5.1).", "params": "TurnRetractedParams"},
2189
+ "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"},
2190
+ "turn/started": {"description": "A foreground turn began running (SS4.5.1).", "params": "TurnStartedParams"},
2191
+ "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"},
2192
+ "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"},
2193
+ "userInput/requested": {"description": "A user-input prompt opened: the fold of its durable Requested record (SS5.10.1).", "params": "UserInputRequestParams"},
2194
+ "userInput/settled": {"description": "The first durable user-input settlement landed; protected delivery (SS5.10.3).", "params": "UserInputSettledParams"},
2195
+ "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"},
2196
+ }
2197
+
2198
+ ERRORS: Final[tuple[ErrorSpec, ...]] = (
2199
+ {"code": -32700, "kind": "parseError", "retryable": False, "overrideKinds": ()},
2200
+ {"code": -32600, "kind": "invalidRequest", "retryable": False, "overrideKinds": ("notInitialized", "alreadyInitialized",)},
2201
+ {"code": -32601, "kind": "methodNotFound", "retryable": False, "overrideKinds": ("experimentalRequired",)},
2202
+ {"code": -32602, "kind": "invalidParams", "retryable": False, "overrideKinds": ("experimentalRequired",)},
2203
+ {"code": -32603, "kind": "internal", "retryable": False, "overrideKinds": ("pageEventTooLarge", "outputResultTooLarge",)},
2204
+ {"code": -32001, "kind": "overloaded", "retryable": True, "overrideKinds": ()},
2205
+ {"code": -32002, "kind": "inputTooLarge", "retryable": False, "overrideKinds": ()},
2206
+ {"code": -32010, "kind": "capabilityRequired", "retryable": False, "overrideKinds": ()},
2207
+ {"code": -32011, "kind": "notFound", "retryable": False, "overrideKinds": ()},
2208
+ {"code": -32013, "kind": "interrupted", "retryable": False, "overrideKinds": ()},
2209
+ {"code": -32014, "kind": "cancelled", "retryable": False, "overrideKinds": ()},
2210
+ {"code": -32020, "kind": "sessionNotFound", "retryable": False, "overrideKinds": ()},
2211
+ {"code": -32021, "kind": "sessionInUse", "retryable": False, "overrideKinds": ()},
2212
+ {"code": -32022, "kind": "sessionAmbiguous", "retryable": False, "overrideKinds": ()},
2213
+ {"code": -32023, "kind": "forkBoundaryInvalid", "retryable": False, "overrideKinds": ()},
2214
+ {"code": -32024, "kind": "sessionNotLoaded", "retryable": False, "overrideKinds": ()},
2215
+ {"code": -32025, "kind": "sessionStreamMismatch", "retryable": False, "overrideKinds": ()},
2216
+ {"code": -32030, "kind": "commandRejected", "retryable": False, "overrideKinds": ()},
2217
+ {"code": -32031, "kind": "backpressured", "retryable": True, "overrideKinds": ()},
2218
+ {"code": -32032, "kind": "skillNotFound", "retryable": False, "overrideKinds": ()},
2219
+ {"code": -32040, "kind": "viewTruncated", "retryable": False, "overrideKinds": ()},
2220
+ {"code": -32041, "kind": "outputUnavailable", "retryable": False, "overrideKinds": ()},
2221
+ {"code": -32042, "kind": "boundaryPruned", "retryable": False, "overrideKinds": ("boundaryUnusable", "noBoundary",)},
2222
+ {"code": -32050, "kind": "approvalNotFound", "retryable": False, "overrideKinds": ()},
2223
+ {"code": -32051, "kind": "approvalAlreadyResolved", "retryable": False, "overrideKinds": ()},
2224
+ {"code": -32052, "kind": "approvalChoiceInvalid", "retryable": False, "overrideKinds": ()},
2225
+ {"code": -32053, "kind": "approvalRequirementStale", "retryable": False, "overrideKinds": ()},
2226
+ {"code": -32054, "kind": "approvalReviewerUnavailable", "retryable": False, "overrideKinds": ()},
2227
+ {"code": -32055, "kind": "userInputNotFound", "retryable": False, "overrideKinds": ()},
2228
+ {"code": -32056, "kind": "userInputAlreadySettled", "retryable": False, "overrideKinds": ()},
2229
+ {"code": -32057, "kind": "userInputAnswerInvalid", "retryable": False, "overrideKinds": ()},
2230
+ )
2231
+
2232
+ GRANTABLE_CAPABILITIES: Final[tuple[str, ...]] = ("userShell", "sessionMcp",)