@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.
Files changed (70) hide show
  1. package/README.md +245 -42
  2. package/dist/checkpoint-manager.d.ts +29 -4
  3. package/dist/checkpoint-manager.mjs +133 -24
  4. package/dist/command.d.ts +9 -2
  5. package/dist/command.mjs +8 -8
  6. package/dist/contract.d.ts +687 -0
  7. package/dist/driver-billing.d.ts +29 -0
  8. package/dist/driver-catalog.d.ts +43 -58
  9. package/dist/driver-catalog.mjs +192 -229
  10. package/dist/drivers/boat-client.d.ts +95 -0
  11. package/dist/drivers/boat-named-snapshots.d.ts +31 -0
  12. package/dist/drivers/boat-template.d.ts +49 -0
  13. package/dist/drivers/boat-template.mjs +1196 -0
  14. package/dist/drivers/boat.d.ts +64 -0
  15. package/dist/drivers/boat.mjs +990 -0
  16. package/dist/drivers/cloudflare.d.ts +5 -8
  17. package/dist/drivers/cloudflare.mjs +364 -213
  18. package/dist/drivers/docker.d.ts +4 -3
  19. package/dist/drivers/docker.mjs +244 -165
  20. package/dist/drivers/local-brokering.d.ts +14 -0
  21. package/dist/drivers/local-brokering.mjs +1029 -0
  22. package/dist/drivers/modal.d.ts +4 -7
  23. package/dist/drivers/modal.mjs +220 -155
  24. package/dist/drivers/transient-error.d.ts +13 -0
  25. package/dist/drivers/vercel.d.ts +21 -23
  26. package/dist/drivers/vercel.mjs +279 -169
  27. package/dist/egress-policy.d.ts +134 -0
  28. package/dist/egress-warnings.d.ts +22 -0
  29. package/dist/garbage-collect.d.ts +14 -0
  30. package/dist/hosted-network-policy.d.ts +11 -4
  31. package/dist/hosted-network-policy.mjs +221 -4
  32. package/dist/image-name.d.ts +12 -2
  33. package/dist/image-name.mjs +43 -0
  34. package/dist/image.d.ts +1 -20
  35. package/dist/image.mjs +11 -66
  36. package/dist/index.d.ts +8 -533
  37. package/dist/index.mjs +1420 -315
  38. package/dist/json.d.ts +13 -0
  39. package/dist/lease-failure.d.ts +173 -0
  40. package/dist/lease-lifecycle.d.ts +65 -0
  41. package/dist/lease-retry-wait.d.ts +8 -0
  42. package/dist/lease-start.d.ts +21 -0
  43. package/dist/lease-types.d.ts +15 -5
  44. package/dist/manager.d.ts +2 -0
  45. package/dist/runtime-env.d.ts +15 -2
  46. package/dist/runtime-env.mjs +50 -1
  47. package/dist/runtime-snapshot.d.ts +49 -0
  48. package/dist/runtime-version.d.ts +9 -0
  49. package/dist/runtime-version.mjs +2 -0
  50. package/dist/service-url-exposure.d.ts +1 -3
  51. package/dist/service-url-exposure.mjs +1 -26
  52. package/dist/start-fresh.d.ts +17 -0
  53. package/dist/start-telemetry.d.ts +37 -0
  54. package/dist/stores/memory.d.ts +1 -1
  55. package/dist/stores/memory.mjs +65 -54
  56. package/package.json +67 -81
  57. package/dist/daytona-allow-list.d.ts +0 -16
  58. package/dist/daytona-allow-list.mjs +0 -11
  59. package/dist/drivers/box.d.ts +0 -52
  60. package/dist/drivers/box.mjs +0 -499
  61. package/dist/drivers/cloudflare-egress.d.ts +0 -40
  62. package/dist/drivers/cloudflare-egress.mjs +0 -113
  63. package/dist/drivers/daytona.d.ts +0 -127
  64. package/dist/drivers/daytona.mjs +0 -541
  65. package/dist/drivers/exe.d.ts +0 -26
  66. package/dist/drivers/exe.mjs +0 -469
  67. package/dist/drivers/fetch-bridge.d.ts +0 -10
  68. package/dist/drivers/fetch-bridge.mjs +0 -111
  69. package/dist/lease-policy.d.ts +0 -48
  70. 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[]>;