@fungi.computer/shiitake 0.2.0 → 0.3.1

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 (114) hide show
  1. package/README.md +155 -34
  2. package/dist/agent-control.d.ts +77 -5
  3. package/dist/agent-control.js +271 -65
  4. package/dist/client-entry.d.ts +15 -8
  5. package/dist/client-entry.js +7 -5
  6. package/dist/client-wire.d.ts +24 -8
  7. package/dist/client-wire.js +53 -11
  8. package/dist/client.d.ts +56 -11
  9. package/dist/client.js +1 -1
  10. package/dist/cloudflare.d.ts +42 -23
  11. package/dist/cloudflare.js +76 -54
  12. package/dist/cold-sessions.d.ts +28 -0
  13. package/dist/cold-sessions.js +1 -0
  14. package/dist/delegation.d.ts +214 -0
  15. package/dist/delegation.js +319 -0
  16. package/dist/effect.d.ts +1 -1
  17. package/dist/errors.d.ts +2 -2
  18. package/dist/errors.js +2 -2
  19. package/dist/extension-contract.d.ts +10 -2
  20. package/dist/extensions.d.ts +6 -2
  21. package/dist/fleet.d.ts +43 -9
  22. package/dist/fleet.js +88 -25
  23. package/dist/hosted.js +1 -0
  24. package/dist/http-routes.d.ts +113 -29
  25. package/dist/http-routes.js +18 -1
  26. package/dist/index.d.ts +3 -2
  27. package/dist/internal/accepted-run-executor.d.ts +5 -0
  28. package/dist/internal/accepted-run-executor.js +10 -4
  29. package/dist/internal/admission-door.d.ts +3 -0
  30. package/dist/internal/admission-door.js +12 -2
  31. package/dist/internal/client-boundary.js +7 -1
  32. package/dist/internal/compaction/compaction-slot.d.ts +36 -0
  33. package/dist/internal/compaction/compaction-slot.js +41 -0
  34. package/dist/internal/compaction/compaction.d.ts +11 -8
  35. package/dist/internal/compaction/compaction.js +62 -34
  36. package/dist/internal/compaction/session-compaction.d.ts +8 -16
  37. package/dist/internal/compaction/session-compaction.js +358 -119
  38. package/dist/internal/compaction/settings.d.ts +1 -1
  39. package/dist/internal/compaction/settings.js +5 -0
  40. package/dist/internal/compaction/utils.d.ts +19 -16
  41. package/dist/internal/compaction/utils.js +30 -84
  42. package/dist/internal/contracts.d.ts +40 -13
  43. package/dist/internal/coordinator.js +28 -10
  44. package/dist/internal/effect-client.d.ts +4 -2
  45. package/dist/internal/effect-client.js +29 -0
  46. package/dist/internal/effect-contracts.d.ts +17 -4
  47. package/dist/internal/extension-runtime.d.ts +5 -0
  48. package/dist/internal/extension-runtime.js +184 -89
  49. package/dist/internal/host-meta.d.ts +7 -0
  50. package/dist/internal/model-acquisition.js +7 -1
  51. package/dist/internal/model-preference.d.ts +4 -2
  52. package/dist/internal/model-preference.js +2 -1
  53. package/dist/internal/promise-facade.js +4 -16
  54. package/dist/internal/run-failure-reason.d.ts +10 -0
  55. package/dist/internal/run-failure-reason.js +19 -0
  56. package/dist/internal/run-scope.d.ts +4 -1
  57. package/dist/internal/run-scope.js +38 -5
  58. package/dist/internal/runtime-coordinator.d.ts +2 -1
  59. package/dist/internal/runtime-coordinator.js +65 -4
  60. package/dist/internal/runtime-core.js +1 -0
  61. package/dist/internal/runtime-reconciliation.js +42 -6
  62. package/dist/internal/session-context.d.ts +1 -2
  63. package/dist/internal/session-context.js +8 -30
  64. package/dist/internal/session-status.d.ts +2 -1
  65. package/dist/internal/session-status.js +4 -1
  66. package/dist/internal/woodstock/client-projection.d.ts +6 -5
  67. package/dist/internal/woodstock/client-projection.js +79 -53
  68. package/dist/internal/woodstock/cold-sessions.d.ts +4 -0
  69. package/dist/internal/woodstock/cold-sessions.js +90 -0
  70. package/dist/internal/woodstock/extension-store.d.ts +2 -0
  71. package/dist/internal/woodstock/extension-store.js +4 -0
  72. package/dist/internal/woodstock/fleet-store.d.ts +5 -1
  73. package/dist/internal/woodstock/fleet-store.js +17 -5
  74. package/dist/internal/woodstock/index.d.ts +11 -3
  75. package/dist/internal/woodstock/index.js +33 -14
  76. package/dist/internal/woodstock/progress.d.ts +14 -1
  77. package/dist/internal/woodstock/progress.js +97 -19
  78. package/dist/internal/woodstock/run-recovery.js +6 -4
  79. package/dist/internal/woodstock/session-attention.d.ts +1 -1
  80. package/dist/internal/woodstock/session-attention.js +2 -2
  81. package/dist/internal/woodstock/session-entry.d.ts +110 -43
  82. package/dist/internal/woodstock/session-entry.js +63 -20
  83. package/dist/internal/woodstock/session-inbox.js +2 -0
  84. package/dist/internal/woodstock/session-store.d.ts +104 -24
  85. package/dist/internal/woodstock/session-store.js +937 -246
  86. package/dist/internal/woodstock/storage-admission.d.ts +8 -8
  87. package/dist/internal/woodstock/storage-admission.js +8 -34
  88. package/dist/internal/woodstock/storage-conformance.d.ts +15 -0
  89. package/dist/internal/woodstock/storage-conformance.js +489 -0
  90. package/dist/model-preference.d.ts +2 -2
  91. package/dist/model-preference.js +2 -2
  92. package/dist/node.js +1 -1
  93. package/dist/remote-client.js +8 -1
  94. package/dist/session-attention.d.ts +8 -1
  95. package/dist/session-attention.js +6 -1
  96. package/dist/testing.d.ts +1 -1
  97. package/dist/testing.js +1 -0
  98. package/docs/api/README.md +18 -16
  99. package/docs/api/agent-control.md +171 -1
  100. package/docs/api/client-entry.md +26 -10
  101. package/docs/api/client.md +153 -37
  102. package/docs/api/cloudflare.md +76 -23
  103. package/docs/api/delegation.md +485 -0
  104. package/docs/api/effect.md +20 -2
  105. package/docs/api/extensions.md +21 -9
  106. package/docs/api/fleet.md +159 -104
  107. package/docs/api/http.md +4 -1
  108. package/docs/api/index.md +116 -20
  109. package/docs/api/internal/woodstock/storage-conformance.md +81 -0
  110. package/docs/api/model-preference.md +27 -10
  111. package/docs/api/testing.md +16 -4
  112. package/package.json +26 -14
  113. package/dist/internal/browser-sessions.d.ts +0 -31
  114. package/dist/internal/browser-sessions.js +0 -173
