@madarco/agentbox 0.24.6 → 0.25.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +59 -0
- package/LICENSE +21 -0
- package/README.md +4 -0
- package/dist/{_cloud-attach-ESCPOKG5.js → _cloud-attach-W2CFNXKO.js} +5 -5
- package/dist/{chunk-RFRWS5CD.js → chunk-4UNSBU5R.js} +2 -2
- package/dist/{chunk-H6A4BQMG.js → chunk-5F5SOSDY.js} +40 -1
- package/dist/chunk-5F5SOSDY.js.map +1 -0
- package/dist/{chunk-7DPDUZ7L.js → chunk-7C5MOA4Z.js} +194 -56
- package/dist/chunk-7C5MOA4Z.js.map +1 -0
- package/dist/{chunk-LJMGHFLZ.js → chunk-7PRLM3PH.js} +3 -3
- package/dist/chunk-G3H2L3O2.js +0 -0
- package/dist/{chunk-4HPLS5HJ.js → chunk-GHFIKSBJ.js} +110 -9
- package/dist/chunk-GHFIKSBJ.js.map +1 -0
- package/dist/{chunk-5JDOTQTM.js → chunk-LCZOQTIX.js} +4 -4
- package/dist/{chunk-QHISF6O6.js → chunk-LU3WAHTU.js} +3 -3
- package/dist/{chunk-CE3S7UDQ.js → chunk-NH3W6HUZ.js} +44 -12
- package/dist/chunk-NH3W6HUZ.js.map +1 -0
- package/dist/{chunk-OSPM4Q5V.js → chunk-VZC5J44U.js} +5 -5
- package/dist/chunk-VZC5J44U.js.map +1 -0
- package/dist/chunk-WJFZJZIM.js +0 -0
- package/dist/{chunk-3MDYQROX.js → chunk-Y3OPQWAQ.js} +11 -11
- package/dist/chunk-Y3OPQWAQ.js.map +1 -0
- package/dist/cloud-poller-SUNA6ZQC-7M5LJHHE.js +0 -0
- package/dist/{dist-TRKHS6I7.js → dist-3V5SLNK4.js} +6 -6
- package/dist/{dist-NOUPH5E6.js → dist-BIDAC4H4.js} +4 -4
- package/dist/{dist-VFPT5TDH.js → dist-I5OBPLP2.js} +6 -6
- package/dist/{dist-3M53BF4E.js → dist-IGQNVIV3.js} +6 -6
- package/dist/dist-KL73Z37T.js +677 -0
- package/dist/dist-KL73Z37T.js.map +1 -0
- package/dist/{dist-HPPHBZTO.js → dist-SBDYDH7H.js} +8 -2
- package/dist/{dist-FGXCG4JY.js → dist-UB3PYSCG.js} +6 -6
- package/dist/index.js +114 -38
- package/dist/index.js.map +1 -1
- package/dist/{prepared-state-BUO75YLZ-46W2PAHH.js → prepared-state-OBM2F7CU-DY7TZV4R.js} +2 -2
- package/package.json +29 -30
- package/runtime/_shared/agentbox-checkpoint-cleanup +0 -0
- 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 +31 -4
- package/runtime/_shared/gh-shim +0 -0
- package/runtime/_shared/git-shim +0 -0
- package/runtime/_shared/linear-shim +0 -0
- package/runtime/_shared/ntn-shim +0 -0
- package/runtime/digitalocean/agentbox-checkpoint-cleanup +0 -0
- package/runtime/digitalocean/agentbox-dockerd-start +0 -0
- package/runtime/digitalocean/agentbox-open +0 -0
- package/runtime/digitalocean/agentbox-portless-trust +0 -0
- package/runtime/digitalocean/agentbox-vnc-start +0 -0
- package/runtime/digitalocean/ctl.cjs +31 -4
- package/runtime/digitalocean/gh-shim +0 -0
- package/runtime/digitalocean/git-shim +0 -0
- package/runtime/digitalocean/linear-shim +0 -0
- package/runtime/digitalocean/ntn-shim +0 -0
- package/runtime/digitalocean/scripts/install-box.sh +0 -0
- package/runtime/docker/packages/ctl/dist/bin.cjs +31 -4
- package/runtime/docker/packages/sandbox-docker/scripts/agentbox-checkpoint-cleanup +0 -0
- 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/gh-shim +0 -0
- package/runtime/docker/packages/sandbox-docker/scripts/git-shim +0 -0
- 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-dockerd-start +0 -0
- package/runtime/e2b/agentbox-open +0 -0
- package/runtime/e2b/agentbox-vnc-start +0 -0
- package/runtime/e2b/ctl.cjs +31 -4
- package/runtime/e2b/gh-shim +0 -0
- package/runtime/e2b/git-shim +0 -0
- package/runtime/e2b/linear-shim +0 -0
- package/runtime/e2b/ntn-shim +0 -0
- package/runtime/e2b/scripts/build-template.sh +0 -0
- package/runtime/hetzner/agentbox-checkpoint-cleanup +0 -0
- 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 +31 -4
- package/runtime/hetzner/gh-shim +0 -0
- package/runtime/hetzner/git-shim +0 -0
- package/runtime/hetzner/linear-shim +0 -0
- package/runtime/hetzner/ntn-shim +0 -0
- package/runtime/hetzner/scripts/install-box.sh +0 -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/_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 +6 -6
- package/runtime/hub/apps/hub/.next/server/chunks/_0760z6y._.js +1 -1
- package/runtime/hub/apps/hub/.next/server/chunks/ssr/_0ro6vh6._.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/{auth-HY5K55Y5.js → auth-MVL4NCQC.js} +3 -3
- package/runtime/hub/apps/hub/{auth-config-MNW2XGKK.js → auth-config-GRIXACTV.js} +3 -3
- package/runtime/hub/apps/hub/{chunk-OF242BLD.js → chunk-CKBHQ7OI.js} +1 -1
- package/runtime/hub/apps/hub/{chunk-PROXBLRJ.js → chunk-JLG5JJXD.js} +1 -1
- package/runtime/hub/apps/hub/{chunk-EY6HEDTK.js → chunk-LNHPLR3L.js} +11 -11
- package/runtime/hub/apps/hub/{chunk-DNR2YM2G.js → chunk-MA73PTOR.js} +57 -9
- package/runtime/hub/apps/hub/{chunk-TZFWAJVB.js → chunk-OG4KH2FZ.js} +5 -0
- package/runtime/hub/apps/hub/{chunk-5KMJIVZC.js → chunk-QBJOF5D3.js} +111 -10
- package/runtime/hub/apps/hub/chunk-QYJ37CUJ.js +62140 -0
- package/runtime/hub/apps/hub/{chunk-EFW34I43.js → chunk-UDZ3VXRF.js} +1 -1
- package/runtime/hub/apps/hub/{chunk-TRUQCO4U.js → chunk-V3OMPMI3.js} +40 -1
- package/runtime/hub/apps/hub/{cloud-poller-SUNA6ZQC-VSKVMYHL.js → cloud-poller-SUNA6ZQC-YAWTNA2W.js} +1 -1
- package/runtime/hub/apps/hub/{dist-YCRESLWD.js → dist-26KVXHXV.js} +7 -7
- package/runtime/hub/apps/hub/{dist-SX2NXGI6.js → dist-7LB4D4ZQ.js} +7 -7
- package/runtime/hub/apps/hub/{dist-M73U3ZDH.js → dist-ERQDDSOY.js} +7 -7
- package/runtime/hub/apps/hub/{dist-NTKPAYA3.js → dist-IZ2JCN5R.js} +8 -2
- package/runtime/hub/apps/hub/{dist-3DCKZYID.js → dist-SIQJD72C.js} +596 -113
- package/runtime/hub/apps/hub/{dist-RSWTJWRN.js → dist-YZJA4WRV.js} +5 -5
- package/runtime/hub/apps/hub/{dist-KV5ESR24.js → dist-ZVY2FWG6.js} +7 -7
- package/runtime/hub/apps/hub/esm-VGBJAFLR.js +79 -0
- package/runtime/hub/apps/hub/{execa-4DLVNM6E.js → execa-AFY4ZODY.js} +2 -2
- package/runtime/hub/apps/hub/{hub-token-QKQWV2I6.js → hub-token-BJG6Q5II.js} +3 -3
- package/runtime/hub/apps/hub/{prepared-state-BUO75YLZ-KR4YLKDC.js → prepared-state-OBM2F7CU-ZEYFNYFI.js} +3 -3
- package/runtime/hub/apps/hub/server.js +19 -19
- package/runtime/relay/bin.cjs +177 -42
- package/runtime/vercel/agentbox-checkpoint-cleanup +0 -0
- 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 +31 -4
- package/runtime/vercel/gh-shim +0 -0
- package/runtime/vercel/git-shim +0 -0
- package/runtime/vercel/linear-shim +0 -0
- package/runtime/vercel/ntn-shim +0 -0
- package/runtime/vercel/scripts/provision.sh +0 -0
- package/dist/chunk-3MDYQROX.js.map +0 -1
- package/dist/chunk-4HPLS5HJ.js.map +0 -1
- package/dist/chunk-7DPDUZ7L.js.map +0 -1
- package/dist/chunk-CE3S7UDQ.js.map +0 -1
- package/dist/chunk-H6A4BQMG.js.map +0 -1
- package/dist/chunk-OSPM4Q5V.js.map +0 -1
- package/dist/dist-2N3XHMBQ.js +0 -322
- package/dist/dist-2N3XHMBQ.js.map +0 -1
- /package/dist/{_cloud-attach-ESCPOKG5.js.map → _cloud-attach-W2CFNXKO.js.map} +0 -0
- /package/dist/{chunk-RFRWS5CD.js.map → chunk-4UNSBU5R.js.map} +0 -0
- /package/dist/{chunk-LJMGHFLZ.js.map → chunk-7PRLM3PH.js.map} +0 -0
- /package/dist/{chunk-5JDOTQTM.js.map → chunk-LCZOQTIX.js.map} +0 -0
- /package/dist/{chunk-QHISF6O6.js.map → chunk-LU3WAHTU.js.map} +0 -0
- /package/dist/{dist-HPPHBZTO.js.map → dist-3V5SLNK4.js.map} +0 -0
- /package/dist/{dist-NOUPH5E6.js.map → dist-BIDAC4H4.js.map} +0 -0
- /package/dist/{dist-TRKHS6I7.js.map → dist-I5OBPLP2.js.map} +0 -0
- /package/dist/{dist-3M53BF4E.js.map → dist-IGQNVIV3.js.map} +0 -0
- /package/dist/{dist-VFPT5TDH.js.map → dist-SBDYDH7H.js.map} +0 -0
- /package/dist/{dist-FGXCG4JY.js.map → dist-UB3PYSCG.js.map} +0 -0
- /package/dist/{prepared-state-BUO75YLZ-46W2PAHH.js.map → prepared-state-OBM2F7CU-DY7TZV4R.js.map} +0 -0
- /package/runtime/hub/apps/hub/.next/static/{2LDXStEUVHS2oK1ID_Uvo → c82uDoByt-dPQUHilRojD}/_buildManifest.js +0 -0
- /package/runtime/hub/apps/hub/.next/static/{2LDXStEUVHS2oK1ID_Uvo → c82uDoByt-dPQUHilRojD}/_clientMiddlewareManifest.js +0 -0
- /package/runtime/hub/apps/hub/.next/static/{2LDXStEUVHS2oK1ID_Uvo → c82uDoByt-dPQUHilRojD}/_ssgManifest.js +0 -0
|
@@ -10,13 +10,21 @@ import {
|
|
|
10
10
|
ve,
|
|
11
11
|
we,
|
|
12
12
|
ye
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-CKBHQ7OI.js";
|
|
14
14
|
import {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
cloudSnapshotName,
|
|
16
|
+
createCloudProvider,
|
|
17
|
+
currentCloudBaseFingerprint,
|
|
18
|
+
listCloudCheckpoints,
|
|
19
|
+
removeCloudCheckpointDir,
|
|
20
|
+
resolveCloudCheckpoint,
|
|
21
|
+
seedAgentStaticIntoCloudBox,
|
|
22
|
+
writeCloudCheckpointManifest
|
|
23
|
+
} from "./chunk-QBJOF5D3.js";
|
|
24
|
+
import "./chunk-MA73PTOR.js";
|
|
18
25
|
import "./chunk-3LAHFDJF.js";
|
|
19
26
|
import {
|
|
27
|
+
BOX_IMAGE_REGISTRY,
|
|
20
28
|
DOCKER_CONTEXT_FILE_MAP,
|
|
21
29
|
claudeInstallFingerprint,
|
|
22
30
|
computeContextSha256,
|
|
@@ -24,16 +32,35 @@ import {
|
|
|
24
32
|
hostOpenCommand,
|
|
25
33
|
readCliStamp,
|
|
26
34
|
readPreparedStateRaw,
|
|
35
|
+
registryRefForSha,
|
|
27
36
|
resolveContextFilesFrom,
|
|
28
37
|
stageAllAgentStatic,
|
|
29
38
|
writeManagedSecrets,
|
|
30
39
|
writePreparedStateRaw
|
|
31
|
-
} from "./chunk-
|
|
32
|
-
import "./chunk-
|
|
33
|
-
import
|
|
34
|
-
|
|
40
|
+
} from "./chunk-LNHPLR3L.js";
|
|
41
|
+
import "./chunk-UDZ3VXRF.js";
|
|
42
|
+
import {
|
|
43
|
+
DAYTONA_VM_REGION,
|
|
44
|
+
loadEffectiveConfig,
|
|
45
|
+
resolveDaytonaClass
|
|
46
|
+
} from "./chunk-V3OMPMI3.js";
|
|
47
|
+
import {
|
|
48
|
+
Daytona,
|
|
49
|
+
DaytonaAuthenticationError,
|
|
50
|
+
DaytonaAuthorizationError,
|
|
51
|
+
DaytonaConflictError,
|
|
52
|
+
DaytonaConnectionError,
|
|
53
|
+
DaytonaError,
|
|
54
|
+
DaytonaNotFoundError,
|
|
55
|
+
DaytonaRateLimitError,
|
|
56
|
+
DaytonaTimeoutError,
|
|
57
|
+
DaytonaValidationError,
|
|
58
|
+
Image,
|
|
59
|
+
import_api_client
|
|
60
|
+
} from "./chunk-QYJ37CUJ.js";
|
|
61
|
+
import "./chunk-OG4KH2FZ.js";
|
|
35
62
|
|
|
36
|
-
// ../../packages/sandbox-daytona/dist/chunk-
|
|
63
|
+
// ../../packages/sandbox-daytona/dist/chunk-HEUB57SZ.js
|
|
37
64
|
import { existsSync } from "fs";
|
|
38
65
|
import { dirname, resolve } from "path";
|
|
39
66
|
import { fileURLToPath } from "url";
|
|
@@ -44,18 +71,6 @@ import { createHash } from "crypto";
|
|
|
44
71
|
import { existsSync as existsSync3 } from "fs";
|
|
45
72
|
import { dirname as dirname2, resolve as resolve3 } from "path";
|
|
46
73
|
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
47
|
-
import { Daytona, DaytonaNotFoundError as DaytonaNotFoundError2, Image, SandboxState } from "@daytonaio/sdk";
|
|
48
|
-
import {
|
|
49
|
-
DaytonaAuthenticationError,
|
|
50
|
-
DaytonaAuthorizationError,
|
|
51
|
-
DaytonaConflictError,
|
|
52
|
-
DaytonaConnectionError,
|
|
53
|
-
DaytonaError,
|
|
54
|
-
DaytonaNotFoundError,
|
|
55
|
-
DaytonaRateLimitError,
|
|
56
|
-
DaytonaTimeoutError,
|
|
57
|
-
DaytonaValidationError
|
|
58
|
-
} from "@daytonaio/sdk";
|
|
59
74
|
import { spawnSync } from "child_process";
|
|
60
75
|
import { homedir as homedir2 } from "os";
|
|
61
76
|
import { resolve as resolve4 } from "path";
|
|
@@ -140,16 +155,7 @@ function parseEnvFile(body) {
|
|
|
140
155
|
}
|
|
141
156
|
var SCHEMA = 1;
|
|
142
157
|
function resolveDaytonaContextFiles() {
|
|
143
|
-
const
|
|
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
|
-
});
|
|
158
|
+
const docker = resolveDockerContextFilesForDaytona();
|
|
153
159
|
if (!docker) return null;
|
|
154
160
|
const overlay = resolveDaytonaCustomClaudeMd();
|
|
155
161
|
if (!overlay) return null;
|
|
@@ -161,6 +167,23 @@ function resolveDaytonaContextFiles() {
|
|
|
161
167
|
{ rel: "daytona/custom-system-CLAUDE.md", abs: overlay }
|
|
162
168
|
];
|
|
163
169
|
}
|
|
170
|
+
function resolveDockerContextFilesForDaytona() {
|
|
171
|
+
const ctx = resolveDockerfileContext();
|
|
172
|
+
if (!ctx) return null;
|
|
173
|
+
const here = dirname2(fileURLToPath2(import.meta.url));
|
|
174
|
+
const packageRoot = resolve3(here, "..");
|
|
175
|
+
const monorepoRoot = resolve3(here, "..", "..", "..");
|
|
176
|
+
const dockerPackageRoot = resolve3(monorepoRoot, "packages", "sandbox-docker");
|
|
177
|
+
return resolveContextFilesFrom(DOCKER_CONTEXT_FILE_MAP, {
|
|
178
|
+
contextDir: ctx.context,
|
|
179
|
+
devRoot: existsSync3(dockerPackageRoot) ? dockerPackageRoot : packageRoot
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
async function computeDockerBaseSha(claudeInstall = "native") {
|
|
183
|
+
const files = resolveDockerContextFilesForDaytona();
|
|
184
|
+
if (!files) return null;
|
|
185
|
+
return claudeInstallFingerprint(await computeContextSha256(files), claudeInstall);
|
|
186
|
+
}
|
|
164
187
|
var DAYTONA_SEED_SCHEMA = "relctx-1";
|
|
165
188
|
async function computeDaytonaContextFingerprint() {
|
|
166
189
|
const files = resolveDaytonaContextFiles();
|
|
@@ -187,6 +210,11 @@ function readPreparedDaytonaState() {
|
|
|
187
210
|
}
|
|
188
211
|
function writePreparedDaytonaState(opts) {
|
|
189
212
|
const stamp = readCliStamp();
|
|
213
|
+
const extras = {
|
|
214
|
+
...opts.size ? { size: opts.size } : {},
|
|
215
|
+
...opts.class ? { class: opts.class } : {},
|
|
216
|
+
...opts.env && opts.env.length > 0 ? { env: opts.env } : {}
|
|
217
|
+
};
|
|
190
218
|
const state = {
|
|
191
219
|
schema: SCHEMA,
|
|
192
220
|
base: {
|
|
@@ -196,13 +224,36 @@ function writePreparedDaytonaState(opts) {
|
|
|
196
224
|
cliCommit: stamp.cliCommit,
|
|
197
225
|
createdAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
198
226
|
},
|
|
199
|
-
...
|
|
227
|
+
...Object.keys(extras).length > 0 ? { extras } : {}
|
|
200
228
|
};
|
|
201
229
|
writePreparedStateRaw("daytona", state);
|
|
202
230
|
}
|
|
203
|
-
function preparedMatches(state, current, size) {
|
|
231
|
+
function preparedMatches(state, current, size, sandboxClass) {
|
|
204
232
|
if (state?.base?.contextSha256 !== current) return false;
|
|
205
|
-
|
|
233
|
+
if ((state?.extras?.size ?? void 0) !== (size ?? void 0)) return false;
|
|
234
|
+
if (sandboxClass === void 0) return true;
|
|
235
|
+
return (state?.extras?.class ?? "container") === sandboxClass;
|
|
236
|
+
}
|
|
237
|
+
async function waitForSnapshotActive(client, name, timeoutMs = 9e5) {
|
|
238
|
+
const deadline = Date.now() + timeoutMs;
|
|
239
|
+
for (; ; ) {
|
|
240
|
+
let state;
|
|
241
|
+
try {
|
|
242
|
+
state = (await client.snapshot.get(name))?.state;
|
|
243
|
+
} catch {
|
|
244
|
+
state = void 0;
|
|
245
|
+
}
|
|
246
|
+
if (state === "active") return;
|
|
247
|
+
if (state === "error" || state === "build_failed") {
|
|
248
|
+
throw new Error(`daytona snapshot '${name}' ended in state '${state}'`);
|
|
249
|
+
}
|
|
250
|
+
if (Date.now() >= deadline) {
|
|
251
|
+
throw new Error(
|
|
252
|
+
`daytona snapshot '${name}' did not become active within ${String(Math.round(timeoutMs / 6e4))} min (state: ${state ?? "unknown"})`
|
|
253
|
+
);
|
|
254
|
+
}
|
|
255
|
+
await new Promise((r) => setTimeout(r, 3e3));
|
|
256
|
+
}
|
|
206
257
|
}
|
|
207
258
|
var DEFAULT_BACKOFF = [1e3, 2e3, 4e3];
|
|
208
259
|
var DEFAULT_ATTEMPT_TIMEOUT_MS = 3e4;
|
|
@@ -307,21 +358,23 @@ function retry(method, fn, opts = {}) {
|
|
|
307
358
|
);
|
|
308
359
|
}
|
|
309
360
|
var DEFAULT_BOX_IMAGE_REF = "agentbox/box:dev";
|
|
310
|
-
var
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
361
|
+
var DAYTONA_DEFAULT_RESOURCES = { cpu: 2, memory: 4, disk: 8 };
|
|
362
|
+
var clients = /* @__PURE__ */ new Map();
|
|
363
|
+
function getClient(target = "") {
|
|
364
|
+
const cached = clients.get(target);
|
|
365
|
+
if (cached) return cached;
|
|
366
|
+
ensureDaytonaEnvLoaded();
|
|
367
|
+
try {
|
|
368
|
+
const created = target.length > 0 ? new Daytona({ target }) : new Daytona();
|
|
369
|
+
clients.set(target, created);
|
|
370
|
+
return created;
|
|
371
|
+
} catch (err) {
|
|
372
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
373
|
+
throw new Error(
|
|
374
|
+
`Daytona credentials not configured: ${msg}
|
|
320
375
|
Run \`agentbox daytona login\` interactively, or set DAYTONA_API_KEY in the environment.`
|
|
321
|
-
|
|
322
|
-
}
|
|
376
|
+
);
|
|
323
377
|
}
|
|
324
|
-
return client;
|
|
325
378
|
}
|
|
326
379
|
async function getSandbox(id) {
|
|
327
380
|
return getClient().get(id);
|
|
@@ -335,26 +388,29 @@ async function maybeGetSandbox(id) {
|
|
|
335
388
|
}
|
|
336
389
|
function mapState(s) {
|
|
337
390
|
switch (s) {
|
|
338
|
-
case SandboxState.STARTED:
|
|
391
|
+
case import_api_client.SandboxState.STARTED:
|
|
339
392
|
return "running";
|
|
340
|
-
case SandboxState.STARTING:
|
|
341
|
-
case SandboxState.CREATING:
|
|
342
|
-
case SandboxState.RESTORING:
|
|
343
|
-
case SandboxState.BUILDING_SNAPSHOT:
|
|
344
|
-
case SandboxState.PULLING_SNAPSHOT:
|
|
345
|
-
case SandboxState.PENDING_BUILD:
|
|
346
|
-
case SandboxState.STOPPING:
|
|
393
|
+
case import_api_client.SandboxState.STARTING:
|
|
394
|
+
case import_api_client.SandboxState.CREATING:
|
|
395
|
+
case import_api_client.SandboxState.RESTORING:
|
|
396
|
+
case import_api_client.SandboxState.BUILDING_SNAPSHOT:
|
|
397
|
+
case import_api_client.SandboxState.PULLING_SNAPSHOT:
|
|
398
|
+
case import_api_client.SandboxState.PENDING_BUILD:
|
|
399
|
+
case import_api_client.SandboxState.STOPPING:
|
|
400
|
+
case import_api_client.SandboxState.RESUMING:
|
|
347
401
|
return "running";
|
|
348
|
-
case SandboxState.STOPPED:
|
|
402
|
+
case import_api_client.SandboxState.STOPPED:
|
|
349
403
|
return "stopped";
|
|
350
|
-
case SandboxState.ARCHIVED:
|
|
351
|
-
case SandboxState.ARCHIVING:
|
|
404
|
+
case import_api_client.SandboxState.ARCHIVED:
|
|
405
|
+
case import_api_client.SandboxState.ARCHIVING:
|
|
406
|
+
case import_api_client.SandboxState.PAUSED:
|
|
407
|
+
case import_api_client.SandboxState.PAUSING:
|
|
352
408
|
return "paused";
|
|
353
|
-
case SandboxState.DESTROYED:
|
|
354
|
-
case SandboxState.DESTROYING:
|
|
355
|
-
case SandboxState.ERROR:
|
|
356
|
-
case SandboxState.BUILD_FAILED:
|
|
357
|
-
case SandboxState.UNKNOWN:
|
|
409
|
+
case import_api_client.SandboxState.DESTROYED:
|
|
410
|
+
case import_api_client.SandboxState.DESTROYING:
|
|
411
|
+
case import_api_client.SandboxState.ERROR:
|
|
412
|
+
case import_api_client.SandboxState.BUILD_FAILED:
|
|
413
|
+
case import_api_client.SandboxState.UNKNOWN:
|
|
358
414
|
default:
|
|
359
415
|
return "missing";
|
|
360
416
|
}
|
|
@@ -400,17 +456,40 @@ var daytonaBackend = {
|
|
|
400
456
|
}
|
|
401
457
|
}
|
|
402
458
|
const resources = sizeResources ?? req.resources;
|
|
459
|
+
const prepared = readPreparedDaytonaState();
|
|
460
|
+
const baseRef = req.snapshot ?? req.image;
|
|
461
|
+
const bootingPreparedBase = prepared?.base?.imageRef !== void 0 && baseRef === prepared.base.imageRef;
|
|
462
|
+
const imageEnv = {};
|
|
463
|
+
if (bootingPreparedBase) {
|
|
464
|
+
for (const kv of prepared.extras?.env ?? []) {
|
|
465
|
+
const i = kv.indexOf("=");
|
|
466
|
+
if (i > 0) imageEnv[kv.slice(0, i)] = kv.slice(i + 1);
|
|
467
|
+
}
|
|
468
|
+
}
|
|
403
469
|
const baseParams = {
|
|
404
470
|
...resources ? { resources } : {},
|
|
405
|
-
envVars: req.env,
|
|
471
|
+
envVars: { ...imageEnv, ...req.env },
|
|
406
472
|
...req.volumes && req.volumes.length > 0 ? { volumes: req.volumes.map(toDaytonaVolumeMount) } : {},
|
|
407
|
-
labels: { "agentbox.name": req.name }
|
|
473
|
+
labels: { "agentbox.name": req.name },
|
|
474
|
+
// Daytona auto-stops a sandbox after N minutes of INACTIVITY (its own
|
|
475
|
+
// default is 15). The host keepalive loop pushes this forward via
|
|
476
|
+
// `renewTimeout` while an agent is working, so only a genuinely idle
|
|
477
|
+
// box lapses. 0 disables it entirely.
|
|
478
|
+
...typeof req.timeoutMs === "number" ? { autoStopInterval: Math.max(0, Math.round(req.timeoutMs / 6e4)) } : {}
|
|
408
479
|
};
|
|
409
|
-
const
|
|
480
|
+
const bakedClass = bootingPreparedBase ? prepared.extras?.class ?? "container" : void 0;
|
|
481
|
+
const sandboxClass = bakedClass ?? req.sandboxClass;
|
|
482
|
+
if (bakedClass && req.sandboxClass && bakedClass !== req.sandboxClass) {
|
|
483
|
+
req.onLog?.(
|
|
484
|
+
`daytona: base '${baseRef ?? ""}' was baked as '${bakedClass}', so this box will be a '${bakedClass}' one (box.daytonaClass asks for '${req.sandboxClass}'). Re-bake with \`agentbox prepare --provider daytona --force\` to change it.`
|
|
485
|
+
);
|
|
486
|
+
}
|
|
487
|
+
const region = req.location && req.location.length > 0 ? req.location : sandboxClass === "linux-vm" ? DAYTONA_VM_REGION : "";
|
|
488
|
+
const client = getClient(region);
|
|
410
489
|
let snapshotName = req.snapshot;
|
|
411
490
|
if (!snapshotName && req.image && req.image !== DEFAULT_BOX_IMAGE_REF) {
|
|
412
491
|
try {
|
|
413
|
-
const snap = await
|
|
492
|
+
const snap = await client.snapshot.get(req.image);
|
|
414
493
|
if (snap && snap.name) snapshotName = snap.name;
|
|
415
494
|
} catch {
|
|
416
495
|
}
|
|
@@ -418,7 +497,7 @@ var daytonaBackend = {
|
|
|
418
497
|
const snapshotParams = { ...baseParams };
|
|
419
498
|
delete snapshotParams.resources;
|
|
420
499
|
if (snapshotName && sizeResources) {
|
|
421
|
-
const bakedSize =
|
|
500
|
+
const bakedSize = prepared?.extras?.size;
|
|
422
501
|
const requestedKey = `${String(sizeResources.cpu)}-${String(sizeResources.memory)}-${String(sizeResources.disk)}`;
|
|
423
502
|
if (bakedSize !== requestedKey) {
|
|
424
503
|
req.onLog?.(
|
|
@@ -426,21 +505,31 @@ var daytonaBackend = {
|
|
|
426
505
|
);
|
|
427
506
|
}
|
|
428
507
|
}
|
|
429
|
-
|
|
508
|
+
if (!snapshotName && sandboxClass === "linux-vm") {
|
|
509
|
+
throw new Error(
|
|
510
|
+
`no linux-vm base snapshot for daytona: Daytona can only build a VM snapshot from a prebuilt image, not from a Dockerfile, so there is nothing to boot.
|
|
511
|
+
Run \`agentbox prepare --provider daytona\` to bake one, or set \`agentbox config set box.daytonaClass container\` to use the container class.`
|
|
512
|
+
);
|
|
513
|
+
}
|
|
514
|
+
const sandbox = snapshotName ? await client.create({ snapshot: snapshotName, ...snapshotParams }, { timeout: 900 }) : await client.create(
|
|
430
515
|
{ image: resolveImage(req.image), ...baseParams },
|
|
431
516
|
{
|
|
432
517
|
timeout: 900,
|
|
433
518
|
...req.onLog ? { onSnapshotCreateLogs: req.onLog } : {}
|
|
434
519
|
}
|
|
435
520
|
);
|
|
436
|
-
|
|
521
|
+
const bootedClass = sandboxClass;
|
|
522
|
+
return {
|
|
523
|
+
sandboxId: sandbox.id,
|
|
524
|
+
...bootedClass ? { sandboxClass: bootedClass } : {}
|
|
525
|
+
};
|
|
437
526
|
},
|
|
438
527
|
{ retryOnAmbiguous: false, attemptTimeoutMs: 9e5 }
|
|
439
528
|
);
|
|
440
529
|
},
|
|
441
530
|
async ensureVolume(name) {
|
|
442
|
-
const
|
|
443
|
-
let vol = await retry("volume.get(create)", () =>
|
|
531
|
+
const client = getClient();
|
|
532
|
+
let vol = await retry("volume.get(create)", () => client.volume.get(name, true));
|
|
444
533
|
const deadline = Date.now() + 6e4;
|
|
445
534
|
while (vol.state !== "ready") {
|
|
446
535
|
if (vol.state === "error" || vol.state === "deleted" || vol.state === "deleting") {
|
|
@@ -454,7 +543,7 @@ var daytonaBackend = {
|
|
|
454
543
|
);
|
|
455
544
|
}
|
|
456
545
|
await new Promise((r) => setTimeout(r, 1e3));
|
|
457
|
-
vol = await retry("volume.get(poll)", () =>
|
|
546
|
+
vol = await retry("volume.get(poll)", () => client.volume.get(name));
|
|
458
547
|
}
|
|
459
548
|
return { volumeId: vol.id };
|
|
460
549
|
},
|
|
@@ -466,18 +555,18 @@ var daytonaBackend = {
|
|
|
466
555
|
},
|
|
467
556
|
async list() {
|
|
468
557
|
return retry("list", async () => {
|
|
469
|
-
const
|
|
470
|
-
const
|
|
471
|
-
const
|
|
472
|
-
return items.map((sb) => {
|
|
558
|
+
const client = getClient();
|
|
559
|
+
const items = [];
|
|
560
|
+
for await (const sb of client.list()) {
|
|
473
561
|
const summary = { sandboxId: sb.id };
|
|
474
562
|
const raw = sb;
|
|
475
563
|
const friendly = raw.labels?.["agentbox.name"] ?? raw.name;
|
|
476
564
|
if (friendly) summary.name = friendly;
|
|
477
565
|
if (raw.createdAt) summary.createdAt = raw.createdAt;
|
|
478
566
|
if (typeof raw.state === "string") summary.state = mapState(raw.state);
|
|
479
|
-
|
|
480
|
-
}
|
|
567
|
+
items.push(summary);
|
|
568
|
+
}
|
|
569
|
+
return items;
|
|
481
570
|
});
|
|
482
571
|
},
|
|
483
572
|
async start(h) {
|
|
@@ -505,9 +594,25 @@ var daytonaBackend = {
|
|
|
505
594
|
"pause",
|
|
506
595
|
async () => {
|
|
507
596
|
const sb = await getSandbox(h.sandboxId);
|
|
508
|
-
|
|
597
|
+
const freeze = async () => {
|
|
598
|
+
await sb.pause();
|
|
599
|
+
};
|
|
600
|
+
const archive = async () => {
|
|
601
|
+
await sb.stop();
|
|
602
|
+
await sb.archive();
|
|
603
|
+
};
|
|
604
|
+
const preferVm = h.sandboxClass !== "container";
|
|
605
|
+
try {
|
|
606
|
+
await (preferVm ? freeze() : archive());
|
|
607
|
+
} catch (err) {
|
|
608
|
+
try {
|
|
609
|
+
await (preferVm ? archive() : freeze());
|
|
610
|
+
} catch {
|
|
611
|
+
throw err;
|
|
612
|
+
}
|
|
613
|
+
}
|
|
509
614
|
},
|
|
510
|
-
{ attemptTimeoutMs:
|
|
615
|
+
{ attemptTimeoutMs: 12e4 }
|
|
511
616
|
);
|
|
512
617
|
},
|
|
513
618
|
async resume(h) {
|
|
@@ -520,6 +625,42 @@ var daytonaBackend = {
|
|
|
520
625
|
{ attemptTimeoutMs: 6e4 }
|
|
521
626
|
);
|
|
522
627
|
},
|
|
628
|
+
/**
|
|
629
|
+
* Daytona's `autoStopInterval` is an idle window that any request to the
|
|
630
|
+
* sandbox resets — including the host relay's own continuous preview-URL
|
|
631
|
+
* polling, which therefore holds every tracked box open forever. The host
|
|
632
|
+
* keepalive loop reads this and pauses an idle box itself instead of waiting
|
|
633
|
+
* for a lapse that never comes. See `CloudBackend.timeoutModel`.
|
|
634
|
+
*/
|
|
635
|
+
timeoutModel: "inactivity",
|
|
636
|
+
/**
|
|
637
|
+
* Daytona's SSH gateway gives a shell session a terminal but an exec session
|
|
638
|
+
* none — `ssh -tt <token>@ssh.app.daytona.io 'tty'` answers "not a tty" while
|
|
639
|
+
* the same connection with no command lands on /dev/pts/1. So interactive
|
|
640
|
+
* attach connects command-less and gets its command via stdin. See
|
|
641
|
+
* `CloudBackend.attachExecLacksTty`.
|
|
642
|
+
*/
|
|
643
|
+
attachExecLacksTty: true,
|
|
644
|
+
/**
|
|
645
|
+
* Hold off Daytona's auto-stop while the in-box agent is working.
|
|
646
|
+
*
|
|
647
|
+
* Daytona's timeout is an INACTIVITY window, not an absolute deadline like
|
|
648
|
+
* vercel's/e2b's, so there is nothing to extend to a target time — the box
|
|
649
|
+
* simply needs to look active. `refreshActivity()` resets that clock, which
|
|
650
|
+
* grants another full `autoStopInterval`. So both deadline args are unused:
|
|
651
|
+
* the host loop calls us precisely when it wants the box kept alive, and that
|
|
652
|
+
* call is the whole signal.
|
|
653
|
+
*/
|
|
654
|
+
async renewTimeout(h) {
|
|
655
|
+
await retry(
|
|
656
|
+
"renewTimeout",
|
|
657
|
+
async () => {
|
|
658
|
+
const sb = await getSandbox(h.sandboxId);
|
|
659
|
+
await sb.refreshActivity();
|
|
660
|
+
},
|
|
661
|
+
{ attemptTimeoutMs: 3e4 }
|
|
662
|
+
);
|
|
663
|
+
},
|
|
523
664
|
async destroy(h) {
|
|
524
665
|
return retry(
|
|
525
666
|
"destroy",
|
|
@@ -636,7 +777,13 @@ var daytonaBackend = {
|
|
|
636
777
|
"createSnapshot",
|
|
637
778
|
async () => {
|
|
638
779
|
const sb = await getSandbox(h.sandboxId);
|
|
639
|
-
await sb.
|
|
780
|
+
await sb.stop();
|
|
781
|
+
try {
|
|
782
|
+
await sb._experimental_createSnapshot(snapshotName, 900);
|
|
783
|
+
await waitForSnapshotActive(getClient(), snapshotName);
|
|
784
|
+
} finally {
|
|
785
|
+
await sb.start();
|
|
786
|
+
}
|
|
640
787
|
},
|
|
641
788
|
{ attemptTimeoutMs: 9e5, retryOnAmbiguous: false }
|
|
642
789
|
);
|
|
@@ -644,11 +791,11 @@ var daytonaBackend = {
|
|
|
644
791
|
async deleteSnapshot(snapshotName) {
|
|
645
792
|
return retry("deleteSnapshot", async () => {
|
|
646
793
|
try {
|
|
647
|
-
const
|
|
648
|
-
const snapshot = await
|
|
649
|
-
await
|
|
794
|
+
const client = getClient();
|
|
795
|
+
const snapshot = await client.snapshot.get(snapshotName);
|
|
796
|
+
await client.snapshot.delete(snapshot);
|
|
650
797
|
} catch (err) {
|
|
651
|
-
if (err instanceof
|
|
798
|
+
if (err instanceof DaytonaNotFoundError) return;
|
|
652
799
|
const msg = err instanceof Error ? err.message : String(err);
|
|
653
800
|
if (/not found/i.test(msg)) return;
|
|
654
801
|
throw err;
|
|
@@ -743,9 +890,9 @@ async function validateCredentials(creds) {
|
|
|
743
890
|
const snapshot = snapshotManagedEnv();
|
|
744
891
|
applyToEnv(creds);
|
|
745
892
|
try {
|
|
746
|
-
const { Daytona: Daytona2 } = await import("
|
|
747
|
-
const
|
|
748
|
-
await
|
|
893
|
+
const { Daytona: Daytona2 } = await import("./esm-VGBJAFLR.js");
|
|
894
|
+
const client = new Daytona2();
|
|
895
|
+
await client.list();
|
|
749
896
|
s.stop("Daytona credentials accepted");
|
|
750
897
|
return { ok: true };
|
|
751
898
|
} catch (err) {
|
|
@@ -828,9 +975,258 @@ function secretsPath() {
|
|
|
828
975
|
import { copyFileSync, mkdtempSync, readFileSync as readFileSync2, rmSync, writeFileSync } from "fs";
|
|
829
976
|
import { tmpdir } from "os";
|
|
830
977
|
import { dirname as dirname3, join } from "path";
|
|
831
|
-
import {
|
|
832
|
-
|
|
833
|
-
|
|
978
|
+
import { createHash as createHash2 } from "crypto";
|
|
979
|
+
var BACKEND_NAME = "daytona";
|
|
980
|
+
function makeDaytonaCheckpoint(cloudProvider2) {
|
|
981
|
+
return {
|
|
982
|
+
async create(box, name) {
|
|
983
|
+
if (!box.projectRoot) {
|
|
984
|
+
throw new Error(
|
|
985
|
+
"cloud checkpoint requires the box to have a project root (run `agentbox checkpoint` from inside the project)"
|
|
986
|
+
);
|
|
987
|
+
}
|
|
988
|
+
const sandboxId = box.cloud?.sandboxId;
|
|
989
|
+
if (!sandboxId) {
|
|
990
|
+
throw new Error(`daytona box ${box.name} has no sandboxId \u2014 record is malformed`);
|
|
991
|
+
}
|
|
992
|
+
const handle = { sandboxId, sandboxClass: box.cloud?.sandboxClass };
|
|
993
|
+
const snapshotName = `${cloudSnapshotName(box.projectRoot, name)}-${Math.floor(Date.now() / 1e3).toString(36)}`;
|
|
994
|
+
await daytonaBackend.createSnapshot?.(handle, snapshotName);
|
|
995
|
+
await cloudProvider2.reconnect(box);
|
|
996
|
+
const info = await writeCloudCheckpointManifest(box.projectRoot, BACKEND_NAME, name, {
|
|
997
|
+
snapshotName,
|
|
998
|
+
sourceBoxId: box.id,
|
|
999
|
+
sourceBoxName: box.name,
|
|
1000
|
+
baseProvider: BACKEND_NAME,
|
|
1001
|
+
baseFingerprint: currentCloudBaseFingerprint(BACKEND_NAME),
|
|
1002
|
+
cliVersion: readCliStamp().cliVersion
|
|
1003
|
+
});
|
|
1004
|
+
return { ref: info.name };
|
|
1005
|
+
},
|
|
1006
|
+
async list(projectRoot) {
|
|
1007
|
+
const entries = await listCloudCheckpoints(projectRoot, BACKEND_NAME);
|
|
1008
|
+
return entries.map((e) => ({ ref: e.name, createdAt: e.manifest.createdAt }));
|
|
1009
|
+
},
|
|
1010
|
+
async remove(projectRoot, ref) {
|
|
1011
|
+
const entry = await resolveCloudCheckpoint(projectRoot, BACKEND_NAME, ref);
|
|
1012
|
+
if (!entry) return;
|
|
1013
|
+
try {
|
|
1014
|
+
await daytonaBackend.deleteSnapshot?.(entry.manifest.snapshotName);
|
|
1015
|
+
} catch {
|
|
1016
|
+
}
|
|
1017
|
+
await removeCloudCheckpointDir(projectRoot, BACKEND_NAME, ref);
|
|
1018
|
+
}
|
|
1019
|
+
};
|
|
1020
|
+
}
|
|
1021
|
+
function buildSudoRepairCommand() {
|
|
1022
|
+
return `docker run --rm --privileged -v /:/host alpine sh -c 'chown root:root /host/usr/bin/sudo && chmod 4755 /host/usr/bin/sudo && grep -q "\\b$(cat /host/etc/hostname)\\b" /host/etc/hosts || echo "127.0.0.1 $(cat /host/etc/hostname)" >> /host/etc/hosts'`;
|
|
1023
|
+
}
|
|
1024
|
+
function buildDockerWaitCommand() {
|
|
1025
|
+
return "for i in $(seq 1 30); do docker info >/dev/null 2>&1 && exit 0; sleep 2; done; exit 1";
|
|
1026
|
+
}
|
|
1027
|
+
var VmBaseImageUnavailableError = class extends Error {
|
|
1028
|
+
};
|
|
1029
|
+
async function ghcrTagExists(ref) {
|
|
1030
|
+
const m = /^ghcr\.io\/(.+):([^:]+)$/.exec(ref);
|
|
1031
|
+
if (!m) return true;
|
|
1032
|
+
const [, repo, tag] = m;
|
|
1033
|
+
try {
|
|
1034
|
+
const tokenRes = await fetch(
|
|
1035
|
+
`https://ghcr.io/token?scope=repository:${repo}:pull&service=ghcr.io`
|
|
1036
|
+
);
|
|
1037
|
+
if (!tokenRes.ok) return false;
|
|
1038
|
+
const { token } = await tokenRes.json();
|
|
1039
|
+
if (!token) return false;
|
|
1040
|
+
const res = await fetch(`https://ghcr.io/v2/${repo}/manifests/${tag}`, {
|
|
1041
|
+
method: "HEAD",
|
|
1042
|
+
headers: {
|
|
1043
|
+
Authorization: `Bearer ${token}`,
|
|
1044
|
+
Accept: [
|
|
1045
|
+
"application/vnd.oci.image.index.v1+json",
|
|
1046
|
+
"application/vnd.oci.image.manifest.v1+json",
|
|
1047
|
+
"application/vnd.docker.distribution.manifest.list.v2+json",
|
|
1048
|
+
"application/vnd.docker.distribution.manifest.v2+json"
|
|
1049
|
+
].join(",")
|
|
1050
|
+
}
|
|
1051
|
+
});
|
|
1052
|
+
return res.ok;
|
|
1053
|
+
} catch {
|
|
1054
|
+
return true;
|
|
1055
|
+
}
|
|
1056
|
+
}
|
|
1057
|
+
async function fetchImageEnv(ref) {
|
|
1058
|
+
const m = /^ghcr\.io\/(.+):([^:]+)$/.exec(ref);
|
|
1059
|
+
if (!m) return null;
|
|
1060
|
+
const [, repo, tag] = m;
|
|
1061
|
+
const accept = [
|
|
1062
|
+
"application/vnd.oci.image.index.v1+json",
|
|
1063
|
+
"application/vnd.oci.image.manifest.v1+json",
|
|
1064
|
+
"application/vnd.docker.distribution.manifest.list.v2+json",
|
|
1065
|
+
"application/vnd.docker.distribution.manifest.v2+json"
|
|
1066
|
+
].join(",");
|
|
1067
|
+
try {
|
|
1068
|
+
const tokenRes = await fetch(
|
|
1069
|
+
`https://ghcr.io/token?scope=repository:${repo}:pull&service=ghcr.io`
|
|
1070
|
+
);
|
|
1071
|
+
if (!tokenRes.ok) return null;
|
|
1072
|
+
const { token } = await tokenRes.json();
|
|
1073
|
+
if (!token) return null;
|
|
1074
|
+
const headers = { Authorization: `Bearer ${token}`, Accept: accept };
|
|
1075
|
+
const get = async (r) => {
|
|
1076
|
+
const res = await fetch(`https://ghcr.io/v2/${repo}/${r}`, { headers });
|
|
1077
|
+
return res.ok ? await res.json() : null;
|
|
1078
|
+
};
|
|
1079
|
+
let manifest = await get(`manifests/${tag}`);
|
|
1080
|
+
const children = manifest?.manifests;
|
|
1081
|
+
if (children) {
|
|
1082
|
+
const amd64 = children.find(
|
|
1083
|
+
(c) => c.platform?.os === "linux" && c.platform.architecture === "amd64"
|
|
1084
|
+
);
|
|
1085
|
+
if (!amd64) return null;
|
|
1086
|
+
manifest = await get(`manifests/${amd64.digest}`);
|
|
1087
|
+
}
|
|
1088
|
+
const configDigest = manifest?.config?.digest;
|
|
1089
|
+
if (!configDigest) return null;
|
|
1090
|
+
const config = await get(`blobs/${configDigest}`);
|
|
1091
|
+
const env = config?.config?.Env;
|
|
1092
|
+
if (!Array.isArray(env)) return null;
|
|
1093
|
+
return env.filter((e) => typeof e === "string" && e.includes("="));
|
|
1094
|
+
} catch {
|
|
1095
|
+
return null;
|
|
1096
|
+
}
|
|
1097
|
+
}
|
|
1098
|
+
function buildEnvRestoreCommand(env) {
|
|
1099
|
+
const shQuote = (v2) => `'${v2.replace(/'/g, `'\\''`)}'`;
|
|
1100
|
+
const profile = env.map((e) => {
|
|
1101
|
+
const i = e.indexOf("=");
|
|
1102
|
+
return `export ${e.slice(0, i)}=${shQuote(e.slice(i + 1))}`;
|
|
1103
|
+
}).join("\n");
|
|
1104
|
+
const envFile = env.join("\n");
|
|
1105
|
+
const b64 = (s) => Buffer.from(`${s}
|
|
1106
|
+
`, "utf8").toString("base64");
|
|
1107
|
+
return `printf %s '${b64(profile)}' | base64 -d | sudo tee /etc/profile.d/agentbox-image-env.sh >/dev/null && sudo chmod 644 /etc/profile.d/agentbox-image-env.sh && printf %s '${b64(envFile)}' | base64 -d | sudo tee -a /etc/environment >/dev/null`;
|
|
1108
|
+
}
|
|
1109
|
+
async function bakeDaytonaVmBase(opts) {
|
|
1110
|
+
const log = opts.onLog ?? (() => {
|
|
1111
|
+
});
|
|
1112
|
+
let imageEnv = [];
|
|
1113
|
+
const override = opts.baseImage?.trim();
|
|
1114
|
+
const registry = opts.registry && opts.registry.length > 0 ? opts.registry : BOX_IMAGE_REGISTRY;
|
|
1115
|
+
const imageRef = override || registryRefForSha(opts.dockerBaseSha, registry);
|
|
1116
|
+
if (!override && !await ghcrTagExists(imageRef)) {
|
|
1117
|
+
throw new VmBaseImageUnavailableError(
|
|
1118
|
+
`the linux-vm base needs a published box image, and '${imageRef}' isn't in the registry.`
|
|
1119
|
+
);
|
|
1120
|
+
}
|
|
1121
|
+
if (override) log(`using box.daytonaVmBaseImage override: ${imageRef}`);
|
|
1122
|
+
const vmBaseStem = override ? `agentbox-vmbase-x${sha12(override)}` : `agentbox-vmbase-${opts.dockerBaseSha.slice(0, 12)}`;
|
|
1123
|
+
let vmBaseName = vmBaseStem;
|
|
1124
|
+
if (await snapshotIsActive(opts.client, vmBaseName)) {
|
|
1125
|
+
log(`reusing linux-vm base image snapshot '${vmBaseName}'`);
|
|
1126
|
+
} else {
|
|
1127
|
+
vmBaseName = await createVmBaseSnapshot(opts, vmBaseStem, imageRef, log);
|
|
1128
|
+
}
|
|
1129
|
+
log("booting a throwaway sandbox to seed the base\u2026");
|
|
1130
|
+
let sandbox;
|
|
1131
|
+
try {
|
|
1132
|
+
sandbox = await opts.client.create({ snapshot: vmBaseName }, { timeout: 900 });
|
|
1133
|
+
} catch {
|
|
1134
|
+
log(`linux-vm base '${vmBaseName}' failed to boot; rebuilding it under a fresh name\u2026`);
|
|
1135
|
+
await deleteSnapshotQuietly(opts.client, vmBaseName);
|
|
1136
|
+
vmBaseName = await createVmBaseSnapshot(opts, `${vmBaseStem}-${nonce()}`, imageRef, log);
|
|
1137
|
+
sandbox = await opts.client.create({ snapshot: vmBaseName }, { timeout: 900 });
|
|
1138
|
+
}
|
|
1139
|
+
const handle = { sandboxId: sandbox.id, sandboxClass: "linux-vm" };
|
|
1140
|
+
try {
|
|
1141
|
+
const wait = await opts.backend.exec(handle, buildDockerWaitCommand());
|
|
1142
|
+
if (wait.exitCode !== 0) {
|
|
1143
|
+
throw new Error(
|
|
1144
|
+
"dockerd never came up in the VM base, so sudo cannot be repaired (the repair borrows root from the docker socket)."
|
|
1145
|
+
);
|
|
1146
|
+
}
|
|
1147
|
+
log("repairing sudo (the VM rootfs conversion strips setuid bits)\u2026");
|
|
1148
|
+
const repair = await opts.backend.exec(handle, buildSudoRepairCommand());
|
|
1149
|
+
if (repair.exitCode !== 0) {
|
|
1150
|
+
throw new Error(
|
|
1151
|
+
`failed to restore sudo in the VM base (exit ${String(repair.exitCode)}): ${repair.stdout}${repair.stderr}`
|
|
1152
|
+
);
|
|
1153
|
+
}
|
|
1154
|
+
imageEnv = await fetchImageEnv(imageRef) ?? [];
|
|
1155
|
+
if (imageEnv.length > 0) {
|
|
1156
|
+
log(`restoring the image's ${String(imageEnv.length)} env vars (the VM conversion drops them)\u2026`);
|
|
1157
|
+
const envFix = await opts.backend.exec(handle, buildEnvRestoreCommand(imageEnv));
|
|
1158
|
+
if (envFix.exitCode !== 0) {
|
|
1159
|
+
throw new Error(
|
|
1160
|
+
`failed to restore the image environment in the VM base (exit ${String(envFix.exitCode)}): ${envFix.stdout}${envFix.stderr}`
|
|
1161
|
+
);
|
|
1162
|
+
}
|
|
1163
|
+
} else {
|
|
1164
|
+
log(
|
|
1165
|
+
`warning: could not read the environment of '${imageRef}' from the registry \u2014 a VM box may come up without DISPLAY (no in-box browser).`
|
|
1166
|
+
);
|
|
1167
|
+
}
|
|
1168
|
+
await seedAgentStaticIntoCloudBox(opts.backend, handle, {
|
|
1169
|
+
hostWorkspace: opts.hostWorkspace,
|
|
1170
|
+
claudeMdOverlay: opts.claudeMdOverlay,
|
|
1171
|
+
onLog: log
|
|
1172
|
+
});
|
|
1173
|
+
log("stopping the sandbox to capture a cold snapshot\u2026");
|
|
1174
|
+
await sandbox.stop();
|
|
1175
|
+
const finalName = `${opts.snapshotName}-${nonce()}`;
|
|
1176
|
+
log(`capturing base snapshot '${finalName}'\u2026`);
|
|
1177
|
+
await sandbox._experimental_createSnapshot(finalName, 900);
|
|
1178
|
+
await waitForSnapshotActive(opts.client, finalName);
|
|
1179
|
+
log(`snapshot '${finalName}' is active`);
|
|
1180
|
+
return { snapshotName: finalName, env: imageEnv };
|
|
1181
|
+
} finally {
|
|
1182
|
+
try {
|
|
1183
|
+
await sandbox.delete(120);
|
|
1184
|
+
} catch (err) {
|
|
1185
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
1186
|
+
log(`warning: could not delete the temporary bake sandbox ${sandbox.id}: ${msg}`);
|
|
1187
|
+
}
|
|
1188
|
+
}
|
|
1189
|
+
}
|
|
1190
|
+
function sha12(s) {
|
|
1191
|
+
return createHash2("sha256").update(s).digest("hex").slice(0, 12);
|
|
1192
|
+
}
|
|
1193
|
+
function nonce() {
|
|
1194
|
+
return Math.floor(Date.now() / 1e3).toString(36);
|
|
1195
|
+
}
|
|
1196
|
+
async function createVmBaseSnapshot(opts, name, imageRef, log) {
|
|
1197
|
+
log(`creating linux-vm base image snapshot '${name}' from ${imageRef}\u2026`);
|
|
1198
|
+
await opts.client.snapshot.create(
|
|
1199
|
+
{
|
|
1200
|
+
name,
|
|
1201
|
+
image: imageRef,
|
|
1202
|
+
sandboxClass: import_api_client.SandboxClass.LINUX_VM,
|
|
1203
|
+
regionId: opts.regionId,
|
|
1204
|
+
// Always explicit: a snapshot with no `resources` gets Daytona's 1 vCPU /
|
|
1205
|
+
// 1 GiB / 3 GiB default, and the box image does not fit in 3 GiB — the
|
|
1206
|
+
// build dies mid-pull with a bare "internal error".
|
|
1207
|
+
resources: opts.resources ?? { cpu: 2, memory: 4, disk: 8 }
|
|
1208
|
+
},
|
|
1209
|
+
{ onLogs: (c) => log(String(c).split("\n").filter(Boolean).join(" ")) }
|
|
1210
|
+
);
|
|
1211
|
+
return name;
|
|
1212
|
+
}
|
|
1213
|
+
async function snapshotIsActive(client, name) {
|
|
1214
|
+
try {
|
|
1215
|
+
const snap = await client.snapshot.get(name);
|
|
1216
|
+
return snap?.state === "active";
|
|
1217
|
+
} catch {
|
|
1218
|
+
return false;
|
|
1219
|
+
}
|
|
1220
|
+
}
|
|
1221
|
+
async function deleteSnapshotQuietly(client, name) {
|
|
1222
|
+
try {
|
|
1223
|
+
const snap = await client.snapshot.get(name);
|
|
1224
|
+
await client.snapshot.delete(snap);
|
|
1225
|
+
} catch {
|
|
1226
|
+
}
|
|
1227
|
+
}
|
|
1228
|
+
function defaultSnapshotName(fingerprint, sizeKey, sandboxClass) {
|
|
1229
|
+
const suffix = `${sizeKey ? `-${sizeKey}` : ""}${sandboxClass === "linux-vm" ? "-vm" : ""}`;
|
|
834
1230
|
if (fingerprint) return `agentbox-base-${fingerprint.slice(0, 12)}${suffix}`;
|
|
835
1231
|
return `agentbox-base-${Math.floor(Date.now() / 1e3).toString()}${suffix}`;
|
|
836
1232
|
}
|
|
@@ -872,14 +1268,15 @@ async function prepareDaytona(opts) {
|
|
|
872
1268
|
);
|
|
873
1269
|
}
|
|
874
1270
|
const sizeKey = sizeResources ? `${String(sizeResources.cpu)}-${String(sizeResources.memory)}-${String(sizeResources.disk)}` : void 0;
|
|
1271
|
+
let sandboxClass = opts.sandboxClass === "container" ? "container" : "linux-vm";
|
|
875
1272
|
const rawFingerprint = await computeDaytonaContextFingerprint();
|
|
876
1273
|
const fingerprint = rawFingerprint ? {
|
|
877
1274
|
...rawFingerprint,
|
|
878
1275
|
contextSha256: claudeInstallFingerprint(rawFingerprint.contextSha256, claudeInstall)
|
|
879
1276
|
} : rawFingerprint;
|
|
880
|
-
|
|
1277
|
+
let snapshotName = opts.name ?? defaultSnapshotName(fingerprint?.contextSha256 ?? null, sizeKey, sandboxClass);
|
|
881
1278
|
const prepared = readPreparedDaytonaState();
|
|
882
|
-
if (!opts.force && fingerprint && preparedMatches(prepared, fingerprint.contextSha256, sizeKey)) {
|
|
1279
|
+
if (!opts.force && fingerprint && preparedMatches(prepared, fingerprint.contextSha256, sizeKey, sandboxClass)) {
|
|
883
1280
|
try {
|
|
884
1281
|
const existing = await getClient().snapshot.get(
|
|
885
1282
|
prepared?.base?.imageRef ?? snapshotName
|
|
@@ -900,7 +1297,13 @@ async function prepareDaytona(opts) {
|
|
|
900
1297
|
}
|
|
901
1298
|
} else if (!opts.force && fingerprint && prepared?.base?.contextSha256) {
|
|
902
1299
|
const bakedSize = prepared.extras?.size;
|
|
903
|
-
|
|
1300
|
+
const bakedClass = prepared.extras?.class ?? "container";
|
|
1301
|
+
const sameContext = prepared.base.contextSha256 === fingerprint.contextSha256;
|
|
1302
|
+
if (sameContext && bakedClass !== sandboxClass) {
|
|
1303
|
+
log(
|
|
1304
|
+
`daytona sandbox class changed (was ${bakedClass}, now ${sandboxClass}); rebuilding snapshot`
|
|
1305
|
+
);
|
|
1306
|
+
} else if (sameContext && bakedSize !== sizeKey) {
|
|
904
1307
|
log(
|
|
905
1308
|
`daytona size changed (was ${bakedSize ?? "default"}, now ${sizeKey ?? "default"}); rebuilding snapshot`
|
|
906
1309
|
);
|
|
@@ -922,6 +1325,55 @@ async function prepareDaytona(opts) {
|
|
|
922
1325
|
"could not locate packages/sandbox-daytona/scripts/custom-system-CLAUDE.md (or its staged runtime/daytona/ copy). Ensure `pnpm -w build` ran so the CLI staging populated runtime/daytona/."
|
|
923
1326
|
);
|
|
924
1327
|
}
|
|
1328
|
+
if (sandboxClass === "linux-vm") {
|
|
1329
|
+
const dockerBaseSha = await computeDockerBaseSha(claudeInstall);
|
|
1330
|
+
if (!dockerBaseSha) {
|
|
1331
|
+
throw new Error(
|
|
1332
|
+
"could not fingerprint the docker build context, which names the published box image a linux-vm base must boot from. Ensure `pnpm -w build` ran, or set `agentbox config set box.daytonaClass container`."
|
|
1333
|
+
);
|
|
1334
|
+
}
|
|
1335
|
+
try {
|
|
1336
|
+
const baked = await bakeDaytonaVmBase({
|
|
1337
|
+
client: getClient(opts.location ?? DAYTONA_VM_REGION),
|
|
1338
|
+
backend: daytonaBackend,
|
|
1339
|
+
regionId: opts.location ?? DAYTONA_VM_REGION,
|
|
1340
|
+
snapshotName,
|
|
1341
|
+
dockerBaseSha,
|
|
1342
|
+
registry: opts.registry,
|
|
1343
|
+
baseImage: opts.vmBaseImage,
|
|
1344
|
+
// Always explicit: a snapshot created with no `resources` gets Daytona's
|
|
1345
|
+
// 1 vCPU / 1 GiB / 3 GiB default, and the box image does not fit in 3 GiB
|
|
1346
|
+
// (the build dies mid-pull with a bare "internal error").
|
|
1347
|
+
resources: sizeResources ?? { ...DAYTONA_DEFAULT_RESOURCES },
|
|
1348
|
+
hostWorkspace: opts.hostWorkspace,
|
|
1349
|
+
claudeMdOverlay: daytonaClaudeMd,
|
|
1350
|
+
onLog: log
|
|
1351
|
+
});
|
|
1352
|
+
if (fingerprint) {
|
|
1353
|
+
writePreparedDaytonaState({
|
|
1354
|
+
snapshotName: baked.snapshotName,
|
|
1355
|
+
contextSha256: fingerprint.contextSha256,
|
|
1356
|
+
size: sizeKey,
|
|
1357
|
+
class: "linux-vm",
|
|
1358
|
+
env: baked.env
|
|
1359
|
+
});
|
|
1360
|
+
log(`recorded daytona-prepared.json (fingerprint ${fingerprint.contextSha256.slice(0, 12)})`);
|
|
1361
|
+
}
|
|
1362
|
+
const superseded = prepared?.base?.imageRef;
|
|
1363
|
+
if (superseded && superseded !== baked.snapshotName && prepared?.extras?.class === "linux-vm") {
|
|
1364
|
+
log(`removing superseded snapshot '${superseded}'`);
|
|
1365
|
+
await deleteSnapshotQuietly(getClient(opts.location ?? DAYTONA_VM_REGION), superseded);
|
|
1366
|
+
}
|
|
1367
|
+
return { snapshotName: baked.snapshotName };
|
|
1368
|
+
} catch (err) {
|
|
1369
|
+
if (!(err instanceof VmBaseImageUnavailableError)) throw err;
|
|
1370
|
+
log(
|
|
1371
|
+
`daytona: ${err.message} This usually means a locally modified Dockerfile.box. Daytona can't build a linux-vm base from a Dockerfile, so falling back to a container snapshot (no pause/resume).`
|
|
1372
|
+
);
|
|
1373
|
+
sandboxClass = "container";
|
|
1374
|
+
snapshotName = opts.name ?? defaultSnapshotName(fingerprint?.contextSha256 ?? null, sizeKey, sandboxClass);
|
|
1375
|
+
}
|
|
1376
|
+
}
|
|
925
1377
|
const stages = await stageAllAgentStatic({ hostWorkspace: opts.hostWorkspace });
|
|
926
1378
|
for (const s of stages) {
|
|
927
1379
|
for (const w of s.staged.warnings) log(w);
|
|
@@ -930,7 +1382,7 @@ async function prepareDaytona(opts) {
|
|
|
930
1382
|
const dockerfilePath = claudeInstall === "npm" ? tempDockerfile = writeNpmDockerfile(ctx.dockerfile) : ctx.dockerfile;
|
|
931
1383
|
let seedContextDir = null;
|
|
932
1384
|
try {
|
|
933
|
-
let image =
|
|
1385
|
+
let image = Image.fromDockerfile(dockerfilePath);
|
|
934
1386
|
seedContextDir = mkdtempSync(join(tmpdir(), "agentbox-daytona-seed-"));
|
|
935
1387
|
copyFileSync(daytonaClaudeMd, join(seedContextDir, DAYTONA_CLAUDE_MD_REL));
|
|
936
1388
|
const usable = stages.filter((s) => s.staged.tarballPath !== null);
|
|
@@ -938,12 +1390,17 @@ async function prepareDaytona(opts) {
|
|
|
938
1390
|
copyFileSync(s.staged.tarballPath, join(seedContextDir, daytonaSeedPaths(s.kind).contextRel));
|
|
939
1391
|
}
|
|
940
1392
|
image = image.dockerfileCommands(buildDaytonaSeedCommands(usable), seedContextDir);
|
|
941
|
-
const
|
|
1393
|
+
const client = getClient(opts.location ?? "");
|
|
942
1394
|
log(
|
|
943
1395
|
`creating Daytona snapshot '${snapshotName}'${sizeResources ? ` (${sizeKey})` : ""}\u2026`
|
|
944
1396
|
);
|
|
945
|
-
const snapshot = await
|
|
946
|
-
{
|
|
1397
|
+
const snapshot = await client.snapshot.create(
|
|
1398
|
+
{
|
|
1399
|
+
name: snapshotName,
|
|
1400
|
+
image,
|
|
1401
|
+
...sizeResources ? { resources: sizeResources } : {},
|
|
1402
|
+
...opts.location ? { regionId: opts.location } : {}
|
|
1403
|
+
},
|
|
947
1404
|
{
|
|
948
1405
|
onLogs: (chunk) => log(String(chunk).split("\n").filter(Boolean).join(" "))
|
|
949
1406
|
}
|
|
@@ -953,7 +1410,8 @@ async function prepareDaytona(opts) {
|
|
|
953
1410
|
writePreparedDaytonaState({
|
|
954
1411
|
snapshotName: snapshot.name ?? snapshotName,
|
|
955
1412
|
contextSha256: fingerprint.contextSha256,
|
|
956
|
-
size: sizeKey
|
|
1413
|
+
size: sizeKey,
|
|
1414
|
+
class: "container"
|
|
957
1415
|
});
|
|
958
1416
|
log(
|
|
959
1417
|
`recorded daytona-prepared.json (fingerprint ${fingerprint.contextSha256.slice(0, 12)})`
|
|
@@ -995,9 +1453,9 @@ async function getDaytonaStatus() {
|
|
|
995
1453
|
reason: err instanceof Error ? err.message : String(err)
|
|
996
1454
|
};
|
|
997
1455
|
}
|
|
998
|
-
let
|
|
1456
|
+
let client;
|
|
999
1457
|
try {
|
|
1000
|
-
|
|
1458
|
+
client = getClient();
|
|
1001
1459
|
} catch (err) {
|
|
1002
1460
|
return {
|
|
1003
1461
|
configured: false,
|
|
@@ -1010,7 +1468,7 @@ async function getDaytonaStatus() {
|
|
|
1010
1468
|
const volumes = [];
|
|
1011
1469
|
let reason;
|
|
1012
1470
|
try {
|
|
1013
|
-
const list = await
|
|
1471
|
+
const list = await client.snapshot.list();
|
|
1014
1472
|
const items = list.items ?? (Array.isArray(list) ? list : []);
|
|
1015
1473
|
for (const s of items) {
|
|
1016
1474
|
const dto = s;
|
|
@@ -1027,7 +1485,7 @@ async function getDaytonaStatus() {
|
|
|
1027
1485
|
reason = `snapshot list failed: ${err instanceof Error ? err.message.split("\n")[0] : String(err)}`;
|
|
1028
1486
|
}
|
|
1029
1487
|
try {
|
|
1030
|
-
const list = await
|
|
1488
|
+
const list = await client.volume.list();
|
|
1031
1489
|
const items = Array.isArray(list) ? list : list.items ?? [];
|
|
1032
1490
|
for (const v2 of items) {
|
|
1033
1491
|
const dto = v2;
|
|
@@ -1071,27 +1529,51 @@ async function doctorChecks() {
|
|
|
1071
1529
|
];
|
|
1072
1530
|
}
|
|
1073
1531
|
const credRes = { label: "credentials", status: "ok", detail: "configured" };
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1532
|
+
return [credRes, await baseSnapshotCheck(status.snapshots.length)];
|
|
1533
|
+
} catch (err) {
|
|
1534
|
+
return [{ label: "credentials", status: "warn", detail: errSummary(err) }];
|
|
1535
|
+
}
|
|
1536
|
+
}
|
|
1537
|
+
async function baseSnapshotCheck(snapshotCount) {
|
|
1538
|
+
if (snapshotCount === 0) {
|
|
1539
|
+
return {
|
|
1079
1540
|
label: "base snapshot",
|
|
1080
1541
|
status: "warn",
|
|
1081
1542
|
detail: "none",
|
|
1082
1543
|
hint: "`agentbox prepare --provider daytona`"
|
|
1083
1544
|
};
|
|
1084
|
-
return [credRes, snapRes];
|
|
1085
|
-
} catch (err) {
|
|
1086
|
-
return [{ label: "credentials", status: "warn", detail: errSummary(err) }];
|
|
1087
1545
|
}
|
|
1546
|
+
const prepared = readPreparedDaytonaState();
|
|
1547
|
+
const bakedClass = prepared?.base ? prepared.extras?.class ?? "container" : void 0;
|
|
1548
|
+
let wantClass;
|
|
1549
|
+
try {
|
|
1550
|
+
wantClass = resolveDaytonaClass((await loadEffectiveConfig(process.cwd())).effective);
|
|
1551
|
+
} catch {
|
|
1552
|
+
}
|
|
1553
|
+
if (bakedClass && wantClass && bakedClass !== wantClass) {
|
|
1554
|
+
return {
|
|
1555
|
+
label: "base snapshot",
|
|
1556
|
+
status: "warn",
|
|
1557
|
+
detail: `baked as '${bakedClass}' but box.daytonaClass is '${wantClass}' \u2014 creates will fail`,
|
|
1558
|
+
hint: "`agentbox prepare --provider daytona --force`"
|
|
1559
|
+
};
|
|
1560
|
+
}
|
|
1561
|
+
return {
|
|
1562
|
+
label: "base snapshot",
|
|
1563
|
+
status: "ok",
|
|
1564
|
+
detail: `${String(snapshotCount)} agentbox snapshot(s)${bakedClass ? ` (base: ${bakedClass})` : ""}`
|
|
1565
|
+
};
|
|
1088
1566
|
}
|
|
1089
1567
|
var cloudProvider = createCloudProvider(daytonaBackend, {
|
|
1090
|
-
defaultResources: {
|
|
1568
|
+
defaultResources: { ...DAYTONA_DEFAULT_RESOURCES }
|
|
1091
1569
|
});
|
|
1092
1570
|
var daytonaProvider = {
|
|
1093
1571
|
...cloudProvider,
|
|
1094
1572
|
prepare: prepareDaytona,
|
|
1573
|
+
// Overrides the generic cloud checkpoint: a Daytona cold snapshot needs the
|
|
1574
|
+
// sandbox stopped, which kills the in-box daemons, so the capture has to
|
|
1575
|
+
// reconnect the box afterwards. See `makeDaytonaCheckpoint`.
|
|
1576
|
+
checkpoint: makeDaytonaCheckpoint(cloudProvider),
|
|
1095
1577
|
baseFingerprint: () => currentDaytonaBaseFingerprintLive()
|
|
1096
1578
|
};
|
|
1097
1579
|
var providerModule = {
|
|
@@ -1104,6 +1586,7 @@ var providerModule = {
|
|
|
1104
1586
|
doctorChecks
|
|
1105
1587
|
};
|
|
1106
1588
|
export {
|
|
1589
|
+
DAYTONA_DEFAULT_RESOURCES,
|
|
1107
1590
|
DEFAULT_BOX_IMAGE_REF,
|
|
1108
1591
|
currentDaytonaBaseFingerprintLive,
|
|
1109
1592
|
daytonaBackend,
|