@fungi.computer/shiitake 0.0.0-stage → 0.0.1

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.
Files changed (164) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +454 -2
  3. package/dist/agar-extension.d.ts +9 -0
  4. package/dist/agar-extension.js +38 -0
  5. package/dist/agent-control.d.ts +72 -0
  6. package/dist/agent-control.js +431 -0
  7. package/dist/client-entry.d.ts +211 -0
  8. package/dist/client-entry.js +101 -0
  9. package/dist/client-wire.d.ts +199 -0
  10. package/dist/client-wire.js +271 -0
  11. package/dist/client.d.ts +439 -0
  12. package/dist/client.js +4 -0
  13. package/dist/cloudflare.d.ts +220 -0
  14. package/dist/cloudflare.js +531 -0
  15. package/dist/effect.d.ts +42 -0
  16. package/dist/effect.js +20 -0
  17. package/dist/errors.d.ts +50 -0
  18. package/dist/errors.js +81 -0
  19. package/dist/extension-client.d.ts +38 -0
  20. package/dist/extension-client.js +56 -0
  21. package/dist/extension-contract.d.ts +73 -0
  22. package/dist/extension-contract.js +11 -0
  23. package/dist/extensions.d.ts +589 -0
  24. package/dist/extensions.js +263 -0
  25. package/dist/fleet.d.ts +297 -0
  26. package/dist/fleet.js +515 -0
  27. package/dist/hosted.d.ts +133 -0
  28. package/dist/hosted.js +265 -0
  29. package/dist/http-routes.d.ts +772 -0
  30. package/dist/http-routes.js +242 -0
  31. package/dist/http.d.ts +1 -0
  32. package/dist/http.js +1 -0
  33. package/dist/index.d.ts +35 -0
  34. package/dist/index.js +13 -0
  35. package/dist/internal/accepted-run-executor.d.ts +23 -0
  36. package/dist/internal/accepted-run-executor.js +129 -0
  37. package/dist/internal/admission-door.d.ts +75 -0
  38. package/dist/internal/admission-door.js +105 -0
  39. package/dist/internal/agent-close.d.ts +4 -0
  40. package/dist/internal/agent-close.js +42 -0
  41. package/dist/internal/browser-sessions.d.ts +31 -0
  42. package/dist/internal/browser-sessions.js +173 -0
  43. package/dist/internal/client-boundary.d.ts +262 -0
  44. package/dist/internal/client-boundary.js +202 -0
  45. package/dist/internal/compaction/compaction.d.ts +54 -0
  46. package/dist/internal/compaction/compaction.js +292 -0
  47. package/dist/internal/compaction/session-compaction.d.ts +69 -0
  48. package/dist/internal/compaction/session-compaction.js +330 -0
  49. package/dist/internal/compaction/settings.d.ts +11 -0
  50. package/dist/internal/compaction/settings.js +40 -0
  51. package/dist/internal/compaction/utils.d.ts +45 -0
  52. package/dist/internal/compaction/utils.js +319 -0
  53. package/dist/internal/contracts.d.ts +235 -0
  54. package/dist/internal/contracts.js +1 -0
  55. package/dist/internal/coordinator.d.ts +18 -0
  56. package/dist/internal/coordinator.js +362 -0
  57. package/dist/internal/document-codec.d.ts +11 -0
  58. package/dist/internal/document-codec.js +39 -0
  59. package/dist/internal/effect-client.d.ts +13 -0
  60. package/dist/internal/effect-client.js +102 -0
  61. package/dist/internal/effect-contracts.d.ts +236 -0
  62. package/dist/internal/effect-contracts.js +2 -0
  63. package/dist/internal/extension-command-registry.d.ts +11 -0
  64. package/dist/internal/extension-command-registry.js +29 -0
  65. package/dist/internal/extension-command-tools.d.ts +17 -0
  66. package/dist/internal/extension-command-tools.js +50 -0
  67. package/dist/internal/extension-context.d.ts +25 -0
  68. package/dist/internal/extension-context.js +35 -0
  69. package/dist/internal/extension-definitions.d.ts +5 -0
  70. package/dist/internal/extension-definitions.js +6 -0
  71. package/dist/internal/extension-hook.d.ts +25 -0
  72. package/dist/internal/extension-hook.js +46 -0
  73. package/dist/internal/extension-roster.d.ts +23 -0
  74. package/dist/internal/extension-roster.js +228 -0
  75. package/dist/internal/extension-runtime.d.ts +63 -0
  76. package/dist/internal/extension-runtime.js +1004 -0
  77. package/dist/internal/failure.d.ts +2 -0
  78. package/dist/internal/failure.js +9 -0
  79. package/dist/internal/host-meta.d.ts +41 -0
  80. package/dist/internal/host-meta.js +39 -0
  81. package/dist/internal/json-value.d.ts +4 -0
  82. package/dist/internal/json-value.js +3 -0
  83. package/dist/internal/model-acquisition.d.ts +21 -0
  84. package/dist/internal/model-acquisition.js +98 -0
  85. package/dist/internal/model-preference.d.ts +21 -0
  86. package/dist/internal/model-preference.js +20 -0
  87. package/dist/internal/observation-kernel.d.ts +28 -0
  88. package/dist/internal/observation-kernel.js +169 -0
  89. package/dist/internal/promise-facade.d.ts +18 -0
  90. package/dist/internal/promise-facade.js +172 -0
  91. package/dist/internal/run-scope.d.ts +27 -0
  92. package/dist/internal/run-scope.js +214 -0
  93. package/dist/internal/runtime-coordinator.d.ts +34 -0
  94. package/dist/internal/runtime-coordinator.js +233 -0
  95. package/dist/internal/runtime-core.d.ts +19 -0
  96. package/dist/internal/runtime-core.js +39 -0
  97. package/dist/internal/runtime-reconciliation.d.ts +18 -0
  98. package/dist/internal/runtime-reconciliation.js +162 -0
  99. package/dist/internal/session-context.d.ts +11 -0
  100. package/dist/internal/session-context.js +67 -0
  101. package/dist/internal/session-status.d.ts +10 -0
  102. package/dist/internal/session-status.js +52 -0
  103. package/dist/internal/woodstock/agent-reply.d.ts +25 -0
  104. package/dist/internal/woodstock/agent-reply.js +67 -0
  105. package/dist/internal/woodstock/client-projection.d.ts +29 -0
  106. package/dist/internal/woodstock/client-projection.js +512 -0
  107. package/dist/internal/woodstock/compaction-activity.d.ts +17 -0
  108. package/dist/internal/woodstock/compaction-activity.js +32 -0
  109. package/dist/internal/woodstock/cursor.d.ts +9 -0
  110. package/dist/internal/woodstock/cursor.js +44 -0
  111. package/dist/internal/woodstock/extension-store.d.ts +72 -0
  112. package/dist/internal/woodstock/extension-store.js +262 -0
  113. package/dist/internal/woodstock/fleet-store.d.ts +32 -0
  114. package/dist/internal/woodstock/fleet-store.js +93 -0
  115. package/dist/internal/woodstock/identities.d.ts +6 -0
  116. package/dist/internal/woodstock/identities.js +11 -0
  117. package/dist/internal/woodstock/index.d.ts +170 -0
  118. package/dist/internal/woodstock/index.js +546 -0
  119. package/dist/internal/woodstock/progress.d.ts +32 -0
  120. package/dist/internal/woodstock/progress.js +89 -0
  121. package/dist/internal/woodstock/run-recovery.d.ts +8 -0
  122. package/dist/internal/woodstock/run-recovery.js +95 -0
  123. package/dist/internal/woodstock/session-attention.d.ts +16 -0
  124. package/dist/internal/woodstock/session-attention.js +88 -0
  125. package/dist/internal/woodstock/session-documents.d.ts +18 -0
  126. package/dist/internal/woodstock/session-documents.js +51 -0
  127. package/dist/internal/woodstock/session-entry.d.ts +478 -0
  128. package/dist/internal/woodstock/session-entry.js +484 -0
  129. package/dist/internal/woodstock/session-grants.d.ts +24 -0
  130. package/dist/internal/woodstock/session-grants.js +84 -0
  131. package/dist/internal/woodstock/session-inbox.d.ts +56 -0
  132. package/dist/internal/woodstock/session-inbox.js +307 -0
  133. package/dist/internal/woodstock/session-store.d.ts +432 -0
  134. package/dist/internal/woodstock/session-store.js +2006 -0
  135. package/dist/internal/woodstock/storage-admission.d.ts +14 -0
  136. package/dist/internal/woodstock/storage-admission.js +44 -0
  137. package/dist/model-preference.d.ts +20 -0
  138. package/dist/model-preference.js +30 -0
  139. package/dist/node.d.ts +64 -0
  140. package/dist/node.js +256 -0
  141. package/dist/remote-client.d.ts +11 -0
  142. package/dist/remote-client.js +298 -0
  143. package/dist/session-attention.d.ts +35 -0
  144. package/dist/session-attention.js +22 -0
  145. package/dist/session-documents.d.ts +28 -0
  146. package/dist/session-documents.js +1 -0
  147. package/dist/testing.d.ts +54 -0
  148. package/dist/testing.js +215 -0
  149. package/docs/api/README.md +26 -0
  150. package/docs/api/agar-extension.md +40 -0
  151. package/docs/api/agent-control.md +151 -0
  152. package/docs/api/client-entry.md +344 -0
  153. package/docs/api/client.md +1112 -0
  154. package/docs/api/cloudflare.md +500 -0
  155. package/docs/api/effect.md +904 -0
  156. package/docs/api/extensions.md +2003 -0
  157. package/docs/api/fleet.md +706 -0
  158. package/docs/api/hosted.md +382 -0
  159. package/docs/api/http.md +111 -0
  160. package/docs/api/index.md +1116 -0
  161. package/docs/api/model-preference.md +151 -0
  162. package/docs/api/node.md +142 -0
  163. package/docs/api/testing.md +250 -0
  164. package/package.json +130 -3