@@ -1,11 +1,16 @@
1
1
  import * as Schema from "effect/Schema";
2
- /** An extension-owned request for human attention; expiry is owned by its timer. */
2
+ /**
3
+ * An extension-owned request for human attention; expiry is owned by its timer.
4
+ * Items marked `inbox: false` remain visible without changing the inbox state.
5
+ */
3
6
  export declare const AttentionItemSchema: Schema.Struct<{
4
7
  readonly id: Schema.NonEmptyString;
5
8
  readonly kind: Schema.NonEmptyString;
6
9
  readonly summary: Schema.NonEmptyString;
7
10
  readonly since: Schema.Int;
8
11
  readonly expiresAt: Schema.optional<Schema.Int>;
12
+ /** This item does not change the Session's inbox state; omission does. */
13
+ readonly inbox: Schema.optional<Schema.Literal<false>>;
9
14
  }>;
10
15
  /** Input to the granted attention door, scoped to the calling extension. */
11
16
  export type AttentionItem = typeof AttentionItemSchema.Type;
@@ -17,6 +22,7 @@ export declare const SessionAttentionSchema: Schema.Struct<{
17
22
  readonly summary: Schema.NonEmptyString;
18
23
  readonly since: Schema.Int;
19
24
  readonly expiresAt: Schema.optional<Schema.Int>;
25
+ readonly inbox: Schema.optional<Schema.Literal<false>>;
20
26
  }>;
