@madarco/agentbox 0.24.6 → 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 +59 -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 +114 -38
  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/{2LDXStEUVHS2oK1ID_Uvo → c82uDoByt-dPQUHilRojD}/_buildManifest.js +0 -0
  160. /package/runtime/hub/apps/hub/.next/static/{2LDXStEUVHS2oK1ID_Uvo → c82uDoByt-dPQUHilRojD}/_clientMiddlewareManifest.js +0 -0
  161. /package/runtime/hub/apps/hub/.next/static/{2LDXStEUVHS2oK1ID_Uvo → c82uDoByt-dPQUHilRojD}/_ssgManifest.js +0 -0
@@ -78,10 +78,10 @@ import {
78
78
  upstreamRef,
79
79
  writeClaudeMergedRegistries,
80
80
  writeCredentialBackup
81
- } from "./chunk-EY6HEDTK.js";
81
+ } from "./chunk-LNHPLR3L.js";
82
82
  import {
83
83
  execa
84
- } from "./chunk-EFW34I43.js";
84
+ } from "./chunk-UDZ3VXRF.js";
85
85
  import {
86
86
  BUILT_IN_DEFAULTS,
87
87
  GLOBAL_CONFIG_FILE,
@@ -92,10 +92,10 @@ import {
92
92
  require_dist,
93
93
  sanitizeMnemonic,
94
94
  setConfigValue
95
- } from "./chunk-TRUQCO4U.js";
95
+ } from "./chunk-V3OMPMI3.js";
96
96
  import {
97
97
  __toESM
98
- } from "./chunk-TZFWAJVB.js";
98
+ } from "./chunk-OG4KH2FZ.js";
99
99
 
100
100
  // ../../packages/sandbox-docker/dist/index.js
101
101
  import { spawnSync } from "child_process";
@@ -1349,7 +1349,7 @@ var GitHubAppLeaser = class {
1349
1349
  }
1350
1350
  };
1351
1351
 
1352
- // ../../packages/relay/dist/chunk-UZUBCJOP.js
1352
+ // ../../packages/relay/dist/chunk-MWEABU6N.js
1353
1353
  import { spawn as spawn3 } from "child_process";
1354
1354
  import { createServer } from "http";
1355
1355
  import { mkdtemp, rm as rm2 } from "fs/promises";
@@ -1636,7 +1636,7 @@ function getConnector(service) {
1636
1636
  return null;
1637
1637
  }
1638
1638
 
1639
- // ../../packages/relay/dist/chunk-UZUBCJOP.js
1639
+ // ../../packages/relay/dist/chunk-MWEABU6N.js
1640
1640
  import { randomUUID as randomUUID3 } from "crypto";
1641
1641
  import { randomUUID as randomUUID22 } from "crypto";
1642
1642
  import { spawn as spawn5 } from "child_process";
