@madarco/agentbox 0.24.5 → 0.25.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 (161) hide show
  1. package/CHANGELOG.md +70 -0
  2. package/LICENSE +21 -0
  3. package/README.md +4 -0
  4. package/dist/{_cloud-attach-ESCPOKG5.js → _cloud-attach-W2CFNXKO.js} +5 -5
  5. package/dist/{chunk-RFRWS5CD.js → chunk-4UNSBU5R.js} +2 -2
  6. package/dist/{chunk-H6A4BQMG.js → chunk-5F5SOSDY.js} +40 -1
  7. package/dist/chunk-5F5SOSDY.js.map +1 -0
  8. package/dist/{chunk-7DPDUZ7L.js → chunk-7C5MOA4Z.js} +194 -56
  9. package/dist/chunk-7C5MOA4Z.js.map +1 -0
  10. package/dist/{chunk-LJMGHFLZ.js → chunk-7PRLM3PH.js} +3 -3
  11. package/dist/chunk-G3H2L3O2.js +0 -0
  12. package/dist/{chunk-4HPLS5HJ.js → chunk-GHFIKSBJ.js} +110 -9
  13. package/dist/chunk-GHFIKSBJ.js.map +1 -0
  14. package/dist/{chunk-5JDOTQTM.js → chunk-LCZOQTIX.js} +4 -4
  15. package/dist/{chunk-QHISF6O6.js → chunk-LU3WAHTU.js} +3 -3
  16. package/dist/{chunk-CE3S7UDQ.js → chunk-NH3W6HUZ.js} +44 -12
  17. package/dist/chunk-NH3W6HUZ.js.map +1 -0
  18. package/dist/{chunk-OSPM4Q5V.js → chunk-VZC5J44U.js} +5 -5
  19. package/dist/chunk-VZC5J44U.js.map +1 -0
  20. package/dist/chunk-WJFZJZIM.js +0 -0
  21. package/dist/{chunk-3MDYQROX.js → chunk-Y3OPQWAQ.js} +11 -11
  22. package/dist/chunk-Y3OPQWAQ.js.map +1 -0
  23. package/dist/cloud-poller-SUNA6ZQC-7M5LJHHE.js +0 -0
  24. package/dist/{dist-TRKHS6I7.js → dist-3V5SLNK4.js} +6 -6
  25. package/dist/{dist-NOUPH5E6.js → dist-BIDAC4H4.js} +4 -4
  26. package/dist/{dist-VFPT5TDH.js → dist-I5OBPLP2.js} +6 -6
  27. package/dist/{dist-3M53BF4E.js → dist-IGQNVIV3.js} +6 -6
  28. package/dist/dist-KL73Z37T.js +677 -0
  29. package/dist/dist-KL73Z37T.js.map +1 -0
  30. package/dist/{dist-HPPHBZTO.js → dist-SBDYDH7H.js} +8 -2
  31. package/dist/{dist-FGXCG4JY.js → dist-UB3PYSCG.js} +6 -6
  32. package/dist/index.js +146 -54
  33. package/dist/index.js.map +1 -1
  34. package/dist/{prepared-state-BUO75YLZ-46W2PAHH.js → prepared-state-OBM2F7CU-DY7TZV4R.js} +2 -2
  35. package/package.json +29 -30
  36. package/runtime/_shared/agentbox-checkpoint-cleanup +0 -0
  37. package/runtime/_shared/agentbox-dockerd-start +0 -0
  38. package/runtime/_shared/agentbox-open +0 -0
  39. package/runtime/_shared/agentbox-portless-trust +0 -0
  40. package/runtime/_shared/agentbox-vnc-start +0 -0
  41. package/runtime/_shared/ctl.cjs +31 -4
  42. package/runtime/_shared/gh-shim +0 -0
  43. package/runtime/_shared/git-shim +0 -0
  44. package/runtime/_shared/linear-shim +0 -0
  45. package/runtime/_shared/ntn-shim +0 -0
  46. package/runtime/digitalocean/agentbox-checkpoint-cleanup +0 -0
  47. package/runtime/digitalocean/agentbox-dockerd-start +0 -0
  48. package/runtime/digitalocean/agentbox-open +0 -0
  49. package/runtime/digitalocean/agentbox-portless-trust +0 -0
  50. package/runtime/digitalocean/agentbox-vnc-start +0 -0
  51. package/runtime/digitalocean/ctl.cjs +31 -4
  52. package/runtime/digitalocean/gh-shim +0 -0
  53. package/runtime/digitalocean/git-shim +0 -0
  54. package/runtime/digitalocean/linear-shim +0 -0
  55. package/runtime/digitalocean/ntn-shim +0 -0
  56. package/runtime/digitalocean/scripts/install-box.sh +0 -0
  57. package/runtime/docker/packages/ctl/dist/bin.cjs +31 -4
  58. package/runtime/docker/packages/sandbox-docker/scripts/agentbox-checkpoint-cleanup +0 -0
  59. package/runtime/docker/packages/sandbox-docker/scripts/agentbox-dockerd-start +0 -0
  60. package/runtime/docker/packages/sandbox-docker/scripts/agentbox-open +0 -0
  61. package/runtime/docker/packages/sandbox-docker/scripts/agentbox-portless-trust +0 -0
  62. package/runtime/docker/packages/sandbox-docker/scripts/agentbox-sshd-start +0 -0
  63. package/runtime/docker/packages/sandbox-docker/scripts/agentbox-vnc-start +0 -0
  64. package/runtime/docker/packages/sandbox-docker/scripts/chromium-resolver +0 -0
  65. package/runtime/docker/packages/sandbox-docker/scripts/gh-shim +0 -0
  66. package/runtime/docker/packages/sandbox-docker/scripts/git-shim +0 -0
  67. package/runtime/docker/packages/sandbox-docker/scripts/linear-shim +0 -0
  68. package/runtime/docker/packages/sandbox-docker/scripts/ntn-shim +0 -0
  69. package/runtime/e2b/agentbox-checkpoint-cleanup +0 -0
  70. package/runtime/e2b/agentbox-dockerd-start +0 -0
  71. package/runtime/e2b/agentbox-open +0 -0
  72. package/runtime/e2b/agentbox-vnc-start +0 -0
  73. package/runtime/e2b/ctl.cjs +31 -4
  74. package/runtime/e2b/gh-shim +0 -0
  75. package/runtime/e2b/git-shim +0 -0
  76. package/runtime/e2b/linear-shim +0 -0
  77. package/runtime/e2b/ntn-shim +0 -0
  78. package/runtime/e2b/scripts/build-template.sh +0 -0
  79. package/runtime/hetzner/agentbox-checkpoint-cleanup +0 -0
  80. package/runtime/hetzner/agentbox-dockerd-start +0 -0
  81. package/runtime/hetzner/agentbox-open +0 -0
  82. package/runtime/hetzner/agentbox-portless-trust +0 -0
  83. package/runtime/hetzner/agentbox-vnc-start +0 -0
  84. package/runtime/hetzner/ctl.cjs +31 -4
  85. package/runtime/hetzner/gh-shim +0 -0
  86. package/runtime/hetzner/git-shim +0 -0
  87. package/runtime/hetzner/linear-shim +0 -0
  88. package/runtime/hetzner/ntn-shim +0 -0
  89. package/runtime/hetzner/scripts/install-box.sh +0 -0
  90. package/runtime/hub/apps/hub/.next/BUILD_ID +1 -1
  91. package/runtime/hub/apps/hub/.next/build-manifest.json +3 -3
  92. package/runtime/hub/apps/hub/.next/server/app/_global-error.html +1 -1
  93. package/runtime/hub/apps/hub/.next/server/app/_global-error.rsc +1 -1
  94. package/runtime/hub/apps/hub/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
  95. package/runtime/hub/apps/hub/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  96. package/runtime/hub/apps/hub/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
  97. package/runtime/hub/apps/hub/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
  98. package/runtime/hub/apps/hub/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  99. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0d1lmiq._.js +6 -6
  100. package/runtime/hub/apps/hub/.next/server/chunks/_0760z6y._.js +1 -1
  101. package/runtime/hub/apps/hub/.next/server/chunks/ssr/_0ro6vh6._.js +1 -1
  102. package/runtime/hub/apps/hub/.next/server/middleware-build-manifest.js +3 -3
  103. package/runtime/hub/apps/hub/.next/server/pages/500.html +1 -1
  104. package/runtime/hub/apps/hub/{auth-HY5K55Y5.js → auth-MVL4NCQC.js} +3 -3
  105. package/runtime/hub/apps/hub/{auth-config-MNW2XGKK.js → auth-config-GRIXACTV.js} +3 -3
  106. package/runtime/hub/apps/hub/{chunk-OF242BLD.js → chunk-CKBHQ7OI.js} +1 -1
  107. package/runtime/hub/apps/hub/{chunk-PROXBLRJ.js → chunk-JLG5JJXD.js} +1 -1
  108. package/runtime/hub/apps/hub/{chunk-EY6HEDTK.js → chunk-LNHPLR3L.js} +11 -11
  109. package/runtime/hub/apps/hub/{chunk-DNR2YM2G.js → chunk-MA73PTOR.js} +57 -9
  110. package/runtime/hub/apps/hub/{chunk-TZFWAJVB.js → chunk-OG4KH2FZ.js} +5 -0
  111. package/runtime/hub/apps/hub/{chunk-5KMJIVZC.js → chunk-QBJOF5D3.js} +111 -10
  112. package/runtime/hub/apps/hub/chunk-QYJ37CUJ.js +62140 -0
  113. package/runtime/hub/apps/hub/{chunk-EFW34I43.js → chunk-UDZ3VXRF.js} +1 -1
  114. package/runtime/hub/apps/hub/{chunk-TRUQCO4U.js → chunk-V3OMPMI3.js} +40 -1
  115. package/runtime/hub/apps/hub/{cloud-poller-SUNA6ZQC-VSKVMYHL.js → cloud-poller-SUNA6ZQC-YAWTNA2W.js} +1 -1
  116. package/runtime/hub/apps/hub/{dist-YCRESLWD.js → dist-26KVXHXV.js} +7 -7
  117. package/runtime/hub/apps/hub/{dist-SX2NXGI6.js → dist-7LB4D4ZQ.js} +7 -7
  118. package/runtime/hub/apps/hub/{dist-M73U3ZDH.js → dist-ERQDDSOY.js} +7 -7
  119. package/runtime/hub/apps/hub/{dist-NTKPAYA3.js → dist-IZ2JCN5R.js} +8 -2
  120. package/runtime/hub/apps/hub/{dist-3DCKZYID.js → dist-SIQJD72C.js} +596 -113
  121. package/runtime/hub/apps/hub/{dist-RSWTJWRN.js → dist-YZJA4WRV.js} +5 -5
  122. package/runtime/hub/apps/hub/{dist-KV5ESR24.js → dist-ZVY2FWG6.js} +7 -7
  123. package/runtime/hub/apps/hub/esm-VGBJAFLR.js +79 -0
  124. package/runtime/hub/apps/hub/{execa-4DLVNM6E.js → execa-AFY4ZODY.js} +2 -2
  125. package/runtime/hub/apps/hub/{hub-token-QKQWV2I6.js → hub-token-BJG6Q5II.js} +3 -3
  126. package/runtime/hub/apps/hub/{prepared-state-BUO75YLZ-KR4YLKDC.js → prepared-state-OBM2F7CU-ZEYFNYFI.js} +3 -3
  127. package/runtime/hub/apps/hub/server.js +19 -19
  128. package/runtime/relay/bin.cjs +177 -42
  129. package/runtime/vercel/agentbox-checkpoint-cleanup +0 -0
  130. package/runtime/vercel/agentbox-dockerd-start +0 -0
  131. package/runtime/vercel/agentbox-open +0 -0
  132. package/runtime/vercel/agentbox-vnc-start +0 -0
  133. package/runtime/vercel/ctl.cjs +31 -4
  134. package/runtime/vercel/gh-shim +0 -0
  135. package/runtime/vercel/git-shim +0 -0
  136. package/runtime/vercel/linear-shim +0 -0
  137. package/runtime/vercel/ntn-shim +0 -0
  138. package/runtime/vercel/scripts/provision.sh +0 -0
  139. package/dist/chunk-3MDYQROX.js.map +0 -1
  140. package/dist/chunk-4HPLS5HJ.js.map +0 -1
  141. package/dist/chunk-7DPDUZ7L.js.map +0 -1
  142. package/dist/chunk-CE3S7UDQ.js.map +0 -1
  143. package/dist/chunk-H6A4BQMG.js.map +0 -1
  144. package/dist/chunk-OSPM4Q5V.js.map +0 -1
  145. package/dist/dist-2N3XHMBQ.js +0 -322
  146. package/dist/dist-2N3XHMBQ.js.map +0 -1
  147. /package/dist/{_cloud-attach-ESCPOKG5.js.map → _cloud-attach-W2CFNXKO.js.map} +0 -0
  148. /package/dist/{chunk-RFRWS5CD.js.map → chunk-4UNSBU5R.js.map} +0 -0
  149. /package/dist/{chunk-LJMGHFLZ.js.map → chunk-7PRLM3PH.js.map} +0 -0
  150. /package/dist/{chunk-5JDOTQTM.js.map → chunk-LCZOQTIX.js.map} +0 -0
  151. /package/dist/{chunk-QHISF6O6.js.map → chunk-LU3WAHTU.js.map} +0 -0
  152. /package/dist/{dist-HPPHBZTO.js.map → dist-3V5SLNK4.js.map} +0 -0
  153. /package/dist/{dist-NOUPH5E6.js.map → dist-BIDAC4H4.js.map} +0 -0
  154. /package/dist/{dist-TRKHS6I7.js.map → dist-I5OBPLP2.js.map} +0 -0
  155. /package/dist/{dist-3M53BF4E.js.map → dist-IGQNVIV3.js.map} +0 -0
  156. /package/dist/{dist-VFPT5TDH.js.map → dist-SBDYDH7H.js.map} +0 -0
  157. /package/dist/{dist-FGXCG4JY.js.map → dist-UB3PYSCG.js.map} +0 -0
  158. /package/dist/{prepared-state-BUO75YLZ-46W2PAHH.js.map → prepared-state-OBM2F7CU-DY7TZV4R.js.map} +0 -0
  159. /package/runtime/hub/apps/hub/.next/static/{43_nml7FKErUxJXpspAhb → c82uDoByt-dPQUHilRojD}/_buildManifest.js +0 -0
  160. /package/runtime/hub/apps/hub/.next/static/{43_nml7FKErUxJXpspAhb → c82uDoByt-dPQUHilRojD}/_clientMiddlewareManifest.js +0 -0
  161. /package/runtime/hub/apps/hub/.next/static/{43_nml7FKErUxJXpspAhb → c82uDoByt-dPQUHilRojD}/_ssgManifest.js +0 -0
