@madarco/agentbox 0.23.5 → 0.24.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 (180) hide show
  1. package/CHANGELOG.md +61 -0
  2. package/LICENSE +21 -0
  3. package/README.md +3 -2
  4. package/dist/{_cloud-attach-D4OQO5AJ.js → _cloud-attach-T6GPR6LJ.js} +5 -5
  5. package/dist/{chunk-KY32JO6J.js → chunk-5KHEH47T.js} +91 -79
  6. package/dist/chunk-5KHEH47T.js.map +1 -0
  7. package/dist/{chunk-YRTM3KNT.js → chunk-6U2S6QWD.js} +219 -18
  8. package/dist/chunk-6U2S6QWD.js.map +1 -0
  9. package/dist/{chunk-JYEZ6Q5M.js → chunk-DEDTPG2D.js} +874 -146
  10. package/dist/chunk-DEDTPG2D.js.map +1 -0
  11. package/dist/chunk-G3H2L3O2.js +0 -0
  12. package/dist/{chunk-JNY5GPIM.js → chunk-I654PBHA.js} +290 -330
  13. package/dist/chunk-I654PBHA.js.map +1 -0
  14. package/dist/{chunk-6KOQRSHH.js → chunk-K2EDQGZP.js} +18 -4
  15. package/dist/chunk-K2EDQGZP.js.map +1 -0
  16. package/dist/{chunk-KZWJMNLP.js → chunk-LC4E2EIZ.js} +3 -3
  17. package/dist/{chunk-KZWJMNLP.js.map → chunk-LC4E2EIZ.js.map} +1 -1
  18. package/dist/{chunk-DADOEMXP.js → chunk-NACA6AM7.js} +183 -49
  19. package/dist/chunk-NACA6AM7.js.map +1 -0
  20. package/dist/{chunk-FX32NZD4.js → chunk-RYQLFKCP.js} +20 -10
  21. package/dist/chunk-RYQLFKCP.js.map +1 -0
  22. package/dist/{chunk-QT3SHMLY.js → chunk-UIRBYL4G.js} +43 -12
  23. package/dist/chunk-UIRBYL4G.js.map +1 -0
  24. package/dist/chunk-WJFZJZIM.js +0 -0
  25. package/dist/chunk-WLHJZPFJ.js +845 -0
  26. package/dist/chunk-WLHJZPFJ.js.map +1 -0
  27. package/dist/cloud-poller-SUNA6ZQC-7M5LJHHE.js +0 -0
  28. package/dist/dist-3KIJ2KQ2.js +1437 -0
  29. package/dist/dist-3KIJ2KQ2.js.map +1 -0
  30. package/dist/{dist-564EDHFF.js → dist-7OUOHQPA.js} +196 -151
  31. package/dist/dist-7OUOHQPA.js.map +1 -0
  32. package/dist/{dist-CAT2TN75.js → dist-B7TNWGVG.js} +8 -4
  33. package/dist/{dist-UDQMBWYW.js → dist-KYV3LEHG.js} +10 -6
  34. package/dist/{dist-EAR4BLL2.js → dist-PHYCFYKH.js} +37 -17
  35. package/dist/dist-PHYCFYKH.js.map +1 -0
  36. package/dist/{dist-2BTJQUJS.js → dist-T5MXBZGP.js} +2 -2
  37. package/dist/{dist-O5Y4X4C5.js → dist-Z7KEPQC7.js} +6 -6
  38. package/dist/index.js +2560 -1108
  39. package/dist/index.js.map +1 -1
  40. package/dist/{prepared-state-BUO75YLZ-PW64VQMT.js → prepared-state-BUO75YLZ-RQRFFBJW.js} +2 -2
  41. package/package.json +28 -28
  42. package/runtime/_shared/agentbox-checkpoint-cleanup +0 -0
  43. package/runtime/_shared/agentbox-codex-hooks.json +1 -1
  44. package/runtime/_shared/agentbox-dockerd-start +0 -0
  45. package/runtime/_shared/agentbox-open +0 -0
  46. package/runtime/_shared/agentbox-portless-trust +0 -0
  47. package/runtime/_shared/agentbox-vnc-start +0 -0
  48. package/runtime/_shared/ctl.cjs +468 -97
  49. package/runtime/_shared/gh-shim +0 -0
  50. package/runtime/_shared/git-shim +53 -3
  51. package/runtime/_shared/linear-shim +0 -0
  52. package/runtime/_shared/ntn-shim +0 -0
  53. package/runtime/daytona/custom-system-CLAUDE.md +1 -1
  54. package/runtime/digitalocean/agentbox-checkpoint-cleanup +55 -0
  55. package/runtime/digitalocean/agentbox-codex-hooks.json +68 -0
  56. package/runtime/digitalocean/agentbox-dockerd-start +145 -0
  57. package/runtime/digitalocean/agentbox-open +28 -0
  58. package/runtime/digitalocean/agentbox-portless-trust +82 -0
  59. package/runtime/digitalocean/agentbox-setup-skill.md +317 -0
  60. package/runtime/digitalocean/agentbox-vnc-start +102 -0
  61. package/runtime/digitalocean/claude-managed-settings.json +116 -0
  62. package/runtime/digitalocean/ctl.cjs +27852 -0
  63. package/runtime/digitalocean/custom-system-CLAUDE.md +39 -0
  64. package/runtime/digitalocean/gh-shim +344 -0
  65. package/runtime/digitalocean/git-shim +181 -0
  66. package/runtime/digitalocean/linear-shim +181 -0
  67. package/runtime/digitalocean/ntn-shim +95 -0
  68. package/runtime/digitalocean/opencode-agentbox-plugin.js +76 -0
  69. package/runtime/digitalocean/scripts/install-box.sh +462 -0
  70. package/runtime/docker/Dockerfile.box +5 -0
  71. package/runtime/docker/packages/ctl/dist/bin.cjs +468 -97
  72. package/runtime/docker/packages/sandbox-docker/scripts/agentbox-checkpoint-cleanup +0 -0
  73. package/runtime/docker/packages/sandbox-docker/scripts/agentbox-codex-hooks.json +1 -1
  74. package/runtime/docker/packages/sandbox-docker/scripts/agentbox-dockerd-start +0 -0
  75. package/runtime/docker/packages/sandbox-docker/scripts/agentbox-open +0 -0
  76. package/runtime/docker/packages/sandbox-docker/scripts/agentbox-portless-trust +0 -0
  77. package/runtime/docker/packages/sandbox-docker/scripts/agentbox-sshd-start +0 -0
  78. package/runtime/docker/packages/sandbox-docker/scripts/agentbox-vnc-start +0 -0
  79. package/runtime/docker/packages/sandbox-docker/scripts/chromium-resolver +0 -0
  80. package/runtime/docker/packages/sandbox-docker/scripts/custom-system-CLAUDE.md +2 -1
  81. package/runtime/docker/packages/sandbox-docker/scripts/gh-shim +0 -0
  82. package/runtime/docker/packages/sandbox-docker/scripts/git-shim +53 -3
  83. package/runtime/docker/packages/sandbox-docker/scripts/linear-shim +0 -0
  84. package/runtime/docker/packages/sandbox-docker/scripts/ntn-shim +0 -0
  85. package/runtime/e2b/agentbox-checkpoint-cleanup +0 -0
  86. package/runtime/e2b/agentbox-codex-hooks.json +1 -1
  87. package/runtime/e2b/agentbox-dockerd-start +0 -0
  88. package/runtime/e2b/agentbox-open +0 -0
  89. package/runtime/e2b/agentbox-vnc-start +0 -0
  90. package/runtime/e2b/ctl.cjs +468 -97
  91. package/runtime/e2b/custom-system-CLAUDE.md +6 -3
  92. package/runtime/e2b/gh-shim +0 -0
  93. package/runtime/e2b/git-shim +53 -3
  94. package/runtime/e2b/linear-shim +0 -0
  95. package/runtime/e2b/ntn-shim +0 -0
  96. package/runtime/e2b/scripts/build-template.sh +16 -0
  97. package/runtime/hetzner/agentbox-checkpoint-cleanup +0 -0
  98. package/runtime/hetzner/agentbox-codex-hooks.json +1 -1
  99. package/runtime/hetzner/agentbox-dockerd-start +0 -0
  100. package/runtime/hetzner/agentbox-open +0 -0
  101. package/runtime/hetzner/agentbox-portless-trust +0 -0
  102. package/runtime/hetzner/agentbox-vnc-start +0 -0
  103. package/runtime/hetzner/ctl.cjs +468 -97
  104. package/runtime/hetzner/custom-system-CLAUDE.md +1 -1
  105. package/runtime/hetzner/gh-shim +0 -0
  106. package/runtime/hetzner/git-shim +53 -3
  107. package/runtime/hetzner/linear-shim +0 -0
  108. package/runtime/hetzner/ntn-shim +0 -0
  109. package/runtime/hetzner/scripts/install-box.sh +5 -0
  110. package/runtime/hub/apps/hub/.next/BUILD_ID +1 -1
  111. package/runtime/hub/apps/hub/.next/build-manifest.json +3 -3
  112. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/settings/page_client-reference-manifest.js +1 -1
  113. package/runtime/hub/apps/hub/.next/server/app/_global-error.html +1 -1
  114. package/runtime/hub/apps/hub/.next/server/app/_global-error.rsc +1 -1
  115. package/runtime/hub/apps/hub/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
  116. package/runtime/hub/apps/hub/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  117. package/runtime/hub/apps/hub/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
  118. package/runtime/hub/apps/hub/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
  119. package/runtime/hub/apps/hub/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  120. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0d1lmiq._.js +12 -12
  121. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0keu6we._.js +1 -1
  122. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1bqbkd5._.js +1 -1
  123. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1qa4a0v._.js +1 -1
  124. package/runtime/hub/apps/hub/.next/server/chunks/_0760z6y._.js +8 -8
  125. package/runtime/hub/apps/hub/.next/server/chunks/ssr/_0ro6vh6._.js +1 -1
  126. package/runtime/hub/apps/hub/.next/server/chunks/ssr/apps_hub_0b_hsjl._.js +1 -1
  127. package/runtime/hub/apps/hub/.next/server/middleware-build-manifest.js +3 -3
  128. package/runtime/hub/apps/hub/.next/server/pages/500.html +1 -1
  129. package/runtime/hub/apps/hub/.next/static/chunks/380qcmusmigzz.js +1 -0
  130. package/runtime/hub/apps/hub/{auth-675P3LQS.js → auth-Q447765C.js} +2 -2
  131. package/runtime/hub/apps/hub/{auth-config-AOBEKRZQ.js → auth-config-SIL635ZD.js} +2 -2
  132. package/runtime/hub/apps/hub/{chunk-FSEPYTQ6.js → chunk-3VE7AYVK.js} +594 -145
  133. package/runtime/hub/apps/hub/{chunk-EXQCBM5Q.js → chunk-64WEKO34.js} +42 -11
  134. package/runtime/hub/apps/hub/{chunk-56YQBVN2.js → chunk-DZPQB2JZ.js} +1 -1
  135. package/runtime/hub/apps/hub/{chunk-7M6FXZIO.js → chunk-FGBXEXUV.js} +350 -292
  136. package/runtime/hub/apps/hub/{chunk-Z7ZAL24C.js → chunk-YVELHPNY.js} +218 -17
  137. package/runtime/hub/apps/hub/{dist-EKQHCXWE.js → dist-33ZNVTC6.js} +183 -49
  138. package/runtime/hub/apps/hub/{dist-V4TJ44MT.js → dist-4SXAJBOC.js} +195 -150
  139. package/runtime/hub/apps/hub/{dist-QIXUPGPP.js → dist-EPJFN2J3.js} +116 -86
  140. package/runtime/hub/apps/hub/{dist-STQK5XM6.js → dist-GF5EBRNG.js} +1 -1
  141. package/runtime/hub/apps/hub/{dist-JGZ55OIJ.js → dist-UJVIROA4.js} +19 -5
  142. package/runtime/hub/apps/hub/dist-XULFTIMT.js +2212 -0
  143. package/runtime/hub/apps/hub/{dist-GGWYKXJE.js → dist-YM5J25H6.js} +7 -3
  144. package/runtime/hub/apps/hub/{hub-token-2BZFBBW3.js → hub-token-UITZEWVP.js} +2 -2
  145. package/runtime/hub/apps/hub/package.json +1 -0
  146. package/runtime/hub/apps/hub/{prepared-state-BUO75YLZ-UICXTY25.js → prepared-state-BUO75YLZ-O4GZMDRF.js} +1 -1
  147. package/runtime/hub/apps/hub/server.js +17 -15
  148. package/runtime/relay/bin.cjs +275 -59
  149. package/runtime/vercel/agentbox-checkpoint-cleanup +0 -0
  150. package/runtime/vercel/agentbox-codex-hooks.json +1 -1
  151. package/runtime/vercel/agentbox-dockerd-start +0 -0
  152. package/runtime/vercel/agentbox-open +0 -0
  153. package/runtime/vercel/agentbox-vnc-start +0 -0
  154. package/runtime/vercel/ctl.cjs +468 -97
  155. package/runtime/vercel/custom-system-CLAUDE.md +3 -2
  156. package/runtime/vercel/gh-shim +0 -0
  157. package/runtime/vercel/git-shim +53 -3
  158. package/runtime/vercel/linear-shim +0 -0
  159. package/runtime/vercel/ntn-shim +0 -0
  160. package/runtime/vercel/scripts/provision.sh +16 -0
  161. package/dist/chunk-6KOQRSHH.js.map +0 -1
  162. package/dist/chunk-DADOEMXP.js.map +0 -1
  163. package/dist/chunk-FX32NZD4.js.map +0 -1
  164. package/dist/chunk-JNY5GPIM.js.map +0 -1
  165. package/dist/chunk-JYEZ6Q5M.js.map +0 -1
  166. package/dist/chunk-KY32JO6J.js.map +0 -1
  167. package/dist/chunk-QT3SHMLY.js.map +0 -1
  168. package/dist/chunk-YRTM3KNT.js.map +0 -1
  169. package/dist/dist-564EDHFF.js.map +0 -1
  170. package/dist/dist-EAR4BLL2.js.map +0 -1
  171. package/runtime/hub/apps/hub/.next/static/chunks/0joh_xsiowfc4.js +0 -1
  172. /package/dist/{_cloud-attach-D4OQO5AJ.js.map → _cloud-attach-T6GPR6LJ.js.map} +0 -0
  173. /package/dist/{dist-2BTJQUJS.js.map → dist-B7TNWGVG.js.map} +0 -0
  174. /package/dist/{dist-CAT2TN75.js.map → dist-KYV3LEHG.js.map} +0 -0
  175. /package/dist/{dist-O5Y4X4C5.js.map → dist-T5MXBZGP.js.map} +0 -0
  176. /package/dist/{dist-UDQMBWYW.js.map → dist-Z7KEPQC7.js.map} +0 -0
  177. /package/dist/{prepared-state-BUO75YLZ-PW64VQMT.js.map → prepared-state-BUO75YLZ-RQRFFBJW.js.map} +0 -0
  178. /package/runtime/hub/apps/hub/.next/static/{lOi70Di6lcnEBsUUHKrQ5 → XtIjHGqvY4mQsOY2-m1Jy}/_buildManifest.js +0 -0
  179. /package/runtime/hub/apps/hub/.next/static/{lOi70Di6lcnEBsUUHKrQ5 → XtIjHGqvY4mQsOY2-m1Jy}/_clientMiddlewareManifest.js +0 -0
  180. /package/runtime/hub/apps/hub/.next/static/{lOi70Di6lcnEBsUUHKrQ5 → XtIjHGqvY4mQsOY2-m1Jy}/_ssgManifest.js +0 -0
