@fungi.computer/shiitake 0.5.0 → 0.7.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 (88) hide show
  1. package/README.md +59 -21
  2. package/dist/agent-control.d.ts +94 -2
  3. package/dist/agent-control.js +147 -26
  4. package/dist/client-entry.d.ts +20 -0
  5. package/dist/client-entry.js +5 -0
  6. package/dist/client-visitor.d.ts +33 -0
  7. package/dist/client-visitor.js +231 -0
  8. package/dist/client-wire.d.ts +9 -0
  9. package/dist/client-wire.js +24 -3
  10. package/dist/client.d.ts +27 -6
  11. package/dist/client.js +23 -0
  12. package/dist/cloudflare.d.ts +20 -0
  13. package/dist/cloudflare.js +4 -1
  14. package/dist/delegation.d.ts +79 -53
  15. package/dist/delegation.js +26 -21
  16. package/dist/effect.d.ts +26 -1
  17. package/dist/effect.js +14 -1
  18. package/dist/errors.d.ts +2 -2
  19. package/dist/errors.js +2 -0
  20. package/dist/extensions.d.ts +22 -3
  21. package/dist/extensions.js +1 -1
  22. package/dist/fleet.d.ts +25 -2
  23. package/dist/fleet.js +108 -24
  24. package/dist/hosted.js +3 -0
  25. package/dist/http-routes.d.ts +23 -9
  26. package/dist/http.d.ts +1 -0
  27. package/dist/http.js +1 -0
  28. package/dist/index.d.ts +1 -1
  29. package/dist/internal/accepted-run-executor.js +2 -1
  30. package/dist/internal/admission-door.d.ts +6 -1
  31. package/dist/internal/admission-door.js +33 -3
  32. package/dist/internal/contracts.d.ts +19 -1
  33. package/dist/internal/coordinator.js +115 -52
  34. package/dist/internal/effect-client.js +1 -1
  35. package/dist/internal/effect-contracts.d.ts +9 -2
  36. package/dist/internal/extension-command-registry.d.ts +2 -1
  37. package/dist/internal/extension-command-registry.js +3 -1
  38. package/dist/internal/extension-runtime.d.ts +3 -1
  39. package/dist/internal/extension-runtime.js +18 -8
  40. package/dist/internal/model-acquisition.js +2 -0
  41. package/dist/internal/observation-kernel.d.ts +2 -0
  42. package/dist/internal/observation-kernel.js +17 -6
  43. package/dist/internal/promise-facade.js +2 -0
  44. package/dist/internal/run-scope.d.ts +14 -0
  45. package/dist/internal/run-scope.js +58 -15
  46. package/dist/internal/runtime-coordinator.d.ts +14 -0
  47. package/dist/internal/runtime-coordinator.js +60 -11
  48. package/dist/internal/runtime-core.d.ts +3 -0
  49. package/dist/internal/runtime-core.js +1 -0
  50. package/dist/internal/runtime-reconciliation.js +123 -25
  51. package/dist/internal/session-context.d.ts +5 -5
  52. package/dist/internal/session-context.js +80 -83
  53. package/dist/internal/session-status.d.ts +2 -2
  54. package/dist/internal/session-status.js +5 -3
  55. package/dist/internal/woodstock/agent-reply.d.ts +5 -0
  56. package/dist/internal/woodstock/agent-reply.js +3 -0
  57. package/dist/internal/woodstock/client-projection.js +13 -11
  58. package/dist/internal/woodstock/fleet-store.d.ts +3 -2
  59. package/dist/internal/woodstock/fleet-store.js +24 -4
  60. package/dist/internal/woodstock/index.d.ts +7 -3
  61. package/dist/internal/woodstock/index.js +23 -6
  62. package/dist/internal/woodstock/progress.d.ts +11 -1
  63. package/dist/internal/woodstock/progress.js +126 -25
  64. package/dist/internal/woodstock/session-delegator.d.ts +13 -0
  65. package/dist/internal/woodstock/session-delegator.js +44 -0
  66. package/dist/internal/woodstock/session-entry.d.ts +12 -2
  67. package/dist/internal/woodstock/session-store.d.ts +16 -2
  68. package/dist/internal/woodstock/session-store.js +349 -66
  69. package/dist/internal/woodstock/work-senders.d.ts +32 -0
  70. package/dist/internal/woodstock/work-senders.js +70 -0
  71. package/dist/node.js +11 -2
  72. package/dist/remote-client.js +7 -2
  73. package/dist/server-visitor-stream.d.ts +13 -0
  74. package/dist/server-visitor-stream.js +124 -0
  75. package/dist/session-attention.d.ts +30 -0
  76. package/dist/session-attention.js +14 -0
  77. package/docs/api/agent-control.md +212 -15
  78. package/docs/api/client-entry.md +3 -0
  79. package/docs/api/client.md +209 -5
  80. package/docs/api/cloudflare.md +23 -1
  81. package/docs/api/delegation.md +284 -77
  82. package/docs/api/effect.md +100 -12
  83. package/docs/api/extensions.md +73 -12
  84. package/docs/api/fleet.md +138 -25
  85. package/docs/api/http.md +28 -0
  86. package/docs/api/index.md +43 -17
  87. package/docs/api/testing.md +9 -7
  88. package/package.json +10 -6