@@ -1,4 +1,7 @@
1
1
  #!/usr/bin/env node
2
+ import {
3
+ DAYTONA_VM_REGION
4
+ } from "./chunk-5F5SOSDY.js";
2
5
  import {
3
6
  DOCKER_CONTEXT_FILE_MAP,
4
7
  claudeInstallFingerprint,
@@ -9,9 +12,9 @@ import {
9
12
  resolveContextFilesFrom,
10
13
  writeManagedSecrets,
11
14
  writePreparedStateRaw
12
- } from "./chunk-3MDYQROX.js";
15
+ } from "./chunk-Y3OPQWAQ.js";
13
16
 
14
- // ../../packages/sandbox-daytona/dist/chunk-FNG2UBRZ.js
17
+ // ../../packages/sandbox-daytona/dist/chunk-HEUB57SZ.js
15
18
  import { existsSync } from "fs";
16
19
  import { dirname, resolve } from "path";
17
20
  import { fileURLToPath } from "url";
@@ -22,7 +25,7 @@ import { createHash } from "crypto";
22
25
  import { existsSync as existsSync3 } from "fs";
23
26
  import { dirname as dirname2, resolve as resolve3 } from "path";
24
27
  import { fileURLToPath as fileURLToPath2 } from "url";
25
- import { Daytona, DaytonaNotFoundError as DaytonaNotFoundError2, Image, SandboxState } from "@daytonaio/sdk";
28
+ import { Daytona, DaytonaNotFoundError as DaytonaNotFoundError2, Image, SandboxState } from "@daytona/sdk";
26
29
  import {
27
30
  DaytonaAuthenticationError,
28
31
  DaytonaAuthorizationError,
@@ -33,7 +36,7 @@ import {
33
36
  DaytonaRateLimitError,
34
37
  DaytonaTimeoutError,
35
38
  DaytonaValidationError
36
- } from "@daytonaio/sdk";
39
+ } from "@daytona/sdk";
37
40
  import { spawnSync } from "child_process";
