@fungi.computer/mycelium 0.0.0-stage → 0.0.2
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
package/docs/api/mcp.md
ADDED
|
@@ -0,0 +1,239 @@
|
|
|
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) / mcp
|
|
8
|
+
|
|
9
|
+
# mcp
|
|
10
|
+
|
|
11
|
+
## Type Aliases
|
|
12
|
+
|
|
13
|
+
### McpPrincipal
|
|
14
|
+
|
|
15
|
+
```ts
|
|
16
|
+
type McpPrincipal =
|
|
17
|
+
| Readonly<{
|
|
18
|
+
actor: Extract<
|
|
19
|
+
HostActor,
|
|
20
|
+
{
|
|
21
|
+
kind: "member";
|
|
22
|
+
}
|
|
23
|
+
>;
|
|
24
|
+
role: "owner" | "member";
|
|
25
|
+
}>
|
|
26
|
+
| Readonly<{
|
|
27
|
+
actor: Exclude<
|
|
28
|
+
HostActor,
|
|
29
|
+
{
|
|
30
|
+
kind: "member";
|
|
31
|
+
}
|
|
32
|
+
>;
|
|
33
|
+
}>;
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
Authenticated credential identity, scoped by its host. Never a bearer token.
|
|
37
|
+
|
|
38
|
+
---
|
|
39
|
+
|
|
40
|
+
### McpCatalogSnapshot
|
|
41
|
+
|
|
42
|
+
```ts
|
|
43
|
+
type McpCatalogSnapshot = Readonly<{
|
|
44
|
+
instructions: string;
|
|
45
|
+
sources: readonly CapabilitySource[];
|
|
46
|
+
grants: Grants;
|
|
47
|
+
approvedWrites?: readonly string[];
|
|
48
|
+
}>;
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
Current installed capabilities and explicit grants for one admitted principal.
|
|
52
|
+
|
|
53
|
+
---
|
|
54
|
+
|
|
55
|
+
### McpAuthentication
|
|
56
|
+
|
|
57
|
+
```ts
|
|
58
|
+
type McpAuthentication =
|
|
59
|
+
| Readonly<{
|
|
60
|
+
kind: "admitted";
|
|
61
|
+
principal: McpPrincipal;
|
|
62
|
+
}>
|
|
63
|
+
| Readonly<{
|
|
64
|
+
kind: "refused";
|
|
65
|
+
status: 401 | 403 | 404 | 429;
|
|
66
|
+
retryAfter?: number;
|
|
67
|
+
}>;
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
Admission is required on every HTTP request, including notifications.
|
|
71
|
+
|
|
72
|
+
---
|
|
73
|
+
|
|
74
|
+
### McpToolCall
|
|
75
|
+
|
|
76
|
+
```ts
|
|
77
|
+
type McpToolCall = Readonly<{
|
|
78
|
+
id: string;
|
|
79
|
+
name: string;
|
|
80
|
+
arguments: ToolCall["arguments"];
|
|
81
|
+
}>;
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
A JSON tool call submitted to the host's execution owner.
|
|
85
|
+
|
|
86
|
+
---
|
|
87
|
+
|
|
88
|
+
### McpExecutionContext
|
|
89
|
+
|
|
90
|
+
```ts
|
|
91
|
+
type McpExecutionContext = Readonly<{
|
|
92
|
+
signal: AbortSignal;
|
|
93
|
+
onPart?: (part) => Promise<void>;
|
|
94
|
+
access: Pick<AccessOptions, "confirm"> &
|
|
95
|
+
Readonly<{
|
|
96
|
+
confirmWrites: true;
|
|
97
|
+
beforeCall: (signal) => Promise<void>;
|
|
98
|
+
}>;
|
|
99
|
+
}>;
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
Request-scoped hooks carried into the same Mycelium runtime as hosted tools.
|
|
103
|
+
|
|
104
|
+
---
|
|
105
|
+
|
|
106
|
+
### McpCatalogSession
|
|
107
|
+
|
|
108
|
+
```ts
|
|
109
|
+
type McpCatalogSession = Readonly<{
|
|
110
|
+
id: string;
|
|
111
|
+
principal: McpPrincipal;
|
|
112
|
+
refresh: () => Promise<void>;
|
|
113
|
+
describe: () => Promise<{
|
|
114
|
+
instructions: string;
|
|
115
|
+
tools: readonly MuleTool["descriptor"][];
|
|
116
|
+
}>;
|
|
117
|
+
call: (call, context) => Promise<MuleToolResult>;
|
|
118
|
+
disconnect: () => Promise<void>;
|
|
119
|
+
}>;
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
A principal-bound catalog and its existing execution owner.
|
|
123
|
+
|
|
124
|
+
---
|
|
125
|
+
|
|
126
|
+
### McpCatalogProvider
|
|
127
|
+
|
|
128
|
+
```ts
|
|
129
|
+
type McpCatalogProvider = Readonly<{
|
|
130
|
+
open: (principal, input) => Promise<McpCatalogSession | null>;
|
|
131
|
+
resume: (principal, id) => Promise<McpCatalogSession | null>;
|
|
132
|
+
}>;
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
Host catalog adapter. All lookups and acquisitions are principal-bound.
|
|
136
|
+
|
|
137
|
+
---
|
|
138
|
+
|
|
139
|
+
### Mcp
|
|
140
|
+
|
|
141
|
+
```ts
|
|
142
|
+
type Mcp = Readonly<{
|
|
143
|
+
handleRequest: (request) => Promise<Response>;
|
|
144
|
+
close: () => Promise<void>;
|
|
145
|
+
}>;
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
HTTP MCP lifecycle. Closing transport streams preserves host-owned Sessions.
|
|
149
|
+
|
|
150
|
+
---
|
|
151
|
+
|
|
152
|
+
### McpSessionMetadata
|
|
153
|
+
|
|
154
|
+
```ts
|
|
155
|
+
type McpSessionMetadata = Readonly<{
|
|
156
|
+
id: string;
|
|
157
|
+
principal: McpPrincipal;
|
|
158
|
+
}>;
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
Durable connection identity, without credentials or live execution callbacks.
|
|
162
|
+
|
|
163
|
+
---
|
|
164
|
+
|
|
165
|
+
### McpPersistence
|
|
166
|
+
|
|
167
|
+
```ts
|
|
168
|
+
type McpPersistence = Readonly<{
|
|
169
|
+
eventStore: (sessionId) => EventStore;
|
|
170
|
+
initialized: (id, session) => Promise<void>;
|
|
171
|
+
closed: (id, session) => Promise<void>;
|
|
172
|
+
}>;
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
SDK-supported persistence; live protocol callbacks are never reconstructed.
|
|
176
|
+
|
|
177
|
+
## Functions
|
|
178
|
+
|
|
179
|
+
### sameMcpPrincipal()
|
|
180
|
+
|
|
181
|
+
```ts
|
|
182
|
+
function sameMcpPrincipal(left, right): boolean;
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
Compare complete admitted identities, including a canonical member's role.
|
|
186
|
+
|
|
187
|
+
#### Parameters
|
|
188
|
+
|
|
189
|
+
| Parameter | Type |
|
|
190
|
+
| --------- | ------------------------------- |
|
|
191
|
+
| `left` | [`McpPrincipal`](#mcpprincipal) |
|
|
192
|
+
| `right` | [`McpPrincipal`](#mcpprincipal) |
|
|
193
|
+
|
|
194
|
+
#### Returns
|
|
195
|
+
|
|
196
|
+
`boolean`
|
|
197
|
+
|
|
198
|
+
---
|
|
199
|
+
|
|
200
|
+
### createMcpCatalog()
|
|
201
|
+
|
|
202
|
+
```ts
|
|
203
|
+
function createMcpCatalog(options): McpCatalogProvider;
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
Adapt principal-scoped capability sources and a sandbox to the shared MCP
|
|
207
|
+
server. Connections are process-local. Durable hosts supply their own catalog
|
|
208
|
+
provider.
|
|
209
|
+
|
|
210
|
+
#### Parameters
|
|
211
|
+
|
|
212
|
+
| Parameter | Type |
|
|
213
|
+
| --------- | -------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
214
|
+
| `options` | `Readonly`\<\{ `load`: (`principal`) => `Promise`\<[`McpCatalogSnapshot`](#mcpcatalogsnapshot)\>; `sandbox`: [`Sandbox`](sandbox.md#sandbox); \}\> |
|
|
215
|
+
|
|
216
|
+
#### Returns
|
|
217
|
+
|
|
218
|
+
[`McpCatalogProvider`](#mcpcatalogprovider)
|
|
219
|
+
|
|
220
|
+
---
|
|
221
|
+
|
|
222
|
+
### createMcp()
|
|
223
|
+
|
|
224
|
+
```ts
|
|
225
|
+
function createMcp(options): Mcp;
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
Serve the host's principal-bound Mycelium catalog through one MCP
|
|
229
|
+
implementation.
|
|
230
|
+
|
|
231
|
+
#### Parameters
|
|
232
|
+
|
|
233
|
+
| Parameter | Type |
|
|
234
|
+
| --------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
235
|
+
| `options` | `Readonly`\<\{ `catalog`: [`McpCatalogProvider`](#mcpcatalogprovider); `authenticate`: (`request`) => `Promise`\<[`McpAuthentication`](#mcpauthentication)\>; `persistence?`: [`McpPersistence`](#mcppersistence); \}\> |
|
|
236
|
+
|
|
237
|
+
#### Returns
|
|
238
|
+
|
|
239
|
+
[`Mcp`](#mcp)
|
|
@@ -0,0 +1,108 @@
|
|
|
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) / remote
|
|
8
|
+
|
|
9
|
+
# remote
|
|
10
|
+
|
|
11
|
+
## Type Aliases
|
|
12
|
+
|
|
13
|
+
### RemoteOperationDescriptor
|
|
14
|
+
|
|
15
|
+
```ts
|
|
16
|
+
type RemoteOperationDescriptor = Readonly<{
|
|
17
|
+
replay: "safe" | "unsafe";
|
|
18
|
+
description?: string;
|
|
19
|
+
input: MyceliumJsonValue;
|
|
20
|
+
output: MyceliumJsonValue | null;
|
|
21
|
+
}>;
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
One operation's model-facing contract with its schemas as JSON Schema.
|
|
25
|
+
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
### RemoteModuleDescriptor
|
|
29
|
+
|
|
30
|
+
```ts
|
|
31
|
+
type RemoteModuleDescriptor = Readonly<{
|
|
32
|
+
description?: string;
|
|
33
|
+
operations: Readonly<Record<string, RemoteOperationDescriptor>>;
|
|
34
|
+
}>;
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
A module's operations keyed by their dotted path below the module, for a host
|
|
38
|
+
that runs the module in another isolate. Identity, alias and placement stay the
|
|
39
|
+
host's decision; this carries only what the model may call.
|
|
40
|
+
|
|
41
|
+
## Functions
|
|
42
|
+
|
|
43
|
+
### describeModule()
|
|
44
|
+
|
|
45
|
+
```ts
|
|
46
|
+
function describeModule(registration): RemoteModuleDescriptor;
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
Project one module's callable surface; unrepresentable schemas throw.
|
|
50
|
+
|
|
51
|
+
#### Parameters
|
|
52
|
+
|
|
53
|
+
| Parameter | Type |
|
|
54
|
+
| -------------- | --------------------------------------------------- |
|
|
55
|
+
| `registration` | [`ModuleRegistration`](index.md#moduleregistration) |
|
|
56
|
+
|
|
57
|
+
#### Returns
|
|
58
|
+
|
|
59
|
+
[`RemoteModuleDescriptor`](#remotemoduledescriptor)
|
|
60
|
+
|
|
61
|
+
---
|
|
62
|
+
|
|
63
|
+
### invokeModuleOperation()
|
|
64
|
+
|
|
65
|
+
```ts
|
|
66
|
+
function invokeModuleOperation(
|
|
67
|
+
registration,
|
|
68
|
+
path,
|
|
69
|
+
input,
|
|
70
|
+
context,
|
|
71
|
+
): Promise<JSONType>;
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
Run one described operation through its own input and output schemas.
|
|
75
|
+
|
|
76
|
+
#### Parameters
|
|
77
|
+
|
|
78
|
+
| Parameter | Type |
|
|
79
|
+
| -------------- | --------------------------------------------------- |
|
|
80
|
+
| `registration` | [`ModuleRegistration`](index.md#moduleregistration) |
|
|
81
|
+
| `path` | `string` |
|
|
82
|
+
| `input` | `unknown` |
|
|
83
|
+
| `context` | [`InvocationContext`](index.md#invocationcontext) |
|
|
84
|
+
|
|
85
|
+
#### Returns
|
|
86
|
+
|
|
87
|
+
`Promise`\<`JSONType`\>
|
|
88
|
+
|
|
89
|
+
---
|
|
90
|
+
|
|
91
|
+
### remoteModule()
|
|
92
|
+
|
|
93
|
+
```ts
|
|
94
|
+
function remoteModule(options): ModuleRegistration;
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
Rebuild a described module on the host side. Each operation parses its input and
|
|
98
|
+
output against the described JSON Schema, then forwards to `invoke`.
|
|
99
|
+
|
|
100
|
+
#### Parameters
|
|
101
|
+
|
|
102
|
+
| Parameter | Type |
|
|
103
|
+
| --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
104
|
+
| `options` | `Readonly`\<\{ `id`: `string`; `name`: `string`; `descriptor`: [`RemoteModuleDescriptor`](#remotemoduledescriptor); `invoke`: (`path`, `input`, `context`) => `Promise`\<[`MyceliumJsonValue`](sandbox.md#myceliumjsonvalue)\>; \}\> |
|
|
105
|
+
|
|
106
|
+
#### Returns
|
|
107
|
+
|
|
108
|
+
[`ModuleRegistration`](index.md#moduleregistration)
|
|
@@ -0,0 +1,325 @@
|
|
|
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) / sandbox-boundary
|
|
8
|
+
|
|
9
|
+
# sandbox-boundary
|
|
10
|
+
|
|
11
|
+
## Type Aliases
|
|
12
|
+
|
|
13
|
+
### SandboxBindingInput
|
|
14
|
+
|
|
15
|
+
```ts
|
|
16
|
+
type SandboxBindingInput = MyceliumJsonValue | undefined;
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
JSON argument or the SDK's explicit absence of an argument.
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
### SandboxOperationBindings
|
|
24
|
+
|
|
25
|
+
```ts
|
|
26
|
+
type SandboxOperationBindings = Readonly<
|
|
27
|
+
Record<
|
|
28
|
+
string,
|
|
29
|
+
Readonly<Record<string, (input) => Promise<MyceliumJsonValue>>>
|
|
30
|
+
>
|
|
31
|
+
>;
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
Host operation callbacks after decoding JSON or an absent RPC argument.
|
|
35
|
+
|
|
36
|
+
## Functions
|
|
37
|
+
|
|
38
|
+
### isSandboxFailure()
|
|
39
|
+
|
|
40
|
+
```ts
|
|
41
|
+
function isSandboxFailure(cause): cause is SandboxFailure;
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
Admit only errors constructed by the sandbox owner, using the maintained
|
|
45
|
+
decoder.
|
|
46
|
+
|
|
47
|
+
#### Parameters
|
|
48
|
+
|
|
49
|
+
| Parameter | Type |
|
|
50
|
+
| --------- | --------- |
|
|
51
|
+
| `cause` | `unknown` |
|
|
52
|
+
|
|
53
|
+
#### Returns
|
|
54
|
+
|
|
55
|
+
`cause is SandboxFailure`
|
|
56
|
+
|
|
57
|
+
---
|
|
58
|
+
|
|
59
|
+
### sandboxFailure()
|
|
60
|
+
|
|
61
|
+
```ts
|
|
62
|
+
function sandboxFailure(cause): SandboxFailure;
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
Foreign throws stay private until an owner admits a diagnostic.
|
|
66
|
+
|
|
67
|
+
#### Parameters
|
|
68
|
+
|
|
69
|
+
| Parameter | Type |
|
|
70
|
+
| --------- | --------- |
|
|
71
|
+
| `cause` | `unknown` |
|
|
72
|
+
|
|
73
|
+
#### Returns
|
|
74
|
+
|
|
75
|
+
[`SandboxFailure`](sandbox-failure.md#sandboxfailure)
|
|
76
|
+
|
|
77
|
+
---
|
|
78
|
+
|
|
79
|
+
### sandboxValueKind()
|
|
80
|
+
|
|
81
|
+
```ts
|
|
82
|
+
function sandboxValueKind(value): string;
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
Label a rejected JSON value without caller-owned reflection.
|
|
86
|
+
|
|
87
|
+
#### Parameters
|
|
88
|
+
|
|
89
|
+
| Parameter | Type |
|
|
90
|
+
| --------- | --------- |
|
|
91
|
+
| `value` | `unknown` |
|
|
92
|
+
|
|
93
|
+
#### Returns
|
|
94
|
+
|
|
95
|
+
`string`
|
|
96
|
+
|
|
97
|
+
---
|
|
98
|
+
|
|
99
|
+
### sandboxBindingInput()
|
|
100
|
+
|
|
101
|
+
```ts
|
|
102
|
+
function sandboxBindingInput(value): SandboxBindingInput;
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
Decode the RPC argument before any capability callback observes it.
|
|
106
|
+
|
|
107
|
+
#### Parameters
|
|
108
|
+
|
|
109
|
+
| Parameter | Type |
|
|
110
|
+
| --------- | --------- |
|
|
111
|
+
| `value` | `unknown` |
|
|
112
|
+
|
|
113
|
+
#### Returns
|
|
114
|
+
|
|
115
|
+
[`SandboxBindingInput`](#sandboxbindinginput)
|
|
116
|
+
|
|
117
|
+
---
|
|
118
|
+
|
|
119
|
+
### sandboxOperatorValue()
|
|
120
|
+
|
|
121
|
+
```ts
|
|
122
|
+
function sandboxOperatorValue(cause): JSONType;
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
Full operator representation, including nested errors, aggregates and cycles.
|
|
126
|
+
|
|
127
|
+
#### Parameters
|
|
128
|
+
|
|
129
|
+
| Parameter | Type |
|
|
130
|
+
| --------- | --------- |
|
|
131
|
+
| `cause` | `unknown` |
|
|
132
|
+
|
|
133
|
+
#### Returns
|
|
134
|
+
|
|
135
|
+
`JSONType`
|
|
136
|
+
|
|
137
|
+
---
|
|
138
|
+
|
|
139
|
+
### sandboxGuestFailure()
|
|
140
|
+
|
|
141
|
+
```ts
|
|
142
|
+
function sandboxGuestFailure(cause, bindings?): GuestThrew;
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
Decode the engine's guest-owned diagnostic once; renderers receive typed fields.
|
|
146
|
+
|
|
147
|
+
#### Parameters
|
|
148
|
+
|
|
149
|
+
| Parameter | Type |
|
|
150
|
+
| ---------- | --------------------------------------------------------------------------------------------------------------------- |
|
|
151
|
+
| `cause` | `unknown` |
|
|
152
|
+
| `bindings` | `Readonly`\<`Record`\<`string`, `Readonly`\<`Record`\<`string`, [`SandboxBinding`](sandbox.md#sandboxbinding)\>\>\>\> |
|
|
153
|
+
|
|
154
|
+
#### Returns
|
|
155
|
+
|
|
156
|
+
[`GuestThrew`](sandbox-failure.md#guestthrew)
|
|
157
|
+
|
|
158
|
+
---
|
|
159
|
+
|
|
160
|
+
### sandboxTransportMessage()
|
|
161
|
+
|
|
162
|
+
```ts
|
|
163
|
+
function sandboxTransportMessage(failure, ref): string;
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
Error.message is the SDK's wire carrier; only this safe, bounded envelope
|
|
167
|
+
crosses it.
|
|
168
|
+
|
|
169
|
+
#### Parameters
|
|
170
|
+
|
|
171
|
+
| Parameter | Type |
|
|
172
|
+
| --------- | ----------------------------------------------------- |
|
|
173
|
+
| `failure` | [`SandboxFailure`](sandbox-failure.md#sandboxfailure) |
|
|
174
|
+
| `ref` | `string` |
|
|
175
|
+
|
|
176
|
+
#### Returns
|
|
177
|
+
|
|
178
|
+
`string`
|
|
179
|
+
|
|
180
|
+
---
|
|
181
|
+
|
|
182
|
+
### recoverSandboxFailure()
|
|
183
|
+
|
|
184
|
+
```ts
|
|
185
|
+
function recoverSandboxFailure(failure, failures): SandboxFailure;
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
Recovery uses the decoded identity, never a match against diagnostic text.
|
|
189
|
+
|
|
190
|
+
#### Parameters
|
|
191
|
+
|
|
192
|
+
| Parameter | Type |
|
|
193
|
+
| ---------- | -------------------------------------------------------------------------------- |
|
|
194
|
+
| `failure` | [`SandboxFailure`](sandbox-failure.md#sandboxfailure) |
|
|
195
|
+
| `failures` | `ReadonlyMap`\<`string`, [`SandboxFailure`](sandbox-failure.md#sandboxfailure)\> |
|
|
196
|
+
|
|
197
|
+
#### Returns
|
|
198
|
+
|
|
199
|
+
[`SandboxFailure`](sandbox-failure.md#sandboxfailure)
|
|
200
|
+
|
|
201
|
+
---
|
|
202
|
+
|
|
203
|
+
### sandboxExecutorFailure()
|
|
204
|
+
|
|
205
|
+
```ts
|
|
206
|
+
function sandboxExecutorFailure(cause, limitMs, elapsedMs): SandboxFailure;
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
Decode Codemode's documented error carrier before adapters choose a failure.
|
|
210
|
+
|
|
211
|
+
#### Parameters
|
|
212
|
+
|
|
213
|
+
| Parameter | Type |
|
|
214
|
+
| ----------- | --------- |
|
|
215
|
+
| `cause` | `unknown` |
|
|
216
|
+
| `limitMs` | `number` |
|
|
217
|
+
| `elapsedMs` | `number` |
|
|
218
|
+
|
|
219
|
+
#### Returns
|
|
220
|
+
|
|
221
|
+
[`SandboxFailure`](sandbox-failure.md#sandboxfailure)
|
|
222
|
+
|
|
223
|
+
---
|
|
224
|
+
|
|
225
|
+
### sandboxTransportErrno()
|
|
226
|
+
|
|
227
|
+
```ts
|
|
228
|
+
function sandboxTransportErrno(cause): string | undefined;
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
Decode a transport-owned errno without reflecting on a foreign throw in
|
|
232
|
+
adapters.
|
|
233
|
+
|
|
234
|
+
#### Parameters
|
|
235
|
+
|
|
236
|
+
| Parameter | Type |
|
|
237
|
+
| --------- | --------- |
|
|
238
|
+
| `cause` | `unknown` |
|
|
239
|
+
|
|
240
|
+
#### Returns
|
|
241
|
+
|
|
242
|
+
`string` \| `undefined`
|
|
243
|
+
|
|
244
|
+
---
|
|
245
|
+
|
|
246
|
+
### sandboxSourceError()
|
|
247
|
+
|
|
248
|
+
```ts
|
|
249
|
+
function sandboxSourceError(cause):
|
|
250
|
+
| Readonly<{
|
|
251
|
+
pos: number;
|
|
252
|
+
}>
|
|
253
|
+
| undefined;
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
Admit Acorn's documented offset from a syntax exception at this boundary.
|
|
257
|
+
|
|
258
|
+
#### Parameters
|
|
259
|
+
|
|
260
|
+
| Parameter | Type |
|
|
261
|
+
| --------- | --------- |
|
|
262
|
+
| `cause` | `unknown` |
|
|
263
|
+
|
|
264
|
+
#### Returns
|
|
265
|
+
|
|
266
|
+
\| `Readonly`\<\{ `pos`: `number`; \}\> \| `undefined`
|
|
267
|
+
|
|
268
|
+
---
|
|
269
|
+
|
|
270
|
+
### sandboxCapabilityFailure()
|
|
271
|
+
|
|
272
|
+
```ts
|
|
273
|
+
function sandboxCapabilityFailure(
|
|
274
|
+
cause,
|
|
275
|
+
namespace,
|
|
276
|
+
operation,
|
|
277
|
+
admitted?,
|
|
278
|
+
): SandboxFailure;
|
|
279
|
+
```
|
|
280
|
+
|
|
281
|
+
Capability owners supply an admission schema; decoding and foreign fallback stay
|
|
282
|
+
here.
|
|
283
|
+
|
|
284
|
+
#### Parameters
|
|
285
|
+
|
|
286
|
+
| Parameter | Type |
|
|
287
|
+
| ----------- | ---------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
288
|
+
| `cause` | `unknown` |
|
|
289
|
+
| `namespace` | `string` |
|
|
290
|
+
| `operation` | `string` |
|
|
291
|
+
| `admitted` | `ZodType`\<`Readonly`\<\{ `kind`: `"Files"` \| `"Forage"` \| `"InvalidInput"` \| `"Unavailable"` \| `"OperationFailed"`; `message`: `string`; \}\>\> |
|
|
292
|
+
|
|
293
|
+
#### Returns
|
|
294
|
+
|
|
295
|
+
[`SandboxFailure`](sandbox-failure.md#sandboxfailure)
|
|
296
|
+
|
|
297
|
+
---
|
|
298
|
+
|
|
299
|
+
### sandboxBindingBoundary()
|
|
300
|
+
|
|
301
|
+
```ts
|
|
302
|
+
function sandboxBindingBoundary(bindings): Readonly<{
|
|
303
|
+
bindings: SandboxRequest["bindings"];
|
|
304
|
+
capture: (failure) => string;
|
|
305
|
+
recover: (failure) => SandboxFailure;
|
|
306
|
+
returnedFailure: (value) => SandboxFailure | undefined;
|
|
307
|
+
}>;
|
|
308
|
+
```
|
|
309
|
+
|
|
310
|
+
One boundary owns RPC decoding, safe transport and invocation-scoped recovery.
|
|
311
|
+
|
|
312
|
+
#### Parameters
|
|
313
|
+
|
|
314
|
+
| Parameter | Type |
|
|
315
|
+
| ---------- | ------------------------------------------------------- |
|
|
316
|
+
| `bindings` | [`SandboxOperationBindings`](#sandboxoperationbindings) |
|
|
317
|
+
|
|
318
|
+
#### Returns
|
|
319
|
+
|
|
320
|
+
`Readonly`\<\{ `bindings`:
|
|
321
|
+
[`SandboxRequest`](sandbox.md#sandboxrequest)\[`"bindings"`\]; `capture`:
|
|
322
|
+
(`failure`) => `string`; `recover`: (`failure`) =>
|
|
323
|
+
[`SandboxFailure`](sandbox-failure.md#sandboxfailure); `returnedFailure`:
|
|
324
|
+
(`value`) => [`SandboxFailure`](sandbox-failure.md#sandboxfailure) \|
|
|
325
|
+
`undefined`; \}\>
|