@fungi.computer/shiitake 0.3.1 → 0.5.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 +19 -18
  2. package/dist/agent-control.d.ts +24 -19
  3. package/dist/agent-control.js +69 -128
  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 +151 -17
  11. package/dist/delegation.js +174 -41
  12. package/dist/effect.d.ts +1 -1
  13. package/dist/fleet.d.ts +37 -10
  14. package/dist/fleet.js +217 -48
  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 +9 -2
  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 +4 -2
  44. package/dist/internal/woodstock/fleet-store.js +70 -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
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.5.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.1",
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.1",
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.4.0"
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 ../..",