@@ -0,0 +1,1112 @@
1
+ <!-- Generated by Botanical API docs (TypeDoc + typedoc-plugin-markdown). Do not edit. -->
2
+
3
+ [**@fungi.computer/shiitake**](README.md)
4
+
5
+ ---
6
+
7
+ [@fungi.computer/shiitake](README.md) / client
8
+
9
+ # client
10
+
11
+ ## Type Aliases
12
+
13
+ ### Accepted
14
+
15
+ ```ts
16
+ type Accepted = Readonly<{
17
+ status: "accepted";
18
+ commandId: string;
19
+ }>;
20
+ ```
21
+
22
+ Semantic acknowledgement returned after one durable acceptance commit.
23
+
24
+ ---
25
+
26
+ ### TooLate
27
+
28
+ ```ts
29
+ type TooLate = Readonly<{
30
+ status: "too_late";
31
+ commandId: string;
32
+ }>;
33
+ ```
34
+
35
+ Cancelling found nothing left to cancel: the command is unknown to this Session,
36
+ has already started (for an `onlyIfPending` cancel) or has already settled. It
37
+ is an ordinary outcome, never an error.
38
+
39
+ ---
40
+
41
+ ### CancelResult
42
+
43
+ ```ts
44
+ type CancelResult = Accepted | TooLate;
45
+ ```
46
+
47
+ Outcome of one cancel command.
48
+
49
+ ---
50
+
51
+ ### ForkedSession
52
+
53
+ ```ts
54
+ type ForkedSession = Readonly<{
55
+ sessionId: string;
56
+ }>;
57
+ ```
58
+
59
+ Result returned after a fork commits a new cold-readable Session.
60
+
61
+ ---
62
+
63
+ ### SessionCommandHandler
64
+
65
+ ```ts
66
+ type SessionCommandHandler = {
67
+ (input): Promise<
68
+ Readonly<{
69
+ status: "accepted";
70
+ commandId: string;
71
+ }>
72
+ >;
73
+ (input): Promise<CancelResult>;
74
+ (input): Promise<undefined>;
75
+ (input): Promise<
76
+ Readonly<{
77
+ sessionId: string;
78
+ }>
79
+ >;
80
+ (input): Promise<
81
+ | CancelResult
82
+ | Readonly<{
83
+ sessionId: string;
84
+ }>
85
+ | undefined
86
+ >;
87
+ };
88
+ ```
89
+
90
+ Execute one retained type-discriminated Session command.
91
+
92
+ #### Call Signature
93
+
94
+ ```ts
95
+ (input): Promise<Readonly<{
96
+ status: "accepted";
97
+ commandId: string;
98
+ }>>;
99
+ ```
100
+
101
+ Accept a prompt or a compaction request as queued Session work.
102
+
103
+ ##### Parameters
104
+
105
+ | Parameter | Type |
106
+ | --------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
107
+ | `input` | \| \{ `delivery`: `"followUp"` \| `"steer"`; `requestId`: `string`; `type`: `"prompt"`; `text`: `string`; `images?`: readonly `object`[]; \} \| \{ `type`: `"compact"`; `requestId`: `string`; `instructions?`: `string`; \} |
108
+
109
+ ##### Returns
110
+
111
+ `Promise`\<`Readonly`\<\{ `status`: `"accepted"`; `commandId`: `string`; \}\>\>
112
+
113
+ #### Call Signature
114
+
115
+ ```ts
116
+ (input): Promise<CancelResult>;
117
+ ```
118
+
119
+ Cancel one accepted command, or report that it is too late.
120
+
121
+ ##### Parameters
122
+
123
+ | Parameter | Type |
124
+ | ---------------------- | ----------------------------------------------------------------------------- |
125
+ | `input` | \{ `commandId`: `string`; `onlyIfPending?`: `boolean`; `type`: `"cancel"`; \} |
126
+ | `input.commandId` | `string` |
127
+ | `input.onlyIfPending?` | `boolean` |
128
+ | `input.type` | `"cancel"` |
129
+
130
+ ##### Returns
131
+
132
+ `Promise`\<[`CancelResult`](#cancelresult)\>
133
+
134
+ #### Call Signature
135
+
136
+ ```ts
137
+ (input): Promise<undefined>;
138
+ ```
139
+
140
+ Abort the active run, select a lineage leaf, record an operator line, or set the
141
+ title.
142
+
143
+ ##### Parameters
144
+
145
+ | Parameter | Type |
146
+ | --------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
147
+ | `input` | \| \{ `type`: `"abort"`; \} \| \{ `type`: `"branch"`; `entryId`: `string`; \} \| \{ `type`: `"operator"`; `requestId`: `string`; `author`: `"operator"` \| `"party"`; `text`: `string`; \} \| \{ `type`: `"title"`; `title`: `string` \| `null`; \} |
148
+
149
+ ##### Returns
150
+
151
+ `Promise`\<`undefined`\>
152
+
153
+ #### Call Signature
154
+
155
+ ```ts
156
+ (input): Promise<Readonly<{
157
+ sessionId: string;
158
+ }>>;
159
+ ```
160
+
161
+ Fork one complete entry lineage into a new Session.
162
+
163
+ ##### Parameters
164
+
165
+ | Parameter | Type |
166
+ | --------------- | -------------------------------------------- |
167
+ | `input` | \{ `type`: `"fork"`; `entryId`: `string`; \} |
168
+ | `input.type` | `"fork"` |
169
+ | `input.entryId` | `string` |
170
+
171
+ ##### Returns
172
+
173
+ `Promise`\<`Readonly`\<\{ `sessionId`: `string`; \}\>\>
174
+
175
+ #### Call Signature
176
+
177
+ ```ts
178
+ (input): Promise<
179
+ | CancelResult
180
+ | Readonly<{
181
+ sessionId: string;
182
+ }>
183
+ | undefined>;
184
+ ```
185
+
186
+ Execute an already-decoded command union.
187
+
188
+ ##### Parameters
189
+
190
+ | Parameter | Type |
191
+ | --------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
192
+ | `input` | \| \{ `delivery`: `"followUp"` \| `"steer"`; `requestId`: `string`; `type`: `"prompt"`; `text`: `string`; `images?`: readonly `object`[]; \} \| \{ `type`: `"abort"`; \} \| \{ `commandId`: `string`; `onlyIfPending?`: `boolean`; `type`: `"cancel"`; \} \| \{ `type`: `"branch"`; `entryId`: `string`; \} \| \{ `type`: `"fork"`; `entryId`: `string`; \} \| \{ `type`: `"operator"`; `requestId`: `string`; `author`: `"operator"` \| `"party"`; `text`: `string`; \} \| \{ `type`: `"compact"`; `requestId`: `string`; `instructions?`: `string`; \} \| \{ `type`: `"title"`; `title`: `string` \| `null`; \} |
193
+
194
+ ##### Returns
195
+
196
+ `Promise`\< \| [`CancelResult`](#cancelresult) \| `Readonly`\<\{ `sessionId`:
197
+ `string`; \}\> \| `undefined`\>
198
+
199
+ ---
200
+
201
+ ### SendOptions
202
+
203
+ ```ts
204
+ type SendOptions = Readonly<{
205
+ images?: PromptCommand["images"];
206
+ delivery?: PromptDelivery;
207
+ requestId?: string;
208
+ }>;
209
+ ```
210
+
211
+ Optional controls for the Promise-friendly text sender.
212
+
213
+ ---
214
+
215
+ ### SessionMessage
216
+
217
+ ```ts
218
+ type SessionMessage = Readonly<{
219
+ meta?: Json;
220
+ origin?: Readonly<{
221
+ extensionId: string;
222
+ correlation: string | null;
223
+ }>;
224
+ id: string;
225
+ sequence: number;
226
+ commandId: string | null;
227
+ value: Message;
228
+ }>;
229
+ ```
230
+
231
+ One exact completed Pi message on the selected Session lineage.
232
+
233
+ ---
234
+
235
+ ### ShiitakeEventSourceConstructor
236
+
237
+ ```ts
238
+ type ShiitakeEventSourceConstructor = (
239
+ url,
240
+ ) => Pick<EventTarget, "addEventListener"> &
241
+ Pick<EventSource, "close"> &
242
+ object;
243
+ ```
244
+
245
+ Minimal constructor seam for runtimes without a global EventSource.
246
+
247
+ #### Parameters
248
+
249
+ | Parameter | Type |
250
+ | --------- | -------- |
251
+ | `url` | `string` |
252
+
253
+ #### Returns
254
+
255
+ `Pick`\<`EventTarget`, `"addEventListener"`\> & `Pick`\<`EventSource`,
256
+ `"close"`\> & `object`
257
+
258
+ ---
259
+
260
+ ### SessionTerminal
261
+
262
+ ```ts
263
+ type SessionTerminal = Readonly<{
264
+ commandId: string;
265
+ outcome: "completed" | "cancelled" | "failed" | "interrupted";
266
+ sequence: number;
267
+ diagnostic: string | null;
268
+ meta?: Json;
269
+ }>;
270
+ ```
271
+
272
+ Durable outcome for one accepted work item on the selected Session lineage.
273
+
274
+ ---
275
+
276
+ ### AgentRunningWork
277
+
278
+ ```ts
279
+ type AgentRunningWork =
280
+ | Readonly<{
281
+ kind: "session";
282
+ sessionId: string;
283
+ commandId: string;
284
+ }>
285
+ | Readonly<{
286
+ kind: "host";
287
+ lane: string;
288
+ jobId: string;
289
+ }>;
290
+ ```
291
+
292
+ Work occupying the executor partition that this queued command requires, without
293
+ message or provider data.
294
+
295
+ ---
296
+
297
+ ### SessionActivity
298
+
299
+ ```ts
300
+ type SessionActivity = Readonly<{
301
+ queue:
302
+ | Readonly<{
303
+ state: "idle";
304
+ }>
305
+ | Readonly<{
306
+ state: "queued";
307
+ commandId: string;
308
+ runningWork: AgentRunningWork | null;
309
+ }>
310
+ | Readonly<{
311
+ state: "running";
312
+ commandId: string;
313
+ }>;
314
+ cancellationRequested: boolean;
315
+ retry: Readonly<{
316
+ attempt: number;
317
+ maxAttempts: number;
318
+ delayMs: number;
319
+ errorMessage: string;
320
+ scheduledAt: number;
321
+ }> | null;
322
+ activeTool: string | null;
323
+ lastModelChoiceSequence: number | null;
324
+ compaction: Readonly<{
325
+ trigger: SessionCompactionTrigger;
326
+ }> | null;
327
+ }>;
328
+ ```
329
+
330
+ Raw facts about what a Session is doing now. Shiitake publishes facts only; a
331
+ client decides what they mean (see Parakeet's `sessionViewState`).
332
+
333
+ ---
334
+
335
+ ### SessionExtensionSlots
336
+
337
+ ```ts
338
+ type SessionExtensionSlots = Readonly<Record<string, ExtensionSlotV0>>;
339
+ ```
340
+
341
+ Encoded extension slots keyed by extension identity; absent means unavailable.
342
+
343
+ ---
344
+
345
+ ### SessionExtensionControls
346
+
347
+ ```ts
348
+ type SessionExtensionControls = Readonly<{
349
+ call: (command, input) => Promise<Json>;
350
+ }>;
351
+ ```
352
+
353
+ Generic Session-scope extension commands.
354
+
355
+ ---
356
+
357
+ ### AgentExtensionControls
358
+
359
+ ```ts
360
+ type AgentExtensionControls = Readonly<{
361
+ list: () => Promise<readonly ExtensionStatusV0[]>;
362
+ resume: (extensionId) => Promise<ExtensionStatusV0>;
363
+ call: (extensionId, command, input) => Promise<Json>;
364
+ }>;
365
+ ```
366
+
367
+ Generic Agent-scope extension controls.
368
+
369
+ ---
370
+
371
+ ### SessionProgress
372
+
373
+ ```ts
374
+ type SessionProgress = Readonly<{
375
+ messageId: string;
376
+ revision: number;
377
+ text: string;
378
+ thinking: string;
379
+ textTruncated: boolean;
380
+ thinkingTruncated: boolean;
381
+ }>;
382
+ ```
383
+
384
+ Process-local assistant progress; never a durable Session fact.
385
+
386
+ ---
387
+
388
+ ### SessionPendingPrompt
389
+
390
+ ```ts
391
+ type SessionPendingPrompt = Readonly<{
392
+ meta?: SessionMessage["meta"];
393
+ origin?: SessionMessage["origin"];
394
+ commandId: string;
395
+ text: string;
396
+ images?: PromptCommand["images"];
397
+ delivery: PromptDelivery;
398
+ }>;
399
+ ```
400
+
401
+ Accepted prompt waiting to enter the conversation, not a scheduling command.
402
+
403
+ ---
404
+
405
+ ### SessionPendingPrompts
406
+
407
+ ```ts
408
+ type SessionPendingPrompts = Readonly<{
409
+ total: number;
410
+ prompts: readonly SessionPendingPrompt[];
411
+ hasMore: boolean;
412
+ }>;
413
+ ```
414
+
415
+ Bounded current admission view, in acceptance order rather than execution order.
416
+
417
+ ---
418
+
419
+ ### SessionCompactionMarker
420
+
421
+ ```ts
422
+ type SessionCompactionMarker = Readonly<{
423
+ id: string;
424
+ sequence: number;
425
+ at: number;
426
+ tokensBefore: number;
427
+ tokensAfter: number | null;
428
+ trigger: SessionCompactionTrigger | null;
429
+ }>;
430
+ ```
431
+
432
+ Minimal full-history compaction boundary marker. `sequence` is the Woodstock
433
+ order of the row this marker precedes (ties sort the marker first); `at` is when
434
+ the compaction ran. The agent's model context is unaffected by this marker; it
435
+ exists only for the client timeline.
436
+
437
+ ---
438
+
439
+ ### SessionCompactionTrigger
440
+
441
+ ```ts
442
+ type SessionCompactionTrigger = "manual" | "threshold" | "overflow";
443
+ ```
444
+
445
+ What started a compaction: the user, the context threshold, or an overflow.
446
+
447
+ ---
448
+
449
+ ### SessionCompactionNotice
450
+
451
+ ```ts
452
+ type SessionCompactionNotice = Readonly<{
453
+ id: string;
454
+ sequence: number;
455
+ at: number;
456
+ trigger: SessionCompactionTrigger;
457
+ result: "nothing_to_compact" | "failed";
458
+ diagnostic: string | null;
459
+ }>;
460
+ ```
461
+
462
+ A compaction that changed nothing: a manual request with nothing to summarize
463
+ yet, or a compaction that failed. Automatic failures are never silent; each one
464
+ is a notice at its own place in the timeline.
465
+
466
+ ---
467
+
468
+ ### SessionContext
469
+
470
+ ```ts
471
+ type SessionContext = Readonly<{
472
+ tokens: number;
473
+ window: number | null;
474
+ }>;
475
+ ```
476
+
477
+ The Session's context use as compaction measures it, against the window of the
478
+ model a run would select now; the window is null when that model reports none.
479
+
480
+ ---
481
+
482
+ ### SessionSnapshot
483
+
484
+ ```ts
485
+ type SessionSnapshot = Readonly<{
486
+ sessionId: string;
487
+ cursor: string | null;
488
+ hasMore: boolean;
489
+ oldestCursor?: string | null;
490
+ messages: readonly SessionMessage[];
491
+ terminals: readonly SessionTerminal[];
492
+ compactions?: readonly SessionCompactionMarker[];
493
+ compactionNotices?: readonly SessionCompactionNotice[];
494
+ sandboxFailures?: readonly SandboxFailureEvent[];
495
+ pending: SessionPendingPrompts;
496
+ activity: SessionActivity;
497
+ progress: SessionProgress | null;
498
+ extensions: SessionExtensionSlots;
499
+ attention: readonly SessionAttention[];
500
+ context?: SessionContext;
501
+ }>;
502
+ ```
503
+
504
+ Bounded Session baseline at one opaque owner cursor.
505
+
506
+ ---
507
+
508
+ ### SessionFrame
509
+
510
+ ```ts
511
+ type SessionFrame =
512
+ | Readonly<{
513
+ kind: "update";
514
+ delivery: "replay" | "live";
515
+ cursor: string | null;
516
+ pending: SessionPendingPrompts;
517
+ messages: readonly SessionMessage[];
518
+ terminals: readonly SessionTerminal[];
519
+ compactions?: readonly SessionCompactionMarker[];
520
+ compactionNotices?: readonly SessionCompactionNotice[];
521
+ sandboxFailures?: readonly SandboxFailureEvent[];
522
+ activity: SessionActivity;
523
+ extensions: SessionExtensionSlots;
524
+ attention: readonly SessionAttention[];
525
+ context?: SessionContext;
526
+ }>
527
+ | Readonly<{
528
+ kind: "progress";
529
+ progress: SessionProgress;
530
+ activity: SessionActivity;
531
+ }>
532
+ | Readonly<{
533
+ kind: "reset";
534
+ reason: "history_unavailable";
535
+ cursor: string | null;
536
+ baseline: SessionSnapshot;
537
+ }>;
538
+ ```
539
+
540
+ One bounded replay or live frame.
541
+
542
+ ---
543
+
544
+ ### SubscribeOptions
545
+
546
+ ```ts
547
+ type SubscribeOptions = Readonly<{
548
+ includeSandboxFailures?: boolean;
549
+ after?: string;
550
+ }>;
551
+ ```
552
+
553
+ Strict-after replay request.
554
+
555
+ ---
556
+
557
+ ### ReadOptions
558
+
559
+ ```ts
560
+ type ReadOptions = Readonly<{
561
+ includeSandboxFailures?: boolean;
562
+ limit?: number;
563
+ before?: string;
564
+ }>;
565
+ ```
566
+
567
+ Bounded baseline request.
568
+
569
+ ---
570
+
571
+ ### WatchOptions
572
+
573
+ ```ts
574
+ type WatchOptions = ReadOptions;
575
+ ```
576
+
577
+ Race-safe observation request.
578
+
579
+ ---
580
+
581
+ ### SessionWatch
582
+
583
+ ```ts
584
+ type SessionWatch = Readonly<{
585
+ snapshot: SessionSnapshot;
586
+ changes: AsyncIterable<SessionFrame>;
587
+ close: () => Promise<void>;
588
+ }>;
589
+ ```
590
+
591
+ Race-safe baseline plus live changes resource.
592
+
593
+ ---
594
+
595
+ ### ShiitakeSession
596
+
597
+ ```ts
598
+ type ShiitakeSession = Readonly<{
599
+ address: string;
600
+ command: SessionCommandHandler;
601
+ abort: () => Promise<void>;
602
+ send: (text, options?) => Promise<Accepted>;
603
+ cancel: (input) => Promise<CancelResult>;
604
+ extension: (extensionId) => SessionExtensionControls;
605
+ modelPreference: Readonly<{
606
+ read: () => Promise<ModelPreference | null>;
607
+ set: (preference) => Promise<void>;
608
+ }>;
609
+ read: (input?) => Promise<SessionSnapshot>;
610
+ subscribe: (input) => AsyncIterable<SessionFrame>;
611
+ watch: (input?) => Promise<SessionWatch>;
612
+ }>;
613
+ ```
614
+
615
+ Addressable Session interface. Addressing itself performs no I/O.
616
+
617
+ ---
618
+
619
+ ### SessionInboxState
620
+
621
+ ```ts
622
+ type SessionInboxState = "needs_you" | "running" | "errored" | "done";
623
+ ```
624
+
625
+ Owner-decided inbox state, from Watchdog's queue head and latest outcome.
626
+ `running` covers queued, thinking, streaming, retrying and cancelling; `errored`
627
+ covers failed, interrupted and `outcome_unknown`; `done` covers completed,
628
+ cancelled and never run. Any open extension attention produces `needs_you`,
629
+ taking priority over live and settled work.
630
+
631
+ ---
632
+
633
+ ### SessionSummary
634
+
635
+ ```ts
636
+ type SessionSummary = Readonly<{
637
+ createdAt: number;
638
+ lastActivityAt: number;
639
+ settledAt?: number;
640
+ title: string;
641
+ state: SessionInboxState;
642
+ }>;
643
+ ```
644
+
645
+ Read-only saved conversation projection; opening does not update recency.
646
+
647
+ ---
648
+
649
+ ### SessionSummaryRow
650
+
651
+ ```ts
652
+ type SessionSummaryRow =
653
+ | (SessionSummary &
654
+ Readonly<{
655
+ sessionId: string;
656
+ }>)
657
+ | Readonly<{
658
+ sessionId: string;
659
+ state: "unavailable";
660
+ }>;
661
+ ```
662
+
663
+ One listed conversation, or a saved Session its owner could not read.
664
+
665
+ ---
666
+
667
+ ### SessionSummaryPage
668
+
669
+ ```ts
670
+ type SessionSummaryPage = Readonly<{
671
+ sessions: readonly SessionSummaryRow[];
672
+ next: string | undefined;
673
+ }>;
674
+ ```
675
+
676
+ One owner-bounded page: `needs_you`, then `running`, then settled rows, each
677
+ newest activity first. `next` is an opaque owner cursor.
678
+
679
+ ---
680
+
681
+ ### ShiitakeAgent
682
+
683
+ ```ts
684
+ type ShiitakeAgent = Readonly<{
685
+ createSession: (requestId) => Promise<string>;
686
+ deleteSession: (sessionId) => Promise<boolean>;
687
+ listSessions: (after?) => Promise<SessionSummaryPage>;
688
+ extensions: AgentExtensionControls;
689
+ session: (sessionId) => ShiitakeSession;
690
+ close: () => Promise<void>;
691
+ }>;
692
+ ```
693
+
694
+ Constructed durable harness.
695
+
696
+ ---
697
+
698
+ ### ExtensionViewV0
699
+
700
+ ```ts
701
+ type ExtensionViewV0<P> =
702
+ | Readonly<{
703
+ status: "unavailable";
704
+ }>
705
+ | Readonly<{
706
+ status: "stopped";
707
+ reason: string;
708
+ }>
709
+ | Readonly<{
710
+ status: "running";
711
+ value: P | null;
712
+ }>;
713
+ ```
714
+
715
+ What one client sees of an extension in a Session observation.
716
+
717
+ #### Type Parameters
718
+
719
+ | Type Parameter |
720
+ | -------------- |
721
+ | `P` |
722
+
723
+ ---
724
+
725
+ ### ScopedCommandsV0
726
+
727
+ ```ts
728
+ type ScopedCommandsV0<C, S> = {
729
+ [K in keyof C & string]: C[K]["scope"] extends S ? K : never;
730
+ }[keyof C & string];
731
+ ```
732
+
733
+ Command names of one scope, typed by the shared contract.
734
+
735
+ #### Type Parameters
736
+
737
+ | Type Parameter |
738
+ | ------------------------------------------------------ |
739
+ | `C` _extends_ [`CommandsV0`](extensions.md#commandsv0) |
740
+ | `S` _extends_ `"session"` \| `"agent"` |
741
+
742
+ ---
743
+
744
+ ### BoundCallV0
745
+
746
+ ```ts
747
+ type BoundCallV0<C, S> = <K>(name, input) => Promise<C[K]["output"]["Type"]>;
748
+ ```
749
+
750
+ Typed call surface of one contract's commands in one scope.
751
+
752
+ #### Type Parameters
753
+
754
+ | Type Parameter |
755
+ | ------------------------------------------------------ |
756
+ | `C` _extends_ [`CommandsV0`](extensions.md#commandsv0) |
757
+ | `S` _extends_ `"session"` \| `"agent"` |
758
+
759
+ #### Type Parameters
760
+
761
+ | Type Parameter |
762
+ | ----------------------------------------------------------------- |
763
+ | `K` _extends_ [`ScopedCommandsV0`](#scopedcommandsv0)\<`C`, `S`\> |
764
+
765
+ #### Parameters
766
+
767
+ | Parameter | Type |
768
+ | --------- | ----------------------------------- |
769
+ | `name` | `K` |
770
+ | `input` | `C`\[`K`\]\[`"input"`\]\[`"Type"`\] |
771
+
772
+ #### Returns
773
+
774
+ `Promise`\<`C`\[`K`\]\[`"output"`\]\[`"Type"`\]\>
775
+
776
+ ---
777
+
778
+ ### BoundSessionExtensionV0
779
+
780
+ ```ts
781
+ type BoundSessionExtensionV0<C, P> = Readonly<{
782
+ view: (observation) => ExtensionViewV0<P>;
783
+ call: BoundCallV0<C, "session">;
784
+ }>;
785
+ ```
786
+
787
+ One Session bound to one extension contract.
788
+
789
+ #### Type Parameters
790
+
791
+ | Type Parameter |
792
+ | ------------------------------------------------------ |
793
+ | `C` _extends_ [`CommandsV0`](extensions.md#commandsv0) |
794
+ | `P` |
795
+
796
+ ---
797
+
798
+ ### BoundAgentExtensionV0
799
+
800
+ ```ts
801
+ type BoundAgentExtensionV0<C> = Readonly<{
802
+ call: BoundCallV0<C, "agent">;
803
+ }>;
804
+ ```
805
+
806
+ One Agent bound to one extension contract.
807
+
808
+ #### Type Parameters
809
+
810
+ | Type Parameter |
811
+ | ------------------------------------------------------ |
812
+ | `C` _extends_ [`CommandsV0`](extensions.md#commandsv0) |
813
+
814
+ ---
815
+
816
+ ### OperatorCommand
817
+
818
+ ```ts
819
+ type OperatorCommand = Extract<
820
+ SessionCommand,
821
+ Readonly<{
822
+ type: "operator";
823
+ }>
824
+ >;
825
+ ```
826
+
827
+ Public command that records one operator or party line without a run.
828
+
829
+ ---
830
+
831
+ ### TitleCommand
832
+
833
+ ```ts
834
+ type TitleCommand = Extract<
835
+ SessionCommand,
836
+ Readonly<{
837
+ type: "title";
838
+ }>
839
+ >;
840
+ ```
841
+
842
+ Public command that sets or clears the user's Session title.
843
+
844
+ ---
845
+
846
+ ### ShiitakeClientOptions
847
+
848
+ ```ts
849
+ type ShiitakeClientOptions = Readonly<{
850
+ baseUrl: string;
851
+ fetch?: typeof globalThis.fetch;
852
+ eventSource?: ShiitakeEventSourceConstructor;
853
+ }>;
854
+ ```
855
+
856
+ Network location of one remotely hosted Shiitake agent.
857
+
858
+ ---
859
+
860
+ ### SessionAttention
861
+
862
+ ```ts
863
+ type SessionAttention = typeof SessionAttentionSchema.Type;
864
+ ```
865
+
866
+ One open attention item in a Session observation.
867
+
868
+ ## Variables
869
+
870
+ ### AcceptedSchema
871
+
872
+ ```ts
873
+ const AcceptedSchema: Schema.Codec<Accepted>;
874
+ ```
875
+
876
+ Decode a durable command acceptance value at an RPC boundary.
877
+
878
+ ## Functions
879
+
880
+ ### parseAccepted()
881
+
882
+ ```ts
883
+ function parseAccepted(value): Accepted;
884
+ ```
885
+
886
+ Parse one serialized command acceptance using Shiitake's public grammar.
887
+
888
+ #### Parameters
889
+
890
+ | Parameter | Type |
891
+ | --------- | -------- |
892
+ | `value` | `string` |
893
+
894
+ #### Returns
895
+
896
+ [`Accepted`](#accepted)
897
+
898
+ ---
899
+
900
+ ### parseCancelResult()
901
+
902
+ ```ts
903
+ function parseCancelResult(value): CancelResult;
904
+ ```
905
+
906
+ Parse one serialized cancel outcome: accepted, or too late.
907
+
908
+ #### Parameters
909
+
910
+ | Parameter | Type |
911
+ | --------- | -------- |
912
+ | `value` | `string` |
913
+
914
+ #### Returns
915
+
916
+ [`CancelResult`](#cancelresult)
917
+
918
+ ---
919
+
920
+ ### parseShiitakeError()
921
+
922
+ ```ts
923
+ function parseShiitakeError(value): ShiitakeError;
924
+ ```
925
+
926
+ Parse one serialized canonical Shiitake failure.
927
+
928
+ #### Parameters
929
+
930
+ | Parameter | Type |
931
+ | --------- | -------- |
932
+ | `value` | `string` |
933
+
934
+ #### Returns
935
+
936
+ [`ShiitakeError`](index.md#shiitakeerror)
937
+
938
+ ---
939
+
940
+ ### parseSessionSummaryPage()
941
+
942
+ ```ts
943
+ function parseSessionSummaryPage(value): SessionSummaryPage;
944
+ ```
945
+
946
+ Decode the existing bounded saved-conversation projection.
947
+
948
+ #### Parameters
949
+
950
+ | Parameter | Type |
951
+ | --------- | -------- |
952
+ | `value` | `string` |
953
+
954
+ #### Returns
955
+
956
+ [`SessionSummaryPage`](#sessionsummarypage)
957
+
958
+ ---
959
+
960
+ ### bindSessionExtension()
961
+
962
+ ```ts
963
+ function bindSessionExtension<C, P, PI>(
964
+ session,
965
+ contract,
966
+ ): BoundSessionExtensionV0<C, P>;
967
+ ```
968
+
969
+ Bind one Session to one extension contract; the contract's schemas decode.
970
+
971
+ #### Type Parameters
972
+
973
+ | Type Parameter |
974
+ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
975
+ | `C` _extends_ `Readonly`\<`Record`\<`string`, `Readonly`\<\{ `scope`: `"session"` \| `"agent"`; `input`: `Codec`\<`unknown`\>; `output`: `Codec`\<`unknown`\>; \}\>\>\> |
976
+ | `P` |
977
+ | `PI` |
978
+
979
+ #### Parameters
980
+
981
+ | Parameter | Type |
982
+ | ---------- | ---------------------------------------------------------------------------- |
983
+ | `session` | `Pick`\<[`ShiitakeSession`](#shiitakesession), `"extension"`\> |
984
+ | `contract` | [`ExtensionContractV0`](extensions.md#extensioncontractv0)\<`C`, `P`, `PI`\> |
985
+
986
+ #### Returns
987
+
988
+ [`BoundSessionExtensionV0`](#boundsessionextensionv0)\<`C`, `P`\>
989
+
990
+ ---
991
+
992
+ ### bindAgentExtension()
993
+
994
+ ```ts
995
+ function bindAgentExtension<C, P, PI>(
996
+ agent,
997
+ contract,
998
+ ): BoundAgentExtensionV0<C>;
999
+ ```
1000
+
1001
+ Bind one Agent to one extension contract's Agent-scope commands.
1002
+
1003
+ #### Type Parameters
1004
+
1005
+ | Type Parameter |
1006
+ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
1007
+ | `C` _extends_ `Readonly`\<`Record`\<`string`, `Readonly`\<\{ `scope`: `"session"` \| `"agent"`; `input`: `Codec`\<`unknown`\>; `output`: `Codec`\<`unknown`\>; \}\>\>\> |
1008
+ | `P` |
1009
+ | `PI` |
1010
+
1011
+ #### Parameters
1012
+
1013
+ | Parameter | Type |
1014
+ | ---------- | ---------------------------------------------------------------------------- |
1015
+ | `agent` | `Pick`\<[`ShiitakeAgent`](#shiitakeagent), `"extensions"`\> |
1016
+ | `contract` | [`ExtensionContractV0`](extensions.md#extensioncontractv0)\<`C`, `P`, `PI`\> |
1017
+
1018
+ #### Returns
1019
+
1020
+ [`BoundAgentExtensionV0`](#boundagentextensionv0)\<`C`\>
1021
+
1022
+ ---
1023
+
1024
+ ### createShiitakeClient()
1025
+
1026
+ ```ts
1027
+ function createShiitakeClient(options): ShiitakeAgent;
1028
+ ```
1029
+
1030
+ Connect to a remotely hosted Shiitake agent.
1031
+
1032
+ #### Parameters
1033
+
1034
+ | Parameter | Type |
1035
+ | --------- | ------------------------------------------------- |
1036
+ | `options` | [`ShiitakeClientOptions`](#shiitakeclientoptions) |
1037
+
1038
+ #### Returns
1039
+
1040
+ [`ShiitakeAgent`](#shiitakeagent)
1041
+
1042
+ ## References
1043
+
1044
+ ### parseForkedSession
1045
+
1046
+ Re-exports [parseForkedSession](index.md#parseforkedsession)
1047
+
1048
+ ---
1049
+
1050
+ ### parseSessionFrame
1051
+
1052
+ Re-exports [parseSessionFrame](index.md#parsesessionframe)
1053
+
1054
+ ---
1055
+
1056
+ ### parseSessionSnapshot
1057
+
1058
+ Re-exports [parseSessionSnapshot](index.md#parsesessionsnapshot)
1059
+
1060
+ ---
1061
+
1062
+ ### AbortCommand
1063
+
1064
+ Re-exports [AbortCommand](index.md#abortcommand)
1065
+
1066
+ ---
1067
+
1068
+ ### BranchCommand
1069
+
1070
+ Re-exports [BranchCommand](index.md#branchcommand)
1071
+
1072
+ ---
1073
+
1074
+ ### CompactCommand
1075
+
1076
+ Re-exports [CompactCommand](index.md#compactcommand)
1077
+
1078
+ ---
1079
+
1080
+ ### CancelCommand
1081
+
1082
+ Re-exports [CancelCommand](index.md#cancelcommand)
1083
+
1084
+ ---
1085
+
1086
+ ### ForkCommand
1087
+
1088
+ Re-exports [ForkCommand](index.md#forkcommand)
1089
+
1090
+ ---
1091
+
1092
+ ### PromptCommand
1093
+
1094
+ Re-exports [PromptCommand](index.md#promptcommand)
1095
+
1096
+ ---
1097
+
1098
+ ### PromptDelivery
1099
+
1100
+ Re-exports [PromptDelivery](index.md#promptdelivery)
1101
+
1102
+ ---
1103
+
1104
+ ### SessionCommand
1105
+
1106
+ Re-exports [SessionCommand](index.md#sessioncommand)
1107
+
1108
+ ---
1109
+
1110
+ ### ModelPreference
1111
+
1112
+ Re-exports [ModelPreference](index.md#modelpreference)