@fungi.computer/shiitake 0.3.1 → 0.4.0

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 (63) hide show
  1. package/README.md +18 -8
  2. package/dist/agent-control.d.ts +19 -15
  3. package/dist/agent-control.js +66 -126
  4. package/dist/client-wire.d.ts +12 -3
  5. package/dist/client-wire.js +33 -8
  6. package/dist/client.d.ts +34 -3
  7. package/dist/client.js +1 -1
  8. package/dist/cloudflare.d.ts +3 -1
  9. package/dist/cloudflare.js +2 -2
  10. package/dist/delegation.d.ts +145 -13
  11. package/dist/delegation.js +109 -37
  12. package/dist/effect.d.ts +1 -1
  13. package/dist/fleet.d.ts +30 -8
  14. package/dist/fleet.js +142 -38
  15. package/dist/http-routes.d.ts +84 -12
  16. package/dist/http-routes.js +15 -1
  17. package/dist/index.d.ts +2 -2
  18. package/dist/internal/admission-door.d.ts +2 -0
  19. package/dist/internal/admission-door.js +2 -0
  20. package/dist/internal/client-boundary.d.ts +10 -0
  21. package/dist/internal/client-boundary.js +10 -0
  22. package/dist/internal/compaction/compaction.js +1 -1
  23. package/dist/internal/contracts.d.ts +2 -0
  24. package/dist/internal/coordinator.d.ts +3 -1
  25. package/dist/internal/coordinator.js +98 -13
  26. package/dist/internal/effect-client.d.ts +3 -1
  27. package/dist/internal/effect-client.js +3 -2
  28. package/dist/internal/effect-contracts.d.ts +6 -2
  29. package/dist/internal/model-acquisition.js +2 -0
  30. package/dist/internal/observation-kernel.d.ts +8 -4
  31. package/dist/internal/observation-kernel.js +44 -9
  32. package/dist/internal/promise-facade.d.ts +1 -1
  33. package/dist/internal/promise-facade.js +1 -1
  34. package/dist/internal/run-scope.js +37 -8
  35. package/dist/internal/runtime-coordinator.d.ts +5 -0
  36. package/dist/internal/runtime-coordinator.js +8 -4
  37. package/dist/internal/runtime-core.d.ts +2 -1
  38. package/dist/internal/runtime-core.js +6 -1
  39. package/dist/internal/session-context.d.ts +1 -1
  40. package/dist/internal/session-context.js +84 -13
  41. package/dist/internal/woodstock/agent-reply.d.ts +7 -2
  42. package/dist/internal/woodstock/agent-reply.js +22 -13
  43. package/dist/internal/woodstock/fleet-store.d.ts +3 -2
  44. package/dist/internal/woodstock/fleet-store.js +43 -6
  45. package/dist/internal/woodstock/index.d.ts +2 -0
  46. package/dist/internal/woodstock/index.js +11 -5
  47. package/dist/internal/woodstock/run-recovery.js +4 -1
  48. package/dist/internal/woodstock/session-entry.d.ts +13 -3
  49. package/dist/internal/woodstock/session-entry.js +1 -0
  50. package/dist/internal/woodstock/session-store.d.ts +4 -0
  51. package/dist/internal/woodstock/session-store.js +26 -19
  52. package/dist/remote-client.js +5 -1
  53. package/dist/testing.d.ts +5 -2
  54. package/dist/testing.js +4 -2
  55. package/docs/api/agent-control.md +18 -12
  56. package/docs/api/client.md +78 -0
  57. package/docs/api/delegation.md +72 -55
  58. package/docs/api/effect.md +5 -0
  59. package/docs/api/fleet.md +23 -23
  60. package/docs/api/http.md +2 -1
  61. package/docs/api/index.md +13 -0
  62. package/docs/api/testing.md +3 -3
  63. package/package.json +9 -8
@@ -23,6 +23,30 @@ Semantic acknowledgement returned after one durable acceptance commit.
23
23
 
24
24
  ---
25
25
 
26
+ ### Held
27
+
28
+ ```ts
29
+ type Held = Readonly<{
30
+ status: "held";
31
+ reason: "recipient_offline";
32
+ message: "waiting: recipient offline";
33
+ }>;
34
+ ```
35
+
36
+ Durable relay custody, not acceptance of a command by the recipient.
37
+
38
+ ---
39
+
40
+ ### DelegationReceipt
41
+
42
+ ```ts
43
+ type DelegationReceipt = Accepted | Held;
44
+ ```
45
+
46
+ A delegation send can be accepted by the Agent or held by its relay.
47
+
48
+ ---
49
+
26
50
  ### TooLate
27
51
 
28
52
  ```ts
@@ -581,6 +605,10 @@ Bounded Session baseline at one opaque owner cursor.
581
605
 
582
606
  ```ts
583
607
  type SessionFrame =