38
41
  import { homedir as homedir2 } from "os";
39
42
  import { resolve as resolve4 } from "path";
@@ -130,16 +133,7 @@ function parseEnvFile(body) {
130
133
  }
131
134
  var SCHEMA = 1;
132
135
  function resolveDaytonaContextFiles() {
133
- const ctx = resolveDockerfileContext();
134
- if (!ctx) return null;
135
- const here = dirname2(fileURLToPath2(import.meta.url));
136
- const packageRoot = resolve3(here, "..");
137
- const monorepoRoot = resolve3(here, "..", "..", "..");
138
- const dockerPackageRoot = resolve3(monorepoRoot, "packages", "sandbox-docker");
139
- const docker = resolveContextFilesFrom(DOCKER_CONTEXT_FILE_MAP, {
140
- contextDir: ctx.context,
141
- devRoot: existsSync3(dockerPackageRoot) ? dockerPackageRoot : packageRoot
142
- });
136
+ const docker = resolveDockerContextFilesForDaytona();
143
137
  if (!docker) return null;
144
138
  const overlay = resolveDaytonaCustomClaudeMd();
145
139
  if (!overlay) return null;
@@ -151,6 +145,23 @@ function resolveDaytonaContextFiles() {
151
145
  { rel: "daytona/custom-system-CLAUDE.md", abs: overlay }
152
146
  ];
153
147
  }
