withruntime 0.4.0 → 0.5.1

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 (88) hide show
  1. package/DAYTONA.md +129 -0
  2. package/E2B.md +3 -3
  3. package/README.md +47 -9
  4. package/VERCEL.md +127 -0
  5. package/dist/ai/index.d.ts +33 -0
  6. package/dist/ai/index.js +38 -0
  7. package/dist/claude-agent-sdk/index.d.ts +7 -0
  8. package/dist/claude-agent-sdk/index.js +65 -0
  9. package/dist/cli.d.ts +6 -0
  10. package/dist/cli.js +959 -102
  11. package/dist/client.d.ts +25 -2
  12. package/dist/client.js +14 -1
  13. package/dist/credentials.d.ts +10 -0
  14. package/dist/credentials.js +56 -1
  15. package/dist/daytona/client.d.ts +44 -0
  16. package/dist/daytona/client.js +40 -0
  17. package/dist/daytona/context.d.ts +31 -0
  18. package/dist/daytona/context.js +25 -0
  19. package/dist/daytona/daytona.d.ts +185 -0
  20. package/dist/daytona/daytona.js +416 -0
  21. package/dist/daytona/errors.d.ts +106 -0
  22. package/dist/daytona/errors.js +182 -0
  23. package/dist/daytona/filesystem.d.ts +84 -0
  24. package/dist/daytona/filesystem.js +206 -0
  25. package/dist/daytona/git.d.ts +33 -0
  26. package/dist/daytona/git.js +128 -0
  27. package/dist/daytona/image.d.ts +45 -0
  28. package/dist/daytona/image.js +140 -0
  29. package/dist/daytona/index.d.ts +50 -0
  30. package/dist/daytona/index.js +50 -0
  31. package/dist/daytona/process.d.ts +86 -0
  32. package/dist/daytona/process.js +341 -0
  33. package/dist/daytona/sandbox.d.ts +196 -0
  34. package/dist/daytona/sandbox.js +448 -0
  35. package/dist/e2b/commands.js +6 -2
  36. package/dist/e2b/sandbox.d.ts +22 -2
  37. package/dist/e2b/sandbox.js +39 -7
  38. package/dist/errors.d.ts +10 -4
  39. package/dist/errors.js +26 -6
  40. package/dist/image-context.d.ts +39 -0
  41. package/dist/image-context.js +176 -0
  42. package/dist/index.d.ts +19 -2
  43. package/dist/index.js +17 -2
  44. package/dist/keys.d.ts +43 -0
  45. package/dist/keys.js +196 -0
  46. package/dist/login.js +14 -2
  47. package/dist/openai-agents/index.d.ts +132 -0
  48. package/dist/openai-agents/index.js +791 -0
  49. package/dist/products/audit.d.ts +48 -0
  50. package/dist/products/audit.js +10 -0
  51. package/dist/products/images.d.ts +113 -7
  52. package/dist/products/images.js +186 -27
  53. package/dist/products/index.d.ts +11 -0
  54. package/dist/products/index.js +17 -1
  55. package/dist/products/observability.d.ts +186 -0
  56. package/dist/products/observability.js +117 -0
  57. package/dist/products/secrets.d.ts +40 -0
  58. package/dist/products/secrets.js +24 -0
  59. package/dist/products/switching.d.ts +96 -0
  60. package/dist/products/switching.js +25 -0
  61. package/dist/sandbox.d.ts +26 -1
  62. package/dist/sandbox.js +101 -1
  63. package/dist/ssh.d.ts +21 -0
  64. package/dist/ssh.js +324 -0
  65. package/dist/tar.d.ts +1 -0
  66. package/dist/tar.js +4 -4
  67. package/dist/tools/index.d.ts +62 -0
  68. package/dist/tools/index.js +180 -0
  69. package/dist/transport.d.ts +12 -2
  70. package/dist/transport.js +31 -4
  71. package/dist/tunnel.d.ts +70 -0
  72. package/dist/tunnel.js +316 -0
  73. package/dist/types.d.ts +57 -1
  74. package/dist/vercel/client.d.ts +40 -0
  75. package/dist/vercel/client.js +39 -0
  76. package/dist/vercel/command.d.ts +70 -0
  77. package/dist/vercel/command.js +148 -0
  78. package/dist/vercel/errors.d.ts +53 -0
  79. package/dist/vercel/errors.js +113 -0
  80. package/dist/vercel/filesystem.d.ts +150 -0
  81. package/dist/vercel/filesystem.js +248 -0
  82. package/dist/vercel/index.d.ts +30 -0
  83. package/dist/vercel/index.js +38 -0
  84. package/dist/vercel/sandbox.d.ts +317 -0
  85. package/dist/vercel/sandbox.js +726 -0
  86. package/dist/vercel/snapshot.d.ts +93 -0
  87. package/dist/vercel/snapshot.js +123 -0
  88. package/package.json +56 -4
