@capybara-hq/plugin-sdk 0.1.0-rc.7 → 0.1.0-rc.70
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/README.md +1 -1
- package/agent-docs/agent-templates.md +14 -2
- package/agent-docs/concepts.md +14 -5
- package/agent-docs/connector-templates.md +11 -3
- package/agent-docs/extension-points/channel.md +1 -1
- package/agent-docs/extension-points/context.md +15 -0
- package/agent-docs/extension-points/device-provider.md +15 -0
- package/agent-docs/extension-points/file-preview.md +2 -0
- package/agent-docs/extension-points/model-provider.md +3 -1
- package/agent-docs/extension-points/object-store.md +2 -0
- package/agent-docs/extension-points/push-provider.md +17 -0
- package/agent-docs/extensions.md +76 -3
- package/agent-docs/plugin-format.md +51 -12
- package/agent-docs/setup.md +54 -0
- package/dist/agent-template.d.ts +15 -6
- package/dist/agent-template.js +32 -13
- package/dist/avatar-presets.d.ts +8 -0
- package/dist/avatar-presets.js +17 -0
- package/dist/bootstrap.d.ts +109 -1
- package/dist/bootstrap.js +185 -2
- package/dist/cards.d.ts +60 -13
- package/dist/cards.js +88 -18
- package/dist/channel.d.ts +128 -47
- package/dist/channel.js +10 -5
- package/dist/client-css.d.ts +36 -0
- package/dist/client-css.js +326 -0
- package/dist/client-section.d.ts +35 -0
- package/dist/client-section.js +133 -0
- package/dist/config-ui.d.ts +28 -6
- package/dist/config-ui.js +88 -25
- package/dist/config-url-fetch.d.ts +19 -0
- package/dist/config-url-fetch.js +43 -0
- package/dist/connector-auth.d.ts +13 -2
- package/dist/connector-auth.js +82 -8
- package/dist/connector.d.ts +74 -32
- package/dist/context.d.ts +40 -0
- package/dist/context.js +2 -0
- package/dist/ctx.d.ts +210 -30
- package/dist/ctx.js +9 -1
- package/dist/define-extension.d.ts +23 -13
- package/dist/define-extension.js +19 -5
- package/dist/device-denied-paths.d.ts +20 -0
- package/dist/device-denied-paths.js +118 -0
- package/dist/device-operation.d.ts +339 -0
- package/dist/device-operation.js +312 -0
- package/dist/device-protocol.d.ts +285 -50
- package/dist/device-protocol.js +755 -90
- package/dist/device-provider.d.ts +708 -0
- package/dist/device-provider.js +325 -0
- package/dist/device-service.d.ts +52 -0
- package/dist/device-service.js +105 -0
- package/dist/dial-in.d.ts +239 -0
- package/dist/dial-in.js +155 -0
- package/dist/directory.d.ts +15 -12
- package/dist/extension-point.d.ts +2 -0
- package/dist/extension-point.js +6 -2
- package/dist/field-meta.d.ts +19 -0
- package/dist/field-meta.js +54 -0
- package/dist/file-preview.d.ts +26 -10
- package/dist/git-hosts.d.ts +53 -0
- package/dist/git-hosts.js +98 -0
- package/dist/hooks.d.ts +125 -20
- package/dist/hooks.js +5 -0
- package/dist/http-access.d.ts +62 -0
- package/dist/http-access.js +12 -0
- package/dist/identity.d.ts +38 -9
- package/dist/identity.js +21 -1
- package/dist/index.d.ts +31 -4
- package/dist/index.js +31 -4
- package/dist/model-params.d.ts +41 -22
- package/dist/model-params.js +28 -15
- package/dist/model.d.ts +210 -75
- package/dist/model.js +152 -19
- package/dist/net.d.ts +52 -0
- package/dist/net.js +34 -0
- package/dist/network-classes.d.ts +98 -0
- package/dist/network-classes.js +291 -0
- package/dist/permissions.d.ts +65 -22
- package/dist/permissions.js +139 -43
- package/dist/platform-only.d.ts +27 -0
- package/dist/platform-only.js +35 -0
- package/dist/plugin-manifest.d.ts +40 -9
- package/dist/plugin-manifest.js +171 -60
- package/dist/plugin-package.d.ts +82 -39
- package/dist/plugin-package.js +68 -41
- package/dist/push.d.ts +75 -0
- package/dist/push.js +87 -0
- package/dist/sandbox-linux-runtime-source.d.ts +1 -0
- package/dist/sandbox-linux-runtime-source.js +2343 -0
- package/dist/sandbox-native-runtime-source.d.ts +10 -0
- package/dist/sandbox-native-runtime-source.js +476 -0
- package/dist/sandbox-runtime-source.d.ts +47 -0
- package/dist/sandbox-runtime-source.js +73 -0
- package/dist/sandbox-write-denies.d.ts +139 -0
- package/dist/sandbox-write-denies.js +869 -0
- package/dist/secret.d.ts +8 -2
- package/dist/secret.js +11 -4
- package/dist/setup-check.d.ts +128 -0
- package/dist/setup-check.js +142 -0
- package/dist/setup-guide-parse.d.ts +121 -0
- package/dist/setup-guide-parse.js +356 -0
- package/dist/setup-guide-render.d.ts +45 -0
- package/dist/setup-guide-render.js +351 -0
- package/dist/setup-guide.d.ts +86 -72
- package/dist/setup-guide.js +340 -108
- package/dist/shell-capabilities.d.ts +211 -0
- package/dist/shell-capabilities.js +44 -0
- package/dist/shell-environment.d.ts +57 -0
- package/dist/shell-environment.js +21 -0
- package/dist/skill.d.ts +27 -17
- package/dist/skill.js +40 -26
- package/dist/storage.d.ts +52 -25
- package/dist/svg-viewbox.d.ts +10 -0
- package/dist/svg-viewbox.js +24 -0
- package/dist/theme-assets.d.ts +55 -0
- package/dist/theme-assets.js +489 -0
- package/dist/theme-readability.d.ts +37 -0
- package/dist/theme-readability.js +145 -0
- package/dist/theme-tokens.generated.d.ts +299 -0
- package/dist/theme-tokens.generated.js +184 -0
- package/dist/theme.d.ts +190 -0
- package/dist/theme.js +471 -0
- package/dist/tool.d.ts +104 -30
- package/dist/tool.js +29 -9
- package/dist/ui-parts.d.ts +23 -0
- package/dist/ui-parts.js +385 -0
- package/dist/ui-resolve.d.ts +35 -0
- package/dist/ui-resolve.js +42 -0
- package/dist/ui-slots.d.ts +65 -0
- package/dist/ui-slots.js +261 -0
- package/dist/ui.d.ts +221 -77
- package/dist/ui.js +104 -27
- package/dist/url.d.ts +4 -1
- package/dist/url.js +4 -1
- package/dist/web.d.ts +26 -20
- package/package.json +13 -1
- package/schemas/bootstrap-extra.v1.schema.json +186 -0
- package/schemas/bootstrap.v1.schema.json +20 -0
- package/schemas/connector-template.v1.schema.json +62 -4
- package/schemas/plugin.v1.schema.json +93 -143
- package/schemas/theme.v1.schema.json +302 -0
- package/agent-docs/extension-points/sandbox.md +0 -15
- package/dist/org-access.d.ts +0 -27
- package/dist/org-access.js +0 -35
- package/dist/sandbox.d.ts +0 -254
- package/dist/sandbox.js +0 -153
|
@@ -0,0 +1,339 @@
|
|
|
1
|
+
import { type DeviceProvider, type ExecResult, type SandboxActor, type SandboxHandle } from "./device-provider.js";
|
|
2
|
+
/** The permission profile selected for a conversation. */
|
|
3
|
+
export type PermissionProfile = "request-approval" | "approve-for-me" | "full-access";
|
|
4
|
+
/** Accepts only the supported permission profile names. */
|
|
5
|
+
export declare function isPermissionProfile(value: unknown): value is PermissionProfile;
|
|
6
|
+
/** The provider cannot enforce the requested permission profile. */
|
|
7
|
+
export declare class SandboxPermissionUnsupportedError extends Error {
|
|
8
|
+
readonly sandboxPermissionUnsupported: true;
|
|
9
|
+
constructor(message: string, opts?: ErrorOptions);
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Recognizes the inherited tag across SDK copies without requiring this class's identity, so every
|
|
13
|
+
* subclass counts too (for example {@link SandboxWorkUnsettledError}: the same definite refusal).
|
|
14
|
+
*/
|
|
15
|
+
export declare function isSandboxPermissionUnsupportedError(e: unknown): e is SandboxPermissionUnsupportedError;
|
|
16
|
+
/**
|
|
17
|
+
* Earlier work on the device has not settled, so it refused to start a new operation. It extends
|
|
18
|
+
* {@link SandboxPermissionUnsupportedError} so every check that treats that error as a definite
|
|
19
|
+
* refusal (nothing ran) treats this one the same way.
|
|
20
|
+
*/
|
|
21
|
+
export declare class SandboxWorkUnsettledError extends SandboxPermissionUnsupportedError {
|
|
22
|
+
readonly sandboxWorkUnsettled: true;
|
|
23
|
+
constructor(message: string, opts?: ErrorOptions);
|
|
24
|
+
}
|
|
25
|
+
/** Recognizes the name and tag across SDK copies without requiring this class's identity. */
|
|
26
|
+
export declare function isSandboxWorkUnsettledError(e: unknown): e is SandboxWorkUnsettledError;
|
|
27
|
+
/** The requested operation is outside the permitted scope. */
|
|
28
|
+
export declare class SandboxScopeDeniedError extends Error {
|
|
29
|
+
readonly sandboxScopeDenied: true;
|
|
30
|
+
constructor(message: string, opts?: ErrorOptions);
|
|
31
|
+
}
|
|
32
|
+
/** Recognizes the name and tag across SDK copies without requiring this class's identity. */
|
|
33
|
+
export declare function isSandboxScopeDeniedError(e: unknown): e is SandboxScopeDeniedError;
|
|
34
|
+
/**
|
|
35
|
+
* A request refused because the machine's connection changed before it was sent: the request
|
|
36
|
+
* never reached the machine, so it ran nothing. A scope refusal (it keeps that error's name, so
|
|
37
|
+
* every scope check treats it as the definite pre-effect failure it is) that the operation path
|
|
38
|
+
* records as `not_sent`, never as an unknown outcome. It says nothing about an earlier request of
|
|
39
|
+
* the same operation, so a recovery tells it apart ({@link isDeviceRequestNotSent}).
|
|
40
|
+
*
|
|
41
|
+
* A provider throws it too when it finds the instance gone before contacting the machine (for
|
|
42
|
+
* example the machine's runtime changed since the instance was created), with a
|
|
43
|
+
* `SandboxGoneError` as its `cause`: nothing ran, and the kernel also rebuilds the instance so a
|
|
44
|
+
* retry of the call runs on the new one. A gone instance found after the request was sent is a
|
|
45
|
+
* bare `SandboxGoneError` (its outcome is unknown).
|
|
46
|
+
*/
|
|
47
|
+
export declare class DeviceRequestNotSentError extends SandboxScopeDeniedError {
|
|
48
|
+
readonly notSent: true;
|
|
49
|
+
}
|
|
50
|
+
/** Recognizes {@link DeviceRequestNotSentError} by its scope refusal's name and tags, across SDK copies. */
|
|
51
|
+
export declare function isDeviceRequestNotSent(e: unknown): boolean;
|
|
52
|
+
/** A scope or execution reference is malformed; validate it before performing any effects. */
|
|
53
|
+
export declare class SandboxScopeValidationError extends Error {
|
|
54
|
+
readonly sandboxScopeValidation: true;
|
|
55
|
+
constructor(message: string, opts?: ErrorOptions);
|
|
56
|
+
}
|
|
57
|
+
/** Recognizes validation errors across SDK copies. */
|
|
58
|
+
export declare function isSandboxScopeValidationError(e: unknown): e is SandboxScopeValidationError;
|
|
59
|
+
/** An operation was consumed but its outcome is unknown. Never automatically retry with a new ID. */
|
|
60
|
+
export declare class SandboxOperationOutcomeUnknownError extends Error {
|
|
61
|
+
readonly sandboxOperationOutcomeUnknown: true;
|
|
62
|
+
constructor(message: string, opts?: ErrorOptions);
|
|
63
|
+
}
|
|
64
|
+
/** Recognizes unknown outcomes across SDK copies; an unknown outcome is not a gone instance. */
|
|
65
|
+
export declare function isSandboxOperationOutcomeUnknownError(e: unknown): e is SandboxOperationOutcomeUnknownError;
|
|
66
|
+
/**
|
|
67
|
+
* A scoped operation names the project root (null in free mode) and the roots it may write; what
|
|
68
|
+
* it may read is the provider's rule. Writable roots are also readable. Device scope uses the
|
|
69
|
+
* device's OS authority, never its host's.
|
|
70
|
+
*/
|
|
71
|
+
export type SandboxFileScope = {
|
|
72
|
+
readonly kind: "scoped";
|
|
73
|
+
readonly projectRoot: string | null;
|
|
74
|
+
readonly writeRoots: readonly string[];
|
|
75
|
+
} | {
|
|
76
|
+
readonly kind: "device";
|
|
77
|
+
};
|
|
78
|
+
/** Environment removes only the agent-specific filter; owner/org/provider ceilings still apply. */
|
|
79
|
+
export type SandboxNetworkScope = {
|
|
80
|
+
readonly kind: "none";
|
|
81
|
+
} | {
|
|
82
|
+
readonly kind: "allowlist";
|
|
83
|
+
readonly hosts: readonly string[];
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* The public internet, decided on the resolved address against `AddressClass`
|
|
87
|
+
* (`network-classes.ts`): every class in `OPEN_PUBLIC_DENIED_CLASSES` stays closed.
|
|
88
|
+
*/
|
|
89
|
+
| {
|
|
90
|
+
readonly kind: "open-public";
|
|
91
|
+
}
|
|
92
|
+
/** Only with `filesystem: { kind: "device" }` (and the reverse): the escalated (outside) call. */
|
|
93
|
+
| {
|
|
94
|
+
readonly kind: "environment";
|
|
95
|
+
};
|
|
96
|
+
/** An operation locator for idempotent admission and revocation, never a credential. */
|
|
97
|
+
export interface SandboxOperationRef {
|
|
98
|
+
readonly operationId: string;
|
|
99
|
+
/** Absolute launch-admission deadline; does not shorten an already started execution's timeout. */
|
|
100
|
+
readonly admitBeforeMs: number;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* A fresh grant for one method invocation. Providers must copy and freeze the input before use.
|
|
104
|
+
* Full access normally uses device/environment; explicit bounded grants may expand other profiles.
|
|
105
|
+
* Validation does not resolve authority or infer a grant from the profile name.
|
|
106
|
+
*/
|
|
107
|
+
export interface SandboxOperationScope extends SandboxOperationRef {
|
|
108
|
+
readonly deviceId: string;
|
|
109
|
+
readonly rootConversationId: string;
|
|
110
|
+
readonly profileRevision: number;
|
|
111
|
+
readonly ceilingRevision: string;
|
|
112
|
+
readonly profile: PermissionProfile;
|
|
113
|
+
readonly actor: Readonly<SandboxActor>;
|
|
114
|
+
readonly tag: string;
|
|
115
|
+
readonly filesystem: SandboxFileScope;
|
|
116
|
+
readonly network: SandboxNetworkScope;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Where a provider's sandbox boundary lies: around each operation (the OS sandbox of a local device,
|
|
120
|
+
* the Linux per-operation runtime) or around the whole instance (a cloud container or microVM).
|
|
121
|
+
*/
|
|
122
|
+
export type SandboxBoundary = "operation" | "instance";
|
|
123
|
+
/**
|
|
124
|
+
* Runtime support, version 2 (approval-only profiles design, "SDK and protocol"). `boundary:
|
|
125
|
+
* "instance"` with `restricted: null` is a supported device whose scope is the whole instance.
|
|
126
|
+
* `outsideSandbox` says whether a call can run outside the sandbox (an escalated call). Runtime
|
|
127
|
+
* support, not consent. `limitedBy` names who keeps a crossing closed when it is not the provider
|
|
128
|
+
* itself ({@link SandboxSupportLimitedBy}); absent, a closed crossing is the provider's own limit.
|
|
129
|
+
*/
|
|
130
|
+
export interface SandboxPermissionSupport {
|
|
131
|
+
readonly version: 2;
|
|
132
|
+
readonly boundary: SandboxBoundary;
|
|
133
|
+
readonly restricted: {
|
|
134
|
+
readonly filesystem: true;
|
|
135
|
+
readonly network: true;
|
|
136
|
+
readonly native: true;
|
|
137
|
+
readonly concurrentScopes: true;
|
|
138
|
+
} | null;
|
|
139
|
+
readonly network: {
|
|
140
|
+
readonly openPublic: boolean;
|
|
141
|
+
readonly allowlist: boolean;
|
|
142
|
+
readonly perOperationHosts: boolean;
|
|
143
|
+
};
|
|
144
|
+
readonly outsideSandbox: boolean;
|
|
145
|
+
readonly background: boolean;
|
|
146
|
+
readonly unavailableReason?: string;
|
|
147
|
+
readonly limitedBy?: SandboxSupportLimitedBy;
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Who keeps a closed crossing of a {@link SandboxPermissionSupport} closed, when it is not the
|
|
151
|
+
* provider itself: `owner` is the owner of the machine the device runs on (for example a local
|
|
152
|
+
* connection's owner ceiling, set on that machine). Only a closed crossing may name one:
|
|
153
|
+
* `outsideSandbox` with `outsideSandbox: false`, `openPublic` with `network.openPublic: false`.
|
|
154
|
+
* Display only: the kernel names that layer in its refusals and never enforces from it.
|
|
155
|
+
*/
|
|
156
|
+
export interface SandboxSupportLimitedBy {
|
|
157
|
+
readonly outsideSandbox?: "owner";
|
|
158
|
+
readonly openPublic?: "owner";
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Whether a report is a supported instance boundary: `boundary: "instance"` with no
|
|
162
|
+
* `unavailableReason`. An instance report naming a reason (a stale image, a digest mismatch)
|
|
163
|
+
* claims nothing, so a device reporting it is unsupported, never the whole-instance sandbox.
|
|
164
|
+
*/
|
|
165
|
+
export declare function instanceSupported(report: SandboxPermissionSupport): boolean;
|
|
166
|
+
/** Actor and tag come only from the immutable operation scope. */
|
|
167
|
+
export type SandboxExecOptions = Omit<Parameters<DeviceProvider["exec"]>[1], "tag" | "actor">;
|
|
168
|
+
/**
|
|
169
|
+
* A lightweight factory result: no worker opens until a method is called. Factory and method
|
|
170
|
+
* signals jointly end the operation. Every method consumes its operation ID before effects;
|
|
171
|
+
* a matching retry returns the recorded result or SandboxOperationOutcomeUnknownError, never
|
|
172
|
+
* repeats effects. Missing operation support has no fallback to the provider's raw methods.
|
|
173
|
+
* Native results and exec abort/timeout/output semantics match the existing provider contract.
|
|
174
|
+
*/
|
|
175
|
+
export interface SandboxOperation {
|
|
176
|
+
exec(args: SandboxExecOptions): Promise<ExecResult>;
|
|
177
|
+
readFile(path: string, opts: {
|
|
178
|
+
maxBytes: number;
|
|
179
|
+
signal: AbortSignal;
|
|
180
|
+
}): Promise<{
|
|
181
|
+
data: Uint8Array;
|
|
182
|
+
truncated: boolean;
|
|
183
|
+
} | null>;
|
|
184
|
+
writeFile(path: string, data: Uint8Array, signal: AbortSignal): Promise<void>;
|
|
185
|
+
stat(path: string, signal: AbortSignal): Promise<{
|
|
186
|
+
size: number;
|
|
187
|
+
isDir: boolean;
|
|
188
|
+
} | null>;
|
|
189
|
+
/** List and scan are optional together; without both, projects are unavailable. */
|
|
190
|
+
list?(path: string, opts: {
|
|
191
|
+
limit: number;
|
|
192
|
+
signal: AbortSignal;
|
|
193
|
+
}): Promise<{
|
|
194
|
+
entries: {
|
|
195
|
+
name: string;
|
|
196
|
+
isDir: boolean;
|
|
197
|
+
}[];
|
|
198
|
+
truncated: boolean;
|
|
199
|
+
} | null>;
|
|
200
|
+
scan?(base: string, opts: {
|
|
201
|
+
signal: AbortSignal;
|
|
202
|
+
}): Promise<{
|
|
203
|
+
path: string;
|
|
204
|
+
suggestedName: string;
|
|
205
|
+
}[]>;
|
|
206
|
+
}
|
|
207
|
+
/** Trusted staging only: providers validate purpose-specific roots; user tools never supply this grant. */
|
|
208
|
+
export interface SandboxPreparationScope {
|
|
209
|
+
readonly operationId: string;
|
|
210
|
+
readonly deviceId: string;
|
|
211
|
+
readonly purpose: "skills" | "attachments";
|
|
212
|
+
readonly writeRoots: readonly string[];
|
|
213
|
+
readonly tag: string;
|
|
214
|
+
}
|
|
215
|
+
/** Marker reads and writes inside trusted preparation roots, with no exec or network capability. */
|
|
216
|
+
export type SandboxPreparation = Pick<SandboxOperation, "readFile" | "writeFile" | "stat">;
|
|
217
|
+
/** Owner-authenticated browsing, independent of a conversation or its profile/consent. */
|
|
218
|
+
export interface SandboxBrowseScope extends SandboxOperationRef {
|
|
219
|
+
readonly deviceId: string;
|
|
220
|
+
readonly accountId: string;
|
|
221
|
+
readonly ceilingRevision: string;
|
|
222
|
+
readonly readRoots: readonly string[];
|
|
223
|
+
readonly tag: string;
|
|
224
|
+
}
|
|
225
|
+
/** Browsing exposes metadata only: no file contents, writes, preparation or execution. */
|
|
226
|
+
export type SandboxBrowse = Pick<SandboxOperation, "stat"> & Required<Pick<SandboxOperation, "list" | "scan">>;
|
|
227
|
+
/**
|
|
228
|
+
* An opaque locator over authenticated transport; validate generation before status, tail or stop.
|
|
229
|
+
* `instanceGeneration` is the provider's own generation of the instance (the kernel's when the
|
|
230
|
+
* provider keeps none); the kernel stores the ref as returned and never compares it with its own.
|
|
231
|
+
*/
|
|
232
|
+
export interface SandboxExecutionRef {
|
|
233
|
+
readonly executionId: string;
|
|
234
|
+
readonly operationId: string;
|
|
235
|
+
readonly instanceId: string;
|
|
236
|
+
readonly instanceGeneration: string;
|
|
237
|
+
}
|
|
238
|
+
/** A lost supervisor never binds this reference to a reused PID. */
|
|
239
|
+
export type SandboxExecutionStatus = {
|
|
240
|
+
state: "running";
|
|
241
|
+
} | {
|
|
242
|
+
state: "exited";
|
|
243
|
+
exitCode: number | null;
|
|
244
|
+
timedOut: boolean;
|
|
245
|
+
} | {
|
|
246
|
+
state: "lost";
|
|
247
|
+
};
|
|
248
|
+
/** Atomically claimed terminal outcome; retries preserve it, including a prior natural exit. */
|
|
249
|
+
export type SandboxStopResult = {
|
|
250
|
+
outcome: "already-exited";
|
|
251
|
+
exitCode: number | null;
|
|
252
|
+
timedOut: boolean;
|
|
253
|
+
} | {
|
|
254
|
+
outcome: "stopped";
|
|
255
|
+
} | {
|
|
256
|
+
outcome: "cancel-pending";
|
|
257
|
+
} | {
|
|
258
|
+
outcome: "lost";
|
|
259
|
+
};
|
|
260
|
+
/** Trusted exact-execution supervision. Status, tail and stop never provision or resume an instance. */
|
|
261
|
+
export interface SandboxBackground {
|
|
262
|
+
/**
|
|
263
|
+
* Persist exact ownership before acknowledging; retries of the same generation/operation/input
|
|
264
|
+
* return the same reference. Retain starting grants for the lifetime of the owned execution.
|
|
265
|
+
* Validate outputPath inside the scope. retainUntilMs bounds status/output record retention.
|
|
266
|
+
* instanceGeneration is the kernel's generation of the held instance `h` (the kernel always
|
|
267
|
+
* passes it, and allocates it only after `create` returns): a provider that keeps no generation
|
|
268
|
+
* of its own (a cloud provider) returns it in the reference and keys start idempotency by it; one
|
|
269
|
+
* that keeps its own (device-local's bound machine generation) returns that one instead. The
|
|
270
|
+
* kernel pins the task to its own generation and the held handle's id, not the ref's generation.
|
|
271
|
+
*/
|
|
272
|
+
start(h: SandboxHandle, scope: SandboxOperationScope, args: SandboxExecOptions & {
|
|
273
|
+
taskId: string;
|
|
274
|
+
outputPath: string;
|
|
275
|
+
retainUntilMs: number;
|
|
276
|
+
instanceGeneration?: string;
|
|
277
|
+
}): Promise<SandboxExecutionRef>;
|
|
278
|
+
status(h: SandboxHandle, ref: SandboxExecutionRef, signal: AbortSignal): Promise<SandboxExecutionStatus>;
|
|
279
|
+
/** At most 65,536 bytes, preserving UTF-8 boundaries and existing final-line limits; no caller path. */
|
|
280
|
+
tail(h: SandboxHandle, ref: SandboxExecutionRef, opts: {
|
|
281
|
+
maxBytes: number;
|
|
282
|
+
signal: AbortSignal;
|
|
283
|
+
}): Promise<{
|
|
284
|
+
data: Uint8Array;
|
|
285
|
+
truncated: boolean;
|
|
286
|
+
} | {
|
|
287
|
+
unavailable: "lost" | "expired";
|
|
288
|
+
}>;
|
|
289
|
+
/**
|
|
290
|
+
* Read retained raw merged-output bytes by exact reference, without a caller path, new scope,
|
|
291
|
+
* exec, provisioning or resume. Validate before I/O: offset is a nonnegative safe integer;
|
|
292
|
+
* maxBytes is an integer in [0, 65_536], including zero for a metadata-only probe. Invalid
|
|
293
|
+
* bounds throw SandboxScopeDeniedError. The byte budget includes any caller-requested overlap.
|
|
294
|
+
*
|
|
295
|
+
* totalBytes is one committed append-only prefix snapshot pinned at read admission. Return
|
|
296
|
+
* exactly min(maxBytes, max(totalBytes - offset, 0)) bytes starting at the requested offset,
|
|
297
|
+
* without UTF-8 trimming or decoding; retry short reads or report lost. nextOffset equals
|
|
298
|
+
* offset + data.byteLength. At/past the snapshot end, return empty data with unchanged offset.
|
|
299
|
+
* Reads are non-destructive and repeatable; concurrent appends cannot change returned bytes
|
|
300
|
+
* or this snapshot. Safe-integer position overflow fails collection rather than rounding.
|
|
301
|
+
*
|
|
302
|
+
* Missing/untrustworthy retained storage returns lost; a known expired record returns expired.
|
|
303
|
+
* Exact-ref/device/generation mismatches remain scope-denied errors; aborts propagate.
|
|
304
|
+
* Unlike tail, terminal reads retain every line. Current task access checks still apply.
|
|
305
|
+
*/
|
|
306
|
+
readOutput(h: SandboxHandle, ref: SandboxExecutionRef, opts: {
|
|
307
|
+
offset: number;
|
|
308
|
+
maxBytes: number;
|
|
309
|
+
signal: AbortSignal;
|
|
310
|
+
}): Promise<{
|
|
311
|
+
data: Uint8Array;
|
|
312
|
+
offset: number;
|
|
313
|
+
nextOffset: number;
|
|
314
|
+
totalBytes: number;
|
|
315
|
+
} | {
|
|
316
|
+
unavailable: "lost" | "expired";
|
|
317
|
+
}>;
|
|
318
|
+
/** Persist pending cancellation while unreachable; apply it before an explicit resume can run work. */
|
|
319
|
+
stop(h: SandboxHandle, ref: SandboxExecutionRef, opts: {
|
|
320
|
+
graceMs: number;
|
|
321
|
+
signal: AbortSignal;
|
|
322
|
+
}): Promise<SandboxStopResult>;
|
|
323
|
+
}
|
|
324
|
+
/** Pure structural validation and a frozen copy; no clock lookup or authority resolution. */
|
|
325
|
+
export declare function parseSandboxOperationRef(value: unknown): SandboxOperationRef;
|
|
326
|
+
/**
|
|
327
|
+
* Validates a scope and returns a deeply frozen copy, throwing SandboxScopeValidationError.
|
|
328
|
+
* IDs and ceiling revisions are bounded to 128 characters; roots to 64 paths of at most 4096 characters;
|
|
329
|
+
* hosts to 100 entries passing validateAllowHost. Empty grants stay empty, including deny-all.
|
|
330
|
+
* Performs no I/O, authority lookup or deadline refresh. Unknown fields are rejected at every level.
|
|
331
|
+
* The `environment` network and the `device` filesystem are accepted only together.
|
|
332
|
+
*/
|
|
333
|
+
export declare function parseSandboxOperationScope(value: unknown): SandboxOperationScope;
|
|
334
|
+
/** Validates an owner browsing grant and returns a deeply frozen copy; no conversation is required. */
|
|
335
|
+
export declare function parseSandboxBrowseScope(value: unknown): SandboxBrowseScope;
|
|
336
|
+
/** Validates trusted staging structure and returns a deeply frozen copy; does not authorize its roots. */
|
|
337
|
+
export declare function parseSandboxPreparationScope(value: unknown): SandboxPreparationScope;
|
|
338
|
+
/** Validates all four bounded locator fields and returns a frozen copy; does not authenticate the caller. */
|
|
339
|
+
export declare function parseSandboxExecutionRef(value: unknown): SandboxExecutionRef;
|
|
@@ -0,0 +1,312 @@
|
|
|
1
|
+
import { SANDBOX_TAG_RE, validateAllowHost, validateSandboxPathShape, } from "./device-provider.js";
|
|
2
|
+
/** Accepts only the supported permission profile names. */
|
|
3
|
+
export function isPermissionProfile(value) {
|
|
4
|
+
return value === "request-approval" || value === "approve-for-me" || value === "full-access";
|
|
5
|
+
}
|
|
6
|
+
/** The provider cannot enforce the requested permission profile. */
|
|
7
|
+
export class SandboxPermissionUnsupportedError extends Error {
|
|
8
|
+
sandboxPermissionUnsupported = true;
|
|
9
|
+
constructor(message, opts) {
|
|
10
|
+
super(message, opts && "cause" in opts ? { cause: opts.cause } : undefined);
|
|
11
|
+
this.name = "SandboxPermissionUnsupportedError";
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Recognizes the inherited tag across SDK copies without requiring this class's identity, so every
|
|
16
|
+
* subclass counts too (for example {@link SandboxWorkUnsettledError}: the same definite refusal).
|
|
17
|
+
*/
|
|
18
|
+
export function isSandboxPermissionUnsupportedError(e) {
|
|
19
|
+
return (e instanceof Error &&
|
|
20
|
+
e.sandboxPermissionUnsupported === true);
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Earlier work on the device has not settled, so it refused to start a new operation. It extends
|
|
24
|
+
* {@link SandboxPermissionUnsupportedError} so every check that treats that error as a definite
|
|
25
|
+
* refusal (nothing ran) treats this one the same way.
|
|
26
|
+
*/
|
|
27
|
+
export class SandboxWorkUnsettledError extends SandboxPermissionUnsupportedError {
|
|
28
|
+
sandboxWorkUnsettled = true;
|
|
29
|
+
constructor(message, opts) {
|
|
30
|
+
super(message, opts);
|
|
31
|
+
this.name = "SandboxWorkUnsettledError";
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
/** Recognizes the name and tag across SDK copies without requiring this class's identity. */
|
|
35
|
+
export function isSandboxWorkUnsettledError(e) {
|
|
36
|
+
return (e instanceof Error &&
|
|
37
|
+
e.name === "SandboxWorkUnsettledError" &&
|
|
38
|
+
e.sandboxWorkUnsettled === true);
|
|
39
|
+
}
|
|
40
|
+
/** The requested operation is outside the permitted scope. */
|
|
41
|
+
export class SandboxScopeDeniedError extends Error {
|
|
42
|
+
sandboxScopeDenied = true;
|
|
43
|
+
constructor(message, opts) {
|
|
44
|
+
super(message, opts && "cause" in opts ? { cause: opts.cause } : undefined);
|
|
45
|
+
this.name = "SandboxScopeDeniedError";
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
/** Recognizes the name and tag across SDK copies without requiring this class's identity. */
|
|
49
|
+
export function isSandboxScopeDeniedError(e) {
|
|
50
|
+
return (e instanceof Error &&
|
|
51
|
+
e.name === "SandboxScopeDeniedError" &&
|
|
52
|
+
e.sandboxScopeDenied === true);
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* A request refused because the machine's connection changed before it was sent: the request
|
|
56
|
+
* never reached the machine, so it ran nothing. A scope refusal (it keeps that error's name, so
|
|
57
|
+
* every scope check treats it as the definite pre-effect failure it is) that the operation path
|
|
58
|
+
* records as `not_sent`, never as an unknown outcome. It says nothing about an earlier request of
|
|
59
|
+
* the same operation, so a recovery tells it apart ({@link isDeviceRequestNotSent}).
|
|
60
|
+
*
|
|
61
|
+
* A provider throws it too when it finds the instance gone before contacting the machine (for
|
|
62
|
+
* example the machine's runtime changed since the instance was created), with a
|
|
63
|
+
* `SandboxGoneError` as its `cause`: nothing ran, and the kernel also rebuilds the instance so a
|
|
64
|
+
* retry of the call runs on the new one. A gone instance found after the request was sent is a
|
|
65
|
+
* bare `SandboxGoneError` (its outcome is unknown).
|
|
66
|
+
*/
|
|
67
|
+
export class DeviceRequestNotSentError extends SandboxScopeDeniedError {
|
|
68
|
+
notSent = true;
|
|
69
|
+
}
|
|
70
|
+
/** Recognizes {@link DeviceRequestNotSentError} by its scope refusal's name and tags, across SDK copies. */
|
|
71
|
+
export function isDeviceRequestNotSent(e) {
|
|
72
|
+
return isSandboxScopeDeniedError(e) && e.notSent === true;
|
|
73
|
+
}
|
|
74
|
+
/** A scope or execution reference is malformed; validate it before performing any effects. */
|
|
75
|
+
export class SandboxScopeValidationError extends Error {
|
|
76
|
+
sandboxScopeValidation = true;
|
|
77
|
+
constructor(message, opts) {
|
|
78
|
+
super(message, opts && "cause" in opts ? { cause: opts.cause } : undefined);
|
|
79
|
+
this.name = "SandboxScopeValidationError";
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
/** Recognizes validation errors across SDK copies. */
|
|
83
|
+
export function isSandboxScopeValidationError(e) {
|
|
84
|
+
return (e instanceof Error &&
|
|
85
|
+
e.name === "SandboxScopeValidationError" &&
|
|
86
|
+
e.sandboxScopeValidation === true);
|
|
87
|
+
}
|
|
88
|
+
/** An operation was consumed but its outcome is unknown. Never automatically retry with a new ID. */
|
|
89
|
+
export class SandboxOperationOutcomeUnknownError extends Error {
|
|
90
|
+
sandboxOperationOutcomeUnknown = true;
|
|
91
|
+
constructor(message, opts) {
|
|
92
|
+
super(message, opts && "cause" in opts ? { cause: opts.cause } : undefined);
|
|
93
|
+
this.name = "SandboxOperationOutcomeUnknownError";
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
/** Recognizes unknown outcomes across SDK copies; an unknown outcome is not a gone instance. */
|
|
97
|
+
export function isSandboxOperationOutcomeUnknownError(e) {
|
|
98
|
+
return (e instanceof Error &&
|
|
99
|
+
e.name === "SandboxOperationOutcomeUnknownError" &&
|
|
100
|
+
e.sandboxOperationOutcomeUnknown === true);
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Whether a report is a supported instance boundary: `boundary: "instance"` with no
|
|
104
|
+
* `unavailableReason`. An instance report naming a reason (a stale image, a digest mismatch)
|
|
105
|
+
* claims nothing, so a device reporting it is unsupported, never the whole-instance sandbox.
|
|
106
|
+
*/
|
|
107
|
+
export function instanceSupported(report) {
|
|
108
|
+
return report.boundary === "instance" && report.unavailableReason === undefined;
|
|
109
|
+
}
|
|
110
|
+
function invalid(field, requirement) {
|
|
111
|
+
throw new SandboxScopeValidationError(`Invalid ${field}: ${requirement}. Supply a valid scope or reference before retrying.`);
|
|
112
|
+
}
|
|
113
|
+
function record(value, keys, field) {
|
|
114
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
115
|
+
return invalid(field, "expected an object");
|
|
116
|
+
}
|
|
117
|
+
const prototype = Object.getPrototypeOf(value);
|
|
118
|
+
if (prototype !== Object.prototype && prototype !== null)
|
|
119
|
+
return invalid(field, "expected a plain object");
|
|
120
|
+
const result = Object.create(null);
|
|
121
|
+
for (const key of Reflect.ownKeys(value)) {
|
|
122
|
+
if (typeof key !== "string" || !keys.includes(key))
|
|
123
|
+
return invalid(field, "unknown fields are not allowed");
|
|
124
|
+
const descriptor = Object.getOwnPropertyDescriptor(value, key);
|
|
125
|
+
if (!descriptor || !("value" in descriptor))
|
|
126
|
+
return invalid(field, "accessor fields are not allowed");
|
|
127
|
+
result[key] = descriptor.value;
|
|
128
|
+
}
|
|
129
|
+
return result;
|
|
130
|
+
}
|
|
131
|
+
function id(value, field) {
|
|
132
|
+
if (typeof value !== "string" || value.length === 0 || value.length > 128) {
|
|
133
|
+
return invalid(field, "expected a nonempty string of at most 128 characters");
|
|
134
|
+
}
|
|
135
|
+
return value;
|
|
136
|
+
}
|
|
137
|
+
function integer(value, minimum, field) {
|
|
138
|
+
if (typeof value !== "number" || !Number.isSafeInteger(value) || value < minimum) {
|
|
139
|
+
return invalid(field, `expected a safe integer greater than or equal to ${minimum}`);
|
|
140
|
+
}
|
|
141
|
+
return value;
|
|
142
|
+
}
|
|
143
|
+
function tag(value) {
|
|
144
|
+
if (typeof value !== "string" || !SANDBOX_TAG_RE.test(value))
|
|
145
|
+
return invalid("tag", "expected 1–64 lowercase letters, digits or hyphens");
|
|
146
|
+
return value;
|
|
147
|
+
}
|
|
148
|
+
function strings(value, maximum, check, field) {
|
|
149
|
+
if (!Array.isArray(value) || value.length > maximum)
|
|
150
|
+
return invalid(field, `expected an array of at most ${maximum} entries`);
|
|
151
|
+
if (Reflect.ownKeys(value).length !== value.length + 1)
|
|
152
|
+
return invalid(field, "sparse arrays and extra fields are not allowed");
|
|
153
|
+
const result = [];
|
|
154
|
+
for (let i = 0; i < value.length; i++) {
|
|
155
|
+
const descriptor = Object.getOwnPropertyDescriptor(value, i);
|
|
156
|
+
if (!descriptor || !("value" in descriptor))
|
|
157
|
+
return invalid(field, "expected array data entries");
|
|
158
|
+
const item = descriptor.value;
|
|
159
|
+
if (typeof item !== "string")
|
|
160
|
+
return invalid(field, "expected string entries");
|
|
161
|
+
const errors = check(item);
|
|
162
|
+
if (errors.length > 0)
|
|
163
|
+
return invalid(field, errors.join("; "));
|
|
164
|
+
result.push(item);
|
|
165
|
+
}
|
|
166
|
+
return Object.freeze(result);
|
|
167
|
+
}
|
|
168
|
+
function roots(value, field) {
|
|
169
|
+
return strings(value, 64, validateSandboxPathShape, field);
|
|
170
|
+
}
|
|
171
|
+
function projectRoot(value) {
|
|
172
|
+
if (value === null)
|
|
173
|
+
return null;
|
|
174
|
+
if (typeof value !== "string")
|
|
175
|
+
return invalid("filesystem.projectRoot", "expected an absolute path or null");
|
|
176
|
+
const errors = validateSandboxPathShape(value);
|
|
177
|
+
if (errors.length > 0)
|
|
178
|
+
return invalid("filesystem.projectRoot", errors.join("; "));
|
|
179
|
+
return value;
|
|
180
|
+
}
|
|
181
|
+
function fileScope(value) {
|
|
182
|
+
const v = record(value, ["kind", "projectRoot", "writeRoots"], "filesystem");
|
|
183
|
+
if (v.kind === "device") {
|
|
184
|
+
record(value, ["kind"], "filesystem");
|
|
185
|
+
return Object.freeze({ kind: "device" });
|
|
186
|
+
}
|
|
187
|
+
if (v.kind !== "scoped")
|
|
188
|
+
return invalid("filesystem.kind", "expected scoped or device");
|
|
189
|
+
return Object.freeze({
|
|
190
|
+
kind: "scoped",
|
|
191
|
+
projectRoot: projectRoot(v.projectRoot),
|
|
192
|
+
writeRoots: roots(v.writeRoots, "filesystem.writeRoots"),
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
function networkScope(value) {
|
|
196
|
+
const v = record(value, ["kind", "hosts"], "network");
|
|
197
|
+
if (v.kind === "none" || v.kind === "open-public" || v.kind === "environment") {
|
|
198
|
+
record(value, ["kind"], "network");
|
|
199
|
+
return Object.freeze({ kind: v.kind });
|
|
200
|
+
}
|
|
201
|
+
if (v.kind !== "allowlist")
|
|
202
|
+
return invalid("network.kind", "expected none, allowlist, open-public or environment");
|
|
203
|
+
return Object.freeze({
|
|
204
|
+
kind: "allowlist",
|
|
205
|
+
hosts: strings(v.hosts, 100, validateAllowHost, "network.hosts"),
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
function actor(value) {
|
|
209
|
+
const v = record(value, ["accountId", "conversationId", "runId"], "actor");
|
|
210
|
+
return Object.freeze({
|
|
211
|
+
accountId: id(v.accountId, "actor.accountId"),
|
|
212
|
+
conversationId: id(v.conversationId, "actor.conversationId"),
|
|
213
|
+
...(Object.hasOwn(v, "runId") ? { runId: id(v.runId, "actor.runId") } : {}),
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
function operationRef(v) {
|
|
217
|
+
return {
|
|
218
|
+
operationId: id(v.operationId, "operationId"),
|
|
219
|
+
admitBeforeMs: integer(v.admitBeforeMs, 1, "admitBeforeMs"),
|
|
220
|
+
};
|
|
221
|
+
}
|
|
222
|
+
/** Pure structural validation and a frozen copy; no clock lookup or authority resolution. */
|
|
223
|
+
export function parseSandboxOperationRef(value) {
|
|
224
|
+
return Object.freeze(operationRef(record(value, ["operationId", "admitBeforeMs"], "operation reference")));
|
|
225
|
+
}
|
|
226
|
+
/**
|
|
227
|
+
* Validates a scope and returns a deeply frozen copy, throwing SandboxScopeValidationError.
|
|
228
|
+
* IDs and ceiling revisions are bounded to 128 characters; roots to 64 paths of at most 4096 characters;
|
|
229
|
+
* hosts to 100 entries passing validateAllowHost. Empty grants stay empty, including deny-all.
|
|
230
|
+
* Performs no I/O, authority lookup or deadline refresh. Unknown fields are rejected at every level.
|
|
231
|
+
* The `environment` network and the `device` filesystem are accepted only together.
|
|
232
|
+
*/
|
|
233
|
+
export function parseSandboxOperationScope(value) {
|
|
234
|
+
const v = record(value, [
|
|
235
|
+
"operationId",
|
|
236
|
+
"admitBeforeMs",
|
|
237
|
+
"deviceId",
|
|
238
|
+
"rootConversationId",
|
|
239
|
+
"profileRevision",
|
|
240
|
+
"ceilingRevision",
|
|
241
|
+
"profile",
|
|
242
|
+
"actor",
|
|
243
|
+
"tag",
|
|
244
|
+
"filesystem",
|
|
245
|
+
"network",
|
|
246
|
+
], "operation scope");
|
|
247
|
+
if (!isPermissionProfile(v.profile))
|
|
248
|
+
return invalid("profile", "expected request-approval, approve-for-me or full-access");
|
|
249
|
+
const filesystem = fileScope(v.filesystem);
|
|
250
|
+
const network = networkScope(v.network);
|
|
251
|
+
// The device filesystem and the environment network are the two halves of the escalated call:
|
|
252
|
+
// neither ever pairs with a sandboxed counterpart.
|
|
253
|
+
if (network.kind === "environment" && filesystem.kind !== "device")
|
|
254
|
+
return invalid("network.kind: environment requires the device filesystem", "a scoped filesystem takes none, allowlist or open-public");
|
|
255
|
+
if (filesystem.kind === "device" && network.kind !== "environment")
|
|
256
|
+
return invalid("filesystem.kind: device requires the environment network", "the device filesystem is only the escalated call's");
|
|
257
|
+
return Object.freeze({
|
|
258
|
+
...operationRef(v),
|
|
259
|
+
deviceId: id(v.deviceId, "deviceId"),
|
|
260
|
+
rootConversationId: id(v.rootConversationId, "rootConversationId"),
|
|
261
|
+
profileRevision: integer(v.profileRevision, 0, "profileRevision"),
|
|
262
|
+
ceilingRevision: id(v.ceilingRevision, "ceilingRevision"),
|
|
263
|
+
profile: v.profile,
|
|
264
|
+
actor: actor(v.actor),
|
|
265
|
+
tag: tag(v.tag),
|
|
266
|
+
filesystem,
|
|
267
|
+
network,
|
|
268
|
+
});
|
|
269
|
+
}
|
|
270
|
+
/** Validates an owner browsing grant and returns a deeply frozen copy; no conversation is required. */
|
|
271
|
+
export function parseSandboxBrowseScope(value) {
|
|
272
|
+
const v = record(value, [
|
|
273
|
+
"operationId",
|
|
274
|
+
"admitBeforeMs",
|
|
275
|
+
"deviceId",
|
|
276
|
+
"accountId",
|
|
277
|
+
"ceilingRevision",
|
|
278
|
+
"readRoots",
|
|
279
|
+
"tag",
|
|
280
|
+
], "browse scope");
|
|
281
|
+
return Object.freeze({
|
|
282
|
+
...operationRef(v),
|
|
283
|
+
deviceId: id(v.deviceId, "deviceId"),
|
|
284
|
+
accountId: id(v.accountId, "accountId"),
|
|
285
|
+
ceilingRevision: id(v.ceilingRevision, "ceilingRevision"),
|
|
286
|
+
readRoots: roots(v.readRoots, "readRoots"),
|
|
287
|
+
tag: tag(v.tag),
|
|
288
|
+
});
|
|
289
|
+
}
|
|
290
|
+
/** Validates trusted staging structure and returns a deeply frozen copy; does not authorize its roots. */
|
|
291
|
+
export function parseSandboxPreparationScope(value) {
|
|
292
|
+
const v = record(value, ["operationId", "deviceId", "purpose", "writeRoots", "tag"], "preparation scope");
|
|
293
|
+
if (v.purpose !== "skills" && v.purpose !== "attachments")
|
|
294
|
+
return invalid("purpose", "expected skills or attachments");
|
|
295
|
+
return Object.freeze({
|
|
296
|
+
operationId: id(v.operationId, "operationId"),
|
|
297
|
+
deviceId: id(v.deviceId, "deviceId"),
|
|
298
|
+
purpose: v.purpose,
|
|
299
|
+
writeRoots: roots(v.writeRoots, "writeRoots"),
|
|
300
|
+
tag: tag(v.tag),
|
|
301
|
+
});
|
|
302
|
+
}
|
|
303
|
+
/** Validates all four bounded locator fields and returns a frozen copy; does not authenticate the caller. */
|
|
304
|
+
export function parseSandboxExecutionRef(value) {
|
|
305
|
+
const v = record(value, ["executionId", "operationId", "instanceId", "instanceGeneration"], "execution reference");
|
|
306
|
+
return Object.freeze({
|
|
307
|
+
executionId: id(v.executionId, "executionId"),
|
|
308
|
+
operationId: id(v.operationId, "operationId"),
|
|
309
|
+
instanceId: id(v.instanceId, "instanceId"),
|
|
310
|
+
instanceGeneration: id(v.instanceGeneration, "instanceGeneration"),
|
|
311
|
+
});
|
|
312
|
+
}
|