@claxedo/sandbox-manager 0.9.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 (67) hide show
  1. package/README.md +233 -26
  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 +42 -7
  9. package/dist/driver-catalog.mjs +115 -161
  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 +3 -3
  17. package/dist/drivers/cloudflare.mjs +208 -147
  18. package/dist/drivers/docker.d.ts +4 -3
  19. package/dist/drivers/docker.mjs +154 -126
  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 +2 -2
  23. package/dist/drivers/modal.mjs +121 -111
  24. package/dist/drivers/transient-error.d.ts +2 -0
  25. package/dist/drivers/vercel.d.ts +3 -2
  26. package/dist/drivers/vercel.mjs +151 -115
  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 +9 -2
  31. package/dist/hosted-network-policy.mjs +218 -1
  32. package/dist/image-name.d.ts +12 -2
  33. package/dist/image-name.mjs +14 -5
  34. package/dist/image.d.ts +1 -20
  35. package/dist/image.mjs +11 -88
  36. package/dist/index.d.ts +8 -578
  37. package/dist/index.mjs +1379 -320
  38. package/dist/lease-failure.d.ts +173 -0
  39. package/dist/lease-lifecycle.d.ts +65 -0
  40. package/dist/lease-retry-wait.d.ts +8 -0
  41. package/dist/lease-start.d.ts +21 -0
  42. package/dist/lease-types.d.ts +4 -3
  43. package/dist/manager.d.ts +2 -0
  44. package/dist/runtime-env.d.ts +4 -2
  45. package/dist/runtime-env.mjs +37 -2
  46. package/dist/runtime-snapshot.d.ts +49 -0
  47. package/dist/runtime-version.d.ts +9 -0
  48. package/dist/runtime-version.mjs +2 -0
  49. package/dist/service-url-exposure.d.ts +0 -1
  50. package/dist/service-url-exposure.mjs +0 -9
  51. package/dist/start-fresh.d.ts +17 -0
  52. package/dist/start-telemetry.d.ts +37 -0
  53. package/dist/stores/memory.d.ts +1 -1
  54. package/dist/stores/memory.mjs +63 -52
  55. package/package.json +26 -42
  56. package/dist/daytona-allow-list.d.ts +0 -16
  57. package/dist/daytona-allow-list.mjs +0 -11
  58. package/dist/drivers/box.d.ts +0 -52
  59. package/dist/drivers/box.mjs +0 -574
  60. package/dist/drivers/daytona.d.ts +0 -163
  61. package/dist/drivers/daytona.mjs +0 -683
  62. package/dist/drivers/exe.d.ts +0 -26
  63. package/dist/drivers/exe.mjs +0 -492
  64. package/dist/drivers/fetch-bridge.d.ts +0 -10
  65. package/dist/drivers/fetch-bridge.mjs +0 -126
  66. package/dist/lease-policy.d.ts +0 -52
  67. package/dist/lease-policy.mjs +0 -290