package/dist/client.d.ts CHANGED
@@ -16,6 +16,12 @@ export type RuntimeOptions = {
16
16
  maxRetries?: number;
17
17
  /** Calls in flight at once; more wait their turn and reuse connections. Default 32. */
18
18
  maxConnections?: number;
19
+ /** How long `sandboxes.create` keeps retrying, with the same key and input,
20
+ * when the trial's slots, the account's quota or the region is full
21
+ * (trial_busy, quota_exceeded, no_capacity and the like). Default 120 000
22
+ * (two minutes); 0 fails at once. The refusal is thrown as it came when the
23
+ * wait runs out. */
24
+ waitForCapacityMs?: number;
19
25
  };
20
26
  /** One client for every Runtime Cloud product. Create it once and reuse it:
21
27
  * it keeps its connections open. */
@@ -34,6 +40,10 @@ export declare class Runtime {
34
40
  principalId: string;
35
41
  credentialId: string | null;
36
42
  apiVersion: string;
43
+ /** The account's name. */
44
+ orgName?: string | null;
45
+ /** The role of the member who made this key: owner, admin, developer or billing. */
46
+ role?: string | null;
37
47
  }>;
38
48
  /** Balance, holds, trial time and per-resource charges, in integer microdollars. */
39
49
  /** Credit, holds, trial time and per-resource charges. */
@@ -44,10 +54,23 @@ export declare class Sandboxes {
44
54
  constructor(t: Transport);
45
55
  /** Creates a sandbox and waits until it is running. Every field is optional:
46
56
  * with none you get the free trial while it lasts, the default region and a
47
- * 2 vCPU / 4 GiB machine from a warm template. `wait: false` returns at once. */
57
+ * 2 vCPU / 4 GiB machine from a warm template. `wait: false` returns at once.
58
+ * When every trial slot or the account's quota is taken, it waits for one to
59
+ * free, up to `waitForCapacityMs` (the client's, two minutes by default). */
48
60
  create(input?: CreateSandbox & {
49
61
  wait?: boolean;
50
- }, options?: RequestOptions): Promise<Sandbox>;
62
+ }, options?: RequestOptions & {
63
+ waitForCapacityMs?: number;
64
+ }): Promise<Sandbox>;
65
+ /** The sandbox named `name` in this account, ready to use: running as it
66
+ * is, woken if it is paused, restarted if it is stopped and persistent, or
67
+ * created with `input` when no sandbox has the name. `sandbox.info.reused`
68
+ * says which. The other fields apply only when it is created. */
69
+ getOrCreate(name: string, input?: Omit<CreateSandbox, "name" | "getOrCreate"> & {
70
+ wait?: boolean;
71
+ }, options?: RequestOptions & {
72
+ waitForCapacityMs?: number;
73
+ }): Promise<Sandbox>;
51
74
  get(id: string, options?: RequestOptions): Promise<Sandbox>;
52
75
  /** Live sandboxes, oldest first. Await for a page, or `for await` over all. */
