@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
@@ -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`\<[`DelegationReceipt`](client.md#delegationreceipt)\>; `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`\>; `stageAcceptedNotice`: (`mail`, `scopeId`) => `void`; `accept`: (`mail`, `reply`, `stageAcceptedNotice`) => `Promise`\<[`Accepted`](client.md#accepted)\>; \}\> |
30
30
 
31
31
  ###### Returns
32
32
 
@@ -144,6 +144,24 @@ Admit one addressed Agent mail for this Agent, or refuse it.
144
144
 
145
145
  `Promise`\<`PostDeliveryResult`\>
146
146
 
147
+ ##### localUndeliverable()
148
+
149
+ ```ts
150
+ localUndeliverable(original): Promise<PostDeliveryResult>;
151
+ ```
152
+
153
+ Admit local outbox exhaustion through the same Fleet/system reply gate.
154
+
155
+ ###### Parameters
156
+
157
+ | Parameter | Type |
158
+ | ---------- | ------------- |
159
+ | `original` | `BirdDogMail` |
160
+
161
+ ###### Returns
162
+
163
+ `Promise`\<`PostDeliveryResult`\>
164
+
147
165
  ---
148
166
 
149
167
  ### AgentDisclosureRefused
@@ -189,9 +207,9 @@ new AgentMail(deps): AgentMail;
189
207
 
190
208
  ###### Parameters
191
209
 
192
- | Parameter | Type |
193
- | --------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
194
- | `deps` | `Readonly`\<\{ `storage`: `WatchdogSqliteOwner`; `post`: () => [`AgentMailPost`](#agentmailpost); `identity`: () => \| [`DelegationIdentity`](#delegationidentity) \| `null` \| `Promise`\<[`DelegationIdentity`](#delegationidentity) \| `null`\>; `replySettlement`: [`AgentReplySettlement`](#agentreplysettlement); `drain`: () => `Promise`\<`void`\>; `wake`: () => `Promise`\<`void`\>; \}\> |
210
+ | Parameter | Type |
211
+ | --------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
212
+ | `deps` | `Readonly`\<\{ `storage`: `WatchdogSqliteOwner`; `post`: () => [`AgentMailPost`](#agentmailpost); `identity`: () => \| [`DelegationIdentity`](#delegationidentity) \| `null` \| `Promise`\<[`DelegationIdentity`](#delegationidentity) \| `null`\>; `replySettlement`: [`AgentReplySettlement`](#agentreplysettlement); `onUndeliverable`: (`original`, `reply`) => `Promise`\<`PostDeliveryResult`\>; `drain`: () => `Promise`\<`void`\>; `wake`: () => `Promise`\<`void`\>; \}\> |
195
213
 
196
214
  ###### Returns
197
215
 
@@ -217,18 +235,53 @@ Submit one mail and return recipient acceptance or relay-held custody.
217
235
 
218
236
  `Promise`\<[`DelegationReceipt`](client.md#delegationreceipt)\>
219
237
 
238
+ ##### stageUndeliverableReplies()
239
+
240
+ ```ts
241
+ stageUndeliverableReplies(): Promise<void>;
242
+ ```
243
+
244
+ Reconcile exhausted original outbox mail into one local system reply.
245
+
246
+ ###### Returns
247
+
248
+ `Promise`\<`void`\>
249
+
250
+ ##### stageAcceptedNotice()
251
+
252
+ ```ts
253
+ stageAcceptedNotice(mail, scopeId): void;
254
+ ```
255
+
256
+ Stage the acceptance reply through this Post owner without leaving the
257
+ transaction.
258
+
259
+ ###### Parameters
260
+
261
+ | Parameter | Type |
262
+ | --------- | ------------- |
263
+ | `mail` | `BirdDogMail` |
264
+ | `scopeId` | `string` |
265
+
266
+ ###### Returns
267
+
268
+ `void`
269
+
220
270
  ##### mailRoom()
221
271
 
222
272
  ```ts