@@ -18,8 +18,8 @@ import {
18
18
  renderInnerCommand,
19
19
  resolveCloudCheckpoint,
20
20
  writeCloudCheckpointManifest
21
- } from "./chunk-Z7ZAL24C.js";
22
- import "./chunk-7M6FXZIO.js";
21
+ } from "./chunk-YVELHPNY.js";
22
+ import "./chunk-FGBXEXUV.js";
23
23
  import "./chunk-3LAHFDJF.js";
24
24
  import {
25
25
  UserFacingError,
@@ -34,12 +34,12 @@ import {
34
34
  stageAllAgentStatic,
35
35
  writeManagedSecrets,
36
36
  writePreparedStateRaw
37
- } from "./chunk-FSEPYTQ6.js";
37
+ } from "./chunk-3VE7AYVK.js";
38
38
  import "./chunk-EFW34I43.js";
39
- import "./chunk-EXQCBM5Q.js";
39
+ import "./chunk-64WEKO34.js";
40
40
  import "./chunk-TZFWAJVB.js";
41
41
 
42
- // ../../packages/sandbox-e2b/dist/chunk-4FOXSEPX.js
42
+ // ../../packages/sandbox-e2b/dist/chunk-WQRH5SXA.js
43
43
  import { existsSync, readFileSync } from "fs";
