@fungi.computer/shiitake 0.4.0 → 0.6.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 (68) hide show
  1. package/README.md +1 -10
  2. package/dist/agent-control.d.ts +98 -5
  3. package/dist/agent-control.js +111 -8
  4. package/dist/client-entry.d.ts +20 -0
  5. package/dist/client-entry.js +5 -0
  6. package/dist/client-visitor.d.ts +31 -0
  7. package/dist/client-visitor.js +226 -0
  8. package/dist/client-wire.d.ts +5 -0
  9. package/dist/client-wire.js +6 -0
  10. package/dist/client.d.ts +4 -3
  11. package/dist/client.js +1 -0
  12. package/dist/delegation.d.ts +100 -77
  13. package/dist/delegation.js +73 -23
  14. package/dist/effect.d.ts +25 -0
  15. package/dist/effect.js +14 -1
  16. package/dist/extensions.d.ts +21 -2
  17. package/dist/extensions.js +1 -1
  18. package/dist/fleet.d.ts +22 -2
  19. package/dist/fleet.js +127 -36
  20. package/dist/hosted.js +3 -0
  21. package/dist/http-routes.d.ts +11 -0
  22. package/dist/internal/accepted-run-executor.js +2 -1
  23. package/dist/internal/admission-door.d.ts +5 -0
  24. package/dist/internal/admission-door.js +34 -3
  25. package/dist/internal/contracts.d.ts +14 -1
  26. package/dist/internal/coordinator.js +8 -2
  27. package/dist/internal/effect-client.js +1 -1
  28. package/dist/internal/effect-contracts.d.ts +4 -2
  29. package/dist/internal/extension-command-registry.d.ts +2 -1
  30. package/dist/internal/extension-command-registry.js +3 -1
  31. package/dist/internal/extension-runtime.d.ts +3 -1
  32. package/dist/internal/extension-runtime.js +13 -5
  33. package/dist/internal/model-acquisition.js +2 -0
  34. package/dist/internal/observation-kernel.d.ts +2 -0
  35. package/dist/internal/observation-kernel.js +17 -6
  36. package/dist/internal/run-scope.d.ts +14 -0
  37. package/dist/internal/run-scope.js +32 -9
  38. package/dist/internal/runtime-coordinator.js +8 -1
  39. package/dist/internal/runtime-reconciliation.js +119 -24
  40. package/dist/internal/woodstock/agent-reply.d.ts +5 -0
  41. package/dist/internal/woodstock/agent-reply.js +3 -0
  42. package/dist/internal/woodstock/client-projection.js +9 -1
  43. package/dist/internal/woodstock/fleet-store.d.ts +1 -0
  44. package/dist/internal/woodstock/fleet-store.js +28 -1
  45. package/dist/internal/woodstock/index.d.ts +4 -0
  46. package/dist/internal/woodstock/index.js +7 -0
  47. package/dist/internal/woodstock/session-delegator.d.ts +12 -0
  48. package/dist/internal/woodstock/session-delegator.js +44 -0
  49. package/dist/internal/woodstock/session-entry.d.ts +12 -2
  50. package/dist/internal/woodstock/session-store.d.ts +2 -0
  51. package/dist/internal/woodstock/session-store.js +20 -0
  52. package/dist/internal/woodstock/work-senders.d.ts +32 -0
  53. package/dist/internal/woodstock/work-senders.js +70 -0
  54. package/dist/remote-client.js +7 -2
  55. package/dist/server-visitor-stream.d.ts +13 -0
  56. package/dist/server-visitor-stream.js +115 -0
  57. package/dist/session-attention.d.ts +30 -0
  58. package/dist/session-attention.js +14 -0
  59. package/docs/api/agent-control.md +209 -13
  60. package/docs/api/client-entry.md +3 -0
  61. package/docs/api/client.md +136 -1
  62. package/docs/api/cloudflare.md +7 -1
  63. package/docs/api/delegation.md +234 -61
  64. package/docs/api/effect.md +16 -6
  65. package/docs/api/extensions.md +65 -4
  66. package/docs/api/fleet.md +69 -16
  67. package/docs/api/index.md +6 -4
  68. package/package.json +10 -6
package/docs/api/fleet.md CHANGED
@@ -73,7 +73,7 @@ new DirectoryError(status, code): DirectoryError;
73
73
  | Parameter | Type |
74
74
  | --------- | --------------------------------------------------------------------------------------------------------------------------------- |
75
75
  | `status` | `400` \| `403` \| `404` \| `409` \| `503` |
76
- | `code` | \| `"not_found"` \| `"invalid_input"` \| `"name_taken"` \| `"request_conflict"` \| `"computer_team_conflict"` \| `"partial_init"` |
76
+ | `code` | \| `"not_found"` \| `"request_conflict"` \| `"invalid_input"` \| `"name_taken"` \| `"computer_team_conflict"` \| `"partial_init"` |
77
77
 
78
78
  ###### Returns
79
79
 
