@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,2003 @@
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) / extensions
8
+
9
+ # extensions
10
+
11
+ ## Classes
12
+
13
+ ### ExtensionRead
14
+
15
+ Present only inside a core-run read (projection, run tools, hooks).
16
+
17
+ #### Extends
18
+
19
+ - `Shape`\<`"@fungi.computer/shiitake/ExtensionRead"`, `Readonly`\<\{
20
+ `extensionId`: `string` & `Brand`\<`"ExtensionId"`\>; \}\>, `this`\>
21
+
22
+ #### Constructors
23
+
24
+ ##### Constructor
25
+
26
+ ```ts
27
+ new ExtensionRead(_): ExtensionRead;
28
+ ```
29
+
30
+ ###### Parameters
31
+
32
+ | Parameter | Type |
33
+ | --------- | ------- |
34
+ | `_` | `never` |
35
+
36
+ ###### Returns
37
+
38
+ [`ExtensionRead`](#extensionread)
39
+
40
+ ###### Inherited from
41
+
42
+ ```ts
43
+ Context.Service<ExtensionRead, Readonly<{ extensionId: ExtensionId }>>()(
44
+ "@fungi.computer/shiitake/ExtensionRead",
45
+ ).constructor;
46
+ ```
47
+
48
+ ---
49
+
50
+ ### ExtensionTx
51
+
52
+ Present only inside a core-run write transaction (hooks, commands, `transact`).
53
+ Core runs these Effects synchronously inside the owner transaction; an
54
+ asynchronous boundary is a defect that stops the extension.
55
+
56
+ #### Extends
57
+
58
+ - `Shape`\<`"@fungi.computer/shiitake/ExtensionTx"`, `Readonly`\<\{
59
+ `extensionId`: `string` & `Brand`\<`"ExtensionId"`\>; \}\>, `this`\>
60
+
61
+ #### Constructors
62
+
63
+ ##### Constructor
64
+
65
+ ```ts
66
+ new ExtensionTx(_): ExtensionTx;
67
+ ```
68
+
69
+ ###### Parameters
70
+
71
+ | Parameter | Type |
72
+ | --------- | ------- |
73
+ | `_` | `never` |
74
+
75
+ ###### Returns
76
+
77
+ [`ExtensionTx`](#extensiontx)
78
+
79
+ ###### Inherited from
80
+
81
+ ```ts
82
+ Context.Service<ExtensionTx, Readonly<{ extensionId: ExtensionId }>>()(
83
+ "@fungi.computer/shiitake/ExtensionTx",
84
+ ).constructor;
85
+ ```
86
+
87
+ ---
88
+
89
+ ### ExtensionStateError
90
+
91
+ Durable record failure: stored or supplied values broke their schema or bounds.
92
+
93
+ #### Extends
94
+
95
+ - `YieldableError`\<`this`\> & `object` & `Readonly`\<\{ `reason`:
96
+ `"unavailable"` \| `"decode"` \| `"encode"` \| `"bound"`; `message`: `string`;
97
+ \}\>
98
+
99
+ #### Constructors
100
+
101
+ ##### Constructor
102
+
103
+ ```ts
104
+ new ExtensionStateError(args): ExtensionStateError;
105
+ ```
106
+
107
+ ###### Parameters
108
+
109
+ | Parameter | Type |
110
+ | -------------- | ---------------------------------------------------------------------------------------------- |
111
+ | `args` | \{ `reason`: `"unavailable"` \| `"decode"` \| `"encode"` \| `"bound"`; `message`: `string`; \} |
112
+ | `args.reason` | `"unavailable"` \| `"decode"` \| `"encode"` \| `"bound"` |
113
+ | `args.message` | `string` |
114
+
115
+ ###### Returns
116
+
117
+ [`ExtensionStateError`](#extensionstateerror)
118
+
119
+ ###### Inherited from
120
+
121
+ ```ts
122
+ Data.TaggedError(
123
+ "ExtensionStateError",
124
+ )<{
125
+ reason: "decode" | "encode" | "bound" | "unavailable";
126
+ message: string;
127
+ }>.constructor
128
+ ```
129
+
130
+ #### Properties
131
+
132
+ ##### reason
133
+
134
+ ```ts
135
+ readonly reason: "unavailable" | "decode" | "encode" | "bound";
136
+ ```
137
+
138
+ ###### Inherited from
139
+
140
+ ```ts
141
+ Data.TaggedError("ExtensionStateError").reason;
142
+ ```
143
+
144
+ ##### message
145
+
146
+ ```ts
147
+ message: string;
148
+ ```
149
+
150
+ ###### Inherited from
151
+
152
+ ```ts
153
+ Data.TaggedError("ExtensionStateError").message;
154
+ ```
155
+
156
+ ---
157
+
158
+ ### AdmissionError
159
+
160
+ The door refused an extension admission.
161
+
162
+ #### Extends
163
+
164
+ - `YieldableError`\<`this`\> & `object` & `Readonly`\<\{ `reason`: `"closed"` \|
165
+ `"conflict"` \| `"invalid"`; `message`: `string`; \}\>
166
+
167
+ #### Constructors
168
+
169
+ ##### Constructor
170
+
171
+ ```ts
172
+ new AdmissionError(args): AdmissionError;
173
+ ```
174
+
175
+ ###### Parameters
176
+
177
+ | Parameter | Type |
178
+ | -------------- | ------------------------------------------------------------------------------- |
179
+ | `args` | \{ `reason`: `"closed"` \| `"conflict"` \| `"invalid"`; `message`: `string`; \} |
180
+ | `args.reason` | `"closed"` \| `"conflict"` \| `"invalid"` |
181
+ | `args.message` | `string` |
182
+
183
+ ###### Returns
184
+
185
+ [`AdmissionError`](#admissionerror)
186
+
187
+ ###### Inherited from
188
+
189
+ ```ts
190
+ Data.TaggedError("AdmissionError")<{
191
+ reason: "invalid" | "conflict" | "closed";
192
+ message: string;
193
+ }>.constructor
194
+ ```
195
+
196
+ #### Properties
197
+
198
+ ##### reason
199
+
200
+ ```ts
201
+ readonly reason: "closed" | "conflict" | "invalid";
202
+ ```
203
+
204
+ ###### Inherited from
205
+
206
+ ```ts
207
+ Data.TaggedError("AdmissionError").reason;
208
+ ```
209
+
210
+ ##### message
211
+
212
+ ```ts
213
+ message: string;
214
+ ```
215
+
216
+ ###### Inherited from
217
+
218
+ ```ts
219
+ Data.TaggedError("AdmissionError").message;
220
+ ```
221
+
222
+ ---
223
+
224
+ ### ExtensionCommandError
225
+
226
+ Typed rejection of one extension command, returned to its caller.
227
+
228
+ #### Extends
229
+
230
+ - `YieldableError`\<`this`\> & `object` & `Readonly`\<\{ `reason`: `"conflict"`
231
+ \| `"invalid"` \| `"rejected"` \| `"not_found"`; `message`: `string`; \}\>
232
+
233
+ #### Constructors
234
+
235
+ ##### Constructor
236
+
237
+ ```ts
238
+ new ExtensionCommandError(args): ExtensionCommandError;
239
+ ```
240
+
241
+ ###### Parameters
242
+
243
+ | Parameter | Type |
244
+ | -------------- | -------------------------------------------------------------------------------------------------- |
245
+ | `args` | \{ `reason`: `"conflict"` \| `"invalid"` \| `"rejected"` \| `"not_found"`; `message`: `string`; \} |
246
+ | `args.reason` | `"conflict"` \| `"invalid"` \| `"rejected"` \| `"not_found"` |
247
+ | `args.message` | `string` |
248
+
249
+ ###### Returns
250
+
251
+ [`ExtensionCommandError`](#extensioncommanderror)
252
+
253
+ ###### Inherited from
254
+
255
+ ```ts
256
+ Data.TaggedError(
257
+ "ExtensionCommandError",
258
+ )<{
259
+ reason: "invalid" | "conflict" | "not_found" | "rejected";
260
+ message: string;
261
+ }>.constructor
262
+ ```
263
+
264
+ #### Properties
265
+
266
+ ##### reason
267
+
268
+ ```ts
269
+ readonly reason: "conflict" | "invalid" | "rejected" | "not_found";
270
+ ```
271
+
272
+ ###### Inherited from
273
+
274
+ ```ts
275
+ Data.TaggedError("ExtensionCommandError").reason;
276
+ ```
277
+
278
+ ##### message
279
+
280
+ ```ts
281
+ message: string;
282
+ ```
283
+
284
+ ###### Inherited from
285
+
286
+ ```ts
287
+ Data.TaggedError("ExtensionCommandError").message;
288
+ ```
289
+
290
+ ---
291
+
292
+ ### ExtensionStop
293
+
294
+ Fail a hook with this (or die) to stop this extension with a visible reason.
295
+
296
+ #### Extends
297
+
298
+ - `YieldableError`\<`this`\> & `object` & `Readonly`\<\{ `reason`: `string`;
299
+ \}\>
300
+
301
+ #### Constructors
302
+
303
+ ##### Constructor
304
+
305
+ ```ts
306
+ new ExtensionStop(args): ExtensionStop;
307
+ ```
308
+
309
+ ###### Parameters
310
+
311
+ | Parameter | Type |
312
+ | ------------- | ------------------------- |
313
+ | `args` | \{ `reason`: `string`; \} |
314
+ | `args.reason` | `string` |
315
+
316
+ ###### Returns
317
+
318
+ [`ExtensionStop`](#extensionstop)
319
+
320
+ ###### Inherited from
321
+
322
+ ```ts
323
+ Data.TaggedError("ExtensionStop")<{
324
+ reason: string;
325
+ }>.constructor
326
+ ```
327
+
328
+ #### Properties
329
+
330
+ ##### reason
331
+
332
+ ```ts
333
+ readonly reason: string;
334
+ ```
335
+
336
+ ###### Inherited from
337
+
338
+ ```ts
339
+ Data.TaggedError("ExtensionStop").reason;
340
+ ```
341
+
342
+ ---
343
+
344
+ ### ExtensionActivationError
345
+
346
+ Typed activation failure; the extension is stopped with this message.
347
+
348
+ #### Extends
349
+
350
+ - `YieldableError`\<`this`\> & `object` & `Readonly`\<\{ `message`: `string`;
351
+ \}\>
352
+
353
+ #### Constructors
354
+
355
+ ##### Constructor
356
+
357
+ ```ts
358
+ new ExtensionActivationError(args): ExtensionActivationError;
359
+ ```
360
+
361
+ ###### Parameters
362
+
363
+ | Parameter | Type |
364
+ | -------------- | -------------------------- |
365
+ | `args` | \{ `message`: `string`; \} |
366
+ | `args.message` | `string` |
367
+
368
+ ###### Returns
369
+
370
+ [`ExtensionActivationError`](#extensionactivationerror)
371
+
372
+ ###### Inherited from
373
+
374
+ ```ts
375
+ Data.TaggedError(
376
+ "ExtensionActivationError",
377
+ )<{ message: string }>.constructor
378
+ ```
379
+
380
+ #### Properties
381
+
382
+ ##### message
383
+
384
+ ```ts
385
+ message: string;
386
+ ```
387
+
388
+ ###### Inherited from
389
+
390
+ ```ts
391
+ Data.TaggedError("ExtensionActivationError").message;
392
+ ```
393
+
394
+ ---
395
+
396
+ ### ExtensionBuilderV0
397
+
398
+ Configure typed metadata, then register callbacks against its actual values.
399
+
400
+ #### Type Parameters
401
+
402
+ | Type Parameter |
403
+ | --------------------------------------------------- |
404
+ | `S` _extends_ [`CollectionsV0`](#collectionsv0) |
405
+ | `Config` _extends_ [`Json`](#json) |
406
+ | `D` _extends_ [`DocumentsV0`](index.md#documentsv0) |
407
+
408
+ #### Methods
409
+
410
+ ##### fromIdentity()
411
+
412
+ ```ts
413
+ static fromIdentity(identity): ExtensionBuilderV0<Readonly<Record<never, never>>, Readonly<Record<never, never>>, Readonly<Record<never, never>>>;
414
+ ```
415
+
416
+ Begin with concrete empty metadata and no requested capability.
417
+
418
+ ###### Parameters
419
+
420
+ | Parameter | Type |
421
+ | ---------- | ------------------------------------------------------------------------------- |
422
+ | `identity` | `Readonly`\<\{ `id`: [`ExtensionId`](#extensionid-1); `version`: `string`; \}\> |
423
+
424
+ ###### Returns
425
+
426
+ [`ExtensionBuilderV0`](#extensionbuilderv0)\<`Readonly`\<`Record`\<`never`,
427
+ `never`\>\>, `Readonly`\<`Record`\<`never`, `never`\>\>,
428
+ `Readonly`\<`Record`\<`never`, `never`\>\>\>
429
+
430
+ ##### config()
431
+
432
+ ```ts
433
+ config<Next>(value): ExtensionBuilderV0<S, Next, D>;
434
+ ```
435
+
436
+ Hash this explicit JSON configuration with the extension revision.
437
+
438
+ ###### Type Parameters
439
+
440
+ | Type Parameter |
441
+ | -------------------------------- |
442
+ | `Next` _extends_ [`Json`](#json) |
443
+
444
+ ###### Parameters
445
+
446
+ | Parameter | Type |
447
+ | --------- | ------ |
448
+ | `value` | `Next` |
449
+
450
+ ###### Returns
451
+
452
+ [`ExtensionBuilderV0`](#extensionbuilderv0)\<`S`, `Next`, `D`\>
453
+
454
+ ##### state()
455
+
456
+ ```ts
457
+ state<Next>(value): ExtensionBuilderV0<Next, Config, D>;
458
+ ```
459
+
460
+ Request state and bind handles to each collection's declared schema. Pass the
461
+ collections alone (state version 1, no migrations) or the full versioned
462
+ declaration.
463
+
464
+ ###### Type Parameters
465
+
466
+ | Type Parameter |
467
+ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
468
+ | `Next` _extends_ `Readonly`\<`Record`\<`string`, `Readonly`\<\{ `schema`: `Codec`\<`unknown`\>; `bind`: (`port`, `name`) => [`CollectionBindingV0`](#collectionbindingv0); `indexFromEncoded`: (`value`) => `Result`\<`string` \| `null`, `SchemaError`\>; `key`: (`value`) => `string`; `index?`: (`value`) => `string` \| `null`; \}\>\>\> |
469
+
470
+ ###### Parameters
471
+
472
+ | Parameter | Type |
473
+ | --------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
474
+ | `value` | \| `Next` \| `Readonly`\<\{ `version?`: `number`; `collections`: `Next`; `migrations?`: `Readonly`\<`Record`\<`number`, (`row`) => readonly `Readonly`\<\{ `collection`: `string`; `key`: `string`; `value`: [`Json`](#json); \}\>[]\>\>; \}\> |
475
+
476
+ ###### Returns
477
+
478
+ [`ExtensionBuilderV0`](#extensionbuilderv0)\<`Next`, `Config`, `D`\>
479
+
480
+ ##### documents()
481
+
482
+ ```ts
483
+ documents<Next>(value): ExtensionBuilderV0<S, Config, Next>;
484
+ ```
485
+
486
+ Request bounded Session documents under the state grant.
487
+
488
+ ###### Type Parameters
489
+
490
+ | Type Parameter |
491
+ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
492
+ | `Next` _extends_ `Readonly`\<`Record`\<`string`, `Readonly`\<\{ `schema`: `Codec`\<`unknown`\>; `initial`: `unknown`; `fork`: [`DocumentForkPolicyV0`](index.md#documentforkpolicyv0); `maxBytes`: `number`; \}\>\>\> |
493
+
494
+ ###### Parameters
495
+
496
+ | Parameter | Type |
497
+ | --------- | ------ |
498
+ | `value` | `Next` |
499
+
500
+ ###### Returns
501
+
502
+ [`ExtensionBuilderV0`](#extensionbuilderv0)\<`S`, `Config`, `Next`\>
503
+
504
+ ##### define()
505
+
506
+ ###### Call Signature
507
+
508
+ ```ts
509
+ define<C, P, PI, H>(definition): DefinedExtensionV0<C, P, PI>;
510
+ ```
511
+
512
+ Register commands without a client entry.
513
+
514
+ ###### Type Parameters
515
+
516
+ | Type Parameter | Default type |
517
+ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------ |
518
+ | `C` _extends_ `Readonly`\<`Record`\<`string`, `Readonly`\<\{ `scope`: `"session"` \| `"agent"`; `input`: `Codec`\<`unknown`\>; `output`: `Codec`\<`unknown`\>; \}\>\>\> | - |
519
+ | `P` | - |
520
+ | `PI` | - |
521
+ | `H` _extends_ [`CommandHandlersV0`](#commandhandlersv0)\<`C`\> | [`CommandHandlersV0`](#commandhandlersv0)\<`C`\> |
522
+
523
+ ###### Parameters
524
+
525
+ | Parameter | Type |
526
+ | ------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
527
+ | `definition` | `Omit`\<`Readonly`\<\{ `catalog?`: [`Json`](#json); `commands?`: `Readonly`\<\{ `specs`: `C`; `handlers`: (`context`) => [`CommandHandlersV0`](#commandhandlersv0)\<`C`\>; \}\>; `projection?`: `Readonly`\<\{ `schema`: `Codec`\<`P`, `PI`\>; `catalog?`: (`value`) => [`Json`](#json); `read`: (`context`, `sessionId`) => `P` \| `Option`\<`P`\> \| `undefined`; \}\>; `prompt?`: (`context`, `run`) => \| readonly `Readonly`\<\{ `name`: `string`; `text`: `string`; \}\>[] \| `Promise`\<readonly `Readonly`\<\{ `name`: ...; `text`: ...; \}\>[]\> \| `Effect`\<readonly `Readonly`\<\{ `name`: ...; `text`: ...; \}\>[], [`HookError`](#hookerror), [`ExtensionRead`](#extensionread)\>; `tools?`: (`context`, `run`, `commands`) => \| `Readonly`\<\{ `[moduleBrand]`: `true`; \}\> \| `Promise`\< \| `Readonly`\<\{ `[moduleBrand]`: ...; \}\> \| `null`\> \| `Effect`\< \| `Readonly`\<\{ `[moduleBrand]`: ...; \}\> \| `Option`\<`Readonly`\<...\>\> \| `null`, [`HookError`](#hookerror), [`ExtensionRead`](#extensionread)\> \| `null`; `files?`: (`context`, `run`) => \| readonly `FileTool`[] \| `Promise`\<readonly `FileTool`[] \| `null`\> \| `Effect`\<readonly `FileTool`[] \| `Option`\<readonly ...[]\> \| `null`, [`HookError`](#hookerror), [`ExtensionRead`](#extensionread)\> \| `null`; `hooks?`: `Readonly`\<\{ `start?`: (`context`) => `void` \| `Promise`\<...\> \| `Effect`\<..., ..., ...\>; `onSettled?`: (`context`, `page`) => `void` \| `Effect`\<..., ..., ...\>; `onTimer?`: (`context`, `timer`) => `void` \| `Effect`\<..., ..., ...\>; \}\>; `timers?`: `true`; `attention?`: `true`; `compaction?`: (`context`) => `Readonly`\<\{ `consume`: (`view`) => \| [`CompactionHandoffResultV0`](#compactionhandoffresultv0) \| `Promise`\<...\> \| `Effect.Effect`\<..., ...\>; \}\>; \}\>, `"commands"`\> & `Readonly`\<\{ `commands?`: `Readonly`\<\{ `specs`: `C`; `handlers`: (`context`) => [`CommandHandlersV0`](#commandhandlersv0)\<`NoInfer`\<`C`\>\> & `H` & [`CheckedCommandHandlers`](#checkedcommandhandlers)\<`H`\>; \}\>; \}\> & `object` |
528
+
529
+ ###### Returns
530
+
531
+ [`DefinedExtensionV0`](#definedextensionv0)\<`C`, `P`, `PI`\>
532
+
533
+ ###### Call Signature
534
+
535
+ ```ts
536
+ define<P, PI>(definition): DefinedExtensionV0<Readonly<Record<never, never>>, P, PI>;
537
+ ```
538
+
539
+ Register contributions without commands or a client entry.
540
+
541
+ ###### Type Parameters
542
+
543
+ | Type Parameter |
544
+ | -------------- |
545
+ | `P` |
546
+ | `PI` |
547
+
548
+ ###### Parameters
549
+
550
+ | Parameter | Type |
551
+ | ------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
552
+ | `definition` | `Omit`\<`Readonly`\<\{ `catalog?`: [`Json`](#json); `commands?`: `Readonly`\<\{ `specs`: `C`; `handlers`: (`context`) => [`CommandHandlersV0`](#commandhandlersv0)\<`C`\>; \}\>; `projection?`: `Readonly`\<\{ `schema`: `Codec`\<`P`, `PI`\>; `catalog?`: (`value`) => [`Json`](#json); `read`: (`context`, `sessionId`) => `P` \| `Option`\<`P`\> \| `undefined`; \}\>; `prompt?`: (`context`, `run`) => \| readonly `Readonly`\<\{ `name`: `string`; `text`: `string`; \}\>[] \| `Promise`\<readonly `Readonly`\<\{ `name`: ...; `text`: ...; \}\>[]\> \| `Effect`\<readonly `Readonly`\<\{ `name`: ...; `text`: ...; \}\>[], [`HookError`](#hookerror), [`ExtensionRead`](#extensionread)\>; `tools?`: (`context`, `run`, `commands`) => \| `Readonly`\<\{ `[moduleBrand]`: `true`; \}\> \| `Promise`\< \| `Readonly`\<\{ `[moduleBrand]`: ...; \}\> \| `null`\> \| `Effect`\< \| `Readonly`\<\{ `[moduleBrand]`: ...; \}\> \| `Option`\<`Readonly`\<...\>\> \| `null`, [`HookError`](#hookerror), [`ExtensionRead`](#extensionread)\> \| `null`; `files?`: (`context`, `run`) => \| readonly `FileTool`[] \| `Promise`\<readonly `FileTool`[] \| `null`\> \| `Effect`\<readonly `FileTool`[] \| `Option`\<readonly ...[]\> \| `null`, [`HookError`](#hookerror), [`ExtensionRead`](#extensionread)\> \| `null`; `hooks?`: `Readonly`\<\{ `start?`: (`context`) => `void` \| `Promise`\<...\> \| `Effect`\<..., ..., ...\>; `onSettled?`: (`context`, `page`) => `void` \| `Effect`\<..., ..., ...\>; `onTimer?`: (`context`, `timer`) => `void` \| `Effect`\<..., ..., ...\>; \}\>; `timers?`: `true`; `attention?`: `true`; `compaction?`: (`context`) => `Readonly`\<\{ `consume`: (`view`) => \| [`CompactionHandoffResultV0`](#compactionhandoffresultv0) \| `Promise`\<...\> \| `Effect.Effect`\<..., ...\>; \}\>; \}\>, `"commands"`\> & `Readonly`\<\{ `commands?`: `Readonly`\<\{ `specs`: `C`; `handlers`: (`context`) => [`CommandHandlersV0`](#commandhandlersv0)\<`NoInfer`\<`Readonly`\<...\>\>\> & `Readonly`\<`Record`\<`never`, `never`\>\> & [`CheckedCommandHandlers`](#checkedcommandhandlers)\<`Readonly`\<`Record`\<..., ...\>\>\>; \}\>; \}\> & `object` |
553
+
554
+ ###### Returns
555
+
556
+ [`DefinedExtensionV0`](#definedextensionv0)\<`Readonly`\<`Record`\<`never`,
557
+ `never`\>\>, `P`, `PI`\>
558
+
559
+ ---
560
+
561
+ ### ExtensionHookError
562
+
563
+ An outside handler rejected or threw before Shiitake could use its result.
564
+
565
+ #### Extends
566
+
567
+ - `YieldableError`\<`this`\> & `object` & `Readonly`\<\{ `cause`: `unknown`;
568
+ \}\>
569
+
570
+ #### Constructors
571
+
572
+ ##### Constructor
573
+
574
+ ```ts
575
+ new ExtensionHookError(args): ExtensionHookError;
576
+ ```
577
+
578
+ ###### Parameters
579
+
580
+ | Parameter | Type |
581
+ | ------------ | ------------------------- |
582
+ | `args` | \{ `cause`: `unknown`; \} |
583
+ | `args.cause` | `unknown` |
584
+
585
+ ###### Returns
586
+
587
+ [`ExtensionHookError`](#extensionhookerror)
588
+
589
+ ###### Inherited from
590
+
591
+ ```ts
592
+ Data.TaggedError("ExtensionHookError")<{
593
+ cause: unknown;
594
+ }>.constructor
595
+ ```
596
+
597
+ #### Properties
598
+
599
+ ##### cause
600
+
601
+ ```ts
602
+ cause: unknown;
603
+ ```
604
+
605
+ ###### Inherited from
606
+
607
+ ```ts
608
+ Data.TaggedError("ExtensionHookError").cause;
609
+ ```
610
+
611
+ ## Type Aliases
612
+
613
+ ### ShiitakeExtensionProtocolV0
614
+
615
+ ```ts
616
+ type ShiitakeExtensionProtocolV0 = "shiitake.extension/v0";
617
+ ```
618
+
619
+ Host extension protocol; client-entry protocol is versioned independently.
620
+
621
+ ---
622
+
623
+ ### ExtensionId
624
+
625
+ ```ts
626
+ type ExtensionId = Schema.Schema.Type<typeof ExtensionId>;
627
+ ```
628
+
629
+ ASCII extension identity shared by the server definition and its clients.
630
+
631
+ ---
632
+
633
+ ### ExtensionManifestV0
634
+
635
+ ```ts
636
+ type ExtensionManifestV0 = Readonly<{
637
+ protocol: ShiitakeExtensionProtocolV0;
638
+ id: ExtensionId;
639
+ version: string;
640
+ requests: readonly ExtensionCapabilityV0[];
641
+ }>;
642
+ ```
643
+
644
+ Static identity and requested capabilities of one v0 extension.
645
+
646
+ ---
647
+
648
+ ### CommandSpecV0
649
+
650
+ ```ts
651
+ type CommandSpecV0<S, I, II, O, OI> = Readonly<{
652
+ scope: S;
653
+ input: Schema.Codec<I, II>;
654
+ output: Schema.Codec<O, OI>;
655
+ }>;
656
+ ```
657
+
658
+ One command's scope and its encoded input and output schemas.
659
+
660
+ #### Type Parameters
661
+
662
+ | Type Parameter |
663
+ | -------------------------------------- |
664
+ | `S` _extends_ `"session"` \| `"agent"` |
665
+ | `I` |
666
+ | `II` |
667
+ | `O` |
668
+ | `OI` |
669
+
670
+ ---
671
+
672
+ ### AnyCommandSpecV0
673
+
674
+ ```ts
675
+ type AnyCommandSpecV0 = Readonly<{
676
+ scope: "session" | "agent";
677
+ input: Schema.Codec<unknown>;
678
+ output: Schema.Codec<unknown>;
679
+ }>;
680
+ ```
681
+
682
+ Existential command spec.
683
+
684
+ ---
685
+
686
+ ### CommandsV0
687
+
688
+ ```ts
689
+ type CommandsV0 = Readonly<Record<string, AnyCommandSpecV0>>;
690
+ ```
691
+
692
+ Commands declared by one extension contract.
693
+
694
+ ---
695
+
696
+ ### ProjectionSpecV0
697
+
698
+ ```ts
699
+ type ProjectionSpecV0<P, PI> = Readonly<{
700
+ schema: Schema.Codec<P, PI>;
701
+ }>;
702
+ ```
703
+
704
+ The encoded Session projection slot.
705
+
706
+ #### Type Parameters
707
+
708
+ | Type Parameter |
709
+ | -------------- |
710
+ | `P` |
711
+ | `PI` |
712
+
713
+ ---
714
+
715
+ ### ExtensionContractV0
716
+
717
+ ```ts
718
+ type ExtensionContractV0<C, P, PI> = Readonly<{
719
+ id: ExtensionId;
720
+ commands: C;
721
+ projection: ProjectionSpecV0<P, PI> | null;
722
+ }>;
723
+ ```
724
+
725
+ Shared by the host definition and the client binding: one schema set.
726
+
727
+ #### Type Parameters
728
+
729
+ | Type Parameter |
730
+ | ----------------------------------------- |
731
+ | `C` _extends_ [`CommandsV0`](#commandsv0) |
732
+ | `P` |
733
+ | `PI` |
734
+
735
+ ---
736
+
737
+ ### ExtensionRevision
738
+
739
+ ```ts
740
+ type ExtensionRevision = typeof extensionRevisionSchema.Type;
741
+ ```
742
+
743
+ `sha256:<64 hex>` derived by core from a definition; never authored.
744
+
745
+ ---
746
+
747
+ ### ExtensionFingerprint
748
+
749
+ ```ts
750
+ type ExtensionFingerprint = typeof extensionFingerprintSchema.Type;
751
+ ```
752
+
753
+ `sha256:<64 hex>` over one revision and its sorted granted capabilities.
754
+
755
+ ---
756
+
757
+ ### Json
758
+
759
+ ```ts
760
+ type Json =
761
+ | null
762
+ | boolean
763
+ | number
764
+ | string
765
+ | readonly Json[]
766
+ | Readonly<{
767
+ [key: string]: Json;
768
+ }>;
769
+ ```
770
+
771
+ JSON value accepted as hashed extension configuration.
772
+
773
+ ---
774
+
775
+ ### ExtensionGrantV0
776
+
777
+ ```ts
778
+ type ExtensionGrantV0 = Readonly<{
779
+ id: ExtensionId;
780
+ capabilities: readonly ExtensionCapabilityV0[];
781
+ grantKey?: string;
782
+ }>;
783
+ ```
784
+
785
+ Host decision: the exact subset of requested capabilities it grants.
786
+
787
+ ---
788
+
789
+ ### HookError
790
+
791
+ ```ts
792
+ type HookError =
793
+ ExtensionStop | ExtensionStateError | AdmissionError | ExtensionHookError;
794
+ ```
795
+
796
+ Failures a background hook may return; each one stops only its extension.
797
+
798
+ ---
799
+
800
+ ### CollectionSpecV0
801
+
802
+ ```ts
803
+ type CollectionSpecV0<A, I> = Readonly<{
804
+ schema: Schema.Codec<A, I>;
805
+ bind: (
806
+ port,
807
+ name,
808
+ ) => Readonly<{
809
+ read: CollectionV0<A>;
810
+ update: UpdateCollectionV0<A>;
811
+ }>;
812
+ indexFromEncoded: (value) => Result.Result<string | null, Schema.SchemaError>;
813
+ key: (value) => string;
814
+ index?: (value) => string | null;
815
+ }>;
816
+ ```
817
+
818
+ One namespaced collection: its row schema is the only stored-row decoder.
819
+
820
+ #### Type Parameters
821
+
822
+ | Type Parameter |
823
+ | -------------- |
824
+ | `A` |
825
+ | `I` |
826
+
827
+ ---
828
+
829
+ ### AnyCollectionSpecV0
830
+
831
+ ```ts
832
+ type AnyCollectionSpecV0 = Readonly<{
833
+ schema: Schema.Codec<unknown>;
834
+ bind: (port, name) => CollectionBindingV0;
835
+ indexFromEncoded: (value) => Result.Result<string | null, Schema.SchemaError>;
836
+ key: (value) => string;
837
+ index?: (value) => string | null;
838
+ }>;
839
+ ```
840
+
841
+ Existential collection spec stored by core.
842
+
843
+ ---
844
+
845
+ ### CollectionsV0
846
+
847
+ ```ts
848
+ type CollectionsV0 = Readonly<Record<string, AnyCollectionSpecV0>>;
849
+ ```
850
+
851
+ Collections declared by one extension.
852
+
853
+ ---
854
+
855
+ ### StoredRecordV0
856
+
857
+ ```ts
858
+ type StoredRecordV0 = Readonly<{
859
+ collection: string;
860
+ key: string;
861
+ value: Json;
862
+ }>;
863
+ ```
864
+
865
+ One stored record as seen by a pure migration.
866
+
867
+ ---
868
+
869
+ ### StateSpecV0
870
+
871
+ ```ts
872
+ type StateSpecV0<C> = Readonly<{
873
+ version: number;
874
+ collections: C;
875
+ migrations: Readonly<Record<number, (row) => readonly StoredRecordV0[]>>;
876
+ }>;
877
+ ```
878
+
879
+ Versioned state declaration; core runs pure row migrations at activation.
880
+
881
+ #### Type Parameters
882
+
883
+ | Type Parameter |
884
+ | ----------------------------------------------- |
885
+ | `C` _extends_ [`CollectionsV0`](#collectionsv0) |
886
+
887
+ ---
888
+
889
+ ### StateDeclarationV0
890
+
891
+ ```ts
892
+ type StateDeclarationV0<C> = Readonly<{
893
+ version?: number;
894
+ collections: C;
895
+ migrations?: StateSpecV0<C>["migrations"];
896
+ }>;
897
+ ```
898
+
899
+ The versioned state declaration as authored; version defaults to 1.
900
+
901
+ #### Type Parameters
902
+
903
+ | Type Parameter |
904
+ | ----------------------------------------------- |
905
+ | `C` _extends_ [`CollectionsV0`](#collectionsv0) |
906
+
907
+ ---
908
+
909
+ ### CollectionV0
910
+
911
+ ```ts
912
+ type CollectionV0<A> = Readonly<{
913
+ peek: (key) => Option.Option<A>;
914
+ peekPage: (query) => readonly A[];
915
+ get: (
916
+ key,
917
+ ) => Effect.Effect<Option.Option<A>, ExtensionStateError, ExtensionRead>;
918
+ page: (
919
+ query,
920
+ ) => Effect.Effect<readonly A[], ExtensionStateError, ExtensionRead>;
921
+ put: (value) => Effect.Effect<void, ExtensionStateError, ExtensionTx>;
922
+ remove: (key) => Effect.Effect<void, ExtensionStateError, ExtensionTx>;
923
+ }>;
924
+ ```
925
+
926
+ Typed access to one collection inside a core transaction.
927
+
928
+ #### Type Parameters
929
+
930
+ | Type Parameter |
931
+ | -------------- |
932
+ | `A` |
933
+
934
+ ---
935
+
936
+ ### UpdateCollectionV0
937
+
938
+ ```ts
939
+ type UpdateCollectionV0<A> = Readonly<{
940
+ get: (key) => Option.Option<A>;
941
+ page: (query) => readonly A[];
942
+ put: (value) => void;
943
+ remove: (key) => void;
944
+ }>;
945
+ ```
946
+
947
+ The transaction-local interface used by plain synchronous state.update.
948
+
949
+ #### Type Parameters
950
+
951
+ | Type Parameter |
952
+ | -------------- |
953
+ | `A` |
954
+
955
+ ---
956
+
957
+ ### UpdateStateV0
958
+
959
+ ```ts
960
+ type UpdateStateV0<C> = {
961
+ readonly [K in keyof C]: ReturnType<C[K]["bind"]>["update"];
962
+ } & Readonly<{
963
+ observe: (sessionId) => void;
964
+ }>;
965
+ ```
966
+
967
+ Transaction-scoped collections plus post-commit Session notification.
968
+
969
+ #### Type Parameters
970
+
971
+ | Type Parameter |
972
+ | ----------------------------------------------- |
973
+ | `C` _extends_ [`CollectionsV0`](#collectionsv0) |
974
+
975
+ ---
976
+
977
+ ### ReadStateV0
978
+
979
+ ```ts
980
+ type ReadStateV0<C> = {
981
+ readonly [K in keyof C]: Pick<
982
+ ReturnType<C[K]["bind"]>["update"],
983
+ "get" | "page"
984
+ >;
985
+ };
986
+ ```
987
+
988
+ Synchronous, read-only collection access inside `state.read`.
989
+
990
+ #### Type Parameters
991
+
992
+ | Type Parameter |
993
+ | ----------------------------------------------- |
994
+ | `C` _extends_ [`CollectionsV0`](#collectionsv0) |
995
+
996
+ ---
997
+
998
+ ### StateHandleV0
999
+
1000
+ ```ts
1001
+ type StateHandleV0<C> = {
1002
+ readonly [K in keyof C]: ReturnType<C[K]["bind"]>["read"];
1003
+ } & Readonly<{
1004
+ update: StateUpdate<UpdateStateV0<C>>;
1005
+ read: StateUpdate<ReadStateV0<C>>;
1006
+ }>;
1007
+ ```
1008
+
1009
+ Typed handles for every declared collection.
1010
+
1011
+ #### Type Parameters
1012
+
1013
+ | Type Parameter |
1014
+ | ----------------------------------------------- |
1015
+ | `C` _extends_ [`CollectionsV0`](#collectionsv0) |
1016
+
1017
+ ---
1018
+
1019
+ ### RunOutcomeV0
1020
+
1021
+ ```ts
1022
+ type RunOutcomeV0 =
1023
+ "completed" | "failed" | "cancelled" | "interrupted" | "outcome_unknown";
1024
+ ```
1025
+
1026
+ Watchdog settlement or exact Woodstock terminal of one run.
1027
+
1028
+ ---
1029
+
1030
+ ### RunOriginV0
1031
+
1032
+ ```ts
1033
+ type RunOriginV0 = Readonly<{
1034
+ extensionId: ExtensionId;
1035
+ correlation: string | null;
1036
+ }>;
1037
+ ```
1038
+
1039
+ Extension that admitted a run, with its stored correlation.
1040
+
1041
+ ---
1042
+
1043
+ ### SettledRunV0
1044
+
1045
+ ```ts
1046
+ type SettledRunV0 = Readonly<{
1047
+ sequence: number;
1048
+ sessionId: string;
1049
+ workId: string;
1050
+ outcome: RunOutcomeV0;
1051
+ terminal: RunOutcomeV0 | "missing";
1052
+ toolCalls: number;
1053
+ origin: RunOriginV0 | null;
1054
+ }>;
1055
+ ```
1056
+
1057
+ One settled run joined by core with its terminal and admission origin.
1058
+
1059
+ ---
1060
+
1061
+ ### SettledPageV0
1062
+
1063
+ ```ts
1064
+ type SettledPageV0 = readonly SettledRunV0[];
1065
+ ```
1066
+
1067
+ 1..64 records, ascending, each delivered to each running extension once.
1068
+
1069
+ ---
1070
+
1071
+ ### SendInputV0
1072
+
1073
+ ```ts
1074
+ type SendInputV0 = Readonly<{
1075
+ sessionId: string;
1076
+ requireExistingSession?: boolean;
1077
+ prompt: Readonly<{
1078
+ text: string;
1079
+ requestId: string;
1080
+ delivery: "followUp" | "steer";
1081
+ }>;
1082
+ when: "now" | "idle";
1083
+ correlation?: string;
1084
+ }>;
1085
+ ```
1086
+
1087
+ One prompt sent through the accepted-command door.
1088
+
1089
+ ---
1090
+
1091
+ ### SendResultV0
1092
+
1093
+ ```ts
1094
+ type SendResultV0 =
1095
+ | Readonly<{
1096
+ _tag: "Accepted";
1097
+ commandId: string;
1098
+ delivery: "new" | "replay";
1099
+ }>
1100
+ | Readonly<{
1101
+ _tag: "NotReady";
1102
+ }>;
1103
+ ```
1104
+
1105
+ Door outcome for one extension admission.
1106
+
1107
+ ---
1108
+
1109
+ ### TimersV0
1110
+
1111
+ ```ts
1112
+ type TimersV0 = Readonly<{
1113
+ set: (key, dueAt) => Effect.Effect<void, ExtensionStateError, ExtensionTx>;
1114
+ cancel: (key) => Effect.Effect<void, ExtensionStateError, ExtensionTx>;
1115
+ read: (
1116
+ key,
1117
+ ) => Effect.Effect<Option.Option<number>, ExtensionStateError, ExtensionRead>;
1118
+ }>;
1119
+ ```
1120
+
1121
+ Durable per-extension wake timers (the scheduling substrate).
1122
+
1123
+ ---
1124
+
1125
+ ### FiredTimerV0
1126
+
1127
+ ```ts
1128
+ type FiredTimerV0 = Readonly<{
1129
+ key: string;
1130
+ dueAt: number;
1131
+ firedAt: number;
1132
+ }>;
1133
+ ```
1134
+
1135
+ A fired timer; its row is consumed unless the handler sets it again.
1136
+
1137
+ ---
1138
+
1139
+ ### CommandSessionIdsV0
1140
+
1141
+ ```ts
1142
+ type CommandSessionIdsV0 = object;
1143
+ ```
1144
+
1145
+ A command's scope fixes whether its invocation names a Session.
1146
+
1147
+ #### Properties
1148
+
1149
+ ##### agent
1150
+
1151
+ ```ts
1152
+ agent: null;
1153
+ ```
1154
+
1155
+ ##### session
1156
+
1157
+ ```ts
1158
+ session: string;
1159
+ ```
1160
+
1161
+ ---
1162
+
1163
+ ### CommandHandlersV0
1164
+
1165
+ ```ts
1166
+ type CommandHandlersV0<C> = {
1167
+ readonly [K in keyof C]: (
1168
+ call: Readonly<{
1169
+ sessionId: CommandSessionIdsV0[C[K]["scope"]];
1170
+ input: C[K]["input"]["Type"];
1171
+ }>,
1172
+ ) =>
1173
+ | C[K]["output"]["Type"]
1174
+ | Effect.Effect<
1175
+ C[K]["output"]["Type"],
1176
+ ExtensionCommandError | ExtensionStateError | AdmissionError,
1177
+ ExtensionTx | ExtensionRead
1178
+ >;
1179
+ };
1180
+ ```
1181
+
1182
+ Handlers for every declared command, run in one core transaction.
1183
+
1184
+ #### Type Parameters
1185
+
1186
+ | Type Parameter |
1187
+ | ----------------------------------------- |
1188
+ | `C` _extends_ [`CommandsV0`](#commandsv0) |
1189
+
1190
+ ---
1191
+
1192
+ ### AttentionV0
1193
+
1194
+ ```ts
1195
+ type AttentionV0 = Readonly<{
1196
+ set: (
1197
+ sessionId,
1198
+ item,
1199
+ ) => Effect.Effect<void, ExtensionStateError, ExtensionTx>;
1200
+ clear: (
1201
+ sessionId,
1202
+ id,
1203
+ ) => Effect.Effect<void, ExtensionStateError, ExtensionTx>;
1204
+ }>;
1205
+ ```
1206
+
1207
+ Transaction-scoped, extension-owned attention on an existing Session.
1208
+
1209
+ ---
1210
+
1211
+ ### ExtensionContextV0
1212
+
1213
+ ```ts
1214
+ type ExtensionContextV0<S, Config, D> = Readonly<{
1215
+ manifest: ExtensionManifestV0;
1216
+ revision: ExtensionRevision;
1217
+ grants: readonly ExtensionCapabilityV0[];
1218
+ config: Config;
1219
+ state: StateHandleV0<S>;
1220
+ documents: DocumentHandlesV0<D>;
1221
+ send: (input) => Effect.Effect<SendResultV0, AdmissionError, ExtensionTx>;
1222
+ timers: TimersV0;
1223
+ attention: AttentionV0;
1224
+ hasPendingSteer: (
1225
+ run,
1226
+ ) => Effect.Effect<boolean, ExtensionStateError, ExtensionRead>;
1227
+ hasSuccessfulToolResult: (
1228
+ run,
1229
+ toolCallId,
1230
+ ) => Effect.Effect<boolean, ExtensionStateError, ExtensionRead>;
1231
+ observe: (sessionId) => Effect.Effect<void, never, ExtensionTx>;
1232
+ transact: <A, E>(body) => Effect.Effect<A, E | ExtensionStop | ShiitakeError>;
1233
+ }>;
1234
+ ```
1235
+
1236
+ Everything core hands one activated extension.
1237
+
1238
+ #### Type Parameters
1239
+
1240
+ | Type Parameter | Default type |
1241
+ | --------------------------------------------------- | ------------------------------------- |
1242
+ | `S` _extends_ [`CollectionsV0`](#collectionsv0) | - |
1243
+ | `Config` _extends_ [`Json`](#json) | - |
1244
+ | `D` _extends_ [`DocumentsV0`](index.md#documentsv0) | [`DocumentsV0`](index.md#documentsv0) |
1245
+
1246
+ ---
1247
+
1248
+ ### RunIdentityV0
1249
+
1250
+ ```ts
1251
+ type RunIdentityV0 = Readonly<{
1252
+ sessionId: string;
1253
+ workId: string;
1254
+ origin: RunOriginV0 | null;
1255
+ }>;
1256
+ ```
1257
+
1258
+ One run the extension may attach tools to.
1259
+
1260
+ ---
1261
+
1262
+ ### PromptSectionV0
1263
+
1264
+ ```ts
1265
+ type PromptSectionV0 = Readonly<{
1266
+ name: string;
1267
+ text: string;
1268
+ }>;
1269
+ ```
1270
+
1271
+ A named, bounded system-prompt section; core orders by extension and name.
1272
+
1273
+ ---
1274
+
1275
+ ### AgentHooksV0
1276
+
1277
+ ```ts
1278
+ type AgentHooksV0<C, P> = Readonly<{
1279
+ onSettled?: (
1280
+ page,
1281
+ ) => Effect.Effect<void, HookError, ExtensionTx | ExtensionRead>;
1282
+ onTimer?: (
1283
+ timer,
1284
+ ) => Effect.Effect<void, HookError, ExtensionTx | ExtensionRead>;
1285
+ moduleForRun?: (
1286
+ run,
1287
+ ) => Effect.Effect<
1288
+ Option.Option<ModuleRegistration>,
1289
+ HookError,
1290
+ ExtensionRead
1291
+ >;
1292
+ filesForRun?: (
1293
+ run,
1294
+ ) => Effect.Effect<
1295
+ Option.Option<readonly FileTool[]>,
1296
+ HookError,
1297
+ ExtensionRead
1298
+ >;
1299
+ prompt?: (
1300
+ run,
1301
+ ) =>
1302
+ | readonly PromptSectionV0[]
1303
+ | Promise<readonly PromptSectionV0[]>
1304
+ | Effect.Effect<readonly PromptSectionV0[], HookError, ExtensionRead>;
1305
+ project?: (sessionId) => Option.Option<P>;
1306
+ compactionHandoff?: CompactionHandoffV0;
1307
+ commands: CommandHandlersV0<C>;
1308
+ }>;
1309
+ ```
1310
+
1311
+ Hooks returned by one activation; each runs in its own isolation boundary.
1312
+
1313
+ #### Type Parameters
1314
+
1315
+ | Type Parameter |
1316
+ | ----------------------------------------- |
1317
+ | `C` _extends_ [`CommandsV0`](#commandsv0) |
1318
+ | `P` |
1319
+
1320
+ ---
1321
+
1322
+ ### RosteredExtensionV0
1323
+
1324
+ ```ts
1325
+ type RosteredExtensionV0 = Readonly<{
1326
+ manifest: ExtensionManifestV0;
1327
+ [definitionReader]?: () => AnyExtensionDefinitionV0;
1328
+ }> &
1329
+ Brand.Brand<"RosteredExtensionV0">;
1330
+ ```
1331
+
1332
+ Opaque rostered value; core reads the definition existentially.
1333
+
1334
+ ---
1335
+
1336
+ ### DefinedExtensionV0
1337
+
1338
+ ```ts
1339
+ type DefinedExtensionV0<C, P, PI> = RosteredExtensionV0 &
1340
+ Readonly<{
1341
+ contract: ExtensionContractV0<C, P, PI>;
1342
+ }>;
1343
+ ```
1344
+
1345
+ A defined extension: its roster entry and the client contract it declares.
1346
+
1347
+ #### Type Parameters
1348
+
1349
+ | Type Parameter |
1350
+ | ----------------------------------------- |
1351
+ | `C` _extends_ [`CommandsV0`](#commandsv0) |
1352
+ | `P` |
1353
+ | `PI` |
1354
+
1355
+ ---
1356
+
1357
+ ### ExtensionDefinitionV0
1358
+
1359
+ ```ts
1360
+ type ExtensionDefinitionV0<S, C, P, PI, Config, D> = Readonly<{
1361
+ catalog?: Json;
1362
+ commands?: Readonly<{
1363
+ specs: C;
1364
+ handlers: (context) => CommandHandlersV0<C>;
1365
+ }>;
1366
+ projection?: Readonly<{
1367
+ schema: Schema.Codec<P, PI>;
1368
+ catalog?: (value) => Json;
1369
+ read: (context, sessionId) => P | Option.Option<P> | undefined;
1370
+ }>;
1371
+ prompt?: (
1372
+ context,
1373
+ run,
1374
+ ) =>
1375
+ | readonly PromptSectionV0[]
1376
+ | Promise<readonly PromptSectionV0[]>
1377
+ | Effect.Effect<readonly PromptSectionV0[], HookError, ExtensionRead>;
1378
+ tools?: (
1379
+ context,
1380
+ run,
1381
+ commands,
1382
+ ) =>
1383
+ | ModuleRegistration
1384
+ | null
1385
+ | Promise<ModuleRegistration | null>
1386
+ | Effect.Effect<
1387
+ ModuleRegistration | null | Option.Option<ModuleRegistration>,
1388
+ HookError,
1389
+ ExtensionRead
1390
+ >;
1391
+ files?: (
1392
+ context,
1393
+ run,
1394
+ ) =>
1395
+ | readonly FileTool[]
1396
+ | null
1397
+ | Promise<readonly FileTool[] | null>
1398
+ | Effect.Effect<
1399
+ readonly FileTool[] | null | Option.Option<readonly FileTool[]>,
1400
+ HookError,
1401
+ ExtensionRead
1402
+ >;
1403
+ hooks?: Readonly<{
1404
+ start?: (
1405
+ context,
1406
+ ) =>
1407
+ | void
1408
+ | Promise<void>
1409
+ | Effect.Effect<void, ExtensionActivationError, Scope.Scope>;
1410
+ onSettled?: (
1411
+ context,
1412
+ page,
1413
+ ) => void | Effect.Effect<void, HookError, ExtensionTx | ExtensionRead>;
1414
+ onTimer?: (
1415
+ context,
1416
+ timer,
1417
+ ) => void | Effect.Effect<void, HookError, ExtensionTx | ExtensionRead>;
1418
+ }>;
1419
+ timers?: true;
1420
+ attention?: true;
1421
+ compaction?: (context) => Readonly<{
1422
+ consume: (
1423
+ view,
1424
+ ) =>
1425
+ | CompactionHandoffResultV0
1426
+ | Promise<CompactionHandoffResultV0>
1427
+ | Effect.Effect<
1428
+ CompactionHandoffResultV0,
1429
+ CompactionHandoffErrorV0 | ExtensionHookError
1430
+ >;
1431
+ }>;
1432
+ }>;
1433
+ ```
1434
+
1435
+ Contributions registered against the builder's captured metadata.
1436
+
1437
+ #### Type Parameters
1438
+
1439
+ | Type Parameter | Default type |
1440
+ | --------------------------------------------------- | ------------------------------------- |
1441
+ | `S` _extends_ [`CollectionsV0`](#collectionsv0) | - |
1442
+ | `C` _extends_ [`CommandsV0`](#commandsv0) | - |
1443
+ | `P` | - |
1444
+ | `PI` | - |
1445
+ | `Config` _extends_ [`Json`](#json) | - |
1446
+ | `D` _extends_ [`DocumentsV0`](index.md#documentsv0) | [`DocumentsV0`](index.md#documentsv0) |
1447
+
1448
+ ---
1449
+
1450
+ ### CheckedCommandHandlers
1451
+
1452
+ ```ts
1453
+ type CheckedCommandHandlers<H> = {
1454
+ readonly [K in keyof H]: H[K] extends (args: never[]) => infer Result
1455
+ ? Result extends Promise<unknown>
1456
+ ? never
1457
+ : H[K]
1458
+ : never;
1459
+ };
1460
+ ```
1461
+
1462
+ Reject Promise-returning transactional commands even when output is `{}`.
1463
+
1464
+ #### Type Parameters
1465
+
1466
+ | Type Parameter |
1467
+ | -------------- |
1468
+ | `H` |
1469
+
1470
+ ---
1471
+
1472
+ ### ExtensionAuthorDefinitionV0
1473
+
1474
+ ```ts
1475
+ type ExtensionAuthorDefinitionV0<S, C, P, PI, Config, D, H> = Omit<
1476
+ ExtensionDefinitionV0<S, C, P, PI, Config, D>,
1477
+ "commands"
1478
+ > &
1479
+ Readonly<{
1480
+ commands?: Readonly<{
1481
+ specs: C;
1482
+ handlers: (
1483
+ context,
1484
+ ) => CommandHandlersV0<NoInfer<C>> & H & CheckedCommandHandlers<H>;
1485
+ }>;
1486
+ }>;
1487
+ ```
1488
+
1489
+ Caller-owned extension metadata and handlers accepted by the v0 builder.
1490
+
1491
+ #### Type Parameters
1492
+
1493
+ | Type Parameter |
1494
+ | -------------------------------------------------------------- |
1495
+ | `S` _extends_ [`CollectionsV0`](#collectionsv0) |
1496
+ | `C` _extends_ [`CommandsV0`](#commandsv0) |
1497
+ | `P` |
1498
+ | `PI` |
1499
+ | `Config` _extends_ [`Json`](#json) |
1500
+ | `D` _extends_ [`DocumentsV0`](index.md#documentsv0) |
1501
+ | `H` _extends_ [`CommandHandlersV0`](#commandhandlersv0)\<`C`\> |
1502
+
1503
+ ---
1504
+
1505
+ ### EmptyExtensionFieldsV0
1506
+
1507
+ ```ts
1508
+ type EmptyExtensionFieldsV0 = Readonly<Record<never, never>>;
1509
+ ```
1510
+
1511
+ Concrete metadata with no declared fields.
1512
+
1513
+ ---
1514
+
1515
+ ### ExtensionIdentityV0
1516
+
1517
+ ```ts
1518
+ type ExtensionIdentityV0 =
1519
+ | string
1520
+ | Readonly<{
1521
+ id: string;
1522
+ version?: string;
1523
+ }>;
1524
+ ```
1525
+
1526
+ An extension id, or an id with an explicit SemVer version.
1527
+
1528
+ ---
1529
+
1530
+ ### AnyAgentHooksV0
1531
+
1532
+ ```ts
1533
+ type AnyAgentHooksV0 = Readonly<{
1534
+ onSettled?: NonNullable<AgentHooksV0<CommandsV0, never>["onSettled"]>;
1535
+ onTimer?: NonNullable<AgentHooksV0<CommandsV0, never>["onTimer"]>;
1536
+ moduleForRun?: NonNullable<AgentHooksV0<CommandsV0, never>["moduleForRun"]>;
1537
+ filesForRun?: NonNullable<AgentHooksV0<CommandsV0, never>["filesForRun"]>;
1538
+ prompt?: NonNullable<AgentHooksV0<CommandsV0, never>["prompt"]>;
1539
+ project?: (sessionId) => Option.Option<unknown>;
1540
+ projectCatalog?: (value) => Json;
1541
+ compactionHandoff?: CompactionHandoffV0;
1542
+ commands: ReadonlyMap<string, RegisteredExtensionCommandV0>;
1543
+ }>;
1544
+ ```
1545
+
1546
+ Existential hooks as stored by core; each handler is re-typed by its schema.
1547
+
1548
+ ---
1549
+
1550
+ ### AnyExtensionDefinitionV0
1551
+
1552
+ ```ts
1553
+ type AnyExtensionDefinitionV0 = Readonly<{
1554
+ manifest: ExtensionManifestV0;
1555
+ contract: Readonly<{
1556
+ id: ExtensionId;
1557
+ commands: CommandsV0;
1558
+ projection: Readonly<{
1559
+ schema: Schema.Codec<unknown>;
1560
+ }> | null;
1561
+ }>;
1562
+ config: Json;
1563
+ state: StateSpecV0<CollectionsV0>;
1564
+ documents?: DocumentsV0;
1565
+ catalog?: Json;
1566
+ activate: (
1567
+ port,
1568
+ ) => Effect.Effect<
1569
+ AnyAgentHooksV0,
1570
+ ExtensionActivationError | ExtensionHookError,
1571
+ Scope.Scope
1572
+ >;
1573
+ }>;
1574
+ ```
1575
+
1576
+ Existential definition stored by core.
1577
+
1578
+ ---
1579
+
1580
+ ### ExtensionRosterV0
1581
+
1582
+ ```ts
1583
+ type ExtensionRosterV0 = Readonly<{
1584
+ roster: readonly RosteredExtensionV0[];
1585
+ grants: readonly ExtensionGrantV0[];
1586
+ }>;
1587
+ ```
1588
+
1589
+ A host's explicit roster and grants.
1590
+
1591
+ ---
1592
+
1593
+ ### ExtensionStatusV0
1594
+
1595
+ ```ts
1596
+ type ExtensionStatusV0 = Readonly<{
1597
+ id: string;
1598
+ version: string;
1599
+ revision: string;
1600
+ status: "running" | "stopped";
1601
+ reason: string | null;
1602
+ stoppedAt: number | null;
1603
+ }>;
1604
+ ```
1605
+
1606
+ Visible lifecycle of one rostered extension (wire representation).
1607
+
1608
+ ---
1609
+
1610
+ ### ExtensionSlotV0
1611
+
1612
+ ```ts
1613
+ type ExtensionSlotV0 =
1614
+ | Readonly<{
1615
+ status: "running";
1616
+ revision: string;
1617
+ value: Json;
1618
+ catalog?: Json;
1619
+ }>
1620
+ | Readonly<{
1621
+ status: "stopped";
1622
+ revision: string;
1623
+ reason: string;
1624
+ }>;
1625
+ ```
1626
+
1627
+ One extension's encoded slot in a Session snapshot or frame.
1628
+
1629
+ ---
1630
+
1631
+ ### BorrowedCompactionViewV0
1632
+
1633
+ ```ts
1634
+ type BorrowedCompactionViewV0 = Readonly<{
1635
+ messagesToSummarize: readonly Message[];
1636
+ turnPrefixMessages: readonly Message[];
1637
+ result: Readonly<{
1638
+ summary: string;
1639
+ firstKeptEntryId: string;
1640
+ tokensBefore: number;
1641
+ usage: Usage;
1642
+ details?: Readonly<{
1643
+ readFiles: readonly string[];
1644
+ modifiedFiles: readonly string[];
1645
+ }>;
1646
+ }>;
1647
+ contextRevision: string;
1648
+ }>;
1649
+ ```
1650
+
1651
+ Borrowed view of the exact objects already built for compaction.
1652
+
1653
+ ---
1654
+
1655
+ ### CompactionHandoffResultV0
1656
+
1657
+ ```ts
1658
+ type CompactionHandoffResultV0 =
1659
+ | Readonly<{
1660
+ type: "accepted";
1661
+ receipt: string;
1662
+ }>
1663
+ | Readonly<{
1664
+ type: "discarded_by_policy";
1665
+ }>;
1666
+ ```
1667
+
1668
+ Result returned before a borrowed compaction view may be released.
1669
+
1670
+ ---
1671
+
1672
+ ### CompactionHandoffErrorV0
1673
+
1674
+ ```ts
1675
+ type CompactionHandoffErrorV0 = Readonly<{
1676
+ _tag: "CompactionHandoffError";
1677
+ message: string;
1678
+ }>;
1679
+ ```
1680
+
1681
+ Typed failure returned by the compaction contribution.
1682
+
1683
+ ---
1684
+
1685
+ ### CompactionHandoffV0
1686
+
1687
+ ```ts
1688
+ type CompactionHandoffV0 = Readonly<{
1689
+ consume: (
1690
+ view,
1691
+ ) => Effect.Effect<
1692
+ CompactionHandoffResultV0,
1693
+ CompactionHandoffErrorV0 | ExtensionHookError
1694
+ >;
1695
+ }>;
1696
+ ```
1697
+
1698
+ The exclusive compaction handoff callable of one extension.
1699
+
1700
+ ---
1701
+
1702
+ ### RegisteredExtensionCommandV0
1703
+
1704
+ ```ts
1705
+ type RegisteredExtensionCommandV0 = (
1706
+ frame,
1707
+ ) => Result.Result<
1708
+ () => Effect.Effect<
1709
+ Json,
1710
+ ExtensionCommandError | ExtensionStateError | AdmissionError,
1711
+ ExtensionTx | ExtensionRead
1712
+ >,
1713
+ Schema.SchemaError
1714
+ >;
1715
+ ```
1716
+
1717
+ A parsed invocation retains its typed handler until the transaction runs.
1718
+
1719
+ #### Parameters
1720
+
1721
+ | Parameter | Type |
1722
+ | --------- | ------------------------------------------------------------------------------ |
1723
+ | `frame` | `Readonly`\<\{ `sessionId`: `string` \| `null`; `input`: [`Json`](#json); \}\> |
1724
+
1725
+ #### Returns
1726
+
1727
+ `Result.Result`\<() => `Effect.Effect`\<[`Json`](#json), \|
1728
+ [`ExtensionCommandError`](#extensioncommanderror) \|
1729
+ [`ExtensionStateError`](#extensionstateerror) \|
1730
+ [`AdmissionError`](#admissionerror), [`ExtensionTx`](#extensiontx) \|
1731
+ [`ExtensionRead`](#extensionread)\>, `Schema.SchemaError`\>
1732
+
1733
+ ---
1734
+
1735
+ ### CommandToolOptionsV0
1736
+
1737
+ ```ts
1738
+ type CommandToolOptionsV0 = Readonly<{
1739
+ description: string;
1740
+ }>;
1741
+ ```
1742
+
1743
+ How one command appears to the model when exposed as a tool.
1744
+
1745
+ ---
1746
+
1747
+ ### CommandToolsV0
1748
+
1749
+ ```ts
1750
+ type CommandToolsV0<C> = Readonly<{
1751
+ tool: (name, options) => OperationRegistration;
1752
+ }>;
1753
+ ```
1754
+
1755
+ Expose declared commands as model tools, bound to the current run's Session.
1756
+
1757
+ #### Type Parameters
1758
+
1759
+ | Type Parameter |
1760
+ | ----------------------------------------- |
1761
+ | `C` _extends_ [`CommandsV0`](#commandsv0) |
1762
+
1763
+ ---
1764
+
1765
+ ### CollectionBindingV0
1766
+
1767
+ ```ts
1768
+ type CollectionBindingV0 = Readonly<{
1769
+ read: Omit<CollectionV0<unknown>, "put"> & Pick<CollectionV0<never>, "put">;
1770
+ update: Omit<UpdateCollectionV0<unknown>, "put"> &
1771
+ Pick<UpdateCollectionV0<never>, "put">;
1772
+ }>;
1773
+ ```
1774
+
1775
+ Core retains only these erased results; the author retains each concrete
1776
+ factory.
1777
+
1778
+ ---
1779
+
1780
+ ### ExtensionRuntimePortV0
1781
+
1782
+ ```ts
1783
+ type ExtensionRuntimePortV0 = Readonly<{
1784
+ context: Omit<
1785
+ ExtensionContextV0<EmptyExtensionFieldsV0, Json, EmptyExtensionFieldsV0>,
1786
+ "config" | "state" | "documents"
1787
+ >;
1788
+ collection: <A, I>(name, spec) => CollectionV0<A>;
1789
+ updateCollection: <A, I>(name, spec) => UpdateCollectionV0<A>;
1790
+ document: <A, I>(name, spec) => DocumentHandleV0<A>;
1791
+ update: <A>(body) => A;
1792
+ observeUpdate: (sessionId) => void;
1793
+ }>;
1794
+ ```
1795
+
1796
+ State operations capture their typed declaration before entering core.
1797
+
1798
+ ---
1799
+
1800
+ ### SyncResult
1801
+
1802
+ ```ts
1803
+ type SyncResult<A> =
1804
+ A extends Option.Option<unknown>
1805
+ ? A
1806
+ : A extends Promise<unknown> | Effect.Effect<unknown, unknown, unknown>
1807
+ ? never
1808
+ : A;
1809
+ ```
1810
+
1811
+ A write callback must resolve before the owner commits its SQLite transaction.
1812
+
1813
+ #### Type Parameters
1814
+
1815
+ | Type Parameter |
1816
+ | -------------- |
1817
+ | `A` |
1818
+
1819
+ ---
1820
+
1821
+ ### StateUpdate
1822
+
1823
+ ```ts
1824
+ type StateUpdate<Tx> = <A>(handler) => A;
1825
+ ```
1826
+
1827
+ Public state-update shape: infer the return _before_ rejecting async results.
1828
+
1829
+ #### Type Parameters
1830
+
1831
+ | Type Parameter |
1832
+ | -------------- |
1833
+ | `Tx` |
1834
+
1835
+ #### Type Parameters
1836
+
1837
+ | Type Parameter |
1838
+ | -------------- |
1839
+ | `A` |
1840
+
1841
+ #### Parameters
1842
+
1843
+ | Parameter | Type |
1844
+ | --------- | -------------------------------------------- |
1845
+ | `handler` | (`tx`) => [`SyncResult`](#syncresult)\<`A`\> |
1846
+
1847
+ #### Returns
1848
+
1849
+ `A`
1850
+
1851
+ ---
1852
+
1853
+ ### AttentionItem
1854
+
1855
+ ```ts
1856
+ type AttentionItem = typeof AttentionItemSchema.Type;
1857
+ ```
1858
+
1859
+ Input to the granted attention door, scoped to the calling extension.
1860
+
1861
+ ## Variables
1862
+
1863
+ ### extensionIdentifier
1864
+
1865
+ ```ts
1866
+ const extensionIdentifier: String;
1867
+ ```
1868
+
1869
+ ASCII extension identity shared by the host definition and its clients.
1870
+
1871
+ ---
1872
+
1873
+ ### extensionVersion
1874
+
1875
+ ```ts
1876
+ const extensionVersion: String;
1877
+ ```
1878
+
1879
+ SemVer spelling used by host admission.
1880
+
1881
+ ---
1882
+
1883
+ ### ExtensionId
1884
+
1885
+ ```ts
1886
+ const ExtensionId: brand<String, "ExtensionId">;
1887
+ ```
1888
+
1889
+ ASCII extension identity shared by the host definition and its clients.
1890
+
1891
+ ---
1892
+
1893
+ ### AttentionItemSchema
1894
+
1895
+ ```ts
1896
+ const AttentionItemSchema: Struct<{
1897
+ id: NonEmptyString;
1898
+ kind: NonEmptyString;
1899
+ summary: NonEmptyString;
1900
+ since: Int;
1901
+ expiresAt: optional<Int>;
1902
+ }>;
1903
+ ```
1904
+
1905
+ An extension-owned request for human attention; expiry is owned by its timer.
1906
+
1907
+ ## Functions
1908
+
1909
+ ### parseExtensionJson()
1910
+
1911
+ ```ts
1912
+ function parseExtensionJson(source): Json;
1913
+ ```
1914
+
1915
+ Parse a serialized extension value into the finite JSON contract.
1916
+
1917
+ #### Parameters
1918
+
1919
+ | Parameter | Type |
1920
+ | --------- | -------- |
1921
+ | `source` | `string` |
1922
+
1923
+ #### Returns
1924
+
1925
+ [`Json`](#json)
1926
+
1927
+ ---
1928
+
1929
+ ### defineExtension()
1930
+
1931
+ ```ts
1932
+ function defineExtension(
1933
+ identity,
1934
+ ): ExtensionBuilderV0<
1935
+ Readonly<Record<never, never>>,
1936
+ Readonly<Record<never, never>>,
1937
+ Readonly<Record<never, never>>
1938
+ >;
1939
+ ```
1940
+
1941
+ Begin with honest empty defaults; optional contributions are declared
1942
+ explicitly. The version defaults to `0.0.0` and any SemVer, including a
1943
+ pre-release, is valid. It is part of the extension's revision, which already
1944
+ covers schemas, config and requested capabilities; a different version marks a
1945
+ behaviour change those do not show, such as a fixed hook.
1946
+
1947
+ #### Parameters
1948
+
1949
+ | Parameter | Type |
1950
+ | ---------- | --------------------------------------------- |
1951
+ | `identity` | [`ExtensionIdentityV0`](#extensionidentityv0) |
1952
+
1953
+ #### Returns
1954
+
1955
+ [`ExtensionBuilderV0`](#extensionbuilderv0)\<`Readonly`\<`Record`\<`never`,
1956
+ `never`\>\>, `Readonly`\<`Record`\<`never`, `never`\>\>,
1957
+ `Readonly`\<`Record`\<`never`, `never`\>\>\>
1958
+
1959
+ ---
1960
+
1961
+ ### defineCollection()
1962
+
1963
+ ```ts
1964
+ function defineCollection<A, I>(schema, keys): CollectionSpecV0<A, I>;
1965
+ ```
1966
+
1967
+ Declare one collection with its key inferred from the row schema.
1968
+
1969
+ #### Type Parameters
1970
+
1971
+ | Type Parameter |
1972
+ | -------------- |
1973
+ | `A` |
1974
+ | `I` |
1975
+
1976
+ #### Parameters
1977
+
1978
+ | Parameter | Type |
1979
+ | --------- | -------------------------------------------------------------------------------------------- |
1980
+ | `schema` | `Codec`\<`A`, `I`\> |
1981
+ | `keys` | `Readonly`\<\{ `key`: (`value`) => `string`; `index?`: (`value`) => `string` \| `null`; \}\> |
1982
+
1983
+ #### Returns
1984
+
1985
+ [`CollectionSpecV0`](#collectionspecv0)\<`A`, `I`\>
1986
+
1987
+ ## References
1988
+
1989
+ ### SessionAttention
1990
+
1991
+ Re-exports [SessionAttention](client.md#sessionattention)
1992
+
1993
+ ---
1994
+
1995
+ ### ClientActivityV0
1996
+
1997
+ Re-exports [ClientActivityV0](client-entry.md#clientactivityv0)
1998
+
1999
+ ---
2000
+
2001
+ ### ExtensionCapabilityV0
2002
+
2003
+ Re-exports [ExtensionCapabilityV0](index.md#extensioncapabilityv0)