44
44
  import { homedir } from "os";
45
45
  import { resolve } from "path";
@@ -421,6 +421,182 @@ function errorSummary(err) {
421
421
  function truncate(s, max = 160) {
422
422
  return s.length > max ? `${s.slice(0, max)}\u2026` : s;
423
423
  }
424
+ var TEMPLATE_NAME = "agentbox-base:latest";
425
+ var DEFAULT_TAG = "latest";
426
+ var DEFAULT_CPU = 2;
427
+ var DEFAULT_MEMORY_MB = 4096;
428
+ function parseE2bSize(spec, warn) {
429
+ const trimmed = (spec ?? "").trim();
430
+ if (trimmed === "") return void 0;
431
+ const parts = trimmed.split("-");
432
+ const bad = () => {
433
+ throw new Error(
434
+ `invalid --size '${trimmed}' for e2b: expected 'cpu-memory' GB, e.g. '4-8'.`
435
+ );
436
+ };
437
+ if (parts.length < 2 || parts.length > 3) bad();
438
+ const nums = parts.map((p) => Number(p));
439
+ if (nums.some((n) => !Number.isInteger(n) || n <= 0)) bad();
440
+ if (parts.length === 3) {
441
+ warn?.(
442
+ `e2b: ignoring the disk slot in size '${trimmed}' \u2014 E2B templates have no disk knob; only cpu-memory (${String(nums[0])}-${String(nums[1])}) is applied.`
443
+ );
444
+ }
445
+ return { cpuCount: nums[0], memoryMB: nums[1] * 1024 };
446
+ }
447
+ function e2bSizeKey(parsed) {
448
+ return `${String(parsed.cpuCount)}-${String(parsed.memoryMB / 1024)}`;
449
+ }
450
+ async function prepareE2b(opts = {}) {
451
+ await ensureE2bCredentials();
452
+ const apiKey = resolveApiKey();
453
+ const log = opts.onLog ?? (() => {
454
+ });
455
+ const progress = (s) => log(`prepare-e2b: ${s}`);
456
+ const assets = resolveRuntimeAssets({
457
+ cliRuntimeRoot: opts.cliRuntimeRoot ?? findStagedCliRuntimeRoot(),
458
+ repoRoot: opts.repoRoot
459
+ });
460
+ const claudeInstall = opts.claudeInstall ?? "native";
461
+ const contextSha = claudeInstallFingerprint(
462
+ await computeContextSha256(assets.map((a) => ({ rel: a.name, abs: a.localPath }))),
463
+ claudeInstall
464
+ );
465
+ const parsedSize = parseE2bSize(opts.size, (m) => log(m));
466
+ const sizeKey = parsedSize ? e2bSizeKey(parsedSize) : void 0;
467
+ const existing = readPreparedState();
468
+ if (!opts.force && existing.base) {
469
+ const bakedSize = existing.base.size;
470
+ if (existing.base.contextSha256 === contextSha && bakedSize === sizeKey) {
471
+ const stillThere = await templateExists(existing.base.templateId, apiKey);
472
+ if (stillThere) {
473
+ progress(
474
+ `template ${existing.base.templateId} already exists (fingerprint ${contextSha.slice(0, 12)} matches); skipping (pass --force to rebuild)`
475
+ );
476
+ return { snapshotName: existing.base.templateId };
477
+ }
478
+ progress(`recorded template ${existing.base.templateId} is gone on E2B; rebuilding`);
479
+ } else if (existing.base.contextSha256 === contextSha && bakedSize !== sizeKey) {
480
+ progress(
481
+ `size changed (was ${bakedSize ?? "default"}, now ${sizeKey ?? "default"}); rebuilding`
482
+ );
483
+ } else {
484
+ progress(
485
+ `build context changed (was ${existing.base.contextSha256?.slice(0, 12) ?? "<none>"}, now ${contextSha.slice(0, 12)}); rebuilding`
486
+ );
487
+ }
488
+ }
489
+ const contextDir = await mkdtemp(join(tmpdir(), "agentbox-e2b-build-"));
490
+ let agentStages = [];
491
+ try {
492
+ progress(`staging build context at ${contextDir}`);
493
+ await stageAssetsInto(contextDir, assets);
494
+ agentStages = await stageAllAgentStatic({ hostWorkspace: opts.hostWorkspace });
495
+ for (const s of agentStages) for (const w of s.staged.warnings) log(w);
496
+ const usableStages = agentStages.filter((s) => s.staged.tarballPath !== null);
497
+ for (const s of usableStages) {
498
+ await copyFile(s.staged.tarballPath, resolve4(contextDir, e2bStagePaths(s.kind).contextRel));
499
+ }
500
+ progress("assembling template build (fromBaseImage + asset copy + runCmd)");
501
+ const template = Template({ fileContextPath: contextDir }).fromBaseImage();
502
+ for (const a of assets) {
503
+ progress(` copy ${a.name} -> ${a.remotePath}`);
504
+ template.copy(a.name, a.remotePath, {
505
+ forceUpload: true,
506
+ mode: a.remoteMode,
507
+ user: "root"
508
+ });
509
+ }
510
+ template.runCmd(`AGENTBOX_CLAUDE_INSTALL=${claudeInstall} bash /tmp/agentbox-build-template.sh 2>&1`, {
511
+ user: "root"
512
+ });
513
+ for (const s of usableStages) {
514
+ const { contextRel, remoteTar } = e2bStagePaths(s.kind);
515
+ progress(` seed ${s.kind} static -> ${s.extractDir}`);
516
+ template.copy(contextRel, remoteTar, { forceUpload: true, mode: 420, user: "root" });
517
+ }
518
+ if (usableStages.length > 0) {
519
+ const extract = usableStages.map((s) => `mkdir -p ${s.extractDir} && tar -xzf ${e2bStagePaths(s.kind).remoteTar} -C ${s.extractDir} --no-same-permissions --no-same-owner -m`).join(" && ") + " && chown -R vscode:vscode /home/vscode/.claude /home/vscode/.codex /home/vscode/.local && ([ -d /home/vscode/.agents ] && chown -R vscode:vscode /home/vscode/.agents || true) && rm -f /tmp/agentbox-seed-*.tar.gz";
520
+ template.runCmd(extract, { user: "root" });
521
+ }
522
+ const finalTemplate = template.setReadyCmd(
523
+ "test -x /usr/local/bin/agentbox-ctl"
524
+ );
525
+ const cpuCount = parsedSize?.cpuCount ?? opts.cpuCount ?? DEFAULT_CPU;
526
+ const memoryMB = parsedSize?.memoryMB ?? opts.memoryMB ?? DEFAULT_MEMORY_MB;
527
+ progress(
528
+ `running Template.build('${TEMPLATE_NAME}', { cpuCount: ${String(cpuCount)}, memoryMB: ${String(memoryMB)} })`
529
+ );
530
+ const info = await Template.build(finalTemplate, TEMPLATE_NAME, {
531
+ apiKey,
532
+ cpuCount,
533
+ memoryMB,
534
+ onBuildLogs: (entry) => {
535
+ log(`[build] ${formatBuildLog(entry)}`);
536
+ }
537
+ });
538
+ progress(`template built: id=${info.templateId} build=${info.buildId} name=${info.name}`);
539
+ const tag = info.tags?.[0] ?? DEFAULT_TAG;
540
+ const cliStamp = readCliStamp();
541
+ const taggedId = `${info.templateId}:${tag}`;
542
+ writePreparedState({
543
+ schema: 1,
544
+ base: {
545
+ templateId: taggedId,
546
+ // info.name is the full `name:tag` pair Template.build() was called
547
+ // with (e.g. `agentbox-base:latest`). Earlier code re-appended `:${tag}`
548
+ // and produced `agentbox-base:latest:latest` in the status display.
549
+ templateName: info.name,
550
+ contextSha256: contextSha,
551
+ ...sizeKey ? { size: sizeKey } : {},
552
+ cliVersion: cliStamp.cliVersion,
553
+ cliCommit: cliStamp.cliCommit,
554
+ createdAt: (/* @__PURE__ */ new Date()).toISOString()
555
+ }
556
+ });
557
+ progress(`wrote ${preparedStatePath()}`);
558
+ progress(`prepare complete \u2014 base template ${taggedId}`);
559
+ return { snapshotName: taggedId };
560
+ } finally {
561
+ await Promise.all(agentStages.map((s) => s.staged.cleanup())).catch(() => {
562
+ });
563
+ await rm(contextDir, { recursive: true, force: true }).catch(() => {
564
+ });
565
+ }
566
+ }
567
+ async function stageAssetsInto(contextDir, assets) {
568
+ for (const a of assets) {
569
+ const dest = resolve4(contextDir, a.name);
570
+ await mkdir(dirname2(dest), { recursive: true });
571
+ await copyFile(a.localPath, dest);
572
+ }
573
+ }
574
+ function e2bStagePaths(kind) {
575
+ return {
576
+ contextRel: `agentbox-seed-${kind}.tar.gz`,
577
+ remoteTar: `/tmp/agentbox-seed-${kind}.tar.gz`
578
+ };
579
+ }
580
+ async function templateExists(name, apiKey) {
581
+ try {
582
+ return await Template.exists(name, { apiKey });
583
+ } catch {
584
+ return false;
585
+ }
586
+ }
587
+ function formatBuildLog(entry) {
588
+ const raw = typeof entry.message === "string" ? entry.message : entry.toString();
589
+ const cleaned = raw.replace(/\r?\n+$/, "");
590
+ return cleaned.length > 200 ? cleaned.slice(0, 200) + "\u2026" : cleaned;
591
+ }
592
+ var prepareE2bProvider = (req) => prepareE2b({
593
+ name: req.name,
594
+ hostWorkspace: req.hostWorkspace ?? process.cwd(),
595
+ force: req.force,
596
+ size: req.size,
597
+ claudeInstall: req.claudeInstall,
598
+ onLog: req.onLog
599
+ });
424
600
  var DEFAULT_BOX_IMAGE_REF = "agentbox/box:dev";
425
601
  var BOX_USER = "vscode";
426
602
  var BOX_OWNER = "vscode:vscode";
@@ -476,6 +652,20 @@ var e2bBackend = {
476
652
  "e2b provision: no template available \u2014 `agentbox prepare --provider e2b` must run first"
477
653
  );
478
654
  }