@@ -98,15 +98,39 @@ readonly status: 400 | 403 | 404 | 409 | 503;
98
98
  ```ts
99
99
  readonly code:
100
100
  | "not_found"
101
+ | "request_conflict"
101
102
  | "invalid_input"
102
103
  | "name_taken"
103
- | "request_conflict"
104
104
  | "computer_team_conflict"
105
105
  | "partial_init";
106
106
  ```
107
107
 
108
108
  ## Type Aliases
109
109
 
110
+ ### AgentDelegationRequestKeyInput
111
+
112
+ ```ts
113
+ type AgentDelegationRequestKeyInput = Readonly<{
114
+ owner:
115
+ | Readonly<{
116
+ kind: "local";
117
+ agentId: string;
118
+ }>
119
+ | Readonly<{
120
+ kind: "hosted";
121
+ scopeId: string;
122
+ agentId: string;
123
+ }>;
124
+ sourceSessionId: string;
125
+ targetAgentId: string;
126
+ requestId: string;
127
+ }>;
128
+ ```
129
+
130
+ Inputs shared by Local and hosted delegation request identity.
131
+
132
+ ---
133
+
110
134
  ### AgentAction
111
135
 
112
136
  ```ts
@@ -535,6 +559,28 @@ Replay identity and work, with the parent supplied exclusively by the grant.
535
559
 
536
560
  ## Functions
537
561
 
562
+ ### agentDelegationRequestKey()
563
+
564
+ ```ts
565
+ function agentDelegationRequestKey(input): Promise<string>;
566
+ ```
567
+
568
+ One idempotency identity for a caller-owned delegation request. The target
569
+ Session is deliberately excluded: a sessionless send learns it only after
570
+ acceptance, when recall must still resolve the original receipt.
571
+
572
+ #### Parameters
573
+
574
+ | Parameter | Type |
575
+ | --------- | ------------------------------------------------------------------- |
576
+ | `input` | [`AgentDelegationRequestKeyInput`](#agentdelegationrequestkeyinput) |
577
+
578
+ #### Returns
579
+
580
+ `Promise`\<`string`\>
581
+
582
+ ---
583
+
538
584
  ### assertAgentGrant()
539
585
 
540
586
  ```ts
@@ -666,8 +712,9 @@ that reply's own line and never travel onward.
666
712
  function delegationReplyMeta(delegation, replierName): DelegationReplyMeta;
667
713
  ```
668
714
 
669
- The host metadata for one authenticated reply line: the replying Agent is its
670
- author, and the verified reply rides beside the caller's own path.
715
+ The host metadata for one authenticated reply line. An ordinary reply is
716
+ authored by its replying Agent; a delivery failure is a Hub/system fact, while
717
+ the verified reply retains the failed recipient's identity.
671
718
 
672
719
  #### Parameters
673
720
 
@@ -700,11 +747,14 @@ Shiitake owns work deduplication, execution and settlement; Post owns replies.
700
747
 
701
748
  #### Returns
702
749
 
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. |
750
+ | Name | Type | Description |
751
+ | ---------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
752
+ | `start()` | (`grant`, `raw`) => `Promise`\<[`DelegationReceipt`](client.md#delegationreceipt)\> | Submit frozen mail or reuse its recorded Session admission receipt. |
753
+ | `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. |
754
+ | `recordLocalUndeliverable()` | (`original`, `reply`) => `boolean` | Bind exhausted local delivery to its frozen sender correspondence. Bind an exhausted local Carrier row to its frozen sender correspondence. |
755
+ | `recordUndeliverableReply()` | (`mailKey`) => `boolean` | Prevent replay after a system undeliverable reply is admitted. Make a successfully admitted system disposition replay-ineligible. |
756
+ | `receipt()` | (`requestId`) => \| `Readonly`\<\{ `status`: `"accepted"`; `commandId`: `string`; `sessionId?`: `string`; \}\> \| `undefined` | Read an existing acceptance receipt without reserving or delivering mail. Read only the existing acceptance receipt; do not reserve or deliver mail. |
757
+ | `recordAcceptedNotice()` | (`mail`) => \| `Readonly`\<\{ `status`: `"accepted"`; `commandId`: `string`; `sessionId?`: `string`; \}\> \| `undefined` | Consume a recipient's stable `<mailKey>:accepted` notice. Atomically bind the recipient Session carried by a late acceptance notice. |
708
758
 
709
759
  ---
710
760
 
@@ -725,13 +775,16 @@ it.
725
775
 
726
776
  #### Returns