223
- mailRoom(): BirdDogEffect;
273
+ mailRoom(): Readonly<{
274
+ fanOut: (settlement) => Effect<void, BirdDogError>;
275
+ postMail?: (mail) => Effect<void, BirdDogError>;
276
+ drainOutbox: () => Effect<void, BirdDogError>;
277
+ nextWakeAt: () => Effect<number | undefined, BirdDogError>;
278
+ }> & object;
224
279
  ```
225
280
 
226
281
  BirdDog's mail room: disclosed settlement replies fan out over Post.
227
282
 
228
283
  ###### Returns
229
284
 
230
- `BirdDogEffect`
231
-
232
285
  ## Type Aliases
233
286
 
234
287
  ### DelegationIdentity
@@ -272,7 +325,7 @@ type AgentMailPost = Pick<
272
325
  PostRuntime<{
273
326
  agentMail: ReturnType<typeof agentMailRoute>;
274
327
  }>,
275
- "send" | "read" | "nextWake"
328
+ "send" | "read" | "nextWake" | "deadLetters"
276
329
  >;
277
330
  ```
278
331
 
@@ -302,106 +355,206 @@ link routes Agent work without owning Shiitake's grammar.
302
355
  ### agentMailRoute()
303
356
 
304
357
  ```ts
305
- function agentMailRoute(namespace, replySettlement): PostRoute<AgentMailAddress, {
306
- key: string;
307
- to: {
308
- kind: "agent";
309
- agentId: string;
310
- sessionId: string;
311
- };
358
+ function agentMailRoute(namespace, replySettlement): PostRoute<AgentMailAddress,
359
+ | {
312
360
  from: {
313
361
  kind: "agent";
314
362
  agentId: string;
315
363
  sessionId: string;
316
364
  };
317
- replyTo: readonly object[];
318
- content: string;
319
- createdAt: number;
320
- meta?: Json | undefined;
321
365
  reply?: | {
322
366
  commandId: string;
323
367
  outcome: "completed" | "failed" | "cancelled" | "interrupted" | "outcome_unknown";
324
368
  diagnostic?: string;
369
+ }
370
+ | {
371
+ outcome: "accepted";
372
+ commandId: string;
325
373
  }
326
374
  | {
327
375
  outcome: "undeliverable";
328
- reason: "recipient_offline" | "recipient_left";
376
+ reason: "recipient_left";
329
377
  };
330
- }, {
331
378
  key: string;
332
379
  to: {
333
380
  kind: "agent";
334
381
  agentId: string;
335
- sessionId: string;
382
+ sessionId?: string;
336
383
  };
384
+ replyTo: readonly object[];
385
+ content: string;
386
+ createdAt: number;
387
+ meta?: Json | undefined;
388
+ }
389
+ | {
337
390
  from: {
391
+ kind: "system";
392
+ systemId: "hub";
393
+ };
394
+ reply: {
395
+ outcome: "undeliverable";
396
+ reason: "recipient_offline";
397
+ };
398
+ key: string;
399
+ to: {
338
400
  kind: "agent";
339
401
  agentId: string;
340
- sessionId: string;
402
+ sessionId?: string;
341
403
  };
342
404
  replyTo: readonly object[];
343
405
  content: string;
344
406
  createdAt: number;
345
407
  meta?: Json | undefined;
408
+ },
409
+ | {
410
+ from: {
411
+ kind: "agent";
412
+ agentId: string;
413
+ sessionId: string;
414
+ };
346
415
  reply?: | {
347
416
  commandId: string;
348
417
  outcome: "completed" | "failed" | "cancelled" | "interrupted" | "outcome_unknown";
349
418
  diagnostic?: string;
419
+ }
420
+ | {
421
+ outcome: "accepted";
422
+ commandId: string;
350
423
  }
351
424
  | {
352
425
  outcome: "undeliverable";
353
- reason: "recipient_offline" | "recipient_left";
426
+ reason: "recipient_left";
354
427
  };
355
- }, AgentMailAddress, {
356
428
  key: string;
357
429
  to: {
358
430
  kind: "agent";
359
431
  agentId: string;
360
- sessionId: string;
432
+ sessionId?: string;
361
433
  };
434
+ replyTo: readonly object[];
435
+ content: string;
436
+ createdAt: number;
437
+ meta?: Json | undefined;
438
+ }
439
+ | {
362
440
  from: {
441
+ kind: "system";
442
+ systemId: "hub";
443
+ };
444
+ reply: {
445
+ outcome: "undeliverable";
446
+ reason: "recipient_offline";
447
+ };
448
+ key: string;
449
+ to: {
363
450
  kind: "agent";
364
451
  agentId: string;
365
- sessionId: string;
452
+ sessionId?: string;
366
453
  };
367
454
  replyTo: readonly object[];
368
455
  content: string;
369
456
  createdAt: number;
370
457
  meta?: Json | undefined;
458
+ }, AgentMailAddress,
459
+ | {
460
+ from: {
461
+ kind: "agent";
462
+ agentId: string;
463
+ sessionId: string;
464
+ };
371
465
  reply?: | {
372
466
  commandId: string;
373
467
  outcome: "completed" | "failed" | "cancelled" | "interrupted" | "outcome_unknown";
374
468
  diagnostic?: string;
469
+ }
470
+ | {
471
+ outcome: "accepted";
472
+ commandId: string;
375
473
  }
376
474
  | {
377
475
  outcome: "undeliverable";
378
- reason: "recipient_offline" | "recipient_left";
476
+ reason: "recipient_left";
379
477
  };
380
- }, {
381
478
  key: string;
382
479
  to: {
383
480
  kind: "agent";
384
481
  agentId: string;
385
- sessionId: string;
482
+ sessionId?: string;
386
483
  };
484
+ replyTo: readonly object[];
485
+ content: string;
486
+ createdAt: number;
487
+ meta?: Json | undefined;
488
+ }
489
+ | {
387
490
  from: {
491
+ kind: "system";
492
+ systemId: "hub";
493
+ };
494
+ reply: {
495
+ outcome: "undeliverable";
496
+ reason: "recipient_offline";
497
+ };
498
+ key: string;
499
+ to: {
388
500
  kind: "agent";
389
501
  agentId: string;
390
- sessionId: string;
502
+ sessionId?: string;
391
503
  };
392
504
  replyTo: readonly object[];
393
505
  content: string;
394
506
  createdAt: number;
395
507
  meta?: Json | undefined;
508
+ },
509
+ | {
510
+ from: {
511
+ kind: "agent";
512
+ agentId: string;
513
+ sessionId: string;
514
+ };
396
515
  reply?: | {
397
516
  commandId: string;
398
517
  outcome: "completed" | "failed" | "cancelled" | "interrupted" | "outcome_unknown";
399
518
  diagnostic?: string;
519
+ }
520
+ | {
521
+ outcome: "accepted";
522
+ commandId: string;
400
523
  }
401
524
  | {
402
525
  outcome: "undeliverable";
403
- reason: "recipient_offline" | "recipient_left";
526
+ reason: "recipient_left";
404
527
  };
528
+ key: string;
529
+ to: {
530
+ kind: "agent";
531
+ agentId: string;
532
+ sessionId?: string;
533
+ };
534
+ replyTo: readonly object[];
535
+ content: string;
536
+ createdAt: number;
537
+ meta?: Json | undefined;
538
+ }
539
+ | {
540
+ from: {
541
+ kind: "system";
542
+ systemId: "hub";
543
+ };
544
+ reply: {
545
+ outcome: "undeliverable";
546
+ reason: "recipient_offline";
547
+ };
548
+ key: string;
549
+ to: {
550
+ kind: "agent";
551
+ agentId: string;
552
+ sessionId?: string;
553
+ };
554
+ replyTo: readonly object[];
555
+ content: string;
556
+ createdAt: number;
557
+ meta?: Json | undefined;
405
558
  }> & Omit<Readonly<{
406
559
  addressKind: string;
407
560
  deadlineMs?: number;
@@ -439,35 +592,55 @@ retries.
439
592
 
440
593
  #### Returns
441
594
 
442
- `PostRoute`\<`AgentMailAddress`, \{ `key`: `string`; `to`: \{ `kind`: `"agent"`;
443
- `agentId`: `string`; `sessionId`: `string`; \}; `from`: \{ `kind`: `"agent"`;
444
- `agentId`: `string`; `sessionId`: `string`; \}; `replyTo`: readonly `object`[];
445
- `content`: `string`; `createdAt`: `number`; `meta?`: Json \| undefined;
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"` \|
454
- `"cancelled"` \| `"interrupted"` \| `"outcome_unknown"`; `diagnostic?`:
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`:
595
+ `PostRoute`\<`AgentMailAddress`, \| \{ `from`: \{ `kind`: `"agent"`; `agentId`:
596
+ `string`; `sessionId`: `string`; \}; `reply?`: \| \{ `commandId`: `string`;
597
+ `outcome`: `"completed"` \| `"failed"` \| `"cancelled"` \| `"interrupted"` \|
598
+ `"outcome_unknown"`; `diagnostic?`: `string`; \} \| \{ `outcome`: `"accepted"`;
599
+ `commandId`: `string`; \} \| \{ `outcome`: `"undeliverable"`; `reason`:
600
+ `"recipient_left"`; \}; `key`: `string`; `to`: \{ `kind`: `"agent"`; `agentId`:
601
+ `string`; `sessionId?`: `string`; \}; `replyTo`: readonly `object`[]; `content`:
602
+ `string`; `createdAt`: `number`; `meta?`: Json \| undefined; \} \| \{ `from`: \{
603
+ `kind`: `"system"`; `systemId`: `"hub"`; \}; `reply`: \{ `outcome`:
604
+ `"undeliverable"`; `reason`: `"recipient_offline"`; \}; `key`: `string`; `to`:
605
+ \{ `kind`: `"agent"`; `agentId`: `string`; `sessionId?`: `string`; \};
606
+ `replyTo`: readonly `object`[]; `content`: `string`; `createdAt`: `number`;
607
+ `meta?`: Json \| undefined; \}, \| \{ `from`: \{ `kind`: `"agent"`; `agentId`:
608
+ `string`; `sessionId`: `string`; \}; `reply?`: \| \{ `commandId`: `string`;
609
+ `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`; \};
618
+ `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`:
459
626
  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`:
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`:
466
638
  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`\<\{
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`\<\{
471
644
  `addressKind`: `string`; `deadlineMs?`: `number`; `address`: `Codec`\<`unknown`,
472
645
  `unknown`\>; `event`: `Codec`\<`unknown`, `unknown`\>; `encodeEnvelope`:
473
646
  (`envelope`) => `object`; `parseDelivery`: (`envelope`) => `object`;
@@ -19,7 +19,12 @@ type ShiitakeEffectHost = Readonly<{
19
19
  commandId,
20
20
  ) => Effect.Effect<CommandSettlement | undefined, ShiitakeError>;
21
21
  agent: ShiitakeEffectOwner;
22
- acceptMail: (mail, meta?, reply?) => Effect.Effect<Accepted, ShiitakeError>;
22
+ acceptMail: (
23
+ mail,
24
+ meta?,
25
+ reply?,
26
+ stageAcceptedNotice?,
27
+ ) => Effect.Effect<Accepted, ShiitakeError>;
23
28
  }>;
24
29
  ```
25
30
 
@@ -36,6 +41,7 @@ type ModelAcquisitionEffect = Readonly<{
36
41
  retryAfterMs?: (message) => number | undefined;
37
42
  retryable: (message) => boolean;
38
43
  failureReason?: (message) => string | undefined;
44
+ rejection?: (message) => ProviderRejection | undefined;
39
45
  providerError?: (message) => string | undefined;
40
46
  release: Effect.Effect<void, ShiitakeError>;
41
47
  }>;
@@ -157,6 +163,7 @@ type ShiitakeEffectCommandHandler = {
157
163
  Readonly<{
158
164
  status: "accepted";
159
165
  commandId: string;
166
+ sessionId?: string;
160
167
  }>,
161
168
  ShiitakeError
162
169
  >;
@@ -187,6 +194,7 @@ Effect-native addressable Session handle.
187
194
  (input): Effect<Readonly<{
188
195
  status: "accepted";
189
196
  commandId: string;
197
+ sessionId?: string;
190
198
  }>, ShiitakeError>;
191
199
  ```
192
200
 
@@ -200,8 +208,8 @@ Accept one durable prompt command.
200
208
 
201
209
  ##### Returns
202
210
 
203
- `Effect`\<`Readonly`\<\{ `status`: `"accepted"`; `commandId`: `string`; \}\>,
204
- [`ShiitakeError`](index.md#shiitakeerror)\>
211
+ `Effect`\<`Readonly`\<\{ `status`: `"accepted"`; `commandId`: `string`;
212
+ `sessionId?`: `string`; \}\>, [`ShiitakeError`](index.md#shiitakeerror)\>
205
213
 
206
214
  #### Call Signature
207
215
 
@@ -489,9 +497,10 @@ function openHost(options, mailRoom): Effect<Readonly<{
489
497
  }>
490
498
  | undefined, ShiitakeError>;
491
499
  agent: ShiitakeEffectOwner;
492
- acceptMail: (mail, meta?, reply?) => Effect<Readonly<{
500
+ acceptMail: (mail, meta?, reply?, stageAcceptedNotice?) => Effect<Readonly<{
493
501
  status: "accepted";
494
502
  commandId: string;
503
+ sessionId?: string;
495
504
  }>, ShiitakeError>;
496
505
  }>, ShiitakeError>;
497
506
  ```
@@ -513,8 +522,9 @@ Open the Effect-native host composition with addressed mail.
513
522
  readonly `Pick`\<`AssistantMessage`, ... \| ... \| ...\>[]; `toolCalls`:
514
523
  `number`; \}\> \| `undefined`, [`ShiitakeError`](index.md#shiitakeerror)\>;
515
524
  `agent`: [`ShiitakeEffectOwner`](#shiitakeeffectowner); `acceptMail`: (`mail`,
516
- `meta?`, `reply?`) => `Effect`\<`Readonly`\<\{ `status`: `"accepted"`;
517
- `commandId`: `string`; \}\>, [`ShiitakeError`](index.md#shiitakeerror)\>; \}\>,
525
+ `meta?`, `reply?`, `stageAcceptedNotice?`) => `Effect`\<`Readonly`\<\{ `status`:
526
+ `"accepted"`; `commandId`: `string`; `sessionId?`: `string`; \}\>,
527
+ [`ShiitakeError`](index.md#shiitakeerror)\>; \}\>,
518
528
  [`ShiitakeError`](index.md#shiitakeerror)\>
519
529
 
520
530
  ---
@@ -1081,6 +1081,7 @@ type SendInputV0 = Readonly<{
1081
1081
  }>;
1082
1082
  when: "now" | "idle";
1083
1083
  correlation?: string;
1084
+ continuesWorkId?: string;
1084
1085
  }>;
1085
1086
  ```
1086
1087
 
@@ -1160,6 +1161,19 @@ session: string;
1160
1161
 
1161
1162
  ---
1162
1163
 
1164
+ ### ExtensionCommandCallerV0
1165
+
1166
+ ```ts
1167
+ type ExtensionCommandCallerV0 = Readonly<{
1168
+ agentId: string;
1169
+ sessionId: string;
1170
+ }>;
1171
+ ```
1172
+
1173
+ Host-authenticated caller context; never decoded from command JSON or HTTP.
1174
+
1175
+ ---
1176
+
1163
1177
  ### CommandHandlersV0
1164
1178
 
1165
1179
  ```ts
@@ -1168,6 +1182,7 @@ type CommandHandlersV0<C> = {
1168
1182
  call: Readonly<{
1169
1183
  sessionId: CommandSessionIdsV0[C[K]["scope"]];
1170
1184
  input: C[K]["input"]["Type"];
1185
+ caller?: ExtensionCommandCallerV0;
1171
1186
  }>,
1172
1187
  ) =>
1173
1188
  | C[K]["output"]["Type"]
@@ -1197,6 +1212,9 @@ type AttentionV0 = Readonly<{
1197
1212
  sessionId,
1198
1213
  item,
1199
1214
  ) => Effect.Effect<void, ExtensionStateError, ExtensionTx>;
1215
+ awaitsPerson: (
1216
+ sessionId,
1217
+ ) => Effect.Effect<boolean, ExtensionStateError, ExtensionRead>;
1200
1218
  clear: (
1201
1219
  sessionId,
1202
1220
  id,
@@ -1227,11 +1245,19 @@ type ExtensionContextV0<S, Config, D> = Readonly<{
1227
1245
  hasPendingSteer: (
1228
1246
  run,
1229
1247
  ) => Effect.Effect<boolean, ExtensionStateError, ExtensionRead>;
1248
+ workSender: (
1249
+ run,
1250
+ ) => Effect.Effect<
1251
+ AttentionRecipient | null,
1252
+ ExtensionStateError,
1253
+ ExtensionRead
1254
+ >;
1230
1255
  hasSuccessfulToolResult: (
1231
1256
  run,
1232
1257
  toolCallId,
1233
1258
  ) => Effect.Effect<boolean, ExtensionStateError, ExtensionRead>;
1234
1259
  observe: (sessionId) => Effect.Effect<void, never, ExtensionTx>;
1260
+ isObserved: (sessionId) => boolean;
1235
1261
  transact: <A, E>(body) => Effect.Effect<A, E | ExtensionStop | ShiitakeError>;
1236
1262
  }>;
1237
1263
  ```
@@ -1722,9 +1748,9 @@ A parsed invocation retains its typed handler until the transaction runs.
1722
1748
 
1723
1749
  #### Parameters
1724
1750
 
1725
- | Parameter | Type |
1726
- | --------- | ------------------------------------------------------------------------------ |
1727
- | `frame` | `Readonly`\<\{ `sessionId`: `string` \| `null`; `input`: [`Json`](#json); \}\> |
1751
+ | Parameter | Type |
1752
+ | --------- | -------------------------------------------------------------------------------------------------------------------------------------------------- |
1753
+ | `frame` | `Readonly`\<\{ `sessionId`: `string` \| `null`; `input`: [`Json`](#json); `caller?`: [`ExtensionCommandCallerV0`](#extensioncommandcallerv0); \}\> |
1728
1754
 
1729
1755
  #### Returns
1730
1756
 
@@ -1854,6 +1880,16 @@ Public state-update shape: infer the return _before_ rejecting async results.
1854
1880
 
1855
1881
  ---
1856
1882
 
1883
+ ### AttentionRecipient
1884
+
1885
+ ```ts
1886
+ type AttentionRecipient = typeof AttentionRecipientSchema.Type;
1887
+ ```
1888
+
1889
+ Decoded Agent Session an attention item waits on.
1890
+
1891
+ ---
1892
+
1857
1893
  ### AttentionItem
1858
1894
 
1859
1895
  ```ts
@@ -1894,6 +1930,22 @@ ASCII extension identity shared by the host definition and its clients.
1894
1930
 
1895
1931
  ---
1896
1932
 
1933
+ ### AttentionRecipientSchema
1934
+
1935
+ ```ts
1936
+ const AttentionRecipientSchema: Struct<{
1937
+ agentId: NonEmptyString;
1938
+ sessionId: NonEmptyString;
1939
+ name: NonEmptyString;
1940
+ }>;
1941
+ ```
1942
+
1943
+ The Agent Session that sent the work an item belongs to. The host derives it
1944
+ from the accepted mail; it is the only party the item waits on until it is
1945
+ escalated.
1946
+
1947
+ ---
1948
+
1897
1949
  ### AttentionItemSchema
1898
1950
 
1899
1951
  ```ts
@@ -1904,11 +1956,20 @@ const AttentionItemSchema: Struct<{
1904
1956
  since: Int;
1905
1957
  expiresAt: optional<Int>;
1906
1958
  inbox: optional<Literal<false>>;
1959
+ waitingOn: optional<
1960
+ Struct<{
1961
+ agentId: NonEmptyString;
1962
+ sessionId: NonEmptyString;
1963
+ name: NonEmptyString;
1964
+ }>
1965
+ >;
1907
1966
  }>;
1908
1967
  ```
1909
1968
 
1910
1969
  An extension-owned request for human attention; expiry is owned by its timer.
1911
- Items marked `inbox: false` remain visible without changing the inbox state.
1970
+ Items marked `inbox: false` remain visible without changing the inbox state. An
1971
+ item with `waitingOn` waits on that Agent first and is never a person's inbox
1972
+ item until it is escalated past every Agent.
1912
1973
 
1913
1974
  ## Functions
1914
1975