@@ -172,6 +172,7 @@ const clientTimelineCellSchemaV1: Struct<{
172
172
  id: String;
173
173
  label: String;
174
174
  input: optional<$Record<..., ...>>;
175
+ awaiting: optionalKey<Literal<...>>;
175
176
  }>>>;
176
177
  }>>;
177
178
  }>;
@@ -222,6 +223,7 @@ const clientContributionSchemaV1: Struct<{
222
223
  id: String;
223
224
  label: String;
224
225
  input: optional<$Record<..., ...>>;
226
+ awaiting: optionalKey<Literal<...>>;
225
227
  }>>>;
226
228
  inspection: optionalKey<Struct<{
227
229
  commandId: String;
@@ -261,6 +263,7 @@ const clientContributionSchemaV1: Struct<{
261
263
  id: String;
262
264
  label: String;
263
265
  input: optional<$Record<String, Codec<Json, Json, never, never>>>;
266
+ awaiting: optionalKey<Literal<"question">>;
264
267
  }>;
265
268
  }>>;
266
269
  }>;
@@ -10,12 +10,67 @@
10
10
 
11
11
  ## Type Aliases
12
12
 
13
+ ### ParticipantPolicy
14
+
15
+ ```ts
16
+ type ParticipantPolicy = Readonly<{
17
+ turnIsCurrent: (sessionId, commandId) => boolean;
18
+ deliverAgentReply: (sessionId, commandId, reply) => boolean;
19
+ }>;
20
+ ```
21
+
22
+ The host decides which Agent work may be delivered to this participant.
23
+
24
+ ---
25
+
26
+ ### VisitorView
27
+
28
+ ```ts
29
+ type VisitorView = Readonly<{
30
+ status: "idle" | "working";
31
+ lines: readonly Readonly<{
32
+ id: string;
33
+ from: "visitor" | "agent" | "operator";
34
+ text: string;
35
+ }>[];
36
+ progress: string | null;
37
+ }>;
38
+ ```
39
+
40
+ What a visitor may see of their own conversation Session.
41
+
42
+ ---
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
+
54
+ ### VisitorPendingPrompt
55
+
56
+ ```ts
57
+ type VisitorPendingPrompt = Pick<
58
+ SessionPendingPrompt,
59
+ "commandId" | "requestId" | "text" | "delivery" | "images"
60
+ >;
61
+ ```
62
+
63
+ Public pending facts exclude the host's private metadata and admission origin.
64
+
65
+ ---
66
+
13
67
  ### Accepted
14
68
 
15
69
  ```ts
16
70
  type Accepted = Readonly<{
17
71
  status: "accepted";
18
72
  commandId: string;
73
+ sessionId?: string;
19
74
  }>;
20
75
  ```
21
76
 