727
777
 
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. |
778
+ | Name | Type | Description |
779
+ | ---------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
780
+ | `start()` | (`grant`, `raw`) => `Promise`\<[`DelegationReceipt`](client.md#delegationreceipt)\> | Submit frozen mail or reuse its recorded Session admission receipt. |
781
+ | `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. |
782
+ | `recordLocalUndeliverable()` | (`original`, `reply`) => `boolean` | Bind exhausted local delivery to its frozen sender correspondence. Bind an exhausted local Carrier row to its frozen sender correspondence. |
783
+ | `recordUndeliverableReply()` | (`mailKey`) => `boolean` | Prevent replay after a system undeliverable reply is admitted. Make a successfully admitted system disposition replay-ineligible. |
784
+ | `receipt()` | (`requestId`) => \| `Readonly`\<\{ `status`: `"accepted"`; `commandId`: `string`; `sessionId?`: `string`; \}\> \| `undefined` | Read an existing acceptance receipt without reserving or delivering mail. Read only the existing acceptance receipt; do not reserve or deliver mail. |
785
+ | `recordAcceptedNotice()` | (`mail`) => \| `Readonly`\<\{ `status`: `"accepted"`; `commandId`: `string`; `sessionId?`: `string`; \}\> \| `undefined` | Consume a recipient's stable `<mailKey>:accepted` notice. Atomically bind the recipient Session carried by a late acceptance notice. |
786
+ | `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. |
787
+ | `delegate()` | (`grant`, `task`) => `Promise`\< \| `Readonly`\<\{ `kind`: `"pending"`; `retryAfterMs`: `number`; \}\> \| [`AgentDelegationOutcome`](#agentdelegationoutcome)\> | Submit or poll the exact turn, yielding Agar Pending until settled. |
735
788
 
736
789
  ---
737
790
 
package/docs/api/index.md CHANGED
@@ -224,7 +224,7 @@ type ShiitakeHost = Readonly<{
224
224
  commandId,
225
225
  ) => Promise<CommandSettlement | undefined>;
226
226
  agent: ShiitakeOwnerAgent;
227
- acceptMail: (mail, meta?, reply?) => Promise<Accepted>;
227
+ acceptMail: (mail, meta?, reply?, stageAcceptedNotice?) => Promise<Accepted>;
228
228
  }>;
229
229
  ```
230
230
 
@@ -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
+ rejection?: (message) => ProviderRejection | undefined;
418
419
  providerError?: (message) => string | undefined;
419
420
  release: () => Promise<void>;
420
421
  }>;
@@ -932,9 +933,10 @@ function makeHost(options, mailRoom): Promise<Readonly<{
932
933
  }>
933
934
  | undefined>;
934
935
  agent: ShiitakeOwnerAgent;
935
- acceptMail: (mail, meta?, reply?) => Promise<Readonly<{
936
+ acceptMail: (mail, meta?, reply?, stageAcceptedNotice?) => Promise<Readonly<{
936
937
  status: "accepted";
937
938
  commandId: string;
939
+ sessionId?: string;
938
940
  }>>;
939
941
  }>>;
940
942
  ```
@@ -956,8 +958,8 @@ Construct the host-only Promise facade over the canonical Effect program.
956
958
  readonly `Pick`\<`AssistantMessage`, ... \| ... \| ...\>[]; `toolCalls`:
957
959
  `number`; \}\> \| `undefined`\>; `agent`:
958
960
  [`ShiitakeOwnerAgent`](#shiitakeowneragent); `acceptMail`: (`mail`, `meta?`,
959
- `reply?`) => `Promise`\<`Readonly`\<\{ `status`: `"accepted"`; `commandId`:
960
- `string`; \}\>\>; \}\>\>
961
+ `reply?`, `stageAcceptedNotice?`) => `Promise`\<`Readonly`\<\{ `status`:
962
+ `"accepted"`; `commandId`: `string`; `sessionId?`: `string`; \}\>\>; \}\>\>
961
963
 
962
964
  ## References
963
965
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fungi.computer/shiitake",
3
- "version": "0.4.0",
3
+ "version": "0.6.0",
4
4
  "author": "Levi <levi@technomancy.dev>",
5
5
  "description": "Effect-native durable Session acceptance and bounded run orchestration",
6
6
  "type": "module",
@@ -19,6 +19,10 @@
19
19
  "types": "./dist/client.d.ts",
20
20
  "import": "./dist/client.js"
21
21
  },
22
+ "./server-visitor-stream": {
23
+ "types": "./dist/server-visitor-stream.d.ts",
24
+ "import": "./dist/server-visitor-stream.js"
25
+ },
22
26
  "./agent-control": {
23
27
  "types": "./dist/agent-control.d.ts",
24
28
  "import": "./dist/agent-control.js"
@@ -82,19 +86,19 @@
82
86
  "node": ">=22.13"
83
87
  },
84
88
  "dependencies": {
85
- "@fungi.computer/bird-dog": "0.2.0",
89
+ "@fungi.computer/bird-dog": "0.3.0",
86
90
  "@fungi.computer/cairn": "0.1.0",
87
91
  "@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",
92
+ "@fungi.computer/knapsack": "0.4.0",
93
+ "@fungi.computer/mule": "0.2.1",
94
+ "@fungi.computer/mycelium": "0.2.3",
91
95
  "@fungi.computer/seam": "0.2.0",
92
96
  "@fungi.computer/watchdog": "0.1.0",
93
97
  "effect": "4.0.2",
94
98
  "zod": "4.4.3",
95
99
  "@earendil-works/pi-ai": "1.3.0",
96
100
  "@fungi.computer/gills": "0.2.0",
97
- "@fungi.computer/agar": "0.3.1"
101
+ "@fungi.computer/agar": "0.5.0"
98
102
  },
99
103
  "devDependencies": {
100
104
  "@cloudflare/workers-types": "5.20260828.1",