@@ -3409,7 +3409,7 @@ function createRelayServer(opts) {
3409
3409
  let pollers = null;
3410
3410
  async function getPollers() {
3411
3411
  if (!pollers) {
3412
- const mod = await import("./cloud-poller-SUNA6ZQC-VSKVMYHL.js");
3412
+ const mod = await import("./cloud-poller-SUNA6ZQC-YAWTNA2W.js");
3413
3413
  pollers = new mod.CloudBoxPollers();
3414
3414
  }
3415
3415
  return pollers;
@@ -5451,6 +5451,10 @@ function selectBoxesToRenew(entries, windowMs, now) {
5451
5451
  }
5452
5452
  return out;
5453
5453
  }
5454
+ function shouldIdlePause(e, idleWindowMs, now) {
5455
+ if (e.agentState !== "idle" || e.lastActivityMs == null) return false;
5456
+ return now - e.lastActivityMs >= idleWindowMs;
5457
+ }
5454
5458
  function coarseKeepaliveState(s) {
5455
5459
  switch (s) {
5456
5460
  case "working":
@@ -5471,12 +5475,14 @@ function startCloudKeepaliveLoop(deps) {
5471
5475
  const loadConfig2 = deps.loadConfig ?? loadAutopauseConfig;
5472
5476
  const resolveBackend = deps.resolveBackend ?? resolveCloudBackend;
5473
5477
  const lookupBox = deps.lookupBox ?? defaultLookupBox;
5478
+ const persistPaused = deps.persistPaused ?? defaultPersistPaused;
5474
5479
  const fallbackCreateTimeoutMs = deps.fallbackCreateTimeoutMs ?? defaultFallbackCreateTimeoutMs;
5475
5480
  const nowFn = deps.now ?? Date.now;
5476
5481
  const intervalMs = deps.intervalMs ?? DEFAULT_INTERVAL_MS3;
5477
5482
  const { registry, statusStore, log } = deps;
5478
5483
  const tracked = /* @__PURE__ */ new Map();
5479
5484
  const backoffUntil = /* @__PURE__ */ new Map();
5485
+ const idlePaused = /* @__PURE__ */ new Map();
5480
5486
  const backendCache = /* @__PURE__ */ new Map();
5481
5487
  let ticking = false;
5482
5488
  let stopped = false;
@@ -5517,6 +5523,7 @@ function startCloudKeepaliveLoop(deps) {
5517
5523
  }
5518
5524
  for (const id of [...tracked.keys()]) if (!live.has(id)) tracked.delete(id);
5519
5525
  for (const id of [...backoffUntil.keys()]) if (!live.has(id)) backoffUntil.delete(id);
5526
+ for (const id of [...idlePaused.keys()]) if (!live.has(id)) idlePaused.delete(id);
5520
5527
  const decisions = selectBoxesToRenew(entries, windowMs, now);
5521
5528
  for (const d of decisions) {
5522
5529
  const until = backoffUntil.get(d.boxId);
@@ -5546,6 +5553,39 @@ function startCloudKeepaliveLoop(deps) {
5546
5553
  log(`cloud-keepalive: renew box ${d.boxId} (${d.backend}) failed: ${msg}`);
5547
5554
  }
5548
5555
  }
5556
+ for (const e of entries) {
5557
+ const boxId = e.boxId;
5558
+ if (e.agentState !== "idle") continue;
5559
+ const backend = await resolveCached(e.backend);
5560
+ if (backend?.timeoutModel !== "inactivity") continue;
5561
+ if (typeof backend.pause !== "function") continue;
5562
+ if (idlePaused.get(boxId) === e.lastActivityMs) continue;
5563
+ const until = backoffUntil.get(boxId);
5564
+ if (until != null && now < until) continue;
5565
+ const lookup = await lookupBox(boxId);
5566
+ if (!lookup) continue;
5567
+ const idleWindowMs = lookup.createTimeoutMs ?? await fallbackCreateTimeoutMs(e.backend);
5568
+ if (idleWindowMs <= 0) continue;
5569
+ if (!shouldIdlePause(e, idleWindowMs, now)) continue;
5570
+ try {
5571
+ await backend.pause({
5572
+ sandboxId: lookup.sandboxId,
5573
+ ...lookup.sandboxClass ? { sandboxClass: lookup.sandboxClass } : {}
5574
+ });
5575
+ idlePaused.set(boxId, e.lastActivityMs);
5576
+ backoffUntil.delete(boxId);
5577
+ await persistPaused(boxId).catch(() => {
5578
+ });
5579
+ const mins = e.lastActivityMs != null ? Math.round((now - e.lastActivityMs) / 6e4) : null;
5580
+ log(
5581
+ `cloud-keepalive: paused idle box ${boxId} (${e.backend})` + (mins != null ? ` after ~${String(mins)}m idle` : "") + ` \u2014 ${e.backend}'s own idle timer never fires while we poll it`
5582
+ );
5583
+ } catch (err) {
5584
+ backoffUntil.set(boxId, now + FAILURE_BACKOFF_MS);
5585
+ const msg = err instanceof Error ? err.message : String(err);
5586
+ log(`cloud-keepalive: pause idle box ${boxId} (${e.backend}) failed: ${msg}`);
5587
+ }
5588
+ }
5549
5589
  } catch (err) {
5550
5590
  const msg = err instanceof Error ? err.message : String(err);
5551
5591
  log(`cloud-keepalive: tick error: ${msg}`);
@@ -5578,12 +5618,20 @@ async function defaultLookupBox(boxId) {
5578
5618
  if (hit.kind !== "ok") return null;
5579
5619
  const sandboxId = hit.box.cloud?.sandboxId;
5580
5620
  if (!sandboxId) return null;
5621
+ const sandboxClass = hit.box.cloud?.sandboxClass;
5581
5622
  return {
5582
5623
  sandboxId,
5583
5624
  createdAtMs: toEpoch2(hit.box.createdAt),
5584
- createTimeoutMs: hit.box.cloud?.sessionTimeoutMs ?? null
5625
+ createTimeoutMs: hit.box.cloud?.sessionTimeoutMs ?? null,
5626
+ ...sandboxClass ? { sandboxClass } : {}
5585
5627
  };
5586
5628
  }
5629
+ async function defaultPersistPaused(boxId) {
5630
+ const state = await readState();
5631
+ const hit = findBox(boxId, state);
5632
+ if (hit.kind !== "ok" || !hit.box.cloud) return;
5633
+ await recordBox({ ...hit.box, cloud: { ...hit.box.cloud, lastState: "paused" } });
5634
+ }
5587
5635
  async function defaultFallbackCreateTimeoutMs(backend) {
5588
5636
  const generic = 45 * 6e4;
5589
5637
  if (backend !== "vercel") return generic;
@@ -10353,7 +10401,7 @@ async function ensureAgentboxTasksFile(container, services, opts = {}) {
10353
10401
  return { status: "wrote" };
10354
10402
  }
10355
10403
  async function writeFileInBox(container, path, content) {
10356
- const { execa: execa22 } = await import("./execa-4DLVNM6E.js");
10404
+ const { execa: execa22 } = await import("./execa-AFY4ZODY.js");
10357
10405
  const result = await execa22(
10358
10406
  "docker",
10359
10407
  ["exec", "-i", "--user", "vscode", container, "sh", "-c", `cat > ${shellQuote2(path)}`],
@@ -14,6 +14,10 @@ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require
14
14
  var __commonJS = (cb, mod) => function __require2() {
15
15
  return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
16
16
  };
17
+ var __export = (target, all) => {
18
+ for (var name in all)
19
+ __defProp(target, name, { get: all[name], enumerable: true });
20
+ };
17
21
  var __copyProps = (to, from, except, desc) => {
18
22
  if (from && typeof from === "object" || typeof from === "function") {
19
23
  for (let key of __getOwnPropNames(from))
@@ -34,5 +38,6 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
34
38
  export {
35
39
  __require,
36
40
  __commonJS,
41
+ __export,
37
42
  __toESM
38
43
  };
@@ -22,7 +22,7 @@ import {
22
22
  readBoxStatus,
23
23
  registerBoxWithRelay,
24
24
  syncClaudeCredentials
25
- } from "./chunk-DNR2YM2G.js";
25
+ } from "./chunk-MA73PTOR.js";
26
26
  import {
27
27
  AGENT_SYNC_SPECS,
28
28
  BOX_DYNAMIC_SYNC_MANIFEST,
@@ -60,6 +60,7 @@ import {
60
60
  resolveSyncTopology,
61
61
  resyncWorkspace,
62
62
  shouldAcceptCredentialUpdate,
63
+ stageAllAgentStatic,
63
64
  stageClaudeCredentialsForUpload,
64
65
  stageClaudeJsonOnlyForUpload,
65
66
  stageClaudeStaticForUpload,
@@ -70,20 +71,20 @@ import {
70
71
  stageOpencodeStateForUpload,
71
72
  stageOpencodeStaticForUpload,
72
73
  writeCredentialBackup
73
- } from "./chunk-EY6HEDTK.js";
74
+ } from "./chunk-LNHPLR3L.js";
74
75
  import {
75
76
  execa
76
- } from "./chunk-EFW34I43.js";
77
+ } from "./chunk-UDZ3VXRF.js";
77
78
  import {
78
79
  hashProjectPath,
79
80
  loadEffectiveConfig,
80
81
  projectDirSegment,
81
82
  require_dist,
82
83
  sanitizeMnemonic
83
- } from "./chunk-TRUQCO4U.js";
84
+ } from "./chunk-V3OMPMI3.js";
84
85
  import {
85
86
  __toESM
86
- } from "./chunk-TZFWAJVB.js";
87
+ } from "./chunk-OG4KH2FZ.js";
87
88
 
88
89
  // ../../packages/sandbox-cloud/dist/index.js
89
90
  import { basename as basename2, resolve } from "path";
@@ -417,6 +418,12 @@ async function ensureAgentVolumesForCloud(backend, opts = {}) {
417
418
  const log = opts.onLog ?? (() => {
418
419
  });
419
420
  const allAgents = AGENT_SPECS.map((s) => s.kind);
421
+ if (opts.volumesUsable === false) {
422
+ log(
423
+ `cloud backend '${backend.name}' cannot mount volumes for this sandbox class \u2014 agent credentials seeded per-create only`
424
+ );
425
+ return { mounts: [], env: buildForwardedEnv(allAgents), agents: allAgents };
426
+ }
420
427
  if (typeof backend.ensureVolume !== "function") {
421
428
  log(
422
429
  `cloud backend '${backend.name}' has no volume primitive \u2014 agent credentials seeded per-create only`
@@ -2040,7 +2047,11 @@ function createCloudProvider(backend, opts = {}) {
2040
2047
  if (!sandboxId) {
2041
2048
  throw new Error(`cloud box ${box.name} has no sandboxId \u2014 record is malformed`);
2042
2049
  }
2043
- return { sandboxId, inbound: box.cloud?.inbound };
2050
+ return {
2051
+ sandboxId,
2052
+ inbound: box.cloud?.inbound,
2053
+ sandboxClass: box.cloud?.sandboxClass
2054
+ };
2044
2055
  }
2045
2056
  function mintBox(req) {
2046
2057
  const id = generateBoxId();
@@ -2232,7 +2243,7 @@ function createCloudProvider(backend, opts = {}) {
2232
2243
  const image = opts.provisionImage ? await opts.provisionImage(req) : req.image ?? FALLBACK_IMAGE;
2233
2244
  const resources = opts.defaultResources ?? { cpu: 2, memory: 4, disk: 8 };
2234
2245
  const timeoutOverride = req.providerOptions?.["timeoutMs"];
2235
- const timeoutMs = typeof timeoutOverride === "number" && timeoutOverride > 0 ? timeoutOverride : void 0;
2246
+ const timeoutMs = typeof timeoutOverride === "number" && timeoutOverride >= 0 ? timeoutOverride : void 0;
2236
2247
  const networkPolicyOpt = req.providerOptions?.["networkPolicy"];
2237
2248
  const networkPolicy = typeof networkPolicyOpt === "string" && networkPolicyOpt.trim() !== "" ? networkPolicyOpt.trim() : void 0;
2238
2249
  const sizeOpt = req.providerOptions?.["size"];
@@ -2243,6 +2254,8 @@ function createCloudProvider(backend, opts = {}) {
2243
2254
  const inbound = typeof inboundOpt === "string" && inboundOpt.trim() !== "" ? inboundOpt.trim() : void 0;
2244
2255
  const projectOpt = req.providerOptions?.["project"];
2245
2256
  const project = typeof projectOpt === "string" && projectOpt.trim() !== "" ? projectOpt.trim() : void 0;
2257
+ const classOpt = req.providerOptions?.["sandboxClass"];
2258
+ const sandboxClass = typeof classOpt === "string" && classOpt.trim() !== "" ? classOpt.trim() : void 0;
2246
2259
  const relayToken = generateRelayToken();
2247
2260
  const bridgeToken = generateRelayToken();
2248
2261
  try {
@@ -2270,7 +2283,12 @@ function createCloudProvider(backend, opts = {}) {
2270
2283
  );
2271
2284
  }
2272
2285
  }
2273
- const agentVolumes = await ensureAgentVolumesForCloud(backend, { onLog: log });
2286
+ const agentVolumes = await ensureAgentVolumesForCloud(backend, {
2287
+ onLog: log,
2288
+ // Daytona's linux-vm class accepts volume mounts and never honors them
2289
+ // (see ensureAgentVolumesForCloud) — take the per-create upload path.
2290
+ volumesUsable: sandboxClass !== "linux-vm"
2291
+ });
2274
2292
  const exposeServicePorts = await readExposedServicePorts(req.workspacePath);
2275
2293
  const credentialSyncOff = (req.credentialSync ?? (await loadEffectiveConfig(req.projectRoot ?? req.workspacePath)).effective.box.credentialSync) === false;
2276
2294
  const provisionEnv = {
@@ -2300,6 +2318,7 @@ function createCloudProvider(backend, opts = {}) {
2300
2318
  location,
2301
2319
  project,
2302
2320
  inbound,
2321
+ sandboxClass,
2303
2322
  timeoutMs,
2304
2323
  exposePorts: exposeServicePorts,
2305
2324
  networkPolicy,
@@ -2598,6 +2617,10 @@ function createCloudProvider(backend, opts = {}) {
2598
2617
  // Inbound-access policy the backend applied to the per-box firewall
2599
2618
  // (VPS providers). Persisted so drift re-syncs preserve the whitelist.
2600
2619
  inbound: handle.inbound,
2620
+ // Daytona sandbox class, read back from the class of the snapshot the
2621
+ // box actually booted from (not from config, which can disagree).
2622
+ // pause() branches on it: a VM pauses, a container archives.
2623
+ sandboxClass: handle.sandboxClass,
2601
2624
  // Only host-seeded boxes share a fork base with the host, so only
2602
2625
  // they can be resynced back to the host tip on session start (7.5).
2603
2626
  // inBoxClone / plane boxes clone from a leased URL — left unset.
@@ -2775,12 +2798,28 @@ function createCloudProvider(backend, opts = {}) {
2775
2798
  const handle = handleFor(box);
2776
2799
  const baseArgv = await backend.attachArgv(handle);
2777
2800
  const inner = renderInnerCommand(kind, opts2);
2778
- const argv = opts2?.detached ? [...baseArgv.slice(1), inner] : [...baseArgv.slice(1), "-t", inner];
2801
+ const viaStdin = backend.attachExecLacksTty === true && !opts2?.detached && kind !== "logs";
2802
+ const scriptPath = viaStdin ? attachScriptPath(opts2?.sessionName ?? kind) : "";
2803
+ if (viaStdin) {
2804
+ const b64 = Buffer.from(inner, "utf8").toString("base64");
2805
+ await backend.exec(
2806
+ handle,
2807
+ `printf %s '${b64}' | base64 -d > ${scriptPath} && chmod 700 ${scriptPath}`
2808
+ );
2809
+ }
2810
+ const argv = opts2?.detached ? [...baseArgv.slice(1), inner] : viaStdin ? [...baseArgv.slice(1)] : [...baseArgv.slice(1), "-t", inner];
2779
2811
  const fullArgv = [baseArgv[0], ...argv];
2780
2812
  const cleanup = backend.revokeAttachToken ? async () => {
2781
2813
  await backend.revokeAttachToken(handle, baseArgv);
2782
2814
  } : void 0;
2783
- return { argv: fullArgv, cleanup };
2815
+ return {
2816
+ argv: fullArgv,
2817
+ // `exec` so the script replaces the login shell: the user never lands
2818
+ // back on a prompt when they detach from tmux.
2819
+ ...viaStdin ? { initialInput: `exec bash ${scriptPath}
2820
+ ` } : {},
2821
+ cleanup
2822
+ };
2784
2823
  },
2785
2824
  async uploadPath(box, hostSrcs, boxDst, exclude) {
2786
2825
  return uploadToCloudBox(backend, handleFor(box), hostSrcs, boxDst, exclude);
@@ -2946,6 +2985,10 @@ function hostTermForCloud() {
2946
2985
  const t = process.env["TERM"];
2947
2986
  return t && /^[A-Za-z0-9][A-Za-z0-9._+-]*$/.test(t) ? t : "xterm-256color";
2948
2987
  }
2988
+ function attachScriptPath(sessionName) {
2989
+ const safe = sessionName.replace(/[^A-Za-z0-9._-]/g, "_").slice(0, 40) || "attach";
2990
+ return `/tmp/agentbox-attach-${safe}.sh`;
2991
+ }
2949
2992
  function renderInnerCommand(kind, opts) {
2950
2993
  const sessionName = opts?.sessionName ?? defaultSessionName(kind);
2951
2994
  const fallback = opts?.command ?? defaultCommand(kind, opts);
@@ -2997,6 +3040,62 @@ function defaultCommand(kind, opts) {
2997
3040
  function shellSingle(s) {
2998
3041
  return "'" + s.replace(/'/g, "'\\''") + "'";
2999
3042
  }
3043
+ function remoteTarFor(kind) {
3044
+ return `/tmp/agentbox-seed-${kind}.tar.gz`;
3045
+ }
3046
+ var REMOTE_CLAUDE_MD = "/tmp/agentbox-custom-CLAUDE.md";
3047
+ function buildAgentStaticSeedCommands(usable, opts = {}) {
3048
+ const cmds = [];
3049
+ if (opts.claudeMdOverlay) {
3050
+ cmds.push(
3051
+ `sudo -n mkdir -p /etc/claude-code && sudo -n install -m 0644 ${REMOTE_CLAUDE_MD} /etc/claude-code/CLAUDE.md && rm -f ${REMOTE_CLAUDE_MD}`
3052
+ );
3053
+ }
3054
+ for (const s of usable) {
3055
+ cmds.push(
3056
+ `mkdir -p ${s.extractDir} && tar -xzf ${remoteTarFor(s.kind)} -C ${s.extractDir} --no-same-permissions --no-same-owner -m && rm -f ${remoteTarFor(s.kind)}`
3057
+ );
3058
+ }
3059
+ if (usable.length > 0) {
3060
+ cmds.push(
3061
+ "sudo -n chown -R vscode:vscode /home/vscode/.claude /home/vscode/.codex /home/vscode/.local && ( [ -d /home/vscode/.agents ] && sudo -n chown -R vscode:vscode /home/vscode/.agents || true )"
3062
+ );
3063
+ }
3064
+ return cmds;
3065
+ }
3066
+ async function seedAgentStaticIntoCloudBox(backend, handle, opts = {}) {
3067
+ const log = opts.onLog ?? (() => {
3068
+ });
3069
+ const stages = await stageAllAgentStatic({ hostWorkspace: opts.hostWorkspace });
3070
+ try {
3071
+ for (const s of stages) {
3072
+ for (const w of s.staged.warnings) log(w);
3073
+ }
3074
+ const usable = stages.filter((s) => s.staged.tarballPath !== null);
3075
+ if (opts.claudeMdOverlay) {
3076
+ await backend.uploadFile(handle, opts.claudeMdOverlay, REMOTE_CLAUDE_MD);
3077
+ }
3078
+ for (const s of usable) {
3079
+ await backend.uploadFile(handle, s.staged.tarballPath, remoteTarFor(s.kind));
3080
+ }
3081
+ const cmds = buildAgentStaticSeedCommands(usable, {
3082
+ claudeMdOverlay: Boolean(opts.claudeMdOverlay)
3083
+ });
3084
+ for (const cmd of cmds) {
3085
+ const r = await backend.exec(handle, cmd);
3086
+ if (r.exitCode !== 0) {
3087
+ throw new Error(
3088
+ `agent-static seed failed (exit ${String(r.exitCode)}): ${cmd}
3089
+ ${r.stdout}${r.stderr}`
3090
+ );
3091
+ }
3092
+ }
3093
+ log(`seeded agent static config: ${usable.map((s) => s.kind).join(", ") || "(none)"}`);
3094
+ return { seeded: usable.map((s) => s.kind) };
3095
+ } finally {
3096
+ await Promise.all(stages.map((s) => s.staged.cleanup()));
3097
+ }
3098
+ }
3000
3099
  async function openWebAppOnVncScreen(box, provider) {
3001
3100
  const persisted = await readBoxStatus(box);
3002
3101
  const hasWebService = persisted?.services.some((s) => s.expose) ?? false;
@@ -3019,6 +3118,7 @@ async function openWebAppOnVncScreen(box, provider) {
3019
3118
  }
3020
3119
 
3021
3120
  export {
3121
+ cloudSnapshotName,
3022
3122
  listCloudCheckpoints,
3023
3123
  resolveCloudCheckpoint,
3024
3124
  writeCloudCheckpointManifest,
@@ -3028,5 +3128,6 @@ export {
3028
3128
  createCloudProvider,
3029
3129
  hostTermForCloud,
3030
3130
  renderInnerCommand,
3131
+ seedAgentStaticIntoCloudBox,
3031
3132
  openWebAppOnVncScreen
3032
3133
  };