@@ -115,6 +170,7 @@ type SessionCommandHandler = {
115
170
  Readonly<{
116
171
  status: "accepted";
117
172
  commandId: string;
173
+ sessionId?: string;
118
174
  }>
119
175
  >;
120
176
  (input): Promise<CancelResult>;
@@ -142,6 +198,7 @@ Execute one retained type-discriminated Session command.
142
198
  (input): Promise<Readonly<{
143
199
  status: "accepted";
144
200
  commandId: string;
201
+ sessionId?: string;
145
202
  }>>;
146
203
  ```
147
204
 
@@ -155,7 +212,8 @@ Accept a prompt or a compaction request as queued Session work.
155
212
 
156
213
  ##### Returns
157
214
 
158
- `Promise`\<`Readonly`\<\{ `status`: `"accepted"`; `commandId`: `string`; \}\>\>
215
+ `Promise`\<`Readonly`\<\{ `status`: `"accepted"`; `commandId`: `string`;
216
+ `sessionId?`: `string`; \}\>\>
159
217
 
160
218
  #### Call Signature
161
219
 
@@ -356,6 +414,7 @@ type AgentRunningWork =
356
414
  kind: "session";
357
415
  sessionId: string;
358
416
  commandId: string;
417
+ title: string;
359
418
  }>
360
419
  | Readonly<{
361
420
  kind: "host";
@@ -364,8 +423,8 @@ type AgentRunningWork =
364
423
  }>;
365
424
  ```
366
425
 
367
- Work occupying the executor partition that this queued command requires, without
368
- message or provider data.
426
+ Blocking executor identity and Session display metadata, never messages or
427
+ provider data.
369
428
 
370
429
  ---
371
430
 
@@ -421,7 +480,7 @@ Encoded extension slots keyed by extension identity; absent means unavailable.
421
480
 
422
481
  ```ts
423
482
  type SessionExtensionControls = Readonly<{
424
- call: (command, input) => Promise<Json>;
483
+ call: (command, input, caller?) => Promise<Json>;
425
484
  }>;
426
485
  ```
427
486
 
@@ -467,6 +526,8 @@ type SessionProgress = Readonly<{
467
526
  revision: number;
468
527
  text: string;
469
528
  thinking: string;
529
+ textOffset: number;
530
+ thinkingOffset: number;
470
531
  textTruncated: boolean;
471
532
  thinkingTruncated: boolean;
472
533
  }>;
@@ -476,6 +537,27 @@ Process-local assistant progress; never a durable Session fact.
476
537
 
477
538
  ---
478
539
 
540
+ ### SessionProgressDelta
541
+
542
+ ```ts
543
+ type SessionProgressDelta = Readonly<{
544
+ messageId: string;
545
+ revision: number;
546
+ text: Readonly<{
547
+ offset: number;
548
+ append: string;
549
+ }>;
550
+ thinking: Readonly<{
551
+ offset: number;
552
+ append: string;
553
+ }>;
554
+ }>;
555
+ ```
556
+
557
+ Append-only progress on the wire. Offsets count JavaScript string units.
558
+
559
+ ---
560
+
479
561
  ### SessionPendingPrompt
480
562
 
481
563
  ```ts
@@ -631,7 +713,7 @@ type SessionFrame =
631
713
  }>
632
714
  | Readonly<{
633
715
  kind: "progress";
634
- progress: SessionProgress;
716
+ progress: SessionProgressDelta;
635
717
  activity: SessionActivity;
636
718
  }>
637
719
  | Readonly<{
@@ -978,6 +1060,93 @@ A delegated send is accepted by its owner or held in durable mail custody.
978
1060
 
979
1061
  ## Functions
980
1062
 
1063
+ ### participantSnapshot()
1064
+
1065
+ ```ts
1066
+ function participantSnapshot(snapshot, owner): SessionSnapshot;
1067
+ ```
1068
+
1069
+ Filter participant delivery only; the holder's stored Session is unchanged.
1070
+
1071
+ #### Parameters
1072
+
1073
+ | Parameter | Type |
1074
+ | ---------- | ----------------------------------------- |
1075
+ | `snapshot` | [`SessionSnapshot`](#sessionsnapshot) |
1076
+ | `owner` | [`ParticipantPolicy`](#participantpolicy) |
1077
+
1078
+ #### Returns
1079
+
1080
+ [`SessionSnapshot`](#sessionsnapshot)
1081
+
1082
+ ---
1083
+
1084
+ ### visitorPendingPrompt()
1085
+
1086
+ ```ts
1087
+ function visitorPendingPrompt(prompt, visitorId): VisitorPendingPrompt;
1088
+ ```
1089
+
1090
+ Project one owner-selected prompt without exposing host identity or correlation
1091
+ metadata.
1092
+
1093
+ #### Parameters
1094
+
1095
+ | Parameter | Type |
1096
+ | ----------- | ----------------------------------------------- |
1097
+ | `prompt` | [`SessionPendingPrompt`](#sessionpendingprompt) |
1098
+ | `visitorId` | `string` |
1099
+
1100
+ #### Returns
1101
+
1102
+ [`VisitorPendingPrompt`](#visitorpendingprompt)
1103
+
1104
+ ---
1105
+
1106
+ ### visitorSnapshot()
1107
+
1108
+ ```ts
1109
+ function visitorSnapshot(snapshot, visitorId): SessionSnapshot;
1110
+ ```
1111
+
1112
+ Visitor-scoped Session facts use the visitor's public address, never the
1113
+ internal Session ID.
1114
+
1115
+ #### Parameters
1116
+
1117
+ | Parameter | Type |
1118
+ | ----------- | ------------------------------------- |
1119
+ | `snapshot` | [`SessionSnapshot`](#sessionsnapshot) |
1120
+ | `visitorId` | `string` |
1121
+
1122
+ #### Returns
1123
+
1124
+ [`SessionSnapshot`](#sessionsnapshot)
1125
+
1126
+ ---
1127
+
1128
+ ### visitorView()
1129
+
1130
+ ```ts
1131
+ function visitorView(snapshot, visitorId): VisitorView;
1132
+ ```
1133
+
1134
+ Project only this visitor's host-attributed prompts, their replies, and explicit
1135
+ operator replies.
1136
+
1137
+ #### Parameters
1138
+
1139
+ | Parameter | Type |
1140
+ | ----------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
1141
+ | `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` |
1142
+ | `visitorId` | `string` |
1143
+
1144
+ #### Returns
1145
+
1146
+ [`VisitorView`](#visitorview)
1147
+
1148
+ ---
1149
+
981
1150
  ### parseDelegationReceipt()
982
1151
 
983
1152
  ```ts
@@ -1133,6 +1302,41 @@ Decode the existing bounded saved-conversation projection.
1133
1302
 
1134
1303
  ---
1135
1304
 
1305
+ ### appendSessionProgress()
1306
+
1307
+ ```ts
1308
+ function appendSessionProgress(
1309
+ current,
1310
+ delta,
1311
+ ): Readonly<{
1312
+ messageId: string;
1313
+ revision: number;
1314
+ text: string;
1315
+ thinking: string;
1316
+ textOffset: number;
1317
+ thinkingOffset: number;
1318
+ textTruncated: boolean;
1319
+ thinkingTruncated: boolean;
1320
+ }> | null;
1321
+ ```
1322
+
1323
+ Fold a decoded append once; a missing prefix waits for an owner reset.
1324
+
1325
+ #### Parameters
1326
+
1327
+ | Parameter | Type |
1328
+ | --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
1329
+ | `current` | \| `Readonly`\<\{ `messageId`: `string`; `revision`: `number`; `text`: `string`; `thinking`: `string`; `textOffset`: `number`; `thinkingOffset`: `number`; `textTruncated`: `boolean`; `thinkingTruncated`: `boolean`; \}\> \| `null` |
1330
+ | `delta` | [`SessionProgressDelta`](#sessionprogressdelta) |
1331
+
1332
+ #### Returns
1333
+
1334
+ \| `Readonly`\<\{ `messageId`: `string`; `revision`: `number`; `text`: `string`;
1335
+ `thinking`: `string`; `textOffset`: `number`; `thinkingOffset`: `number`;
1336
+ `textTruncated`: `boolean`; `thinkingTruncated`: `boolean`; \}\> \| `null`
1337
+
1338
+ ---
1339
+
1136
1340
  ### bindSessionExtension()
1137
1341
 
1138
1342
  ```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,11 +427,30 @@ 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,
430
446
  ) => Promise<CommandSettlement | undefined>;
431
- acceptMail: (mail, meta?, reply?) => Promise<Accepted>;
447
+ acceptMail: (
448
+ mail,
449
+ meta?,
450
+ reply?,
451
+ stageAcceptedNotice?,
452
+ sessionGrantDelivery?,
453
+ ) => Promise<Accepted>;
432
454
  alarm: () => Promise<void>;
433
455
  activeSessions: () => Promise<readonly string[]>;
434
456
  abortActive: () => Promise<void>;