@fungi.computer/shiitake 0.6.0 → 0.8.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 (67) hide show
  1. package/README.md +59 -21
  2. package/dist/agent-control.d.ts +1 -1
  3. package/dist/agent-control.js +40 -21
  4. package/dist/client-visitor.d.ts +2 -0
  5. package/dist/client-visitor.js +6 -1
  6. package/dist/client-wire.d.ts +4 -0
  7. package/dist/client-wire.js +26 -15
  8. package/dist/client.d.ts +23 -11
  9. package/dist/client.js +22 -0
  10. package/dist/cloudflare.d.ts +20 -0
  11. package/dist/cloudflare.js +4 -1
  12. package/dist/delegation.d.ts +5 -0
  13. package/dist/delegation.js +24 -8
  14. package/dist/effect.d.ts +1 -1
  15. package/dist/errors.d.ts +2 -2
  16. package/dist/errors.js +2 -0
  17. package/dist/extensions.d.ts +1 -1
  18. package/dist/fleet.d.ts +14 -2
  19. package/dist/fleet.js +81 -19
  20. package/dist/http-routes.d.ts +12 -16
  21. package/dist/http.d.ts +1 -0
  22. package/dist/http.js +1 -0
  23. package/dist/index.d.ts +1 -1
  24. package/dist/internal/admission-door.d.ts +1 -1
  25. package/dist/internal/admission-door.js +8 -4
  26. package/dist/internal/contracts.d.ts +5 -0
  27. package/dist/internal/coordinator.js +107 -50
  28. package/dist/internal/effect-contracts.d.ts +5 -0
  29. package/dist/internal/extension-runtime.js +5 -3
  30. package/dist/internal/observation-kernel.js +12 -3
  31. package/dist/internal/promise-facade.js +2 -0
  32. package/dist/internal/run-scope.d.ts +1 -0
  33. package/dist/internal/run-scope.js +29 -7
  34. package/dist/internal/runtime-coordinator.d.ts +14 -0
  35. package/dist/internal/runtime-coordinator.js +57 -10
  36. package/dist/internal/runtime-core.d.ts +3 -0
  37. package/dist/internal/runtime-core.js +1 -0
  38. package/dist/internal/runtime-reconciliation.js +4 -1
  39. package/dist/internal/session-context.d.ts +5 -5
  40. package/dist/internal/session-context.js +80 -83
  41. package/dist/internal/session-status.d.ts +4 -2
  42. package/dist/internal/session-status.js +22 -4
  43. package/dist/internal/woodstock/client-projection.js +5 -11
  44. package/dist/internal/woodstock/fleet-store.d.ts +3 -2
  45. package/dist/internal/woodstock/fleet-store.js +24 -4
  46. package/dist/internal/woodstock/index.d.ts +3 -3
  47. package/dist/internal/woodstock/index.js +18 -7
  48. package/dist/internal/woodstock/progress.d.ts +13 -1
  49. package/dist/internal/woodstock/progress.js +130 -24
  50. package/dist/internal/woodstock/session-delegator.d.ts +2 -1
  51. package/dist/internal/woodstock/session-store.d.ts +14 -2
  52. package/dist/internal/woodstock/session-store.js +329 -66
  53. package/dist/node.js +11 -2
  54. package/dist/server-visitor-stream.js +33 -24
  55. package/dist/testing.d.ts +2 -0
  56. package/dist/testing.js +2 -0
  57. package/docs/api/agent-control.md +3 -2
  58. package/docs/api/client.md +79 -19
  59. package/docs/api/cloudflare.md +16 -0
  60. package/docs/api/delegation.md +84 -50
  61. package/docs/api/effect.md +85 -7
  62. package/docs/api/extensions.md +8 -8
  63. package/docs/api/fleet.md +118 -29
  64. package/docs/api/http.md +28 -0
  65. package/docs/api/index.md +39 -15
  66. package/docs/api/testing.md +20 -7
  67. package/package.json +5 -5
@@ -54,26 +54,17 @@ export function visitorStream(options) {
54
54
  });
55
55
  }, 30_000);
56
56
  };