21
27
  /** One open attention item in a Session observation. */
22
28
  export type SessionAttention = typeof SessionAttentionSchema.Type;
@@ -32,4 +38,5 @@ export declare const SessionAttentionListSchema: Schema.$Array<Schema.Struct<{
32
38
  readonly summary: Schema.NonEmptyString;
33
39
  readonly since: Schema.Int;
34
40
  readonly expiresAt: Schema.optional<Schema.Int>;
41
+ readonly inbox: Schema.optional<Schema.Literal<false>>;
35
42
  }>>;
@@ -1,13 +1,18 @@
1
1
  import * as Schema from "effect/Schema";
2
2
  const identity = Schema.NonEmptyString.check(Schema.isMaxLength(256));
3
3
  const instant = Schema.Int.check(Schema.isGreaterThanOrEqualTo(0));
4
- /** An extension-owned request for human attention; expiry is owned by its timer. */
4
+ /**
5
+ * An extension-owned request for human attention; expiry is owned by its timer.
6
+ * Items marked `inbox: false` remain visible without changing the inbox state.
7
+ */
5
8
  export const AttentionItemSchema = Schema.Struct({
6
9
  id: identity,
7
10
  kind: Schema.NonEmptyString.check(Schema.isMaxLength(64)),
8
11
  summary: Schema.NonEmptyString.check(Schema.isMaxLength(200)),
9
12
  since: instant,
10
13
  expiresAt: Schema.optional(instant),
14
+ /** This item does not change the Session's inbox state; omission does. */
15
+ inbox: Schema.optional(Schema.Literal(false)),
11
16
  });
12
17
  /** Public identity includes the owner so two extensions can use the same id. */
