@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
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import type { SandboxMachineClass } from "@claxedo/sandbox-contract";
|
|
2
|
+
import { type SandboxStartLimit, type SandboxStartWindow } from "../lease-failure";
|
|
3
|
+
export type BoatSandboxState = "init" | "provisioning" | "provisioned" | "cloning" | "ready" | "idle" | "running" | "archiving" | "archived" | "error" | "cancelled";
|
|
4
|
+
/** `hydrated`: Boat has downloaded every file of the snapshot the sandbox started from (docs.boat.dev/readiness). */
|
|
5
|
+
export type BoatSandbox = {
|
|
6
|
+
id: string;
|
|
7
|
+
state: BoatSandboxState;
|
|
8
|
+
hydrated: boolean;
|
|
9
|
+
};
|
|
10
|
+
export type BoatCommandResult = {
|
|
11
|
+
success: boolean;
|
|
12
|
+
stdout: string;
|
|
13
|
+
stderr: string;
|
|
14
|
+
exitCode: number | null;
|
|
15
|
+
timedOut: boolean;
|
|
16
|
+
};
|
|
17
|
+
export type BoatFetch = (input: string, init?: RequestInit) => Promise<Response>;
|
|
18
|
+
/**
|
|
19
|
+
* What Boat's 429 `rate_limited` says about the account's start limit: the
|
|
20
|
+
* window that is used up, its limit, and the starts used of each window. It
|
|
21
|
+
* names no time the window reopens (2026-10-15), so none is kept.
|
|
22
|
+
*/
|
|
23
|
+
export type BoatStartLimit = {
|
|
24
|
+
window: SandboxStartWindow;
|
|
25
|
+
limit: number;
|
|
26
|
+
starts: Partial<Record<SandboxStartWindow, {
|
|
27
|
+
limit: number;
|
|
28
|
+
used: number;
|
|
29
|
+
}>>;
|
|
30
|
+
};
|
|
31
|
+
export declare class BoatApiError extends Error {
|
|
32
|
+
readonly code: string;
|
|
33
|
+
readonly status?: number | undefined;
|
|
34
|
+
/** Boat answers 401 or 403 to the API key itself, never to a sandbox it was asked about. */
|
|
35
|
+
readonly providerKeyRefused: boolean;
|
|
36
|
+
/** Create, fork and resume each count as one start (Boat's own refusal, 2026-10-15). */
|
|
37
|
+
readonly providerRateLimited?: SandboxStartLimit;
|
|
38
|
+
readonly startLimit?: BoatStartLimit;
|
|
39
|
+
/** The state Boat's refusal gives the sandbox it refused, e.g. `archived` on a 400 `stop_failed` (2026-10-17). */
|
|
40
|
+
readonly sandboxState?: BoatSandboxState;
|
|
41
|
+
constructor(message: string, code: string, status?: number | undefined, refusal?: {
|
|
42
|
+
startLimit?: BoatStartLimit;
|
|
43
|
+
sandboxState?: BoatSandboxState;
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
export declare function invalid(): never;
|
|
47
|
+
export declare function requiredText(value: unknown): string;
|
|
48
|
+
export type BoatClientOptions = {
|
|
49
|
+
apiKey: string;
|
|
50
|
+
baseUrl?: string;
|
|
51
|
+
timeoutMs?: number;
|
|
52
|
+
fetchImpl?: BoatFetch;
|
|
53
|
+
};
|
|
54
|
+
export type BoatApi = ReturnType<typeof createBoatApi>;
|
|
55
|
+
/** One Boat v1 call: the bearer key, the deadline, the bounded envelope, and the envelope types the call accepts. */
|
|
56
|
+
export declare function createBoatApi(options: BoatClientOptions): (path: string, types: readonly string[], init?: {
|
|
57
|
+
method?: string;
|
|
58
|
+
body?: unknown;
|
|
59
|
+
headers?: Record<string, string>;
|
|
60
|
+
timeoutMs?: number;
|
|
61
|
+
}) => Promise<Record<string, unknown>>;
|
|
62
|
+
export declare function createBoatClient(options: BoatClientOptions): {
|
|
63
|
+
/** `from` is a named snapshot or a share code (`bsh_…`) the sandbox starts from; omitted, Boat's base machine. */
|
|
64
|
+
create(input: {
|
|
65
|
+
idempotencyKey: string;
|
|
66
|
+
ttlSeconds: number | null;
|
|
67
|
+
type?: SandboxMachineClass;
|
|
68
|
+
from?: string;
|
|
69
|
+
}): Promise<BoatSandbox>;
|
|
70
|
+
get(id: string): Promise<BoatSandbox>;
|
|
71
|
+
/** `type` resumes the sandbox onto that machine size; omitted, it keeps the size it has (docs.boat.dev/machines/change-size). */
|
|
72
|
+
resume(id: string, input: {
|
|
73
|
+
ttlSeconds: number | null;
|
|
74
|
+
type?: SandboxMachineClass;
|
|
75
|
+
}): Promise<void>;
|
|
76
|
+
/**
|
|
77
|
+
* `ttlSeconds` sets the auto-stop deadline to now plus that many seconds; `null` removes it.
|
|
78
|
+
* Boat's reference example answers `sandbox.info`; the API answers `sandbox.updated` (2026-10-13).
|
|
79
|
+
*/
|
|
80
|
+
update(id: string, input: {
|
|
81
|
+
ttlSeconds: number | null;
|
|
82
|
+
}): Promise<BoatSandbox>;
|
|
83
|
+
stop(id: string): Promise<void>;
|
|
84
|
+
delete(id: string): Promise<void>;
|
|
85
|
+
writeFile(id: string, input: {
|
|
86
|
+
path: string;
|
|
87
|
+
content: string;
|
|
88
|
+
}): Promise<void>;
|
|
89
|
+
/** `ready` once a command runs, which Boat answers the moment the sandbox is ready; `starting` when Boat's hold ended first. */
|
|
90
|
+
whenReady(id: string): Promise<"ready" | "starting">;
|
|
91
|
+
command(id: string, input: {
|
|
92
|
+
command: string;
|
|
93
|
+
timeoutSeconds?: number;
|
|
94
|
+
}): Promise<BoatCommandResult>;
|
|
95
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { type BoatClientOptions } from "./boat-client";
|
|
2
|
+
export type BoatNamedSnapshotStatus = "saving" | "ready" | "failed";
|
|
3
|
+
export type BoatNamedSnapshot = {
|
|
4
|
+
name: string;
|
|
5
|
+
status: BoatNamedSnapshotStatus;
|
|
6
|
+
createdAt: string;
|
|
7
|
+
};
|
|
8
|
+
export type BoatSnapshotShare = {
|
|
9
|
+
id: string;
|
|
10
|
+
status: "active" | "revoked";
|
|
11
|
+
createdAt: string;
|
|
12
|
+
};
|
|
13
|
+
/** Boat's named snapshots and their share codes (docs.boat.dev/snapshots/templates). */
|
|
14
|
+
export declare function createBoatNamedSnapshotClient(options: BoatClientOptions): {
|
|
15
|
+
/** A stopped sandbox is saved from its last snapshot; the save settles in the background. */
|
|
16
|
+
save(input: {
|
|
17
|
+
sandboxId: string;
|
|
18
|
+
name: string;
|
|
19
|
+
}): Promise<BoatNamedSnapshot>;
|
|
20
|
+
get(name: string): Promise<BoatNamedSnapshot | undefined>;
|
|
21
|
+
/** Newest first. */
|
|
22
|
+
list(): Promise<BoatNamedSnapshot[]>;
|
|
23
|
+
delete(name: string): Promise<void>;
|
|
24
|
+
/** Boat shows the code only in this answer and keeps a hash of it. */
|
|
25
|
+
share(name: string): Promise<{
|
|
26
|
+
shareCode: string;
|
|
27
|
+
share: BoatSnapshotShare;
|
|
28
|
+
}>;
|
|
29
|
+
shares(name: string): Promise<BoatSnapshotShare[]>;
|
|
30
|
+
revokeShare(name: string, shareId: string): Promise<void>;
|
|
31
|
+
};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { type BoatRuntimeTemplate, type BoatSandboxDriverOptions } from "./boat";
|
|
2
|
+
import { type BoatClientOptions } from "./boat-client";
|
|
3
|
+
export type BoatRuntimeTemplateOptions = BoatClientOptions & {
|
|
4
|
+
image: string;
|
|
5
|
+
/** Template names start with it, and pruning removes only names that do. */
|
|
6
|
+
prefix?: string;
|
|
7
|
+
/** How many templates of the prefix pruning keeps, the image's own and the newest others. */
|
|
8
|
+
keep?: number;
|
|
9
|
+
log?: (line: string) => void;
|
|
10
|
+
pollIntervalMs?: number;
|
|
11
|
+
hydrationTimeoutMs?: number;
|
|
12
|
+
stopTimeoutMs?: number;
|
|
13
|
+
saveTimeoutMs?: number;
|
|
14
|
+
driver?: Pick<BoatSandboxDriverOptions, "statePollMs" | "provisionTimeoutMs" | "healthIntervalMs" | "healthTimeoutMs">;
|
|
15
|
+
};
|
|
16
|
+
/** The image reference is content-addressed (its tag names the build), and the seeded trees are named by it, so it keys the template. */
|
|
17
|
+
export declare function boatRuntimeTemplateName(image: string, prefix?: string): Promise<string>;
|
|
18
|
+
/**
|
|
19
|
+
* Saves the template once per image: a ready template is reused, one still
|
|
20
|
+
* saving is waited for, and a missing or failed one is built on a builder
|
|
21
|
+
* sandbox that is deleted whatever the outcome.
|
|
22
|
+
*/
|
|
23
|
+
export declare function ensureBoatRuntimeTemplate(options: BoatRuntimeTemplateOptions): Promise<{
|
|
24
|
+
name: string;
|
|
25
|
+
built: boolean;
|
|
26
|
+
}>;
|
|
27
|
+
/**
|
|
28
|
+
* A new share code for the image's template, revoking none: until the deploy
|
|
29
|
+
* that carries it has succeeded, the running Worker creates with the code it
|
|
30
|
+
* holds. `shareId` names the code without being the secret.
|
|
31
|
+
*/
|
|
32
|
+
export declare function shareBoatRuntimeTemplate(options: BoatRuntimeTemplateOptions): Promise<{
|
|
33
|
+
template: BoatRuntimeTemplate;
|
|
34
|
+
shareId: string;
|
|
35
|
+
}>;
|
|
36
|
+
/**
|
|
37
|
+
* Run once the deploy carrying `deployedShareId` succeeded: every other code of
|
|
38
|
+
* the deployed image's template is revoked, those of earlier deploys and of
|
|
39
|
+
* deploys that failed alike.
|
|
40
|
+
*/
|
|
41
|
+
export declare function revokeBoatRuntimeTemplateShares(options: BoatRuntimeTemplateOptions, deployedShareId: string): Promise<string[]>;
|
|
42
|
+
/**
|
|
43
|
+
* Run once the deploy of `options.image` succeeded, so the template it keeps
|
|
44
|
+
* is the one the live Worker creates from. Each template past Boat's ten free
|
|
45
|
+
* named snapshots costs $1.70 a month, and a template serves only the image it
|
|
46
|
+
* was built for, so templates of the prefix beyond the newest `keep` (the
|
|
47
|
+
* deployed image's among them) are removed; Boat removes their codes with them.
|
|
48
|
+
*/
|
|
49
|
+
export declare function pruneBoatRuntimeTemplates(options: BoatRuntimeTemplateOptions): Promise<string[]>;
|