148
+ function resolveDockerContextFilesForDaytona() {
149
+ const ctx = resolveDockerfileContext();
150
+ if (!ctx) return null;
151
+ const here = dirname2(fileURLToPath2(import.meta.url));
152
+ const packageRoot = resolve3(here, "..");
153
+ const monorepoRoot = resolve3(here, "..", "..", "..");
154
+ const dockerPackageRoot = resolve3(monorepoRoot, "packages", "sandbox-docker");
155
+ return resolveContextFilesFrom(DOCKER_CONTEXT_FILE_MAP, {
156
+ contextDir: ctx.context,
157
+ devRoot: existsSync3(dockerPackageRoot) ? dockerPackageRoot : packageRoot
158
+ });
159
+ }
160
+ async function computeDockerBaseSha(claudeInstall = "native") {
161
+ const files = resolveDockerContextFilesForDaytona();
162
+ if (!files) return null;
163
+ return claudeInstallFingerprint(await computeContextSha256(files), claudeInstall);
164
+ }
154
165
  var DAYTONA_SEED_SCHEMA = "relctx-1";
155
166
  async function computeDaytonaContextFingerprint() {
156
167
  const files = resolveDaytonaContextFiles();
@@ -177,6 +188,11 @@ function readPreparedDaytonaState() {
177
188
  }
178
189
  function writePreparedDaytonaState(opts) {
179
190
  const stamp = readCliStamp();
191
+ const extras = {
192
+ ...opts.size ? { size: opts.size } : {},
193
+ ...opts.class ? { class: opts.class } : {},
194
+ ...opts.env && opts.env.length > 0 ? { env: opts.env } : {}
195
+ };
180
196
  const state = {
181
197
  schema: SCHEMA,
182
198
  base: {
@@ -186,13 +202,36 @@ function writePreparedDaytonaState(opts) {
186
202
  cliCommit: stamp.cliCommit,
187
203
  createdAt: (/* @__PURE__ */ new Date()).toISOString()
188
204
  },
189
- ...opts.size ? { extras: { size: opts.size } } : {}
205
+ ...Object.keys(extras).length > 0 ? { extras } : {}
190
206
  };
191
207
  writePreparedStateRaw("daytona", state);
192
208
  }
193
- function preparedMatches(state, current, size) {
209
+ function preparedMatches(state, current, size, sandboxClass) {
194
210
  if (state?.base?.contextSha256 !== current) return false;
195
- return (state?.extras?.size ?? void 0) === (size ?? void 0);
211
+ if ((state?.extras?.size ?? void 0) !== (size ?? void 0)) return false;
212
+ if (sandboxClass === void 0) return true;
213
+ return (state?.extras?.class ?? "container") === sandboxClass;
214
+ }
215
+ async function waitForSnapshotActive(client, name, timeoutMs = 9e5) {
216
+ const deadline = Date.now() + timeoutMs;
217
+ for (; ; ) {
218
+ let state;
219
+ try {
220
+ state = (await client.snapshot.get(name))?.state;
221
+ } catch {
222
+ state = void 0;
223
+ }
224
+ if (state === "active") return;
225
+ if (state === "error" || state === "build_failed") {
226
+ throw new Error(`daytona snapshot '${name}' ended in state '${state}'`);
227
+ }
228
+ if (Date.now() >= deadline) {
229
+ throw new Error(
230
+ `daytona snapshot '${name}' did not become active within ${String(Math.round(timeoutMs / 6e4))} min (state: ${state ?? "unknown"})`
231
+ );
232
+ }
233
+ await new Promise((r) => setTimeout(r, 3e3));
234
+ }
196
235
  }
197
236
  var DEFAULT_BACKOFF = [1e3, 2e3, 4e3];
198
237
  var DEFAULT_ATTEMPT_TIMEOUT_MS = 3e4;
@@ -297,21 +336,23 @@ function retry(method, fn, opts = {}) {
297
336
  );
298
337
  }
299
338
  var DEFAULT_BOX_IMAGE_REF = "agentbox/box:dev";
300
- var client = null;
301
- function getClient() {
302
- if (!client) {
303
- ensureDaytonaEnvLoaded();
304
- try {
305
- client = new Daytona();
306
- } catch (err) {
307
- const msg = err instanceof Error ? err.message : String(err);
308
- throw new Error(
309
- `Daytona credentials not configured: ${msg}
339
+ var DAYTONA_DEFAULT_RESOURCES = { cpu: 2, memory: 4, disk: 8 };
340
+ var clients = /* @__PURE__ */ new Map();
341
+ function getClient(target = "") {
342
+ const cached = clients.get(target);
343
+ if (cached) return cached;
344
+ ensureDaytonaEnvLoaded();
345
+ try {
346
+ const created = target.length > 0 ? new Daytona({ target }) : new Daytona();
347
+ clients.set(target, created);
348
+ return created;
349
+ } catch (err) {
350
+ const msg = err instanceof Error ? err.message : String(err);
351
+ throw new Error(
352
+ `Daytona credentials not configured: ${msg}
310
353
  Run \`agentbox daytona login\` interactively, or set DAYTONA_API_KEY in the environment.`
311
- );
312
- }
354
+ );
313
355
  }
314
- return client;
315
356
  }
316
357
  async function getSandbox(id) {
317
358
  return getClient().get(id);
@@ -334,11 +375,14 @@ function mapState(s) {
334
375
  case SandboxState.PULLING_SNAPSHOT:
335
376
  case SandboxState.PENDING_BUILD:
336
377
  case SandboxState.STOPPING:
378
+ case SandboxState.RESUMING:
337
379
  return "running";
338
380
  case SandboxState.STOPPED:
339
381
  return "stopped";
340
382
  case SandboxState.ARCHIVED:
341
383
  case SandboxState.ARCHIVING:
384
+ case SandboxState.PAUSED:
385
+ case SandboxState.PAUSING:
342
386
  return "paused";
343
387
  case SandboxState.DESTROYED:
344
388
  case SandboxState.DESTROYING:
@@ -390,17 +434,40 @@ var daytonaBackend = {
390
434
  }
391
435
  }
392
436
  const resources = sizeResources ?? req.resources;
437
+ const prepared = readPreparedDaytonaState();
438
+ const baseRef = req.snapshot ?? req.image;
439
+ const bootingPreparedBase = prepared?.base?.imageRef !== void 0 && baseRef === prepared.base.imageRef;
440
+ const imageEnv = {};
441
+ if (bootingPreparedBase) {
442
+ for (const kv of prepared.extras?.env ?? []) {
443
+ const i = kv.indexOf("=");
444
+ if (i > 0) imageEnv[kv.slice(0, i)] = kv.slice(i + 1);
445
+ }
446
+ }
393
447
  const baseParams = {
394
448
  ...resources ? { resources } : {},
395
- envVars: req.env,
449
+ envVars: { ...imageEnv, ...req.env },
396
450
  ...req.volumes && req.volumes.length > 0 ? { volumes: req.volumes.map(toDaytonaVolumeMount) } : {},
397
- labels: { "agentbox.name": req.name }
451
+ labels: { "agentbox.name": req.name },
452
+ // Daytona auto-stops a sandbox after N minutes of INACTIVITY (its own
453
+ // default is 15). The host keepalive loop pushes this forward via
454
+ // `renewTimeout` while an agent is working, so only a genuinely idle
455
+ // box lapses. 0 disables it entirely.
456
+ ...typeof req.timeoutMs === "number" ? { autoStopInterval: Math.max(0, Math.round(req.timeoutMs / 6e4)) } : {}
398
457
  };
399
- const client2 = getClient();
458
+ const bakedClass = bootingPreparedBase ? prepared.extras?.class ?? "container" : void 0;
459
+ const sandboxClass = bakedClass ?? req.sandboxClass;
460
+ if (bakedClass && req.sandboxClass && bakedClass !== req.sandboxClass) {
461
+ req.onLog?.(
462
+ `daytona: base '${baseRef ?? ""}' was baked as '${bakedClass}', so this box will be a '${bakedClass}' one (box.daytonaClass asks for '${req.sandboxClass}'). Re-bake with \`agentbox prepare --provider daytona --force\` to change it.`
463
+ );
464
+ }
465
+ const region = req.location && req.location.length > 0 ? req.location : sandboxClass === "linux-vm" ? DAYTONA_VM_REGION : "";
466
+ const client = getClient(region);
400
467
  let snapshotName = req.snapshot;
401
468
  if (!snapshotName && req.image && req.image !== DEFAULT_BOX_IMAGE_REF) {
402
469
  try {
403
- const snap = await client2.snapshot.get(req.image);
470
+ const snap = await client.snapshot.get(req.image);
404
471
  if (snap && snap.name) snapshotName = snap.name;
405
472
  } catch {
406
473
  }
@@ -408,7 +475,7 @@ var daytonaBackend = {
408
475
  const snapshotParams = { ...baseParams };
409
476
  delete snapshotParams.resources;
410
477
  if (snapshotName && sizeResources) {
411
- const bakedSize = readPreparedDaytonaState()?.extras?.size;
478
+ const bakedSize = prepared?.extras?.size;
412
479
  const requestedKey = `${String(sizeResources.cpu)}-${String(sizeResources.memory)}-${String(sizeResources.disk)}`;
413
480
  if (bakedSize !== requestedKey) {
414
481
  req.onLog?.(
@@ -416,21 +483,31 @@ var daytonaBackend = {
416
483
  );
417
484
  }
418
485
  }
419
- const sandbox = snapshotName ? await client2.create({ snapshot: snapshotName, ...snapshotParams }, { timeout: 900 }) : await client2.create(
486
+ if (!snapshotName && sandboxClass === "linux-vm") {
487
+ throw new Error(
488
+ `no linux-vm base snapshot for daytona: Daytona can only build a VM snapshot from a prebuilt image, not from a Dockerfile, so there is nothing to boot.
489
+ Run \`agentbox prepare --provider daytona\` to bake one, or set \`agentbox config set box.daytonaClass container\` to use the container class.`
490
+ );
491
+ }
492
+ const sandbox = snapshotName ? await client.create({ snapshot: snapshotName, ...snapshotParams }, { timeout: 900 }) : await client.create(
420
493
  { image: resolveImage(req.image), ...baseParams },
421
494
  {
422
495
  timeout: 900,
423
496
  ...req.onLog ? { onSnapshotCreateLogs: req.onLog } : {}
424
497
  }
425
498
  );
426
- return { sandboxId: sandbox.id };
499
+ const bootedClass = sandboxClass;
500
+ return {
501
+ sandboxId: sandbox.id,
502
+ ...bootedClass ? { sandboxClass: bootedClass } : {}
503
+ };
427
504
  },
428
505
  { retryOnAmbiguous: false, attemptTimeoutMs: 9e5 }
429
506
  );
430
507
  },
431
508
  async ensureVolume(name) {
432
- const client2 = getClient();
433
- let vol = await retry("volume.get(create)", () => client2.volume.get(name, true));
509
+ const client = getClient();
510
+ let vol = await retry("volume.get(create)", () => client.volume.get(name, true));
434
511
  const deadline = Date.now() + 6e4;
435
512
  while (vol.state !== "ready") {
436
513
  if (vol.state === "error" || vol.state === "deleted" || vol.state === "deleting") {
@@ -444,7 +521,7 @@ var daytonaBackend = {
444
521
  );
445
522
  }
446
523
  await new Promise((r) => setTimeout(r, 1e3));
447
- vol = await retry("volume.get(poll)", () => client2.volume.get(name));
524
+ vol = await retry("volume.get(poll)", () => client.volume.get(name));
448
525
  }
449
526
  return { volumeId: vol.id };
450
527
  },
@@ -456,18 +533,18 @@ var daytonaBackend = {
456
533
  },
457
534
  async list() {
458
535
  return retry("list", async () => {
459
- const client2 = getClient();
460
- const page = await client2.list();
461
- const items = Array.isArray(page) ? page : page.items ?? [];
462
- return items.map((sb) => {
536
+ const client = getClient();
537
+ const items = [];
538
+ for await (const sb of client.list()) {
463
539
  const summary = { sandboxId: sb.id };
464
540
  const raw = sb;
465
541
  const friendly = raw.labels?.["agentbox.name"] ?? raw.name;
466
542
  if (friendly) summary.name = friendly;
467
543
  if (raw.createdAt) summary.createdAt = raw.createdAt;
468
544
  if (typeof raw.state === "string") summary.state = mapState(raw.state);
469
- return summary;
470
- });
545
+ items.push(summary);
546
+ }
547
+ return items;
471
548
  });
472
549
  },
473
550
  async start(h) {
@@ -495,9 +572,25 @@ var daytonaBackend = {
495
572
  "pause",
496
573
  async () => {
497
574
  const sb = await getSandbox(h.sandboxId);
498
- await sb.archive();
575
+ const freeze = async () => {
576
+ await sb.pause();
577
+ };
578
+ const archive = async () => {
579
+ await sb.stop();
580
+ await sb.archive();
581
+ };
582
+ const preferVm = h.sandboxClass !== "container";
583
+ try {
584
+ await (preferVm ? freeze() : archive());
585
+ } catch (err) {
586
+ try {
587
+ await (preferVm ? archive() : freeze());
588
+ } catch {
589
+ throw err;
590
+ }
591
+ }
499
592
  },
500
- { attemptTimeoutMs: 6e4 }
593
+ { attemptTimeoutMs: 12e4 }
501
594
  );
502
595
  },
503
596
  async resume(h) {
@@ -510,6 +603,42 @@ var daytonaBackend = {
510
603
  { attemptTimeoutMs: 6e4 }
511
604
  );
512
605
  },
606
+ /**
607
+ * Daytona's `autoStopInterval` is an idle window that any request to the
608
+ * sandbox resets — including the host relay's own continuous preview-URL
609
+ * polling, which therefore holds every tracked box open forever. The host
610
+ * keepalive loop reads this and pauses an idle box itself instead of waiting
611
+ * for a lapse that never comes. See `CloudBackend.timeoutModel`.
612
+ */
613
+ timeoutModel: "inactivity",
614
+ /**
615
+ * Daytona's SSH gateway gives a shell session a terminal but an exec session
616
+ * none — `ssh -tt <token>@ssh.app.daytona.io 'tty'` answers "not a tty" while
617
+ * the same connection with no command lands on /dev/pts/1. So interactive
618
+ * attach connects command-less and gets its command via stdin. See
619
+ * `CloudBackend.attachExecLacksTty`.
620
+ */
621
+ attachExecLacksTty: true,
622
+ /**
623
+ * Hold off Daytona's auto-stop while the in-box agent is working.
624
+ *
625
+ * Daytona's timeout is an INACTIVITY window, not an absolute deadline like
626
+ * vercel's/e2b's, so there is nothing to extend to a target time — the box
627
+ * simply needs to look active. `refreshActivity()` resets that clock, which
628
+ * grants another full `autoStopInterval`. So both deadline args are unused:
629
+ * the host loop calls us precisely when it wants the box kept alive, and that
630
+ * call is the whole signal.
631
+ */
632
+ async renewTimeout(h) {
633
+ await retry(
634
+ "renewTimeout",
635
+ async () => {
636
+ const sb = await getSandbox(h.sandboxId);
637
+ await sb.refreshActivity();
638
+ },
639
+ { attemptTimeoutMs: 3e4 }
640
+ );
641
+ },
513
642
  async destroy(h) {
514
643
  return retry(
515
644
  "destroy",
@@ -626,7 +755,13 @@ var daytonaBackend = {
626
755
  "createSnapshot",
627
756
  async () => {
628
757
  const sb = await getSandbox(h.sandboxId);
629
- await sb._experimental_createSnapshot(snapshotName);
758
+ await sb.stop();
759
+ try {
760
+ await sb._experimental_createSnapshot(snapshotName, 900);
761
+ await waitForSnapshotActive(getClient(), snapshotName);
762
+ } finally {
763
+ await sb.start();
764
+ }
630
765
  },
631
766
  { attemptTimeoutMs: 9e5, retryOnAmbiguous: false }
632
767
  );
@@ -634,9 +769,9 @@ var daytonaBackend = {
634
769
  async deleteSnapshot(snapshotName) {
635
770
  return retry("deleteSnapshot", async () => {
636
771
  try {
637
- const client2 = getClient();
638
- const snapshot = await client2.snapshot.get(snapshotName);
639
- await client2.snapshot.delete(snapshot);
772
+ const client = getClient();
773
+ const snapshot = await client.snapshot.get(snapshotName);
774
+ await client.snapshot.delete(snapshot);
640
775
  } catch (err) {
641
776
  if (err instanceof DaytonaNotFoundError2) return;
642
777
  const msg = err instanceof Error ? err.message : String(err);
@@ -733,9 +868,9 @@ async function validateCredentials(creds) {
733
868
  const snapshot = snapshotManagedEnv();
734
869
  applyToEnv(creds);
735
870
  try {
736
- const { Daytona: Daytona2 } = await import("@daytonaio/sdk");
737
- const client2 = new Daytona2();
738
- await client2.list();
871
+ const { Daytona: Daytona2 } = await import("@daytona/sdk");
872
+ const client = new Daytona2();
873
+ await client.list();
739
874
  s.stop("Daytona credentials accepted");
740
875
  return { ok: true };
741
876
  } catch (err) {
@@ -836,12 +971,15 @@ export {
836
971
  resolveDockerfileContext,
837
972
  resolveDaytonaCustomClaudeMd,
838
973
  ensureDaytonaEnvLoaded,
974
+ computeDockerBaseSha,
839
975
  computeDaytonaContextFingerprint,
840
976
  currentDaytonaBaseFingerprintLive,
841
977
  readPreparedDaytonaState,
842
978
  writePreparedDaytonaState,
843
979
  preparedMatches,
980
+ waitForSnapshotActive,
844
981
  DEFAULT_BOX_IMAGE_REF,
982
+ DAYTONA_DEFAULT_RESOURCES,
845
983
  getClient,
846
984
  parseDaytonaSize,
847
985
  daytonaBackend,
@@ -851,4 +989,4 @@ export {
851
989
  readDaytonaCredStatus,
852
990
  maskKey
853
991
  };
854
- //# sourceMappingURL=chunk-7DPDUZ7L.js.map
992
+ //# sourceMappingURL=chunk-7C5MOA4Z.js.map