655
+ if (req.size && req.size.trim().length > 0) {
656
+ let requestedKey;
657
+ try {
658
+ const parsed = parseE2bSize(req.size);
659
+ if (parsed) requestedKey = `${String(parsed.cpuCount)}-${String(parsed.memoryMB / 1024)}`;
660
+ } catch {
661
+ }
662
+ const bakedSize = readPreparedState().base?.size;
663
+ if (requestedKey && requestedKey !== bakedSize) {
664
+ log(
665
+ `e2b: WARNING \u2014 size '${requestedKey}' is ignored at create time; this template was baked at ${bakedSize ?? "the default size"}. E2B resources are fixed at bake time \u2014 re-bake with \`agentbox prepare --provider e2b --size ${requestedKey} --force\` to change them.`
666
+ );
667
+ }
668
+ }
479
669
  const sb = await withE2bRetry(
480
670
  { method: "provision", retryOnAmbiguous: false, attemptTimeoutMs: 3e5, backoffMs: [] },
481
671
  async () => Sandbox.create({
@@ -687,151 +877,6 @@ var e2bBackend = {
687
877
  });
688
878
  }
689
879
  };
690
- var TEMPLATE_NAME = "agentbox-base:latest";
691
- var DEFAULT_TAG = "latest";
692
- var DEFAULT_CPU = 2;
693
- var DEFAULT_MEMORY_MB = 4096;
694
- async function prepareE2b(opts = {}) {
695
- await ensureE2bCredentials();
696
- const apiKey = resolveApiKey();
697
- const log = opts.onLog ?? (() => {
698
- });
699
- const progress = (s) => log(`prepare-e2b: ${s}`);
700
- const assets = resolveRuntimeAssets({
701
- cliRuntimeRoot: opts.cliRuntimeRoot ?? findStagedCliRuntimeRoot(),
702
- repoRoot: opts.repoRoot
703
- });
704
- const claudeInstall = opts.claudeInstall ?? "native";
705
- const contextSha = claudeInstallFingerprint(
706
- await computeContextSha256(assets.map((a) => ({ rel: a.name, abs: a.localPath }))),
707
- claudeInstall
708
- );
709
- const existing = readPreparedState();
710
- if (!opts.force && existing.base) {
711
- if (existing.base.contextSha256 === contextSha) {
712
- const stillThere = await templateExists(existing.base.templateId, apiKey);
713
- if (stillThere) {
714
- progress(
715
- `template ${existing.base.templateId} already exists (fingerprint ${contextSha.slice(0, 12)} matches); skipping (pass --force to rebuild)`
716
- );
717
- return { snapshotName: existing.base.templateId };
718
- }
719
- progress(`recorded template ${existing.base.templateId} is gone on E2B; rebuilding`);
720
- } else {
721
- progress(
722
- `build context changed (was ${existing.base.contextSha256?.slice(0, 12) ?? "<none>"}, now ${contextSha.slice(0, 12)}); rebuilding`
723
- );
724
- }
725
- }
726
- const contextDir = await mkdtemp(join(tmpdir(), "agentbox-e2b-build-"));
727
- let agentStages = [];
728
- try {
729
- progress(`staging build context at ${contextDir}`);
730
- await stageAssetsInto(contextDir, assets);
731
- agentStages = await stageAllAgentStatic({ hostWorkspace: opts.hostWorkspace });
732
- for (const s of agentStages) for (const w of s.staged.warnings) log(w);
733
- const usableStages = agentStages.filter((s) => s.staged.tarballPath !== null);
734
- for (const s of usableStages) {
735
- await copyFile(s.staged.tarballPath, resolve4(contextDir, e2bStagePaths(s.kind).contextRel));
736
- }
737
- progress("assembling template build (fromBaseImage + asset copy + runCmd)");
738
- const template = Template({ fileContextPath: contextDir }).fromBaseImage();
739
- for (const a of assets) {
740
- progress(` copy ${a.name} -> ${a.remotePath}`);
741
- template.copy(a.name, a.remotePath, {
742
- forceUpload: true,
743
- mode: a.remoteMode,
744
- user: "root"
745
- });
746
- }
747
- template.runCmd(`AGENTBOX_CLAUDE_INSTALL=${claudeInstall} bash /tmp/agentbox-build-template.sh 2>&1`, {
748
- user: "root"
749
- });
750
- for (const s of usableStages) {
751
- const { contextRel, remoteTar } = e2bStagePaths(s.kind);
752
- progress(` seed ${s.kind} static -> ${s.extractDir}`);
753
- template.copy(contextRel, remoteTar, { forceUpload: true, mode: 420, user: "root" });
754
- }
755
- if (usableStages.length > 0) {
756
- const extract = usableStages.map((s) => `mkdir -p ${s.extractDir} && tar -xzf ${e2bStagePaths(s.kind).remoteTar} -C ${s.extractDir} --no-same-permissions --no-same-owner -m`).join(" && ") + " && chown -R vscode:vscode /home/vscode/.claude /home/vscode/.codex /home/vscode/.local && ([ -d /home/vscode/.agents ] && chown -R vscode:vscode /home/vscode/.agents || true) && rm -f /tmp/agentbox-seed-*.tar.gz";
757
- template.runCmd(extract, { user: "root" });
758
- }
759
- const finalTemplate = template.setReadyCmd(
760
- "test -x /usr/local/bin/agentbox-ctl"
761
- );
762
- const cpuCount = opts.cpuCount ?? DEFAULT_CPU;
763
- const memoryMB = opts.memoryMB ?? DEFAULT_MEMORY_MB;
764
- progress(
765
- `running Template.build('${TEMPLATE_NAME}', { cpuCount: ${String(cpuCount)}, memoryMB: ${String(memoryMB)} })`
766
- );
767
- const info = await Template.build(finalTemplate, TEMPLATE_NAME, {
768
- apiKey,
769
- cpuCount,
770
- memoryMB,
771
- onBuildLogs: (entry) => {
772
- log(`[build] ${formatBuildLog(entry)}`);
773
- }
774
- });
775
- progress(`template built: id=${info.templateId} build=${info.buildId} name=${info.name}`);
776
- const tag = info.tags?.[0] ?? DEFAULT_TAG;
777
- const cliStamp = readCliStamp();
778
- const taggedId = `${info.templateId}:${tag}`;
779
- writePreparedState({
780
- schema: 1,
781
- base: {
782
- templateId: taggedId,
783
- // info.name is the full `name:tag` pair Template.build() was called
784
- // with (e.g. `agentbox-base:latest`). Earlier code re-appended `:${tag}`
785
- // and produced `agentbox-base:latest:latest` in the status display.
786
- templateName: info.name,
787
- contextSha256: contextSha,
788
- cliVersion: cliStamp.cliVersion,
789
- cliCommit: cliStamp.cliCommit,
790
- createdAt: (/* @__PURE__ */ new Date()).toISOString()
791
- }
792
- });
793
- progress(`wrote ${preparedStatePath()}`);
794
- progress(`prepare complete \u2014 base template ${taggedId}`);
795
- return { snapshotName: taggedId };
796
- } finally {
797
- await Promise.all(agentStages.map((s) => s.staged.cleanup())).catch(() => {
798
- });
799
- await rm(contextDir, { recursive: true, force: true }).catch(() => {
800
- });
801
- }
802
- }
803
- async function stageAssetsInto(contextDir, assets) {
804
- for (const a of assets) {
805
- const dest = resolve4(contextDir, a.name);
806
- await mkdir(dirname2(dest), { recursive: true });
807
- await copyFile(a.localPath, dest);
808
- }
809
- }
810
- function e2bStagePaths(kind) {
811
- return {
812
- contextRel: `agentbox-seed-${kind}.tar.gz`,
813
- remoteTar: `/tmp/agentbox-seed-${kind}.tar.gz`
814
- };
815
- }
816
- async function templateExists(name, apiKey) {
817
- try {
818
- return await Template.exists(name, { apiKey });
819
- } catch {
820
- return false;
821
- }
822
- }
823
- function formatBuildLog(entry) {
824
- const raw = typeof entry.message === "string" ? entry.message : entry.toString();
825
- const cleaned = raw.replace(/\r?\n+$/, "");
826
- return cleaned.length > 200 ? cleaned.slice(0, 200) + "\u2026" : cleaned;
827
- }
828
- var prepareE2bProvider = (req) => prepareE2b({
829
- name: req.name,
830
- hostWorkspace: req.hostWorkspace ?? process.cwd(),
831
- force: req.force,
832
- claudeInstall: req.claudeInstall,
833
- onLog: req.onLog
834
- });
835
880
  var SELF2 = dirname22(fileURLToPath2(import.meta.url));