608
+ | Readonly<{
609
+ kind: "activity";
610
+ activity: SessionActivity;
611
+ }>
584
612
  | Readonly<{
585
613
  kind: "tool_output";
586
614
  toolOutput: readonly SessionToolOutput[];
@@ -686,6 +714,10 @@ type ShiitakeSession = Readonly<{
686
714
  set: (preference) => Promise<void>;
687
715
  }>;
688
716
  read: (input?) => Promise<SessionSnapshot>;
717
+ readSettlement: (
718
+ commandId,
719
+ options?,
720
+ ) => Promise<CommandSettlement | undefined>;
689
721
  subscribe: (input) => AsyncIterable<SessionFrame>;
690
722
  watch: (input?) => Promise<SessionWatch>;
691
723
  }>;
@@ -924,8 +956,48 @@ const AcceptedSchema: Schema.Codec<Accepted>;
924
956
 
925
957
  Decode a durable command acceptance value at an RPC boundary.
926
958
 
959
+ ---
960
+
961
+ ### HeldSchema
962
+
963
+ ```ts
964
+ const HeldSchema: Schema.Codec<Held>;
965
+ ```
966
+
967
+ Parse the relay's custody acknowledgment without implying Agent acceptance.
968
+
969
+ ---
970
+
971
+ ### DelegationReceiptSchema
972
+
973
+ ```ts
974
+ const DelegationReceiptSchema: Schema.Codec<DelegationReceipt>;
975
+ ```
976
+
977
+ A delegated send is accepted by its owner or held in durable mail custody.
978
+
927
979
  ## Functions
928
980
 
