@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
package/runtime/hetzner/ctl.cjs
CHANGED
|
@@ -3057,15 +3057,15 @@ var require_windows = __commonJS({
|
|
|
3057
3057
|
}
|
|
3058
3058
|
return false;
|
|
3059
3059
|
}
|
|
3060
|
-
function checkStat(
|
|
3061
|
-
if (!
|
|
3060
|
+
function checkStat(stat5, path6, options) {
|
|
3061
|
+
if (!stat5.isSymbolicLink() && !stat5.isFile()) {
|
|
3062
3062
|
return false;
|
|
3063
3063
|
}
|
|
3064
3064
|
return checkPathExt(path6, options);
|
|
3065
3065
|
}
|
|
3066
3066
|
function isexe(path6, options, cb) {
|
|
3067
|
-
fs.stat(path6, function(er,
|
|
3068
|
-
cb(er, er ? false : checkStat(
|
|
3067
|
+
fs.stat(path6, function(er, stat5) {
|
|
3068
|
+
cb(er, er ? false : checkStat(stat5, path6, options));
|
|
3069
3069
|
});
|
|
3070
3070
|
}
|
|
3071
3071
|
function sync(path6, options) {
|
|
@@ -3082,20 +3082,20 @@ var require_mode = __commonJS({
|
|
|
3082
3082
|
isexe.sync = sync;
|
|
3083
3083
|
var fs = require("fs");
|
|
3084
3084
|
function isexe(path6, options, cb) {
|
|
3085
|
-
fs.stat(path6, function(er,
|
|
3086
|
-
cb(er, er ? false : checkStat(
|
|
3085
|
+
fs.stat(path6, function(er, stat5) {
|
|
3086
|
+
cb(er, er ? false : checkStat(stat5, options));
|
|
3087
3087
|
});
|
|
3088
3088
|
}
|
|
3089
3089
|
function sync(path6, options) {
|
|
3090
3090
|
return checkStat(fs.statSync(path6), options);
|
|
3091
3091
|
}
|
|
3092
|
-
function checkStat(
|
|
3093
|
-
return
|
|
3092
|
+
function checkStat(stat5, options) {
|
|
3093
|
+
return stat5.isFile() && checkMode(stat5, options);
|
|
3094
3094
|
}
|
|
3095
|
-
function checkMode(
|
|
3096
|
-
var mod =
|
|
3097
|
-
var uid =
|
|
3098
|
-
var gid =
|
|
3095
|
+
function checkMode(stat5, options) {
|
|
3096
|
+
var mod = stat5.mode;
|
|
3097
|
+
var uid = stat5.uid;
|
|
3098
|
+
var gid = stat5.gid;
|
|
3099
3099
|
var myUid = options.uid !== void 0 ? options.uid : process.getuid && process.getuid();
|
|
3100
3100
|
var myGid = options.gid !== void 0 ? options.gid : process.getgid && process.getgid();
|
|
3101
3101
|
var u2 = parseInt("100", 8);
|
|
@@ -10868,13 +10868,13 @@ function isConnectionLevelError(err) {
|
|
|
10868
10868
|
const msg = err instanceof Error ? err.message : String(err);
|
|
10869
10869
|
return /\b(ECONNREFUSED|ENOTFOUND|EHOSTUNREACH|ECONNRESET|EPIPE)\b/.test(msg);
|
|
10870
10870
|
}
|
|
10871
|
-
var import_http, import_https,
|
|
10871
|
+
var import_http, import_https, import_promises19, BACKOFF_BASE_MS, BACKOFF_MAX_MS, REQUEST_TIMEOUT_MS, FAST_REQUEST_TIMEOUT_MS, FAST_MODE_DECAY_POLLS, STOPPED_TICK_MS, CONNECTION_LEVEL_CODES, CloudBoxPoller, CloudBoxPollers;
|
|
10872
10872
|
var init_chunk_YVJLTAM3 = __esm({
|
|
10873
10873
|
"../relay/dist/chunk-YVJLTAM3.js"() {
|
|
10874
10874
|
"use strict";
|
|
10875
10875
|
import_http = require("http");
|
|
10876
10876
|
import_https = require("https");
|
|
10877
|
-
|
|
10877
|
+
import_promises19 = require("timers/promises");
|
|
10878
10878
|
BACKOFF_BASE_MS = 1500;
|
|
10879
10879
|
BACKOFF_MAX_MS = 3e4;
|
|
10880
10880
|
REQUEST_TIMEOUT_MS = 25e3;
|
|
@@ -11028,12 +11028,12 @@ var init_chunk_YVJLTAM3 = __esm({
|
|
|
11028
11028
|
if (this.currentBackoffMs === 0 && this.fastModePolls > 0) {
|
|
11029
11029
|
this.fastModePolls -= 1;
|
|
11030
11030
|
}
|
|
11031
|
-
if (this.currentBackoffMs === 0) await (0,
|
|
11031
|
+
if (this.currentBackoffMs === 0) await (0, import_promises19.setTimeout)(STOPPED_TICK_MS);
|
|
11032
11032
|
}
|
|
11033
11033
|
}
|
|
11034
11034
|
async backoff() {
|
|
11035
11035
|
this.currentBackoffMs = this.currentBackoffMs === 0 ? BACKOFF_BASE_MS : Math.min(this.currentBackoffMs * 2, BACKOFF_MAX_MS);
|
|
11036
|
-
await (0,
|
|
11036
|
+
await (0, import_promises19.setTimeout)(this.currentBackoffMs);
|
|
11037
11037
|
}
|
|
11038
11038
|
async tryRecoverPreviewUrl() {
|
|
11039
11039
|
if (!this.deps.recoverPreviewUrl) return;
|
|
@@ -11196,6 +11196,7 @@ var CLAUDE_ACTIVITY_STATES = [
|
|
|
11196
11196
|
];
|
|
11197
11197
|
var BOX_STATUS_SCHEMA = 1;
|
|
11198
11198
|
var BOX_STATUS_EVENT = "box-status";
|
|
11199
|
+
var CREDENTIALS_UPDATED_EVENT = "credentials-updated";
|
|
11199
11200
|
var DEFAULT_SOCKET_PATH = "/run/agentbox/ctl.sock";
|
|
11200
11201
|
var DEFAULT_CONFIG_PATH = "/workspace/agentbox.yaml";
|
|
11201
11202
|
var DEFAULT_LOG_DIR = "/var/log/agentbox";
|
|
@@ -11327,6 +11328,10 @@ function spawnDetached(cmd, args, logFile) {
|
|
|
11327
11328
|
stdio: ["ignore", fd, fd],
|
|
11328
11329
|
env: process.env
|
|
11329
11330
|
});
|
|
11331
|
+
child.on("error", (err) => {
|
|
11332
|
+
process.stderr.write(`agentbox-ctl bootstrap: ${cmd} failed to spawn: ${err.message}
|
|
11333
|
+
`);
|
|
11334
|
+
});
|
|
11330
11335
|
child.unref();
|
|
11331
11336
|
}
|
|
11332
11337
|
async function hasSudo() {
|
|
@@ -11924,8 +11929,15 @@ async function pollParkedResult(raw202, prefix) {
|
|
|
11924
11929
|
return reply.result;
|
|
11925
11930
|
}
|
|
11926
11931
|
}
|
|
11927
|
-
return {
|
|
11928
|
-
|
|
11932
|
+
return {
|
|
11933
|
+
exitCode: 124,
|
|
11934
|
+
stdout: "",
|
|
11935
|
+
stderr: `${prefix}: timed out after 10m waiting for the host.
|
|
11936
|
+
This action runs on your PC (host relay): either your PC/relay isn't running, or a host
|
|
11937
|
+
approval prompt went unanswered. Operations like cp, download, and checkpoint need your PC
|
|
11938
|
+
on even for an independent (git.pushMode=direct) box \u2014 only git push/pull run in the box.
|
|
11939
|
+
`
|
|
11940
|
+
};
|
|
11929
11941
|
}
|
|
11930
11942
|
|
|
11931
11943
|
// src/commands/cp.ts
|
|
@@ -12859,7 +12871,7 @@ function sanitizeGitArgs(args) {
|
|
|
12859
12871
|
return Array.isArray(args) ? args.filter((a2) => typeof a2 === "string") : [];
|
|
12860
12872
|
}
|
|
12861
12873
|
|
|
12862
|
-
// ../relay/dist/chunk-
|
|
12874
|
+
// ../relay/dist/chunk-LH565Z3T.js
|
|
12863
12875
|
var import_child_process = require("child_process");
|
|
12864
12876
|
var import_http2 = require("http");
|
|
12865
12877
|
|
|
@@ -19638,10 +19650,10 @@ var {
|
|
|
19638
19650
|
getCancelSignal: getCancelSignal2
|
|
19639
19651
|
} = getIpcExport();
|
|
19640
19652
|
|
|
19641
|
-
// ../relay/dist/chunk-
|
|
19642
|
-
var
|
|
19653
|
+
// ../relay/dist/chunk-LH565Z3T.js
|
|
19654
|
+
var import_promises20 = require("fs/promises");
|
|
19643
19655
|
var import_os6 = require("os");
|
|
19644
|
-
var
|
|
19656
|
+
var import_path10 = require("path");
|
|
19645
19657
|
var import_url = require("url");
|
|
19646
19658
|
|
|
19647
19659
|
// ../sandbox-core/dist/index.js
|
|
@@ -19652,6 +19664,8 @@ var import_fs = require("fs");
|
|
|
19652
19664
|
var import_os4 = require("os");
|
|
19653
19665
|
var import_path5 = require("path");
|
|
19654
19666
|
var import_path6 = require("path");
|
|
19667
|
+
var import_promises16 = require("fs/promises");
|
|
19668
|
+
var import_path7 = require("path");
|
|
19655
19669
|
var STATE_DIR = (0, import_path4.join)((0, import_os3.homedir)(), ".agentbox");
|
|
19656
19670
|
var STATE_FILE = (0, import_path4.join)(STATE_DIR, "state.json");
|
|
19657
19671
|
var EMPTY = { version: 1, boxes: [] };
|
|
@@ -19816,6 +19830,17 @@ var AGENT_SYNC_SPECS = [
|
|
|
19816
19830
|
// separately; `state_*.sqlite*` is the resume-cwd index (rebuilt in-box);
|
|
19817
19831
|
// `packages`/`plugins/.plugin-appserver`/`computer-use` are heavy
|
|
19818
19832
|
// macOS-only artifacts; the rest is host-only session/log/cache state.
|
|
19833
|
+
//
|
|
19834
|
+
// `.tmp` carve-in: the git-marketplace snapshots (`.tmp/marketplaces/`,
|
|
19835
|
+
// ~13 MB) must reach the box or in-box `codex plugin` breaks
|
|
19836
|
+
// ("marketplace root does not contain a supported manifest" — and the
|
|
19837
|
+
// box can't re-clone, the git shim blocks `clone`). The includes are
|
|
19838
|
+
// emitted BEFORE the excludes (first-match-wins): the root `.tmp/` dir
|
|
19839
|
+
// and the marketplaces subtree transfer, `/.tmp/*` drops its other
|
|
19840
|
+
// children (the ~200 MB desktop-app `bundled-marketplaces` + `plugins`
|
|
19841
|
+
// payloads), and the unanchored `.tmp` still blocks nested `.tmp` dirs
|
|
19842
|
+
// elsewhere in the tree.
|
|
19843
|
+
include: ["/.tmp/", "/.tmp/marketplaces/***"],
|
|
19819
19844
|
exclude: [
|
|
19820
19845
|
"auth.json",
|
|
19821
19846
|
"sessions",
|
|
@@ -19829,6 +19854,7 @@ var AGENT_SYNC_SPECS = [
|
|
|
19829
19854
|
"cache",
|
|
19830
19855
|
"vendor_imports",
|
|
19831
19856
|
"tmp",
|
|
19857
|
+
"/.tmp/*",
|
|
19832
19858
|
".tmp",
|
|
19833
19859
|
".codex-global-state.json",
|
|
19834
19860
|
".codex-global-state.json.bak",
|
|
@@ -19927,6 +19953,78 @@ function resolveAgentSpec(name) {
|
|
|
19927
19953
|
}
|
|
19928
19954
|
var BOX_CLAUDE_PROJECT_DIR = "/home/vscode/.claude/projects/-workspace";
|
|
19929
19955
|
var CLAUDE_HOST_BACKUP = resolveAgentSpec("claude").credential.hostBackup;
|
|
19956
|
+
function isRealAgentCredential(agent, text) {
|
|
19957
|
+
let parsed;
|
|
19958
|
+
try {
|
|
19959
|
+
parsed = JSON.parse(text);
|
|
19960
|
+
} catch {
|
|
19961
|
+
return false;
|
|
19962
|
+
}
|
|
19963
|
+
if (typeof parsed !== "object" || parsed === null) return false;
|
|
19964
|
+
const spec = AGENT_SYNC_SPECS.find((s) => s.id === agent);
|
|
19965
|
+
if (spec?.credential.realShape === "claude-oauth") {
|
|
19966
|
+
const rt = parsed.claudeAiOauth?.refreshToken;
|
|
19967
|
+
return typeof rt === "string" && rt.length > 0;
|
|
19968
|
+
}
|
|
19969
|
+
return Object.keys(parsed).length > 0;
|
|
19970
|
+
}
|
|
19971
|
+
var MAX_CREDENTIAL_BYTES = 256 * 1024;
|
|
19972
|
+
function parseCredentialsUpdate(payload) {
|
|
19973
|
+
if (payload === null || typeof payload !== "object") return null;
|
|
19974
|
+
const obj = payload;
|
|
19975
|
+
const agent = obj["agent"];
|
|
19976
|
+
if (typeof agent !== "string" || !AGENT_SYNC_SPECS.some((s) => s.id === agent)) return null;
|
|
19977
|
+
const b64 = obj["contentBase64"];
|
|
19978
|
+
if (typeof b64 !== "string" || b64.length === 0 || b64.length > MAX_CREDENTIAL_BYTES) return null;
|
|
19979
|
+
let content;
|
|
19980
|
+
try {
|
|
19981
|
+
content = Buffer.from(b64, "base64").toString("utf8");
|
|
19982
|
+
} catch {
|
|
19983
|
+
return null;
|
|
19984
|
+
}
|
|
19985
|
+
if (!isRealAgentCredential(agent, content)) return null;
|
|
19986
|
+
return { agent, content };
|
|
19987
|
+
}
|
|
19988
|
+
function claudeExpiresAt(text) {
|
|
19989
|
+
try {
|
|
19990
|
+
const parsed = JSON.parse(text);
|
|
19991
|
+
const exp = parsed?.claudeAiOauth?.expiresAt;
|
|
19992
|
+
return typeof exp === "number" && Number.isFinite(exp) ? exp : null;
|
|
19993
|
+
} catch {
|
|
19994
|
+
return null;
|
|
19995
|
+
}
|
|
19996
|
+
}
|
|
19997
|
+
function shouldAcceptCredentialUpdate(agent, incoming, existing) {
|
|
19998
|
+
if (existing === null) return { accept: true, reason: "no existing backup" };
|
|
19999
|
+
if (existing === incoming) return { accept: false, reason: "unchanged" };
|
|
20000
|
+
if (resolveAgentSpec(agent).credential.realShape === "claude-oauth") {
|
|
20001
|
+
const incomingExp = claudeExpiresAt(incoming);
|
|
20002
|
+
const existingExp = claudeExpiresAt(existing);
|
|
20003
|
+
if (incomingExp === null) return { accept: false, reason: "incoming blob has no expiresAt" };
|
|
20004
|
+
if (existingExp !== null && incomingExp <= existingExp) {
|
|
20005
|
+
return { accept: false, reason: "not newer than backup" };
|
|
20006
|
+
}
|
|
20007
|
+
return { accept: true, reason: "newer expiresAt" };
|
|
20008
|
+
}
|
|
20009
|
+
return { accept: true, reason: "content changed" };
|
|
20010
|
+
}
|
|
20011
|
+
async function writeCredentialBackup(agent, content, opts = {}) {
|
|
20012
|
+
const path6 = opts.backupPath ?? resolveAgentSpec(agent).credential.hostBackup;
|
|
20013
|
+
await (0, import_promises16.mkdir)((0, import_path7.dirname)(path6), { recursive: true });
|
|
20014
|
+
const tmp = `${path6}.tmp-${String(process.pid)}`;
|
|
20015
|
+
await (0, import_promises16.writeFile)(tmp, content, { mode: 384 });
|
|
20016
|
+
await (0, import_promises16.rename)(tmp, path6);
|
|
20017
|
+
await (0, import_promises16.chmod)(path6, 384).catch(() => {
|
|
20018
|
+
});
|
|
20019
|
+
}
|
|
20020
|
+
async function readCredentialBackup(agent, opts = {}) {
|
|
20021
|
+
const path6 = opts.backupPath ?? resolveAgentSpec(agent).credential.hostBackup;
|
|
20022
|
+
try {
|
|
20023
|
+
return await (0, import_promises16.readFile)(path6, "utf8");
|
|
20024
|
+
} catch {
|
|
20025
|
+
return null;
|
|
20026
|
+
}
|
|
20027
|
+
}
|
|
19930
20028
|
var BOX_MEMORY_DIR = `${BOX_CLAUDE_PROJECT_DIR}/memory`;
|
|
19931
20029
|
var BOX_WORKSPACE2 = "/workspace";
|
|
19932
20030
|
var MINIMAL_TRUSTED_CODEX_CONFIG = `[projects."${BOX_WORKSPACE2}"]
|
|
@@ -19935,9 +20033,10 @@ trust_level = "trusted"
|
|
|
19935
20033
|
var CREDENTIALS_BACKUP_FILE = resolveAgentSpec("claude").credential.hostBackup;
|
|
19936
20034
|
var CLAUDE_STATIC_EXCLUDES = resolveAgentSpec("claude").staticPaths[0]?.exclude ?? [];
|
|
19937
20035
|
var CODEX_STATIC_EXCLUDES = resolveAgentSpec("codex").staticPaths[0]?.exclude ?? [];
|
|
20036
|
+
var CODEX_STATIC_INCLUDES = resolveAgentSpec("codex").staticPaths[0]?.include ?? [];
|
|
19938
20037
|
var OPENCODE_DATA_EXCLUDES = resolveAgentSpec("opencode").staticPaths[0]?.exclude ?? [];
|
|
19939
20038
|
|
|
19940
|
-
// ../relay/dist/chunk-
|
|
20039
|
+
// ../relay/dist/chunk-LH565Z3T.js
|
|
19941
20040
|
var import_child_process2 = require("child_process");
|
|
19942
20041
|
var import_crypto5 = require("crypto");
|
|
19943
20042
|
var import_child_process3 = require("child_process");
|
|
@@ -19945,12 +20044,12 @@ var import_child_process3 = require("child_process");
|
|
|
19945
20044
|
// ../config/dist/index.js
|
|
19946
20045
|
var import_yaml = __toESM(require_dist(), 1);
|
|
19947
20046
|
var import_crypto4 = require("crypto");
|
|
19948
|
-
var import_promises16 = require("fs/promises");
|
|
19949
|
-
var import_os5 = require("os");
|
|
19950
|
-
var import_path7 = require("path");
|
|
19951
20047
|
var import_promises17 = require("fs/promises");
|
|
19952
|
-
var
|
|
20048
|
+
var import_os5 = require("os");
|
|
19953
20049
|
var import_path8 = require("path");
|
|
20050
|
+
var import_promises18 = require("fs/promises");
|
|
20051
|
+
var import_yaml2 = __toESM(require_dist(), 1);
|
|
20052
|
+
var import_path9 = require("path");
|
|
19954
20053
|
var import_yaml3 = __toESM(require_dist(), 1);
|
|
19955
20054
|
var PROVIDERS = [
|
|
19956
20055
|
{
|
|
@@ -19970,7 +20069,7 @@ var PROVIDERS = [
|
|
|
19970
20069
|
loginHint: "approve a browser sign-in link",
|
|
19971
20070
|
rebuildMinutes: "7",
|
|
19972
20071
|
blurb: "Daytona Cloud sandboxes",
|
|
19973
|
-
sizeDesc: "Per-provider override of `box.size` for daytona. `cpu-memory-disk` GB spec (e.g. `4-8-20`). Only honored on the image/Dockerfile create path; Daytona rejects custom resources on snapshot-resume.",
|
|
20072
|
+
sizeDesc: "Per-provider override of `box.size` for daytona. `cpu-memory-disk` GB spec (e.g. `4-8-20`). Only honored on the image/Dockerfile create path; on the snapshot path the size is fixed at bake time (Daytona rejects custom resources on snapshot-resume).",
|
|
19974
20073
|
imageDesc: "Per-provider override of `box.image` for daytona (named snapshot, e.g. `agentbox-base-<fingerprint>`). Written by `agentbox prepare --provider daytona`."
|
|
19975
20074
|
},
|
|
19976
20075
|
{
|
|
@@ -19990,7 +20089,7 @@ var PROVIDERS = [
|
|
|
19990
20089
|
loginHint: "installs the Vercel sandbox CLI, then a browser sign-in",
|
|
19991
20090
|
rebuildMinutes: "5-10",
|
|
19992
20091
|
blurb: "Vercel Sandboxes",
|
|
19993
|
-
sizeDesc: "Per-provider override of `box.size` for vercel.
|
|
20092
|
+
sizeDesc: "Per-provider override of `box.size` for vercel. vCPU count \u2014 one of `1`, `2`, `4`, `8` (Vercel couples RAM at 2048 MB/vCPU). Default 2.",
|
|
19994
20093
|
imageDesc: "Per-provider override of `box.image` for vercel (snapshot id, e.g. `snap_\u2026`). Written by `agentbox prepare --provider vercel`."
|
|
19995
20094
|
},
|
|
19996
20095
|
{
|
|
@@ -20000,8 +20099,18 @@ var PROVIDERS = [
|
|
|
20000
20099
|
loginHint: "paste an API key from the E2B dashboard",
|
|
20001
20100
|
rebuildMinutes: "2",
|
|
20002
20101
|
blurb: "E2B microVMs",
|
|
20003
|
-
sizeDesc: "Per-provider override of `box.size` for e2b.
|
|
20102
|
+
sizeDesc: "Per-provider override of `box.size` for e2b. `cpu-memory` GB spec (e.g. `4-8`). Template-level: baked by `agentbox prepare --provider e2b --size <spec>`; E2B rejects per-create resources.",
|
|
20004
20103
|
imageDesc: "Per-provider override of `box.image` for e2b (template id or `name:tag`, e.g. `agentbox-base:latest`). Written by `agentbox prepare --provider e2b`."
|
|
20104
|
+
},
|
|
20105
|
+
{
|
|
20106
|
+
name: "digitalocean",
|
|
20107
|
+
kind: "cloud",
|
|
20108
|
+
label: "DigitalOcean (cloud VPS)",
|
|
20109
|
+
loginHint: "paste a Personal Access Token from the DigitalOcean Console",
|
|
20110
|
+
rebuildMinutes: "7-10",
|
|
20111
|
+
blurb: "DigitalOcean Droplets",
|
|
20112
|
+
sizeDesc: "Per-provider override of `box.size` for digitalocean. Droplet size slug (e.g. `s-2vcpu-4gb`, `s-4vcpu-8gb`).",
|
|
20113
|
+
imageDesc: "Per-provider override of `box.image` for digitalocean (numeric snapshot id). Written by `agentbox prepare --provider digitalocean`."
|
|
20005
20114
|
}
|
|
20006
20115
|
];
|
|
20007
20116
|
var PROVIDER_NAMES = PROVIDERS.map((p) => p.name);
|
|
@@ -20024,12 +20133,14 @@ var BUILT_IN_DEFAULTS = {
|
|
|
20024
20133
|
defaultCheckpointHetzner: "",
|
|
20025
20134
|
defaultCheckpointVercel: "",
|
|
20026
20135
|
defaultCheckpointE2b: "",
|
|
20136
|
+
defaultCheckpointDigitalocean: "",
|
|
20027
20137
|
size: "",
|
|
20028
20138
|
sizeDocker: "",
|
|
20029
20139
|
sizeDaytona: "",
|
|
20030
20140
|
sizeHetzner: "",
|
|
20031
20141
|
sizeVercel: "",
|
|
20032
20142
|
sizeE2b: "",
|
|
20143
|
+
sizeDigitalocean: "",
|
|
20033
20144
|
withPlaywright: false,
|
|
20034
20145
|
claudeInstall: "native",
|
|
20035
20146
|
withEnv: false,
|
|
@@ -20046,6 +20157,7 @@ var BUILT_IN_DEFAULTS = {
|
|
|
20046
20157
|
imageHetzner: "",
|
|
20047
20158
|
imageVercel: "",
|
|
20048
20159
|
imageE2b: "",
|
|
20160
|
+
imageDigitalocean: "",
|
|
20049
20161
|
// Mirrors BOX_IMAGE_REGISTRY in @agentbox/sandbox-docker. Empty disables the
|
|
20050
20162
|
// registry pull (always build the docker base image locally).
|
|
20051
20163
|
imageRegistry: "ghcr.io/madarco/agentbox/box",
|
|
@@ -20055,11 +20167,14 @@ var BUILT_IN_DEFAULTS = {
|
|
|
20055
20167
|
pidsLimit: 0,
|
|
20056
20168
|
disk: "",
|
|
20057
20169
|
bundleDepth: void 0,
|
|
20058
|
-
|
|
20170
|
+
hetznerLocation: "nbg1",
|
|
20171
|
+
digitaloceanRegion: "nyc3",
|
|
20059
20172
|
vercelTimeoutMs: 27e5,
|
|
20060
20173
|
vercelNetworkPolicy: "",
|
|
20061
20174
|
e2bTimeoutMs: 27e5,
|
|
20062
|
-
cpMaxBytes: 100 * 1024 * 1024
|
|
20175
|
+
cpMaxBytes: 100 * 1024 * 1024,
|
|
20176
|
+
credentialSync: true,
|
|
20177
|
+
inbound: "locked"
|
|
20063
20178
|
},
|
|
20064
20179
|
checkpoint: {
|
|
20065
20180
|
maxLayers: 3
|
|
@@ -20190,7 +20305,7 @@ var KEY_REGISTRY = [
|
|
|
20190
20305
|
{
|
|
20191
20306
|
key: "box.size",
|
|
20192
20307
|
type: "string",
|
|
20193
|
-
description: "Default VM size for cloud providers. Provider-interpreted: hetzner = server type (e.g. `cx33`); daytona = `cpu-memory-disk` GB (e.g. `4-8-20`). Used as fallback when no per-provider override is set. Docker
|
|
20308
|
+
description: "Default VM size for cloud providers. Provider-interpreted: hetzner = server type (e.g. `cx33`); daytona = `cpu-memory-disk` GB (e.g. `4-8-20`); vercel = vCPU count (1, 2, 4, 8); e2b = `cpu-memory` GB (e.g. `4-8`). Used as fallback when no per-provider override is set. Docker ignores it."
|
|
20194
20309
|
},
|
|
20195
20310
|
...perProviderSizeKeys(),
|
|
20196
20311
|
{
|
|
@@ -20295,9 +20410,14 @@ var KEY_REGISTRY = [
|
|
|
20295
20410
|
description: "Cap git bundle history shipped to cloud sandboxes (daytona, hetzner). 0 = full history. Unset = adaptive default (last 200 commits; re-bundle at 100 if the bundle exceeds 20 MB). Ignored for docker (which bind-mounts .git/)."
|
|
20296
20411
|
},
|
|
20297
20412
|
{
|
|
20298
|
-
key: "box.
|
|
20299
|
-
type: "
|
|
20300
|
-
description: "
|
|
20413
|
+
key: "box.hetznerLocation",
|
|
20414
|
+
type: "string",
|
|
20415
|
+
description: "Hetzner datacenter location new --provider hetzner boxes are created in (e.g. `nbg1`, `fsn1`, `hel1`, `ash`). Default `nbg1`. Overridable per-create with `--location`. Hetzner-only; ignored by other providers."
|
|
20416
|
+
},
|
|
20417
|
+
{
|
|
20418
|
+
key: "box.digitaloceanRegion",
|
|
20419
|
+
type: "string",
|
|
20420
|
+
description: "DigitalOcean region new --provider digitalocean boxes are created in (e.g. `nyc3`, `nyc1`, `sfo3`, `ams3`, `fra1`). Default `nyc3`. Overridable per-create with `--location`. DigitalOcean-only; ignored by other providers."
|
|
20301
20421
|
},
|
|
20302
20422
|
{
|
|
20303
20423
|
key: "box.vercelTimeoutMs",
|
|
@@ -20315,6 +20435,16 @@ var KEY_REGISTRY = [
|
|
|
20315
20435
|
description: "Max bytes a single host\u2192box copy may transfer after excludes, shared by `agentbox cp` (blocked with a size breakdown unless --yes) and each `carry:` entry (rejected at resolve time). Default 104857600 (100 MiB).",
|
|
20316
20436
|
advanced: true
|
|
20317
20437
|
},
|
|
20438
|
+
{
|
|
20439
|
+
key: "box.credentialSync",
|
|
20440
|
+
type: "bool",
|
|
20441
|
+
description: "Automatically sync refreshed agent credentials (claude/codex/opencode) from boxes to the host backup and out to all other running boxes. Claude OAuth refresh rotates the refresh token, so without this every other copy 401s after any box refreshes. Default true; --no-credential-sync at create disables the in-box watcher for that box."
|
|
20442
|
+
},
|
|
20443
|
+
{
|
|
20444
|
+
key: "box.inbound",
|
|
20445
|
+
type: "string",
|
|
20446
|
+
description: "Inbound-access policy for VPS boxes (hetzner, digitalocean per-box firewall). `locked` (default) = SSH reachable only from your host's egress IP; `open` = SSH reachable from anywhere (0.0.0.0/0, key-only \u2014 to drive a box from a phone with the laptop off); a CIDR list (e.g. `203.0.113.5/32`) = host egress plus those. Override per box with `--inbound` or after create with `agentbox inbound <box>`. Ignored by non-VPS providers."
|
|
20447
|
+
},
|
|
20318
20448
|
{
|
|
20319
20449
|
key: "box.vercelNetworkPolicy",
|
|
20320
20450
|
type: "string",
|
|
@@ -20428,8 +20558,8 @@ var KEY_REGISTRY = [
|
|
|
20428
20558
|
{
|
|
20429
20559
|
key: "git.pushMode",
|
|
20430
20560
|
type: "enum",
|
|
20431
|
-
enumValues: ["auto", "relay", "lease"],
|
|
20432
|
-
description: "How a box's `git push` reaches GitHub: `relay` (the host relay pushes with your host credentials \u2014 they never enter the box), `lease` (the relay/plane leases a short-lived GitHub-App token and the box pushes directly, so it works with the laptop off), or `auto` (default \u2014 lease when `relay.controlPlaneUrl` is set for the box, else relay). Only affects cloud boxes; docker boxes always use `relay`. Forcing `relay` needs a reachable host relay for the box; forcing `lease` needs a reachable relay/plane with a GitHub App."
|
|
20561
|
+
enumValues: ["auto", "relay", "lease", "direct"],
|
|
20562
|
+
description: "How a box's `git push` reaches GitHub: `relay` (the host relay pushes with your host credentials \u2014 they never enter the box), `lease` (the relay/plane leases a short-lived GitHub-App token and the box pushes directly, so it works with the laptop off), `direct` (the box holds a COPY of your git credentials and pushes/pulls/signs entirely on its own \u2014 needs no host or hub, but the credentials live inside the box and its snapshots; set via `--with-credentials`, which copies them in behind a confirmation), or `auto` (default \u2014 lease when `relay.controlPlaneUrl` is set for the box, else relay). Only affects cloud boxes; docker boxes always use `relay`. Forcing `relay` needs a reachable host relay for the box; forcing `lease` needs a reachable relay/plane with a GitHub App; `direct` needs credentials to have been copied into the box at create time."
|
|
20433
20563
|
},
|
|
20434
20564
|
{
|
|
20435
20565
|
key: "vnc.containerPort",
|
|
@@ -20663,34 +20793,34 @@ function branchHasLeafBelow(branchSpec, prefix) {
|
|
|
20663
20793
|
}
|
|
20664
20794
|
return false;
|
|
20665
20795
|
}
|
|
20666
|
-
var STATE_DIR2 = (0,
|
|
20667
|
-
var GLOBAL_CONFIG_FILE = (0,
|
|
20668
|
-
var PROJECTS_DIR = (0,
|
|
20796
|
+
var STATE_DIR2 = (0, import_path8.join)((0, import_os5.homedir)(), ".agentbox");
|
|
20797
|
+
var GLOBAL_CONFIG_FILE = (0, import_path8.join)(STATE_DIR2, "config.yaml");
|
|
20798
|
+
var PROJECTS_DIR = (0, import_path8.join)(STATE_DIR2, "projects");
|
|
20669
20799
|
var WORKSPACE_CONFIG_BASENAME = "agentbox.yaml";
|
|
20670
20800
|
async function findProjectRoot(cwd) {
|
|
20671
20801
|
const start2 = await canonicalize(cwd);
|
|
20672
20802
|
let dir = start2;
|
|
20673
20803
|
for (let i2 = 0; i2 < 64; i2++) {
|
|
20674
|
-
if (await fileExists((0,
|
|
20804
|
+
if (await fileExists((0, import_path8.join)(dir, WORKSPACE_CONFIG_BASENAME))) {
|
|
20675
20805
|
return { root: dir, hasAgentboxYaml: true };
|
|
20676
20806
|
}
|
|
20677
|
-
const parent = (0,
|
|
20807
|
+
const parent = (0, import_path8.dirname)(dir);
|
|
20678
20808
|
if (parent === dir) break;
|
|
20679
20809
|
dir = parent;
|
|
20680
20810
|
}
|
|
20681
20811
|
return { root: start2, hasAgentboxYaml: false };
|
|
20682
20812
|
}
|
|
20683
20813
|
async function canonicalize(p) {
|
|
20684
|
-
const abs = (0,
|
|
20814
|
+
const abs = (0, import_path8.resolve)(p);
|
|
20685
20815
|
try {
|
|
20686
|
-
return await (0,
|
|
20816
|
+
return await (0, import_promises17.realpath)(abs);
|
|
20687
20817
|
} catch {
|
|
20688
20818
|
return abs;
|
|
20689
20819
|
}
|
|
20690
20820
|
}
|
|
20691
20821
|
async function fileExists(p) {
|
|
20692
20822
|
try {
|
|
20693
|
-
const st = await (0,
|
|
20823
|
+
const st = await (0, import_promises17.stat)(p);
|
|
20694
20824
|
return st.isFile();
|
|
20695
20825
|
} catch {
|
|
20696
20826
|
return false;
|
|
@@ -20704,21 +20834,21 @@ function sanitizeMnemonic2(raw) {
|
|
|
20704
20834
|
return raw.toLowerCase().replace(/-/g, "_").replace(/[^a-z0-9_]+/g, "_").replace(/_+/g, "_").replace(/^_+|_+$/g, "").slice(0, 32) || "unnamed";
|
|
20705
20835
|
}
|
|
20706
20836
|
function projectDirSegment(absPath) {
|
|
20707
|
-
return `${hashProjectPath(absPath)}-${sanitizeMnemonic2((0,
|
|
20837
|
+
return `${hashProjectPath(absPath)}-${sanitizeMnemonic2((0, import_path8.basename)(absPath))}`;
|
|
20708
20838
|
}
|
|
20709
20839
|
function projectConfigDir(absPath) {
|
|
20710
|
-
return (0,
|
|
20840
|
+
return (0, import_path8.join)(PROJECTS_DIR, projectDirSegment(absPath));
|
|
20711
20841
|
}
|
|
20712
20842
|
function projectConfigFile(absPath) {
|
|
20713
|
-
return (0,
|
|
20843
|
+
return (0, import_path8.join)(projectConfigDir(absPath), "config.yaml");
|
|
20714
20844
|
}
|
|
20715
20845
|
function workspaceConfigFile(workspacePath) {
|
|
20716
|
-
return (0,
|
|
20846
|
+
return (0, import_path8.join)(workspacePath, WORKSPACE_CONFIG_BASENAME);
|
|
20717
20847
|
}
|
|
20718
20848
|
async function loadOptionalUserConfig(path6) {
|
|
20719
20849
|
let text;
|
|
20720
20850
|
try {
|
|
20721
|
-
text = await (0,
|
|
20851
|
+
text = await (0, import_promises18.readFile)(path6, "utf8");
|
|
20722
20852
|
} catch (err) {
|
|
20723
20853
|
if (err.code === "ENOENT") return {};
|
|
20724
20854
|
throw err;
|
|
@@ -20729,7 +20859,7 @@ async function loadProjectAgentboxDefaults(workspacePath) {
|
|
|
20729
20859
|
const path6 = workspaceConfigFile(workspacePath);
|
|
20730
20860
|
let text;
|
|
20731
20861
|
try {
|
|
20732
|
-
text = await (0,
|
|
20862
|
+
text = await (0, import_promises18.readFile)(path6, "utf8");
|
|
20733
20863
|
} catch (err) {
|
|
20734
20864
|
if (err.code === "ENOENT") return {};
|
|
20735
20865
|
throw err;
|
|
@@ -20830,7 +20960,7 @@ function writeLeaf(obj, branch, leaf, value) {
|
|
|
20830
20960
|
}
|
|
20831
20961
|
cur[segs[segs.length - 1]] = value;
|
|
20832
20962
|
}
|
|
20833
|
-
var PROJECT_GC_COUNTER_FILE = (0,
|
|
20963
|
+
var PROJECT_GC_COUNTER_FILE = (0, import_path9.join)(PROJECTS_DIR, ".gc.json");
|
|
20834
20964
|
|
|
20835
20965
|
// ../integrations/dist/index.js
|
|
20836
20966
|
var linearConnector = {
|
|
@@ -21108,10 +21238,10 @@ function getConnector(service) {
|
|
|
21108
21238
|
return null;
|
|
21109
21239
|
}
|
|
21110
21240
|
|
|
21111
|
-
// ../relay/dist/chunk-
|
|
21241
|
+
// ../relay/dist/chunk-LH565Z3T.js
|
|
21112
21242
|
var import_crypto6 = require("crypto");
|
|
21113
21243
|
var import_crypto7 = require("crypto");
|
|
21114
|
-
var
|
|
21244
|
+
var import_path11 = require("path");
|
|
21115
21245
|
var GH_PR_OPS = [
|
|
21116
21246
|
"create",
|
|
21117
21247
|
"view",
|
|
@@ -21667,6 +21797,10 @@ async function resolveCloudBackend(name) {
|
|
|
21667
21797
|
const pkg = "@agentbox/sandbox-e2b";
|
|
21668
21798
|
return loadCloudBackend(pkg, async () => (await import(pkg)).e2bBackend);
|
|
21669
21799
|
}
|
|
21800
|
+
if (name === "digitalocean") {
|
|
21801
|
+
const pkg = "@agentbox/sandbox-digitalocean";
|
|
21802
|
+
return loadCloudBackend(pkg, async () => (await import(pkg)).digitaloceanBackend);
|
|
21803
|
+
}
|
|
21670
21804
|
const plugin = pluginForProvider(name);
|
|
21671
21805
|
if (plugin) {
|
|
21672
21806
|
if (!isSupportedApiVersion(plugin.apiVersion)) {
|
|
@@ -22302,8 +22436,8 @@ async function runGitRpc(action, deps) {
|
|
|
22302
22436
|
}
|
|
22303
22437
|
if (params.hostOnly) {
|
|
22304
22438
|
const dest = resolveLandDest(branch, params.as);
|
|
22305
|
-
const stageSave = await (0,
|
|
22306
|
-
const hostBundleSave = (0,
|
|
22439
|
+
const stageSave = await (0, import_promises20.mkdtemp)((0, import_path10.join)((0, import_os6.tmpdir)(), "agentbox-git-save-"));
|
|
22440
|
+
const hostBundleSave = (0, import_path10.join)(stageSave, "op.bundle");
|
|
22307
22441
|
const remoteBundleSave = "/tmp/agentbox-rpc-save.bundle";
|
|
22308
22442
|
try {
|
|
22309
22443
|
const make = await backend.exec(
|
|
@@ -22334,7 +22468,7 @@ ${landed.stdout ?? ""}`,
|
|
|
22334
22468
|
stderr: landed.stderr ?? ""
|
|
22335
22469
|
};
|
|
22336
22470
|
} finally {
|
|
22337
|
-
await (0,
|
|
22471
|
+
await (0, import_promises20.rm)(stageSave, { recursive: true, force: true });
|
|
22338
22472
|
await backend.exec(handle, `rm -f ${shellQuote(remoteBundleSave)}`).catch(() => {
|
|
22339
22473
|
});
|
|
22340
22474
|
}
|
|
@@ -22413,8 +22547,8 @@ ${landed.stdout ?? ""}`,
|
|
|
22413
22547
|
}
|
|
22414
22548
|
}
|
|
22415
22549
|
}
|
|
22416
|
-
const stage = await (0,
|
|
22417
|
-
const hostBundle = (0,
|
|
22550
|
+
const stage = await (0, import_promises20.mkdtemp)((0, import_path10.join)((0, import_os6.tmpdir)(), "agentbox-git-rpc-"));
|
|
22551
|
+
const hostBundle = (0, import_path10.join)(stage, "op.bundle");
|
|
22418
22552
|
const remoteBundle = "/tmp/agentbox-rpc.bundle";
|
|
22419
22553
|
try {
|
|
22420
22554
|
if (action.method === "git.push") {
|
|
@@ -22515,7 +22649,7 @@ relay: post-push in-box origin/upstream sync threw: ${err instanceof Error ? err
|
|
|
22515
22649
|
stderr: sandboxFetch.stderr
|
|
22516
22650
|
};
|
|
22517
22651
|
} finally {
|
|
22518
|
-
await (0,
|
|
22652
|
+
await (0, import_promises20.rm)(stage, { recursive: true, force: true });
|
|
22519
22653
|
await backend.exec(handle, `rm -f ${shellQuote(remoteBundle)}`).catch(() => {
|
|
22520
22654
|
});
|
|
22521
22655
|
}
|
|
@@ -22681,6 +22815,82 @@ var BoxNotices = class {
|
|
|
22681
22815
|
return this.entries.size;
|
|
22682
22816
|
}
|
|
22683
22817
|
};
|
|
22818
|
+
var CREDENTIALS_UPDATED_EVENT2 = "credentials-updated";
|
|
22819
|
+
var CredentialsFanout = class {
|
|
22820
|
+
log;
|
|
22821
|
+
debounceMs;
|
|
22822
|
+
runPropagate;
|
|
22823
|
+
backupPathFor;
|
|
22824
|
+
pending = /* @__PURE__ */ new Map();
|
|
22825
|
+
chains = /* @__PURE__ */ new Map();
|
|
22826
|
+
constructor(deps) {
|
|
22827
|
+
this.log = deps.log;
|
|
22828
|
+
this.debounceMs = deps.debounceMs ?? 3e3;
|
|
22829
|
+
this.runPropagate = deps.runPropagate ?? defaultRunPropagate;
|
|
22830
|
+
this.backupPathFor = deps.backupPathFor;
|
|
22831
|
+
}
|
|
22832
|
+
/**
|
|
22833
|
+
* Validate, newest-wins-gate, persist the host backup, and schedule the
|
|
22834
|
+
* fan-out. Fast (no box I/O); the propagate CLI does the slow work detached.
|
|
22835
|
+
*/
|
|
22836
|
+
async handle(sourceBoxId, payload) {
|
|
22837
|
+
const update = parseCredentialsUpdate(payload);
|
|
22838
|
+
if (!update) return { accepted: false, reason: "invalid payload" };
|
|
22839
|
+
const backupPath = this.backupPathFor?.(update.agent);
|
|
22840
|
+
const existing = await readCredentialBackup(update.agent, { backupPath });
|
|
22841
|
+
const verdict = shouldAcceptCredentialUpdate(update.agent, update.content, existing);
|
|
22842
|
+
if (!verdict.accept) {
|
|
22843
|
+
return { accepted: false, reason: verdict.reason };
|
|
22844
|
+
}
|
|
22845
|
+
await writeCredentialBackup(update.agent, update.content, { backupPath });
|
|
22846
|
+
this.log(
|
|
22847
|
+
`credentials: accepted ${update.agent} update from box ${sourceBoxId} (${verdict.reason}); fan-out in ${String(this.debounceMs)}ms`
|
|
22848
|
+
);
|
|
22849
|
+
this.schedule(update.agent, sourceBoxId);
|
|
22850
|
+
return { accepted: true, reason: verdict.reason };
|
|
22851
|
+
}
|
|
22852
|
+
schedule(agent, sourceBoxId) {
|
|
22853
|
+
const existing = this.pending.get(agent);
|
|
22854
|
+
if (existing) clearTimeout(existing);
|
|
22855
|
+
const timer = setTimeout(() => {
|
|
22856
|
+
this.pending.delete(agent);
|
|
22857
|
+
const prev = this.chains.get(agent) ?? Promise.resolve();
|
|
22858
|
+
const next = prev.then(() => this.runPropagate(agent, sourceBoxId)).catch((err) => {
|
|
22859
|
+
this.log(
|
|
22860
|
+
`credentials: ${agent} fan-out failed: ${err instanceof Error ? err.message : String(err)}`
|
|
22861
|
+
);
|
|
22862
|
+
});
|
|
22863
|
+
this.chains.set(agent, next);
|
|
22864
|
+
}, this.debounceMs);
|
|
22865
|
+
timer.unref();
|
|
22866
|
+
this.pending.set(agent, timer);
|
|
22867
|
+
}
|
|
22868
|
+
/** Pending debounce timers + in-flight chain, for tests/shutdown. */
|
|
22869
|
+
async flush() {
|
|
22870
|
+
for (const [agent, timer] of this.pending) {
|
|
22871
|
+
clearTimeout(timer);
|
|
22872
|
+
this.pending.delete(agent);
|
|
22873
|
+
void agent;
|
|
22874
|
+
}
|
|
22875
|
+
await Promise.all([...this.chains.values()]);
|
|
22876
|
+
}
|
|
22877
|
+
};
|
|
22878
|
+
async function defaultRunPropagate(agent, sourceBoxId) {
|
|
22879
|
+
const entry = process.env["AGENTBOX_CLI_ENTRY"];
|
|
22880
|
+
if (!entry) {
|
|
22881
|
+
throw new Error("AGENTBOX_CLI_ENTRY not set; cannot run credential propagate host-side");
|
|
22882
|
+
}
|
|
22883
|
+
const result = await execa(
|
|
22884
|
+
process.execPath,
|
|
22885
|
+
[entry, "credentials", "propagate", "--agent", agent, "--source-box", sourceBoxId],
|
|
22886
|
+
{ reject: false, timeout: 3e5 }
|
|
22887
|
+
);
|
|
22888
|
+
if (result.exitCode !== 0) {
|
|
22889
|
+
throw new Error(
|
|
22890
|
+
`credentials propagate exited ${String(result.exitCode)}: ${String(result.stderr).slice(-300)}`
|
|
22891
|
+
);
|
|
22892
|
+
}
|
|
22893
|
+
}
|
|
22684
22894
|
var BOX_STATUS_EVENT2 = "box-status";
|
|
22685
22895
|
var MAX_BODY_BYTES = 1024 * 1024;
|
|
22686
22896
|
var GIT_RPC_TIMEOUT_MS = 12e4;
|
|
@@ -22774,6 +22984,7 @@ function createRelayServer(opts) {
|
|
|
22774
22984
|
const host = opts.host ?? "0.0.0.0";
|
|
22775
22985
|
const mode = opts.mode ?? "host";
|
|
22776
22986
|
const hostActions = mode === "box" ? new HostActionQueue() : null;
|
|
22987
|
+
const credentialsFanout = mode === "box" ? null : new CredentialsFanout({ log });
|
|
22777
22988
|
if (mode === "box" && (!opts.bridgeToken || opts.bridgeToken.length === 0)) {
|
|
22778
22989
|
throw new Error("relay mode='box' requires a non-empty bridgeToken");
|
|
22779
22990
|
}
|
|
@@ -22899,6 +23110,14 @@ function createRelayServer(opts) {
|
|
|
22899
23110
|
send(res, 202, { ok: true });
|
|
22900
23111
|
return;
|
|
22901
23112
|
}
|
|
23113
|
+
if (body.type === CREDENTIALS_UPDATED_EVENT2 && credentialsFanout) {
|
|
23114
|
+
const verdict = await credentialsFanout.handle(reg.boxId, body.payload);
|
|
23115
|
+
log(
|
|
23116
|
+
`credentials-updated box=${reg.boxId} accepted=${String(verdict.accepted)} (${verdict.reason})`
|
|
23117
|
+
);
|
|
23118
|
+
send(res, 202, { ok: true, accepted: verdict.accepted });
|
|
23119
|
+
return;
|
|
23120
|
+
}
|
|
22902
23121
|
const ev = await store.appendEvent({
|
|
22903
23122
|
boxId: reg.boxId,
|
|
22904
23123
|
type: body.type,
|
|
@@ -23333,6 +23552,13 @@ function createRelayServer(opts) {
|
|
|
23333
23552
|
previewToken: reg.previewToken,
|
|
23334
23553
|
onEvents: async (evs) => {
|
|
23335
23554
|
for (const ev of evs) {
|
|
23555
|
+
if (ev.type === CREDENTIALS_UPDATED_EVENT2 && credentialsFanout) {
|
|
23556
|
+
const verdict = await credentialsFanout.handle(reg.boxId, ev.payload);
|
|
23557
|
+
log(
|
|
23558
|
+
`credentials-updated box=${reg.boxId} accepted=${String(verdict.accepted)} (${verdict.reason})`
|
|
23559
|
+
);
|
|
23560
|
+
continue;
|
|
23561
|
+
}
|
|
23336
23562
|
await store.appendEvent({
|
|
23337
23563
|
boxId: reg.boxId,
|
|
23338
23564
|
type: ev.type,
|
|
@@ -24044,21 +24270,21 @@ async function startRelayServer(opts) {
|
|
|
24044
24270
|
});
|
|
24045
24271
|
return handle;
|
|
24046
24272
|
}
|
|
24047
|
-
var QUEUE_DIR = (0,
|
|
24273
|
+
var QUEUE_DIR = (0, import_path11.join)(STATE_DIR, "queue");
|
|
24048
24274
|
var TERMINAL_RETENTION_MS = 60 * 60 * 1e3;
|
|
24049
24275
|
var SWEEP_INTERVAL_MS = 60 * 1e3;
|
|
24050
|
-
var QUEUE_LOGS_DIR = (0,
|
|
24276
|
+
var QUEUE_LOGS_DIR = (0, import_path11.join)(STATE_DIR, "logs");
|
|
24051
24277
|
var FAILURE_BACKOFF_MS = 5 * 6e4;
|
|
24052
24278
|
|
|
24053
24279
|
// ../relay/dist/index.js
|
|
24054
24280
|
init_chunk_YVJLTAM3();
|
|
24055
24281
|
|
|
24056
24282
|
// src/config.ts
|
|
24057
|
-
var
|
|
24283
|
+
var import_promises22 = require("fs/promises");
|
|
24058
24284
|
var import_yaml5 = __toESM(require_dist(), 1);
|
|
24059
24285
|
|
|
24060
24286
|
// src/replace.ts
|
|
24061
|
-
var
|
|
24287
|
+
var import_promises21 = require("fs/promises");
|
|
24062
24288
|
var import_yaml4 = __toESM(require_dist(), 1);
|
|
24063
24289
|
function isPlainObject4(v) {
|
|
24064
24290
|
return typeof v === "object" && v !== null && !Array.isArray(v);
|
|
@@ -24077,7 +24303,7 @@ function parseReplacementsSection(text) {
|
|
|
24077
24303
|
async function loadReplacementsSection(path6) {
|
|
24078
24304
|
let text;
|
|
24079
24305
|
try {
|
|
24080
|
-
text = await (0,
|
|
24306
|
+
text = await (0, import_promises21.readFile)(path6, "utf8");
|
|
24081
24307
|
} catch (err) {
|
|
24082
24308
|
if (err.code === "ENOENT") return {};
|
|
24083
24309
|
throw err;
|
|
@@ -24643,7 +24869,7 @@ function parseConfig(text) {
|
|
|
24643
24869
|
async function loadConfig(path6) {
|
|
24644
24870
|
let text;
|
|
24645
24871
|
try {
|
|
24646
|
-
text = await (0,
|
|
24872
|
+
text = await (0, import_promises22.readFile)(path6, "utf8");
|
|
24647
24873
|
} catch (err) {
|
|
24648
24874
|
if (err.code === "ENOENT") {
|
|
24649
24875
|
return { services: [], tasks: [], replacements: {} };
|
|
@@ -24820,20 +25046,20 @@ var import_node_child_process10 = require("child_process");
|
|
|
24820
25046
|
var import_node_crypto = require("crypto");
|
|
24821
25047
|
var import_node_events15 = require("events");
|
|
24822
25048
|
var import_node_fs10 = require("fs");
|
|
24823
|
-
var
|
|
25049
|
+
var import_promises25 = require("fs/promises");
|
|
24824
25050
|
var import_node_path9 = require("path");
|
|
24825
25051
|
|
|
24826
25052
|
// src/state-dir.ts
|
|
24827
|
-
var
|
|
25053
|
+
var import_promises23 = require("fs/promises");
|
|
24828
25054
|
var import_node_path8 = require("path");
|
|
24829
25055
|
async function resolveWritableStateDir(want = DEFAULT_STATE_DIR, logDir = DEFAULT_LOG_DIR, ensureSubdir = "tasks", onNotice) {
|
|
24830
25056
|
try {
|
|
24831
|
-
await (0,
|
|
25057
|
+
await (0, import_promises23.mkdir)((0, import_node_path8.join)(want, ensureSubdir), { recursive: true });
|
|
24832
25058
|
return want;
|
|
24833
25059
|
} catch {
|
|
24834
25060
|
const fallback = (0, import_node_path8.join)(logDir, "state");
|
|
24835
25061
|
try {
|
|
24836
|
-
await (0,
|
|
25062
|
+
await (0, import_promises23.mkdir)((0, import_node_path8.join)(fallback, ensureSubdir), { recursive: true });
|
|
24837
25063
|
onNotice?.(`${want} not writable, using ${fallback}`);
|
|
24838
25064
|
return fallback;
|
|
24839
25065
|
} catch {
|
|
@@ -25007,7 +25233,7 @@ var RelayClient = class {
|
|
|
25007
25233
|
};
|
|
25008
25234
|
|
|
25009
25235
|
// src/web-proxy.ts
|
|
25010
|
-
var
|
|
25236
|
+
var import_promises24 = require("fs/promises");
|
|
25011
25237
|
var import_node_net4 = require("net");
|
|
25012
25238
|
var DEFAULT_LISTEN_PORT = 80;
|
|
25013
25239
|
var DEFAULT_LOG = "/var/log/agentbox/web-proxy.log";
|
|
@@ -25067,7 +25293,7 @@ var WebProxy = class {
|
|
|
25067
25293
|
}
|
|
25068
25294
|
async log(msg) {
|
|
25069
25295
|
try {
|
|
25070
|
-
await (0,
|
|
25296
|
+
await (0, import_promises24.appendFile)(this.logPath, `[${(/* @__PURE__ */ new Date()).toISOString()}] ${msg}
|
|
25071
25297
|
`);
|
|
25072
25298
|
} catch {
|
|
25073
25299
|
}
|
|
@@ -25471,7 +25697,7 @@ var TaskRunner = class extends import_node_events15.EventEmitter {
|
|
|
25471
25697
|
return await this.runCheck(ro.command, cwd) ? "check passed" : null;
|
|
25472
25698
|
}
|
|
25473
25699
|
try {
|
|
25474
|
-
const have = (await (0,
|
|
25700
|
+
const have = (await (0, import_promises25.readFile)(this.markerPath(), "utf8")).trim();
|
|
25475
25701
|
if (have === this.commandHash(cwd)) return "marker matches";
|
|
25476
25702
|
} catch {
|
|
25477
25703
|
}
|
|
@@ -25480,8 +25706,8 @@ var TaskRunner = class extends import_node_events15.EventEmitter {
|
|
|
25480
25706
|
async writeMarker(cwd) {
|
|
25481
25707
|
const marker = this.markerPath();
|
|
25482
25708
|
try {
|
|
25483
|
-
await (0,
|
|
25484
|
-
await (0,
|
|
25709
|
+
await (0, import_promises25.mkdir)((0, import_node_path9.join)(this.opts.stateDir, "tasks"), { recursive: true });
|
|
25710
|
+
await (0, import_promises25.writeFile)(marker, `${this.commandHash(cwd)}
|
|
25485
25711
|
`, "utf8");
|
|
25486
25712
|
} catch (err) {
|
|
25487
25713
|
this.appendEvent(
|
|
@@ -25657,7 +25883,7 @@ var Supervisor = class extends import_node_events15.EventEmitter {
|
|
|
25657
25883
|
this.webProxy.reconfigure(first ? first.port : null);
|
|
25658
25884
|
}
|
|
25659
25885
|
async init(cfg) {
|
|
25660
|
-
await (0,
|
|
25886
|
+
await (0, import_promises25.mkdir)(this.opts.logDir, { recursive: true });
|
|
25661
25887
|
this.resolvedStateDir = await this.ensureStateDir();
|
|
25662
25888
|
for (const t of cfg.tasks) this.addTaskUnit(t);
|
|
25663
25889
|
for (const s of cfg.services) this.addServiceUnit(s);
|
|
@@ -26011,7 +26237,7 @@ async function readLogFile(logDir, service, tail) {
|
|
|
26011
26237
|
const path6 = (0, import_node_path9.join)(logDir, `${service}.log`);
|
|
26012
26238
|
let text;
|
|
26013
26239
|
try {
|
|
26014
|
-
text = await (0,
|
|
26240
|
+
text = await (0, import_promises25.readFile)(path6, "utf8");
|
|
26015
26241
|
} catch (err) {
|
|
26016
26242
|
if (err.code === "ENOENT") return [];
|
|
26017
26243
|
throw err;
|
|
@@ -26029,7 +26255,7 @@ async function readLogFile(logDir, service, tail) {
|
|
|
26029
26255
|
|
|
26030
26256
|
// src/socket.ts
|
|
26031
26257
|
var import_node_net5 = require("net");
|
|
26032
|
-
var
|
|
26258
|
+
var import_promises26 = require("fs/promises");
|
|
26033
26259
|
var import_node_path10 = require("path");
|
|
26034
26260
|
|
|
26035
26261
|
// src/status-reporter.ts
|
|
@@ -26305,8 +26531,8 @@ async function discoverListeningPorts() {
|
|
|
26305
26531
|
|
|
26306
26532
|
// src/socket.ts
|
|
26307
26533
|
async function startServer(opts) {
|
|
26308
|
-
await (0,
|
|
26309
|
-
await (0,
|
|
26534
|
+
await (0, import_promises26.mkdir)((0, import_node_path10.dirname)(opts.socketPath), { recursive: true });
|
|
26535
|
+
await (0, import_promises26.unlink)(opts.socketPath).catch(() => {
|
|
26310
26536
|
});
|
|
26311
26537
|
const server = (0, import_node_net5.createServer)((sock) => {
|
|
26312
26538
|
handleConnection(sock, opts).catch((err) => {
|
|
@@ -26322,7 +26548,7 @@ async function startServer(opts) {
|
|
|
26322
26548
|
resolve4();
|
|
26323
26549
|
});
|
|
26324
26550
|
});
|
|
26325
|
-
await (0,
|
|
26551
|
+
await (0, import_promises26.chmod)(opts.socketPath, 432).catch(() => {
|
|
26326
26552
|
});
|
|
26327
26553
|
return server;
|
|
26328
26554
|
}
|
|
@@ -26515,6 +26741,85 @@ async function* createLineReader(sock) {
|
|
|
26515
26741
|
if (buf.length > 0) yield buf;
|
|
26516
26742
|
}
|
|
26517
26743
|
|
|
26744
|
+
// src/credentials-watcher.ts
|
|
26745
|
+
var import_node_crypto2 = require("crypto");
|
|
26746
|
+
var import_promises27 = require("fs/promises");
|
|
26747
|
+
var WATCHED_CREDENTIALS = [
|
|
26748
|
+
{
|
|
26749
|
+
agent: "claude",
|
|
26750
|
+
path: "/home/vscode/.claude/.credentials.json",
|
|
26751
|
+
shape: "claude-oauth"
|
|
26752
|
+
},
|
|
26753
|
+
{ agent: "codex", path: "/home/vscode/.codex/auth.json", shape: "nonempty-json" },
|
|
26754
|
+
{
|
|
26755
|
+
agent: "opencode",
|
|
26756
|
+
path: "/home/vscode/.local/share/opencode/auth.json",
|
|
26757
|
+
shape: "nonempty-json"
|
|
26758
|
+
}
|
|
26759
|
+
];
|
|
26760
|
+
function isRealCredentialText(shape, text) {
|
|
26761
|
+
let parsed;
|
|
26762
|
+
try {
|
|
26763
|
+
parsed = JSON.parse(text);
|
|
26764
|
+
} catch {
|
|
26765
|
+
return false;
|
|
26766
|
+
}
|
|
26767
|
+
if (parsed === null || typeof parsed !== "object") return false;
|
|
26768
|
+
const obj = parsed;
|
|
26769
|
+
if (shape === "nonempty-json") return Object.keys(obj).length > 0;
|
|
26770
|
+
const oauth = obj["claudeAiOauth"];
|
|
26771
|
+
if (oauth === null || typeof oauth !== "object") return false;
|
|
26772
|
+
const refresh = oauth["refreshToken"];
|
|
26773
|
+
return typeof refresh === "string" && refresh.length > 0;
|
|
26774
|
+
}
|
|
26775
|
+
var CredentialsWatcher = class {
|
|
26776
|
+
relay;
|
|
26777
|
+
intervalMs;
|
|
26778
|
+
files;
|
|
26779
|
+
lastMtime = /* @__PURE__ */ new Map();
|
|
26780
|
+
lastPosted = /* @__PURE__ */ new Map();
|
|
26781
|
+
timer = null;
|
|
26782
|
+
constructor(opts) {
|
|
26783
|
+
this.relay = opts.relay;
|
|
26784
|
+
this.intervalMs = opts.intervalMs ?? 15e3;
|
|
26785
|
+
this.files = opts.files ?? WATCHED_CREDENTIALS;
|
|
26786
|
+
}
|
|
26787
|
+
start() {
|
|
26788
|
+
this.timer = setInterval(() => void this.scan(), this.intervalMs);
|
|
26789
|
+
this.timer.unref();
|
|
26790
|
+
void this.scan();
|
|
26791
|
+
}
|
|
26792
|
+
stop() {
|
|
26793
|
+
if (this.timer) {
|
|
26794
|
+
clearInterval(this.timer);
|
|
26795
|
+
this.timer = null;
|
|
26796
|
+
}
|
|
26797
|
+
}
|
|
26798
|
+
/** One poll pass; exposed for tests. Never throws. */
|
|
26799
|
+
async scan() {
|
|
26800
|
+
if (!this.relay.enabled) return;
|
|
26801
|
+
for (const file of this.files) {
|
|
26802
|
+
try {
|
|
26803
|
+
const st = await (0, import_promises27.stat)(file.path);
|
|
26804
|
+
if (this.lastMtime.get(file.agent) === st.mtimeMs) continue;
|
|
26805
|
+
this.lastMtime.set(file.agent, st.mtimeMs);
|
|
26806
|
+
const text = await (0, import_promises27.readFile)(file.path, "utf8");
|
|
26807
|
+
if (!isRealCredentialText(file.shape, text)) continue;
|
|
26808
|
+
const hash = (0, import_node_crypto2.createHash)("sha256").update(text).digest("hex");
|
|
26809
|
+
if (this.lastPosted.get(file.agent) === hash) continue;
|
|
26810
|
+
this.lastPosted.set(file.agent, hash);
|
|
26811
|
+
this.relay.post(CREDENTIALS_UPDATED_EVENT, {
|
|
26812
|
+
schema: 1,
|
|
26813
|
+
agent: file.agent,
|
|
26814
|
+
contentBase64: Buffer.from(text, "utf8").toString("base64"),
|
|
26815
|
+
capturedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
26816
|
+
});
|
|
26817
|
+
} catch {
|
|
26818
|
+
}
|
|
26819
|
+
}
|
|
26820
|
+
}
|
|
26821
|
+
};
|
|
26822
|
+
|
|
26518
26823
|
// src/box-relay-forwarder.ts
|
|
26519
26824
|
var import_node_http3 = require("http");
|
|
26520
26825
|
var import_node_https3 = require("https");
|
|
@@ -26614,6 +26919,11 @@ var daemonCommand = new Command("daemon").description("Run the agentbox-ctl supe
|
|
|
26614
26919
|
sessionName: DEFAULT_CLAUDE_SESSION_NAME
|
|
26615
26920
|
});
|
|
26616
26921
|
reporter.start();
|
|
26922
|
+
let credentialsWatcher = null;
|
|
26923
|
+
if (process.env.AGENTBOX_CREDENTIAL_SYNC !== "0") {
|
|
26924
|
+
credentialsWatcher = new CredentialsWatcher({ relay: sup.relayClient });
|
|
26925
|
+
credentialsWatcher.start();
|
|
26926
|
+
}
|
|
26617
26927
|
let codexScraper = null;
|
|
26618
26928
|
try {
|
|
26619
26929
|
codexScraper = startCodexScraper({ reporter });
|
|
@@ -26724,6 +27034,7 @@ var daemonCommand = new Command("daemon").description("Run the agentbox-ctl supe
|
|
|
26724
27034
|
`);
|
|
26725
27035
|
if (codexScraper) codexScraper.stop();
|
|
26726
27036
|
if (claudeScraper) claudeScraper.stop();
|
|
27037
|
+
if (credentialsWatcher) credentialsWatcher.stop();
|
|
26727
27038
|
reporter.stop();
|
|
26728
27039
|
reporter.flush();
|
|
26729
27040
|
server.close();
|
|
@@ -26918,6 +27229,50 @@ function runLocalGit(args, cwd) {
|
|
|
26918
27229
|
});
|
|
26919
27230
|
});
|
|
26920
27231
|
}
|
|
27232
|
+
function isDirectMode() {
|
|
27233
|
+
return process.env.AGENTBOX_GIT_DIRECT === "1";
|
|
27234
|
+
}
|
|
27235
|
+
function runRealGit(args, cwd) {
|
|
27236
|
+
const bin = process.env.AGENTBOX_REAL_GIT_PATH ?? "/usr/bin/git";
|
|
27237
|
+
return new Promise((resolve4) => {
|
|
27238
|
+
const child = (0, import_node_child_process13.spawn)(bin, args, { cwd, stdio: "inherit" });
|
|
27239
|
+
child.on("close", (code) => resolve4(code ?? 1));
|
|
27240
|
+
child.on("error", (err) => {
|
|
27241
|
+
process.stderr.write(`agentbox-ctl git: ${String(err.message ?? err)}
|
|
27242
|
+
`);
|
|
27243
|
+
resolve4(126);
|
|
27244
|
+
});
|
|
27245
|
+
});
|
|
27246
|
+
}
|
|
27247
|
+
async function runDirectNetworkOp(op, opts, extra) {
|
|
27248
|
+
const cwd = opts.cwd ?? process.cwd();
|
|
27249
|
+
const remote = resolveRemote(opts.remote);
|
|
27250
|
+
const branch = await captureGit(["rev-parse", "--abbrev-ref", "HEAD"], cwd);
|
|
27251
|
+
if (!branch) {
|
|
27252
|
+
process.stderr.write("agentbox-ctl git: could not resolve current branch\n");
|
|
27253
|
+
return 1;
|
|
27254
|
+
}
|
|
27255
|
+
return runRealGit([op, remote, branch, ...extra], cwd);
|
|
27256
|
+
}
|
|
27257
|
+
function partitionPullArgs(args) {
|
|
27258
|
+
const fetchArgs = [];
|
|
27259
|
+
const mergeArgs = [];
|
|
27260
|
+
for (const arg of args) {
|
|
27261
|
+
switch (arg) {
|
|
27262
|
+
case "--ff-only":
|
|
27263
|
+
mergeArgs.push(arg);
|
|
27264
|
+
break;
|
|
27265
|
+
case "--quiet":
|
|
27266
|
+
case "-q":
|
|
27267
|
+
fetchArgs.push(arg);
|
|
27268
|
+
mergeArgs.push(arg);
|
|
27269
|
+
break;
|
|
27270
|
+
default:
|
|
27271
|
+
fetchArgs.push(arg);
|
|
27272
|
+
}
|
|
27273
|
+
}
|
|
27274
|
+
return { fetchArgs, mergeArgs };
|
|
27275
|
+
}
|
|
26921
27276
|
function captureGit(args, cwd) {
|
|
26922
27277
|
return new Promise((resolve4) => {
|
|
26923
27278
|
const child = (0, import_node_child_process13.spawn)("git", args, { cwd, stdio: ["ignore", "pipe", "ignore"] });
|
|
@@ -26982,6 +27337,15 @@ var gitCommand = new Command("git").description("Git operations that need host c
|
|
|
26982
27337
|
process.stderr.write("agentbox-ctl git push: --host-only does not use a remote; drop --remote\n");
|
|
26983
27338
|
process.exit(64);
|
|
26984
27339
|
}
|
|
27340
|
+
if (isDirectMode()) {
|
|
27341
|
+
if (opts.hostOnly) {
|
|
27342
|
+
process.stderr.write(
|
|
27343
|
+
"agentbox-ctl git push: --host-only is not available with git.pushMode=direct (there is no host repo; this box pushes to the remote itself)\n"
|
|
27344
|
+
);
|
|
27345
|
+
process.exit(64);
|
|
27346
|
+
}
|
|
27347
|
+
process.exit(await runDirectNetworkOp("push", opts, args));
|
|
27348
|
+
}
|
|
26985
27349
|
const code = process.env.AGENTBOX_GIT_LEASE === "1" ? await leaseAndPush(opts, args) : await postRpcAndExit("git.push", buildParams(opts, args), {
|
|
26986
27350
|
errorPrefix: "agentbox-ctl git"
|
|
26987
27351
|
});
|
|
@@ -26992,6 +27356,9 @@ var gitCommand = new Command("git").description("Git operations that need host c
|
|
|
26992
27356
|
"[args...]",
|
|
26993
27357
|
"extra flags appended to the host-built `git fetch <remote> <branch>` (e.g. `--prune`, `--tags`). Do NOT re-pass the remote or branch; they come from --remote and the registered worktree (same gotcha as `push`)."
|
|
26994
27358
|
).action(async (args, opts) => {
|
|
27359
|
+
if (isDirectMode()) {
|
|
27360
|
+
process.exit(await runDirectNetworkOp("fetch", opts, args));
|
|
27361
|
+
}
|
|
26995
27362
|
const code = await postRpcAndExit("git.fetch", buildParams(opts, args), {
|
|
26996
27363
|
errorPrefix: "agentbox-ctl git"
|
|
26997
27364
|
});
|
|
@@ -27002,10 +27369,11 @@ var gitCommand = new Command("git").description("Git operations that need host c
|
|
|
27002
27369
|
"Fetch via the relay (host creds), then merge into the in-container working tree locally"
|
|
27003
27370
|
).option("--remote <name>", "remote name (default: origin)").option("--cwd <path>", "container path identifying which registered worktree to use").option("--ff-only", "pass --ff-only to the local merge").addOption(hostInitiatedOption()).allowExcessArguments(true).allowUnknownOption(true).argument(
|
|
27004
27371
|
"[args...]",
|
|
27005
|
-
"extra flags
|
|
27372
|
+
"extra flags, split between the host-built `git fetch <remote> <branch>` (e.g. `--prune`) and the local merge (`--ff-only`; `--quiet` goes to both). Do NOT re-pass the remote or branch; they come from --remote and the registered worktree (same gotcha as `push`)."
|
|
27006
27373
|
).action(
|
|
27007
27374
|
async (args, opts) => {
|
|
27008
|
-
const
|
|
27375
|
+
const { fetchArgs, mergeArgs: passthroughMergeArgs } = partitionPullArgs(args);
|
|
27376
|
+
const fetchCode = isDirectMode() ? await runDirectNetworkOp("fetch", opts, fetchArgs) : await postRpcAndExit("git.fetch", buildParams(opts, fetchArgs), {
|
|
27009
27377
|
errorPrefix: "agentbox-ctl git"
|
|
27010
27378
|
});
|
|
27011
27379
|
if (fetchCode !== 0) process.exit(fetchCode);
|
|
@@ -27021,7 +27389,10 @@ var gitCommand = new Command("git").description("Git operations that need host c
|
|
|
27021
27389
|
);
|
|
27022
27390
|
}
|
|
27023
27391
|
mergeArgs.push("merge");
|
|
27024
|
-
if (opts.ffOnly
|
|
27392
|
+
if (opts.ffOnly && !passthroughMergeArgs.includes("--ff-only")) {
|
|
27393
|
+
mergeArgs.push("--ff-only");
|
|
27394
|
+
}
|
|
27395
|
+
mergeArgs.push(...passthroughMergeArgs);
|
|
27025
27396
|
mergeArgs.push(`${remote}/HEAD`);
|
|
27026
27397
|
const mergeCode = await runLocalGit(mergeArgs, cwd);
|
|
27027
27398
|
process.exit(mergeCode);
|
|
@@ -27149,16 +27520,16 @@ var openCommand = new Command("open").description("Open a URL in the box's brows
|
|
|
27149
27520
|
});
|
|
27150
27521
|
|
|
27151
27522
|
// src/commands/render.ts
|
|
27152
|
-
var
|
|
27523
|
+
var import_promises29 = require("fs/promises");
|
|
27153
27524
|
|
|
27154
27525
|
// src/secret.ts
|
|
27155
|
-
var
|
|
27156
|
-
var
|
|
27526
|
+
var import_node_crypto3 = require("crypto");
|
|
27527
|
+
var import_promises28 = require("fs/promises");
|
|
27157
27528
|
var import_node_path11 = require("path");
|
|
27158
27529
|
var SECRET_RE = /\{\{\s*AGENTBOX_AUTO_SECRET(?::([A-Za-z0-9_-]+))?\s*\}\}/g;
|
|
27159
27530
|
var SECRET_BYTES = 32;
|
|
27160
27531
|
function generateSecret() {
|
|
27161
|
-
return (0,
|
|
27532
|
+
return (0, import_node_crypto3.randomBytes)(SECRET_BYTES).toString("base64url");
|
|
27162
27533
|
}
|
|
27163
27534
|
async function resolveAutoSecrets(content, opts = {}) {
|
|
27164
27535
|
if (!content.includes("AGENTBOX_AUTO_SECRET")) return content;
|
|
@@ -27184,13 +27555,13 @@ async function resolveAutoSecrets(content, opts = {}) {
|
|
|
27184
27555
|
async function loadOrCreateSecret(dir, name, onLog) {
|
|
27185
27556
|
const file = (0, import_node_path11.join)(dir, name);
|
|
27186
27557
|
try {
|
|
27187
|
-
const existing = (await (0,
|
|
27558
|
+
const existing = (await (0, import_promises28.readFile)(file, "utf8")).trim();
|
|
27188
27559
|
if (existing.length > 0) return existing;
|
|
27189
27560
|
} catch {
|
|
27190
27561
|
}
|
|
27191
27562
|
const secret = generateSecret();
|
|
27192
|
-
await (0,
|
|
27193
|
-
await (0,
|
|
27563
|
+
await (0, import_promises28.mkdir)(dir, { recursive: true });
|
|
27564
|
+
await (0, import_promises28.writeFile)(file, `${secret}
|
|
27194
27565
|
`, { mode: 384 });
|
|
27195
27566
|
onLog?.(`generated persisted secret "${name}"`);
|
|
27196
27567
|
return secret;
|
|
@@ -27204,7 +27575,7 @@ function collect(value, prev) {
|
|
|
27204
27575
|
var renderCommand = new Command("render").description(
|
|
27205
27576
|
"Render a file by substituting {{AGENTBOX_*}} placeholders and/or applying replacement rules (a declarative alternative to sed)."
|
|
27206
27577
|
).argument("<src>", "file to read").option("--out <path>", "write the result here (default: stdout)").option("--in-place", "overwrite <src> with the result").option("--env", "substitute {{AGENTBOX_*}} whitelist placeholders").option("--rule <from=>to>", "literal replacement (repeatable)", collect, []).option("--rule-regex <pat=>repl>", "regex replacement (repeatable)", collect, []).option("--rules <names>", "comma-separated replacements: rule-set names to apply").option("--config <path>", "agentbox.yaml to read replacements: from", DEFAULT_CONFIG_PATH).option("--state-dir <path>", "where named {{AGENTBOX_AUTO_SECRET:x}} secrets persist", DEFAULT_STATE_DIR).action(async (src, opts) => {
|
|
27207
|
-
const content = await (0,
|
|
27578
|
+
const content = await (0, import_promises29.readFile)(src, "utf8");
|
|
27208
27579
|
const rules = [];
|
|
27209
27580
|
if (opts.rules) {
|
|
27210
27581
|
const refs = opts.rules.split(",").map((s) => s.trim()).filter((s) => s.length > 0);
|
|
@@ -27228,9 +27599,9 @@ var renderCommand = new Command("render").description(
|
|
|
27228
27599
|
`)
|
|
27229
27600
|
});
|
|
27230
27601
|
if (opts.inPlace) {
|
|
27231
|
-
await (0,
|
|
27602
|
+
await (0, import_promises29.writeFile)(src, result, "utf8");
|
|
27232
27603
|
} else if (opts.out) {
|
|
27233
|
-
await (0,
|
|
27604
|
+
await (0, import_promises29.writeFile)(opts.out, result, "utf8");
|
|
27234
27605
|
} else {
|
|
27235
27606
|
process.stdout.write(result);
|
|
27236
27607
|
}
|
|
@@ -27330,10 +27701,10 @@ var logsCommand = new Command("logs").description("Print recent log lines for a
|
|
|
27330
27701
|
});
|
|
27331
27702
|
|
|
27332
27703
|
// src/commands/validate.ts
|
|
27333
|
-
var
|
|
27704
|
+
var import_promises30 = require("fs/promises");
|
|
27334
27705
|
var validateCommand = new Command("validate").description("Check agentbox.yaml for syntax and shape errors, without starting the daemon").argument("[path]", "path to agentbox.yaml", DEFAULT_CONFIG_PATH).action(async (path6) => {
|
|
27335
27706
|
try {
|
|
27336
|
-
await (0,
|
|
27707
|
+
await (0, import_promises30.stat)(path6);
|
|
27337
27708
|
} catch {
|
|
27338
27709
|
process.stderr.write(`agentbox-ctl: ${path6} not found
|
|
27339
27710
|
`);
|