53
76
  list(filter?: {
package/dist/client.js CHANGED
@@ -30,6 +30,9 @@ export class Runtime {
30
30
  ...(options.timeoutMs ? { timeoutMs: options.timeoutMs } : {}),
31
31
  ...(options.maxRetries !== undefined ? { maxRetries: options.maxRetries } : {}),
32
32
  ...(options.maxConnections ? { maxConnections: options.maxConnections } : {}),
33
+ ...(options.waitForCapacityMs !== undefined
34
+ ? { waitForCapacityMs: options.waitForCapacityMs }
35
+ : {}),
33
36
  });
34
37
  this.sandboxes = new Sandboxes(this.transport);
35
38
  this.snapshots = new Snapshots(this.transport);
@@ -63,7 +66,9 @@ export class Sandboxes {
63
66
  }
64
67
  /** Creates a sandbox and waits until it is running. Every field is optional:
65
68
  * with none you get the free trial while it lasts, the default region and a
66
- * 2 vCPU / 4 GiB machine from a warm template. `wait: false` returns at once. */
69
+ * 2 vCPU / 4 GiB machine from a warm template. `wait: false` returns at once.
70
+ * When every trial slot or the account's quota is taken, it waits for one to
71
+ * free, up to `waitForCapacityMs` (the client's, two minutes by default). */
67
72
  async create(input = {}, options = {}) {
68
73
  const { wait, ...body } = input;
69
74
  const info = await this.t.json({
@@ -72,6 +77,7 @@ export class Sandboxes {
72
77
  body,
73
78
  wait: wait === false ? 0 : 60,
74
79
  ...options,
80
+ waitForCapacityMs: options.waitForCapacityMs ?? this.t.waitForCapacityMs,
75
81
  });
76
82
  const sandbox = new Sandbox(this.t, info);
77
83
  if (wait !== false && info.state !== "running") {
@@ -86,6 +92,13 @@ export class Sandboxes {
86
92
  }
87
93
  return sandbox;
88
94
  }
95
+ /** The sandbox named `name` in this account, ready to use: running as it
96
+ * is, woken if it is paused, restarted if it is stopped and persistent, or
97
+ * created with `input` when no sandbox has the name. `sandbox.info.reused`
98
+ * says which. The other fields apply only when it is created. */
99
+ async getOrCreate(name, input = {}, options = {}) {
100
+ return this.create({ ...input, name, getOrCreate: true }, options);
101
+ }
89
102
  async get(id, options = {}) {
90
103
  return new Sandbox(this.t, await this.t.json({
91
104
  method: "GET",
@@ -7,6 +7,8 @@ export type SavedConnection = {
7
7
  connectionId: string;
8
8
  orgId: string;
9
9
  agentName: string;
10
+ /** The account's name when it was saved, for `runtime account`. */
11
+ orgName?: string;
10
12
  };
11
13
  export declare function connectionOrigins(env: NodeJS.ProcessEnv): {
12
14
  api: string;
@@ -16,7 +18,15 @@ export declare function connectionOrigins(env: NodeJS.ProcessEnv): {
16
18
  * returns a secret to CLI output. Store names bind credentials to both origins. */
17
19
  export declare function connectionStore(env: NodeJS.ProcessEnv, directory?: string): {
18
20
  read(): Promise<SavedConnection | null>;
21
+ /** Save the connection in use. One for another account moves to the
22
+ * saved accounts, so connecting a second account never loses the first
23
+ * (ARCHITECTURE.md section 3.9); one for the same account is replaced. */
19
24
  save(connection: SavedConnection): Promise<void>;
25
+ /** The other accounts this machine has connected, newest first. */
26
+ others(): Promise<SavedConnection[]>;
27
+ /** Use another saved account's connection, by account id or name. The one
28
+ * in use moves to the saved accounts. Null when none matches. */
29
+ use(which: string): Promise<SavedConnection | null>;
20
30
  remove(): Promise<void>;
21
31
  /** A browser approval that was started and not yet answered, so a command
22
32
  * that was stopped while it waited picks up the same link and code rather
@@ -5,6 +5,8 @@ import { homedir } from "node:os";
5
5
  import { isAbsolute, join } from "node:path";
6
6
  import { apiOrigin } from "./index.js";
7
7
  import { missingKey } from "./transport.js";
8
+ /** How many other accounts' connections one machine keeps beside the one in use. */
9
+ const SAVED_ACCOUNTS = 20;
8
10
  export function connectionOrigins(env) {
9
11
  return {
10
12
  api: apiOrigin(env.RUNTIME_API_URL ?? "https://api.withruntime.com"),
@@ -93,6 +95,7 @@ export function connectionStore(env, directory = defaultDirectory(env)) {
93
95
  });
94
96
  }
95
97
  const pendingFile = join(directory, `${name}.pending.json`);
98
+ const accountsFile = join(directory, `${name}.accounts.json`);
96
99
  return {
97
100
  async read() {
98
101
  const text = await readPrivate(file, 4096, "saved connection");
@@ -112,15 +115,67 @@ export function connectionStore(env, directory = defaultDirectory(env)) {
112
115
  !/^rtcloud_[a-f0-9-]{36}_[A-Za-z0-9_-]{43}$/.test(saved.key) ||
113
116
  typeof saved.connectionId !== "string" ||
114
117
  typeof saved.orgId !== "string" ||
115
- typeof saved.agentName !== "string")
118
+ typeof saved.agentName !== "string" ||
119
+ (saved.orgName !== undefined && typeof saved.orgName !== "string"))
116
120
  throw new Error("Runtime's saved connection is invalid. Connect again.");
117
121
  return saved;
118
122
  },
123
+ /** Save the connection in use. One for another account moves to the
124
+ * saved accounts, so connecting a second account never loses the first
125
+ * (ARCHITECTURE.md section 3.9); one for the same account is replaced. */
119
126
  async save(connection) {
120
127
  if (connection.apiOrigin !== origins.api || connection.authOrigin !== origins.auth)
121
128
  throw new Error("Connection origins do not match.");
129
+ const previous = await this.read().catch(() => null);
130
+ if (previous && previous.orgId !== connection.orgId) {
131
+ const others = (await this.others()).filter((one) => one.orgId !== previous.orgId && one.orgId !== connection.orgId);
132
+ await writePrivate(accountsFile, JSON.stringify([previous, ...others].slice(0, SAVED_ACCOUNTS)));
133
+ }
122
134
  await writePrivate(file, JSON.stringify(connection));
123
135
  },
136
+ /** The other accounts this machine has connected, newest first. */
137
+ async others() {
138
+ let text;
139
+ try {
140
+ text = await readPrivate(accountsFile, 64 * 1024, "saved accounts");
141
+ }
142
+ catch {
143
+ return [];
144
+ }
145
+ if (text === null)
146
+ return [];
147
+ try {
148
+ const list = JSON.parse(text);
149
+ return Array.isArray(list)
150
+ ? list.filter((one) => one &&
151
+ one.version === 1 &&
152
+ one.apiOrigin === origins.api &&
153
+ one.authOrigin === origins.auth &&
154
+ typeof one.key === "string" &&
155
+ /^rtcloud_[a-f0-9-]{36}_[A-Za-z0-9_-]{43}$/.test(one.key) &&
156
+ typeof one.orgId === "string")
157
+ : [];
158
+ }
159
+ catch {
160
+ return [];
161
+ }
162
+ },
163
+ /** Use another saved account's connection, by account id or name. The one
164
+ * in use moves to the saved accounts. Null when none matches. */
165
+ async use(which) {
166
+ const others = await this.others();
167
+ const wanted = which.trim().toLowerCase();
168
+ const chosen = others.find((one) => one.orgId === which) ??
169
+ others.find((one) => one.orgName?.toLowerCase() === wanted) ??
170
+ null;
171
+ if (!chosen)
172
+ return null;
173
+ const current = await this.read().catch(() => null);
174
+ const rest = others.filter((one) => one.orgId !== chosen.orgId);
175
+ await writePrivate(accountsFile, JSON.stringify((current ? [current, ...rest] : rest).slice(0, SAVED_ACCOUNTS)));
176
+ await writePrivate(file, JSON.stringify(chosen));
177
+ return chosen;
178
+ },
124
179
  async remove() {
125
180
  await removePrivate(file);
126
181
  },
@@ -0,0 +1,44 @@
1
+ import { Runtime } from "../client.js";
2
+ /** The Runtime sandbox the adapter drives. */
3
+ export type RuntimeSandbox = Awaited<ReturnType<Runtime["sandboxes"]["create"]>>;
4
+ /** What `daytona.create` sends to Runtime. */
5
+ export type RuntimeCreate = NonNullable<Parameters<Runtime["sandboxes"]["create"]>[0]>;
6
+ /** Runtime-only options, for code that has been through the switch. */
7
+ export interface WithRuntime {
8
+ /** A Runtime client to use instead of one made from the key. */
9
+ client?: Runtime;
10
+ /** Fields sent as they are with every create, over the adapter's own: for
11
+ * example `{ funding: "trial" }`. */
12
+ create?: Partial<RuntimeCreate>;
13
+ }
14
+ /** Daytona's client options, as far as they mean anything on Runtime. */
15
+ export interface DaytonaConfig {
16
+ /** A Runtime key (`rtcloud_...`). Default: RUNTIME_API_KEY, then a Runtime
17
+ * key left in DAYTONA_API_KEY, then the key `npx withruntime login` saved.
18
+ * A Daytona key is never sent anywhere. */
19
+ apiKey?: string;
20
+ /** Refused: Runtime authenticates with keys. */
21
+ jwtToken?: string;
22
+ organizationId?: string;
23
+ /** Daytona's API address. Ignored: this package talks only to Runtime
24
+ * (RUNTIME_API_URL overrides Runtime's). */
25
+ apiUrl?: string;
26
+ serverUrl?: string;
27
+ /** "us" is Runtime's one region; any other is refused. */
28
+ target?: string;
29
+ /** Accepted and ignored: Runtime's SDK does not export traces. */
30
+ otelEnabled?: boolean;
31
+ useDeprecatedPolling?: boolean;
32
+ /** Accepted and ignored: Runtime's SDK sets its own request deadlines. */
33
+ requestTimeoutMs?: number;
34
+ _experimental?: Record<string, unknown>;
35
+ /** Runtime-only: an explicit client, or fields for every create. */
36
+ withruntime?: WithRuntime;
37
+ }
38
+ /** Explicit Runtime key, then RUNTIME_API_KEY, then DAYTONA_API_KEY when it
39
+ * holds a Runtime key; undefined lets the Runtime SDK find the saved login. */
40
+ export declare function pickKey(explicit?: string): string | undefined;
41
+ /** The Runtime client for this configuration. */
42
+ export declare function clientFor(config?: DaytonaConfig): Runtime;
43
+ /** Test hook: forget the cached clients. */
44
+ export declare function resetClients(): void;
@@ -0,0 +1,40 @@
1
+ import { Runtime } from "../client.js";
2
+ import { DaytonaAuthenticationError, NotSupportedError } from "./errors.js";
3
+ const env = (name) => typeof process === "undefined" ? undefined : process.env[name];
4
+ const isRuntimeKey = (key) => key.startsWith("rtcloud_");
5
+ /** Explicit Runtime key, then RUNTIME_API_KEY, then DAYTONA_API_KEY when it
6
+ * holds a Runtime key; undefined lets the Runtime SDK find the saved login. */
7
+ export function pickKey(explicit) {
8
+ if (explicit !== undefined && isRuntimeKey(explicit))
9
+ return explicit;
10
+ const runtimeKey = env("RUNTIME_API_KEY");
11
+ if (runtimeKey)
12
+ return runtimeKey;
13
+ if (explicit !== undefined && explicit !== "")
14
+ throw new DaytonaAuthenticationError("The apiKey passed is a Daytona API key, and it was not sent. Set RUNTIME_API_KEY to a Runtime key " +
15
+ "(https://withruntime.com/account/keys, or run `npx withruntime login`), or pass the Runtime key as apiKey.");
16
+ const daytonaVariable = env("DAYTONA_API_KEY");
17
+ return daytonaVariable && isRuntimeKey(daytonaVariable) ? daytonaVariable : undefined;
18
+ }
19
+ const clients = new Map();
20
+ /** The Runtime client for this configuration. */
21
+ export function clientFor(config = {}) {
22
+ if (config.jwtToken !== undefined || (config.organizationId !== undefined && !config.apiKey))
23
+ throw new NotSupportedError("Daytona JWT sign-in (jwtToken, organizationId)", "Use a Runtime key: set RUNTIME_API_KEY, or run `npx withruntime login` once.");
24
+ const target = config.target ?? env("DAYTONA_TARGET");
25
+ if (target !== undefined && target !== "" && target !== "us")
26
+ throw new NotSupportedError(`The Daytona target "${target}"`, 'Runtime runs in one US region; remove target or use "us".');
27
+ if (config.withruntime?.client)
28
+ return config.withruntime.client;
29
+ const key = pickKey(config.apiKey);
30
+ let client = clients.get(key ?? "");
31
+ if (!client) {
32
+ client = new Runtime(key ? { apiKey: key } : {});
33
+ clients.set(key ?? "", client);
34
+ }
35
+ return client;
36
+ }
37
+ /** Test hook: forget the cached clients. */
38
+ export function resetClients() {
39
+ clients.clear();
40
+ }
@@ -0,0 +1,31 @@
1
+ import type { RuntimeSandbox } from "./client.js";
2
+ /** What a sandbox's modules (process, fs, git, code interpreter) share. */
3
+ export interface SandboxContext {
4
+ /** The Runtime sandbox, with its lease renewed if this call is activity
5
+ * that should keep it running (autoStopInterval). */
6
+ live(): Promise<RuntimeSandbox>;
7
+ /** Environment given at create (envVars) or with updateEnv. */
8
+ readonly env: Record<string, string>;
9
+ /** The language of `process.codeRun`: python, javascript or typescript. */
10
+ readonly language: string;
11
+ /** Makes /home/daytona (Daytona's home) lead to /workspace (Runtime's),
12
+ * once, the first time something names it. */
13
+ ensureHome(text: string | undefined): Promise<void>;
14
+ }
15
+ /** Daytona's home, and the working directory relative paths resolve from. */
16
+ export declare const DAYTONA_HOME = "/home/daytona";
17
+ /** Runtime's. */
18
+ export declare const HOME = "/workspace";
19
+ export declare const HOME_LINK = "[ -e /home/daytona ] || sudo ln -s /workspace /home/daytona";
20
+ /** Commands without a timeout run until the sandbox ends: Runtime's longest. */
21
+ export declare const LONGEST_MS = 86400000;
22
+ /** Given to exec so it streams and returns the whole output, as Daytona does:
23
+ * an exec with no output callback returns at most 64 KiB of each stream. */
24
+ export declare const WHOLE_OUTPUT: {
25
+ readonly onStdout: () => undefined;
26
+ };
27
+ /** A Daytona path as a Runtime one: relative paths (and `~`) resolve from the
28
+ * working directory, /workspace on Runtime. */
29
+ export declare function resolvePath(path: string): string;
30
+ /** Quotes a word for bash. */
31
+ export declare function quote(word: string): string;
@@ -0,0 +1,25 @@
1
+ /** Daytona's home, and the working directory relative paths resolve from. */
2
+ export const DAYTONA_HOME = "/home/daytona";
3
+ /** Runtime's. */
4
+ export const HOME = "/workspace";
5
+ export const HOME_LINK = `[ -e ${DAYTONA_HOME} ] || sudo ln -s ${HOME} ${DAYTONA_HOME}`;
6
+ /** Commands without a timeout run until the sandbox ends: Runtime's longest. */
7
+ export const LONGEST_MS = 86_400_000;
8
+ /** Given to exec so it streams and returns the whole output, as Daytona does:
9
+ * an exec with no output callback returns at most 64 KiB of each stream. */
10
+ export const WHOLE_OUTPUT = { onStdout: () => undefined };
11
+ /** A Daytona path as a Runtime one: relative paths (and `~`) resolve from the
12
+ * working directory, /workspace on Runtime. */
13
+ export function resolvePath(path) {
14
+ if (path === "~" || path === "")
15
+ return HOME;
16
+ if (path.startsWith("~/"))
17
+ return `${HOME}/${path.slice(2)}`;
18
+ if (path.startsWith("/"))
19
+ return path;
20
+ return `${HOME}/${path.replace(/^\.\/?/, "")}`.replace(/\/+$/, "") || HOME;
21
+ }
22
+ /** Quotes a word for bash. */
23
+ export function quote(word) {
24
+ return `'${word.replace(/'/g, `'\\''`)}'`;
25
+ }
@@ -0,0 +1,185 @@
1
+ import type { Runtime } from "../client.js";
2
+ import { type DaytonaConfig, type WithRuntime } from "./client.js";
3
+ import type { Image } from "./image.js";
4
+ import { Sandbox, type Lifecycle, type SandboxState } from "./sandbox.js";
5
+ /** Daytona's default machine: 1 vCPU, 1 GiB memory, 3 GiB disk (checked
6
+ * 23 September 2026). */
7
+ export declare const DEFAULT_RESOURCES: {
8
+ readonly cpu: 1;
9
+ readonly memory: 1;
10
+ readonly disk: 3;
11
+ };
12
+ /** Daytona's default autoStopInterval, 15 minutes. */
13
+ export declare const DEFAULT_AUTO_STOP_MINUTES = 15;
14
+ /** Daytona's label for a sandbox's code language. */
15
+ export declare const LANGUAGE_LABEL = "code-toolbox-language";
16
+ export declare enum CodeLanguage {
17
+ PYTHON = "python",
18
+ TYPESCRIPT = "typescript",
19
+ JAVASCRIPT = "javascript"
20
+ }
21
+ export interface Resources {
22
+ cpu?: number;
23
+ gpu?: number;
24
+ gpuType?: unknown;
25
+ /** GiB. */
26
+ memory?: number;
27
+ /** GiB. */
28
+ disk?: number;
29
+ }
30
+ export interface VolumeMount {
31
+ volumeId: string;
32
+ mountPath: string;
33
+ subpath?: string;
34
+ }
35
+ export type CreateSandboxBaseParams = {
36
+ name?: string;
37
+ user?: string;
38
+ language?: CodeLanguage | string;
39
+ envVars?: Record<string, string>;
40
+ labels?: Record<string, string>;
41
+ public?: boolean;
42
+ autoStopInterval?: number;
43
+ autoPauseInterval?: number;
44
+ autoArchiveInterval?: number;
45
+ autoDeleteInterval?: number;
46
+ ttlMinutes?: number;
47
+ volumes?: VolumeMount[];
48
+ networkBlockAll?: boolean;
49
+ networkAllowList?: string;
50
+ domainAllowList?: string;
51
+ outboundProxyUrl?: string;
52
+ otelEndpointOverride?: string;
53
+ ephemeral?: boolean;
54
+ spot?: boolean;
55
+ linkedSandbox?: string;
56
+ secrets?: Record<string, string>;
57
+ /** Runtime-only: an explicit client, or fields for this create. */
58
+ withruntime?: WithRuntime;
59
+ };
60
+ export type CreateSandboxFromImageParams = CreateSandboxBaseParams & {
61
+ image: string | Image;
62
+ resources?: Resources;
63
+ };
64
+ export type CreateSandboxFromSnapshotParams = CreateSandboxBaseParams & {
65
+ snapshot?: string;
66
+ resources?: Resources;
67
+ };
68
+ export type ForkSandboxParams = {
69
+ name?: string;
70
+ };
71
+ export interface ListSandboxesQuery {
72
+ limit?: number;
73
+ name?: string;
74
+ labels?: Record<string, string>;
75
+ states?: SandboxState[];
76
+ [other: string]: unknown;
77
+ }
78
+ /** A Daytona snapshot: on Runtime, an image (or a snapshot made with
79
+ * sandbox.createSnapshot). */
80
+ export interface Snapshot {
81
+ id: string;
82
+ name: string;
83
+ imageName: string;
84
+ state: "active" | "building" | "pending" | "error" | "removing";
85
+ size: number | null;
86
+ errorReason: string | null;
87
+ createdAt: string;
88
+ updatedAt: string;
89
+ lastUsedAt: string | null;
90
+ general: boolean;
91
+ cpu: number;
92
+ gpu: number;
93
+ mem: number;
94
+ disk: number;
95
+ }
96
+ export interface PaginatedSnapshots {
97
+ items: Snapshot[];
98
+ total: number;
99
+ page: number;
100
+ totalPages: number;
101
+ }
102
+ export interface CreateSnapshotParams {
103
+ name: string;
104
+ image: string | Image;
105
+ resources?: Resources;
106
+ entrypoint?: string[];
107
+ regionId?: string;
108
+ }
109
+ export interface Volume {
110
+ id: string;
111
+ name: string;
112
+ organizationId: string;
113
+ state: string;
114
+ createdAt: string;
115
+ updatedAt: string;
116
+ lastUsedAt: string | null;
117
+ errorReason: string | null;
118
+ }
119
+ /** `daytona.snapshot`: Daytona snapshots as Runtime images. */
120
+ export declare class SnapshotService {
121
+ #private;
122
+ constructor(client: Runtime);
123
+ list(queryOrPage?: {
124
+ page?: number;
125
+ limit?: number;
126
+ sourceSandboxId?: string;
127
+ } | number, maybeLimit?: number): Promise<PaginatedSnapshots>;
128
+ get(idOrName: string): Promise<Snapshot>;
129
+ /** Builds a Runtime image named `name` from a registry image or a Daytona
130
+ * Image, streaming the build log to `onLogs`. */
131
+ create(params: CreateSnapshotParams, options?: {
132
+ onLogs?: (chunk: string) => void;
133
+ timeout?: number;
134
+ }): Promise<Snapshot>;
135
+ delete(snapshot: Snapshot | string): Promise<void>;
136
+ /** Runtime images do not go inactive: returns the snapshot as it is. */
137
+ activate(snapshot: Snapshot | string): Promise<Snapshot>;
138
+ }
139
+ /** `daytona.volume`: Daytona volumes as Runtime volumes. */
140
+ export declare class VolumeService {
141
+ #private;
142
+ constructor(client: Runtime);
143
+ list(): Promise<Volume[]>;
144
+ get(name: string, create?: boolean): Promise<Volume>;
145
+ create(name: string): Promise<Volume>;
146
+ delete(volume: Volume): Promise<void>;
147
+ }
148
+ /** Daytona's client. Uses RUNTIME_API_KEY (or a Runtime key in apiKey or
149
+ * DAYTONA_API_KEY, or the saved `npx withruntime login`). */
150
+ export declare class Daytona implements AsyncDisposable {
151
+ #private;
152
+ readonly snapshot: SnapshotService;
153
+ readonly volume: VolumeService;
154
+ readonly secret: unknown;
155
+ readonly warmPool: unknown;
156
+ constructor(config?: DaytonaConfig);
157
+ [Symbol.asyncDispose](): Promise<void>;
158
+ /** Creates a sandbox and waits until it runs, with Daytona's defaults: 1
159
+ * vCPU, 1 GiB, 3 GiB disk, pausing after 15 minutes without calls. Funding
160
+ * is left to Runtime: the free trial while the account has trial time, then
161
+ * prepaid credit, exactly as withruntime's own create. */
162
+ create(params?: CreateSandboxFromSnapshotParams | CreateSandboxFromImageParams, options?: {
163
+ timeout?: number;
164
+ onSnapshotCreateLogs?: (chunk: string) => void;
165
+ }): Promise<Sandbox>;
166
+ /** A sandbox by id or name. */
167
+ get(sandboxIdOrName: string): Promise<Sandbox>;
168
+ /** Live and stopped (paused) sandboxes, oldest first. Await it for the old
169
+ * paginated shape, `{ items, total, page, totalPages }`. */
170
+ list(query?: ListSandboxesQuery): AsyncIterableIterator<Sandbox> & PromiseLike<{
171
+ items: Sandbox[];
172
+ total: number;
173
+ page: number;
174
+ totalPages: number;
175
+ }>;
176
+ start(sandbox: Sandbox, timeout?: number): Promise<void>;
177
+ stop(sandbox: Sandbox): Promise<void>;
178
+ delete(sandbox: Sandbox, timeout?: number): Promise<void>;
179
+ /** Daytona's older name for delete. */
180
+ remove(sandbox: Sandbox, timeout?: number): Promise<void>;
181
+ fork(sandbox: Sandbox, params?: ForkSandboxParams, timeout?: number): Promise<Sandbox>;
182
+ _experimental_fork(sandbox: Sandbox, params?: ForkSandboxParams, timeout?: number): Promise<Sandbox>;
183
+ }
184
+ /** Daytona's lifecycle settings as the lease Runtime keeps. */
185
+ export declare function lifecycleOf(params: CreateSandboxBaseParams): Lifecycle;