@@ -1,163 +0,0 @@
1
- import type { SandboxDriver, SandboxDriverEnsureInput } from "..";
2
- import { type WorkspaceRuntimeControlEnv } from "../runtime-env";
3
- export type DaytonaSandboxLike = {
4
- id: string;
5
- state?: string;
6
- labels?: Record<string, string>;
7
- process: {
8
- executeCommand: (command: string, cwd?: string, env?: Record<string, string>, timeout?: number) => Promise<unknown>;
9
- };
10
- getPreviewLink: (port: number) => Promise<{
11
- url?: string;
12
- token?: string;
13
- }>;
14
- getSignedPreviewUrl: (port: number, expiresInSeconds?: number) => Promise<{
15
- url?: string;
16
- token?: string;
17
- }>;
18
- refreshActivity: () => Promise<void>;
19
- start: (timeout?: number) => Promise<void>;
20
- stop: (timeout?: number) => Promise<void>;
21
- delete: (timeout?: number) => Promise<void>;
22
- updateSecrets: (secrets: Record<string, string>) => Promise<void>;
23
- /**
24
- * Replace the sandbox's outbound egress policy in place, without stopping it
25
- * — the Daytona SDK's `Sandbox.updateNetworkSettings`, which drives the same
26
- * runner-side iptables mechanism as `create`'s `networkBlockAll` /
27
- * `networkAllowList` / `domainAllowList`. This is what makes the create-time
28
- * policy reappliable on reuse and resume; see `applyNetworkPolicy` below.
29
- *
30
- * Optional because a client injected by an embedder may predate it. When it
31
- * is absent and a restricted policy was requested, reuse is REFUSED rather
32
- * than silently served on the creation-time policy.
33
- */
34
- updateNetworkSettings?: (settings: {
35
- networkBlockAll?: boolean;
36
- networkAllowList?: string;
37
- domainAllowList?: string;
38
- }) => Promise<void>;
39
- _experimental_createSnapshot?: (name: string, timeout?: number) => Promise<void>;
40
- };
41
- export type DaytonaClientLike = {
42
- findByLabels?: (labels: Record<string, string>) => Promise<DaytonaSandboxLike | undefined>;
43
- /**
44
- * One page of sandboxes matching `labels`. Pages are 1-based; a page that
45
- * returns fewer than `limit` items (or none) is the last one — that is the
46
- * termination rule `list()` below relies on, and any implementation must
47
- * honor it or the sweep loops forever.
48
- *
49
- * `createDefaultClient` satisfies it by returning every match on page 1 and
50
- * nothing after: the Daytona SDK's `list()` is an `AsyncIterableIterator`
51
- * that paginates internally, so `limit` is its per-page fetch size and NOT a
52
- * cap on the total (see @daytona/sdk `ListSandboxesQuery.limit`). There is no
53
- * cursor to hand back, so re-slicing per page would re-walk the whole account
54
- * on every call.
55
- */
56
- list?: (labels?: Record<string, string>, page?: number, limit?: number) => Promise<{
57
- items?: DaytonaSandboxLike[];
58
- }>;
59
- create: (params: {
60
- name?: string;
61
- image?: string;
62
- snapshot?: string;
63
- envVars?: Record<string, string>;
64
- /** Env-var-name → Daytona secret-name references (brokered secrets). */
65
- secrets?: Record<string, string>;
66
- labels?: Record<string, string>;
67
- public?: boolean;
68
- autoStopInterval?: number;
69
- autoDeleteInterval?: number;
70
- networkBlockAll?: boolean;
71
- /** Comma-separated allowed CIDR network addresses. */
72
- networkAllowList?: string;
73
- /** Comma-separated allowed domains — the name-based egress allowlist. */
74
- domainAllowList?: string;
75
- }, options?: {
76
- timeout?: number;
77
- }) => Promise<DaytonaSandboxLike>;
78
- get: (sandboxIdOrName: string) => Promise<DaytonaSandboxLike>;
79
- /**
80
- * The org-secret service, in the SDK's own shape so `createDefaultClient`
81
- * hands `sdk.secret` straight through. Upsert and withdrawal POLICY lives in
82
- * this driver (`reconcileBrokeredSecrets`) rather than behind a
83
- * `upsertSecret` client method: `create` is a conflict on an existing name,
84
- * so a client-level "upsert" is a second implementation of the lookup every
85
- * embedder would have to get right.
86
- */
87
- secret?: DaytonaSecretServiceLike;
88
- };
89
- /** Identity of an org secret. The plaintext value is write-only and never returned. */
90
- export type DaytonaSecretLike = {
91
- id: string;
92
- name: string;
93
- };
94
- export type DaytonaSecretServiceLike = {
95
- /**
96
- * `name` is a PARTIAL match, and pages are cursor-based; callers filter the
97
- * page themselves and follow `nextCursor` until it is null.
98
- */
99
- list: (query?: {
100
- name?: string;
101
- cursor?: string;
102
- limit?: number;
103
- }) => Promise<{
104
- items: DaytonaSecretLike[];
105
- nextCursor?: string | null;
106
- }>;
107
- /** Throws `DaytonaConflictError` when a secret of that name already exists. */
108
- create: (params: {
109
- name: string;
110
- value: string;
111
- hosts?: string[];
112
- }) => Promise<DaytonaSecretLike>;
113
- update: (secretId: string, params: {
114
- value?: string;
115
- hosts?: string[];
116
- }) => Promise<unknown>;
117
- delete: (secretId: string) => Promise<void>;
118
- };
119
- export type DaytonaSandboxDriverOptions = {
120
- /** Daytona API base URL. Defaults to the SDK default. */
121
- apiUrl?: string;
122
- /** Daytona API key. */
123
- apiKey: string;
124
- /** Optional Daytona organization id. */
125
- organizationId?: string;
126
- /** Optional Daytona target/region. */
127
- target?: string;
128
- /** Snapshot the sandbox boots from. */
129
- baseSnapshot: string;
130
- /** Port the workspace-runtime listens on inside the sandbox. */
131
- runtimePort?: number;
132
- /** Path to the workspace-runtime binary inside the image. */
133
- runtimeCommand?: string;
134
- /** Workspace directory inside the sandbox. */
135
- workspaceDir?: string;
136
- /** Default runner injected as WORKSPACE_RUNTIME_RUNNER. */
137
- runner?: string;
138
- /** Static control-plane config injected so the runtime verifies relay-proxied requests. */
139
- controlEnv?: WorkspaceRuntimeControlEnv;
140
- /** Dynamic runtime env that needs the acquired sandbox id or current lease. */
141
- env?: (input: SandboxDriverEnsureInput, sandbox: DaytonaSandboxLike) => Record<string, string> | Promise<Record<string, string>>;
142
- /** Auto-stop / auto-delete policy, in minutes. */
143
- autoStopMinutes?: number;
144
- autoDeleteMinutes?: number;
145
- /** Signed preview URL expiry, in seconds. */
146
- previewExpirySeconds?: number;
147
- /** Daytona SDK operation timeout, in seconds. */
148
- operationTimeoutSeconds?: number;
149
- /** Injected for tests. */
150
- client?: DaytonaClientLike;
151
- /**
152
- * Sink for the two operator-visible events this driver has no other way to
153
- * report: a restart it had to force on a live sandbox, and an org secret
154
- * under this workspace's prefix that it did not mint and therefore emptied
155
- * without mounting.
156
- *
157
- * Defaults to `console.warn`, deliberately unconditional — the same
158
- * reasoning as `onEgressUnenforced` in index.ts. Pass your own to route them
159
- * into a logger; pass `() => {}` only if you have another way to see them.
160
- */
161
- warn?: (message: string) => void;
162
- };
163
- export declare function createDaytonaSandboxDriver(options: DaytonaSandboxDriverOptions): SandboxDriver;