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