57
- const publish = async (snapshot, progressOnly) => {
57
+ const publish = async (snapshot) => {
58
58
  if (!(await admitted()))
59
59
  return false;
60
60
  const baseline = visitorSnapshot(options.filter(snapshot), options.visitorId);
61
- await stream.writeSSE(progressOnly
62
- ? {
63
- event: "frame",
64
- data: JSON.stringify({
65
- kind: "progress",
66
- progress: baseline.progress,
67
- activity: baseline.activity,
68
- }),
69
- }
70
- : { event: "session", data: JSON.stringify(baseline) });
61
+ await stream.writeSSE({ event: "session", data: JSON.stringify(baseline) });
71
62
  return !ending;
72
63
  };
73
64
  const pump = async () => {
74
65
  try {
75
66
  let snapshot = options.watch.snapshot;
76
- if (!(await publish(snapshot, false)))
67
+ if (!(await publish(snapshot)))
77
68
  return;
78
69
  heartbeat = setTimeout(() => {
79
70
  void beat().catch((cause) => {
@@ -88,19 +79,37 @@ export function visitorStream(options) {
88
79
  break;
89
80
  if (frame.kind === "tool_output")
90
81
  continue;
82
+ if (frame.kind === "progress" || frame.kind === "activity") {
83
+ if (!(await admitted()))
84
+ break;
85
+ snapshot = { ...snapshot, activity: frame.activity };
86
+ const baseline = visitorSnapshot(options.filter(snapshot), options.visitorId);
87
+ if (baseline.activity.queue.state === "idle") {
88
+ if (frame.kind === "activity")
89
+ await stream.writeSSE({
90
+ event: "session",
91
+ data: JSON.stringify(baseline),
92
+ });
93
+ continue;
94
+ }
95
+ await stream.writeSSE({
96
+ event: "frame",
97
+ data: JSON.stringify(frame.kind === "activity"
98
+ ? { kind: "activity", activity: baseline.activity }
99
+ : {
100
+ ...frame,
101
+ progress: {
102
+ ...frame.progress,
103
+ thinking: { offset: 0, append: "" },
104
+ },
105
+ activity: baseline.activity,
106
+ }),
107
+ });
108
+ continue;
109
+ }
91
110
  snapshot =
92
- frame.kind === "progress"
93
- ? {
94
- ...snapshot,
95
- progress: frame.progress,
96
- activity: frame.activity,
97
- }
98
- : frame.kind === "activity"
99
- ? { ...snapshot, activity: frame.activity }
100
- : frame.kind === "reset"
101
- ? frame.baseline
102
- : await options.read();
103
- if (!(await publish(snapshot, frame.kind === "progress")))
111
+ frame.kind === "reset" ? frame.baseline : await options.read();
112
+ if (!(await publish(snapshot)))
104
113
  break;
105
114
  }
106
115
  }
package/dist/testing.d.ts CHANGED
@@ -1,6 +1,8 @@
1
1
  import { type FauxResponseStep } from "@fungi.computer/mule/testing";
2
2
  import type { ExtensionRosterV0, Json, RosteredExtensionV0 } from "./extensions.js";
3
3
  import { type ModelSource, type SessionSnapshot, type ShiitakeOwnerAgent, type ShiitakeOptions, type SqliteOwner } from "./index.js";
4
+ /** Product finalizer grace, exposed for tests that wait for durable queue settlement. */
5
+ export { runFinalizerGraceMs } from "./internal/run-scope.js";
4
6
  /** A deterministic model source for trusted tests; no provider account or I/O. */
5
7
  export declare function fauxModelSource(replies: readonly FauxResponseStep[]): ModelSource;
6
8
  /** One scripted model tool call; the scripted sandbox runs exactly this call. */
package/dist/testing.js CHANGED
@@ -7,6 +7,8 @@ import * as z from "zod";
7
7
  import { fauxAssistantMessage, fauxToolCall, } from "@earendil-works/pi-ai/providers/faux";
8
8
  import { GuestThrew } from "@fungi.computer/mycelium";
9
9
  import { Shiitake, } from "./index.js";
10
+ /** Product finalizer grace, exposed for tests that wait for durable queue settlement. */
11
+ export { runFinalizerGraceMs } from "./internal/run-scope.js";
10
12
  const settlementBudgetSchema = z.int().min(1).max(1_000).default(1_000);
11
13
  /** A deterministic model source for trusted tests; no provider account or I/O. */
12
14
  export function fauxModelSource(replies) {
@@ -31,7 +31,7 @@ new AgentArchiveRefused(reason, message): AgentArchiveRefused;
31
31
 
32
32
  | Parameter | Type |
33
33
  | --------- | ---------------------------------------------------------------------------------------------- |
34
- | `reason` | \| `"running"` \| `"pending"` \| `"archived"` \| `"not_creator"` \| `"self"` \| `"unreadable"` |
34
+ | `reason` | \| `"archived"` \| `"running"` \| `"pending"` \| `"not_creator"` \| `"self"` \| `"unreadable"` |
35
35
  | `message` | `string` |
36
36
 
37
37
  ###### Returns
@@ -62,9 +62,9 @@ Error.name;
62
62
 
63
63
  ```ts
64
64
  readonly reason:
65
+ | "archived"
65
66
  | "running"
66
67
  | "pending"
67
- | "archived"
68
68
  | "not_creator"
69
69
  | "self"
70
70
  | "unreadable";
@@ -235,6 +235,7 @@ type AgentDelegationInput = Readonly<{
235
235
  | Readonly<{
236
236
  sessionId?: string;
237
237
  delivery: "followUp";
238
+ goal?: string | false;
238
239
  }>;
239
240
  ```
240
241
 
@@ -41,6 +41,16 @@ What a visitor may see of their own conversation Session.
41
41
 
42
42
  ---
43
43
 
44
+ ### VisitorLine
45
+
46
+ ```ts
47
+ type VisitorLine = VisitorView["lines"][number];
48
+ ```
49
+
50
+ One visitor-visible line without internal attribution or tool metadata.
51
+
52
+ ---
53
+
44
54
  ### VisitorPendingPrompt
45
55
 
46
56
  ```ts
@@ -399,21 +409,13 @@ Durable outcome for one accepted work item on the selected Session lineage.
399
409
  ### AgentRunningWork
400
410
 
401
411
  ```ts
402
- type AgentRunningWork =
403
- | Readonly<{
404
- kind: "session";
405
- sessionId: string;
406
- commandId: string;
407
- }>
408
- | Readonly<{
409
- kind: "host";
410
- lane: string;
411
- jobId: string;
412
- }>;
412
+ type AgentRunningWork = Readonly<{
413
+ phase:
414
+ "thinking" | "streaming" | "running_tool" | "waiting_on_you" | "cancelling";
415
+ }>;
413
416
  ```
414
417
 
415
- Work occupying the executor partition that this queued command requires, without
416
- message or provider data.
418
+ The occupying work's current phase; never its identity or transcript.
417
419
 
418
420
  ---
419
421
 
@@ -469,7 +471,7 @@ Encoded extension slots keyed by extension identity; absent means unavailable.
469
471
 
470
472
  ```ts
471
473
  type SessionExtensionControls = Readonly<{
472
- call: (command, input) => Promise<Json>;
474
+ call: (command, input, caller?) => Promise<Json>;
473
475
  }>;
474
476
  ```
475
477
 
@@ -515,6 +517,8 @@ type SessionProgress = Readonly<{
515
517
  revision: number;
516
518
  text: string;
517
519
  thinking: string;
520
+ textOffset: number;
521
+ thinkingOffset: number;
518
522
  textTruncated: boolean;
519
523
  thinkingTruncated: boolean;
520
524
  }>;
@@ -524,6 +528,27 @@ Process-local assistant progress; never a durable Session fact.
524
528
 
525
529
  ---
526
530
 
531
+ ### SessionProgressDelta
532
+
533
+ ```ts
534
+ type SessionProgressDelta = Readonly<{
535
+ messageId: string;
536
+ revision: number;
537
+ text: Readonly<{
538
+ offset: number;
539
+ append: string;
540
+ }>;
541
+ thinking: Readonly<{
542
+ offset: number;
543
+ append: string;
544
+ }>;
545
+ }>;
546
+ ```
547
+
548
+ Append-only progress on the wire. Offsets count JavaScript string units.
549
+
550
+ ---
551
+
527
552
  ### SessionPendingPrompt
528
553
 
529
554
  ```ts
@@ -679,7 +704,7 @@ type SessionFrame =
679
704
  }>
680
705
  | Readonly<{
681
706
  kind: "progress";
682
- progress: SessionProgress;
707
+ progress: SessionProgressDelta;
683
708
  activity: SessionActivity;
684
709
  }>
685
710
  | Readonly<{
@@ -1102,10 +1127,10 @@ operator replies.
1102
1127
 
1103
1128
  #### Parameters
1104
1129
 
1105
- | Parameter | Type |
1106
- | ----------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
1107
- | `snapshot` | \| `Readonly`\<\{ `sessionId`: `string`; `cursor`: `string` \| `null`; `hasMore`: `boolean`; `oldestCursor?`: `string` \| `null`; `messages`: readonly `Readonly`\<\{ `requestId?`: `string`; `meta?`: [`Json`](extensions.md#json); `data?`: [`Json`](extensions.md#json); `origin?`: `Readonly`\<\{ `extensionId`: `string`; `correlation`: `string` \| `null`; \}\>; `id`: `string`; `sequence`: `number`; `commandId`: `string` \| `null`; `value`: [`ModelMessage`](#modelmessage); \}\>[]; `terminals`: readonly `Readonly`\<\{ `commandId`: `string`; `outcome`: `"completed"` \| `"failed"` \| `"cancelled"` \| `"interrupted"`; `sequence`: `number`; `diagnostic`: `string` \| `null`; `meta?`: [`Json`](extensions.md#json); \}\>[]; `compactions?`: readonly `Readonly`\<\{ `id`: `string`; `sequence`: `number`; `at`: `number`; `tokensBefore`: `number`; `tokensAfter`: `number` \| `null`; `trigger`: [`SessionCompactionTrigger`](#sessioncompactiontrigger) \| `null`; \}\>[]; `compactionNotices?`: readonly `Readonly`\<\{ `id`: `string`; `sequence`: `number`; `at`: `number`; `trigger`: [`SessionCompactionTrigger`](#sessioncompactiontrigger); `result`: `"failed"` \| `"nothing_to_compact"` \| `"stale"` \| `"insufficient"`; `diagnostic`: `string` \| `null`; \}\>[]; `sandboxFailures?`: readonly `object`[]; `pending`: [`SessionPendingPrompts`](#sessionpendingprompts); `activity`: [`SessionActivity`](#sessionactivity); `progress`: \| `Readonly`\<\{ `messageId`: `string`; `revision`: `number`; `text`: `string`; `thinking`: `string`; `textTruncated`: `boolean`; `thinkingTruncated`: `boolean`; \}\> \| `null`; `toolOutput`: readonly `Readonly`\<\{ `toolCallId`: `string`; `revision`: `number`; `tail`: `string`; `droppedBytes`: `number`; `totalBytes`: `number`; \}\>[]; `extensions`: [`SessionExtensionSlots`](#sessionextensionslots); `attention`: readonly `object`[]; `context?`: `Readonly`\<\{ `tokens`: `number`; `window`: `number` \| `null`; \}\>; \}\> \| `null` |
1108
- | `visitorId` | `string` |
1130
+ | Parameter | Type |
1131
+ | ----------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
1132
+ | `snapshot` | \| `Readonly`\<\{ `sessionId`: `string`; `cursor`: `string` \| `null`; `hasMore`: `boolean`; `oldestCursor?`: `string` \| `null`; `messages`: readonly `Readonly`\<\{ `requestId?`: `string`; `meta?`: [`Json`](extensions.md#json); `data?`: [`Json`](extensions.md#json); `origin?`: `Readonly`\<\{ `extensionId`: `string`; `correlation`: `string` \| `null`; \}\>; `id`: `string`; `sequence`: `number`; `commandId`: `string` \| `null`; `value`: [`ModelMessage`](#modelmessage); \}\>[]; `terminals`: readonly `Readonly`\<\{ `commandId`: `string`; `outcome`: `"completed"` \| `"failed"` \| `"cancelled"` \| `"interrupted"`; `sequence`: `number`; `diagnostic`: `string` \| `null`; `meta?`: [`Json`](extensions.md#json); \}\>[]; `compactions?`: readonly `Readonly`\<\{ `id`: `string`; `sequence`: `number`; `at`: `number`; `tokensBefore`: `number`; `tokensAfter`: `number` \| `null`; `trigger`: [`SessionCompactionTrigger`](#sessioncompactiontrigger) \| `null`; \}\>[]; `compactionNotices?`: readonly `Readonly`\<\{ `id`: `string`; `sequence`: `number`; `at`: `number`; `trigger`: [`SessionCompactionTrigger`](#sessioncompactiontrigger); `result`: `"failed"` \| `"nothing_to_compact"` \| `"stale"` \| `"insufficient"`; `diagnostic`: `string` \| `null`; \}\>[]; `sandboxFailures?`: readonly `object`[]; `pending`: [`SessionPendingPrompts`](#sessionpendingprompts); `activity`: [`SessionActivity`](#sessionactivity); `progress`: \| `Readonly`\<\{ `messageId`: `string`; `revision`: `number`; `text`: `string`; `thinking`: `string`; `textOffset`: `number`; `thinkingOffset`: `number`; `textTruncated`: `boolean`; `thinkingTruncated`: `boolean`; \}\> \| `null`; `toolOutput`: readonly `Readonly`\<\{ `toolCallId`: `string`; `revision`: `number`; `tail`: `string`; `droppedBytes`: `number`; `totalBytes`: `number`; \}\>[]; `extensions`: [`SessionExtensionSlots`](#sessionextensionslots); `attention`: readonly `object`[]; `context?`: `Readonly`\<\{ `tokens`: `number`; `window`: `number` \| `null`; \}\>; \}\> \| `null` |
1133
+ | `visitorId` | `string` |
1109
1134
 
1110
1135
  #### Returns
1111
1136
 
@@ -1268,6 +1293,41 @@ Decode the existing bounded saved-conversation projection.
1268
1293
 
1269
1294
  ---
1270
1295
 
1296
+ ### appendSessionProgress()
1297
+
1298
+ ```ts
1299
+ function appendSessionProgress(
1300
+ current,
1301
+ delta,
1302
+ ): Readonly<{
1303
+ messageId: string;
1304
+ revision: number;
1305
+ text: string;
1306
+ thinking: string;
1307
+ textOffset: number;
1308
+ thinkingOffset: number;
1309
+ textTruncated: boolean;
1310
+ thinkingTruncated: boolean;
1311
+ }> | null;
1312
+ ```
1313
+
1314
+ Fold a decoded append once; a missing prefix waits for an owner reset.
1315
+
1316
+ #### Parameters
1317
+
1318
+ | Parameter | Type |
1319
+ | --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
1320
+ | `current` | \| `Readonly`\<\{ `messageId`: `string`; `revision`: `number`; `text`: `string`; `thinking`: `string`; `textOffset`: `number`; `thinkingOffset`: `number`; `textTruncated`: `boolean`; `thinkingTruncated`: `boolean`; \}\> \| `null` |
1321
+ | `delta` | [`SessionProgressDelta`](#sessionprogressdelta) |
1322
+
1323
+ #### Returns
1324
+
1325
+ \| `Readonly`\<\{ `messageId`: `string`; `revision`: `number`; `text`: `string`;
1326
+ `thinking`: `string`; `textOffset`: `number`; `thinkingOffset`: `number`;
1327
+ `textTruncated`: `boolean`; `thinkingTruncated`: `boolean`; \}\> \| `null`
1328
+
1329
+ ---
1330
+
1271
1331
  ### bindSessionExtension()
1272
1332
 
1273
1333
  ```ts
@@ -405,6 +405,9 @@ type CloudflareShiitakeOptions = Readonly<{
405
405
  instructions: InstructionSource;
406
406
  tools?: readonly [] | CloudflareShiitakeTools;
407
407
  storagePressure?: StoragePressureCheck;
408
+ admission?: Readonly<{
409
+ assertOpen: () => void;
410
+ }>;
408
411
  compaction?: CompactionOptions;
409
412
  extensions: ExtensionRosterV0;
410
413
  initialize?: (agent) => Promise<void>;
@@ -424,6 +427,19 @@ Cloudflare host inputs; the model owner resolves one frozen run selection.
424
427
  ```ts
425
428
  type CloudflareShiitake = ShiitakeOwnerAgent &
426
429
  Readonly<{
430
+ busySync: () =>
431
+ | Readonly<{
432
+ kind: "session";
433
+ sessionId: string;
434
+ commandId: string;
435
+ }>
436
+ | Readonly<{
437
+ kind: "delegation";
438
+ agentId: string;
439
+ sessionId: string;
440
+ commandId: string;
441
+ }>
442
+ | undefined;
427
443
  readSettlement: (
428
444
  sessionId,
429
445
  commandId,
@@ -34,6 +34,26 @@ new AgentDelegation(deps): AgentDelegation;
34
34
 
35
35
  #### Methods
36
36
 
37
+ ##### refreshOutstanding()
38
+
39
+ ```ts
40
+ refreshOutstanding(readSettlement): Promise<void>;
41
+ ```
42
+
43
+ Best-effort remote refresh before an owner-local archive transaction. Confirmed
44
+ settlements are recorded by Shiitake; unreadable targets leave their local
45
+ accepted receipt outstanding for busySync to refuse.
46
+
47
+ ###### Parameters
48
+
49
+ | Parameter | Type |
50
+ | ---------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
51
+ | `readSettlement` | (`agentId`, `sessionId`, `commandId`) => `Promise`\< \| `Readonly`\<\{ `acceptedSender`: `string` \| `null`; `delegator`: `string` \| `null`; `terminal`: [`SessionTerminal`](client.md#sessionterminal); `content`: `string`; `usage`: readonly `Pick`\<`AssistantMessage`, `"model"` \| `"provider"` \| `"usage"`\>[]; `toolCalls`: `number`; `waitingOnYou`: readonly `Readonly`\<\{ `itemId`: `string`; `kind`: `string`; `summary`: `string`; \}\>[]; \}\> \| `undefined`\> |
52
+
53
+ ###### Returns
54
+
55
+ `Promise`\<`void`\>
56
+
37
57
  ##### settlement()
38
58
 
39
59
  ```ts
@@ -45,10 +65,16 @@ settlement(
45
65
  ): Promise<
46
66
  | Readonly<{
47
67
  acceptedSender: string | null;
68
+ delegator: string | null;
48
69
  terminal: SessionTerminal;
49
70
  content: string;
50
71
  usage: readonly Pick<AssistantMessage, "model" | "provider" | "usage">[];
51
72
  toolCalls: number;
73
+ waitingOnYou: readonly Readonly<{
74
+ itemId: string;
75
+ kind: string;
76
+ summary: string;
77
+ }>[];
52
78
  }>
53
79
  | undefined>;
54
80
  ```
@@ -66,10 +92,12 @@ Recipient-local disclosure through the public host, never another Agent's RPC.
66
92
 
67
93
  ###### Returns
68
94
 
69
- `Promise`\< \| `Readonly`\<\{ `acceptedSender`: `string` \| `null`; `terminal`:
70
- [`SessionTerminal`](client.md#sessionterminal); `content`: `string`; `usage`:
71
- readonly `Pick`\<`AssistantMessage`, `"model"` \| `"provider"` \| `"usage"`\>[];
72
- `toolCalls`: `number`; \}\> \| `undefined`\>
95
+ `Promise`\< \| `Readonly`\<\{ `acceptedSender`: `string` \| `null`; `delegator`:
96
+ `string` \| `null`; `terminal`: [`SessionTerminal`](client.md#sessionterminal);
97
+ `content`: `string`; `usage`: readonly `Pick`\<`AssistantMessage`, `"model"` \|
98
+ `"provider"` \| `"usage"`\>[]; `toolCalls`: `number`; `waitingOnYou`: readonly
99
+ `Readonly`\<\{ `itemId`: `string`; `kind`: `string`; `summary`: `string`;
100
+ \}\>[]; \}\> \| `undefined`\>
73
101
 
74
102
  ##### send()
75
103
 
@@ -82,8 +110,8 @@ send(
82
110
  ): Promise<DelegationReceipt>;
83
111
  ```
84
112
 
85
- Delegate work to an in-scope Agent: steer its Session, or start fleet
86
- correspondence.
113
+ Delegate work to an in-scope Agent through fleet correspondence; a steer rides
114
+ the mail.
87
115
 
88
116
  ###### Parameters
89
117
 
@@ -366,6 +394,7 @@ function agentMailRoute(namespace, replySettlement): PostRoute<AgentMailAddress,
366
394
  commandId: string;
367
395
  outcome: "completed" | "failed" | "cancelled" | "interrupted" | "outcome_unknown";
368
396
  diagnostic?: string;
397
+ waitingOnYou?: readonly object[];
369
398
  }
370
399
  | {
371
400
  outcome: "accepted";
@@ -416,6 +445,7 @@ function agentMailRoute(namespace, replySettlement): PostRoute<AgentMailAddress,
416
445
  commandId: string;
417
446
  outcome: "completed" | "failed" | "cancelled" | "interrupted" | "outcome_unknown";
418
447
  diagnostic?: string;
448
+ waitingOnYou?: readonly object[];
419
449
  }
420
450
  | {
421
451
  outcome: "accepted";
@@ -466,6 +496,7 @@ function agentMailRoute(namespace, replySettlement): PostRoute<AgentMailAddress,
466
496
  commandId: string;
467
497
  outcome: "completed" | "failed" | "cancelled" | "interrupted" | "outcome_unknown";
468
498
  diagnostic?: string;
499
+ waitingOnYou?: readonly object[];
469
500
  }
470
501
  | {
471
502
  outcome: "accepted";
@@ -516,6 +547,7 @@ function agentMailRoute(namespace, replySettlement): PostRoute<AgentMailAddress,
516
547
  commandId: string;
517
548
  outcome: "completed" | "failed" | "cancelled" | "interrupted" | "outcome_unknown";
518
549
  diagnostic?: string;
550
+ waitingOnYou?: readonly object[];
519
551
  }
520
552
  | {
521
553
  outcome: "accepted";
@@ -595,7 +627,33 @@ retries.
595
627
  `PostRoute`\<`AgentMailAddress`, \| \{ `from`: \{ `kind`: `"agent"`; `agentId`:
596
628
  `string`; `sessionId`: `string`; \}; `reply?`: \| \{ `commandId`: `string`;
597
629
  `outcome`: `"completed"` \| `"failed"` \| `"cancelled"` \| `"interrupted"` \|
598
- `"outcome_unknown"`; `diagnostic?`: `string`; \} \| \{ `outcome`: `"accepted"`;
630
+ `"outcome_unknown"`; `diagnostic?`: `string`; `waitingOnYou?`: readonly
631
+ `object`[]; \} \| \{ `outcome`: `"accepted"`; `commandId`: `string`; \} \| \{
632
+ `outcome`: `"undeliverable"`; `reason`: `"recipient_left"`; \}; `key`: `string`;
633
+ `to`: \{ `kind`: `"agent"`; `agentId`: `string`; `sessionId?`: `string`; \};
634
+ `replyTo`: readonly `object`[]; `content`: `string`; `createdAt`: `number`;
635
+ `meta?`: Json \| undefined; \} \| \{ `from`: \{ `kind`: `"system"`; `systemId`:
636
+ `"hub"`; \}; `reply`: \{ `outcome`: `"undeliverable"`; `reason`:
637
+ `"recipient_offline"`; \}; `key`: `string`; `to`: \{ `kind`: `"agent"`;
638
+ `agentId`: `string`; `sessionId?`: `string`; \}; `replyTo`: readonly `object`[];
639
+ `content`: `string`; `createdAt`: `number`; `meta?`: Json \| undefined; \}, \|
640
+ \{ `from`: \{ `kind`: `"agent"`; `agentId`: `string`; `sessionId`: `string`; \};
641
+ `reply?`: \| \{ `commandId`: `string`; `outcome`: `"completed"` \| `"failed"` \|
642
+ `"cancelled"` \| `"interrupted"` \| `"outcome_unknown"`; `diagnostic?`:
643
+ `string`; `waitingOnYou?`: readonly `object`[]; \} \| \{ `outcome`:
644
+ `"accepted"`; `commandId`: `string`; \} \| \{ `outcome`: `"undeliverable"`;
645
+ `reason`: `"recipient_left"`; \}; `key`: `string`; `to`: \{ `kind`: `"agent"`;
646
+ `agentId`: `string`; `sessionId?`: `string`; \}; `replyTo`: readonly `object`[];
647
+ `content`: `string`; `createdAt`: `number`; `meta?`: Json \| undefined; \} \| \{
648
+ `from`: \{ `kind`: `"system"`; `systemId`: `"hub"`; \}; `reply`: \{ `outcome`:
649
+ `"undeliverable"`; `reason`: `"recipient_offline"`; \}; `key`: `string`; `to`:
650
+ \{ `kind`: `"agent"`; `agentId`: `string`; `sessionId?`: `string`; \};
651
+ `replyTo`: readonly `object`[]; `content`: `string`; `createdAt`: `number`;
652
+ `meta?`: Json \| undefined; \}, `AgentMailAddress`, \| \{ `from`: \{ `kind`:
653
+ `"agent"`; `agentId`: `string`; `sessionId`: `string`; \}; `reply?`: \| \{
654
+ `commandId`: `string`; `outcome`: `"completed"` \| `"failed"` \| `"cancelled"`
655
+ \| `"interrupted"` \| `"outcome_unknown"`; `diagnostic?`: `string`;
656
+ `waitingOnYou?`: readonly `object`[]; \} \| \{ `outcome`: `"accepted"`;
599
657
  `commandId`: `string`; \} \| \{ `outcome`: `"undeliverable"`; `reason`:
600
658
  `"recipient_left"`; \}; `key`: `string`; `to`: \{ `kind`: `"agent"`; `agentId`:
601
659
  `string`; `sessionId?`: `string`; \}; `replyTo`: readonly `object`[]; `content`:
@@ -607,50 +665,26 @@ retries.
607
665
  `meta?`: Json \| undefined; \}, \| \{ `from`: \{ `kind`: `"agent"`; `agentId`:
608
666
  `string`; `sessionId`: `string`; \}; `reply?`: \| \{ `commandId`: `string`;
609
667
  `outcome`: `"completed"` \| `"failed"` \| `"cancelled"` \| `"interrupted"` \|
610
- `"outcome_unknown"`; `diagnostic?`: `string`; \} \| \{ `outcome`: `"accepted"`;
611
- `commandId`: `string`; \} \| \{ `outcome`: `"undeliverable"`; `reason`:
612
- `"recipient_left"`; \}; `key`: `string`; `to`: \{ `kind`: `"agent"`; `agentId`:
613
- `string`; `sessionId?`: `string`; \}; `replyTo`: readonly `object`[]; `content`:
614
- `string`; `createdAt`: `number`; `meta?`: Json \| undefined; \} \| \{ `from`: \{
615
- `kind`: `"system"`; `systemId`: `"hub"`; \}; `reply`: \{ `outcome`:
616
- `"undeliverable"`; `reason`: `"recipient_offline"`; \}; `key`: `string`; `to`:
617
- \{ `kind`: `"agent"`; `agentId`: `string`; `sessionId?`: `string`; \};
668
+ `"outcome_unknown"`; `diagnostic?`: `string`; `waitingOnYou?`: readonly
669
+ `object`[]; \} \| \{ `outcome`: `"accepted"`; `commandId`: `string`; \} \| \{
670
+ `outcome`: `"undeliverable"`; `reason`: `"recipient_left"`; \}; `key`: `string`;
671
+ `to`: \{ `kind`: `"agent"`; `agentId`: `string`; `sessionId?`: `string`; \};
618
672
  `replyTo`: readonly `object`[]; `content`: `string`; `createdAt`: `number`;
619
- `meta?`: Json \| undefined; \}, `AgentMailAddress`, \| \{ `from`: \{ `kind`:
620
- `"agent"`; `agentId`: `string`; `sessionId`: `string`; \}; `reply?`: \| \{
621
- `commandId`: `string`; `outcome`: `"completed"` \| `"failed"` \| `"cancelled"`
622
- \| `"interrupted"` \| `"outcome_unknown"`; `diagnostic?`: `string`; \} \| \{
623
- `outcome`: `"accepted"`; `commandId`: `string`; \} \| \{ `outcome`:
624
- `"undeliverable"`; `reason`: `"recipient_left"`; \}; `key`: `string`; `to`: \{
625
- `kind`: `"agent"`; `agentId`: `string`; `sessionId?`: `string`; \}; `replyTo`:
626
- readonly `object`[]; `content`: `string`; `createdAt`: `number`; `meta?`: Json
627
- \| undefined; \} \| \{ `from`: \{ `kind`: `"system"`; `systemId`: `"hub"`; \};
628
- `reply`: \{ `outcome`: `"undeliverable"`; `reason`: `"recipient_offline"`; \};
629
- `key`: `string`; `to`: \{ `kind`: `"agent"`; `agentId`: `string`; `sessionId?`:
630
- `string`; \}; `replyTo`: readonly `object`[]; `content`: `string`; `createdAt`:
631
- `number`; `meta?`: Json \| undefined; \}, \| \{ `from`: \{ `kind`: `"agent"`;
632
- `agentId`: `string`; `sessionId`: `string`; \}; `reply?`: \| \{ `commandId`:
633
- `string`; `outcome`: `"completed"` \| `"failed"` \| `"cancelled"` \|
634
- `"interrupted"` \| `"outcome_unknown"`; `diagnostic?`: `string`; \} \| \{
635
- `outcome`: `"accepted"`; `commandId`: `string`; \} \| \{ `outcome`:
636
- `"undeliverable"`; `reason`: `"recipient_left"`; \}; `key`: `string`; `to`: \{
637
- `kind`: `"agent"`; `agentId`: `string`; `sessionId?`: `string`; \}; `replyTo`:
638
- readonly `object`[]; `content`: `string`; `createdAt`: `number`; `meta?`: Json
639
- \| undefined; \} \| \{ `from`: \{ `kind`: `"system"`; `systemId`: `"hub"`; \};
640
- `reply`: \{ `outcome`: `"undeliverable"`; `reason`: `"recipient_offline"`; \};
641
- `key`: `string`; `to`: \{ `kind`: `"agent"`; `agentId`: `string`; `sessionId?`:
642
- `string`; \}; `replyTo`: readonly `object`[]; `content`: `string`; `createdAt`:
643
- `number`; `meta?`: Json \| undefined; \}\> & `Omit`\<`Readonly`\<\{
644
- `addressKind`: `string`; `deadlineMs?`: `number`; `address`: `Codec`\<`unknown`,
645
- `unknown`\>; `event`: `Codec`\<`unknown`, `unknown`\>; `encodeEnvelope`:
646
- (`envelope`) => `object`; `parseDelivery`: (`envelope`) => `object`;
647
- `prepareEnvelope?`: (`envelope`, `signal`) => `Promise`\<\{ `key`: `string`;
648
- `kind`: `string`; `address`: `unknown`; `event`: `unknown`; \}\>;
649
- `recordDelivered?`: (`envelope`) => `void`; `nameOf`: (`envelope`) => `string`;
650
- `namespace`: `Readonly`\<\{ `getByName`: (`name`) => `Readonly`\<\{ `deliver`:
651
- (`envelope`) => `Promise`\<...\>; \}\>; \}\>; `recordCursor?`: (`envelope`,
652
- `cursor`) => `void`; `recordRefused?`: (`envelope`) => `void`; \}\>, `"event"`
653
- \| `"address"`\>
673
+ `meta?`: Json \| undefined; \} \| \{ `from`: \{ `kind`: `"system"`; `systemId`:
674
+ `"hub"`; \}; `reply`: \{ `outcome`: `"undeliverable"`; `reason`:
675
+ `"recipient_offline"`; \}; `key`: `string`; `to`: \{ `kind`: `"agent"`;
676
+ `agentId`: `string`; `sessionId?`: `string`; \}; `replyTo`: readonly `object`[];
677
+ `content`: `string`; `createdAt`: `number`; `meta?`: Json \| undefined; \}\> &
678
+ `Omit`\<`Readonly`\<\{ `addressKind`: `string`; `deadlineMs?`: `number`;
679
+ `address`: `Codec`\<`unknown`, `unknown`\>; `event`: `Codec`\<`unknown`,
680
+ `unknown`\>; `encodeEnvelope`: (`envelope`) => `object`; `parseDelivery`:
681
+ (`envelope`) => `object`; `prepareEnvelope?`: (`envelope`, `signal`) =>
682
+ `Promise`\<\{ `key`: `string`; `kind`: `string`; `address`: `unknown`; `event`:
683
+ `unknown`; \}\>; `recordDelivered?`: (`envelope`) => `void`; `nameOf`:
684
+ (`envelope`) => `string`; `namespace`: `Readonly`\<\{ `getByName`: (`name`) =>
685
+ `Readonly`\<\{ `deliver`: (`envelope`) => `Promise`\<...\>; \}\>; \}\>;
686
+ `recordCursor?`: (`envelope`, `cursor`) => `void`; `recordRefused?`:
687
+ (`envelope`) => `void`; \}\>, `"event"` \| `"address"`\>
654
688
 
655
689
  ---
656
690