981
+ ### parseDelegationReceipt()
982
+
983
+ ```ts
984
+ function parseDelegationReceipt(value): DelegationReceipt;
985
+ ```
986
+
987
+ Decode one delegated send's acceptance or durable-custody result.
988
+
989
+ #### Parameters
990
+
991
+ | Parameter | Type |
992
+ | --------- | -------- |
993
+ | `value` | `string` |
994
+
995
+ #### Returns
996
+
997
+ [`DelegationReceipt`](#delegationreceipt)
998
+
999
+ ---
1000
+
929
1001
  ### parseWithdrawResult()
930
1002
 
931
1003
  ```ts
@@ -1145,6 +1217,12 @@ Connect to a remotely hosted Shiitake agent.
1145
1217
 
1146
1218
  ## References
1147
1219
 
1220
+ ### CommandSettlement
1221
+
1222
+ Re-exports [CommandSettlement](index.md#commandsettlement)
1223
+
1224
+ ---
1225
+
1148
1226
  ### parseForkedSession
1149
1227
 
1150
1228
  Re-exports [parseForkedSession](index.md#parseforkedsession)
@@ -24,9 +24,9 @@ new AgentDelegation(deps): AgentDelegation;
24
24
 
25
25
  ###### Parameters
26
26
 
27
- | Parameter | Type |
28
- | --------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
29
- | `deps` | `Readonly`\<\{ `storage`: `WatchdogSqliteOwner`; `expiresAt`: () => `number`; `identity`: () => \| [`DelegationIdentity`](#delegationidentity) \| `null` \| `Promise`\<[`DelegationIdentity`](#delegationidentity) \| `null`\>; `directory`: () => [`AgentControlDirectory`](agent-control.md#agentcontroldirectory); `deliver`: (`mail`) => `Promise`\<[`Accepted`](client.md#accepted)\>; `prepare`: (`mail`) => `Promise`\<`void`\>; `accept`: (`mail`, `reply?`) => `Promise`\<[`Accepted`](client.md#accepted)\>; \}\> |
27
+ | Parameter | Type |
28
+ | --------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
29
+ | `deps` | `Readonly`\<\{ `storage`: `WatchdogSqliteOwner`; `expiresAt`: () => `number`; `identity`: () => \| [`DelegationIdentity`](#delegationidentity) \| `null` \| `Promise`\<[`DelegationIdentity`](#delegationidentity) \| `null`\>; `directory`: () => [`AgentControlDirectory`](agent-control.md#agentcontroldirectory); `deliver`: (`mail`) => `Promise`\<[`DelegationReceipt`](client.md#delegationreceipt)\>; `prepare`: (`mail`) => `Promise`\<`void`\>; `accept`: (`mail`, `reply?`) => `Promise`\<[`Accepted`](client.md#accepted)\>; \}\> |
30
30
 
31
31
  ###### Returns
32
32
 
@@ -79,10 +79,7 @@ send(
79
79
  sourceSessionId,
80
80
  signal,
81
81
  invocation?
82
- ): Promise<Readonly<{
83
- status: "accepted";
84
- commandId: string;
85
- }>>;
82
+ ): Promise<DelegationReceipt>;
86
83
  ```
87
84
 
88
85
  Delegate work to an in-scope Agent: steer its Session, or start fleet
@@ -99,7 +96,7 @@ correspondence.
99
96
 
100
97
  ###### Returns
101
98
 
102
- `Promise`\<`Readonly`\<\{ `status`: `"accepted"`; `commandId`: `string`; \}\>\>
99
+ `Promise`\<[`DelegationReceipt`](client.md#delegationreceipt)\>
103
100
 
104
101
  ##### recall()
105
102
 
@@ -205,13 +202,10 @@ new AgentMail(deps): AgentMail;
205
202
  ##### send()
206
203
 
207
204
  ```ts
208
- send(mail): Promise<Readonly<{
209
- status: "accepted";
210
- commandId: string;
211
- }>>;
205
+ send(mail): Promise<DelegationReceipt>;
212
206
  ```
213
207
 
214
- Submit one mail and return the recipient's Accepted receipt.
208
+ Submit one mail and return recipient acceptance or relay-held custody.
215
209
 
216
210
  ###### Parameters
217
211
 
@@ -221,7 +215,7 @@ Submit one mail and return the recipient's Accepted receipt.
221
215
 
222
216
  ###### Returns
223
217
 
224
- `Promise`\<`Readonly`\<\{ `status`: `"accepted"`; `commandId`: `string`; \}\>\>
218
+ `Promise`\<[`DelegationReceipt`](client.md#delegationreceipt)\>
225
219
 
226
220
  ##### mailRoom()
227
221
 
@@ -297,11 +291,11 @@ link routes Agent work without owning Shiitake's grammar.
297
291
 
298
292
  #### Type Declaration
299
293
 
300
- | Name | Type | Description |
301
- | ------------------- | ------------------------------------------------------------------- | ----------------------------------------------------------------------- |
302
- | `sessionCreation()` | (`body`) => \| `Readonly`\<\{ `requestId`: `string`; \}\> \| `null` | The Session-creation intent, or null when the body is not one. |
303
- | `settlement()` | (`encoded`) => [`CommandSettlement`](index.md#commandsettlement) | One serialized settlement from a hosted or machine-homed Agent. |
304
- | `accepted()` | (`receipt`) => `void` | Throws unless an acknowledgment carries a well-formed Accepted receipt. |
294
+ | Name | Type | Description |
295
+ | ------------------- | ------------------------------------------------------------------- | -------------------------------------------------------------------------- |
296
+ | `sessionCreation()` | (`body`) => \| `Readonly`\<\{ `requestId`: `string`; \}\> \| `null` | The Session-creation intent, or null when the body is not one. |
297
+ | `settlement()` | (`encoded`) => [`CommandSettlement`](index.md#commandsettlement) | One serialized settlement from a hosted or machine-homed Agent. |
298
+ | `accepted()` | (`receipt`) => `void` | Throws unless an acknowledgment carries a valid acceptance or Held result. |
305
299
 
306
300
  ## Functions
307
301
 
@@ -324,11 +318,15 @@ function agentMailRoute(namespace, replySettlement): PostRoute<AgentMailAddress,
324
318
  content: string;
325
319
  createdAt: number;
326
320
  meta?: Json | undefined;
327
- reply?: {
321
+ reply?: | {
328
322
  commandId: string;
329
323
  outcome: "completed" | "failed" | "cancelled" | "interrupted" | "outcome_unknown";
330
324
  diagnostic?: string;
331
- };
325
+ }
326
+ | {
327
+ outcome: "undeliverable";
328
+ reason: "recipient_offline" | "recipient_left";
329
+ };
332
330
  }, {
333
331
  key: string;
334
332
  to: {
@@ -345,11 +343,15 @@ function agentMailRoute(namespace, replySettlement): PostRoute<AgentMailAddress,
345
343
  content: string;
346
344
  createdAt: number;
347
345
  meta?: Json | undefined;
348
- reply?: {
346
+ reply?: | {
349
347
  commandId: string;
350
348
  outcome: "completed" | "failed" | "cancelled" | "interrupted" | "outcome_unknown";
351
349
  diagnostic?: string;
352
- };
350
+ }
351
+ | {
352
+ outcome: "undeliverable";
353
+ reason: "recipient_offline" | "recipient_left";
354
+ };
353
355
  }, AgentMailAddress, {
354
356
  key: string;
355
357
  to: {
@@ -366,11 +368,15 @@ function agentMailRoute(namespace, replySettlement): PostRoute<AgentMailAddress,
366
368
  content: string;
367
369
  createdAt: number;
368
370
  meta?: Json | undefined;
369
- reply?: {
371
+ reply?: | {
370
372
  commandId: string;
371
373
  outcome: "completed" | "failed" | "cancelled" | "interrupted" | "outcome_unknown";
372
374
  diagnostic?: string;
373
- };
375
+ }
376
+ | {
377
+ outcome: "undeliverable";
378
+ reason: "recipient_offline" | "recipient_left";
379
+ };
374
380
  }, {
375
381
  key: string;
376
382
  to: {
@@ -387,13 +393,18 @@ function agentMailRoute(namespace, replySettlement): PostRoute<AgentMailAddress,
387
393
  content: string;
388
394
  createdAt: number;
389
395
  meta?: Json | undefined;
390
- reply?: {
396
+ reply?: | {
391
397
  commandId: string;
392
398
  outcome: "completed" | "failed" | "cancelled" | "interrupted" | "outcome_unknown";
393
399
  diagnostic?: string;
394
- };
400
+ }
401
+ | {
402
+ outcome: "undeliverable";
403
+ reason: "recipient_offline" | "recipient_left";
404
+ };
395
405
  }> & Omit<Readonly<{
396
406
  addressKind: string;
407
+ deadlineMs?: number;
397
408
  address: Codec<unknown, unknown>;
398
409
  event: Codec<unknown, unknown>;
399
410
  encodeEnvelope: (envelope) => object;
@@ -432,35 +443,41 @@ retries.
432
443
  `agentId`: `string`; `sessionId`: `string`; \}; `from`: \{ `kind`: `"agent"`;
433
444
  `agentId`: `string`; `sessionId`: `string`; \}; `replyTo`: readonly `object`[];
434
445
  `content`: `string`; `createdAt`: `number`; `meta?`: Json \| undefined;
435
- `reply?`: \{ `commandId`: `string`; `outcome`: `"completed"` \| `"failed"` \|
446
+ `reply?`: \| \{ `commandId`: `string`; `outcome`: `"completed"` \| `"failed"` \|
447
+ `"cancelled"` \| `"interrupted"` \| `"outcome_unknown"`; `diagnostic?`:
448
+ `string`; \} \| \{ `outcome`: `"undeliverable"`; `reason`: `"recipient_offline"`
449
+ \| `"recipient_left"`; \}; \}, \{ `key`: `string`; `to`: \{ `kind`: `"agent"`;
450
+ `agentId`: `string`; `sessionId`: `string`; \}; `from`: \{ `kind`: `"agent"`;
451
+ `agentId`: `string`; `sessionId`: `string`; \}; `replyTo`: readonly `object`[];
452
+ `content`: `string`; `createdAt`: `number`; `meta?`: Json \| undefined;
453
+ `reply?`: \| \{ `commandId`: `string`; `outcome`: `"completed"` \| `"failed"` \|
436
454
  `"cancelled"` \| `"interrupted"` \| `"outcome_unknown"`; `diagnostic?`:
437
- `string`; \}; \}, \{ `key`: `string`; `to`: \{ `kind`: `"agent"`; `agentId`:
438
- `string`; `sessionId`: `string`; \}; `from`: \{ `kind`: `"agent"`; `agentId`:
439
- `string`; `sessionId`: `string`; \}; `replyTo`: readonly `object`[]; `content`:
440
- `string`; `createdAt`: `number`; `meta?`: Json \| undefined; `reply?`: \{
441
- `commandId`: `string`; `outcome`: `"completed"` \| `"failed"` \| `"cancelled"`
442
- \| `"interrupted"` \| `"outcome_unknown"`; `diagnostic?`: `string`; \}; \},
443
- `AgentMailAddress`, \{ `key`: `string`; `to`: \{ `kind`: `"agent"`; `agentId`:
444
- `string`; `sessionId`: `string`; \}; `from`: \{ `kind`: `"agent"`; `agentId`:
445
- `string`; `sessionId`: `string`; \}; `replyTo`: readonly `object`[]; `content`:
446
- `string`; `createdAt`: `number`; `meta?`: Json \| undefined; `reply?`: \{
447
- `commandId`: `string`; `outcome`: `"completed"` \| `"failed"` \| `"cancelled"`
448
- \| `"interrupted"` \| `"outcome_unknown"`; `diagnostic?`: `string`; \}; \}, \{
449
- `key`: `string`; `to`: \{ `kind`: `"agent"`; `agentId`: `string`; `sessionId`:
450
- `string`; \}; `from`: \{ `kind`: `"agent"`; `agentId`: `string`; `sessionId`:
451
- `string`; \}; `replyTo`: readonly `object`[]; `content`: `string`; `createdAt`:
452
- `number`; `meta?`: Json \| undefined; `reply?`: \{ `commandId`: `string`;
453
- `outcome`: `"completed"` \| `"failed"` \| `"cancelled"` \| `"interrupted"` \|
454
- `"outcome_unknown"`; `diagnostic?`: `string`; \}; \}\> & `Omit`\<`Readonly`\<\{
455
- `addressKind`: `string`; `address`: `Codec`\<`unknown`, `unknown`\>; `event`:
456
- `Codec`\<`unknown`, `unknown`\>; `encodeEnvelope`: (`envelope`) => `object`;
457
- `parseDelivery`: (`envelope`) => `object`; `prepareEnvelope?`: (`envelope`,
458
- `signal`) => `Promise`\<\{ `key`: `string`; `kind`: `string`; `address`:
459
- `unknown`; `event`: `unknown`; \}\>; `recordDelivered?`: (`envelope`) => `void`;
460
- `nameOf`: (`envelope`) => `string`; `namespace`: `Readonly`\<\{ `getByName`:
461
- (`name`) => `Readonly`\<\{ `deliver`: (`envelope`) => `Promise`\<...\>; \}\>;
462
- \}\>; `recordCursor?`: (`envelope`, `cursor`) => `void`; `recordRefused?`:
463
- (`envelope`) => `void`; \}\>, `"event"` \| `"address"`\>
455
+ `string`; \} \| \{ `outcome`: `"undeliverable"`; `reason`: `"recipient_offline"`
456
+ \| `"recipient_left"`; \}; \}, `AgentMailAddress`, \{ `key`: `string`; `to`: \{
457
+ `kind`: `"agent"`; `agentId`: `string`; `sessionId`: `string`; \}; `from`: \{
458
+ `kind`: `"agent"`; `agentId`: `string`; `sessionId`: `string`; \}; `replyTo`:
459
+ readonly `object`[]; `content`: `string`; `createdAt`: `number`; `meta?`: Json
460
+ \| undefined; `reply?`: \| \{ `commandId`: `string`; `outcome`: `"completed"` \|
461
+ `"failed"` \| `"cancelled"` \| `"interrupted"` \| `"outcome_unknown"`;
462
+ `diagnostic?`: `string`; \} \| \{ `outcome`: `"undeliverable"`; `reason`:
463
+ `"recipient_offline"` \| `"recipient_left"`; \}; \}, \{ `key`: `string`; `to`:
464
+ \{ `kind`: `"agent"`; `agentId`: `string`; `sessionId`: `string`; \}; `from`: \{
465
+ `kind`: `"agent"`; `agentId`: `string`; `sessionId`: `string`; \}; `replyTo`:
466
+ readonly `object`[]; `content`: `string`; `createdAt`: `number`; `meta?`: Json
467
+ \| undefined; `reply?`: \| \{ `commandId`: `string`; `outcome`: `"completed"` \|
468
+ `"failed"` \| `"cancelled"` \| `"interrupted"` \| `"outcome_unknown"`;
469
+ `diagnostic?`: `string`; \} \| \{ `outcome`: `"undeliverable"`; `reason`:
470
+ `"recipient_offline"` \| `"recipient_left"`; \}; \}\> & `Omit`\<`Readonly`\<\{
471
+ `addressKind`: `string`; `deadlineMs?`: `number`; `address`: `Codec`\<`unknown`,
472
+ `unknown`\>; `event`: `Codec`\<`unknown`, `unknown`\>; `encodeEnvelope`:
473
+ (`envelope`) => `object`; `parseDelivery`: (`envelope`) => `object`;
474
+ `prepareEnvelope?`: (`envelope`, `signal`) => `Promise`\<\{ `key`: `string`;
475
+ `kind`: `string`; `address`: `unknown`; `event`: `unknown`; \}\>;
476
+ `recordDelivered?`: (`envelope`) => `void`; `nameOf`: (`envelope`) => `string`;
477
+ `namespace`: `Readonly`\<\{ `getByName`: (`name`) => `Readonly`\<\{ `deliver`:
478
+ (`envelope`) => `Promise`\<...\>; \}\>; \}\>; `recordCursor?`: (`envelope`,
479
+ `cursor`) => `void`; `recordRefused?`: (`envelope`) => `void`; \}\>, `"event"`
480
+ \| `"address"`\>
464
481
 
465
482
  ---
466
483
 
@@ -36,6 +36,7 @@ type ModelAcquisitionEffect = Readonly<{
36
36
  retryAfterMs?: (message) => number | undefined;
37
37
  retryable: (message) => boolean;
38
38
  failureReason?: (message) => string | undefined;
39
+ providerError?: (message) => string | undefined;
39
40
  release: Effect.Effect<void, ShiitakeError>;
40
41
  }>;
41
42
  ```
@@ -322,6 +323,10 @@ type ShiitakeEffectSession = Readonly<{
322
323
  set: (preference) => Effect.Effect<void, ShiitakeError>;
323
324
  }>;
324
325
  read: (input?) => Effect.Effect<SessionSnapshot, ShiitakeError>;
326
+ readSettlement: (
327
+ commandId,
328
+ timeoutMs?,
329
+ ) => Effect.Effect<CommandSettlement | undefined, ShiitakeError>;
325
330
  subscribe: (input) => Stream.Stream<SessionFrame, ShiitakeError>;
326
331
  watch: (input?) => Effect.Effect<ShiitakeEffectWatch, ShiitakeError>;
327
332
  }>;
package/docs/api/fleet.md CHANGED
@@ -217,7 +217,7 @@ Exact settled Session facts, including Pi usage and tool-call records.
217
217
  ```ts
218
218
  type FleetDelegationOptions = Readonly<{
219
219
  storage: WatchdogSqliteOwner;
220
- deliver: (mail) => Promise<Accepted>;
220
+ deliver: (mail) => Promise<DelegationReceipt>;
221
221
  readSettlement: (
222
222
  agentId,
223
223
  sessionId,
@@ -364,6 +364,16 @@ One idempotent prompt, using the Session owner's existing delivery grammar.
364
364
 
365
365
  ## Variables
366
366
 
367
+ ### commandSettlementSchema
368
+
369
+ ```ts
370
+ const commandSettlementSchema: Schema.Codec<CommandSettlement>;
371
+ ```
372
+
373
+ Exact command facts shared by Session clients and host fleet transports.
374
+
375
+ ---
376
+
367
377
  ### agentActionSchema
368
378
 
369
379
  ```ts
@@ -523,16 +533,6 @@ const agentDelegationTaskSchema: ZodLazy<
523
533
 
524
534
  Replay identity and work, with the parent supplied exclusively by the grant.
525
535
 
526
- ---
527
-
528
- ### commandSettlementSchema
529
-
530
- ```ts
531
- const commandSettlementSchema: Schema.Codec<CommandSettlement>;
532
- ```
533
-
534
- Exact host facts encoded over internal transports, without transcript content.
535
-
536
536
  ## Functions
537
537
 
538
538
  ### assertAgentGrant()
@@ -700,11 +700,11 @@ Shiitake owns work deduplication, execution and settlement; Post owns replies.
700
700
 
701
701
  #### Returns
702
702
 
703
- | Name | Type | Description |
704
- | --------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
705
- | `start()` | (`grant`, `raw`) => `Promise`\<`Readonly`\<\{ `status`: `"accepted"`; `commandId`: `string`; \}\>\> | Submit frozen mail or reuse its recorded Session admission receipt. |
706
- | `authenticateReply()` | (`mail`) => \| `Readonly`\<\{ `ancestors`: readonly `string`[]; `maxDepth`: `number`; `reply`: \{ `commandId`: `string`; `outcome`: `"completed"` \| `"failed"` \| `"cancelled"` \| `"interrupted"` \| `"outcome_unknown"`; `diagnostic?`: `string`; `agentId`: `string`; `sessionId`: `string`; \}; \}\> \| `undefined` | Match a reply to frozen mail and restore the caller's delegation path. Authenticate one arriving reply against the frozen mail this owner sent. It must be BirdDog's single reply key for that mail, mirror its sender and recipient exactly, carry BirdDog's settlement facts and, once the send's receipt is recorded, name that receipt's `commandId`. The result restores the caller's own delegation path and the verified reply; it never reads the reply's text or any settlement metadata. |
707
- | `receipt()` | (`requestId`) => \| `Readonly`\<\{ `status`: `"accepted"`; `commandId`: `string`; \}\> \| `undefined` | Read an existing acceptance receipt without reserving or delivering mail. Read only the existing acceptance receipt; do not reserve or deliver mail. |
703
+ | Name | Type | Description |
704
+ | --------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
705
+ | `start()` | (`grant`, `raw`) => `Promise`\<[`DelegationReceipt`](client.md#delegationreceipt)\> | Submit frozen mail or reuse its recorded Session admission receipt. |
706
+ | `authenticateReply()` | (`mail`) => \| `Readonly`\<\{ `ancestors`: readonly `string`[]; `maxDepth`: `number`; `reply`: \| \{ `commandId`: `string`; `outcome`: `"completed"` \| `"failed"` \| `"cancelled"` \| `"interrupted"` \| `"outcome_unknown"`; `diagnostic?`: `string`; `agentId`: `string`; `sessionId`: `string`; \} \| \{ `outcome`: `"undeliverable"`; `reason`: `"recipient_offline"` \| `"recipient_left"`; `agentId`: `string`; `sessionId`: `string`; \}; \}\> \| `undefined` | Match a reply to frozen mail and restore the caller's delegation path. Authenticate one arriving reply against the frozen mail this owner sent. It must be BirdDog's single reply key for that mail, mirror its sender and recipient exactly, carry BirdDog's settlement facts and, once the send's receipt is recorded, name that receipt's `commandId`. The result restores the caller's own delegation path and the verified reply; it never reads the reply's text or any settlement metadata. |
707
+ | `receipt()` | (`requestId`) => \| `Readonly`\<\{ `status`: `"accepted"`; `commandId`: `string`; \}\> \| `undefined` | Read an existing acceptance receipt without reserving or delivering mail. Read only the existing acceptance receipt; do not reserve or deliver mail. |
708
708
 
709
709
  ---
710
710
 
@@ -725,13 +725,13 @@ it.
725
725
 
726
726
  #### Returns
727
727
 
728
- | Name | Type | Description |
729
- | --------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
730
- | `start()` | (`grant`, `raw`) => `Promise`\<`Readonly`\<\{ `status`: `"accepted"`; `commandId`: `string`; \}\>\> | Submit frozen mail or reuse its recorded Session admission receipt. |
731
- | `authenticateReply()` | (`mail`) => \| `Readonly`\<\{ `ancestors`: readonly `string`[]; `maxDepth`: `number`; `reply`: \{ `commandId`: `string`; `outcome`: `"completed"` \| `"failed"` \| `"cancelled"` \| `"interrupted"` \| `"outcome_unknown"`; `diagnostic?`: `string`; `agentId`: `string`; `sessionId`: `string`; \}; \}\> \| `undefined` | Match a reply to frozen mail and restore the caller's delegation path. Authenticate one arriving reply against the frozen mail this owner sent. It must be BirdDog's single reply key for that mail, mirror its sender and recipient exactly, carry BirdDog's settlement facts and, once the send's receipt is recorded, name that receipt's `commandId`. The result restores the caller's own delegation path and the verified reply; it never reads the reply's text or any settlement metadata. |
732
- | `receipt()` | (`requestId`) => \| `Readonly`\<\{ `status`: `"accepted"`; `commandId`: `string`; \}\> \| `undefined` | Read an existing acceptance receipt without reserving or delivering mail. Read only the existing acceptance receipt; do not reserve or deliver mail. |
733
- | `outstanding()` | () => `Promise`\< \| `Readonly`\<\{ `agentId`: `string`; `sessionId`: `string`; `commandId`: `string`; `unreadable?`: `string`; \}\> \| `undefined`\> | The delegated work this owner still waits on, if any. The newest delegation this owner sent whose work has not settled at its target, so the owner is still waiting for a reply; undefined when none. |
734
- | `delegate()` | (`grant`, `task`) => `Promise`\< \| `Readonly`\<\{ `kind`: `"pending"`; `retryAfterMs`: `number`; \}\> \| [`AgentDelegationOutcome`](#agentdelegationoutcome)\> | Submit or poll the exact turn, yielding Agar Pending until settled. |
728
+ | Name | Type | Description |
729
+ | --------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
730
+ | `start()` | (`grant`, `raw`) => `Promise`\<[`DelegationReceipt`](client.md#delegationreceipt)\> | Submit frozen mail or reuse its recorded Session admission receipt. |
731
+ | `authenticateReply()` | (`mail`) => \| `Readonly`\<\{ `ancestors`: readonly `string`[]; `maxDepth`: `number`; `reply`: \| \{ `commandId`: `string`; `outcome`: `"completed"` \| `"failed"` \| `"cancelled"` \| `"interrupted"` \| `"outcome_unknown"`; `diagnostic?`: `string`; `agentId`: `string`; `sessionId`: `string`; \} \| \{ `outcome`: `"undeliverable"`; `reason`: `"recipient_offline"` \| `"recipient_left"`; `agentId`: `string`; `sessionId`: `string`; \}; \}\> \| `undefined` | Match a reply to frozen mail and restore the caller's delegation path. Authenticate one arriving reply against the frozen mail this owner sent. It must be BirdDog's single reply key for that mail, mirror its sender and recipient exactly, carry BirdDog's settlement facts and, once the send's receipt is recorded, name that receipt's `commandId`. The result restores the caller's own delegation path and the verified reply; it never reads the reply's text or any settlement metadata. |
732
+ | `receipt()` | (`requestId`) => \| `Readonly`\<\{ `status`: `"accepted"`; `commandId`: `string`; \}\> \| `undefined` | Read an existing acceptance receipt without reserving or delivering mail. Read only the existing acceptance receipt; do not reserve or deliver mail. |
733
+ | `outstanding()` | () => `Promise`\< \| `Readonly`\<\{ `agentId`: `string`; `sessionId`: `string`; `commandId`: `string`; `unreadable?`: `string`; \}\> \| `undefined`\> | The delegated work this owner still waits on, if any. The newest delegation this owner sent whose work has not settled at its target, so the owner is still waiting for a reply; undefined when none. |
734
+ | `delegate()` | (`grant`, `task`) => `Promise`\< \| `Readonly`\<\{ `kind`: `"pending"`; `retryAfterMs`: `number`; \}\> \| [`AgentDelegationOutcome`](#agentdelegationoutcome)\> | Submit or poll the exact turn, yielding Agar Pending until settled. |
735
735
 
736
736
  ---
737
737
 
package/docs/api/http.md CHANGED
@@ -88,6 +88,7 @@ function createShiitakeHttpRoutes(
88
88
  object &
89
89
  object &
90
90
  object &
91
+ object &
91
92
  object,
92
93
  "/",
93
94
  "/sessions/:sessionId/events"
@@ -110,5 +111,5 @@ Build Shiitake's typed HTTP routes around an existing Session owner.
110
111
 
111
112
  `Hono`\<[`ShiitakeHttpEnv`](#shiitakehttpenv), `object` & `object` & `object` &
112
113
  `object` & `object` & `object` & `object` & `object` & `object` & `object` &
113
- `object` & `object` & `object` & `object`, `"/"`,
114
+ `object` & `object` & `object` & `object` & `object`, `"/"`,
114
115
  `"/sessions/:sessionId/events"`\>
package/docs/api/index.md CHANGED
@@ -415,6 +415,7 @@ type ModelAcquisition = Readonly<{
415
415
  retryable: (message) => boolean;
416
416
  retryAfterMs?: (message) => number | undefined;
417
417
  failureReason?: (message) => string | undefined;
418
+ providerError?: (message) => string | undefined;
418
419
  release: () => Promise<void>;
419
420
  }>;
420
421
  ```
@@ -978,6 +979,18 @@ Re-exports [Accepted](client.md#accepted)
978
979
 
979
980
  ---
980
981
 
982
+ ### DelegationReceipt
983
+
984
+ Re-exports [DelegationReceipt](client.md#delegationreceipt)
985
+
986
+ ---
987
+
988
+ ### Held
989
+
990
+ Re-exports [Held](client.md#held)
991
+
992
+ ---
993
+
981
994
  ### ForkedSession
982
995
 
983
996
  Re-exports [ForkedSession](client.md#forkedsession)
@@ -84,7 +84,7 @@ Optional canonical Agent inputs and a borrowed owner; defaults are in-memory.
84
84
  type MemoryHost = Readonly<{
85
85
  agent: ShiitakeOwnerAgent;
86
86
  reconcile: () => Promise<void>;
87
- settle: (sessionId, maxTicks?) => Promise<SessionSnapshot>;
87
+ settle: (sessionId, maxTicks?, beforeRead?) => Promise<SessionSnapshot>;
88
88
  close: () => Promise<void>;
89
89
  }>;
90
90
  ```
@@ -154,7 +154,7 @@ Script one model turn that replies with the system prompt it received.
154
154
  function memoryHost(options?): Promise<Readonly<{
155
155
  agent: ShiitakeOwnerAgent;
156
156
  reconcile: () => Promise<void>;
157
- settle: (sessionId, maxTicks?) => Promise<Readonly<{
157
+ settle: (sessionId, maxTicks?, beforeRead?) => Promise<Readonly<{
158
158
  sessionId: string;
159
159
  cursor: string | null;
160
160
  hasMore: boolean;
@@ -237,7 +237,7 @@ privileges. No submitted JavaScript is evaluated by this helper.
237
237
 
238
238
  `Promise`\<`Readonly`\<\{ `agent`:
239
239
  [`ShiitakeOwnerAgent`](index.md#shiitakeowneragent); `reconcile`: () =>
240
- `Promise`\<`void`\>; `settle`: (`sessionId`, `maxTicks?`) =>
240
+ `Promise`\<`void`\>; `settle`: (`sessionId`, `maxTicks?`, `beforeRead?`) =>
241
241
  `Promise`\<`Readonly`\<\{ `sessionId`: `string`; `cursor`: `string` \| `null`;
242
242
  `hasMore`: `boolean`; `oldestCursor?`: `string` \| `null`; `messages`: readonly
243
243
  `Readonly`\<\{ `requestId?`: ... \| ...; `meta?`: ... \| ...; `data?`: ... \|
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fungi.computer/shiitake",
3
- "version": "0.3.1",
3
+ "version": "0.4.0",
4
4
  "author": "Levi <levi@technomancy.dev>",
5
5
  "description": "Effect-native durable Session acceptance and bounded run orchestration",
6
6
  "type": "module",
@@ -82,19 +82,19 @@
82
82
  "node": ">=22.13"
83
83
  },
84
84
  "dependencies": {
85
- "@fungi.computer/bird-dog": "0.1.0",
85
+ "@fungi.computer/bird-dog": "0.2.0",
86
86
  "@fungi.computer/cairn": "0.1.0",
87
- "@fungi.computer/carrier": "0.1.0",
88
- "@fungi.computer/knapsack": "0.2.1",
89
- "@fungi.computer/mule": "0.1.1",
90
- "@fungi.computer/mycelium": "0.2.1",
91
- "@fungi.computer/seam": "0.1.0",
87
+ "@fungi.computer/carrier": "0.2.0",
88
+ "@fungi.computer/knapsack": "0.3.0",
89
+ "@fungi.computer/mule": "0.2.0",
90
+ "@fungi.computer/mycelium": "0.2.2",
91
+ "@fungi.computer/seam": "0.2.0",
92
92
  "@fungi.computer/watchdog": "0.1.0",
93
93
  "effect": "4.0.2",
94
94
  "zod": "4.4.3",
95
95
  "@earendil-works/pi-ai": "1.3.0",
96
96
  "@fungi.computer/gills": "0.2.0",
97
- "@fungi.computer/agar": "0.3.0"
97
+ "@fungi.computer/agar": "0.3.1"
98
98
  },
99
99
  "devDependencies": {
100
100
  "@cloudflare/workers-types": "5.20260828.1",
@@ -132,6 +132,7 @@
132
132
  "clean": "node --input-type=module --eval \"import { rm } from 'node:fs/promises'; await rm('dist', { recursive: true, force: true });\"",
133
133
  "test": "pnpm run test:unit && pnpm run test:merge",
134
134
  "test:unit": "vitest run",
135
+ "test:load": "vitest run --config vitest.load.config.ts",
135
136
  "test:merge": "node test/cloudflare-durable-wake.native.mjs && node test/woodstock-storage-conformance.native.mjs && pnpm run test:docs",
136
137
  "test:docs": "node --import tsx --test examples/bookmarks/checks.ts",
137
138
  "docs": "tsx ../../tooling/repository/src/docs/cli.ts check --root ../..",