@claxedo/sandbox-manager 0.7.0 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +245 -42
- package/dist/checkpoint-manager.d.ts +29 -4
- package/dist/checkpoint-manager.mjs +133 -24
- package/dist/command.d.ts +9 -2
- package/dist/command.mjs +8 -8
- package/dist/contract.d.ts +687 -0
- package/dist/driver-billing.d.ts +29 -0
- package/dist/driver-catalog.d.ts +43 -58
- package/dist/driver-catalog.mjs +192 -229
- package/dist/drivers/boat-client.d.ts +95 -0
- package/dist/drivers/boat-named-snapshots.d.ts +31 -0
- package/dist/drivers/boat-template.d.ts +49 -0
- package/dist/drivers/boat-template.mjs +1196 -0
- package/dist/drivers/boat.d.ts +64 -0
- package/dist/drivers/boat.mjs +990 -0
- package/dist/drivers/cloudflare.d.ts +5 -8
- package/dist/drivers/cloudflare.mjs +364 -213
- package/dist/drivers/docker.d.ts +4 -3
- package/dist/drivers/docker.mjs +244 -165
- package/dist/drivers/local-brokering.d.ts +14 -0
- package/dist/drivers/local-brokering.mjs +1029 -0
- package/dist/drivers/modal.d.ts +4 -7
- package/dist/drivers/modal.mjs +220 -155
- package/dist/drivers/transient-error.d.ts +13 -0
- package/dist/drivers/vercel.d.ts +21 -23
- package/dist/drivers/vercel.mjs +279 -169
- package/dist/egress-policy.d.ts +134 -0
- package/dist/egress-warnings.d.ts +22 -0
- package/dist/garbage-collect.d.ts +14 -0
- package/dist/hosted-network-policy.d.ts +11 -4
- package/dist/hosted-network-policy.mjs +221 -4
- package/dist/image-name.d.ts +12 -2
- package/dist/image-name.mjs +43 -0
- package/dist/image.d.ts +1 -20
- package/dist/image.mjs +11 -66
- package/dist/index.d.ts +8 -533
- package/dist/index.mjs +1420 -315
- package/dist/json.d.ts +13 -0
- package/dist/lease-failure.d.ts +173 -0
- package/dist/lease-lifecycle.d.ts +65 -0
- package/dist/lease-retry-wait.d.ts +8 -0
- package/dist/lease-start.d.ts +21 -0
- package/dist/lease-types.d.ts +15 -5
- package/dist/manager.d.ts +2 -0
- package/dist/runtime-env.d.ts +15 -2
- package/dist/runtime-env.mjs +50 -1
- package/dist/runtime-snapshot.d.ts +49 -0
- package/dist/runtime-version.d.ts +9 -0
- package/dist/runtime-version.mjs +2 -0
- package/dist/service-url-exposure.d.ts +1 -3
- package/dist/service-url-exposure.mjs +1 -26
- package/dist/start-fresh.d.ts +17 -0
- package/dist/start-telemetry.d.ts +37 -0
- package/dist/stores/memory.d.ts +1 -1
- package/dist/stores/memory.mjs +65 -54
- package/package.json +67 -81
- package/dist/daytona-allow-list.d.ts +0 -16
- package/dist/daytona-allow-list.mjs +0 -11
- package/dist/drivers/box.d.ts +0 -52
- package/dist/drivers/box.mjs +0 -499
- package/dist/drivers/cloudflare-egress.d.ts +0 -40
- package/dist/drivers/cloudflare-egress.mjs +0 -113
- package/dist/drivers/daytona.d.ts +0 -127
- package/dist/drivers/daytona.mjs +0 -541
- package/dist/drivers/exe.d.ts +0 -26
- package/dist/drivers/exe.mjs +0 -469
- package/dist/drivers/fetch-bridge.d.ts +0 -10
- package/dist/drivers/fetch-bridge.mjs +0 -111
- package/dist/lease-policy.d.ts +0 -48
- package/dist/lease-policy.mjs +0 -280
package/dist/index.d.ts
CHANGED
|
@@ -1,535 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
export
|
|
1
|
+
export * from "./contract";
|
|
2
|
+
export * from "./egress-policy";
|
|
3
|
+
export * from "./driver-billing";
|
|
4
|
+
export * from "./lease-failure";
|
|
5
|
+
export * from "./lease-retry-wait";
|
|
5
6
|
export * from "./checkpoint-manager";
|
|
6
7
|
export * from "./hosted-network-policy";
|
|
7
|
-
export
|
|
8
|
-
export
|
|
9
|
-
export type
|
|
10
|
-
export type SandboxCaptureSourceBehavior = "not-applicable" | "preserved" | "stopped" | "deleted";
|
|
11
|
-
export type SandboxRestoreMountBehavior = "not-applicable" | "same-resource" | "copy-on-write" | "new-resource";
|
|
12
|
-
export type SandboxPersistenceCapabilities = {
|
|
13
|
-
resume: "same-sandbox" | "replacement-restore";
|
|
14
|
-
capture: SandboxCaptureScope;
|
|
15
|
-
clone: boolean;
|
|
16
|
-
captureSource: SandboxCaptureSourceBehavior;
|
|
17
|
-
retention: "not-applicable" | "provider-managed" | "explicit";
|
|
18
|
-
restoreMount: SandboxRestoreMountBehavior;
|
|
19
|
-
};
|
|
20
|
-
export declare function validateSandboxPersistenceCapabilities(input: SandboxPersistenceCapabilities): {
|
|
21
|
-
valid: false;
|
|
22
|
-
reason: string;
|
|
23
|
-
} | {
|
|
24
|
-
reason?: undefined;
|
|
25
|
-
valid: true;
|
|
26
|
-
};
|
|
27
|
-
export type SandboxCheckpointReference = {
|
|
28
|
-
id: string;
|
|
29
|
-
providerReference: string;
|
|
30
|
-
sourceEpoch: number;
|
|
31
|
-
capturedAt: number;
|
|
32
|
-
metadata: {
|
|
33
|
-
scope: Exclude<SandboxCaptureScope, "none">;
|
|
34
|
-
sourceBehavior: Exclude<SandboxCaptureSourceBehavior, "not-applicable">;
|
|
35
|
-
retentionExpiresAt?: number;
|
|
36
|
-
restoreMount: Exclude<SandboxRestoreMountBehavior, "not-applicable">;
|
|
37
|
-
};
|
|
38
|
-
};
|
|
39
|
-
type SandboxRestoreIdentity = {
|
|
40
|
-
checkpointId: string;
|
|
41
|
-
sourceEpoch: number;
|
|
42
|
-
};
|
|
43
|
-
export type SandboxRestoreStatus = (SandboxRestoreIdentity & {
|
|
44
|
-
state: "pending";
|
|
45
|
-
requestedAt: number;
|
|
46
|
-
}) | (SandboxRestoreIdentity & {
|
|
47
|
-
state: "restoring";
|
|
48
|
-
requestedAt: number;
|
|
49
|
-
startedAt: number;
|
|
50
|
-
}) | (SandboxRestoreIdentity & {
|
|
51
|
-
state: "ready";
|
|
52
|
-
requestedAt: number;
|
|
53
|
-
startedAt: number;
|
|
54
|
-
completedAt: number;
|
|
55
|
-
}) | (SandboxRestoreIdentity & {
|
|
56
|
-
state: "failed";
|
|
57
|
-
requestedAt: number;
|
|
58
|
-
startedAt?: number;
|
|
59
|
-
failedAt: number;
|
|
60
|
-
error: string;
|
|
61
|
-
});
|
|
62
|
-
export type SandboxDriverMetadata = {
|
|
63
|
-
/** Where the sandbox driver code can execute. This is not sandbox infrastructure. */
|
|
64
|
-
driverRunsIn: Array<"worker" | "node" | "local">;
|
|
65
|
-
/** What `SandboxManager.stop()` actually does to the driver-owned resource. */
|
|
66
|
-
hostStopBehavior: "not-supported" | "suspends-host" | "terminates-host";
|
|
67
|
-
/** Whether a stopped/stale lease can resume the same driver-owned resource. */
|
|
68
|
-
hostResumeBehavior: "same-host" | "replacement-host";
|
|
69
|
-
/** How the control plane reaches the sandbox target returned by the driver. */
|
|
70
|
-
targetAccess: "relay" | "loopback";
|
|
71
|
-
/**
|
|
72
|
-
* How the driver can honor a `SandboxBrokeredSecret` — a credential the
|
|
73
|
-
* sandbox may USE for outbound requests but must NEVER be able to READ.
|
|
74
|
-
*
|
|
75
|
-
* - `"native"` — the provider brokers it automatically on egress to the
|
|
76
|
-
* allowlisted hosts, with no extra infrastructure: Daytona secret
|
|
77
|
-
* placeholders + egress proxy; Vercel firewall header transforms. The
|
|
78
|
-
* driver injects it during `ensureHost`.
|
|
79
|
-
* - `"proxy"` — brokering is achievable but only via a host-operated egress
|
|
80
|
-
* proxy the driver routes through (Cloudflare's official Worker-proxy
|
|
81
|
-
* pattern: the sandbox gets a short-lived JWT, egress hits the Worker,
|
|
82
|
-
* the Worker injects the real credential — the raw value never enters the
|
|
83
|
-
* sandbox). Not automatic; requires the host's proxy to be wired.
|
|
84
|
-
* - `"none"` — no way to keep the value out of sandbox processes. The
|
|
85
|
-
* provider may still have an encrypted secret STORE (e.g. Modal secrets),
|
|
86
|
-
* but those are exposed as readable env vars, so they cannot satisfy the
|
|
87
|
-
* never-readable contract.
|
|
88
|
-
*
|
|
89
|
-
* The manager fails closed unless the driver actually injects brokered
|
|
90
|
-
* secrets (today: `"native"` only). `"proxy"` records an achievable ceiling
|
|
91
|
-
* that is not yet wired and therefore also fails closed.
|
|
92
|
-
*/
|
|
93
|
-
secretBrokering: "native" | "proxy" | "none";
|
|
94
|
-
/**
|
|
95
|
-
* How the driver can enforce a RESTRICTED `SandboxNetworkPolicy` — i.e.
|
|
96
|
-
* whether the sandbox's outbound network can actually be contained.
|
|
97
|
-
*
|
|
98
|
-
* A `SandboxNetworkPolicy` states the same allowance in up to two encodings:
|
|
99
|
-
* `hosts` (names) and `cidrs` (addresses). A driver contains egress if it
|
|
100
|
-
* enforces AT LEAST ONE encoding the policy carries and blocks everything
|
|
101
|
-
* else; the encodings are alternatives, not additive requirements.
|
|
102
|
-
*
|
|
103
|
-
* - `"hosts-and-cidrs"` — the provider filters by name AND by address
|
|
104
|
-
* (Daytona: `domainAllowList` + `networkAllowList`).
|
|
105
|
-
* - `"hosts"` — the provider filters by hostname only (Vercel firewall).
|
|
106
|
-
* - `"none"` — the driver cannot express an egress allowlist. This covers
|
|
107
|
-
* BOTH drivers that throw when handed a restricted policy (exe, docker,
|
|
108
|
-
* box, and modal for host policy) AND — more dangerously — drivers that
|
|
109
|
-
* silently ignore `net` and run wide open (cloudflare, the fetch bridge).
|
|
110
|
-
* Modal is `"none"` even though it can cut the network entirely: a total
|
|
111
|
-
* blackout is not an allowlist and cannot serve a workspace that has to
|
|
112
|
-
* clone a repo and reach a model provider.
|
|
113
|
-
*
|
|
114
|
-
* The manager reads this to decide what the driver is handed:
|
|
115
|
-
* `sandboxEgressDisposition` enforces where it can and WITHHOLDS (loudly)
|
|
116
|
-
* where it cannot. See `SandboxEgressDisposition` for the posture and
|
|
117
|
-
* `public-docs/sandbox-egress.md` for the operator-facing consequence.
|
|
118
|
-
*/
|
|
119
|
-
egressControl: SandboxEgressControl;
|
|
120
|
-
persistence: SandboxPersistenceCapabilities;
|
|
121
|
-
};
|
|
122
|
-
/** @see SandboxDriverMetadata.egressControl */
|
|
123
|
-
export type SandboxEgressControl = "none" | "hosts" | "hosts-and-cidrs";
|
|
124
|
-
/**
|
|
125
|
-
* What the manager does with a caller's `net` for a given driver.
|
|
126
|
-
*
|
|
127
|
-
* Owner directive (2026-07-28): *"for egress in sandbox enforce where we can
|
|
128
|
-
* and document where we cant."* That replaces the previous fail-closed refusal
|
|
129
|
-
* for drivers with no egress control at all — provisioning now proceeds, and
|
|
130
|
-
* the gap is made loud instead of fatal.
|
|
131
|
-
*
|
|
132
|
-
* - `"enforce"` — the driver gets the policy verbatim and contains the
|
|
133
|
-
* sandbox. Also the answer when the caller asked for no containment
|
|
134
|
-
* (absent / `allow-all`), which is nothing to enforce.
|
|
135
|
-
* - `"withhold"` — the driver declares `egressControl: "none"`, so there is no
|
|
136
|
-
* containment to be had. The policy is NOT handed down: half the `"none"`
|
|
137
|
-
* drivers throw on a restricted policy (exe, docker, modal, box) and the
|
|
138
|
-
* other half silently drop it (cloudflare, the fetch bridge). Withholding at
|
|
139
|
-
* the manager means the throwing drivers never see one — their throws stay
|
|
140
|
-
* in place as their own last line of defence — and the silently-dropping
|
|
141
|
-
* ones stop pretending. The sandbox comes up with UNRESTRICTED egress, which
|
|
142
|
-
* is a real exposure, so the manager warns (see `onEgressUnenforced`).
|
|
143
|
-
* - `"refuse"` — the driver HAS egress control but cannot express this
|
|
144
|
-
* particular policy's encoding (a hosts-only driver handed an address-only
|
|
145
|
-
* allowlist). Deliberately still fail-closed: this is a composition mistake
|
|
146
|
-
* on an otherwise-enforcing driver, and degrading it to "withhold" would
|
|
147
|
-
* weaken the enforcing path. `hostedSandboxNetworkPolicy` only ever emits
|
|
148
|
-
* hosts, so no production path reaches it.
|
|
149
|
-
*
|
|
150
|
-
* Pure, like `validateSandboxPersistenceCapabilities`, so the manager, the
|
|
151
|
-
* composition layer, and tests can all ask the same question.
|
|
152
|
-
*/
|
|
153
|
-
export type SandboxEgressDisposition = {
|
|
154
|
-
action: "enforce";
|
|
155
|
-
} | {
|
|
156
|
-
action: "withhold";
|
|
157
|
-
reason: "sandbox_egress_uncontained";
|
|
158
|
-
} | {
|
|
159
|
-
action: "refuse";
|
|
160
|
-
reason: "sandbox_egress_policy_unenforceable";
|
|
161
|
-
};
|
|
162
|
-
/** @see SandboxEgressDisposition */
|
|
163
|
-
export declare function sandboxEgressDisposition(control: SandboxEgressControl, net: SandboxNetworkPolicy | undefined): SandboxEgressDisposition;
|
|
164
|
-
/**
|
|
165
|
-
* Emitted whenever a restricted egress policy is withheld because the composed
|
|
166
|
-
* driver declares no egress control. This is the "document where we can't" half
|
|
167
|
-
* of the directive expressed at runtime: an unrestricted sandbox that nobody
|
|
168
|
-
* was told about is the original finding, so the degrade is never silent.
|
|
169
|
-
*
|
|
170
|
-
* Two phases, because a per-create line is easy to miss in request logs:
|
|
171
|
-
* - `"composition"` — once per `createSandboxManager` per driver, at boot.
|
|
172
|
-
* - `"ensure"` — every time a caller's policy is actually withheld, naming the
|
|
173
|
-
* workspace and the allowlist that did not take effect.
|
|
174
|
-
*/
|
|
175
|
-
export type SandboxEgressUnenforcedEvent = {
|
|
176
|
-
phase: "composition" | "ensure";
|
|
177
|
-
reason: "sandbox_egress_uncontained";
|
|
178
|
-
/** `SandboxDriver.id` of the composed driver. */
|
|
179
|
-
driver: string;
|
|
180
|
-
/** Always `"none"` today — carried so a sink can group without re-deriving. */
|
|
181
|
-
egressControl: SandboxEgressControl;
|
|
182
|
-
/** Ready-to-log sentence. Sinks that only forward text can use this alone. */
|
|
183
|
-
message: string;
|
|
184
|
-
/** Present on `"ensure"`. */
|
|
185
|
-
workspaceId?: string;
|
|
186
|
-
/** The allowlist the caller asked for and did NOT get. Present on `"ensure"`. */
|
|
187
|
-
requested?: SandboxNetworkPolicy;
|
|
188
|
-
};
|
|
189
|
-
/**
|
|
190
|
-
* A credential the SANDBOX must be able to USE for outbound requests but must
|
|
191
|
-
* NEVER be able to READ. Unlike `env` (plaintext, readable — reserved for
|
|
192
|
-
* credentials the agent is trusted with, e.g. the user's own model
|
|
193
|
-
* subscription), a brokered secret's `value` never enters the sandbox: the
|
|
194
|
-
* provider injects it on egress to `hosts` only. Non-model credentials
|
|
195
|
-
* (connection tokens, deploy tokens) belong here.
|
|
196
|
-
*
|
|
197
|
-
* Guarantees enforced by the manager: brokered secrets are never written to
|
|
198
|
-
* labels, never logged, and never captured in a driver snapshot. A driver
|
|
199
|
-
* whose `metadata.secretBrokering !== "native"` cannot honor them and the
|
|
200
|
-
* manager refuses to provision (fail-closed).
|
|
201
|
-
*/
|
|
202
|
-
export type SandboxBrokeredSecret = {
|
|
203
|
-
/** Env var name the sandbox references (Daytona placeholder key). */
|
|
204
|
-
name: string;
|
|
205
|
-
/** The secret material. Never enters the sandbox in plaintext. */
|
|
206
|
-
value: string;
|
|
207
|
-
/** Egress allowlist: the only hosts for which the value is substituted/injected. */
|
|
208
|
-
hosts: string[];
|
|
209
|
-
/**
|
|
210
|
-
* When set, the value is injected as this HTTP header on egress to `hosts`
|
|
211
|
-
* (required for the Vercel firewall-transform model). When omitted, the
|
|
212
|
-
* driver exposes the credential via its native placeholder mechanism for
|
|
213
|
-
* the sandbox to attach itself (Daytona).
|
|
214
|
-
*/
|
|
215
|
-
header?: string;
|
|
216
|
-
};
|
|
217
|
-
export type SandboxExposure = {
|
|
218
|
-
kind: "loopback";
|
|
219
|
-
} | {
|
|
220
|
-
kind: "relay";
|
|
221
|
-
} | {
|
|
222
|
-
kind: "private-network";
|
|
223
|
-
} | {
|
|
224
|
-
kind: "embedded";
|
|
225
|
-
};
|
|
226
|
-
export type SandboxLeaseStatus = "acquiring" | "ready" | "unavailable" | "stopped" | "destroyed";
|
|
227
|
-
export type SandboxLease = {
|
|
228
|
-
workspaceId: string;
|
|
229
|
-
homeRegion: SandboxRegion;
|
|
230
|
-
driver: string;
|
|
231
|
-
epoch: number;
|
|
232
|
-
status: SandboxLeaseStatus;
|
|
233
|
-
retryCount: number;
|
|
234
|
-
updatedAt: number;
|
|
235
|
-
createdAt: number;
|
|
236
|
-
sandboxId?: string;
|
|
237
|
-
url?: string;
|
|
238
|
-
hostId?: string;
|
|
239
|
-
driverResourceId?: string;
|
|
240
|
-
nextRetryAt?: number;
|
|
241
|
-
lastError?: string;
|
|
242
|
-
lastHeartbeatAt?: number;
|
|
243
|
-
lastActivityAt?: number;
|
|
244
|
-
labels?: Record<string, string>;
|
|
245
|
-
checkpoint?: SandboxCheckpointReference;
|
|
246
|
-
persistence?: SandboxPersistenceCapabilities;
|
|
247
|
-
restore?: SandboxRestoreStatus;
|
|
248
|
-
};
|
|
249
|
-
export type SandboxLeaseAcquireInput = {
|
|
250
|
-
homeRegion: SandboxRegion;
|
|
251
|
-
driver: string;
|
|
252
|
-
staleAfterMs: number;
|
|
253
|
-
now?: number;
|
|
254
|
-
};
|
|
255
|
-
export type SandboxLeaseAcquireResult = {
|
|
256
|
-
acquired: true;
|
|
257
|
-
lease: SandboxLease;
|
|
258
|
-
} | {
|
|
259
|
-
acquired: false;
|
|
260
|
-
lease: SandboxLease;
|
|
261
|
-
retryAfterMs: number;
|
|
262
|
-
};
|
|
263
|
-
export type SandboxLeasePatch = Partial<Pick<SandboxLease, "status" | "sandboxId" | "url" | "hostId" | "driverResourceId" | "retryCount" | "lastHeartbeatAt" | "lastActivityAt" | "labels">> & {
|
|
264
|
-
/** `null` clears the stored value; `undefined` leaves it unchanged. */
|
|
265
|
-
nextRetryAt?: number | null;
|
|
266
|
-
/** `null` clears the stored value; `undefined` leaves it unchanged. */
|
|
267
|
-
lastError?: string | null;
|
|
268
|
-
/** `null` clears the stored value; `undefined` leaves it unchanged. */
|
|
269
|
-
checkpoint?: SandboxCheckpointReference | null;
|
|
270
|
-
/** `null` clears the stored value; `undefined` leaves it unchanged. */
|
|
271
|
-
persistence?: SandboxPersistenceCapabilities | null;
|
|
272
|
-
/** `null` clears the stored value; `undefined` leaves it unchanged. */
|
|
273
|
-
restore?: SandboxRestoreStatus | null;
|
|
274
|
-
};
|
|
275
|
-
/**
|
|
276
|
-
* Canonical SandboxLeasePatch merge semantics shared by every lease store driver:
|
|
277
|
-
* absent/`undefined` keeps the current value, `null` clears it.
|
|
278
|
-
*/
|
|
279
|
-
export declare function applySandboxLeasePatch(current: SandboxLease, patch: SandboxLeasePatch, updatedAt: number): SandboxLease;
|
|
280
|
-
export type SandboxLeaseStore = {
|
|
281
|
-
acquire: (workspaceId: string, input: SandboxLeaseAcquireInput) => Promise<SandboxLeaseAcquireResult>;
|
|
282
|
-
update: (workspaceId: string, expectedEpoch: number, patch: SandboxLeasePatch) => Promise<SandboxLease | undefined>;
|
|
283
|
-
recordFailure: (workspaceId: string, expectedEpoch: number, error: string, nextRetryAt?: number) => Promise<SandboxLease | undefined>;
|
|
284
|
-
release: (workspaceId: string) => Promise<void>;
|
|
285
|
-
get: (workspaceId: string) => Promise<SandboxLease | undefined>;
|
|
286
|
-
list: () => Promise<SandboxLease[]>;
|
|
287
|
-
};
|
|
288
|
-
export type SandboxNetworkPolicy = {
|
|
289
|
-
mode: "allow-all" | "restricted";
|
|
290
|
-
hosts?: string[];
|
|
291
|
-
cidrs?: string[];
|
|
292
|
-
};
|
|
293
|
-
export type SandboxBootSource = {
|
|
294
|
-
kind: "image";
|
|
295
|
-
image: string;
|
|
296
|
-
} | {
|
|
297
|
-
kind: "driver-snapshot";
|
|
298
|
-
snapshotId: string;
|
|
299
|
-
} | {
|
|
300
|
-
kind: "default";
|
|
301
|
-
};
|
|
302
|
-
export type SandboxSource = {
|
|
303
|
-
kind: "git";
|
|
304
|
-
repoUrl: string;
|
|
305
|
-
branch?: string;
|
|
306
|
-
} | {
|
|
307
|
-
kind: "empty";
|
|
308
|
-
};
|
|
309
|
-
export type SandboxDriverEnsureInput = {
|
|
310
|
-
workspaceId: string;
|
|
311
|
-
hostId?: string;
|
|
312
|
-
homeRegion: SandboxRegion;
|
|
313
|
-
epoch: number;
|
|
314
|
-
labels: Record<string, string>;
|
|
315
|
-
bootSource?: SandboxBootSource;
|
|
316
|
-
workspaceRoot?: string;
|
|
317
|
-
runtimeCwd?: string;
|
|
318
|
-
workspaceRuntimePort?: number;
|
|
319
|
-
env?: Record<string, string>;
|
|
320
|
-
/** Brokered secrets: injected on egress, never readable inside the sandbox. */
|
|
321
|
-
secrets?: SandboxBrokeredSecret[];
|
|
322
|
-
source?: SandboxSource;
|
|
323
|
-
exposure?: SandboxExposure;
|
|
324
|
-
/**
|
|
325
|
-
* Egress policy. Omitted means allow-all, which is only appropriate for a
|
|
326
|
-
* single-tenant deployment the operator already trusts.
|
|
327
|
-
*
|
|
328
|
-
* A driver can rely on this being ABSENT whenever it declares
|
|
329
|
-
* `egressControl: "none"`: the manager withholds the policy rather than hand
|
|
330
|
-
* it to a driver that would either throw on it or silently drop it. A driver
|
|
331
|
-
* that receives a restricted policy here is one that declared it can enforce
|
|
332
|
-
* it. @see SandboxEgressDisposition
|
|
333
|
-
*/
|
|
334
|
-
net?: SandboxNetworkPolicy;
|
|
335
|
-
/** Optional snapshot/image to boot from (user-supplied or pre-built). */
|
|
336
|
-
snapshot?: string;
|
|
337
|
-
};
|
|
338
|
-
export type SandboxTarget = {
|
|
339
|
-
workspaceId?: string;
|
|
340
|
-
sandboxId: string;
|
|
341
|
-
url: string;
|
|
342
|
-
hostId: string;
|
|
343
|
-
driverResourceId?: string;
|
|
344
|
-
labels?: Record<string, string>;
|
|
345
|
-
driver?: {
|
|
346
|
-
id: string;
|
|
347
|
-
resourceId: string;
|
|
348
|
-
metadata?: Record<string, string>;
|
|
349
|
-
};
|
|
350
|
-
};
|
|
351
|
-
export type SandboxSnapshotResult = {
|
|
352
|
-
snapshotId: string;
|
|
353
|
-
};
|
|
354
|
-
export type SandboxCommandResult = {
|
|
355
|
-
stdout: string;
|
|
356
|
-
stderr: string;
|
|
357
|
-
exitCode: number;
|
|
358
|
-
};
|
|
359
|
-
export type SandboxDriver = {
|
|
360
|
-
id: string;
|
|
361
|
-
metadata: SandboxDriverMetadata;
|
|
362
|
-
ensureHost: (input: SandboxDriverEnsureInput) => Promise<SandboxTarget | {
|
|
363
|
-
provisioning: true;
|
|
364
|
-
retryAfterMs: number;
|
|
365
|
-
}>;
|
|
366
|
-
resumeHost?: (input: {
|
|
367
|
-
lease: SandboxLease;
|
|
368
|
-
ensure: SandboxDriverEnsureInput;
|
|
369
|
-
}) => Promise<SandboxTarget | {
|
|
370
|
-
provisioning: true;
|
|
371
|
-
retryAfterMs: number;
|
|
372
|
-
}>;
|
|
373
|
-
list?: () => Promise<SandboxTarget[]>;
|
|
374
|
-
touch?: (target: SandboxTarget) => Promise<void>;
|
|
375
|
-
suspend?: (target: SandboxTarget) => Promise<void>;
|
|
376
|
-
stop?: (target: SandboxTarget) => Promise<void>;
|
|
377
|
-
destroy?: (target: SandboxTarget) => Promise<void>;
|
|
378
|
-
snapshot?: (target: SandboxTarget) => Promise<SandboxSnapshotResult>;
|
|
379
|
-
inspect?: (target: SandboxTarget) => Promise<SandboxTarget | undefined>;
|
|
380
|
-
exec?: (target: SandboxTarget, command: string) => Promise<SandboxCommandResult>;
|
|
381
|
-
clone?: (target: SandboxTarget, input: {
|
|
382
|
-
name: string;
|
|
383
|
-
}) => Promise<SandboxTarget>;
|
|
384
|
-
};
|
|
385
|
-
export type SandboxManager = {
|
|
386
|
-
ensure: (workspaceId: string, input: SandboxManagerInput) => Promise<SandboxEnsureResult>;
|
|
387
|
-
register: (workspaceId: string, input: SandboxRegisterInput) => Promise<SandboxMutationResult>;
|
|
388
|
-
heartbeat: (workspaceId: string, input: SandboxHeartbeatInput) => Promise<SandboxMutationResult>;
|
|
389
|
-
target: (workspaceId: string) => Promise<SandboxTargetResult>;
|
|
390
|
-
touch: (workspaceId: string) => Promise<SandboxTouchResult>;
|
|
391
|
-
snapshot: (workspaceId: string) => Promise<SandboxSnapshotManagerResult>;
|
|
392
|
-
checkpoint: (workspaceId: string, input: SandboxCheckpointCaptureInput) => Promise<SandboxCheckpointResult>;
|
|
393
|
-
restore: (workspaceId: string, input: SandboxCheckpointRestoreInput) => Promise<SandboxCheckpointResult>;
|
|
394
|
-
stop: (workspaceId: string) => Promise<SandboxMutationResult>;
|
|
395
|
-
destroy: (workspaceId: string) => Promise<SandboxMutationResult>;
|
|
396
|
-
release: (workspaceId: string) => Promise<{
|
|
397
|
-
released: boolean;
|
|
398
|
-
}>;
|
|
399
|
-
garbageCollect: () => Promise<SandboxGarbageCollectResult>;
|
|
400
|
-
list: () => Promise<SandboxLease[]>;
|
|
401
|
-
};
|
|
402
|
-
export type SandboxManagerInput = {
|
|
403
|
-
homeRegion: SandboxRegion;
|
|
404
|
-
hostId?: string;
|
|
405
|
-
labels?: Record<string, string>;
|
|
406
|
-
bootSource?: SandboxBootSource;
|
|
407
|
-
workspaceRoot?: string;
|
|
408
|
-
runtimeCwd?: string;
|
|
409
|
-
workspaceRuntimePort?: number;
|
|
410
|
-
env?: Record<string, string>;
|
|
411
|
-
/** Brokered secrets: injected on egress, never readable inside the sandbox. */
|
|
412
|
-
secrets?: SandboxBrokeredSecret[];
|
|
413
|
-
source?: SandboxSource;
|
|
414
|
-
exposure?: SandboxExposure;
|
|
415
|
-
/**
|
|
416
|
-
* @see SandboxDriverEnsureInput.net — enforced by a capable driver, withheld
|
|
417
|
-
* (with a warning) by one that declares `egressControl: "none"`.
|
|
418
|
-
*/
|
|
419
|
-
net?: SandboxNetworkPolicy;
|
|
420
|
-
snapshot?: string;
|
|
421
|
-
};
|
|
422
|
-
export type SandboxRegisterInput = {
|
|
423
|
-
epoch?: number;
|
|
424
|
-
ok: boolean;
|
|
425
|
-
status?: string;
|
|
426
|
-
sandboxId?: string | null;
|
|
427
|
-
url?: string | null;
|
|
428
|
-
hostId?: string | null;
|
|
429
|
-
driverResourceId?: string | null;
|
|
430
|
-
active?: boolean;
|
|
431
|
-
now?: number;
|
|
432
|
-
};
|
|
433
|
-
export type SandboxHeartbeatInput = SandboxRegisterInput;
|
|
434
|
-
export type SandboxEnsureResult = ({
|
|
435
|
-
status: "ready";
|
|
436
|
-
} & SandboxTarget & {
|
|
437
|
-
epoch: number;
|
|
438
|
-
homeRegion: SandboxRegion;
|
|
439
|
-
}) | {
|
|
440
|
-
status: "provisioning";
|
|
441
|
-
retryAfterMs: number;
|
|
442
|
-
epoch: number;
|
|
443
|
-
homeRegion: SandboxRegion;
|
|
444
|
-
} | {
|
|
445
|
-
status: "unavailable";
|
|
446
|
-
retryAfterMs?: number;
|
|
447
|
-
error?: string;
|
|
448
|
-
epoch?: number;
|
|
449
|
-
homeRegion: SandboxRegion;
|
|
450
|
-
};
|
|
451
|
-
export type SandboxTargetResult = ({
|
|
452
|
-
status: "ready";
|
|
453
|
-
} & SandboxTarget & {
|
|
454
|
-
epoch: number;
|
|
455
|
-
homeRegion: SandboxRegion;
|
|
456
|
-
}) | {
|
|
457
|
-
status: "unavailable";
|
|
458
|
-
reason: string;
|
|
459
|
-
};
|
|
460
|
-
export type SandboxTouchResult = {
|
|
461
|
-
touched: boolean;
|
|
462
|
-
status: SandboxLeaseStatus | "missing";
|
|
463
|
-
};
|
|
464
|
-
export type SandboxMutationResult = {
|
|
465
|
-
ok: true;
|
|
466
|
-
status: SandboxLeaseStatus;
|
|
467
|
-
} | {
|
|
468
|
-
ok: false;
|
|
469
|
-
reason: string;
|
|
470
|
-
};
|
|
471
|
-
export type SandboxSnapshotManagerResult = ({
|
|
472
|
-
ok: true;
|
|
473
|
-
} & SandboxSnapshotResult) | {
|
|
474
|
-
ok: false;
|
|
475
|
-
reason: string;
|
|
476
|
-
};
|
|
477
|
-
export type SandboxGarbageCollectResult = {
|
|
478
|
-
destroyed: SandboxTarget[];
|
|
479
|
-
kept: SandboxTarget[];
|
|
480
|
-
skipped: Array<{
|
|
481
|
-
target: SandboxTarget;
|
|
482
|
-
reason: string;
|
|
483
|
-
}>;
|
|
484
|
-
failed: Array<{
|
|
485
|
-
target: SandboxTarget;
|
|
486
|
-
error: string;
|
|
487
|
-
}>;
|
|
488
|
-
/**
|
|
489
|
-
* Set when the driver cannot enumerate provider state, so the four arrays
|
|
490
|
-
* above mean "we could not look" rather than "nothing is orphaned". Absent on
|
|
491
|
-
* a real sweep. Callers must treat it as a FAILED sweep: four empty arrays
|
|
492
|
-
* reported as success is the exact defect finding B1 names.
|
|
493
|
-
*/
|
|
494
|
-
listingUnsupported?: true;
|
|
495
|
-
/** Driver id, so an ops report can name which driver could not look. */
|
|
496
|
-
driver?: string;
|
|
497
|
-
};
|
|
498
|
-
/**
|
|
499
|
-
* A driver's `list()` may throw this shape to say "my backing service cannot
|
|
500
|
-
* enumerate", as distinct from "listing failed this time". `garbageCollect()`
|
|
501
|
-
* converts it into `listingUnsupported` (a loud, non-fatal capability gap);
|
|
502
|
-
* every other error propagates as a real sweep failure.
|
|
503
|
-
*
|
|
504
|
-
* Structural rather than an `instanceof` check on purpose: drivers are published
|
|
505
|
-
* as separate entry points and bundlers duplicate class identities, so a
|
|
506
|
-
* nominal check would silently fall through to "transient failure" in exactly
|
|
507
|
-
* the deployment that needs the distinction.
|
|
508
|
-
*/
|
|
509
|
-
export type SandboxListingUnsupported = {
|
|
510
|
-
listingUnsupported: true;
|
|
511
|
-
};
|
|
512
|
-
export declare function isSandboxListingUnsupported(err: unknown): err is SandboxListingUnsupported;
|
|
513
|
-
export type SandboxManagerOptions = {
|
|
514
|
-
leaseStore: SandboxLeaseStore;
|
|
515
|
-
driver: SandboxDriver;
|
|
516
|
-
staleAfterMs?: number;
|
|
517
|
-
retryAfterMs?: number;
|
|
518
|
-
retryDelayMs?: (retryCount: number) => number;
|
|
519
|
-
maxRetryCount?: number;
|
|
520
|
-
retryCapCooldownMs?: number;
|
|
521
|
-
now?: () => number;
|
|
522
|
-
appLabel?: string;
|
|
523
|
-
/**
|
|
524
|
-
* Sink for the loud half of "enforce where we can, document where we can't".
|
|
525
|
-
* Called at composition time and again every time a restricted policy is
|
|
526
|
-
* withheld from a driver that cannot enforce it.
|
|
527
|
-
*
|
|
528
|
-
* Defaults to `console.warn(event.message)`. Pass your own to route the gap
|
|
529
|
-
* into a telemetry pipeline instead — but note the default is deliberately
|
|
530
|
-
* unconditional: an operator who never wires a sink still gets the warning.
|
|
531
|
-
* Pass `() => {}` only if you have another way to surface it.
|
|
532
|
-
*/
|
|
533
|
-
onEgressUnenforced?: (event: SandboxEgressUnenforcedEvent) => void;
|
|
534
|
-
};
|
|
535
|
-
export declare function createSandboxManager(options: SandboxManagerOptions): SandboxManager;
|
|
8
|
+
export * from "./runtime-snapshot";
|
|
9
|
+
export { createSandboxManager } from "./manager";
|
|
10
|
+
export type { SandboxLifecycleEvent, SandboxStopCause } from "./lease-lifecycle";
|