@madarco/agentbox 0.24.6 → 0.25.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 +69 -0
- package/LICENSE +21 -0
- package/README.md +4 -0
- package/dist/{_cloud-attach-ESCPOKG5.js → _cloud-attach-FGMI2ZHO.js} +5 -5
- package/dist/{chunk-4HPLS5HJ.js → chunk-3BR63LCB.js} +110 -9
- package/dist/chunk-3BR63LCB.js.map +1 -0
- package/dist/{chunk-OSPM4Q5V.js → chunk-3PSRBK24.js} +6 -6
- package/dist/chunk-3PSRBK24.js.map +1 -0
- package/dist/{chunk-CE3S7UDQ.js → chunk-4DBLYT2F.js} +44 -12
- package/dist/chunk-4DBLYT2F.js.map +1 -0
- package/dist/{chunk-3MDYQROX.js → chunk-4LS2TOF3.js} +17 -13
- package/dist/chunk-4LS2TOF3.js.map +1 -0
- package/dist/{chunk-H6A4BQMG.js → chunk-5F5SOSDY.js} +40 -1
- package/dist/chunk-5F5SOSDY.js.map +1 -0
- package/dist/{chunk-LJMGHFLZ.js → chunk-5VNL6SHJ.js} +3 -3
- package/dist/{chunk-7DPDUZ7L.js → chunk-67VF2QZC.js} +194 -56
- package/dist/chunk-67VF2QZC.js.map +1 -0
- package/dist/{chunk-RFRWS5CD.js → chunk-6GZK74GT.js} +2 -2
- package/dist/chunk-G3H2L3O2.js +0 -0
- package/dist/{chunk-5JDOTQTM.js → chunk-P5U6AP6K.js} +4 -4
- package/dist/chunk-WJFZJZIM.js +0 -0
- package/dist/{chunk-QHISF6O6.js → chunk-ZTSVY3YL.js} +3 -3
- package/dist/cloud-poller-SUNA6ZQC-7M5LJHHE.js +0 -0
- package/dist/{dist-VFPT5TDH.js → dist-4I7XHDC3.js} +6 -6
- package/dist/dist-5G42NFOG.js +677 -0
- package/dist/dist-5G42NFOG.js.map +1 -0
- package/dist/{dist-TRKHS6I7.js → dist-AZUD2LUA.js} +6 -6
- package/dist/{dist-FGXCG4JY.js → dist-MEK44IS5.js} +6 -6
- package/dist/{dist-HPPHBZTO.js → dist-SBDYDH7H.js} +8 -2
- package/dist/{dist-NOUPH5E6.js → dist-SN6ABGMD.js} +4 -4
- package/dist/{dist-3M53BF4E.js → dist-X7R2EMJL.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-75DIZ55S-5UAKJX3L.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-5KMJIVZC.js → chunk-23AU7VYS.js} +111 -10
- package/runtime/hub/apps/hub/{chunk-OF242BLD.js → chunk-CKBHQ7OI.js} +1 -1
- package/runtime/hub/apps/hub/{chunk-DNR2YM2G.js → chunk-GARA7RQW.js} +58 -10
- package/runtime/hub/apps/hub/{chunk-PROXBLRJ.js → chunk-JLG5JJXD.js} +1 -1
- package/runtime/hub/apps/hub/{chunk-TZFWAJVB.js → chunk-OG4KH2FZ.js} +5 -0
- package/runtime/hub/apps/hub/chunk-QYJ37CUJ.js +62140 -0
- package/runtime/hub/apps/hub/{chunk-EY6HEDTK.js → chunk-RSENJ2FT.js} +17 -13
- 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-KV5ESR24.js → dist-DZGSA3US.js} +7 -7
- package/runtime/hub/apps/hub/{dist-NTKPAYA3.js → dist-IZ2JCN5R.js} +8 -2
- package/runtime/hub/apps/hub/{dist-M73U3ZDH.js → dist-JVU3QCLG.js} +7 -7
- package/runtime/hub/apps/hub/{dist-3DCKZYID.js → dist-TP4SXMDY.js} +596 -113
- package/runtime/hub/apps/hub/{dist-YCRESLWD.js → dist-VWSHZIPN.js} +7 -7
- package/runtime/hub/apps/hub/{dist-SX2NXGI6.js → dist-WZKTIA2R.js} +7 -7
- package/runtime/hub/apps/hub/{dist-RSWTJWRN.js → dist-YWY2DSSL.js} +5 -5
- 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-75DIZ55S-JDILR4OP.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-FGMI2ZHO.js.map} +0 -0
- /package/dist/{chunk-LJMGHFLZ.js.map → chunk-5VNL6SHJ.js.map} +0 -0
- /package/dist/{chunk-RFRWS5CD.js.map → chunk-6GZK74GT.js.map} +0 -0
- /package/dist/{chunk-5JDOTQTM.js.map → chunk-P5U6AP6K.js.map} +0 -0
- /package/dist/{chunk-QHISF6O6.js.map → chunk-ZTSVY3YL.js.map} +0 -0
- /package/dist/{dist-HPPHBZTO.js.map → dist-4I7XHDC3.js.map} +0 -0
- /package/dist/{dist-NOUPH5E6.js.map → dist-AZUD2LUA.js.map} +0 -0
- /package/dist/{dist-FGXCG4JY.js.map → dist-MEK44IS5.js.map} +0 -0
- /package/dist/{dist-TRKHS6I7.js.map → dist-SBDYDH7H.js.map} +0 -0
- /package/dist/{dist-VFPT5TDH.js.map → dist-SN6ABGMD.js.map} +0 -0
- /package/dist/{dist-3M53BF4E.js.map → dist-X7R2EMJL.js.map} +0 -0
- /package/dist/{prepared-state-BUO75YLZ-46W2PAHH.js.map → prepared-state-75DIZ55S-5UAKJX3L.js.map} +0 -0
- /package/runtime/hub/apps/hub/.next/static/{2LDXStEUVHS2oK1ID_Uvo → fo5EgsHa6PFLTBagfLiuM}/_buildManifest.js +0 -0
- /package/runtime/hub/apps/hub/.next/static/{2LDXStEUVHS2oK1ID_Uvo → fo5EgsHa6PFLTBagfLiuM}/_clientMiddlewareManifest.js +0 -0
- /package/runtime/hub/apps/hub/.next/static/{2LDXStEUVHS2oK1ID_Uvo → fo5EgsHa6PFLTBagfLiuM}/_ssgManifest.js +0 -0
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
DAYTONA_VM_REGION
|
|
4
|
+
} from "./chunk-5F5SOSDY.js";
|
|
2
5
|
import {
|
|
3
6
|
DOCKER_CONTEXT_FILE_MAP,
|
|
4
7
|
claudeInstallFingerprint,
|
|
@@ -9,9 +12,9 @@ import {
|
|
|
9
12
|
resolveContextFilesFrom,
|
|
10
13
|
writeManagedSecrets,
|
|
11
14
|
writePreparedStateRaw
|
|
12
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-4LS2TOF3.js";
|
|
13
16
|
|
|
14
|
-
// ../../packages/sandbox-daytona/dist/chunk-
|
|
17
|
+
// ../../packages/sandbox-daytona/dist/chunk-HEUB57SZ.js
|
|
15
18
|
import { existsSync } from "fs";
|
|
16
19
|
import { dirname, resolve } from "path";
|
|
17
20
|
import { fileURLToPath } from "url";
|
|
@@ -22,7 +25,7 @@ import { createHash } from "crypto";
|
|
|
22
25
|
import { existsSync as existsSync3 } from "fs";
|
|
23
26
|
import { dirname as dirname2, resolve as resolve3 } from "path";
|
|
24
27
|
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
25
|
-
import { Daytona, DaytonaNotFoundError as DaytonaNotFoundError2, Image, SandboxState } from "@
|
|
28
|
+
import { Daytona, DaytonaNotFoundError as DaytonaNotFoundError2, Image, SandboxState } from "@daytona/sdk";
|
|
26
29
|
import {
|
|
27
30
|
DaytonaAuthenticationError,
|
|
28
31
|
DaytonaAuthorizationError,
|
|
@@ -33,7 +36,7 @@ import {
|
|
|
33
36
|
DaytonaRateLimitError,
|
|
34
37
|
DaytonaTimeoutError,
|
|
35
38
|
DaytonaValidationError
|
|
36
|
-
} from "@
|
|
39
|
+
} from "@daytona/sdk";
|
|
37
40
|
import { spawnSync } from "child_process";
|
|
38
41
|
import { homedir as homedir2 } from "os";
|
|
39
42
|
import { resolve as resolve4 } from "path";
|
|
@@ -130,16 +133,7 @@ function parseEnvFile(body) {
|
|
|
130
133
|
}
|
|
131
134
|
var SCHEMA = 1;
|
|
132
135
|
function resolveDaytonaContextFiles() {
|
|
133
|
-
const
|
|
134
|
-
if (!ctx) return null;
|
|
135
|
-
const here = dirname2(fileURLToPath2(import.meta.url));
|
|
136
|
-
const packageRoot = resolve3(here, "..");
|
|
137
|
-
const monorepoRoot = resolve3(here, "..", "..", "..");
|
|
138
|
-
const dockerPackageRoot = resolve3(monorepoRoot, "packages", "sandbox-docker");
|
|
139
|
-
const docker = resolveContextFilesFrom(DOCKER_CONTEXT_FILE_MAP, {
|
|
140
|
-
contextDir: ctx.context,
|
|
141
|
-
devRoot: existsSync3(dockerPackageRoot) ? dockerPackageRoot : packageRoot
|
|
142
|
-
});
|
|
136
|
+
const docker = resolveDockerContextFilesForDaytona();
|
|
143
137
|
if (!docker) return null;
|
|
144
138
|
const overlay = resolveDaytonaCustomClaudeMd();
|
|
145
139
|
if (!overlay) return null;
|
|
@@ -151,6 +145,23 @@ function resolveDaytonaContextFiles() {
|
|
|
151
145
|
{ rel: "daytona/custom-system-CLAUDE.md", abs: overlay }
|
|
152
146
|
];
|
|
153
147
|
}
|
|
148
|
+
function resolveDockerContextFilesForDaytona() {
|
|
149
|
+
const ctx = resolveDockerfileContext();
|
|
150
|
+
if (!ctx) return null;
|
|
151
|
+
const here = dirname2(fileURLToPath2(import.meta.url));
|
|
152
|
+
const packageRoot = resolve3(here, "..");
|
|
153
|
+
const monorepoRoot = resolve3(here, "..", "..", "..");
|
|
154
|
+
const dockerPackageRoot = resolve3(monorepoRoot, "packages", "sandbox-docker");
|
|
155
|
+
return resolveContextFilesFrom(DOCKER_CONTEXT_FILE_MAP, {
|
|
156
|
+
contextDir: ctx.context,
|
|
157
|
+
devRoot: existsSync3(dockerPackageRoot) ? dockerPackageRoot : packageRoot
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
async function computeDockerBaseSha(claudeInstall = "native") {
|
|
161
|
+
const files = resolveDockerContextFilesForDaytona();
|
|
162
|
+
if (!files) return null;
|
|
163
|
+
return claudeInstallFingerprint(await computeContextSha256(files), claudeInstall);
|
|
164
|
+
}
|
|
154
165
|
var DAYTONA_SEED_SCHEMA = "relctx-1";
|
|
155
166
|
async function computeDaytonaContextFingerprint() {
|
|
156
167
|
const files = resolveDaytonaContextFiles();
|
|
@@ -177,6 +188,11 @@ function readPreparedDaytonaState() {
|
|
|
177
188
|
}
|
|
178
189
|
function writePreparedDaytonaState(opts) {
|
|
179
190
|
const stamp = readCliStamp();
|
|
191
|
+
const extras = {
|
|
192
|
+
...opts.size ? { size: opts.size } : {},
|
|
193
|
+
...opts.class ? { class: opts.class } : {},
|
|
194
|
+
...opts.env && opts.env.length > 0 ? { env: opts.env } : {}
|
|
195
|
+
};
|
|
180
196
|
const state = {
|
|
181
197
|
schema: SCHEMA,
|
|
182
198
|
base: {
|
|
@@ -186,13 +202,36 @@ function writePreparedDaytonaState(opts) {
|
|
|
186
202
|
cliCommit: stamp.cliCommit,
|
|
187
203
|
createdAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
188
204
|
},
|
|
189
|
-
...
|
|
205
|
+
...Object.keys(extras).length > 0 ? { extras } : {}
|
|
190
206
|
};
|
|
191
207
|
writePreparedStateRaw("daytona", state);
|
|
192
208
|
}
|
|
193
|
-
function preparedMatches(state, current, size) {
|
|
209
|
+
function preparedMatches(state, current, size, sandboxClass) {
|
|
194
210
|
if (state?.base?.contextSha256 !== current) return false;
|
|
195
|
-
|
|
211
|
+
if ((state?.extras?.size ?? void 0) !== (size ?? void 0)) return false;
|
|
212
|
+
if (sandboxClass === void 0) return true;
|
|
213
|
+
return (state?.extras?.class ?? "container") === sandboxClass;
|
|
214
|
+
}
|
|
215
|
+
async function waitForSnapshotActive(client, name, timeoutMs = 9e5) {
|
|
216
|
+
const deadline = Date.now() + timeoutMs;
|
|
217
|
+
for (; ; ) {
|
|
218
|
+
let state;
|
|
219
|
+
try {
|
|
220
|
+
state = (await client.snapshot.get(name))?.state;
|
|
221
|
+
} catch {
|
|
222
|
+
state = void 0;
|
|
223
|
+
}
|
|
224
|
+
if (state === "active") return;
|
|
225
|
+
if (state === "error" || state === "build_failed") {
|
|
226
|
+
throw new Error(`daytona snapshot '${name}' ended in state '${state}'`);
|
|
227
|
+
}
|
|
228
|
+
if (Date.now() >= deadline) {
|
|
229
|
+
throw new Error(
|
|
230
|
+
`daytona snapshot '${name}' did not become active within ${String(Math.round(timeoutMs / 6e4))} min (state: ${state ?? "unknown"})`
|
|
231
|
+
);
|
|
232
|
+
}
|
|
233
|
+
await new Promise((r) => setTimeout(r, 3e3));
|
|
234
|
+
}
|
|
196
235
|
}
|
|
197
236
|
var DEFAULT_BACKOFF = [1e3, 2e3, 4e3];
|
|
198
237
|
var DEFAULT_ATTEMPT_TIMEOUT_MS = 3e4;
|
|
@@ -297,21 +336,23 @@ function retry(method, fn, opts = {}) {
|
|
|
297
336
|
);
|
|
298
337
|
}
|
|
299
338
|
var DEFAULT_BOX_IMAGE_REF = "agentbox/box:dev";
|
|
300
|
-
var
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
339
|
+
var DAYTONA_DEFAULT_RESOURCES = { cpu: 2, memory: 4, disk: 8 };
|
|
340
|
+
var clients = /* @__PURE__ */ new Map();
|
|
341
|
+
function getClient(target = "") {
|
|
342
|
+
const cached = clients.get(target);
|
|
343
|
+
if (cached) return cached;
|
|
344
|
+
ensureDaytonaEnvLoaded();
|
|
345
|
+
try {
|
|
346
|
+
const created = target.length > 0 ? new Daytona({ target }) : new Daytona();
|
|
347
|
+
clients.set(target, created);
|
|
348
|
+
return created;
|
|
349
|
+
} catch (err) {
|
|
350
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
351
|
+
throw new Error(
|
|
352
|
+
`Daytona credentials not configured: ${msg}
|
|
310
353
|
Run \`agentbox daytona login\` interactively, or set DAYTONA_API_KEY in the environment.`
|
|
311
|
-
|
|
312
|
-
}
|
|
354
|
+
);
|
|
313
355
|
}
|
|
314
|
-
return client;
|
|
315
356
|
}
|
|
316
357
|
async function getSandbox(id) {
|
|
317
358
|
return getClient().get(id);
|
|
@@ -334,11 +375,14 @@ function mapState(s) {
|
|
|
334
375
|
case SandboxState.PULLING_SNAPSHOT:
|
|
335
376
|
case SandboxState.PENDING_BUILD:
|
|
336
377
|
case SandboxState.STOPPING:
|
|
378
|
+
case SandboxState.RESUMING:
|
|
337
379
|
return "running";
|
|
338
380
|
case SandboxState.STOPPED:
|
|
339
381
|
return "stopped";
|
|
340
382
|
case SandboxState.ARCHIVED:
|
|
341
383
|
case SandboxState.ARCHIVING:
|
|
384
|
+
case SandboxState.PAUSED:
|
|
385
|
+
case SandboxState.PAUSING:
|
|
342
386
|
return "paused";
|
|
343
387
|
case SandboxState.DESTROYED:
|
|
344
388
|
case SandboxState.DESTROYING:
|
|
@@ -390,17 +434,40 @@ var daytonaBackend = {
|
|
|
390
434
|
}
|
|
391
435
|
}
|
|
392
436
|
const resources = sizeResources ?? req.resources;
|
|
437
|
+
const prepared = readPreparedDaytonaState();
|
|
438
|
+
const baseRef = req.snapshot ?? req.image;
|
|
439
|
+
const bootingPreparedBase = prepared?.base?.imageRef !== void 0 && baseRef === prepared.base.imageRef;
|
|
440
|
+
const imageEnv = {};
|
|
441
|
+
if (bootingPreparedBase) {
|
|
442
|
+
for (const kv of prepared.extras?.env ?? []) {
|
|
443
|
+
const i = kv.indexOf("=");
|
|
444
|
+
if (i > 0) imageEnv[kv.slice(0, i)] = kv.slice(i + 1);
|
|
445
|
+
}
|
|
446
|
+
}
|
|
393
447
|
const baseParams = {
|
|
394
448
|
...resources ? { resources } : {},
|
|
395
|
-
envVars: req.env,
|
|
449
|
+
envVars: { ...imageEnv, ...req.env },
|
|
396
450
|
...req.volumes && req.volumes.length > 0 ? { volumes: req.volumes.map(toDaytonaVolumeMount) } : {},
|
|
397
|
-
labels: { "agentbox.name": req.name }
|
|
451
|
+
labels: { "agentbox.name": req.name },
|
|
452
|
+
// Daytona auto-stops a sandbox after N minutes of INACTIVITY (its own
|
|
453
|
+
// default is 15). The host keepalive loop pushes this forward via
|
|
454
|
+
// `renewTimeout` while an agent is working, so only a genuinely idle
|
|
455
|
+
// box lapses. 0 disables it entirely.
|
|
456
|
+
...typeof req.timeoutMs === "number" ? { autoStopInterval: Math.max(0, Math.round(req.timeoutMs / 6e4)) } : {}
|
|
398
457
|
};
|
|
399
|
-
const
|
|
458
|
+
const bakedClass = bootingPreparedBase ? prepared.extras?.class ?? "container" : void 0;
|
|
459
|
+
const sandboxClass = bakedClass ?? req.sandboxClass;
|
|
460
|
+
if (bakedClass && req.sandboxClass && bakedClass !== req.sandboxClass) {
|
|
461
|
+
req.onLog?.(
|
|
462
|
+
`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.`
|
|
463
|
+
);
|
|
464
|
+
}
|
|
465
|
+
const region = req.location && req.location.length > 0 ? req.location : sandboxClass === "linux-vm" ? DAYTONA_VM_REGION : "";
|
|
466
|
+
const client = getClient(region);
|
|
400
467
|
let snapshotName = req.snapshot;
|
|
401
468
|
if (!snapshotName && req.image && req.image !== DEFAULT_BOX_IMAGE_REF) {
|
|
402
469
|
try {
|
|
403
|
-
const snap = await
|
|
470
|
+
const snap = await client.snapshot.get(req.image);
|
|
404
471
|
if (snap && snap.name) snapshotName = snap.name;
|
|
405
472
|
} catch {
|
|
406
473
|
}
|
|
@@ -408,7 +475,7 @@ var daytonaBackend = {
|
|
|
408
475
|
const snapshotParams = { ...baseParams };
|
|
409
476
|
delete snapshotParams.resources;
|
|
410
477
|
if (snapshotName && sizeResources) {
|
|
411
|
-
const bakedSize =
|
|
478
|
+
const bakedSize = prepared?.extras?.size;
|
|
412
479
|
const requestedKey = `${String(sizeResources.cpu)}-${String(sizeResources.memory)}-${String(sizeResources.disk)}`;
|
|
413
480
|
if (bakedSize !== requestedKey) {
|
|
414
481
|
req.onLog?.(
|
|
@@ -416,21 +483,31 @@ var daytonaBackend = {
|
|
|
416
483
|
);
|
|
417
484
|
}
|
|
418
485
|
}
|
|
419
|
-
|
|
486
|
+
if (!snapshotName && sandboxClass === "linux-vm") {
|
|
487
|
+
throw new Error(
|
|
488
|
+
`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.
|
|
489
|
+
Run \`agentbox prepare --provider daytona\` to bake one, or set \`agentbox config set box.daytonaClass container\` to use the container class.`
|
|
490
|
+
);
|
|
491
|
+
}
|
|
492
|
+
const sandbox = snapshotName ? await client.create({ snapshot: snapshotName, ...snapshotParams }, { timeout: 900 }) : await client.create(
|
|
420
493
|
{ image: resolveImage(req.image), ...baseParams },
|
|
421
494
|
{
|
|
422
495
|
timeout: 900,
|
|
423
496
|
...req.onLog ? { onSnapshotCreateLogs: req.onLog } : {}
|
|
424
497
|
}
|
|
425
498
|
);
|
|
426
|
-
|
|
499
|
+
const bootedClass = sandboxClass;
|
|
500
|
+
return {
|
|
501
|
+
sandboxId: sandbox.id,
|
|
502
|
+
...bootedClass ? { sandboxClass: bootedClass } : {}
|
|
503
|
+
};
|
|
427
504
|
},
|
|
428
505
|
{ retryOnAmbiguous: false, attemptTimeoutMs: 9e5 }
|
|
429
506
|
);
|
|
430
507
|
},
|
|
431
508
|
async ensureVolume(name) {
|
|
432
|
-
const
|
|
433
|
-
let vol = await retry("volume.get(create)", () =>
|
|
509
|
+
const client = getClient();
|
|
510
|
+
let vol = await retry("volume.get(create)", () => client.volume.get(name, true));
|
|
434
511
|
const deadline = Date.now() + 6e4;
|
|
435
512
|
while (vol.state !== "ready") {
|
|
436
513
|
if (vol.state === "error" || vol.state === "deleted" || vol.state === "deleting") {
|
|
@@ -444,7 +521,7 @@ var daytonaBackend = {
|
|
|
444
521
|
);
|
|
445
522
|
}
|
|
446
523
|
await new Promise((r) => setTimeout(r, 1e3));
|
|
447
|
-
vol = await retry("volume.get(poll)", () =>
|
|
524
|
+
vol = await retry("volume.get(poll)", () => client.volume.get(name));
|
|
448
525
|
}
|
|
449
526
|
return { volumeId: vol.id };
|
|
450
527
|
},
|
|
@@ -456,18 +533,18 @@ var daytonaBackend = {
|
|
|
456
533
|
},
|
|
457
534
|
async list() {
|
|
458
535
|
return retry("list", async () => {
|
|
459
|
-
const
|
|
460
|
-
const
|
|
461
|
-
const
|
|
462
|
-
return items.map((sb) => {
|
|
536
|
+
const client = getClient();
|
|
537
|
+
const items = [];
|
|
538
|
+
for await (const sb of client.list()) {
|
|
463
539
|
const summary = { sandboxId: sb.id };
|
|
464
540
|
const raw = sb;
|
|
465
541
|
const friendly = raw.labels?.["agentbox.name"] ?? raw.name;
|
|
466
542
|
if (friendly) summary.name = friendly;
|
|
467
543
|
if (raw.createdAt) summary.createdAt = raw.createdAt;
|
|
468
544
|
if (typeof raw.state === "string") summary.state = mapState(raw.state);
|
|
469
|
-
|
|
470
|
-
}
|
|
545
|
+
items.push(summary);
|
|
546
|
+
}
|
|
547
|
+
return items;
|
|
471
548
|
});
|
|
472
549
|
},
|
|
473
550
|
async start(h) {
|
|
@@ -495,9 +572,25 @@ var daytonaBackend = {
|
|
|
495
572
|
"pause",
|
|
496
573
|
async () => {
|
|
497
574
|
const sb = await getSandbox(h.sandboxId);
|
|
498
|
-
|
|
575
|
+
const freeze = async () => {
|
|
576
|
+
await sb.pause();
|
|
577
|
+
};
|
|
578
|
+
const archive = async () => {
|
|
579
|
+
await sb.stop();
|
|
580
|
+
await sb.archive();
|
|
581
|
+
};
|
|
582
|
+
const preferVm = h.sandboxClass !== "container";
|
|
583
|
+
try {
|
|
584
|
+
await (preferVm ? freeze() : archive());
|
|
585
|
+
} catch (err) {
|
|
586
|
+
try {
|
|
587
|
+
await (preferVm ? archive() : freeze());
|
|
588
|
+
} catch {
|
|
589
|
+
throw err;
|
|
590
|
+
}
|
|
591
|
+
}
|
|
499
592
|
},
|
|
500
|
-
{ attemptTimeoutMs:
|
|
593
|
+
{ attemptTimeoutMs: 12e4 }
|
|
501
594
|
);
|
|
502
595
|
},
|
|
503
596
|
async resume(h) {
|
|
@@ -510,6 +603,42 @@ var daytonaBackend = {
|
|
|
510
603
|
{ attemptTimeoutMs: 6e4 }
|
|
511
604
|
);
|
|
512
605
|
},
|
|
606
|
+
/**
|
|
607
|
+
* Daytona's `autoStopInterval` is an idle window that any request to the
|
|
608
|
+
* sandbox resets — including the host relay's own continuous preview-URL
|
|
609
|
+
* polling, which therefore holds every tracked box open forever. The host
|
|
610
|
+
* keepalive loop reads this and pauses an idle box itself instead of waiting
|
|
611
|
+
* for a lapse that never comes. See `CloudBackend.timeoutModel`.
|
|
612
|
+
*/
|
|
613
|
+
timeoutModel: "inactivity",
|
|
614
|
+
/**
|
|
615
|
+
* Daytona's SSH gateway gives a shell session a terminal but an exec session
|
|
616
|
+
* none — `ssh -tt <token>@ssh.app.daytona.io 'tty'` answers "not a tty" while
|
|
617
|
+
* the same connection with no command lands on /dev/pts/1. So interactive
|
|
618
|
+
* attach connects command-less and gets its command via stdin. See
|
|
619
|
+
* `CloudBackend.attachExecLacksTty`.
|
|
620
|
+
*/
|
|
621
|
+
attachExecLacksTty: true,
|
|
622
|
+
/**
|
|
623
|
+
* Hold off Daytona's auto-stop while the in-box agent is working.
|
|
624
|
+
*
|
|
625
|
+
* Daytona's timeout is an INACTIVITY window, not an absolute deadline like
|
|
626
|
+
* vercel's/e2b's, so there is nothing to extend to a target time — the box
|
|
627
|
+
* simply needs to look active. `refreshActivity()` resets that clock, which
|
|
628
|
+
* grants another full `autoStopInterval`. So both deadline args are unused:
|
|
629
|
+
* the host loop calls us precisely when it wants the box kept alive, and that
|
|
630
|
+
* call is the whole signal.
|
|
631
|
+
*/
|
|
632
|
+
async renewTimeout(h) {
|
|
633
|
+
await retry(
|
|
634
|
+
"renewTimeout",
|
|
635
|
+
async () => {
|
|
636
|
+
const sb = await getSandbox(h.sandboxId);
|
|
637
|
+
await sb.refreshActivity();
|
|
638
|
+
},
|
|
639
|
+
{ attemptTimeoutMs: 3e4 }
|
|
640
|
+
);
|
|
641
|
+
},
|
|
513
642
|
async destroy(h) {
|
|
514
643
|
return retry(
|
|
515
644
|
"destroy",
|
|
@@ -626,7 +755,13 @@ var daytonaBackend = {
|
|
|
626
755
|
"createSnapshot",
|
|
627
756
|
async () => {
|
|
628
757
|
const sb = await getSandbox(h.sandboxId);
|
|
629
|
-
await sb.
|
|
758
|
+
await sb.stop();
|
|
759
|
+
try {
|
|
760
|
+
await sb._experimental_createSnapshot(snapshotName, 900);
|
|
761
|
+
await waitForSnapshotActive(getClient(), snapshotName);
|
|
762
|
+
} finally {
|
|
763
|
+
await sb.start();
|
|
764
|
+
}
|
|
630
765
|
},
|
|
631
766
|
{ attemptTimeoutMs: 9e5, retryOnAmbiguous: false }
|
|
632
767
|
);
|
|
@@ -634,9 +769,9 @@ var daytonaBackend = {
|
|
|
634
769
|
async deleteSnapshot(snapshotName) {
|
|
635
770
|
return retry("deleteSnapshot", async () => {
|
|
636
771
|
try {
|
|
637
|
-
const
|
|
638
|
-
const snapshot = await
|
|
639
|
-
await
|
|
772
|
+
const client = getClient();
|
|
773
|
+
const snapshot = await client.snapshot.get(snapshotName);
|
|
774
|
+
await client.snapshot.delete(snapshot);
|
|
640
775
|
} catch (err) {
|
|
641
776
|
if (err instanceof DaytonaNotFoundError2) return;
|
|
642
777
|
const msg = err instanceof Error ? err.message : String(err);
|
|
@@ -733,9 +868,9 @@ async function validateCredentials(creds) {
|
|
|
733
868
|
const snapshot = snapshotManagedEnv();
|
|
734
869
|
applyToEnv(creds);
|
|
735
870
|
try {
|
|
736
|
-
const { Daytona: Daytona2 } = await import("@
|
|
737
|
-
const
|
|
738
|
-
await
|
|
871
|
+
const { Daytona: Daytona2 } = await import("@daytona/sdk");
|
|
872
|
+
const client = new Daytona2();
|
|
873
|
+
await client.list();
|
|
739
874
|
s.stop("Daytona credentials accepted");
|
|
740
875
|
return { ok: true };
|
|
741
876
|
} catch (err) {
|
|
@@ -836,12 +971,15 @@ export {
|
|
|
836
971
|
resolveDockerfileContext,
|
|
837
972
|
resolveDaytonaCustomClaudeMd,
|
|
838
973
|
ensureDaytonaEnvLoaded,
|
|
974
|
+
computeDockerBaseSha,
|
|
839
975
|
computeDaytonaContextFingerprint,
|
|
840
976
|
currentDaytonaBaseFingerprintLive,
|
|
841
977
|
readPreparedDaytonaState,
|
|
842
978
|
writePreparedDaytonaState,
|
|
843
979
|
preparedMatches,
|
|
980
|
+
waitForSnapshotActive,
|
|
844
981
|
DEFAULT_BOX_IMAGE_REF,
|
|
982
|
+
DAYTONA_DEFAULT_RESOURCES,
|
|
845
983
|
getClient,
|
|
846
984
|
parseDaytonaSize,
|
|
847
985
|
daytonaBackend,
|
|
@@ -851,4 +989,4 @@ export {
|
|
|
851
989
|
readDaytonaCredStatus,
|
|
852
990
|
maskKey
|
|
853
991
|
};
|
|
854
|
-
//# sourceMappingURL=chunk-
|
|
992
|
+
//# sourceMappingURL=chunk-67VF2QZC.js.map
|