13
18
  export const SessionAttentionSchema = AttentionItemSchema.mapFields((fields) => ({
package/dist/testing.d.ts CHANGED
@@ -1,5 +1,5 @@
1
+ import { type FauxResponseStep } from "@fungi.computer/mule/testing";
1
2
  import type { ExtensionRosterV0, Json, RosteredExtensionV0 } from "./extensions.js";
2
- import { type FauxResponseStep } from "@earendil-works/pi-ai/providers/faux";
3
3
  import { type ModelSource, type SessionSnapshot, type ShiitakeOwnerAgent, type ShiitakeOptions, type SqliteOwner } from "./index.js";
4
4
  /** A deterministic model source for trusted tests; no provider account or I/O. */
5
5
  export declare function fauxModelSource(replies: readonly FauxResponseStep[]): ModelSource;
package/dist/testing.js CHANGED
@@ -17,6 +17,7 @@ export function fauxModelSource(replies) {
17
17
  return Promise.resolve({
18
18
  model: faux.model,
19
19
  stream: faux.stream,
20
+ retryable: faux.retryable,
20
21
  release: () => Promise.resolve(),
21
22
  });
22
23
  },
@@ -8,19 +8,21 @@
8
8
 
9
9
  ## Modules
10
10
 
11
- | Module | Description |
12
- | --------------------------------------- | ----------- |
13
- | [agar-extension](agar-extension.md) | - |
14
- | [agent-control](agent-control.md) | - |
15
- | [client-entry](client-entry.md) | - |
16
- | [client](client.md) | - |
17
- | [cloudflare](cloudflare.md) | - |
18
- | [effect](effect.md) | - |
19
- | [extensions](extensions.md) | - |
20
- | [fleet](fleet.md) | - |
21
- | [hosted](hosted.md) | - |
22
- | [http](http.md) | - |
23
- | [index](index.md) | - |
24
- | [model-preference](model-preference.md) | - |
25
- | [node](node.md) | - |
26
- | [testing](testing.md) | - |
11
+ | Module | Description |
12
+ | ----------------------------------------------------------------------------------- | ---------------------------------------------------------------------------- |
13
+ | [agar-extension](agar-extension.md) | - |
14
+ | [agent-control](agent-control.md) | - |
15
+ | [client-entry](client-entry.md) | - |
16
+ | [client](client.md) | - |
17
+ | [cloudflare](cloudflare.md) | - |
18
+ | [delegation](delegation.md) | - |
19
+ | [effect](effect.md) | - |
20
+ | [extensions](extensions.md) | - |
21
+ | [fleet](fleet.md) | - |
22
+ | [hosted](hosted.md) | - |
23
+ | [http](http.md) | - |
24
+ | [index](index.md) | - |
25
+ | [internal/woodstock/storage-conformance](internal/woodstock/storage-conformance.md) | Runner-independent conformance cases for one Woodstock Session storage host. |
26
+ | [model-preference](model-preference.md) | - |
27
+ | [node](node.md) | - |
28
+ | [testing](testing.md) | - |
@@ -8,14 +8,146 @@
8
8
 
9
9
  # agent-control
10
10
 
11
+ ## Classes
12
+
13
+ ### AgentArchiveRefused
14
+
15
+ A host's refusal to archive or restore an Agent, or to work with one that is
16
+ archived. It reaches the caller as a failure of the operation it refused.
17
+
18
+ #### Extends
19
+
20
+ - `Error`
21
+
22
+ #### Constructors
23
+
24
+ ##### Constructor
25
+
26
+ ```ts
27
+ new AgentArchiveRefused(reason, message): AgentArchiveRefused;
28
+ ```
29
+
30
+ ###### Parameters
31
+
32
+ | Parameter | Type |
33
+ | --------- | ---------------------------------------------------------------------------------------------- |
34
+ | `reason` | \| `"running"` \| `"pending"` \| `"archived"` \| `"not_creator"` \| `"self"` \| `"unreadable"` |
35
+ | `message` | `string` |
36
+
37
+ ###### Returns
38
+
39
+ [`AgentArchiveRefused`](#agentarchiverefused)
40
+
41
+ ###### Overrides
42
+
43
+ ```ts
44
+ Error.constructor;
45
+ ```
46
+
47
+ #### Properties
48
+
49
+ ##### name
50
+
51
+ ```ts
52
+ readonly name: "AgentArchiveRefused" = "AgentArchiveRefused";
53
+ ```
54
+
55
+ ###### Overrides
56
+
57
+ ```ts
58
+ Error.name;
59
+ ```
60
+
61
+ ##### reason
62
+
63
+ ```ts
64
+ readonly reason:
65
+ | "running"
66
+ | "pending"
67
+ | "archived"
68
+ | "not_creator"
69
+ | "self"
70
+ | "unreadable";
71
+ ```
72
+
73
+ ---
74
+
75
+ ### AgentCreateRefused
76
+
77
+ A host's refusal of an Agent creating an Agent: the creator asked to give the
78
+ created Agent more than it holds, or the host cannot tell which Agent is
79
+ creating. It reaches the caller as an `agents.create` failure.
80
+
81
+ #### Extends
82
+
83
+ - `Error`
84
+
85
+ #### Constructors
86
+
87
+ ##### Constructor
88
+
89
+ ```ts
90
+ new AgentCreateRefused(reason, message): AgentCreateRefused;
91
+ ```
92
+
93
+ ###### Parameters
94
+
95
+ | Parameter | Type |
96
+ | --------- | ------------------------------------- |
97
+ | `reason` | `"exceeds_creator"` \| `"no_creator"` |
98
+ | `message` | `string` |
99
+
100
+ ###### Returns
101
+
102
+ [`AgentCreateRefused`](#agentcreaterefused)
103
+
104
+ ###### Overrides
105
+
106
+ ```ts
107
+ Error.constructor;
108
+ ```
109
+
110
+ #### Properties
111
+
112
+ ##### name
113
+
114
+ ```ts
115
+ readonly name: "AgentCreateRefused" = "AgentCreateRefused";
116
+ ```
117
+
118
+ ###### Overrides
119
+
120
+ ```ts
121
+ Error.name;
122
+ ```
123
+
124
+ ##### reason
125
+
126
+ ```ts
127
+ readonly reason: "exceeds_creator" | "no_creator";
128
+ ```
129
+
11
130
  ## Type Aliases
12
131
 
132
+ ### ArchiveRefusalReason
133
+
134
+ ```ts
135
+ type ArchiveRefusalReason = (typeof archiveRefusalReasons)[number];
136
+ ```
137
+
138
+ One reason in `archiveRefusalReasons`.
139
+
140
+ ---
141
+
13
142
  ### AgentControlAgent
14
143
 
15
144
  ```ts
16
145
  type AgentControlAgent = Readonly<{
17
146
  agentId: string;
18
147
  name: string;
148
+ createdBy?: string | null;
149
+ model?: ModelPreference;
150
+ workingDirectory?: string;
19
151
  }>;
20
152
  ```
21
153
 
@@ -43,6 +175,8 @@ type AgentDelegationInput = Readonly<{
43
175
  agentId: string;
44
176
  sessionId: string;
45
177
  text: string;
178
+ requestId: string;
179
+ delivery: "steer" | "followUp";
46
180
  }>;
47
181
  ```
48
182
 
@@ -50,6 +184,20 @@ One host-authorized delegation, with the caller Session supplied by acquisition.
50
184
 
51
185
  ---
52
186
 
187
+ ### AgentRecallInput
188
+
189
+ ```ts
190
+ type AgentRecallInput = Readonly<{
191
+ agentId: string;
192
+ sessionId: string;
193
+ requestId: string;
194
+ }>;
195
+ ```
196
+
197
+ Exact authorized destination and caller's original send identity.
198
+
199
+ ---
200
+
53
201
  ### AgentDelegationInvocation
54
202
 
55
203
  ```ts
@@ -70,10 +218,13 @@ Host-only identity and admitted command metadata for one delegated send.
70
218
 
71
219
  ```ts
72
220
  type AgentControlDirectory = Readonly<{
73
- list: (signal) => Promise<readonly AgentControlAgent[]>;
221
+ list: (signal, options?) => Promise<readonly AgentControlAgent[]>;
74
222
  send?: (input, sourceSessionId, signal, invocation?) => Promise<Accepted>;
223
+ recall?: (input, sourceSessionId, signal) => Promise<CancelResult>;
75
224
  create?: (input, signal) => Promise<AgentControlAgent>;
76
225
  setModel?: (input, signal) => Promise<void>;
226
+ archive?: (input, signal) => Promise<void>;
227
+ unarchive?: (input, signal) => Promise<void>;
77
228
  models?: (signal) => Promise<readonly AgentControlModel[]>;
78
229
  checkModel?: (input, signal) => Promise<void>;
79
230
  open: (
@@ -90,6 +241,25 @@ type AgentControlDirectory = Readonly<{
90
241
 
91
242
  Host-owned discovery and per-operation access to ordinary Agents.
92
243
 
244
+ ## Variables
245
+
246
+ ### archiveRefusalReasons
247
+
248
+ ```ts
249
+ const archiveRefusalReasons: readonly [
250
+ "not_creator",
251
+ "self",
252
+ "running",
253
+ "pending",
254
+ "unreadable",
255
+ "archived",
256
+ ];
257
+ ```
258
+
259
+ Why a host refuses an archive or restore: the caller did not create the Agent,
260
+ is the Agent, the Agent has a running command or delegated work still waiting to
261
+ report back, its store predates the current schema, or the Agent is archived.
262
+
93
263
  ## Functions
94
264
 
95
265
  ### waitForAgentTerminal()
@@ -60,7 +60,7 @@ Borrowed latest-value activity; each iterator subscribes separately.
60
60
  type ClientEntryV1 = Readonly<{
61
61
  protocol: "shiitake.client/v1";
62
62
  id: ExtensionId;
63
- correlatedPrompts?: "note";
63
+ promptPresentation?: "footer";
64
64
  attach?: (context) => Effect.Effect<void, Error, Scope.Scope>;
65
65
  contribute?: (slot) => ClientContributionV1;
66
66
  }>;
@@ -71,13 +71,27 @@ closure.
71
71
 
72
72
  ---
73
73
 
74
+ ### ClientActivityStateV0
75
+
76
+ ```ts
77
+ type ClientActivityStateV0 = "idle" | "working" | "blocked" | "unknown";
78
+ ```
79
+
80
+ What a client observed about the Session, never an execution authority.
81
+
82
+ ---
83
+
74
84
  ### ClientActivityV0
75
85
 
76
86
  ```ts
77
- type ClientActivityV0 = "idle" | "working" | "blocked" | "unknown";
87
+ type ClientActivityV0 = Readonly<{
88
+ state: ClientActivityStateV0;
89
+ header?: string;
90
+ }>;
78
91
  ```
79
92
 
80
- Activity already observed by the client, never an execution authority.
93
+ Activity already observed by the client. `header` is only the short heading of
94
+ what blocks the Session; it never carries question bodies or answers.
81
95
 
82
96
  ## Variables
83
97
 
@@ -138,6 +152,7 @@ const clientTimelineCellSchemaV1: Struct<{
138
152
  sequence: Int;
139
153
  at: Int;
140
154
  commandId: NullOr<String>;
155
+ afterSequence: optionalKey<Int>;
141
156
  rows: $Array<Struct<{
142
157
  id: String;
143
158
  title: String;
@@ -162,7 +177,7 @@ const clientTimelineCellSchemaV1: Struct<{
162
177
  }>;
163
178
  ```
164
179
 
165
- One committed presentation event anchored to its real command, if any.
180
+ One committed presentation event with an explicit placement choice.
166
181
 
167
182
  ---
168
183
 
@@ -227,6 +242,7 @@ const clientContributionSchemaV1: Struct<{
227
242
  sequence: Int;
228
243
  at: Int;
229
244
  commandId: NullOr<String>;
245
+ afterSequence: optionalKey<Int>;
230
246
  rows: $Array<Struct<{
231
247
  id: String;
232
248
  title: String;
@@ -263,7 +279,7 @@ const parseClientEntryV1: (
263
279
  ) => Readonly<{
264
280
  protocol: "shiitake.client/v1";
265
281
  id: string & Brand<"ExtensionId">;
266
- correlatedPrompts?: "note";
282
+ promptPresentation?: "footer";
267
283
  attach?: (context) => Effect<void, Error, Scope>;
268
284
  contribute?: (slot) => object;
269
285
  }> = decodeEntry;
@@ -281,7 +297,7 @@ Admit exactly V1; installed executable code is not sandboxed.
281
297
  #### Returns
282
298
 
283
299
  `Readonly`\<\{ `protocol`: `"shiitake.client/v1"`; `id`: `string` &
284
- `Brand`\<`"ExtensionId"`\>; `correlatedPrompts?`: `"note"`; `attach?`:
300
+ `Brand`\<`"ExtensionId"`\>; `promptPresentation?`: `"footer"`; `attach?`:
285
301
  (`context`) => `Effect`\<`void`, `Error`, `Scope`\>; `contribute?`: (`slot`) =>
286
302
  `object`; \}\>
287
303
 
@@ -305,10 +321,10 @@ One typed author seam, usable with ordinary async attachment code.
305
321
 
306
322
  #### Parameters
307
323
 
308
- | Parameter | Type |
309
- | ---------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
310
- | `contract` | [`ExtensionContractV0`](extensions.md#extensioncontractv0)\<`C`, `P`, `PI`\> |
311
- | `client` | `Readonly`\<\{ `correlatedPrompts?`: [`ClientEntryV1`](#cliententryv1)\[`"correlatedPrompts"`\]; `attach?`: (`context`) => \| `void` \| `Promise`\<`void`\> \| `Effect.Effect`\<`void`, `Error`, `Scope.Scope`\>; `contribute?`: (`view`) => [`ClientContributionV1`](#clientcontributionv1); \}\> |
324
+ | Parameter | Type |
325
+ | ---------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
326
+ | `contract` | [`ExtensionContractV0`](extensions.md#extensioncontractv0)\<`C`, `P`, `PI`\> |
327
+ | `client` | `Readonly`\<\{ `promptPresentation?`: [`ClientEntryV1`](#cliententryv1)\[`"promptPresentation"`\]; `attach?`: (`context`) => \| `void` \| `Promise`\<`void`\> \| `Effect.Effect`\<`void`, `Error`, `Scope.Scope`\>; `contribute?`: (`view`) => [`ClientContributionV1`](#clientcontributionv1); \}\> |
312
328
 
313
329
  #### Returns
314
330