@madarco/agentbox 0.29.1 → 0.29.2
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.
- package/CHANGELOG.md +24 -0
- package/dist/{_cloud-attach-EUO2OL7W.js → _cloud-attach-7WVNYNJI.js} +6 -6
- package/dist/{chunk-2JHPGPLE.js → chunk-5I7IFACI.js} +2 -2
- package/dist/{chunk-AC3HU25W.js → chunk-5NVHJS7D.js} +2 -2
- package/dist/{chunk-PFEBKXFD.js → chunk-6UCHNX75.js} +19 -12
- package/dist/{chunk-PFEBKXFD.js.map → chunk-6UCHNX75.js.map} +1 -1
- package/dist/{chunk-UEEW5TW7.js → chunk-F77AZT2M.js} +2 -2
- package/dist/{chunk-UTOC2NHC.js → chunk-FCMBVJFQ.js} +2 -2
- package/dist/{chunk-73D2HKA3.js → chunk-HLBK5ZR6.js} +5 -5
- package/dist/{chunk-4KYP775X.js → chunk-JLVUNDUB.js} +26 -7
- package/dist/chunk-JLVUNDUB.js.map +1 -0
- package/dist/{chunk-BIKWXLX7.js → chunk-JTYWZJIU.js} +3 -3
- package/dist/{chunk-7LC5IG5K.js → chunk-LEVYTABB.js} +3 -3
- package/dist/{chunk-FEFLAITR.js → chunk-MS4NWRXN.js} +2 -2
- package/dist/{chunk-WJUKN4L4.js → chunk-N6EBPKTJ.js} +45 -3
- package/dist/chunk-N6EBPKTJ.js.map +1 -0
- package/dist/{chunk-4NUETVTR.js → chunk-OUOV4OM2.js} +7 -7
- package/dist/{chunk-I7BSBUPC.js → chunk-P5A6MT75.js} +7 -7
- package/dist/{chunk-FELVUIIM.js → chunk-RXH634SC.js} +2 -2
- package/dist/{chunk-QDU7YDME.js → chunk-SXXN7JOC.js} +18 -18
- package/dist/{chunk-B4YFG5TB.js → chunk-TDW2T3HR.js} +4 -4
- package/dist/{chunk-S32GHLVU.js → chunk-TPHSVKMX.js} +2 -2
- package/dist/{chunk-53OTEDBS.js → chunk-ZCHWZYIN.js} +3 -3
- package/dist/cloud-backends.js +3 -3
- package/dist/{control-plane-YQFX2ILX.js → control-plane-TOFT56CT.js} +10 -10
- package/dist/{cp-hub-upload-RMJ3XJ65.js → cp-hub-upload-OTBR5SL3.js} +2 -2
- package/dist/{deploy-hetzner-EECQ4JCM.js → deploy-hetzner-EE5CYX4N.js} +4 -4
- package/dist/{dist-Q4UDCSZQ.js → dist-7HSAWFRN.js} +3 -3
- package/dist/{dist-XUOHE22G.js → dist-BVZBXQ2Y.js} +4 -4
- package/dist/{dist-NFF2KEMB.js → dist-GMIBT6IK.js} +43 -19
- package/dist/{dist-NFF2KEMB.js.map → dist-GMIBT6IK.js.map} +1 -1
- package/dist/{dist-NTUHJOK3.js → dist-JSEXGLYK.js} +3 -3
- package/dist/{dist-TXFTYNNE.js → dist-RWFKW4IU.js} +2 -2
- package/dist/{dist-Z2TPC3EN.js → dist-XV77P3RW.js} +3 -3
- package/dist/{dist-E5EXDZG4.js → dist-Y2GCMA6N.js} +2 -2
- package/dist/{hub-3HPYOV5O.js → hub-53E6EFZB.js} +11 -11
- package/dist/{hub-docker-target-ZKAWXVPH.js → hub-docker-target-CS5XHSSA.js} +7 -7
- package/dist/index.js +47 -39
- package/dist/index.js.map +1 -1
- package/dist/{prepare-KIVDQRMN.js → prepare-VTLE7RCJ.js} +15 -15
- package/dist/{prepared-custody-EFSOOAIQ.js → prepared-custody-ATP6GQGW.js} +11 -11
- package/dist/{publish-credentials-F2A5OVCO.js → publish-credentials-NAWOHOLK.js} +3 -3
- package/dist/{registry-O3X2CDDU.js → registry-5CPAQ2KN.js} +3 -3
- package/dist/{remote-docker-share-QDCBM5UM.js → remote-docker-share-XBV76ZAZ.js} +4 -4
- package/dist/{tool-grant-push-6ISDIJKH.js → tool-grant-push-5GJYMC7C.js} +2 -2
- package/package.json +1 -1
- package/runtime/hub/apps/hub/.next/BUILD_ID +1 -1
- package/runtime/hub/apps/hub/.next/build-manifest.json +3 -3
- package/runtime/hub/apps/hub/.next/server/app/_global-error.html +1 -1
- package/runtime/hub/apps/hub/.next/server/app/_global-error.rsc +1 -1
- package/runtime/hub/apps/hub/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
- package/runtime/hub/apps/hub/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
- package/runtime/hub/apps/hub/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
- package/runtime/hub/apps/hub/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
- package/runtime/hub/apps/hub/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
- package/runtime/hub/apps/hub/.next/server/middleware-build-manifest.js +3 -3
- package/runtime/hub/apps/hub/.next/server/pages/500.html +1 -1
- package/runtime/hub/apps/hub/{chunk-BI4MPGQT.js → chunk-CTNPQ75B.js} +7 -7
- package/runtime/hub/apps/hub/{chunk-2WB3A5IN.js → chunk-DJPQLZ5Y.js} +1 -1
- package/runtime/hub/apps/hub/{chunk-RPPOFMPA.js → chunk-GUKVXSIY.js} +25 -6
- package/runtime/hub/apps/hub/{dist-F547YSBE.js → dist-2G5INR3G.js} +2 -2
- package/runtime/hub/apps/hub/{dist-YB3Y2XDK.js → dist-CIB4ZPJW.js} +85 -19
- package/runtime/hub/apps/hub/{dist-W5SGEJLA.js → dist-PI5ZAQGG.js} +1 -1
- package/runtime/hub/apps/hub/{dist-4F6XEJHK.js → dist-VDPNQEZ7.js} +2 -2
- package/runtime/hub/apps/hub/{dist-FEHV4PC7.js → dist-VZM32WR4.js} +1 -1
- package/runtime/hub/apps/hub/{dist-P7NT6VLK.js → dist-Y3LGOZ56.js} +1 -1
- package/runtime/hub/apps/hub/{dist-A3JOKKYG.js → dist-ZOJYJJ26.js} +1 -1
- package/runtime/hub/apps/hub/{hub-worker-I5QBLSRU.js → hub-worker-YQCQKCXS.js} +3 -3
- package/runtime/hub/apps/hub/server.js +8 -8
- package/runtime/hub/apps/hub/tsconfig.tsbuildinfo +1 -1
- package/dist/chunk-4KYP775X.js.map +0 -1
- package/dist/chunk-WJUKN4L4.js.map +0 -1
- /package/dist/{_cloud-attach-EUO2OL7W.js.map → _cloud-attach-7WVNYNJI.js.map} +0 -0
- /package/dist/{chunk-2JHPGPLE.js.map → chunk-5I7IFACI.js.map} +0 -0
- /package/dist/{chunk-AC3HU25W.js.map → chunk-5NVHJS7D.js.map} +0 -0
- /package/dist/{chunk-UEEW5TW7.js.map → chunk-F77AZT2M.js.map} +0 -0
- /package/dist/{chunk-UTOC2NHC.js.map → chunk-FCMBVJFQ.js.map} +0 -0
- /package/dist/{chunk-73D2HKA3.js.map → chunk-HLBK5ZR6.js.map} +0 -0
- /package/dist/{chunk-BIKWXLX7.js.map → chunk-JTYWZJIU.js.map} +0 -0
- /package/dist/{chunk-7LC5IG5K.js.map → chunk-LEVYTABB.js.map} +0 -0
- /package/dist/{chunk-FEFLAITR.js.map → chunk-MS4NWRXN.js.map} +0 -0
- /package/dist/{chunk-4NUETVTR.js.map → chunk-OUOV4OM2.js.map} +0 -0
- /package/dist/{chunk-I7BSBUPC.js.map → chunk-P5A6MT75.js.map} +0 -0
- /package/dist/{chunk-FELVUIIM.js.map → chunk-RXH634SC.js.map} +0 -0
- /package/dist/{chunk-QDU7YDME.js.map → chunk-SXXN7JOC.js.map} +0 -0
- /package/dist/{chunk-B4YFG5TB.js.map → chunk-TDW2T3HR.js.map} +0 -0
- /package/dist/{chunk-S32GHLVU.js.map → chunk-TPHSVKMX.js.map} +0 -0
- /package/dist/{chunk-53OTEDBS.js.map → chunk-ZCHWZYIN.js.map} +0 -0
- /package/dist/{control-plane-YQFX2ILX.js.map → control-plane-TOFT56CT.js.map} +0 -0
- /package/dist/{cp-hub-upload-RMJ3XJ65.js.map → cp-hub-upload-OTBR5SL3.js.map} +0 -0
- /package/dist/{deploy-hetzner-EECQ4JCM.js.map → deploy-hetzner-EE5CYX4N.js.map} +0 -0
- /package/dist/{dist-NTUHJOK3.js.map → dist-7HSAWFRN.js.map} +0 -0
- /package/dist/{dist-Q4UDCSZQ.js.map → dist-BVZBXQ2Y.js.map} +0 -0
- /package/dist/{dist-TXFTYNNE.js.map → dist-JSEXGLYK.js.map} +0 -0
- /package/dist/{dist-XUOHE22G.js.map → dist-RWFKW4IU.js.map} +0 -0
- /package/dist/{dist-Z2TPC3EN.js.map → dist-XV77P3RW.js.map} +0 -0
- /package/dist/{dist-E5EXDZG4.js.map → dist-Y2GCMA6N.js.map} +0 -0
- /package/dist/{hub-3HPYOV5O.js.map → hub-53E6EFZB.js.map} +0 -0
- /package/dist/{hub-docker-target-ZKAWXVPH.js.map → hub-docker-target-CS5XHSSA.js.map} +0 -0
- /package/dist/{prepare-KIVDQRMN.js.map → prepare-VTLE7RCJ.js.map} +0 -0
- /package/dist/{prepared-custody-EFSOOAIQ.js.map → prepared-custody-ATP6GQGW.js.map} +0 -0
- /package/dist/{publish-credentials-F2A5OVCO.js.map → publish-credentials-NAWOHOLK.js.map} +0 -0
- /package/dist/{registry-O3X2CDDU.js.map → registry-5CPAQ2KN.js.map} +0 -0
- /package/dist/{remote-docker-share-QDCBM5UM.js.map → remote-docker-share-XBV76ZAZ.js.map} +0 -0
- /package/dist/{tool-grant-push-6ISDIJKH.js.map → tool-grant-push-5GJYMC7C.js.map} +0 -0
- /package/runtime/hub/apps/hub/.next/static/{nDHi_1342DzyGDC14ocQo → 2P6VYtaUNxtdBvOVMolM-}/_buildManifest.js +0 -0
- /package/runtime/hub/apps/hub/.next/static/{nDHi_1342DzyGDC14ocQo → 2P6VYtaUNxtdBvOVMolM-}/_clientMiddlewareManifest.js +0 -0
- /package/runtime/hub/apps/hub/.next/static/{nDHi_1342DzyGDC14ocQo → 2P6VYtaUNxtdBvOVMolM-}/_ssgManifest.js +0 -0
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
import {
|
|
3
3
|
applyControlPlaneConfig,
|
|
4
4
|
resolveHubDeployAssets
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-5NVHJS7D.js";
|
|
6
6
|
import {
|
|
7
7
|
createCloudProvider
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-JLVUNDUB.js";
|
|
9
9
|
import {
|
|
10
10
|
detectPortless,
|
|
11
11
|
portlessDoctorRow,
|
|
@@ -2268,4 +2268,4 @@ export {
|
|
|
2268
2268
|
digitaloceanProvider,
|
|
2269
2269
|
providerModule
|
|
2270
2270
|
};
|
|
2271
|
-
//# sourceMappingURL=chunk-
|
|
2271
|
+
//# sourceMappingURL=chunk-JTYWZJIU.js.map
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
destroyControlPlaneOnHetzner,
|
|
5
5
|
readHetznerCredStatus,
|
|
6
6
|
updateControlPlaneOnHetzner
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-5NVHJS7D.js";
|
|
8
8
|
import {
|
|
9
9
|
controlPlaneDeployPath,
|
|
10
10
|
syncAgentboxSshConfig
|
|
@@ -133,7 +133,7 @@ async function purgeLocalControlPlaneState(opts) {
|
|
|
133
133
|
} catch {
|
|
134
134
|
}
|
|
135
135
|
try {
|
|
136
|
-
const { removeHubDockerTarget } = await import("./hub-docker-target-
|
|
136
|
+
const { removeHubDockerTarget } = await import("./hub-docker-target-CS5XHSSA.js");
|
|
137
137
|
await removeHubDockerTarget(() => {
|
|
138
138
|
});
|
|
139
139
|
} catch {
|
|
@@ -150,4 +150,4 @@ export {
|
|
|
150
150
|
runHetznerDestroy,
|
|
151
151
|
purgeLocalControlPlaneState
|
|
152
152
|
};
|
|
153
|
-
//# sourceMappingURL=chunk-
|
|
153
|
+
//# sourceMappingURL=chunk-LEVYTABB.js.map
|
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
renderInnerCommand,
|
|
14
14
|
resolveCloudCheckpoint,
|
|
15
15
|
writeCloudCheckpointManifest
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-JLVUNDUB.js";
|
|
17
17
|
import {
|
|
18
18
|
detectPortless,
|
|
19
19
|
portlessDoctorRow,
|
|
@@ -1305,4 +1305,4 @@ export {
|
|
|
1305
1305
|
remoteDockerProvider,
|
|
1306
1306
|
providerModule
|
|
1307
1307
|
};
|
|
1308
|
-
//# sourceMappingURL=chunk-
|
|
1308
|
+
//# sourceMappingURL=chunk-MS4NWRXN.js.map
|
|
@@ -16,7 +16,7 @@ import {
|
|
|
16
16
|
DAYTONA_VM_REGION
|
|
17
17
|
} from "./chunk-7LNXTPEE.js";
|
|
18
18
|
|
|
19
|
-
// ../../packages/sandbox-daytona/dist/chunk-
|
|
19
|
+
// ../../packages/sandbox-daytona/dist/chunk-QFW67CHZ.js
|
|
20
20
|
import { existsSync } from "fs";
|
|
21
21
|
import { dirname, resolve } from "path";
|
|
22
22
|
import { fileURLToPath } from "url";
|
|
@@ -353,6 +353,31 @@ function retry(method, fn, opts = {}) {
|
|
|
353
353
|
var DEFAULT_BOX_IMAGE_REF = "agentbox/box:dev";
|
|
354
354
|
var DAYTONA_DEFAULT_RESOURCES = { cpu: 2, memory: 4, disk: 8 };
|
|
355
355
|
var clients = /* @__PURE__ */ new Map();
|
|
356
|
+
var BOX_USER = "vscode";
|
|
357
|
+
function shq(s) {
|
|
358
|
+
return `'${s.replace(/'/g, `'\\''`)}'`;
|
|
359
|
+
}
|
|
360
|
+
function buildDaytonaExec(cmd, h, opts) {
|
|
361
|
+
const user = opts?.user ?? BOX_USER;
|
|
362
|
+
const isVm = h.sandboxClass !== "container";
|
|
363
|
+
if (!isVm || user === "root") {
|
|
364
|
+
return {
|
|
365
|
+
cmd,
|
|
366
|
+
...opts?.cwd ? { cwd: opts.cwd } : {},
|
|
367
|
+
...opts?.env ? { env: opts.env } : {}
|
|
368
|
+
};
|
|
369
|
+
}
|
|
370
|
+
const prelude = [];
|
|
371
|
+
if (opts?.cwd) prelude.push(`cd ${shq(opts.cwd)}`);
|
|
372
|
+
for (const [k, v] of Object.entries(opts?.env ?? {})) {
|
|
373
|
+
if (!/^[A-Za-z_][A-Za-z0-9_]*$/.test(k)) {
|
|
374
|
+
throw new Error(`daytona exec: invalid env var name ${JSON.stringify(k)}`);
|
|
375
|
+
}
|
|
376
|
+
prelude.push(`export ${k}=${shq(v)}`);
|
|
377
|
+
}
|
|
378
|
+
const inner = [...prelude, cmd].join("\n");
|
|
379
|
+
return { cmd: `sudo -n -u ${user} -H bash -lc ${shq(inner)}` };
|
|
380
|
+
}
|
|
356
381
|
function getClient(target = "") {
|
|
357
382
|
const cached = clients.get(target);
|
|
358
383
|
if (cached) return cached;
|
|
@@ -634,6 +659,16 @@ Run \`agentbox prepare --provider daytona\` to bake one, or set \`agentbox confi
|
|
|
634
659
|
* `CloudBackend.attachExecLacksTty`.
|
|
635
660
|
*/
|
|
636
661
|
attachExecLacksTty: true,
|
|
662
|
+
/**
|
|
663
|
+
* See `CloudBackend.attachRunAs`. The SSH gateway authenticates with an
|
|
664
|
+
* opaque token and offers no unix user, so a `linux-vm` session lands as root
|
|
665
|
+
* — the class that has no image metadata to say otherwise. Drop it to the box
|
|
666
|
+
* user so the tmux server, the agent and the ctl client are all `vscode`,
|
|
667
|
+
* matching what `exec` now does. `container` already lands there.
|
|
668
|
+
*/
|
|
669
|
+
attachRunAs(h) {
|
|
670
|
+
return h.sandboxClass === "container" ? void 0 : BOX_USER;
|
|
671
|
+
},
|
|
637
672
|
/**
|
|
638
673
|
* Hold off Daytona's auto-stop while the in-box agent is working.
|
|
639
674
|
*
|
|
@@ -682,11 +717,12 @@ Run \`agentbox prepare --provider daytona\` to bake one, or set \`agentbox confi
|
|
|
682
717
|
});
|
|
683
718
|
},
|
|
684
719
|
async exec(h, cmd, opts) {
|
|
720
|
+
const plan = buildDaytonaExec(cmd, h, opts);
|
|
685
721
|
return retry(
|
|
686
722
|
"exec",
|
|
687
723
|
async () => {
|
|
688
724
|
const sb = await getSandbox(h.sandboxId);
|
|
689
|
-
const r = await sb.process.executeCommand(cmd,
|
|
725
|
+
const r = await sb.process.executeCommand(plan.cmd, plan.cwd, plan.env);
|
|
690
726
|
return { exitCode: r.exitCode, stdout: r.result, stderr: "" };
|
|
691
727
|
},
|
|
692
728
|
{ attemptTimeoutMs: opts?.attemptTimeoutMs ?? 12e4, noRetry: opts?.noRetry }
|
|
@@ -698,6 +734,12 @@ Run \`agentbox prepare --provider daytona\` to bake one, or set \`agentbox confi
|
|
|
698
734
|
async () => {
|
|
699
735
|
const sb = await getSandbox(h.sandboxId);
|
|
700
736
|
await sb.fs.uploadFile(localPath, remotePath);
|
|
737
|
+
if (h.sandboxClass !== "container") {
|
|
738
|
+
try {
|
|
739
|
+
await sb.process.executeCommand(`chown ${BOX_USER}: ${shq(remotePath)}`);
|
|
740
|
+
} catch {
|
|
741
|
+
}
|
|
742
|
+
}
|
|
701
743
|
},
|
|
702
744
|
{ attemptTimeoutMs: 3e5 }
|
|
703
745
|
);
|
|
@@ -1013,4 +1055,4 @@ export {
|
|
|
1013
1055
|
readDaytonaCredStatus,
|
|
1014
1056
|
maskKey
|
|
1015
1057
|
};
|
|
1016
|
-
//# sourceMappingURL=chunk-
|
|
1058
|
+
//# sourceMappingURL=chunk-N6EBPKTJ.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../packages/sandbox-daytona/src/dockerfile-context.ts","../../../packages/sandbox-daytona/src/env-loader.ts","../../../packages/sandbox-daytona/src/prepared-state.ts","../../../packages/sandbox-daytona/src/backend.ts","../../../packages/sandbox-daytona/src/snapshot-wait.ts","../../../packages/sandbox-daytona/src/retry.ts","../../../packages/sandbox-daytona/src/credentials.ts"],"sourcesContent":["import { existsSync } from 'node:fs';\nimport { dirname, resolve } from 'node:path';\nimport { fileURLToPath } from 'node:url';\nimport { RUNTIME_ROOT_ENV } from '@agentbox/sandbox-core';\n\n/**\n * Locate `Dockerfile.box` + its build context so Daytona can `Image.fromDockerfile`\n * the same image the Docker provider builds locally. The Dockerfile COPYs from\n * the monorepo (packages/ctl/dist/bin.cjs, apps/cli/share/..., scripts/), so\n * the context dir must contain that tree.\n *\n * Mirrors `@agentbox/sandbox-docker`'s `resolveDockerBuild`, intentionally\n * inlined: sandbox-daytona must not depend on sandbox-docker (cross-provider\n * dep would defeat the point of `@agentbox/sandbox-cloud`).\n *\n * Resolution order:\n * 0. AGENTBOX_DOCKER_CONTEXT env override (points straight at a context dir).\n * 1. AGENTBOX_RUNTIME_ROOT env override → `<root>/docker` (the staged runtime\n * root; lets a source-deployed hub hash the SAME context the CLI baked).\n * 2. Staged context shipped with the bundled `agent-box` package (sibling\n * of dist/, uniform in dev + installed).\n * 3. Legacy monorepo layout: Dockerfile.box at sandbox-docker's package\n * root, context = monorepo root.\n */\nexport interface DockerfileContext {\n dockerfile: string;\n context: string;\n}\n\nexport function resolveDockerfileContext(): DockerfileContext | null {\n const override = process.env.AGENTBOX_DOCKER_CONTEXT;\n if (override && existsSync(resolve(override, 'Dockerfile.box'))) {\n return { dockerfile: resolve(override, 'Dockerfile.box'), context: override };\n }\n const runtimeRoot = process.env[RUNTIME_ROOT_ENV];\n if (runtimeRoot) {\n const ctx = resolve(runtimeRoot, 'docker');\n if (existsSync(resolve(ctx, 'Dockerfile.box'))) {\n return { dockerfile: resolve(ctx, 'Dockerfile.box'), context: ctx };\n }\n }\n const here = dirname(fileURLToPath(import.meta.url));\n const staged = resolve(here, '..', 'runtime', 'docker');\n if (existsSync(resolve(staged, 'Dockerfile.box'))) {\n return { dockerfile: resolve(staged, 'Dockerfile.box'), context: staged };\n }\n // Legacy monorepo: this module is at packages/sandbox-daytona/dist; the\n // Dockerfile lives at packages/sandbox-docker/Dockerfile.box; the build\n // context is the monorepo root.\n const monorepoRoot = resolve(here, '..', '..', '..');\n const dockerfile = resolve(monorepoRoot, 'packages', 'sandbox-docker', 'Dockerfile.box');\n if (existsSync(dockerfile)) {\n return { dockerfile, context: monorepoRoot };\n }\n return null;\n}\n\n/**\n * Locate the daytona-specific `custom-system-CLAUDE.md` that overlays the\n * docker-shaped one baked into `Dockerfile.box`. Daytona boxes have no host\n * `.git/` bind-mount, so the in-box hint needs daytona-specific git wording\n * (use `agentbox-ctl git` for any host-touching op). Same two-tier lookup\n * shape as `resolveDockerfileContext()`: staged CLI runtime first, monorepo\n * source as the dev fallback.\n */\nexport function resolveDaytonaCustomClaudeMd(): string | null {\n const runtimeRoot = process.env[RUNTIME_ROOT_ENV];\n if (runtimeRoot) {\n const overrideMd = resolve(runtimeRoot, 'daytona', 'custom-system-CLAUDE.md');\n if (existsSync(overrideMd)) return overrideMd;\n }\n const here = dirname(fileURLToPath(import.meta.url));\n const staged = resolve(here, '..', 'runtime', 'daytona', 'custom-system-CLAUDE.md');\n if (existsSync(staged)) return staged;\n const monorepoRoot = resolve(here, '..', '..', '..');\n const dev = resolve(\n monorepoRoot,\n 'packages',\n 'sandbox-daytona',\n 'scripts',\n 'custom-system-CLAUDE.md',\n );\n if (existsSync(dev)) return dev;\n return null;\n}\n","import { existsSync, readFileSync } from 'node:fs';\nimport { homedir } from 'node:os';\nimport { resolve } from 'node:path';\n\n/**\n * Daytona env auto-loader. The SDK reads `DAYTONA_API_KEY` /\n * `DAYTONA_JWT_TOKEN` + `DAYTONA_ORGANIZATION_ID` from `process.env`. We pull\n * those keys in from `~/.agentbox/secrets.env` so the SDK Just Works after\n * the user runs `agentbox daytona login` once.\n *\n * Lookup order (first wins; process.env is never overwritten):\n * 1. `process.env` (already set in the shell).\n * 2. `~/.agentbox/secrets.env` — written by `agentbox daytona login`.\n *\n * Project-level `.env` / `.env.local` are intentionally NOT consulted: those\n * files belong to the app code being developed, and a `DAYTONA_API_KEY`\n * there is typically meant for in-box code execution, not for the host CLI\n * to harvest and provision sandboxes with.\n *\n * Only Daytona-prefixed keys are imported; the rest of the file is left\n * alone. The loader is idempotent and side-effect-free after the first call.\n */\nconst DAYTONA_KEYS = [\n 'DAYTONA_API_KEY',\n 'DAYTONA_JWT_TOKEN',\n 'DAYTONA_ORGANIZATION_ID',\n 'DAYTONA_API_URL',\n 'DAYTONA_TARGET',\n] as const;\n\nlet loaded = false;\n\nexport function ensureDaytonaEnvLoaded(): void {\n if (loaded) return;\n loaded = true;\n importDaytonaFromFile(resolve(homedir(), '.agentbox', 'secrets.env'));\n}\n\nfunction importDaytonaFromFile(path: string): void {\n if (!existsSync(path)) return;\n let body: string;\n try {\n body = readFileSync(path, 'utf8');\n } catch {\n return;\n }\n const parsed = parseEnvFile(body);\n for (const key of DAYTONA_KEYS) {\n if (process.env[key] !== undefined) continue;\n const value = parsed[key];\n if (typeof value === 'string') {\n process.env[key] = value;\n }\n }\n}\n\n/**\n * Minimal `.env` parser: handles `KEY=value`, `KEY=\"value with spaces\"`,\n * `KEY='value with $special chars'`, `export KEY=value`, blank lines, and\n * `#` comments. Doesn't do variable interpolation — that's surprising to\n * users coming from full dotenv, but secrets typically don't reference each\n * other and we'd rather be predictable.\n */\nexport function parseEnvFile(body: string): Record<string, string> {\n const out: Record<string, string> = {};\n for (const rawLine of body.split(/\\r?\\n/)) {\n const line = rawLine.trim();\n if (line.length === 0 || line.startsWith('#')) continue;\n const stripped = line.startsWith('export ') ? line.slice('export '.length) : line;\n const eq = stripped.indexOf('=');\n if (eq <= 0) continue;\n const key = stripped.slice(0, eq).trim();\n let value = stripped.slice(eq + 1).trim();\n // Strip surrounding quotes (single or double).\n if (\n value.length >= 2 &&\n ((value.startsWith('\"') && value.endsWith('\"')) ||\n (value.startsWith(\"'\") && value.endsWith(\"'\")))\n ) {\n value = value.slice(1, -1);\n }\n out[key] = value;\n }\n return out;\n}\n","/**\n * Daytona provider's `~/.agentbox/daytona-prepared.json` reader/writer +\n * build-context fingerprinting for the org-scoped base snapshot.\n *\n * The daytona prepare bakes the docker `Dockerfile.box` plus a daytona-\n * specific `custom-system-CLAUDE.md` overlay. The fingerprint covers both\n * — same canonical file map as the docker provider for the dockerfile\n * inputs, plus one extra entry for the daytona overlay.\n */\n\nimport { createHash } from 'node:crypto';\nimport { existsSync } from 'node:fs';\nimport { dirname, resolve } from 'node:path';\nimport { fileURLToPath } from 'node:url';\nimport type { DaytonaSandboxClass } from '@agentbox/config';\nimport {\n claudeInstallFingerprint,\n computeContextSha256,\n DOCKER_CONTEXT_FILE_MAP,\n readCliStamp,\n readPreparedStateRaw,\n resolveContextFilesFrom,\n writePreparedStateRaw,\n type ContextFile,\n type PreparedBaseSnapshot,\n} from '@agentbox/sandbox-core';\nimport { resolveDaytonaCustomClaudeMd, resolveDockerfileContext } from './dockerfile-context.js';\n\nconst SCHEMA = 1 as const;\n\n/** Provider-specific extras baked into the daytona snapshot. `size` is the\n * normalized `cpu-memory-disk` spec the snapshot was created with (absent =\n * a default-resource bake). `class` is the sandbox class it was baked as —\n * absent means a snapshot from before classes existed, i.e. a container.\n * A snapshot's class is immutable and cannot make a sandbox of the other\n * class, so this is what `provision` records on the box record. */\nexport interface DaytonaPreparedExtras {\n size?: string;\n /**\n * The resources the snapshot ACTUALLY has, including when they came from a\n * default rather than an explicit `--size`. Separate from `size` on purpose:\n * `size` is the REQUESTED spec and feeds both `defaultSnapshotName` and\n * `preparedMatches`, so populating it for a default bake would rename every\n * existing snapshot and re-bake the world. This field is advisory only — it\n * lets the \"your size is ignored\" warning name real numbers instead of\n * \"the default size\". Absent when the bake could not know them (a container\n * snapshot created with no resources takes Daytona's server-side default).\n */\n effectiveSize?: string;\n class?: DaytonaSandboxClass;\n /**\n * The box image's `ENV` (`KEY=VALUE` strings), recorded by the linux-vm bake.\n *\n * A VM does NOT inherit the image's env — the conversion keeps the rootfs and\n * drops the metadata — so the bake writes it into the VM's `/etc` AND records\n * it here, because those two cover different processes: on-disk covers login\n * shells, while `create` hands this list to the sandbox as env vars, which is\n * what a plain non-login `exec` (how `agent-browser` starts Chromium) sees.\n * Absent on container bakes, which inherit `ENV` normally.\n */\n env?: string[];\n}\n\nexport type PreparedDaytonaState = PreparedBaseSnapshot<string, DaytonaPreparedExtras>;\n\n/**\n * Resolve every file that influences the daytona base snapshot: the docker\n * build context (shared map from sandbox-core) plus the daytona-specific\n * CLAUDE.md overlay added by `Image.addLocalFile` in `prepare.ts`.\n *\n * Returns `null` if any file is missing — callers degrade to \"always\n * rebuild\" rather than stamp a misleading fingerprint.\n */\nexport function resolveDaytonaContextFiles(): ContextFile[] | null {\n const docker = resolveDockerContextFilesForDaytona();\n if (!docker) return null;\n const overlay = resolveDaytonaCustomClaudeMd();\n if (!overlay) return null;\n return [\n ...docker,\n // Daytona-specific overlay: separate logical name so a docker/daytona\n // CLAUDE.md drift produces different fingerprints (the daytona snapshot\n // contains both files in distinct locations).\n { rel: 'daytona/custom-system-CLAUDE.md', abs: overlay },\n ];\n}\n\n/**\n * Just the DOCKER half of the context — no daytona overlay, no seed-schema salt.\n *\n * This is the exact file set (and therefore the exact sha) that CI hashes when\n * it publishes `ghcr.io/madarco/agentbox/box:sha-<...>`, so it — and only it —\n * can name the published image. The linux-vm bake needs that ref because Daytona\n * builds a VM snapshot only from a prebuilt registry image, never a Dockerfile.\n */\nexport function resolveDockerContextFilesForDaytona(): ContextFile[] | null {\n const ctx = resolveDockerfileContext();\n if (!ctx) return null;\n // sandbox-daytona's package root = parent of src/ or parent of dist/.\n // Mirrors the `resolve(here, '..', '..', '..')` walk in dockerfile-context.ts.\n const here = dirname(fileURLToPath(import.meta.url));\n const packageRoot = resolve(here, '..');\n const monorepoRoot = resolve(here, '..', '..', '..');\n // Docker's dev fallback is anchored at sandbox-docker's root, not\n // sandbox-daytona's, so we pass the monorepo root and prefix the dev\n // paths to walk into packages/sandbox-docker/.\n //\n // Simpler: just point devRoot at sandbox-docker's package root when it\n // exists (legacy monorepo layout).\n const dockerPackageRoot = resolve(monorepoRoot, 'packages', 'sandbox-docker');\n return resolveContextFilesFrom(DOCKER_CONTEXT_FILE_MAP, {\n contextDir: ctx.context,\n devRoot: existsSync(dockerPackageRoot) ? dockerPackageRoot : packageRoot,\n });\n}\n\n/**\n * The docker build-context sha for a given install mode — i.e. the tag of the\n * published GHCR box image the linux-vm base boots from.\n *\n * Folded with `claudeInstallFingerprint`, exactly like the docker pull path\n * (`pullOrBuild`): the same context built with `AGENTBOX_CLAUDE_INSTALL=npm` is\n * a different image and carries a different tag. CI publishes both variants\n * (`.github/workflows/box-image.yml` matrixes over the install mode), so an\n * npm-install bake now has a tag to boot from too — it used to have none, which\n * is why the VM path had to refuse npm outright and fall back to a container.\n */\nexport async function computeDockerBaseSha(\n claudeInstall: 'native' | 'npm' = 'native',\n): Promise<string | null> {\n const files = resolveDockerContextFilesForDaytona();\n if (!files) return null;\n return claudeInstallFingerprint(await computeContextSha256(files), claudeInstall);\n}\n\nexport interface DaytonaFingerprint {\n contextSha256: string;\n files: ContextFile[];\n}\n\n/**\n * Bumped when the daytona seed-bake BUILD LOGIC changes in a way the\n * context-file fingerprint can't see (the files are unchanged but the emitted\n * Dockerfile steps differ). `relctx-1`: switched from absolute `addLocalFile`\n * COPYs (which silently never landed) to relative `dockerfileCommands` COPYs.\n * Folding it into the fingerprint forces existing snapshots to re-bake once.\n */\nconst DAYTONA_SEED_SCHEMA = 'relctx-1';\n\nexport async function computeDaytonaContextFingerprint(): Promise<DaytonaFingerprint | null> {\n const files = resolveDaytonaContextFiles();\n if (!files) return null;\n const rawSha = await computeContextSha256(files);\n const contextSha256 = createHash('sha256')\n .update(`${rawSha}\\0daytona-seed=${DAYTONA_SEED_SCHEMA}`)\n .digest('hex');\n return { contextSha256, files };\n}\n\n/**\n * Compute the CURRENT build-context fingerprint for the daytona base snapshot.\n * Side-effect-free wrapper around `computeDaytonaContextFingerprint` that\n * returns just the SHA (or `undefined` when assets can't be resolved). Used\n * by the CLI's `evaluateBaseFreshness` to compare against the stored\n * `daytona-prepared.json.base.contextSha256`.\n */\nexport async function currentDaytonaBaseFingerprintLive(\n claudeInstall: 'native' | 'npm' = 'native',\n): Promise<string | undefined> {\n try {\n const fp = await computeDaytonaContextFingerprint();\n if (!fp?.contextSha256) return undefined;\n // Fold in claudeInstall exactly as `prepare` does — otherwise an npm-baked\n // base never matches the stored (npm-folded) fingerprint.\n return claudeInstallFingerprint(fp.contextSha256, claudeInstall);\n } catch {\n return undefined;\n }\n}\n\nexport function readPreparedDaytonaState(): PreparedDaytonaState | null {\n const raw = readPreparedStateRaw('daytona');\n if (raw === null || typeof raw !== 'object') return null;\n const parsed = raw as Partial<PreparedDaytonaState>;\n if (parsed.schema !== SCHEMA) return null;\n return { schema: SCHEMA, base: parsed.base, extras: parsed.extras };\n}\n\nexport function writePreparedDaytonaState(opts: {\n snapshotName: string;\n contextSha256: string;\n /** Normalized `cpu-memory-disk` size the snapshot was baked with (absent = default). */\n size?: string;\n /** Resources the snapshot actually has, default included (see DaytonaPreparedExtras). */\n effectiveSize?: string;\n /** Sandbox class the snapshot was baked as. Absent on pre-class bakes = container. */\n class?: DaytonaSandboxClass;\n /** The image env the linux-vm bake had to restore (see DaytonaPreparedExtras). */\n env?: string[];\n}): void {\n const stamp = readCliStamp();\n const extras: DaytonaPreparedExtras = {\n ...(opts.size ? { size: opts.size } : {}),\n ...(opts.effectiveSize ? { effectiveSize: opts.effectiveSize } : {}),\n ...(opts.class ? { class: opts.class } : {}),\n ...(opts.env && opts.env.length > 0 ? { env: opts.env } : {}),\n };\n const state: PreparedDaytonaState = {\n schema: SCHEMA,\n base: {\n imageRef: opts.snapshotName,\n contextSha256: opts.contextSha256,\n cliVersion: stamp.cliVersion,\n cliCommit: stamp.cliCommit,\n createdAt: new Date().toISOString(),\n },\n ...(Object.keys(extras).length > 0 ? { extras } : {}),\n };\n writePreparedStateRaw('daytona', state);\n}\n\n/**\n * A prepared snapshot matches when its build-context fingerprint, its baked\n * size AND its baked class all equal the requested ones. Neither size nor class\n * is folded into `contextSha256` — the live freshness check\n * (`currentDaytonaBaseFingerprintLive`) compares fingerprints only and takes no\n * config, so folding either in would make every sized/classed bake read as\n * \"context drifted\".\n *\n * An absent baked class means a snapshot from before classes existed, which was\n * necessarily a container — so it only matches a container request.\n */\nexport function preparedMatches(\n state: PreparedDaytonaState | null,\n current: string,\n size?: string,\n sandboxClass?: DaytonaSandboxClass,\n): boolean {\n if (state?.base?.contextSha256 !== current) return false;\n if ((state?.extras?.size ?? undefined) !== (size ?? undefined)) return false;\n if (sandboxClass === undefined) return true;\n return (state?.extras?.class ?? 'container') === sandboxClass;\n}\n","/**\n * Daytona `CloudBackend` — maps the provider-neutral cloud primitives onto\n * `@daytona/sdk`. Lazy SDK client + lazy sandbox handle resolution so\n * importing this module costs nothing until a daytona-tagged box does something.\n */\n\nimport { Daytona, DaytonaNotFoundError, Image, SandboxState, type Sandbox } from '@daytona/sdk';\nimport { DAYTONA_VM_REGION } from '@agentbox/config';\nimport type { CloudSandboxSummary } from '@agentbox/core';\nimport type {\n CloudBackend,\n CloudExecOptions,\n CloudExecResult,\n CloudFileEntry,\n CloudHandle,\n CloudPreviewUrl,\n CloudProvisionRequest,\n CloudState,\n CloudVolumeMount,\n} from '@agentbox/core';\nimport { resolveDockerfileContext } from './dockerfile-context.js';\nimport { ensureDaytonaEnvLoaded } from './env-loader.js';\nimport { readPreparedDaytonaState } from './prepared-state.js';\nimport { waitForSnapshotActive } from './snapshot-wait.js';\nimport { withDaytonaRetry } from './retry.js';\n\n/**\n * Thin shorthand for `withDaytonaRetry` with our defaults. Most methods are\n * idempotent and use `retryOnAmbiguous: true`; the few that aren't override.\n */\nfunction retry<T>(\n method: string,\n fn: () => Promise<T>,\n opts: {\n attemptTimeoutMs?: number;\n retryOnAmbiguous?: boolean;\n /** When true, single-shot — no backoff list, no retries. */\n noRetry?: boolean;\n } = {},\n): Promise<T> {\n return withDaytonaRetry(\n {\n method,\n retryOnAmbiguous: opts.retryOnAmbiguous ?? true,\n attemptTimeoutMs: opts.attemptTimeoutMs,\n backoffMs: opts.noRetry === true ? [] : undefined,\n },\n fn,\n );\n}\n\n/**\n * Sentinel image ref the cloud-provider hands to us when the user didn't pass\n * `--image`. We translate it to `Image.fromDockerfile(...)` so Daytona builds\n * the same box image the Docker provider builds locally.\n */\nexport const DEFAULT_BOX_IMAGE_REF = 'agentbox/box:dev';\n\n/**\n * Default sandbox shape — matches Daytona's own `daytona-vm-medium` preset.\n *\n * This MUST be passed explicitly at snapshot-create time. Daytona's true default\n * for a snapshot with no `resources` is 1 vCPU / 1 GiB / **3 GiB disk**, and the\n * box image doesn't fit in 3 GiB: the snapshot build dies mid-pull with a bare\n * \"internal error\".\n */\nexport const DAYTONA_DEFAULT_RESOURCES = { cpu: 2, memory: 4, disk: 8 } as const;\n\n/**\n * Clients keyed by region target ('' = the account default).\n *\n * Region only matters for **create**: `Daytona.create()` places the sandbox in\n * its *client's* target region (the `regionId` create param is ignored), and\n * only `us-east-1` has linux-vm runners. Everything else — `get`, `exec`,\n * `list`, start/stop/pause/delete — is region-agnostic: a default-target client\n * reaches a `us-east-1` sandbox fine and `list()` spans regions (verified\n * 2026-07-12). So the rest of the backend can keep using the default client and\n * only `provision` asks for a targeted one.\n */\nconst clients = new Map<string, Daytona>();\n\n/**\n * The unprivileged user a box's work runs as, matching every other provider\n * (vercel/e2b `BOX_USER`, hetzner/digitalocean `VPS_USER`, docker\n * `CONTAINER_USER`).\n */\nexport const BOX_USER = 'vscode';\n\n/** Single-quote for /bin/sh. */\nfunction shq(s: string): string {\n return `'${s.replace(/'/g, `'\\\\''`)}'`;\n}\n\n/**\n * Decide what Daytona actually runs, honouring `opts.user`.\n *\n * The SDK has NO per-exec user — `executeCommand(command, cwd, env, timeout)`\n * and nothing on sessions or PTYs — so the only lever is an in-shell `sudo -u`,\n * the same one vercel uses (`packages/sandbox-vercel/src/backend.ts`).\n *\n * It is needed because the two sandbox classes land as different users. A\n * `container` honours the image's `USER vscode` metadata and already execs as\n * the box user. A `linux-vm` has no image metadata — the rootfs conversion\n * drops it, which is also why the bake has to hand-repair sudo's setuid bit and\n * re-inject the image's `ENV` — so it execs as **root**, with `HOME=/root`,\n * while every credential and config file is seeded into `/home/vscode`. That\n * mismatch is what left the in-box agent staring at a login prompt.\n *\n * `h.sandboxClass !== 'container'` mirrors `pause()` below: the class is absent\n * on records written before it existed and on the keepalive loop's synthetic\n * handles, and the VM side is the one that needs the wrap, so `undefined` falls\n * there.\n *\n * cwd/env move INSIDE the wrap when we drop: the SDK applies its own arguments\n * to the outer root shell, so a `cd`/`export` passed that way would never reach\n * the dropped user's shell.\n */\nexport function buildDaytonaExec(\n cmd: string,\n h: Pick<CloudHandle, 'sandboxClass'>,\n opts?: CloudExecOptions,\n): { cmd: string; cwd?: string; env?: Record<string, string> } {\n const user = opts?.user ?? BOX_USER;\n const isVm = h.sandboxClass !== 'container';\n // Already the right user: hand the SDK the command untouched. Covers the\n // container class (execs as vscode) and every explicit `user: 'root'` — which\n // the bake relies on, since `sudo` is not setuid until the repair runs and\n // refuses to work at all before then, even for root.\n if (!isVm || user === 'root') {\n return {\n cmd,\n ...(opts?.cwd ? { cwd: opts.cwd } : {}),\n ...(opts?.env ? { env: opts.env } : {}),\n };\n }\n const prelude: string[] = [];\n if (opts?.cwd) prelude.push(`cd ${shq(opts.cwd)}`);\n for (const [k, v] of Object.entries(opts?.env ?? {})) {\n // The value is quoted, but the key is interpolated bare into a shell string\n // that runs as root — reject anything that isn't a POSIX env-var name so a\n // key like `x;rm -rf /` can't inject a command.\n if (!/^[A-Za-z_][A-Za-z0-9_]*$/.test(k)) {\n throw new Error(`daytona exec: invalid env var name ${JSON.stringify(k)}`);\n }\n prelude.push(`export ${k}=${shq(v)}`);\n }\n const inner = [...prelude, cmd].join('\\n');\n // `-n` so a sudoers misconfiguration fails loudly instead of hanging on a\n // password prompt; `-H` so HOME is the target user's.\n return { cmd: `sudo -n -u ${user} -H bash -lc ${shq(inner)}` };\n}\n\nexport function getClient(target = ''): Daytona {\n const cached = clients.get(target);\n if (cached) return cached;\n // Pull DAYTONA_* keys from `.env.local` / `.env` / `~/.agentbox/secrets.env`\n // into process.env first — the SDK reads from process.env and most users\n // keep secrets in a project file rather than their shell rc.\n ensureDaytonaEnvLoaded();\n try {\n // Daytona() reads DAYTONA_API_KEY / DAYTONA_JWT_TOKEN + DAYTONA_ORGANIZATION_ID\n // from env.\n const created = target.length > 0 ? new Daytona({ target }) : new Daytona();\n clients.set(target, created);\n return created;\n } catch (err) {\n const msg = err instanceof Error ? err.message : String(err);\n // The interactive prompt in `agentbox daytona login` handles first-run\n // setup; this error path is for non-TTY callers (CI, scripts) where the\n // prompt was skipped.\n throw new Error(\n `Daytona credentials not configured: ${msg}\\n` +\n `Run \\`agentbox daytona login\\` interactively, or set DAYTONA_API_KEY in the environment.`,\n );\n }\n}\n\nasync function getSandbox(id: string): Promise<Sandbox> {\n return getClient().get(id);\n}\n\nasync function maybeGetSandbox(id: string): Promise<Sandbox | null> {\n try {\n return await getClient().get(id);\n } catch {\n return null;\n }\n}\n\n/**\n * Map Daytona's `SandboxState` (fine-grained, incl. transitional values) onto\n * our 4-value `CloudState`. Transitional states ('starting', 'creating') are\n * reported as 'running' so callers don't ping-pong.\n *\n * Both of Daytona's cold states collapse to our 'paused': `archived` is what a\n * container box gets (our pause == Daytona's archive), `paused` is the real\n * VM freeze. A linux-vm box can never be archived and a container box can never\n * be paused, so the two are mutually exclusive per box — see `pause()`.\n */\nfunction mapState(s: SandboxState | string | undefined): CloudState {\n switch (s) {\n case SandboxState.STARTED:\n return 'running';\n case SandboxState.STARTING:\n case SandboxState.CREATING:\n case SandboxState.RESTORING:\n case SandboxState.BUILDING_SNAPSHOT:\n case SandboxState.PULLING_SNAPSHOT:\n case SandboxState.PENDING_BUILD:\n case SandboxState.STOPPING:\n case SandboxState.RESUMING:\n return 'running';\n case SandboxState.STOPPED:\n return 'stopped';\n case SandboxState.ARCHIVED:\n case SandboxState.ARCHIVING:\n case SandboxState.PAUSED:\n case SandboxState.PAUSING:\n return 'paused';\n case SandboxState.DESTROYED:\n case SandboxState.DESTROYING:\n case SandboxState.ERROR:\n case SandboxState.BUILD_FAILED:\n case SandboxState.UNKNOWN:\n default:\n return 'missing';\n }\n}\n\n/**\n * Translate our provider-neutral `CloudVolumeMount` into the SDK shape Daytona\n * expects. The SDK's `VolumeMount` carries `volumeId` + `mountPath` (+ optional\n * `subpath` for S3-prefix mounts); a 1:1 mapping with our type.\n */\nfunction toDaytonaVolumeMount(v: CloudVolumeMount): {\n volumeId: string;\n mountPath: string;\n subpath?: string;\n} {\n return {\n volumeId: v.volumeId,\n mountPath: v.mountPath,\n ...(v.subpath ? { subpath: v.subpath } : {}),\n };\n}\n\n/** Translate the request's image ref into something Daytona's `create` accepts. */\nfunction resolveImage(ref: string): string | Image {\n if (ref !== DEFAULT_BOX_IMAGE_REF) return ref;\n const ctx = resolveDockerfileContext();\n if (!ctx) {\n throw new Error(\n 'could not locate the AgentBox Dockerfile.box build context for the Daytona snapshot. ' +\n 'Set AGENTBOX_DOCKER_CONTEXT to a directory containing Dockerfile.box, or pass --image <ref> with a Daytona-compatible image.',\n );\n }\n // Image.fromDockerfile bundles the directory the Dockerfile lives in and\n // ships it to Daytona to build a snapshot. The Dockerfile.box COPYs from\n // the monorepo tree; the staged `runtime/docker` context already mirrors\n // that tree, so the build resolves COPY paths correctly.\n return Image.fromDockerfile(ctx.dockerfile);\n}\n\n/**\n * Parse a `cpu-memory-disk` GB size spec (e.g. `4-8-20`) into Daytona's\n * `resources` shape. Returns `undefined` on any malformed input — three\n * positive integer slots are required.\n */\nexport function parseDaytonaSize(\n spec: string | undefined,\n): { cpu: number; memory: number; disk: number } | undefined {\n if (!spec) return undefined;\n const parts = spec.trim().split('-');\n if (parts.length !== 3) return undefined;\n const nums = parts.map((p) => Number(p));\n if (nums.some((n) => !Number.isInteger(n) || n <= 0)) return undefined;\n return { cpu: nums[0]!, memory: nums[1]!, disk: nums[2]! };\n}\n\nexport const daytonaBackend: CloudBackend = {\n name: 'daytona',\n\n async provision(req: CloudProvisionRequest): Promise<CloudHandle> {\n // No-retry: provision is non-idempotent — a 504 after the request reaches\n // the origin could create a duplicate billable sandbox we can't reference\n // for cleanup. The wrapper still bounds wall-clock at 900s (matching the\n // existing inline SDK timeout) so a wedged connection fails cleanly.\n return retry(\n 'provision',\n async () => {\n // Two SDK overloads:\n // - `CreateSandboxFromSnapshotParams` takes `snapshot:` and no\n // `onSnapshotCreateLogs` (the snapshot already exists, nothing to build).\n // - `CreateSandboxFromImageParams` takes `image:` and accepts\n // `onSnapshotCreateLogs` for streaming the Dockerfile build.\n // TypeScript can't infer the right overload from a union literal, so\n // split the call.\n // A `--size` / `box.sizeDaytona` like `4-8-20` overrides the default\n // resources. Note: Daytona rejects `resources` on the snapshot path\n // (stripped below), so this only takes effect when creating from an\n // image — snapshot-resume keeps the snapshot's baked-in resources.\n let sizeResources: { cpu: number; memory: number; disk: number } | undefined;\n if (req.size && req.size.length > 0) {\n sizeResources = parseDaytonaSize(req.size);\n if (!sizeResources) {\n req.onLog?.(\n `daytona: ignoring invalid size '${req.size}' (expected 'cpu-memory-disk' GB, e.g. '4-8-20')`,\n );\n }\n }\n const resources = sizeResources ?? req.resources;\n const prepared = readPreparedDaytonaState();\n const baseRef = req.snapshot ?? req.image;\n const bootingPreparedBase =\n prepared?.base?.imageRef !== undefined && baseRef === prepared.base.imageRef;\n // A linux-vm does NOT inherit the box image's `ENV` — the conversion keeps\n // the rootfs and drops the metadata — so the bake recorded it and we hand\n // it to the sandbox here. The bake also wrote it into the VM's /etc, but\n // that only reaches LOGIN shells; a plain `exec` (which is how the host\n // starts `agent-browser`, hence Chromium) sees only these env vars. Without\n // it there is no DISPLAY and the in-box browser dies with \"Missing X server\".\n // The box's own env (relay tokens, …) wins over the image's.\n const imageEnv: Record<string, string> = {};\n if (bootingPreparedBase) {\n for (const kv of prepared.extras?.env ?? []) {\n const i = kv.indexOf('=');\n if (i > 0) imageEnv[kv.slice(0, i)] = kv.slice(i + 1);\n }\n }\n const baseParams = {\n ...(resources ? { resources } : {}),\n envVars: { ...imageEnv, ...req.env },\n ...(req.volumes && req.volumes.length > 0\n ? { volumes: req.volumes.map(toDaytonaVolumeMount) }\n : {}),\n labels: { 'agentbox.name': req.name },\n // Daytona auto-stops a sandbox after N minutes of INACTIVITY (its own\n // default is 15). The host keepalive loop pushes this forward via\n // `renewTimeout` while an agent is working, so only a genuinely idle\n // box lapses. 0 disables it entirely.\n ...(typeof req.timeoutMs === 'number'\n ? { autoStopInterval: Math.max(0, Math.round(req.timeoutMs / 60_000)) }\n : {}),\n };\n // The class the base we're about to boot was ACTUALLY baked as. A\n // snapshot's class is immutable, so this — not `box.daytonaClass` —\n // decides what kind of box we can create. The two diverge whenever the\n // bake fell back: with no published box image (npm install mode, or any\n // locally shifted fingerprint) a linux-vm bake degrades to a container.\n // Believing config over reality dead-ended the user immediately after a\n // successful `prepare`, with \"no linux-vm base snapshot — run prepare\".\n // Absent `class` on a recorded base = baked before classes existed, i.e.\n // a container.\n const bakedClass = bootingPreparedBase\n ? (prepared.extras?.class ?? 'container')\n : undefined;\n const sandboxClass = bakedClass ?? req.sandboxClass;\n if (bakedClass && req.sandboxClass && bakedClass !== req.sandboxClass) {\n req.onLog?.(\n `daytona: base '${baseRef ?? ''}' was baked as '${bakedClass}', so this box will be a ` +\n `'${bakedClass}' one (box.daytonaClass asks for '${req.sandboxClass}'). ` +\n `Re-bake with \\`agentbox prepare --provider daytona --force\\` to change it.`,\n );\n }\n // `create` places the sandbox in its CLIENT's region — the `regionId`\n // create param is ignored — and only `us-east-1` has linux-vm runners.\n // An explicit `box.daytonaRegion` wins; otherwise derive the region from\n // the class we are actually booting, NOT from the requested one, or a\n // container base gets looked up in the one region that has no container\n // runners (and then reads as \"missing\", which is how this surfaced).\n const region =\n req.location && req.location.length > 0\n ? req.location\n : sandboxClass === 'linux-vm'\n ? DAYTONA_VM_REGION\n : '';\n const client = getClient(region);\n // The first-time Dockerfile.box snapshot build is ~41 layers and pulls\n // Chromium — comfortably 5+ minutes wall time. Daytona's default ready\n // timeout is too short for that; override with 15 min so a cold build\n // doesn't fail mid-snapshot. Cached snapshots and snapshot-based\n // creates come up in seconds.\n // Resolve `req.image` against Daytona's snapshot registry first when\n // it's set to a non-default value: `agentbox prepare --provider\n // daytona` registers a named snapshot and writes `box.image:\n // <name>` into project config; subsequent creates should boot from\n // that snapshot, not try to pull `<name>:latest` from Docker Hub.\n // Default ref (agentbox/box:dev) skips the lookup and goes through\n // resolveImage (Image.fromDockerfile). Explicit `req.snapshot` always\n // wins (cloud checkpoint path).\n let snapshotName = req.snapshot;\n if (!snapshotName && req.image && req.image !== DEFAULT_BOX_IMAGE_REF) {\n try {\n const snap = await client.snapshot.get(req.image);\n if (snap && snap.name) snapshotName = snap.name;\n } catch {\n // Not a known snapshot — fall through and treat as a Docker image ref.\n }\n }\n // Daytona rejects `resources` on the snapshot path — the snapshot's\n // own params encode them. Strip resources only for the snapshot\n // branch; the image branch keeps them.\n const snapshotParams: Record<string, unknown> = { ...baseParams };\n delete snapshotParams.resources;\n // On the snapshot path the size is fixed at bake time. If the user asked\n // for a size that differs from what the snapshot was baked with, warn\n // loudly — silently ignoring `--size` would leave them wondering why the\n // box came up the old size.\n if (snapshotName && sizeResources) {\n const bakedSize = prepared?.extras?.size;\n const requestedKey = `${String(sizeResources.cpu)}-${String(sizeResources.memory)}-${String(sizeResources.disk)}`;\n if (bakedSize !== requestedKey) {\n req.onLog?.(\n `daytona: WARNING — size '${requestedKey}' is ignored on the snapshot path; ` +\n `this snapshot was baked at ${bakedSize ?? 'the default size'}. ` +\n `Daytona resources are fixed at bake time — re-bake with ` +\n `\\`agentbox prepare --provider daytona --size ${requestedKey} --force\\` to change them.`,\n );\n }\n }\n // The image path builds a Dockerfile through Daytona's declarative\n // builder, which is CONTAINER-ONLY. Falling through to it when the user\n // asked for a VM would hand them a container box that silently can't\n // pause — so refuse, and point at the bake that produces a VM base.\n if (!snapshotName && sandboxClass === 'linux-vm') {\n throw new Error(\n `no linux-vm base snapshot for daytona: Daytona can only build a VM snapshot from a ` +\n `prebuilt image, not from a Dockerfile, so there is nothing to boot.\\n` +\n `Run \\`agentbox prepare --provider daytona\\` to bake one, or set ` +\n `\\`agentbox config set box.daytonaClass container\\` to use the container class.`,\n );\n }\n const sandbox = snapshotName\n ? await client.create({ snapshot: snapshotName, ...snapshotParams }, { timeout: 900 })\n : await client.create(\n { image: resolveImage(req.image), ...baseParams },\n {\n timeout: 900,\n ...(req.onLog ? { onSnapshotCreateLogs: req.onLog } : {}),\n },\n );\n // Record the class the box ACTUALLY booted as (resolved above from the\n // base's prepared state), never the requested one — a user whose\n // `box.daytonaClass` disagrees with the snapshot would otherwise have us\n // persist a lie, and `pause()` would then pick the wrong call.\n const bootedClass = sandboxClass;\n return {\n sandboxId: sandbox.id,\n ...(bootedClass ? { sandboxClass: bootedClass } : {}),\n };\n },\n { retryOnAmbiguous: false, attemptTimeoutMs: 900_000 },\n );\n },\n\n async ensureVolume(name: string): Promise<{ volumeId: string }> {\n // Daytona's `volume.get(name, create=true)` returns the existing volume or\n // initiates creation on first call. Critically, a freshly-created volume\n // comes back in `creating`/`pending_create` state — passing such a volume\n // into `Daytona.create({ volumes: […] })` is rejected with\n // \"Volume is not in a ready state. Current state: creating\". So poll\n // `volume.get` until the state lands on `ready` (or a terminal failure).\n //\n // Volumes are org-scoped on Daytona — every sandbox in the same Daytona\n // organization sees the same id, which is what we want for sharing agent\n // credentials across all of a user's boxes.\n //\n // Each individual `volume.get` call is retry-wrapped so a transient edge\n // hiccup mid-poll doesn't fail the whole ensure.\n const client = getClient();\n let vol = await retry('volume.get(create)', () => client.volume.get(name, true));\n // Volumes typically transition from creating → ready within a few seconds.\n // Allow up to 60s in case of slow control-plane operations.\n const deadline = Date.now() + 60_000;\n while (vol.state !== 'ready') {\n if (vol.state === 'error' || vol.state === 'deleted' || vol.state === 'deleting') {\n throw new Error(\n `Daytona volume '${name}' is in unrecoverable state '${vol.state}'. ` +\n `Delete it from the Daytona dashboard and retry.`,\n );\n }\n if (Date.now() >= deadline) {\n throw new Error(\n `Daytona volume '${name}' did not become ready within 60s (state: ${vol.state}). ` +\n `Try again — the Daytona control plane may be slow.`,\n );\n }\n await new Promise((r) => setTimeout(r, 1000));\n vol = await retry('volume.get(poll)', () => client.volume.get(name));\n }\n return { volumeId: vol.id };\n },\n\n async get(sandboxId: string): Promise<CloudHandle | null> {\n return retry('get', async () => {\n const sb = await maybeGetSandbox(sandboxId);\n return sb ? { sandboxId: sb.id } : null;\n });\n },\n\n async list(): Promise<CloudSandboxSummary[]> {\n return retry('list', async () => {\n const client = getClient();\n // `client.list()` is an AsyncIterableIterator that pages internally (it\n // was a single awaited page before SDK 0.196). It spans regions, so one\n // pass sees `us` container boxes and `us-east-1` VM boxes alike.\n const items: CloudSandboxSummary[] = [];\n for await (const sb of client.list()) {\n const summary: CloudSandboxSummary = { sandboxId: sb.id };\n const raw = sb as unknown as {\n name?: string;\n labels?: Record<string, string>;\n state?: string;\n createdAt?: string;\n };\n const friendly = raw.labels?.['agentbox.name'] ?? raw.name;\n if (friendly) summary.name = friendly;\n if (raw.createdAt) summary.createdAt = raw.createdAt;\n if (typeof raw.state === 'string') summary.state = mapState(raw.state);\n items.push(summary);\n }\n return items;\n });\n },\n\n async start(h: CloudHandle): Promise<void> {\n return retry(\n 'start',\n async () => {\n const sb = await getSandbox(h.sandboxId);\n await sb.start();\n },\n { attemptTimeoutMs: 60_000 },\n );\n },\n\n async stop(h: CloudHandle): Promise<void> {\n return retry(\n 'stop',\n async () => {\n const sb = await getSandbox(h.sandboxId);\n await sb.stop();\n },\n { attemptTimeoutMs: 60_000 },\n );\n },\n\n async pause(h: CloudHandle): Promise<void> {\n // The two classes need different calls and each rejects the other's:\n // - linux-vm: `pause()` freezes CPU + memory, so running processes and\n // tmux sessions survive a resume. It cannot be archived\n // (\"Sandboxes in this region or class cannot be archived\").\n // - container: no pause primitive; `archive()` moves it to cold storage\n // (filesystem only) — the historical AgentBox behavior.\n //\n // `h.sandboxClass` comes off the box record. It's absent for records written\n // before the class existed and for the keepalive loop's synthetic handles,\n // so fall back to trying both rather than guessing wrong.\n return retry(\n 'pause',\n async () => {\n const sb = await getSandbox(h.sandboxId);\n // linux-vm: freeze in place, memory and all.\n const freeze = async (): Promise<void> => {\n await sb.pause();\n };\n // container: Daytona archives only a STOPPED sandbox — calling\n // `archive()` on a running one fails with \"Sandbox is not stopped\", so\n // stop it first. (`stop()` is a no-op on an already-stopped sandbox.)\n const archive = async (): Promise<void> => {\n await sb.stop();\n await sb.archive();\n };\n // Try the recorded class first, then the other. The recorded class can\n // be wrong or absent — pre-feature records, the keepalive loop's\n // synthetic handles, and a checkpoint restored while `box.daytonaClass`\n // names the *other* class (the box's real class comes from the snapshot,\n // not from config). Whichever call is wrong is rejected outright rather\n // than doing something surprising, so trying both is safe.\n const preferVm = h.sandboxClass !== 'container';\n try {\n await (preferVm ? freeze() : archive());\n } catch (err) {\n try {\n await (preferVm ? archive() : freeze());\n } catch {\n throw err; // report the failure for the class we believed it was\n }\n }\n },\n { attemptTimeoutMs: 120_000 },\n );\n },\n\n async resume(h: CloudHandle): Promise<void> {\n // `start()` resumes both classes — a paused VM thaws (memory intact), an\n // archived container is restored from cold storage.\n return retry(\n 'resume',\n async () => {\n const sb = await getSandbox(h.sandboxId);\n await sb.start();\n },\n { attemptTimeoutMs: 60_000 },\n );\n },\n\n /**\n * Daytona's `autoStopInterval` is an idle window that any request to the\n * sandbox resets — including the host relay's own continuous preview-URL\n * polling, which therefore holds every tracked box open forever. The host\n * keepalive loop reads this and pauses an idle box itself instead of waiting\n * for a lapse that never comes. See `CloudBackend.timeoutModel`.\n */\n timeoutModel: 'inactivity',\n\n /**\n * Daytona's SSH gateway gives a shell session a terminal but an exec session\n * none — `ssh -tt <token>@ssh.app.daytona.io 'tty'` answers \"not a tty\" while\n * the same connection with no command lands on /dev/pts/1. So interactive\n * attach connects command-less and gets its command via stdin. See\n * `CloudBackend.attachExecLacksTty`.\n */\n attachExecLacksTty: true,\n\n /**\n * See `CloudBackend.attachRunAs`. The SSH gateway authenticates with an\n * opaque token and offers no unix user, so a `linux-vm` session lands as root\n * — the class that has no image metadata to say otherwise. Drop it to the box\n * user so the tmux server, the agent and the ctl client are all `vscode`,\n * matching what `exec` now does. `container` already lands there.\n */\n attachRunAs(h: CloudHandle): string | undefined {\n return h.sandboxClass === 'container' ? undefined : BOX_USER;\n },\n\n /**\n * Hold off Daytona's auto-stop while the in-box agent is working.\n *\n * Daytona's timeout is an INACTIVITY window, not an absolute deadline like\n * vercel's/e2b's, so there is nothing to extend to a target time — the box\n * simply needs to look active. `refreshActivity()` resets that clock, which\n * grants another full `autoStopInterval`. So both deadline args are unused:\n * the host loop calls us precisely when it wants the box kept alive, and that\n * call is the whole signal.\n */\n async renewTimeout(h: CloudHandle): Promise<void> {\n await retry(\n 'renewTimeout',\n async () => {\n const sb = await getSandbox(h.sandboxId);\n await sb.refreshActivity();\n },\n { attemptTimeoutMs: 30_000 },\n );\n },\n\n async destroy(h: CloudHandle): Promise<void> {\n return retry(\n 'destroy',\n async () => {\n const sb = await maybeGetSandbox(h.sandboxId);\n if (!sb) return; // already gone — destroy is idempotent\n // Daytona's `delete()` on a running sandbox is queued, not synchronous —\n // observed in practice: `delete()` returns ok, the sandbox stays in\n // 'started' for tens of seconds, then eventually disappears. Stopping\n // first makes the delete synchronous so callers (and the dashboard) see\n // it gone immediately. Swallow stop errors — if the sandbox is already\n // stopped/archived, delete still works.\n try {\n await sb.stop(60);\n } catch {\n /* best-effort */\n }\n try {\n await sb.delete(60);\n } catch (err) {\n const msg = err instanceof Error ? err.message : String(err);\n // Already deleted between stop and delete — fine.\n if (!/not found/i.test(msg)) throw err;\n }\n },\n { attemptTimeoutMs: 120_000 },\n );\n },\n\n async state(h: CloudHandle): Promise<CloudState> {\n return retry('state', async () => {\n const sb = await maybeGetSandbox(h.sandboxId);\n if (!sb) return 'missing';\n return mapState(sb.state);\n });\n },\n\n async exec(h: CloudHandle, cmd: string, opts?: CloudExecOptions): Promise<CloudExecResult> {\n const plan = buildDaytonaExec(cmd, h, opts);\n return retry(\n 'exec',\n async () => {\n const sb = await getSandbox(h.sandboxId);\n // Daytona's ExecuteResponse returns combined output in `result` with no\n // separate stderr stream. Surface it as stdout and leave stderr empty —\n // callers that need split streams must redirect inside `cmd` itself.\n //\n // cwd/env go through the SDK only when we are NOT dropping privileges;\n // the wrapped form folds them into the inner shell instead (see\n // buildDaytonaExec).\n const r = await sb.process.executeCommand(plan.cmd, plan.cwd, plan.env);\n return { exitCode: r.exitCode, stdout: r.result, stderr: '' };\n },\n { attemptTimeoutMs: opts?.attemptTimeoutMs ?? 120_000, noRetry: opts?.noRetry },\n );\n },\n\n async uploadFile(h: CloudHandle, localPath: string, remotePath: string): Promise<void> {\n return retry(\n 'uploadFile',\n async () => {\n const sb = await getSandbox(h.sandboxId);\n await sb.fs.uploadFile(localPath, remotePath);\n // The toolbox writes as its own identity — root on a linux-vm — while\n // `exec` now drops to the box user. Every caller that uploads a tarball\n // then extracts and `rm`s it would break on the mismatch: /tmp is\n // sticky, so a non-owner cannot unlink a root-owned file there, and the\n // seed died on exactly that (\"rm: cannot remove … Operation not\n // permitted\"). Hand the file to the box user, as e2b's uploadFile does.\n //\n // Best-effort: the file is present and readable either way, and the\n // container class already writes as the box user.\n if (h.sandboxClass !== 'container') {\n try {\n await sb.process.executeCommand(`chown ${BOX_USER}: ${shq(remotePath)}`);\n } catch {\n // ignore — an unchowned upload is still readable\n }\n }\n },\n { attemptTimeoutMs: 300_000 },\n );\n },\n\n async downloadFile(h: CloudHandle, remotePath: string, localPath: string): Promise<void> {\n return retry(\n 'downloadFile',\n async () => {\n const sb = await getSandbox(h.sandboxId);\n await sb.fs.downloadFile(remotePath, localPath);\n },\n { attemptTimeoutMs: 300_000 },\n );\n },\n\n async listFiles(h: CloudHandle, remoteDir: string): Promise<CloudFileEntry[]> {\n return retry('listFiles', async () => {\n const sb = await getSandbox(h.sandboxId);\n const files = await sb.fs.listFiles(remoteDir);\n return files.map((f) => ({\n name: f.name,\n isDir: Boolean((f as { isDir?: boolean }).isDir),\n }));\n });\n },\n\n async previewUrl(h: CloudHandle, port: number): Promise<CloudPreviewUrl> {\n return retry('previewUrl', async () => {\n const sb = await getSandbox(h.sandboxId);\n const p = await sb.getPreviewLink(port);\n // The host CloudBoxPoller attaches `token` as `x-daytona-preview-token`\n // for every /bridge call. Browser-bound URLs use `signedPreviewUrl` below\n // instead (the two token kinds are not interchangeable on Daytona).\n return { url: p.url, token: p.token };\n });\n },\n\n async signedPreviewUrl(\n h: CloudHandle,\n port: number,\n expiresInSeconds: number,\n ): Promise<CloudPreviewUrl> {\n return retry('signedPreviewUrl', async () => {\n const sb = await getSandbox(h.sandboxId);\n const s = await sb.getSignedPreviewUrl(port, expiresInSeconds);\n return { url: s.url, token: s.token };\n });\n },\n\n async attachArgv(h: CloudHandle): Promise<string[]> {\n return retry('attachArgv', async () => {\n const sb = await getSandbox(h.sandboxId);\n // 60 min default expiry matches the SDK default; an interactive session\n // longer than that is rare. `sandbox-cloud`'s buildAttach appends\n // `-t '<inner cmd>'` for the per-session tmux attach.\n const ssh = await sb.createSshAccess(60);\n return [\n 'ssh',\n // First-connect to a never-seen host fingerprint should be silent in a\n // PTY — the user already authenticated via Daytona's API.\n '-o',\n 'StrictHostKeyChecking=accept-new',\n // Daytona's SSH gateway terminates per-token; no key file, no port.\n `${ssh.token}@ssh.app.daytona.io`,\n ];\n });\n },\n\n async revokeAttachToken(h: CloudHandle, argv: string[]): Promise<void> {\n // argv[3] = `${token}@ssh.app.daytona.io`; pull the token off the front.\n const userhost = argv[argv.length - 1] ?? '';\n const atIdx = userhost.indexOf('@');\n if (atIdx <= 0) return;\n const token = userhost.slice(0, atIdx);\n if (token.length === 0) return;\n try {\n await retry('revokeAttachToken', async () => {\n const sb = await getSandbox(h.sandboxId);\n await sb.revokeSshAccess(token);\n });\n } catch {\n // Best-effort — tokens auto-expire after 60 min anyway.\n }\n },\n\n async createSnapshot(h: CloudHandle, snapshotName: string): Promise<void> {\n // A cold (filesystem-only) snapshot requires the sandbox STOPPED, and the\n // API does not stop it for you — a capture attempted on a running sandbox\n // is rejected. So: stop, capture, start again. The caller is responsible for\n // reconnecting the box afterwards (the stop kills ctl/dockerd/tmux) — see\n // `makeDaytonaCheckpoint`.\n //\n // The hot variant (filesystem + memory, linux-vm only) would avoid the stop\n // entirely, but it needs `includeMemory`, and the published TS SDK silently\n // drops that argument. Out of reach until upstream fixes the wrapper.\n //\n // No retry on ambiguous failures: a 504 mid-capture could leave a half-built\n // named snapshot that a retry would collide on. Matches `provision`'s policy.\n return retry(\n 'createSnapshot',\n async () => {\n const sb = await getSandbox(h.sandboxId);\n await sb.stop();\n try {\n await sb._experimental_createSnapshot(snapshotName, 900);\n await waitForSnapshotActive(getClient(), snapshotName);\n } finally {\n // Always bring the box back, even if the capture failed — leaving a\n // user's box stopped because a checkpoint errored is a worse outcome\n // than the failed checkpoint itself.\n await sb.start();\n }\n },\n { attemptTimeoutMs: 900_000, retryOnAmbiguous: false },\n );\n },\n\n async deleteSnapshot(snapshotName: string): Promise<void> {\n return retry('deleteSnapshot', async () => {\n try {\n const client = getClient();\n const snapshot = await client.snapshot.get(snapshotName);\n await client.snapshot.delete(snapshot);\n } catch (err) {\n // Idempotent: a snapshot that's already gone is success from the\n // caller's perspective (mirrors `destroy()`'s \"not found\" handling).\n if (err instanceof DaytonaNotFoundError) return;\n const msg = err instanceof Error ? err.message : String(err);\n if (/not found/i.test(msg)) return;\n throw err;\n }\n });\n },\n};\n","/**\n * Wait for a Daytona snapshot to reach `active`.\n *\n * `_experimental_createSnapshot` returns once the capture is *requested*; the\n * snapshot only becomes usable a little later. Acting on it before then — a\n * `create({ snapshot })`, or deleting the source sandbox — is racy, so every\n * capture path waits here first.\n *\n * Its own module because both the VM bake and the checkpoint path need it, and\n * the bake imports the backend (which owns the checkpoint), so a shared home\n * avoids an import cycle.\n */\nimport type { Daytona } from '@daytona/sdk';\n\nexport async function waitForSnapshotActive(\n client: Daytona,\n name: string,\n timeoutMs = 900_000,\n): Promise<void> {\n const deadline = Date.now() + timeoutMs;\n for (;;) {\n let state: string | undefined;\n try {\n state = (await client.snapshot.get(name))?.state;\n } catch {\n // A just-requested snapshot can 404 briefly before it's registered.\n state = undefined;\n }\n if (state === 'active') return;\n if (state === 'error' || state === 'build_failed') {\n throw new Error(`daytona snapshot '${name}' ended in state '${state}'`);\n }\n if (Date.now() >= deadline) {\n throw new Error(\n `daytona snapshot '${name}' did not become active within ${String(Math.round(timeoutMs / 60_000))} min ` +\n `(state: ${state ?? 'unknown'})`,\n );\n }\n await new Promise((r) => setTimeout(r, 3000));\n }\n}\n","/**\n * Bounded retry wrapper for `daytonaBackend` SDK calls. Daytona's CloudFront\n * edge intermittently 504s on `executeCommand` and other API calls (backlog\n * item 6.1) — without bounded retries an edge hiccup propagates as an\n * unbounded wedge in the calling code. This helper classifies transient\n * failures vs. permanent ones using the SDK's typed error classes, bounds\n * each attempt with a timeout, and caps the total wall-clock cost.\n *\n * Non-idempotent ops (`provision`) pass `retryOnAmbiguous: false` so a 504\n * after the request reached the origin doesn't create a duplicate sandbox.\n */\n\nimport {\n DaytonaAuthenticationError,\n DaytonaAuthorizationError,\n DaytonaConflictError,\n DaytonaConnectionError,\n DaytonaError,\n DaytonaNotFoundError,\n DaytonaRateLimitError,\n DaytonaTimeoutError,\n DaytonaValidationError,\n} from '@daytona/sdk';\n\nexport interface WithRetryOptions {\n /** Method name, used in retry log lines. */\n method: string;\n /** Per-attempt timeout (ms). Default 30_000. */\n attemptTimeoutMs?: number;\n /** Backoff before attempts 2, 3, … (ms). Default [1000, 2000, 4000]. */\n backoffMs?: readonly number[];\n /**\n * Whether to retry on errors where we can't be sure the server applied\n * the request — connection failures, per-attempt timeouts, and 5xx\n * responses (since 504 from CloudFront can mean \"origin still processing\").\n * Set false for non-idempotent operations (e.g. `provision`) where a\n * retry could create a duplicate.\n */\n retryOnAmbiguous: boolean;\n /** Override the default `process.stderr` retry sink (used by tests). */\n onRetry?: (line: string) => void;\n}\n\nconst DEFAULT_BACKOFF: readonly number[] = [1000, 2000, 4000];\nconst DEFAULT_ATTEMPT_TIMEOUT_MS = 30_000;\n\n/** Internal sentinel used by the per-attempt timeout race. */\nclass AttemptTimeoutError extends Error {\n constructor(method: string, ms: number) {\n super(`daytona ${method}: per-attempt timeout after ${String(ms)}ms`);\n this.name = 'AttemptTimeoutError';\n }\n}\n\nexport function isAttemptTimeout(err: unknown): err is AttemptTimeoutError {\n return err instanceof AttemptTimeoutError;\n}\n\n/**\n * Classify an error as retriable or not. `allowAmbiguous` gates the cases\n * where the server may or may not have applied the request — the caller\n * decides based on idempotency.\n */\nexport function isRetriable(err: unknown, allowAmbiguous: boolean): boolean {\n // Rate-limit responses always carry an intent from the server: back off.\n if (err instanceof DaytonaRateLimitError) return true;\n\n // Permanent client-side failures: never retry — the next call will get\n // the same answer and we'd just be wasting wall-clock.\n if (\n err instanceof DaytonaNotFoundError ||\n err instanceof DaytonaAuthenticationError ||\n err instanceof DaytonaAuthorizationError ||\n err instanceof DaytonaValidationError ||\n err instanceof DaytonaConflictError\n ) {\n return false;\n }\n\n // Connection / per-attempt timeout: the request may not have reached\n // the server. Gated by allowAmbiguous so non-idempotent callers can opt\n // out of double-execute risk.\n if (\n err instanceof DaytonaConnectionError ||\n err instanceof DaytonaTimeoutError ||\n err instanceof AttemptTimeoutError\n ) {\n return allowAmbiguous;\n }\n\n // Base DaytonaError: branch on statusCode. 5xx is ambiguous; 4xx we\n // didn't catch above is a permanent failure we hadn't seen before.\n if (err instanceof DaytonaError) {\n const status = err.statusCode;\n if (typeof status === 'number' && status >= 500 && status <= 599) {\n return allowAmbiguous;\n }\n return false;\n }\n\n // Axios-style fallback for raw errors that leak through without an SDK\n // wrapper. Match the same shape the SDK uses internally.\n if (err && typeof err === 'object') {\n const code = (err as { code?: unknown }).code;\n if (\n code === 'ECONNRESET' ||\n code === 'ETIMEDOUT' ||\n code === 'ECONNABORTED' ||\n code === 'EAI_AGAIN' ||\n code === 'ECONNREFUSED' ||\n code === 'ENOTFOUND'\n ) {\n return allowAmbiguous;\n }\n const status =\n (err as { response?: { status?: unknown } }).response?.status ??\n (err as { status?: unknown }).status ??\n (err as { statusCode?: unknown }).statusCode;\n if (typeof status === 'number' && status >= 500 && status <= 599) {\n return allowAmbiguous;\n }\n }\n\n return false;\n}\n\n/**\n * Run `fn`, retrying on transient failures with capped exponential backoff.\n * Each attempt is bounded by `attemptTimeoutMs` via Promise.race; total\n * wall-clock = sum(backoffMs) + maxAttempts * attemptTimeoutMs.\n */\nexport async function withDaytonaRetry<T>(\n opts: WithRetryOptions,\n fn: () => Promise<T>,\n): Promise<T> {\n const backoff = opts.backoffMs ?? DEFAULT_BACKOFF;\n const maxAttempts = backoff.length + 1;\n const timeoutMs = opts.attemptTimeoutMs ?? DEFAULT_ATTEMPT_TIMEOUT_MS;\n const log = opts.onRetry ?? defaultRetryLog;\n\n for (let attempt = 1; attempt <= maxAttempts; attempt++) {\n try {\n return await raceTimeout(fn(), timeoutMs, opts.method);\n } catch (err) {\n const last = attempt === maxAttempts;\n if (last || !isRetriable(err, opts.retryOnAmbiguous)) throw err;\n const delay = backoff[attempt - 1] ?? backoff[backoff.length - 1] ?? 4000;\n log(\n `daytona ${opts.method}: attempt ${String(attempt)} failed (${errorSummary(err)}); retrying in ${String(delay)}ms`,\n );\n await sleep(delay);\n }\n }\n // Unreachable: the loop above either returns or throws.\n throw new Error(`withDaytonaRetry: exhausted attempts for ${opts.method}`);\n}\n\nfunction defaultRetryLog(line: string): void {\n // Prefix so log scrapers + users can distinguish retry chatter from real\n // CLI output. `\\n` before is intentional — many CLI surfaces use clack\n // spinners on stdout, and stderr lines without a leading newline can\n // collide with a redraw.\n process.stderr.write(`\\n[daytona-retry] ${line}\\n`);\n}\n\nfunction sleep(ms: number): Promise<void> {\n return new Promise((resolve) => setTimeout(resolve, ms));\n}\n\nasync function raceTimeout<T>(p: Promise<T>, ms: number, method: string): Promise<T> {\n let timer: ReturnType<typeof setTimeout> | undefined;\n try {\n return await Promise.race([\n p,\n new Promise<never>((_resolve, reject) => {\n timer = setTimeout(() => reject(new AttemptTimeoutError(method, ms)), ms);\n }),\n ]);\n } finally {\n if (timer !== undefined) clearTimeout(timer);\n }\n}\n\nfunction errorSummary(err: unknown): string {\n if (err instanceof DaytonaError) {\n const status = err.statusCode;\n const cls = err.constructor.name;\n return `${cls}${typeof status === 'number' ? ` ${String(status)}` : ''}: ${truncate(err.message)}`;\n }\n if (err instanceof Error) {\n const code = (err as { code?: unknown }).code;\n return code !== undefined ? `${err.name}(${String(code)}): ${truncate(err.message)}` : `${err.name}: ${truncate(err.message)}`;\n }\n return truncate(String(err));\n}\n\nfunction truncate(s: string, max = 160): string {\n return s.length > max ? `${s.slice(0, max)}…` : s;\n}\n","import { spawnSync } from 'node:child_process';\nimport {\n hostOpenCommand,\n publishManagedCredentials,\n writeManagedSecrets,\n type CredSetResult,\n} from '@agentbox/sandbox-core';\nimport { homedir } from 'node:os';\nimport { resolve } from 'node:path';\nimport {\n cancel,\n confirm,\n isCancel,\n intro,\n log,\n note,\n outro,\n password,\n spinner,\n text,\n} from '@clack/prompts';\nimport { ensureDaytonaEnvLoaded } from './env-loader.js';\n\n// Ctrl+C at a prompt resolves with the cancel symbol; turn that into a real\n// quit so the command never silently continues as if the user answered \"No\".\nfunction exitOnCancel<T>(v: T | symbol): T {\n if (isCancel(v)) {\n cancel('Cancelled.');\n process.exit(130);\n }\n return v as T;\n}\n\nconst DASHBOARD_KEYS_URL = 'https://app.daytona.io/dashboard/keys';\n\n/**\n * Keys we manage in `~/.agentbox/secrets.env`. When the user reconfigures we\n * strip any prior values for these keys before appending the new ones so the\n * file never accumulates duplicates.\n */\nconst MANAGED_KEYS = ['DAYTONA_API_KEY', 'DAYTONA_JWT_TOKEN', 'DAYTONA_ORGANIZATION_ID'] as const;\ntype ManagedKey = (typeof MANAGED_KEYS)[number];\n\nexport interface EnsureDaytonaCredentialsOptions {\n /** Re-prompt even when valid credentials are already present (used by `agentbox daytona login`). */\n force?: boolean;\n}\n\n/**\n * First-run interactive setup for Daytona credentials. Walks the user through\n * opening the dashboard, pasting an API key (or JWT + organization ID), and\n * persists the result to `~/.agentbox/secrets.env` — which the env-loader\n * already picks up for every cloud command.\n *\n * No-op when credentials are already configured (env var or our secrets\n * file). Silent no-op when stdin isn't a TTY so scripted/CI callers get the\n * \"credentials not configured\" error from the SDK instead of a hung prompt.\n */\nexport async function ensureDaytonaCredentials(\n opts: EnsureDaytonaCredentialsOptions = {},\n): Promise<void> {\n ensureDaytonaEnvLoaded();\n\n if (!opts.force && hasUsableCredentials()) return;\n if (!process.stdin.isTTY) return;\n\n intro('Daytona setup');\n note(\n `AgentBox needs a Daytona API key to provision cloud boxes.\\n` +\n `Generate one at ${DASHBOARD_KEYS_URL}`,\n 'API key required',\n );\n\n const open = exitOnCancel(\n await confirm({\n message: `Open ${DASHBOARD_KEYS_URL} in your browser?`,\n initialValue: true,\n }),\n );\n if (open) openDashboard();\n\n // One retry on auth failure (typos are the common case). Beyond that we bail\n // and surface the validation error; the user can re-run `agentbox daytona login`.\n for (let attempt = 0; attempt < 2; attempt++) {\n const creds = await promptForCredentials();\n\n const result = await validateCredentials(creds);\n if (result.ok) {\n persistCredentials(creds);\n log.success(`Daytona credentials saved to ${secretsPath()}`);\n await publishDaytonaToHub(creds);\n outro('Setup complete.');\n return;\n }\n if (result.kind === 'auth' && attempt === 0) {\n log.error(`That key was rejected by Daytona: ${result.message}`);\n log.info('Try again, or press Ctrl-C to cancel.');\n continue;\n }\n if (result.kind === 'network') {\n log.warn(`Could not reach Daytona to validate (${result.message}) — saving anyway.`);\n persistCredentials(creds);\n log.success(`Daytona credentials saved to ${secretsPath()}`);\n await publishDaytonaToHub(creds);\n outro('Setup complete (unvalidated).');\n return;\n }\n throw new Error(`Daytona credentials rejected: ${result.message}`);\n }\n}\n\nfunction hasUsableCredentials(): boolean {\n if (process.env.DAYTONA_API_KEY) return true;\n if (process.env.DAYTONA_JWT_TOKEN && process.env.DAYTONA_ORGANIZATION_ID) return true;\n return false;\n}\n\ninterface Credentials {\n apiKey?: string;\n jwtToken?: string;\n organizationId?: string;\n}\n\nasync function promptForCredentials(): Promise<Credentials> {\n const key = exitOnCancel(\n await password({\n message: 'Paste your Daytona API key (or JWT token)',\n validate(v) {\n if (!v || v.trim().length === 0) return 'Cannot be empty';\n return undefined;\n },\n }),\n );\n const trimmed = key.trim();\n\n // JWTs start with `eyJ` (base64-encoded `{\"`). API keys don't, and don't need\n // an org ID — the SDK derives it from the key. Only ask for org ID for JWTs.\n if (trimmed.startsWith('eyJ')) {\n const org = exitOnCancel(\n await text({\n message: 'Paste your Daytona organization ID',\n placeholder: 'org_...',\n validate(v) {\n if (!v || v.trim().length === 0) return 'Cannot be empty';\n return undefined;\n },\n }),\n );\n return { jwtToken: trimmed, organizationId: org.trim() };\n }\n\n return { apiKey: trimmed };\n}\n\ntype ValidationResult =\n | { ok: true }\n | { ok: false; kind: 'auth'; message: string }\n | { ok: false; kind: 'network'; message: string };\n\nasync function validateCredentials(creds: Credentials): Promise<ValidationResult> {\n const s = spinner();\n s.start('Validating credentials with Daytona');\n\n // Snapshot existing env so we can restore on failure — never poison\n // process.env with a bad key.\n const snapshot = snapshotManagedEnv();\n applyToEnv(creds);\n\n try {\n // Dynamic import so the SDK only loads when we actually need it (keeps the\n // Docker hot path lean, same reason as the provider registry).\n const { Daytona } = await import('@daytona/sdk');\n const client = new Daytona();\n await client.list();\n s.stop('Daytona credentials accepted');\n return { ok: true };\n } catch (err) {\n restoreManagedEnv(snapshot);\n const message = err instanceof Error ? err.message : String(err);\n s.stop('Daytona credentials check failed');\n if (/401|403|unauthor|forbidden|invalid/i.test(message)) {\n return { ok: false, kind: 'auth', message };\n }\n return { ok: false, kind: 'network', message };\n }\n}\n\nfunction snapshotManagedEnv(): Record<ManagedKey, string | undefined> {\n const out = {} as Record<ManagedKey, string | undefined>;\n for (const k of MANAGED_KEYS) out[k] = process.env[k];\n return out;\n}\n\nfunction restoreManagedEnv(snap: Record<ManagedKey, string | undefined>): void {\n for (const k of MANAGED_KEYS) {\n if (snap[k] === undefined) delete process.env[k];\n else process.env[k] = snap[k];\n }\n}\n\nfunction applyToEnv(creds: Credentials): void {\n // Wipe the other auth method so the SDK doesn't get confused by stale env\n // (e.g. an old JWT lingering from a previous shell export).\n for (const k of MANAGED_KEYS) delete process.env[k];\n if (creds.apiKey) process.env.DAYTONA_API_KEY = creds.apiKey;\n if (creds.jwtToken) process.env.DAYTONA_JWT_TOKEN = creds.jwtToken;\n if (creds.organizationId) process.env.DAYTONA_ORGANIZATION_ID = creds.organizationId;\n}\n\nfunction persistCredentials(creds: Credentials): void {\n // Only the provided auth method's keys are written; `writeManagedSecrets`\n // strips every managed key first, so a stale JWT is cleared when switching to\n // an API key (and vice-versa). Unrelated DAYTONA_API_URL / DAYTONA_TARGET the\n // user dropped in the file stay untouched.\n const record: Record<string, string> = {};\n if (creds.apiKey) record.DAYTONA_API_KEY = creds.apiKey;\n if (creds.jwtToken) record.DAYTONA_JWT_TOKEN = creds.jwtToken;\n if (creds.organizationId) record.DAYTONA_ORGANIZATION_ID = creds.organizationId;\n writeManagedSecrets(MANAGED_KEYS, record);\n}\n\n/**\n * Mirror the just-saved credentials to the hub. Best-effort; the local\n * secrets.env write stays for the direct IO plane — see publishManagedCredentials.\n */\nasync function publishDaytonaToHub(creds: Credentials): Promise<void> {\n const fields: Record<string, string> = {};\n if (creds.apiKey) fields.apiKey = creds.apiKey;\n if (creds.jwtToken) fields.jwtToken = creds.jwtToken;\n if (creds.organizationId) fields.organizationId = creds.organizationId;\n await publishManagedCredentials('daytona', fields);\n}\n\n/**\n * Non-interactive credential set (the headless path the hub drives). Accepts\n * either `{ apiKey }` or `{ jwtToken, organizationId }`, validates against\n * Daytona (a cheap `list()`), then persists to `~/.agentbox/secrets.env`. A\n * network failure still persists (offline host isn't blocked) but reports a\n * warning label.\n */\nexport async function setDaytonaCredentials(\n fields: Record<string, string>,\n): Promise<CredSetResult> {\n const apiKey = (fields.apiKey ?? '').trim();\n const jwtToken = (fields.jwtToken ?? '').trim();\n const organizationId = (fields.organizationId ?? '').trim();\n let creds: Credentials;\n if (apiKey) {\n creds = { apiKey };\n } else if (jwtToken && organizationId) {\n creds = { jwtToken, organizationId };\n } else {\n return {\n ok: false,\n error: 'provide apiKey, or jwtToken + organizationId',\n status: { configured: false },\n };\n }\n const result = await validateCredentials(creds);\n if (!result.ok && result.kind === 'auth') {\n return {\n ok: false,\n error: `credentials rejected by Daytona: ${result.message}`,\n status: { configured: false },\n };\n }\n persistCredentials(creds);\n const label = result.ok ? (creds.apiKey ? 'key' : 'jwt') : 'key (unvalidated)';\n return { ok: true, status: { configured: true, label } };\n}\n\nfunction openDashboard(): void {\n try {\n const r = spawnSync(hostOpenCommand(), [DASHBOARD_KEYS_URL], { stdio: 'ignore' });\n if (r.status !== 0) {\n log.warn(`Could not auto-open the browser — visit ${DASHBOARD_KEYS_URL} manually.`);\n }\n } catch {\n log.warn(`Could not auto-open the browser — visit ${DASHBOARD_KEYS_URL} manually.`);\n }\n}\n\nexport function secretsPath(): string {\n return resolve(homedir(), '.agentbox', 'secrets.env');\n}\n\n/** What's currently configured. Used by `daytona login --status`. */\nexport interface DaytonaCredStatus {\n apiKey?: string;\n jwtToken?: string;\n organizationId?: string;\n source: 'env' | 'secrets.env' | 'none';\n}\n\nexport function readDaytonaCredStatus(): DaytonaCredStatus {\n // Snapshot what the shell already had before the loader runs so we can\n // distinguish env-from-shell from env-loaded-from-secrets.env.\n const shellHadKey = !!process.env.DAYTONA_API_KEY || !!process.env.DAYTONA_JWT_TOKEN;\n ensureDaytonaEnvLoaded();\n const apiKey = process.env.DAYTONA_API_KEY;\n const jwtToken = process.env.DAYTONA_JWT_TOKEN;\n const organizationId = process.env.DAYTONA_ORGANIZATION_ID;\n if (!apiKey && !jwtToken) return { source: 'none' };\n return {\n apiKey,\n jwtToken,\n organizationId,\n source: shellHadKey ? 'env' : 'secrets.env',\n };\n}\n\nexport function maskKey(value: string): string {\n if (value.length <= 8) return '*'.repeat(value.length);\n return `${value.slice(0, 4)}…${'*'.repeat(8)}${value.slice(-4)}`;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA,SAAS,kBAAkB;AAC3B,SAAS,SAAS,eAAe;AACjC,SAAS,qBAAqB;ACF9B,S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ath","log","DaytonaNotFoundError","Daytona"]}
|
|
@@ -7,13 +7,13 @@ import {
|
|
|
7
7
|
hostKeyDir,
|
|
8
8
|
listHostAliases,
|
|
9
9
|
parseRemoteTarget
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-MS4NWRXN.js";
|
|
11
11
|
import {
|
|
12
12
|
HubApiError
|
|
13
13
|
} from "./chunk-WHFCJBMO.js";
|
|
14
14
|
import {
|
|
15
15
|
quoteShellArg
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-JLVUNDUB.js";
|
|
17
17
|
import {
|
|
18
18
|
mintSshKey,
|
|
19
19
|
resolveSshConfigTarget,
|
|
@@ -164,7 +164,7 @@ async function locallySharedAliases() {
|
|
|
164
164
|
return out;
|
|
165
165
|
}
|
|
166
166
|
async function shareAfterAdd(alias) {
|
|
167
|
-
const { localExposedLoopbackUrl, resolveHubApiClient } = await import("./control-plane-
|
|
167
|
+
const { localExposedLoopbackUrl, resolveHubApiClient } = await import("./control-plane-TOFT56CT.js");
|
|
168
168
|
const cfg = await loadEffectiveConfig(process.cwd()).catch(() => null);
|
|
169
169
|
const url = cfg?.effective.relay.controlPlaneUrl;
|
|
170
170
|
if (!url) return;
|
|
@@ -192,7 +192,7 @@ The host is registered here, so \`agentbox docker:${alias} \u2026\` still works
|
|
|
192
192
|
async function syncSharedHosts(urlFlag, onLog) {
|
|
193
193
|
const aliases = await locallySharedAliases();
|
|
194
194
|
if (aliases.length === 0) return;
|
|
195
|
-
const { localExposedLoopbackUrl, resolveHubApiClient } = await import("./control-plane-
|
|
195
|
+
const { localExposedLoopbackUrl, resolveHubApiClient } = await import("./control-plane-TOFT56CT.js");
|
|
196
196
|
if (await localExposedLoopbackUrl().catch(() => null) !== null) return;
|
|
197
197
|
const client = await resolveHubApiClient(urlFlag, { quiet: true });
|
|
198
198
|
if (!client) {
|
|
@@ -210,9 +210,9 @@ var CONTROL_BOX_STATUS_MS = 5e3;
|
|
|
210
210
|
async function controlBoxKnowsHost(alias, effective) {
|
|
211
211
|
if (!alias || !effective.relay?.controlPlaneUrl) return false;
|
|
212
212
|
const [{ resolveHubApiTarget }, { HubApiClient }, { deadlineFetch, hostReachable }] = await Promise.all([
|
|
213
|
-
import("./control-plane-
|
|
213
|
+
import("./control-plane-TOFT56CT.js"),
|
|
214
214
|
import("./hub-api-client-5U6WOTZ3.js"),
|
|
215
|
-
import("./dist-
|
|
215
|
+
import("./dist-RWFKW4IU.js")
|
|
216
216
|
]);
|
|
217
217
|
const target = await resolveHubApiTarget(void 0, { quiet: true }).catch(() => null);
|
|
218
218
|
if (!target) return false;
|
|
@@ -246,4 +246,4 @@ export {
|
|
|
246
246
|
hubCanRunEngine,
|
|
247
247
|
unsharedHostReason
|
|
248
248
|
};
|
|
249
|
-
//# sourceMappingURL=chunk-
|
|
249
|
+
//# sourceMappingURL=chunk-OUOV4OM2.js.map
|
|
@@ -14,12 +14,12 @@ import {
|
|
|
14
14
|
import { pathToFileURL } from "url";
|
|
15
15
|
var IMPORTERS = {
|
|
16
16
|
docker: () => import("./dist-C5B6NGBO.js"),
|
|
17
|
-
daytona: () => import("./dist-
|
|
18
|
-
hetzner: () => import("./dist-
|
|
19
|
-
vercel: () => import("./dist-
|
|
20
|
-
e2b: () => import("./dist-
|
|
21
|
-
digitalocean: () => import("./dist-
|
|
22
|
-
"remote-docker": () => import("./dist-
|
|
17
|
+
daytona: () => import("./dist-GMIBT6IK.js"),
|
|
18
|
+
hetzner: () => import("./dist-JSEXGLYK.js"),
|
|
19
|
+
vercel: () => import("./dist-XV77P3RW.js"),
|
|
20
|
+
e2b: () => import("./dist-Y2GCMA6N.js"),
|
|
21
|
+
digitalocean: () => import("./dist-BVZBXQ2Y.js"),
|
|
22
|
+
"remote-docker": () => import("./dist-7HSAWFRN.js")
|
|
23
23
|
};
|
|
24
24
|
function pickProviderModule(mod, name) {
|
|
25
25
|
const m = mod;
|
|
@@ -64,4 +64,4 @@ export {
|
|
|
64
64
|
getRuntimeProviderNames,
|
|
65
65
|
isRuntimeProvider
|
|
66
66
|
};
|
|
67
|
-
//# sourceMappingURL=chunk-
|
|
67
|
+
//# sourceMappingURL=chunk-P5A6MT75.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
loadProviderModule
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-P5A6MT75.js";
|
|
5
5
|
import {
|
|
6
6
|
isProviderKind
|
|
7
7
|
} from "./chunk-7LNXTPEE.js";
|
|
@@ -21,4 +21,4 @@ export {
|
|
|
21
21
|
cloudBackendForProvider,
|
|
22
22
|
currentCloudBaseFingerprintLive
|
|
23
23
|
};
|
|
24
|
-
//# sourceMappingURL=chunk-
|
|
24
|
+
//# sourceMappingURL=chunk-RXH634SC.js.map
|
|
@@ -7,16 +7,16 @@ import {
|
|
|
7
7
|
import {
|
|
8
8
|
hubApiTargetFrom,
|
|
9
9
|
withHubClient
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-ZCHWZYIN.js";
|
|
11
11
|
import {
|
|
12
12
|
deployControlPlaneToDigitalOcean,
|
|
13
13
|
destroyControlPlaneOnDigitalOcean,
|
|
14
14
|
readDigitalOceanCredStatus,
|
|
15
15
|
updateControlPlaneOnDigitalOcean
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-JTYWZJIU.js";
|
|
17
17
|
import {
|
|
18
18
|
providerForCreate
|
|
19
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-5I7IFACI.js";
|
|
20
20
|
import {
|
|
21
21
|
HubApiClient,
|
|
22
22
|
HubApiError
|
|
@@ -30,7 +30,7 @@ import {
|
|
|
30
30
|
runHetznerDeploy,
|
|
31
31
|
runHetznerDestroy,
|
|
32
32
|
runHetznerUpdate
|
|
33
|
-
} from "./chunk-
|
|
33
|
+
} from "./chunk-LEVYTABB.js";
|
|
34
34
|
import {
|
|
35
35
|
loadControlPlaneEnv,
|
|
36
36
|
readControlPlaneEnvMap,
|
|
@@ -41,7 +41,7 @@ import {
|
|
|
41
41
|
} from "./chunk-6YSYQZRH.js";
|
|
42
42
|
import {
|
|
43
43
|
detectEgressIp
|
|
44
|
-
} from "./chunk-
|
|
44
|
+
} from "./chunk-5NVHJS7D.js";
|
|
45
45
|
import {
|
|
46
46
|
createGitDeployment,
|
|
47
47
|
createGitProject,
|
|
@@ -53,7 +53,7 @@ import {
|
|
|
53
53
|
projectHasEnv,
|
|
54
54
|
resolveVercelApiAuth,
|
|
55
55
|
upsertProjectEnv
|
|
56
|
-
} from "./chunk-
|
|
56
|
+
} from "./chunk-TPHSVKMX.js";
|
|
57
57
|
import {
|
|
58
58
|
applyProjectSeed,
|
|
59
59
|
deadlineFetch,
|
|
@@ -61,7 +61,7 @@ import {
|
|
|
61
61
|
pushPreparedToCustody,
|
|
62
62
|
pushProjectSeedToCustody,
|
|
63
63
|
readGitOriginUrl
|
|
64
|
-
} from "./chunk-
|
|
64
|
+
} from "./chunk-JLVUNDUB.js";
|
|
65
65
|
import {
|
|
66
66
|
GitHubAppLeaser,
|
|
67
67
|
PostgresStore,
|
|
@@ -76,7 +76,7 @@ import {
|
|
|
76
76
|
import {
|
|
77
77
|
getRuntimeProviderNames,
|
|
78
78
|
loadProviderModule
|
|
79
|
-
} from "./chunk-
|
|
79
|
+
} from "./chunk-P5A6MT75.js";
|
|
80
80
|
import {
|
|
81
81
|
AGENTBOX_HUB_SSH_ALIAS,
|
|
82
82
|
AGENT_SYNC_SPECS,
|
|
@@ -784,8 +784,8 @@ function detectExecutionMethod(input) {
|
|
|
784
784
|
}
|
|
785
785
|
|
|
786
786
|
// src/version.ts
|
|
787
|
-
var AGENTBOX_VERSION = true ? "0.29.
|
|
788
|
-
var AGENTBOX_COMMIT = true ? "
|
|
787
|
+
var AGENTBOX_VERSION = true ? "0.29.2" : "0.0.0-dev";
|
|
788
|
+
var AGENTBOX_COMMIT = true ? "1cd08f2f" : "dev";
|
|
789
789
|
|
|
790
790
|
// src/commands/install-app.ts
|
|
791
791
|
import { intro, log, outro } from "@clack/prompts";
|
|
@@ -2412,7 +2412,7 @@ var setUrlSub = new Command2("set-url").description("Point boxes + the CLI at a
|
|
|
2412
2412
|
try {
|
|
2413
2413
|
const trimmed = await applyControlPlaneUrl(url);
|
|
2414
2414
|
log2.success(`Set relay.controlPlaneUrl = ${trimmed}`);
|
|
2415
|
-
const { ensureHubDockerTarget } = await import("./hub-docker-target-
|
|
2415
|
+
const { ensureHubDockerTarget } = await import("./hub-docker-target-CS5XHSSA.js");
|
|
2416
2416
|
await ensureHubDockerTarget((line) => {
|
|
2417
2417
|
log2.info(line);
|
|
2418
2418
|
});
|
|
@@ -2430,7 +2430,7 @@ var unsetUrlSub = new Command2("unset-url").description("Stop using a control pl
|
|
|
2430
2430
|
if (!g.existed && !p.existed) {
|
|
2431
2431
|
log2.info("No control plane was configured (relay.controlPlaneUrl not set).");
|
|
2432
2432
|
} else {
|
|
2433
|
-
const { removeHubDockerTarget } = await import("./hub-docker-target-
|
|
2433
|
+
const { removeHubDockerTarget } = await import("./hub-docker-target-CS5XHSSA.js");
|
|
2434
2434
|
await removeHubDockerTarget((line) => {
|
|
2435
2435
|
log2.info(line);
|
|
2436
2436
|
});
|
|
@@ -2640,7 +2640,7 @@ async function resolveCustodyTarget(urlFlag, opts = {}) {
|
|
|
2640
2640
|
return { url, adminToken };
|
|
2641
2641
|
}
|
|
2642
2642
|
async function resolveCustodyApiTarget(urlFlag, opts = {}) {
|
|
2643
|
-
const { resolveHubTarget } = await import("./hub-
|
|
2643
|
+
const { resolveHubTarget } = await import("./hub-53E6EFZB.js");
|
|
2644
2644
|
const noCredentialError = "A control box is configured but no custody credential is available. Set AGENTBOX_HUB_API_KEY\n(or AGENTBOX_RELAY_ADMIN_TOKEN), or run this from the machine that ran `agentbox hub setup`\n(it writes both to ~/.agentbox/control-plane) \u2014 custody / SSH-key pull needs one of them.";
|
|
2645
2645
|
const target = await resolveHubTarget(urlFlag);
|
|
2646
2646
|
if (target.mode === "remote") {
|
|
@@ -2692,7 +2692,7 @@ async function restartLocalHubForToken() {
|
|
|
2692
2692
|
}
|
|
2693
2693
|
}
|
|
2694
2694
|
async function resolveHubApiTarget(urlFlag, opts = {}) {
|
|
2695
|
-
const { resolveHubTarget } = await import("./hub-
|
|
2695
|
+
const { resolveHubTarget } = await import("./hub-53E6EFZB.js");
|
|
2696
2696
|
let target = await resolveHubTarget(urlFlag, { preferLocal: opts.preferLocal });
|
|
2697
2697
|
if (target.mode === "local" && !opts.quiet) {
|
|
2698
2698
|
const { getHubStatus: getHubStatus2, readHubToken } = await import("./dist-PTYASENV.js");
|
|
@@ -3575,7 +3575,7 @@ async function syncBakesWithControlBox(url) {
|
|
|
3575
3575
|
const hubVersion = (await probeControlPlaneStatus(target.url)).version;
|
|
3576
3576
|
const results = [];
|
|
3577
3577
|
const providers = getRuntimeProviderNames().filter(isShareablePreparedProvider);
|
|
3578
|
-
const { adoptPreparedBases } = await import("./prepared-custody-
|
|
3578
|
+
const { adoptPreparedBases } = await import("./prepared-custody-ATP6GQGW.js");
|
|
3579
3579
|
const pulled = await adoptPreparedBases().catch(() => ({
|
|
3580
3580
|
adopted: [],
|
|
3581
3581
|
pending: []
|
|
@@ -3681,12 +3681,12 @@ async function syncAgentCredentialsIfChanged(url) {
|
|
|
3681
3681
|
async function finalizeControlBoxState(url) {
|
|
3682
3682
|
await syncAgentCredentials(url, { announce: true });
|
|
3683
3683
|
await syncBakesWithControlBox(url);
|
|
3684
|
-
const { syncSharedHosts } = await import("./remote-docker-share-
|
|
3684
|
+
const { syncSharedHosts } = await import("./remote-docker-share-XBV76ZAZ.js");
|
|
3685
3685
|
await syncSharedHosts(url, (line) => {
|
|
3686
3686
|
log2.info(line);
|
|
3687
3687
|
});
|
|
3688
3688
|
try {
|
|
3689
|
-
const { ensureHubDockerTarget } = await import("./hub-docker-target-
|
|
3689
|
+
const { ensureHubDockerTarget } = await import("./hub-docker-target-CS5XHSSA.js");
|
|
3690
3690
|
await ensureHubDockerTarget((line) => {
|
|
3691
3691
|
log2.info(line);
|
|
3692
3692
|
});
|
|
@@ -3776,4 +3776,4 @@ export {
|
|
|
3776
3776
|
syncAgentCredentialsIfChanged,
|
|
3777
3777
|
controlPlaneSubcommands
|
|
3778
3778
|
};
|
|
3779
|
-
//# sourceMappingURL=chunk-
|
|
3779
|
+
//# sourceMappingURL=chunk-SXXN7JOC.js.map
|