@fungi.computer/mycelium 0.0.0-stage → 0.0.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.
- package/LICENSE +21 -0
- package/README.md +303 -2
- package/THIRD_PARTY_NOTICES +2 -0
- package/dist/access.d.ts +129 -0
- package/dist/access.js +166 -0
- package/dist/capability-source.d.ts +44 -0
- package/dist/capability-source.js +1 -0
- package/dist/compiler.d.ts +28 -0
- package/dist/compiler.js +221 -0
- package/dist/define.d.ts +8 -0
- package/dist/define.js +7 -0
- package/dist/effect.d.ts +89 -0
- package/dist/effect.js +42 -0
- package/dist/errors.d.ts +48 -0
- package/dist/errors.js +62 -0
- package/dist/execute-tool.d.ts +22 -0
- package/dist/execute-tool.js +163 -0
- package/dist/image-collector.d.ts +47 -0
- package/dist/image-collector.js +39 -0
- package/dist/index.d.ts +149 -0
- package/dist/index.js +22 -0
- package/dist/internal/build-identity.d.ts +1 -0
- package/dist/internal/build-identity.js +15 -0
- package/dist/internal/build-identity.node.d.ts +1 -0
- package/dist/internal/build-identity.node.js +42 -0
- package/dist/internal/execution-lifecycle.d.ts +44 -0
- package/dist/internal/execution-lifecycle.js +328 -0
- package/dist/internal/mcp-principal.d.ts +14 -0
- package/dist/internal/mcp-principal.js +17 -0
- package/dist/mcp-catalog.d.ts +23 -0
- package/dist/mcp-catalog.js +110 -0
- package/dist/mcp.d.ts +92 -0
- package/dist/mcp.js +250 -0
- package/dist/operation-schema.d.ts +47 -0
- package/dist/operation-schema.js +50 -0
- package/dist/promise-facade.d.ts +3 -0
- package/dist/promise-facade.js +82 -0
- package/dist/registration.d.ts +74 -0
- package/dist/registration.js +157 -0
- package/dist/remote.d.ts +33 -0
- package/dist/remote.js +126 -0
- package/dist/runtime.d.ts +51 -0
- package/dist/runtime.js +159 -0
- package/dist/sandbox-boundary.d.ts +44 -0
- package/dist/sandbox-boundary.js +325 -0
- package/dist/sandbox-failure-event.d.ts +15 -0
- package/dist/sandbox-failure-event.js +34 -0
- package/dist/sandbox-failure.d.ts +128 -0
- package/dist/sandbox-failure.js +161 -0
- package/dist/sandbox-guest.d.ts +34 -0
- package/dist/sandbox-guest.js +131 -0
- package/dist/sandbox-wire.d.ts +76 -0
- package/dist/sandbox-wire.js +190 -0
- package/dist/sandbox.d.ts +41 -0
- package/dist/sandbox.js +1 -0
- package/dist/semaphore-transition.d.ts +7 -0
- package/dist/semaphore-transition.js +9 -0
- package/dist/source-runtime.d.ts +28 -0
- package/dist/source-runtime.js +162 -0
- package/dist/testing.d.ts +11 -0
- package/dist/testing.js +19 -0
- package/dist/workers/index.d.ts +9 -0
- package/dist/workers/index.js +90 -0
- package/docs/api/README.md +25 -0
- package/docs/api/define.md +20 -0
- package/docs/api/effect.md +245 -0
- package/docs/api/index.md +1081 -0
- package/docs/api/mcp.md +239 -0
- package/docs/api/remote.md +108 -0
- package/docs/api/sandbox-boundary.md +325 -0
- package/docs/api/sandbox-failure.md +1133 -0
- package/docs/api/sandbox-guest.md +191 -0
- package/docs/api/sandbox-wire.md +117 -0
- package/docs/api/sandbox.md +81 -0
- package/docs/api/semaphore-transition.md +40 -0
- package/docs/api/testing.md +72 -0
- package/docs/api/workers.md +55 -0
- package/package.json +132 -3
|
@@ -0,0 +1,1081 @@
|
|
|
1
|
+
<!-- Generated by Botanical API docs (TypeDoc + typedoc-plugin-markdown). Do not edit. -->
|
|
2
|
+
|
|
3
|
+
[**@fungi.computer/mycelium**](README.md)
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
[@fungi.computer/mycelium](README.md) / index
|
|
8
|
+
|
|
9
|
+
# index
|
|
10
|
+
|
|
11
|
+
## Classes
|
|
12
|
+
|
|
13
|
+
### MyceliumDefinitionError
|
|
14
|
+
|
|
15
|
+
A capability declaration could not form one coherent installed surface.
|
|
16
|
+
|
|
17
|
+
#### Extends
|
|
18
|
+
|
|
19
|
+
- `Error`
|
|
20
|
+
|
|
21
|
+
#### Constructors
|
|
22
|
+
|
|
23
|
+
##### Constructor
|
|
24
|
+
|
|
25
|
+
```ts
|
|
26
|
+
new MyceliumDefinitionError(message): MyceliumDefinitionError;
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
###### Parameters
|
|
30
|
+
|
|
31
|
+
| Parameter | Type |
|
|
32
|
+
| --------- | -------- |
|
|
33
|
+
| `message` | `string` |
|
|
34
|
+
|
|
35
|
+
###### Returns
|
|
36
|
+
|
|
37
|
+
[`MyceliumDefinitionError`](#myceliumdefinitionerror)
|
|
38
|
+
|
|
39
|
+
###### Overrides
|
|
40
|
+
|
|
41
|
+
```ts
|
|
42
|
+
Error.constructor;
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
#### Properties
|
|
46
|
+
|
|
47
|
+
##### code
|
|
48
|
+
|
|
49
|
+
```ts
|
|
50
|
+
readonly code: "invalid_definition" = invalidDefinitionCode;
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
Stable machine-readable failure code.
|
|
54
|
+
|
|
55
|
+
---
|
|
56
|
+
|
|
57
|
+
### MyceliumClosedError
|
|
58
|
+
|
|
59
|
+
An operation attempted to use a closed Mycelium runtime.
|
|
60
|
+
|
|
61
|
+
#### Extends
|
|
62
|
+
|
|
63
|
+
- `Error`
|
|
64
|
+
|
|
65
|
+
#### Constructors
|
|
66
|
+
|
|
67
|
+
##### Constructor
|
|
68
|
+
|
|
69
|
+
```ts
|
|
70
|
+
new MyceliumClosedError(message?): MyceliumClosedError;
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
###### Parameters
|
|
74
|
+
|
|
75
|
+
| Parameter | Type | Default value |
|
|
76
|
+
| --------- | -------- | ------------------------------ |
|
|
77
|
+
| `message` | `string` | `"Mycelium runtime is closed"` |
|
|
78
|
+
|
|
79
|
+
###### Returns
|
|
80
|
+
|
|
81
|
+
[`MyceliumClosedError`](#myceliumclosederror)
|
|
82
|
+
|
|
83
|
+
###### Overrides
|
|
84
|
+
|
|
85
|
+
```ts
|
|
86
|
+
Error.constructor;
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
#### Properties
|
|
90
|
+
|
|
91
|
+
##### code
|
|
92
|
+
|
|
93
|
+
```ts
|
|
94
|
+
readonly code: "runtime_closed" = runtimeClosedCode;
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
Stable machine-readable failure code.
|
|
98
|
+
|
|
99
|
+
---
|
|
100
|
+
|
|
101
|
+
### MyceliumSourceError
|
|
102
|
+
|
|
103
|
+
A capability source failed at its bounded host boundary.
|
|
104
|
+
|
|
105
|
+
#### Extends
|
|
106
|
+
|
|
107
|
+
- `Error`
|
|
108
|
+
|
|
109
|
+
#### Constructors
|
|
110
|
+
|
|
111
|
+
##### Constructor
|
|
112
|
+
|
|
113
|
+
```ts
|
|
114
|
+
new MyceliumSourceError(sourceId, phase): MyceliumSourceError;
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
###### Parameters
|
|
118
|
+
|
|
119
|
+
| Parameter | Type | Description |
|
|
120
|
+
| ---------- | --------------------------------------------- | ------------------------------------------------------------------- |
|
|
121
|
+
| `sourceId` | `string` \| `undefined` | Stable identity of the source, absent for whole-candidate failures. |
|
|
122
|
+
| `phase` | [`MyceliumSourcePhase`](#myceliumsourcephase) | Lifecycle phase that could not settle. |
|
|
123
|
+
|
|
124
|
+
###### Returns
|
|
125
|
+
|
|
126
|
+
[`MyceliumSourceError`](#myceliumsourceerror)
|
|
127
|
+
|
|
128
|
+
###### Overrides
|
|
129
|
+
|
|
130
|
+
```ts
|
|
131
|
+
Error.constructor;
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
#### Properties
|
|
135
|
+
|
|
136
|
+
##### code
|
|
137
|
+
|
|
138
|
+
```ts
|
|
139
|
+
readonly code: "source_failure" = sourceFailureCode;
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
Stable machine-readable failure code.
|
|
143
|
+
|
|
144
|
+
##### sourceId
|
|
145
|
+
|
|
146
|
+
```ts
|
|
147
|
+
readonly sourceId: string | undefined;
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
Stable identity of the source, absent for whole-candidate failures.
|
|
151
|
+
|
|
152
|
+
##### phase
|
|
153
|
+
|
|
154
|
+
```ts
|
|
155
|
+
readonly phase: MyceliumSourcePhase;
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
Lifecycle phase that could not settle.
|
|
159
|
+
|
|
160
|
+
---
|
|
161
|
+
|
|
162
|
+
### InvalidOperationInput
|
|
163
|
+
|
|
164
|
+
Untrusted operation input failed the operation's declared input schema.
|
|
165
|
+
|
|
166
|
+
#### Extends
|
|
167
|
+
|
|
168
|
+
- `Error`
|
|
169
|
+
|
|
170
|
+
#### Constructors
|
|
171
|
+
|
|
172
|
+
##### Constructor
|
|
173
|
+
|
|
174
|
+
```ts
|
|
175
|
+
new InvalidOperationInput(issues): InvalidOperationInput;
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
###### Parameters
|
|
179
|
+
|
|
180
|
+
| Parameter | Type | Description |
|
|
181
|
+
| --------- | ----------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------- |
|
|
182
|
+
| `issues` | readonly `Readonly`\<\{ `message`: `string`; `path?`: readonly ( \| `PropertyKey` \| `Readonly`\<\{ `key`: `PropertyKey`; \}\>)[]; \}\>[] | Schema issues, formatted for the model by the execute door. |
|
|
183
|
+
|
|
184
|
+
###### Returns
|
|
185
|
+
|
|
186
|
+
[`InvalidOperationInput`](#invalidoperationinput)
|
|
187
|
+
|
|
188
|
+
###### Overrides
|
|
189
|
+
|
|
190
|
+
```ts
|
|
191
|
+
Error.constructor;
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
#### Properties
|
|
195
|
+
|
|
196
|
+
##### issues
|
|
197
|
+
|
|
198
|
+
```ts
|
|
199
|
+
readonly issues: readonly Readonly<{
|
|
200
|
+
message: string;
|
|
201
|
+
path?: readonly (
|
|
202
|
+
| PropertyKey
|
|
203
|
+
| Readonly<{
|
|
204
|
+
key: PropertyKey;
|
|
205
|
+
}>)[];
|
|
206
|
+
}>[];
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
Schema issues, formatted for the model by the execute door.
|
|
210
|
+
|
|
211
|
+
---
|
|
212
|
+
|
|
213
|
+
### InvalidOperationOutput
|
|
214
|
+
|
|
215
|
+
An operation's result failed its declared output schema.
|
|
216
|
+
|
|
217
|
+
#### Extends
|
|
218
|
+
|
|
219
|
+
- `Error`
|
|
220
|
+
|
|
221
|
+
#### Constructors
|
|
222
|
+
|
|
223
|
+
##### Constructor
|
|
224
|
+
|
|
225
|
+
```ts
|
|
226
|
+
new InvalidOperationOutput(issues): InvalidOperationOutput;
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
###### Parameters
|
|
230
|
+
|
|
231
|
+
| Parameter | Type | Description |
|
|
232
|
+
| --------- | ----------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------ |
|
|
233
|
+
| `issues` | readonly `Readonly`\<\{ `message`: `string`; `path?`: readonly ( \| `PropertyKey` \| `Readonly`\<\{ `key`: `PropertyKey`; \}\>)[]; \}\>[] | Schema issues, kept for operators; never shown to the model. |
|
|
234
|
+
|
|
235
|
+
###### Returns
|
|
236
|
+
|
|
237
|
+
[`InvalidOperationOutput`](#invalidoperationoutput)
|
|
238
|
+
|
|
239
|
+
###### Overrides
|
|
240
|
+
|
|
241
|
+
```ts
|
|
242
|
+
Error.constructor;
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
#### Properties
|
|
246
|
+
|
|
247
|
+
##### issues
|
|
248
|
+
|
|
249
|
+
```ts
|
|
250
|
+
readonly issues: readonly Readonly<{
|
|
251
|
+
message: string;
|
|
252
|
+
path?: readonly (
|
|
253
|
+
| PropertyKey
|
|
254
|
+
| Readonly<{
|
|
255
|
+
key: PropertyKey;
|
|
256
|
+
}>)[];
|
|
257
|
+
}>[];
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
Schema issues, kept for operators; never shown to the model.
|
|
261
|
+
|
|
262
|
+
## Type Aliases
|
|
263
|
+
|
|
264
|
+
### Access
|
|
265
|
+
|
|
266
|
+
```ts
|
|
267
|
+
type Access = typeof ToolAccessSchema.Type;
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
What one operation does: `read` observes, `write` changes something.
|
|
271
|
+
|
|
272
|
+
---
|
|
273
|
+
|
|
274
|
+
### ToolPolicy
|
|
275
|
+
|
|
276
|
+
```ts
|
|
277
|
+
type ToolPolicy = typeof ToolPolicySchema.Type;
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
An author's labels for one operation or direct tool.
|
|
281
|
+
|
|
282
|
+
---
|
|
283
|
+
|
|
284
|
+
### Grant
|
|
285
|
+
|
|
286
|
+
```ts
|
|
287
|
+
type Grant = typeof GrantSchema.Type;
|
|
288
|
+
```
|
|
289
|
+
|
|
290
|
+
The access a host grants one module.
|
|
291
|
+
|
|
292
|
+
---
|
|
293
|
+
|
|
294
|
+
### Grants
|
|
295
|
+
|
|
296
|
+
```ts
|
|
297
|
+
type Grants = Readonly<Record<string, Grant>>;
|
|
298
|
+
```
|
|
299
|
+
|
|
300
|
+
A host's grants, keyed by module id. An unnamed module uses defaultGrant unless
|
|
301
|
+
it is required, in which case missing authority is refused.
|
|
302
|
+
|
|
303
|
+
---
|
|
304
|
+
|
|
305
|
+
### AccessLabel
|
|
306
|
+
|
|
307
|
+
```ts
|
|
308
|
+
type AccessLabel = Readonly<{
|
|
309
|
+
module: string;
|
|
310
|
+
operation: string;
|
|
311
|
+
access: Access;
|
|
312
|
+
confirm: boolean;
|
|
313
|
+
}>;
|
|
314
|
+
```
|
|
315
|
+
|
|
316
|
+
The labels an operation or direct tool carries, as its author declared them.
|
|
317
|
+
|
|
318
|
+
---
|
|
319
|
+
|
|
320
|
+
### AccessContext
|
|
321
|
+
|
|
322
|
+
```ts
|
|
323
|
+
type AccessContext = Readonly<{
|
|
324
|
+
sessionId: string | null;
|
|
325
|
+
}>;
|
|
326
|
+
```
|
|
327
|
+
|
|
328
|
+
The Session a runtime serves; null for a session-free host.
|
|
329
|
+
|
|
330
|
+
---
|
|
331
|
+
|
|
332
|
+
### ConfirmRequest
|
|
333
|
+
|
|
334
|
+
```ts
|
|
335
|
+
type ConfirmRequest = Readonly<
|
|
336
|
+
Omit<AccessLabel, "confirm"> & AccessContext & object
|
|
337
|
+
>;
|
|
338
|
+
```
|
|
339
|
+
|
|
340
|
+
One call the host is asked to approve before it runs.
|
|
341
|
+
|
|
342
|
+
---
|
|
343
|
+
|
|
344
|
+
### AccessRefusalReason
|
|
345
|
+
|
|
346
|
+
```ts
|
|
347
|
+
type AccessRefusalReason =
|
|
348
|
+
"not-granted" | "read-only" | "confirmation-unavailable" | "declined";
|
|
349
|
+
```
|
|
350
|
+
|
|
351
|
+
Why a call was refused before it ran.
|
|
352
|
+
|
|
353
|
+
---
|
|
354
|
+
|
|
355
|
+
### AccessRefusal
|
|
356
|
+
|
|
357
|
+
```ts
|
|
358
|
+
type AccessRefusal = Readonly<{
|
|
359
|
+
refused: true;
|
|
360
|
+
module: string;
|
|
361
|
+
operation: string;
|
|
362
|
+
reason: AccessRefusalReason;
|
|
363
|
+
message: string;
|
|
364
|
+
}>;
|
|
365
|
+
```
|
|
366
|
+
|
|
367
|
+
The ordinary result a refused call returns in place of running.
|
|
368
|
+
|
|
369
|
+
---
|
|
370
|
+
|
|
371
|
+
### AccessOptions
|
|
372
|
+
|
|
373
|
+
```ts
|
|
374
|
+
type AccessOptions = Readonly<{
|
|
375
|
+
defaultGrant?: Grant;
|
|
376
|
+
grants?: Grants;
|
|
377
|
+
required?: readonly string[];
|
|
378
|
+
sessionGrants?: (context) => Grants;
|
|
379
|
+
beforeCall?: (signal) => Promise<void>;
|
|
380
|
+
confirmWrites?: boolean;
|
|
381
|
+
approvedWrites?: (context) => readonly string[];
|
|
382
|
+
confirm?: (request, signal) => Promise<boolean>;
|
|
383
|
+
onRefused?: (refusal, context) => void;
|
|
384
|
+
}>;
|
|
385
|
+
```
|
|
386
|
+
|
|
387
|
+
Host-supplied access data and the one way to ask a person. Every field is
|
|
388
|
+
optional: hosted defaults allow unnamed modules, and no `confirm` means an
|
|
389
|
+
operation requiring approval is refused, never run unasked. MCP catalogs
|
|
390
|
+
explicitly default unnamed modules to none and require approval for writes.
|
|
391
|
+
|
|
392
|
+
---
|
|
393
|
+
|
|
394
|
+
### LabelledTool
|
|
395
|
+
|
|
396
|
+
```ts
|
|
397
|
+
type LabelledTool = MuleTool &
|
|
398
|
+
Readonly<{
|
|
399
|
+
module: string;
|
|
400
|
+
access?: Access;
|
|
401
|
+
confirm?: boolean;
|
|
402
|
+
}>;
|
|
403
|
+
```
|
|
404
|
+
|
|
405
|
+
A Mule tool that carries its author's access labels outside execute.
|
|
406
|
+
|
|
407
|
+
---
|
|
408
|
+
|
|
409
|
+
### CapabilitySession
|
|
410
|
+
|
|
411
|
+
```ts
|
|
412
|
+
type CapabilitySession = Readonly<{
|
|
413
|
+
sessionId: string;
|
|
414
|
+
commandId?: string;
|
|
415
|
+
meta?: typeof Schema.Json.Type;
|
|
416
|
+
}>;
|
|
417
|
+
```
|
|
418
|
+
|
|
419
|
+
Session on whose behalf one runtime acquires its capability projections.
|
|
420
|
+
|
|
421
|
+
---
|
|
422
|
+
|
|
423
|
+
### CapabilitySourceContext
|
|
424
|
+
|
|
425
|
+
```ts
|
|
426
|
+
type CapabilitySourceContext = Readonly<{
|
|
427
|
+
session?: CapabilitySession;
|
|
428
|
+
signal: AbortSignal;
|
|
429
|
+
invalidate: () => void;
|
|
430
|
+
}>;
|
|
431
|
+
```
|
|
432
|
+
|
|
433
|
+
Context supplied while acquiring one current capability projection.
|
|
434
|
+
|
|
435
|
+
---
|
|
436
|
+
|
|
437
|
+
### CapabilitySourceSnapshot
|
|
438
|
+
|
|
439
|
+
```ts
|
|
440
|
+
type CapabilitySourceSnapshot = Readonly<{
|
|
441
|
+
version: string;
|
|
442
|
+
modules: readonly ModuleRegistration[];
|
|
443
|
+
}>;
|
|
444
|
+
```
|
|
445
|
+
|
|
446
|
+
Bounded current projection returned by one capability source.
|
|
447
|
+
|
|
448
|
+
---
|
|
449
|
+
|
|
450
|
+
### CapabilitySourceAcquisition
|
|
451
|
+
|
|
452
|
+
```ts
|
|
453
|
+
type CapabilitySourceAcquisition = Readonly<{
|
|
454
|
+
snapshot: CapabilitySourceSnapshot;
|
|
455
|
+
release: () => Promise<void>;
|
|
456
|
+
}>;
|
|
457
|
+
```
|
|
458
|
+
|
|
459
|
+
Acquired source projection and the cleanup that owns its live adapter.
|
|
460
|
+
|
|
461
|
+
---
|
|
462
|
+
|
|
463
|
+
### CapabilitySource
|
|
464
|
+
|
|
465
|
+
```ts
|
|
466
|
+
type CapabilitySource = Readonly<{
|
|
467
|
+
id: string;
|
|
468
|
+
acquire: (context) => Promise<CapabilitySourceAcquisition>;
|
|
469
|
+
}>;
|
|
470
|
+
```
|
|
471
|
+
|
|
472
|
+
Promise-shaped host boundary for one versioned capability projection.
|
|
473
|
+
|
|
474
|
+
---
|
|
475
|
+
|
|
476
|
+
### MyceliumSourcePhase
|
|
477
|
+
|
|
478
|
+
```ts
|
|
479
|
+
type MyceliumSourcePhase = "acquire" | "release" | "stale";
|
|
480
|
+
```
|
|
481
|
+
|
|
482
|
+
Lifecycle phase in which a capability source failed.
|
|
483
|
+
|
|
484
|
+
---
|
|
485
|
+
|
|
486
|
+
### MyceliumError
|
|
487
|
+
|
|
488
|
+
```ts
|
|
489
|
+
type MyceliumError =
|
|
490
|
+
| MyceliumClosedError
|
|
491
|
+
| MyceliumDefinitionError
|
|
492
|
+
| MyceliumSourceError
|
|
493
|
+
| SandboxFailure;
|
|
494
|
+
```
|
|
495
|
+
|
|
496
|
+
Closed failure vocabulary for the first Mycelium runtime slice.
|
|
497
|
+
|
|
498
|
+
---
|
|
499
|
+
|
|
500
|
+
### ExecutionOptions
|
|
501
|
+
|
|
502
|
+
```ts
|
|
503
|
+
type ExecutionOptions = Readonly<{
|
|
504
|
+
timeoutMs?: number;
|
|
505
|
+
abortGraceMs?: number;
|
|
506
|
+
}>;
|
|
507
|
+
```
|
|
508
|
+
|
|
509
|
+
Host-selectable execution limits; neither budget can be disabled.
|
|
510
|
+
|
|
511
|
+
---
|
|
512
|
+
|
|
513
|
+
### CollectedImage
|
|
514
|
+
|
|
515
|
+
```ts
|
|
516
|
+
type CollectedImage = Readonly<{
|
|
517
|
+
data: string;
|
|
518
|
+
mimeType: "image/jpeg" | "image/png" | "image/webp";
|
|
519
|
+
path: string;
|
|
520
|
+
bytes: number;
|
|
521
|
+
}>;
|
|
522
|
+
```
|
|
523
|
+
|
|
524
|
+
A single image collected during an execute run.
|
|
525
|
+
|
|
526
|
+
---
|
|
527
|
+
|
|
528
|
+
### ExecutionImages
|
|
529
|
+
|
|
530
|
+
```ts
|
|
531
|
+
type ExecutionImages = Readonly<{
|
|
532
|
+
push: (image) => string;
|
|
533
|
+
}>;
|
|
534
|
+
```
|
|
535
|
+
|
|
536
|
+
The collector as one execution's operations see it: push only.
|
|
537
|
+
|
|
538
|
+
---
|
|
539
|
+
|
|
540
|
+
### InvocationContext
|
|
541
|
+
|
|
542
|
+
```ts
|
|
543
|
+
type InvocationContext = Readonly<{
|
|
544
|
+
executionId: string;
|
|
545
|
+
toolCallId?: string;
|
|
546
|
+
toolCallCode?: string;
|
|
547
|
+
deadlineAt: number | null;
|
|
548
|
+
signal: AbortSignal;
|
|
549
|
+
images?: ExecutionImages;
|
|
550
|
+
}>;
|
|
551
|
+
```
|
|
552
|
+
|
|
553
|
+
The only context an operation callback may observe.
|
|
554
|
+
|
|
555
|
+
---
|
|
556
|
+
|
|
557
|
+
### MyceliumOptions
|
|
558
|
+
|
|
559
|
+
```ts
|
|
560
|
+
type MyceliumOptions = Readonly<{
|
|
561
|
+
modules?: readonly ModuleRegistration[];
|
|
562
|
+
sources?: readonly CapabilitySource[];
|
|
563
|
+
session?: CapabilitySession;
|
|
564
|
+
execution?: ExecutionOptions;
|
|
565
|
+
sandbox: Sandbox;
|
|
566
|
+
onSandboxFailure?: (event) => Promise<void>;
|
|
567
|
+
tools?: readonly LabelledTool[];
|
|
568
|
+
access?: AccessOptions;
|
|
569
|
+
}>;
|
|
570
|
+
```
|
|
571
|
+
|
|
572
|
+
Inputs used to construct the Promise-facing runtime.
|
|
573
|
+
|
|
574
|
+
---
|
|
575
|
+
|
|
576
|
+
### AcquireOptions
|
|
577
|
+
|
|
578
|
+
```ts
|
|
579
|
+
type AcquireOptions = Readonly<{
|
|
580
|
+
signal?: AbortSignal;
|
|
581
|
+
}>;
|
|
582
|
+
```
|
|
583
|
+
|
|
584
|
+
Cancellation options for one Promise-facing lease acquisition.
|
|
585
|
+
|
|
586
|
+
---
|
|
587
|
+
|
|
588
|
+
### Lease
|
|
589
|
+
|
|
590
|
+
```ts
|
|
591
|
+
type Lease = Readonly<{
|
|
592
|
+
revision: string;
|
|
593
|
+
catalog: ForageCatalog;
|
|
594
|
+
executeTool: MuleTool;
|
|
595
|
+
tools: readonly MuleTool[];
|
|
596
|
+
release: () => Promise<void>;
|
|
597
|
+
}>;
|
|
598
|
+
```
|
|
599
|
+
|
|
600
|
+
One immutable Promise-facing capability revision.
|
|
601
|
+
|
|
602
|
+
---
|
|
603
|
+
|
|
604
|
+
### Runtime
|
|
605
|
+
|
|
606
|
+
```ts
|
|
607
|
+
type Runtime = Readonly<{
|
|
608
|
+
acquire: (options?) => Promise<Lease>;
|
|
609
|
+
close: () => Promise<void>;
|
|
610
|
+
}>;
|
|
611
|
+
```
|
|
612
|
+
|
|
613
|
+
Warm Promise-facing lifecycle for acquiring immutable run leases.
|
|
614
|
+
|
|
615
|
+
---
|
|
616
|
+
|
|
617
|
+
### OperationDefinition
|
|
618
|
+
|
|
619
|
+
```ts
|
|
620
|
+
type OperationDefinition<I, O> = Readonly<{
|
|
621
|
+
replay?: "safe" | "unsafe";
|
|
622
|
+
access?: Access;
|
|
623
|
+
confirm?: boolean;
|
|
624
|
+
description?: string;
|
|
625
|
+
input: OperationSchema<I>;
|
|
626
|
+
output?: OperationSchema<O>;
|
|
627
|
+
execute: (input, context) => Promise<O>;
|
|
628
|
+
}>;
|
|
629
|
+
```
|
|
630
|
+
|
|
631
|
+
Declaration for one operation behind the execute door. `input` and `output` may
|
|
632
|
+
be Effect schemas (encoded as JSON) or any Standard Schema with Standard JSON
|
|
633
|
+
Schema, such as Zod 4.
|
|
634
|
+
|
|
635
|
+
#### Type Parameters
|
|
636
|
+
|
|
637
|
+
| Type Parameter |
|
|
638
|
+
| -------------- |
|
|
639
|
+
| `I` |
|
|
640
|
+
| `O` |
|
|
641
|
+
|
|
642
|
+
---
|
|
643
|
+
|
|
644
|
+
### ModuleDefinition
|
|
645
|
+
|
|
646
|
+
```ts
|
|
647
|
+
type ModuleDefinition = Readonly<{
|
|
648
|
+
id: string;
|
|
649
|
+
name?: string;
|
|
650
|
+
namespace?: readonly string[];
|
|
651
|
+
description?: string;
|
|
652
|
+
operations: Readonly<
|
|
653
|
+
Record<string, OperationRegistration | ModuleRegistration>
|
|
654
|
+
>;
|
|
655
|
+
}>;
|
|
656
|
+
```
|
|
657
|
+
|
|
658
|
+
Declaration for one stable module and its related operations.
|
|
659
|
+
|
|
660
|
+
---
|
|
661
|
+
|
|
662
|
+
### MyceliumApi
|
|
663
|
+
|
|
664
|
+
```ts
|
|
665
|
+
type MyceliumApi = Readonly<{
|
|
666
|
+
module: (definition) => ModuleRegistration;
|
|
667
|
+
operation: {
|
|
668
|
+
<I, O>(definition): OperationRegistration<I, O>;
|
|
669
|
+
<I, O>(definition): OperationRegistration<I, O>;
|
|
670
|
+
};
|
|
671
|
+
make: (options) => Promise<Runtime>;
|
|
672
|
+
gate: (module, gate) => ModuleRegistration;
|
|
673
|
+
grantAs: (module, grantKey) => ModuleRegistration;
|
|
674
|
+
}>;
|
|
675
|
+
```
|
|
676
|
+
|
|
677
|
+
Public convenience namespace contract.
|
|
678
|
+
|
|
679
|
+
---
|
|
680
|
+
|
|
681
|
+
### OperationSchemaIssue
|
|
682
|
+
|
|
683
|
+
```ts
|
|
684
|
+
type OperationSchemaIssue = Readonly<{
|
|
685
|
+
message: string;
|
|
686
|
+
path?: readonly (
|
|
687
|
+
| PropertyKey
|
|
688
|
+
| Readonly<{
|
|
689
|
+
key: PropertyKey;
|
|
690
|
+
}>
|
|
691
|
+
)[];
|
|
692
|
+
}>;
|
|
693
|
+
```
|
|
694
|
+
|
|
695
|
+
One Standard Schema issue.
|
|
696
|
+
|
|
697
|
+
---
|
|
698
|
+
|
|
699
|
+
### OperationSchemaResult
|
|
700
|
+
|
|
701
|
+
```ts
|
|
702
|
+
type OperationSchemaResult<T> =
|
|
703
|
+
| Readonly<{
|
|
704
|
+
value: T;
|
|
705
|
+
issues?: undefined;
|
|
706
|
+
}>
|
|
707
|
+
| Readonly<{
|
|
708
|
+
issues: readonly OperationSchemaIssue[];
|
|
709
|
+
}>;
|
|
710
|
+
```
|
|
711
|
+
|
|
712
|
+
Standard Schema validation result.
|
|
713
|
+
|
|
714
|
+
#### Type Parameters
|
|
715
|
+
|
|
716
|
+
| Type Parameter |
|
|
717
|
+
| -------------- |
|
|
718
|
+
| `T` |
|
|
719
|
+
|
|
720
|
+
---
|
|
721
|
+
|
|
722
|
+
### StandardOperationSchema
|
|
723
|
+
|
|
724
|
+
```ts
|
|
725
|
+
type StandardOperationSchema<T> = Readonly<{
|
|
726
|
+
~standard: Readonly<{
|
|
727
|
+
validate: (value) =>
|
|
728
|
+
| OperationSchemaResult<T>
|
|
729
|
+
| Promise<OperationSchemaResult<T>>;
|
|
730
|
+
jsonSchema: JsonSchemaSource["~standard"]["jsonSchema"];
|
|
731
|
+
}>;
|
|
732
|
+
}>;
|
|
733
|
+
```
|
|
734
|
+
|
|
735
|
+
Any Standard Schema that also implements Standard JSON Schema, such as a Zod 4
|
|
736
|
+
schema. Mycelium validates with `validate` and describes the operation to the
|
|
737
|
+
model with `jsonSchema`.
|
|
738
|
+
|
|
739
|
+
#### Type Parameters
|
|
740
|
+
|
|
741
|
+
| Type Parameter |
|
|
742
|
+
| -------------- |
|
|
743
|
+
| `T` |
|
|
744
|
+
|
|
745
|
+
---
|
|
746
|
+
|
|
747
|
+
### OperationSchema
|
|
748
|
+
|
|
749
|
+
```ts
|
|
750
|
+
type OperationSchema<T> = Schema.Codec<T, unknown> | StandardOperationSchema<T>;
|
|
751
|
+
```
|
|
752
|
+
|
|
753
|
+
Schema for one operation's input or output: an Effect schema (exchanged as its
|
|
754
|
+
canonical JSON codec, `Schema.toCodecJson`), or any Standard Schema with
|
|
755
|
+
Standard JSON Schema such as Zod 4.
|
|
756
|
+
|
|
757
|
+
#### Type Parameters
|
|
758
|
+
|
|
759
|
+
| Type Parameter |
|
|
760
|
+
| -------------- |
|
|
761
|
+
| `T` |
|
|
762
|
+
|
|
763
|
+
---
|
|
764
|
+
|
|
765
|
+
### OperationRegistration
|
|
766
|
+
|
|
767
|
+
```ts
|
|
768
|
+
type OperationRegistration<I, O> = Readonly<{
|
|
769
|
+
[operationBrand]: true;
|
|
770
|
+
[operationTypes]?: Readonly<{
|
|
771
|
+
input: I;
|
|
772
|
+
output: O;
|
|
773
|
+
}>;
|
|
774
|
+
}>;
|
|
775
|
+
```
|
|
776
|
+
|
|
777
|
+
Opaque handle for one schema-described operation.
|
|
778
|
+
|
|
779
|
+
#### Type Parameters
|
|
780
|
+
|
|
781
|
+
| Type Parameter | Default type |
|
|
782
|
+
| -------------- | ------------ |
|
|
783
|
+
| `I` | `unknown` |
|
|
784
|
+
| `O` | `unknown` |
|
|
785
|
+
|
|
786
|
+
---
|
|
787
|
+
|
|
788
|
+
### ModuleRegistration
|
|
789
|
+
|
|
790
|
+
```ts
|
|
791
|
+
type ModuleRegistration = Readonly<{
|
|
792
|
+
[moduleBrand]: true;
|
|
793
|
+
}>;
|
|
794
|
+
```
|
|
795
|
+
|
|
796
|
+
Opaque handle for one namespaced capability module.
|
|
797
|
+
|
|
798
|
+
---
|
|
799
|
+
|
|
800
|
+
### GateDecision
|
|
801
|
+
|
|
802
|
+
```ts
|
|
803
|
+
type GateDecision =
|
|
804
|
+
| Readonly<{
|
|
805
|
+
kind: "allow";
|
|
806
|
+
}>
|
|
807
|
+
| Readonly<{
|
|
808
|
+
kind: "refuse";
|
|
809
|
+
value: MyceliumJsonValue;
|
|
810
|
+
}>;
|
|
811
|
+
```
|
|
812
|
+
|
|
813
|
+
A gate's verdict for one call: run the operation, or return `value` instead.
|
|
814
|
+
|
|
815
|
+
---
|
|
816
|
+
|
|
817
|
+
### OperationGate
|
|
818
|
+
|
|
819
|
+
```ts
|
|
820
|
+
type OperationGate = (call) => GateDecision | Promise<GateDecision>;
|
|
821
|
+
```
|
|
822
|
+
|
|
823
|
+
Asked before every call of a gated module's operations.
|
|
824
|
+
|
|
825
|
+
#### Parameters
|
|
826
|
+
|
|
827
|
+
| Parameter | Type |
|
|
828
|
+
| --------- | ------------------------------------------------------------------------------------------------ |
|
|
829
|
+
| `call` | `Readonly`\<\{ `operation`: `string`; `context`: [`InvocationContext`](#invocationcontext); \}\> |
|
|
830
|
+
|
|
831
|
+
#### Returns
|
|
832
|
+
|
|
833
|
+
\| [`GateDecision`](#gatedecision) \|
|
|
834
|
+
`Promise`\<[`GateDecision`](#gatedecision)\>
|
|
835
|
+
|
|
836
|
+
---
|
|
837
|
+
|
|
838
|
+
### SandboxFailureEvent
|
|
839
|
+
|
|
840
|
+
```ts
|
|
841
|
+
type SandboxFailureEvent = typeof SandboxFailureEventSchema.Type;
|
|
842
|
+
```
|
|
843
|
+
|
|
844
|
+
Full operator diagnostics, excluded from model conversation and default reads.
|
|
845
|
+
|
|
846
|
+
## Variables
|
|
847
|
+
|
|
848
|
+
### ToolAccessSchema
|
|
849
|
+
|
|
850
|
+
```ts
|
|
851
|
+
const ToolAccessSchema: Literals<readonly ["read", "write"]>;
|
|
852
|
+
```
|
|
853
|
+
|
|
854
|
+
What one operation does, declared by its author as a fixed fact: `read`
|
|
855
|
+
observes, `write` changes something. An unlabelled operation is `write`.
|
|
856
|
+
|
|
857
|
+
---
|
|
858
|
+
|
|
859
|
+
### ToolConfirmSchema
|
|
860
|
+
|
|
861
|
+
```ts
|
|
862
|
+
const ToolConfirmSchema: Boolean = Schema.Boolean;
|
|
863
|
+
```
|
|
864
|
+
|
|
865
|
+
Whether the author asks that a person approve each call first.
|
|
866
|
+
|
|
867
|
+
---
|
|
868
|
+
|
|
869
|
+
### ToolPolicySchema
|
|
870
|
+
|
|
871
|
+
```ts
|
|
872
|
+
const ToolPolicySchema: Struct<{
|
|
873
|
+
access: optional<Literals<readonly ["read", "write"]>>;
|
|
874
|
+
confirm: optional<Boolean>;
|
|
875
|
+
}>;
|
|
876
|
+
```
|
|
877
|
+
|
|
878
|
+
An author's labels for one operation or direct tool: the one definition both the
|
|
879
|
+
TypeScript type and the registration-time parse derive from.
|
|
880
|
+
|
|
881
|
+
---
|
|
882
|
+
|
|
883
|
+
### GrantSchema
|
|
884
|
+
|
|
885
|
+
```ts
|
|
886
|
+
const GrantSchema: Literals<readonly ["none", "read", "write"]>;
|
|
887
|
+
```
|
|
888
|
+
|
|
889
|
+
The access a host grants one module: `write` allows every operation, `read`
|
|
890
|
+
allows only `read` operations, `none` allows nothing.
|
|
891
|
+
|
|
892
|
+
---
|
|
893
|
+
|
|
894
|
+
### MAX\_EXECUTION\_IMAGES
|
|
895
|
+
|
|
896
|
+
```ts
|
|
897
|
+
const MAX_EXECUTION_IMAGES: 8 = 8;
|
|
898
|
+
```
|
|
899
|
+
|
|
900
|
+
Maximum number of out-of-band images retained for one execution.
|
|
901
|
+
|
|
902
|
+
---
|
|
903
|
+
|
|
904
|
+
### Mycelium
|
|
905
|
+
|
|
906
|
+
```ts
|
|
907
|
+
const Mycelium: MyceliumApi;
|
|
908
|
+
```
|
|
909
|
+
|
|
910
|
+
Schema-described authoring and Promise-facing runtime construction.
|
|
911
|
+
|
|
912
|
+
---
|
|
913
|
+
|
|
914
|
+
### SandboxFailureEventSchema
|
|
915
|
+
|
|
916
|
+
```ts
|
|
917
|
+
const SandboxFailureEventSchema: Struct<{
|
|
918
|
+
kind: Literal<"sandbox_failure">;
|
|
919
|
+
ref: String;
|
|
920
|
+
executionId: String;
|
|
921
|
+
adapter: String;
|
|
922
|
+
buildSha: NullOr<String>;
|
|
923
|
+
tag: Literals<
|
|
924
|
+
readonly [
|
|
925
|
+
"SourceInvalid",
|
|
926
|
+
"GuestThrew",
|
|
927
|
+
"DeadlineExceeded",
|
|
928
|
+
"Cancelled",
|
|
929
|
+
"DispatchLost",
|
|
930
|
+
"SandboxCrashed",
|
|
931
|
+
"BadResponse",
|
|
932
|
+
"ResultTooLarge",
|
|
933
|
+
"ResultNotJson",
|
|
934
|
+
"CapabilityFailed",
|
|
935
|
+
"Unknown",
|
|
936
|
+
]
|
|
937
|
+
>;
|
|
938
|
+
fields: $Record<String, Codec<JSONType, JSONType, never, never>>;
|
|
939
|
+
healthAlert: Boolean;
|
|
940
|
+
}>;
|
|
941
|
+
```
|
|
942
|
+
|
|
943
|
+
Shared structural grammar for durable operator facts and client inspection.
|
|
944
|
+
|
|
945
|
+
## References
|
|
946
|
+
|
|
947
|
+
### sandboxFailure
|
|
948
|
+
|
|
949
|
+
Re-exports [sandboxFailure](sandbox-boundary.md#sandboxfailure)
|
|
950
|
+
|
|
951
|
+
---
|
|
952
|
+
|
|
953
|
+
### isSandboxFailure
|
|
954
|
+
|
|
955
|
+
Re-exports [isSandboxFailure](sandbox-boundary.md#issandboxfailure)
|
|
956
|
+
|
|
957
|
+
---
|
|
958
|
+
|
|
959
|
+
### sandboxOperatorValue
|
|
960
|
+
|
|
961
|
+
Re-exports [sandboxOperatorValue](sandbox-boundary.md#sandboxoperatorvalue)
|
|
962
|
+
|
|
963
|
+
---
|
|
964
|
+
|
|
965
|
+
### MyceliumJsonValue
|
|
966
|
+
|
|
967
|
+
Re-exports [MyceliumJsonValue](sandbox.md#myceliumjsonvalue)
|
|
968
|
+
|
|
969
|
+
---
|
|
970
|
+
|
|
971
|
+
### SandboxValue
|
|
972
|
+
|
|
973
|
+
Re-exports [SandboxValue](sandbox.md#sandboxvalue)
|
|
974
|
+
|
|
975
|
+
---
|
|
976
|
+
|
|
977
|
+
### SandboxBinding
|
|
978
|
+
|
|
979
|
+
Re-exports [SandboxBinding](sandbox.md#sandboxbinding)
|
|
980
|
+
|
|
981
|
+
---
|
|
982
|
+
|
|
983
|
+
### SandboxRequest
|
|
984
|
+
|
|
985
|
+
Re-exports [SandboxRequest](sandbox.md#sandboxrequest)
|
|
986
|
+
|
|
987
|
+
---
|
|
988
|
+
|
|
989
|
+
### Sandbox
|
|
990
|
+
|
|
991
|
+
Re-exports [Sandbox](sandbox.md#sandbox)
|
|
992
|
+
|
|
993
|
+
---
|
|
994
|
+
|
|
995
|
+
### SourceInvalid
|
|
996
|
+
|
|
997
|
+
Re-exports [SourceInvalid](sandbox-failure.md#sourceinvalid)
|
|
998
|
+
|
|
999
|
+
---
|
|
1000
|
+
|
|
1001
|
+
### GuestThrew
|
|
1002
|
+
|
|
1003
|
+
Re-exports [GuestThrew](sandbox-failure.md#guestthrew)
|
|
1004
|
+
|
|
1005
|
+
---
|
|
1006
|
+
|
|
1007
|
+
### DeadlineExceeded
|
|
1008
|
+
|
|
1009
|
+
Re-exports [DeadlineExceeded](sandbox-failure.md#deadlineexceeded)
|
|
1010
|
+
|
|
1011
|
+
---
|
|
1012
|
+
|
|
1013
|
+
### Cancelled
|
|
1014
|
+
|
|
1015
|
+
Re-exports [Cancelled](sandbox-failure.md#cancelled)
|
|
1016
|
+
|
|
1017
|
+
---
|
|
1018
|
+
|
|
1019
|
+
### DispatchLost
|
|
1020
|
+
|
|
1021
|
+
Re-exports [DispatchLost](sandbox-failure.md#dispatchlost)
|
|
1022
|
+
|
|
1023
|
+
---
|
|
1024
|
+
|
|
1025
|
+
### SandboxCrashed
|
|
1026
|
+
|
|
1027
|
+
Re-exports [SandboxCrashed](sandbox-failure.md#sandboxcrashed)
|
|
1028
|
+
|
|
1029
|
+
---
|
|
1030
|
+
|
|
1031
|
+
### BadResponse
|
|
1032
|
+
|
|
1033
|
+
Re-exports [BadResponse](sandbox-failure.md#badresponse)
|
|
1034
|
+
|
|
1035
|
+
---
|
|
1036
|
+
|
|
1037
|
+
### ResultTooLarge
|
|
1038
|
+
|
|
1039
|
+
Re-exports [ResultTooLarge](sandbox-failure.md#resulttoolarge)
|
|
1040
|
+
|
|
1041
|
+
---
|
|
1042
|
+
|
|
1043
|
+
### ResultNotJson
|
|
1044
|
+
|
|
1045
|
+
Re-exports [ResultNotJson](sandbox-failure.md#resultnotjson)
|
|
1046
|
+
|
|
1047
|
+
---
|
|
1048
|
+
|
|
1049
|
+
### CapabilityFailed
|
|
1050
|
+
|
|
1051
|
+
Re-exports [CapabilityFailed](sandbox-failure.md#capabilityfailed)
|
|
1052
|
+
|
|
1053
|
+
---
|
|
1054
|
+
|
|
1055
|
+
### Unknown
|
|
1056
|
+
|
|
1057
|
+
Re-exports [Unknown](sandbox-failure.md#unknown)
|
|
1058
|
+
|
|
1059
|
+
---
|
|
1060
|
+
|
|
1061
|
+
### sandboxFailureMessage
|
|
1062
|
+
|
|
1063
|
+
Re-exports [sandboxFailureMessage](sandbox-failure.md#sandboxfailuremessage)
|
|
1064
|
+
|
|
1065
|
+
---
|
|
1066
|
+
|
|
1067
|
+
### SandboxFailure
|
|
1068
|
+
|
|
1069
|
+
Re-exports [SandboxFailure](sandbox-failure.md#sandboxfailure)
|
|
1070
|
+
|
|
1071
|
+
---
|
|
1072
|
+
|
|
1073
|
+
### CapabilityDiagnostic
|
|
1074
|
+
|
|
1075
|
+
Re-exports [CapabilityDiagnostic](sandbox-failure.md#capabilitydiagnostic)
|
|
1076
|
+
|
|
1077
|
+
---
|
|
1078
|
+
|
|
1079
|
+
### CapabilityFailureFields
|
|
1080
|
+
|
|
1081
|
+
Re-exports [CapabilityFailureFields](sandbox-failure.md#capabilityfailurefields)
|