836
881
  function resolveAttachHelperPath() {
837
882
  const candidates = [
@@ -13,8 +13,8 @@ import {
13
13
  } from "./chunk-OF242BLD.js";
14
14
  import {
15
15
  createCloudProvider
16
- } from "./chunk-Z7ZAL24C.js";
17
- import "./chunk-7M6FXZIO.js";
16
+ } from "./chunk-YVELHPNY.js";
17
+ import "./chunk-FGBXEXUV.js";
18
18
  import "./chunk-3LAHFDJF.js";
19
19
  import {
20
20
  DOCKER_CONTEXT_FILE_MAP,
@@ -28,18 +28,22 @@ import {
28
28
  stageAllAgentStatic,
29
29
  writeManagedSecrets,
30
30
  writePreparedStateRaw
31
- } from "./chunk-FSEPYTQ6.js";
31
+ } from "./chunk-3VE7AYVK.js";
32
32
  import "./chunk-EFW34I43.js";
33
- import "./chunk-EXQCBM5Q.js";
33
+ import "./chunk-64WEKO34.js";
34
34
  import "./chunk-TZFWAJVB.js";
35
35
 
36
- // ../../packages/sandbox-daytona/dist/chunk-6WHCUMQO.js
36
+ // ../../packages/sandbox-daytona/dist/chunk-FNG2UBRZ.js
37
37
  import { existsSync } from "fs";
38
38
  import { dirname, resolve } from "path";
39
39
  import { fileURLToPath } from "url";
40
40
  import { existsSync as existsSync2, readFileSync } from "fs";
41
41
  import { homedir } from "os";
42
42
  import { resolve as resolve2 } from "path";
43
+ import { createHash } from "crypto";
44
+ import { existsSync as existsSync3 } from "fs";
45
+ import { dirname as dirname2, resolve as resolve3 } from "path";
46
+ import { fileURLToPath as fileURLToPath2 } from "url";
43
47
  import { Daytona, DaytonaNotFoundError as DaytonaNotFoundError2, Image, SandboxState } from "@daytonaio/sdk";
44
48
  import {
45
49
  DaytonaAuthenticationError,
@@ -54,11 +58,7 @@ import {
54
58
  } from "@daytonaio/sdk";
55
59
  import { spawnSync } from "child_process";
56
60
  import { homedir as homedir2 } from "os";
57
- import { resolve as resolve3 } from "path";
58
- import { createHash } from "crypto";
59
- import { existsSync as existsSync3 } from "fs";
60
- import { dirname as dirname2, resolve as resolve4 } from "path";
61
- import { fileURLToPath as fileURLToPath2 } from "url";
61
+ import { resolve as resolve4 } from "path";
62
62
  function resolveDockerfileContext() {
63
63
  const override = process.env.AGENTBOX_DOCKER_CONTEXT;
64
64
  if (override && existsSync(resolve(override, "Dockerfile.box"))) {
@@ -138,6 +138,72 @@ function parseEnvFile(body) {
138
138
  }
139
139
  return out;
140
140
  }
141
+ var SCHEMA = 1;
142
+ function resolveDaytonaContextFiles() {
143
+ const ctx = resolveDockerfileContext();
144
+ if (!ctx) return null;
145
+ const here = dirname2(fileURLToPath2(import.meta.url));
146
+ const packageRoot = resolve3(here, "..");
147
+ const monorepoRoot = resolve3(here, "..", "..", "..");
148
+ const dockerPackageRoot = resolve3(monorepoRoot, "packages", "sandbox-docker");
149
+ const docker = resolveContextFilesFrom(DOCKER_CONTEXT_FILE_MAP, {
150
+ contextDir: ctx.context,
151
+ devRoot: existsSync3(dockerPackageRoot) ? dockerPackageRoot : packageRoot
152
+ });
153
+ if (!docker) return null;
154
+ const overlay = resolveDaytonaCustomClaudeMd();
155
+ if (!overlay) return null;
156
+ return [
157
+ ...docker,
158
+ // Daytona-specific overlay: separate logical name so a docker/daytona
159
+ // CLAUDE.md drift produces different fingerprints (the daytona snapshot
160
+ // contains both files in distinct locations).
161
+ { rel: "daytona/custom-system-CLAUDE.md", abs: overlay }
162
+ ];
163
+ }
164
+ var DAYTONA_SEED_SCHEMA = "relctx-1";
165
+ async function computeDaytonaContextFingerprint() {
166
+ const files = resolveDaytonaContextFiles();
167
+ if (!files) return null;
168
+ const rawSha = await computeContextSha256(files);
169
+ const contextSha256 = createHash("sha256").update(`${rawSha}\0daytona-seed=${DAYTONA_SEED_SCHEMA}`).digest("hex");
170
+ return { contextSha256, files };
171
+ }
172
+ async function currentDaytonaBaseFingerprintLive(claudeInstall = "native") {
173
+ try {
174
+ const fp = await computeDaytonaContextFingerprint();
175
+ if (!fp?.contextSha256) return void 0;
176
+ return claudeInstallFingerprint(fp.contextSha256, claudeInstall);
177
+ } catch {
178
+ return void 0;
179
+ }
180
+ }
181
+ function readPreparedDaytonaState() {
182
+ const raw = readPreparedStateRaw("daytona");
183
+ if (raw === null || typeof raw !== "object") return null;
184
+ const parsed = raw;
185
+ if (parsed.schema !== SCHEMA) return null;
186
+ return { schema: SCHEMA, base: parsed.base, extras: parsed.extras };
187
+ }
188
+ function writePreparedDaytonaState(opts) {
189
+ const stamp = readCliStamp();
190
+ const state = {
191
+ schema: SCHEMA,
192
+ base: {
193
+ imageRef: opts.snapshotName,
194
+ contextSha256: opts.contextSha256,
195
+ cliVersion: stamp.cliVersion,
196
+ cliCommit: stamp.cliCommit,
197
+ createdAt: (/* @__PURE__ */ new Date()).toISOString()
198
+ },
199
+ ...opts.size ? { extras: { size: opts.size } } : {}
200
+ };
201
+ writePreparedStateRaw("daytona", state);
202
+ }
203
+ function preparedMatches(state, current, size) {
204
+ if (state?.base?.contextSha256 !== current) return false;
205
+ return (state?.extras?.size ?? void 0) === (size ?? void 0);
206
+ }
141
207
  var DEFAULT_BACKOFF = [1e3, 2e3, 4e3];
142
208
  var DEFAULT_ATTEMPT_TIMEOUT_MS = 3e4;
143
209
  var AttemptTimeoutError = class extends Error {
@@ -351,6 +417,15 @@ var daytonaBackend = {
351
417
  }
352
418
  const snapshotParams = { ...baseParams };
353
419
  delete snapshotParams.resources;
420
+ if (snapshotName && sizeResources) {
421
+ const bakedSize = readPreparedDaytonaState()?.extras?.size;
422
+ const requestedKey = `${String(sizeResources.cpu)}-${String(sizeResources.memory)}-${String(sizeResources.disk)}`;
423
+ if (bakedSize !== requestedKey) {
424
+ req.onLog?.(
425
+ `daytona: WARNING \u2014 size '${requestedKey}' is ignored on the snapshot path; this snapshot was baked at ${bakedSize ?? "the default size"}. Daytona resources are fixed at bake time \u2014 re-bake with \`agentbox prepare --provider daytona --size ${requestedKey} --force\` to change them.`
426
+ );
427
+ }
428
+ }
354
429
  const sandbox = snapshotName ? await client2.create({ snapshot: snapshotName, ...snapshotParams }, { timeout: 900 }) : await client2.create(
355
430
  { image: resolveImage(req.image), ...baseParams },
356
431
  {
@@ -746,71 +821,7 @@ function openDashboard() {
746
821
  }
747
822
  }
748
823
  function secretsPath() {
749
- return resolve3(homedir2(), ".agentbox", "secrets.env");
750
- }
751
- var SCHEMA = 1;
752
- function resolveDaytonaContextFiles() {
753
- const ctx = resolveDockerfileContext();
754
- if (!ctx) return null;
755
- const here = dirname2(fileURLToPath2(import.meta.url));
756
- const packageRoot = resolve4(here, "..");
757
- const monorepoRoot = resolve4(here, "..", "..", "..");
758
- const dockerPackageRoot = resolve4(monorepoRoot, "packages", "sandbox-docker");
759
- const docker = resolveContextFilesFrom(DOCKER_CONTEXT_FILE_MAP, {
760
- contextDir: ctx.context,
761
- devRoot: existsSync3(dockerPackageRoot) ? dockerPackageRoot : packageRoot
762
- });
763
- if (!docker) return null;
764
- const overlay = resolveDaytonaCustomClaudeMd();
765
- if (!overlay) return null;
766
- return [
767
- ...docker,
768
- // Daytona-specific overlay: separate logical name so a docker/daytona
769
- // CLAUDE.md drift produces different fingerprints (the daytona snapshot
770
- // contains both files in distinct locations).
771
- { rel: "daytona/custom-system-CLAUDE.md", abs: overlay }
772
- ];
773
- }
774
- var DAYTONA_SEED_SCHEMA = "relctx-1";
775
- async function computeDaytonaContextFingerprint() {
776
- const files = resolveDaytonaContextFiles();
777
- if (!files) return null;
778
- const rawSha = await computeContextSha256(files);
779
- const contextSha256 = createHash("sha256").update(`${rawSha}\0daytona-seed=${DAYTONA_SEED_SCHEMA}`).digest("hex");
780
- return { contextSha256, files };
781
- }
782
- async function currentDaytonaBaseFingerprintLive(claudeInstall = "native") {
783
- try {
784
- const fp = await computeDaytonaContextFingerprint();
785
- if (!fp?.contextSha256) return void 0;
786
- return claudeInstallFingerprint(fp.contextSha256, claudeInstall);
787
- } catch {
788
- return void 0;
789
- }
790
- }
791
- function readPreparedDaytonaState() {
792
- const raw = readPreparedStateRaw("daytona");
793
- if (raw === null || typeof raw !== "object") return null;
794
- const parsed = raw;
795
- if (parsed.schema !== SCHEMA) return null;
796
- return { schema: SCHEMA, base: parsed.base };
797
- }
798
- function writePreparedDaytonaState(opts) {
799
- const stamp = readCliStamp();
800
- const state = {
801
- schema: SCHEMA,
802
- base: {
803
- imageRef: opts.snapshotName,
804
- contextSha256: opts.contextSha256,
805
- cliVersion: stamp.cliVersion,
806
- cliCommit: stamp.cliCommit,
807
- createdAt: (/* @__PURE__ */ new Date()).toISOString()
808
- }
809
- };
810
- writePreparedStateRaw("daytona", state);
811
- }
812
- function preparedMatches(state, current) {
813
- return state?.base?.contextSha256 === current;
824
+ return resolve4(homedir2(), ".agentbox", "secrets.env");
814
825
  }
815
826
 
816
827
  // ../../packages/sandbox-daytona/dist/index.js
@@ -818,9 +829,10 @@ import { copyFileSync, mkdtempSync, readFileSync as readFileSync2, rmSync, write
818
829
  import { tmpdir } from "os";
819
830
  import { dirname as dirname3, join } from "path";
820
831
  import { Image as Image2 } from "@daytonaio/sdk";
821
- function defaultSnapshotName(fingerprint) {
822
- if (fingerprint) return `agentbox-base-${fingerprint.slice(0, 12)}`;
823
- return `agentbox-base-${Math.floor(Date.now() / 1e3).toString()}`;
832
+ function defaultSnapshotName(fingerprint, sizeKey) {
833
+ const suffix = sizeKey ? `-${sizeKey}` : "";
834
+ if (fingerprint) return `agentbox-base-${fingerprint.slice(0, 12)}${suffix}`;
835
+ return `agentbox-base-${Math.floor(Date.now() / 1e3).toString()}${suffix}`;
824
836
  }
825
837
  function daytonaSeedPaths(kind) {
826
838
  return {
@@ -852,14 +864,22 @@ async function prepareDaytona(opts) {
852
864
  const log = opts.onLog ?? (() => {
853
865
  });
854
866
  const claudeInstall = opts.claudeInstall ?? "native";
867
+ const sizeSpec = opts.size?.trim() || void 0;
868
+ const sizeResources = sizeSpec ? parseDaytonaSize(sizeSpec) : void 0;
869
+ if (sizeSpec && !sizeResources) {
870
+ throw new Error(
871
+ `invalid --size '${sizeSpec}' for daytona: expected 'cpu-memory-disk' GB, e.g. '4-8-20'.`
872
+ );
873
+ }
874
+ const sizeKey = sizeResources ? `${String(sizeResources.cpu)}-${String(sizeResources.memory)}-${String(sizeResources.disk)}` : void 0;
855
875
  const rawFingerprint = await computeDaytonaContextFingerprint();
856
876
  const fingerprint = rawFingerprint ? {
857
877
  ...rawFingerprint,
858
878
  contextSha256: claudeInstallFingerprint(rawFingerprint.contextSha256, claudeInstall)
859
879
  } : rawFingerprint;
860
- const snapshotName = opts.name ?? defaultSnapshotName(fingerprint?.contextSha256 ?? null);
880
+ const snapshotName = opts.name ?? defaultSnapshotName(fingerprint?.contextSha256 ?? null, sizeKey);
861
881
  const prepared = readPreparedDaytonaState();
862
- if (!opts.force && fingerprint && preparedMatches(prepared, fingerprint.contextSha256)) {
882
+ if (!opts.force && fingerprint && preparedMatches(prepared, fingerprint.contextSha256, sizeKey)) {
863
883
  try {
864
884
  const existing = await getClient().snapshot.get(
865
885
  prepared?.base?.imageRef ?? snapshotName
@@ -879,9 +899,16 @@ async function prepareDaytona(opts) {
879
899
  );
880
900
  }
881
901
  } else if (!opts.force && fingerprint && prepared?.base?.contextSha256) {
882
- log(
883
- `daytona build context changed (was ${prepared.base.contextSha256.slice(0, 12)}, now ${fingerprint.contextSha256.slice(0, 12)}); rebuilding snapshot`
884
- );
902
+ const bakedSize = prepared.extras?.size;
903
+ if (prepared.base.contextSha256 === fingerprint.contextSha256 && bakedSize !== sizeKey) {
904
+ log(
905
+ `daytona size changed (was ${bakedSize ?? "default"}, now ${sizeKey ?? "default"}); rebuilding snapshot`
906
+ );
907
+ } else {
908
+ log(
909
+ `daytona build context changed (was ${prepared.base.contextSha256.slice(0, 12)}, now ${fingerprint.contextSha256.slice(0, 12)}); rebuilding snapshot`
910
+ );
911
+ }
885
912
  }
886
913
  const ctx = resolveDockerfileContext();
887
914
  if (!ctx) {
@@ -912,9 +939,11 @@ async function prepareDaytona(opts) {
912
939
  }
913
940
  image = image.dockerfileCommands(buildDaytonaSeedCommands(usable), seedContextDir);
914
941
  const client2 = getClient();
915
- log(`creating Daytona snapshot '${snapshotName}'\u2026`);
942
+ log(
943
+ `creating Daytona snapshot '${snapshotName}'${sizeResources ? ` (${sizeKey})` : ""}\u2026`
944
+ );
916
945
  const snapshot = await client2.snapshot.create(
917
- { name: snapshotName, image },
946
+ { name: snapshotName, image, ...sizeResources ? { resources: sizeResources } : {} },
918
947
  {
919
948
  onLogs: (chunk) => log(String(chunk).split("\n").filter(Boolean).join(" "))
920
949
  }
@@ -923,7 +952,8 @@ async function prepareDaytona(opts) {
923
952
  if (fingerprint) {
924
953
  writePreparedDaytonaState({
925
954
  snapshotName: snapshot.name ?? snapshotName,
926
- contextSha256: fingerprint.contextSha256
955
+ contextSha256: fingerprint.contextSha256,
956
+ size: sizeKey
927
957
  });
928
958
  log(
929
959
  `recorded daytona-prepared.json (fingerprint ${fingerprint.contextSha256.slice(0, 12)})`
@@ -41,7 +41,7 @@ import {
41
41
  unregisterProject,
42
42
  unsetConfigValue,
43
43
  workspaceConfigFile
44
- } from "./chunk-EXQCBM5Q.js";
44
+ } from "./chunk-64WEKO34.js";
45
45
  import "./chunk-TZFWAJVB.js";
46
46
  export {
47
47
  BUILT_IN_DEFAULTS,