@madarco/agentbox 0.17.1 → 0.19.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +78 -0
- package/README.md +4 -3
- package/dist/{_cloud-attach-RUD4W33P.js → _cloud-attach-YM2KOWHO.js} +4 -4
- package/dist/{chunk-6QFPYU4Z.js → chunk-7K2A3NLE.js} +8 -5
- package/dist/chunk-7K2A3NLE.js.map +1 -0
- package/dist/{chunk-HFQZJO73.js → chunk-A5OFRJDI.js} +1322 -216
- package/dist/chunk-A5OFRJDI.js.map +1 -0
- package/dist/{chunk-YUGLNTT2.js → chunk-JK5V4OLT.js} +349 -16
- package/dist/chunk-JK5V4OLT.js.map +1 -0
- package/dist/{chunk-IA6YHH52.js → chunk-MODNW54N.js} +6 -3
- package/dist/{chunk-IA6YHH52.js.map → chunk-MODNW54N.js.map} +1 -1
- package/dist/{chunk-46NXCJ6Z.js → chunk-NXX3KQZ6.js} +2 -2
- package/dist/{chunk-3JXSW6PN.js → chunk-P6UT5XGE.js} +2 -2
- package/dist/{chunk-KTDJ5JTE.js → chunk-SPUUOEW2.js} +273 -54
- package/dist/chunk-SPUUOEW2.js.map +1 -0
- package/dist/{chunk-XWBFWUY2.js → chunk-Y6PUCLOE.js} +2 -2
- package/dist/{dist-VAATGBAR.js → dist-EKSNZHDY.js} +13 -3
- package/dist/{dist-TEKY3GFT.js → dist-FTCDWRAL.js} +18 -7
- package/dist/dist-FTCDWRAL.js.map +1 -0
- package/dist/{dist-CNABE32V.js → dist-PRDYMXCX.js} +10 -5
- package/dist/dist-PRDYMXCX.js.map +1 -0
- package/dist/{dist-BO2R55FX.js → dist-U2BHTWG4.js} +17 -5
- package/dist/dist-U2BHTWG4.js.map +1 -0
- package/dist/{dist-CROGTJ7N.js → dist-VQSZVBT3.js} +20 -6
- package/dist/dist-VQSZVBT3.js.map +1 -0
- package/dist/index.js +1009 -449
- package/dist/index.js.map +1 -1
- package/dist/{prepared-state-MQHD3M5F-OVABNV66.js → prepared-state-MQHD3M5F-5ZMCNY43.js} +2 -2
- package/package.json +3 -3
- package/runtime/docker/apps/cli/share/agentbox-setup/SKILL.md +1 -1
- package/runtime/docker/packages/ctl/dist/bin.cjs +142 -110
- package/runtime/docker/packages/sandbox-docker/scripts/agentbox-dockerd-start +13 -0
- package/runtime/e2b/agentbox-setup-skill.md +1 -1
- package/runtime/e2b/ctl.cjs +142 -110
- package/runtime/hetzner/agentbox-dockerd-start +13 -0
- package/runtime/hetzner/agentbox-setup-skill.md +1 -1
- package/runtime/hetzner/ctl.cjs +142 -110
- package/runtime/relay/bin.cjs +270 -66
- package/runtime/vercel/agentbox-dockerd-start +145 -0
- package/runtime/vercel/agentbox-setup-skill.md +1 -1
- package/runtime/vercel/ctl.cjs +142 -110
- package/runtime/vercel/custom-system-CLAUDE.md +5 -4
- package/runtime/vercel/scripts/provision.sh +20 -5
- package/share/agentbox-setup/SKILL.md +1 -1
- package/share/host-skills/agentbox/SKILL.md +2 -2
- package/share/host-skills/codex/agentbox.md +10 -2
- package/dist/chunk-6QFPYU4Z.js.map +0 -1
- package/dist/chunk-HFQZJO73.js.map +0 -1
- package/dist/chunk-KTDJ5JTE.js.map +0 -1
- package/dist/chunk-YUGLNTT2.js.map +0 -1
- package/dist/dist-BO2R55FX.js.map +0 -1
- package/dist/dist-CNABE32V.js.map +0 -1
- package/dist/dist-CROGTJ7N.js.map +0 -1
- package/dist/dist-TEKY3GFT.js.map +0 -1
- /package/dist/{_cloud-attach-RUD4W33P.js.map → _cloud-attach-YM2KOWHO.js.map} +0 -0
- /package/dist/{chunk-46NXCJ6Z.js.map → chunk-NXX3KQZ6.js.map} +0 -0
- /package/dist/{chunk-3JXSW6PN.js.map → chunk-P6UT5XGE.js.map} +0 -0
- /package/dist/{chunk-XWBFWUY2.js.map → chunk-Y6PUCLOE.js.map} +0 -0
- /package/dist/{dist-VAATGBAR.js.map → dist-EKSNZHDY.js.map} +0 -0
- /package/dist/{prepared-state-MQHD3M5F-OVABNV66.js.map → prepared-state-MQHD3M5F-5ZMCNY43.js.map} +0 -0
package/runtime/relay/bin.cjs
CHANGED
|
@@ -3130,12 +3130,12 @@ var require_isexe = __commonJS({
|
|
|
3130
3130
|
if (typeof Promise !== "function") {
|
|
3131
3131
|
throw new TypeError("callback not provided");
|
|
3132
3132
|
}
|
|
3133
|
-
return new Promise(function(
|
|
3133
|
+
return new Promise(function(resolve3, reject) {
|
|
3134
3134
|
isexe(path6, options || {}, function(er, is) {
|
|
3135
3135
|
if (er) {
|
|
3136
3136
|
reject(er);
|
|
3137
3137
|
} else {
|
|
3138
|
-
|
|
3138
|
+
resolve3(is);
|
|
3139
3139
|
}
|
|
3140
3140
|
});
|
|
3141
3141
|
});
|
|
@@ -3202,27 +3202,27 @@ var require_which = __commonJS({
|
|
|
3202
3202
|
opt = {};
|
|
3203
3203
|
const { pathEnv, pathExt, pathExtExe } = getPathInfo(cmd, opt);
|
|
3204
3204
|
const found = [];
|
|
3205
|
-
const step = (i2) => new Promise((
|
|
3205
|
+
const step = (i2) => new Promise((resolve3, reject) => {
|
|
3206
3206
|
if (i2 === pathEnv.length)
|
|
3207
|
-
return opt.all && found.length ?
|
|
3207
|
+
return opt.all && found.length ? resolve3(found) : reject(getNotFoundError(cmd));
|
|
3208
3208
|
const ppRaw = pathEnv[i2];
|
|
3209
3209
|
const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw;
|
|
3210
3210
|
const pCmd = path6.join(pathPart, cmd);
|
|
3211
3211
|
const p = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd : pCmd;
|
|
3212
|
-
|
|
3212
|
+
resolve3(subStep(p, i2, 0));
|
|
3213
3213
|
});
|
|
3214
|
-
const subStep = (p, i2, ii) => new Promise((
|
|
3214
|
+
const subStep = (p, i2, ii) => new Promise((resolve3, reject) => {
|
|
3215
3215
|
if (ii === pathExt.length)
|
|
3216
|
-
return
|
|
3216
|
+
return resolve3(step(i2 + 1));
|
|
3217
3217
|
const ext = pathExt[ii];
|
|
3218
3218
|
isexe(p + ext, { pathExt: pathExtExe }, (er, is) => {
|
|
3219
3219
|
if (!er && is) {
|
|
3220
3220
|
if (opt.all)
|
|
3221
3221
|
found.push(p + ext);
|
|
3222
3222
|
else
|
|
3223
|
-
return
|
|
3223
|
+
return resolve3(p + ext);
|
|
3224
3224
|
}
|
|
3225
|
-
return
|
|
3225
|
+
return resolve3(subStep(p, i2, ii + 1));
|
|
3226
3226
|
});
|
|
3227
3227
|
});
|
|
3228
3228
|
return cb ? step(0).then((res) => cb(null, res), cb) : step(0);
|
|
@@ -10947,7 +10947,7 @@ var init_cloud_poller = __esm({
|
|
|
10947
10947
|
stderr: result.stderr
|
|
10948
10948
|
};
|
|
10949
10949
|
const payload = JSON.stringify(body);
|
|
10950
|
-
await new Promise((
|
|
10950
|
+
await new Promise((resolve3, reject) => {
|
|
10951
10951
|
const headers = {
|
|
10952
10952
|
"Content-Type": "application/json",
|
|
10953
10953
|
"Content-Length": Buffer.byteLength(payload).toString(),
|
|
@@ -10967,7 +10967,7 @@ var init_cloud_poller = __esm({
|
|
|
10967
10967
|
},
|
|
10968
10968
|
(res) => {
|
|
10969
10969
|
res.resume();
|
|
10970
|
-
if ((res.statusCode ?? 0) >= 200 && (res.statusCode ?? 0) < 300)
|
|
10970
|
+
if ((res.statusCode ?? 0) >= 200 && (res.statusCode ?? 0) < 300) resolve3();
|
|
10971
10971
|
else reject(new Error(`bridge/action-result \u2192 ${String(res.statusCode)}`));
|
|
10972
10972
|
}
|
|
10973
10973
|
);
|
|
@@ -11072,7 +11072,7 @@ var init_cloud_poller = __esm({
|
|
|
11072
11072
|
const transport = isHttps ? import_node_https.request : import_node_http.request;
|
|
11073
11073
|
const port = url.port.length > 0 ? Number.parseInt(url.port, 10) : isHttps ? 443 : 80;
|
|
11074
11074
|
const timeoutMs = this.fastModePolls > 0 ? FAST_REQUEST_TIMEOUT_MS : REQUEST_TIMEOUT_MS;
|
|
11075
|
-
return new Promise((
|
|
11075
|
+
return new Promise((resolve3, reject) => {
|
|
11076
11076
|
const headers = {
|
|
11077
11077
|
Authorization: `Bearer ${this.deps.bridgeToken}`,
|
|
11078
11078
|
Accept: "application/json"
|
|
@@ -11101,7 +11101,7 @@ var init_cloud_poller = __esm({
|
|
|
11101
11101
|
}
|
|
11102
11102
|
try {
|
|
11103
11103
|
const parsed = JSON.parse(text);
|
|
11104
|
-
|
|
11104
|
+
resolve3({
|
|
11105
11105
|
actions: Array.isArray(parsed.actions) ? parsed.actions : [],
|
|
11106
11106
|
events: Array.isArray(parsed.events) ? parsed.events : [],
|
|
11107
11107
|
status: parsed.status ?? null,
|
|
@@ -12730,8 +12730,8 @@ var disconnect = (anyProcess) => {
|
|
|
12730
12730
|
// ../../node_modules/.pnpm/execa@9.6.1/node_modules/execa/lib/utils/deferred.js
|
|
12731
12731
|
var createDeferred = () => {
|
|
12732
12732
|
const methods = {};
|
|
12733
|
-
const promise = new Promise((
|
|
12734
|
-
Object.assign(methods, { resolve:
|
|
12733
|
+
const promise = new Promise((resolve3, reject) => {
|
|
12734
|
+
Object.assign(methods, { resolve: resolve3, reject });
|
|
12735
12735
|
});
|
|
12736
12736
|
return Object.assign(promise, methods);
|
|
12737
12737
|
};
|
|
@@ -17368,11 +17368,11 @@ var addConcurrentStream = (concurrentStreams, stream, waitName) => {
|
|
|
17368
17368
|
const promises = weakMap.get(stream);
|
|
17369
17369
|
const promise = createDeferred();
|
|
17370
17370
|
promises.push(promise);
|
|
17371
|
-
const
|
|
17372
|
-
return { resolve:
|
|
17371
|
+
const resolve3 = promise.resolve.bind(promise);
|
|
17372
|
+
return { resolve: resolve3, promises };
|
|
17373
17373
|
};
|
|
17374
|
-
var waitForConcurrentStreams = async ({ resolve:
|
|
17375
|
-
|
|
17374
|
+
var waitForConcurrentStreams = async ({ resolve: resolve3, promises }, subprocess) => {
|
|
17375
|
+
resolve3();
|
|
17376
17376
|
const [isSubprocessExit] = await Promise.race([
|
|
17377
17377
|
Promise.allSettled([true, subprocess]),
|
|
17378
17378
|
Promise.all([false, ...promises])
|
|
@@ -17974,8 +17974,11 @@ var PLACEHOLDER_KEYS = [
|
|
|
17974
17974
|
"AGENTBOX_BOX_KIND",
|
|
17975
17975
|
"AGENTBOX_HOST_WORKSPACE",
|
|
17976
17976
|
"AGENTBOX_PROJECT_ROOT",
|
|
17977
|
-
// Convenience: the
|
|
17978
|
-
//
|
|
17977
|
+
// Convenience: the host this box is reachable at. Derived from
|
|
17978
|
+
// AGENTBOX_BOX_NAME as `<box-name>.localhost` when not set explicitly (the
|
|
17979
|
+
// portless host for docker/hetzner). Public-URL cloud providers
|
|
17980
|
+
// (vercel/daytona/e2b) set it explicitly at boot to the real preview host
|
|
17981
|
+
// (e.g. `<sub>.vercel.run`), which then wins over the derived fallback.
|
|
17979
17982
|
"AGENTBOX_BOX_HOST"
|
|
17980
17983
|
];
|
|
17981
17984
|
var PLACEHOLDER_SET = new Set(PLACEHOLDER_KEYS);
|
|
@@ -18197,7 +18200,7 @@ async function probeGh() {
|
|
|
18197
18200
|
return null;
|
|
18198
18201
|
}
|
|
18199
18202
|
function runHostGh(args, cwd, timeoutMs = GH_RPC_TIMEOUT_MS) {
|
|
18200
|
-
return new Promise((
|
|
18203
|
+
return new Promise((resolve3) => {
|
|
18201
18204
|
const child = (0, import_node_child_process6.spawn)("gh", args, {
|
|
18202
18205
|
cwd,
|
|
18203
18206
|
env: process.env,
|
|
@@ -18209,7 +18212,7 @@ function runHostGh(args, cwd, timeoutMs = GH_RPC_TIMEOUT_MS) {
|
|
|
18209
18212
|
const finish = (exitCode) => {
|
|
18210
18213
|
if (settled) return;
|
|
18211
18214
|
settled = true;
|
|
18212
|
-
|
|
18215
|
+
resolve3({ exitCode, stdout, stderr });
|
|
18213
18216
|
};
|
|
18214
18217
|
const timer = setTimeout(() => {
|
|
18215
18218
|
child.kill("SIGTERM");
|
|
@@ -18273,7 +18276,7 @@ async function checkoutGuards(hostMainRepo, registeredBranches) {
|
|
|
18273
18276
|
return null;
|
|
18274
18277
|
}
|
|
18275
18278
|
function runGitProbe(args) {
|
|
18276
|
-
return new Promise((
|
|
18279
|
+
return new Promise((resolve3) => {
|
|
18277
18280
|
const child = (0, import_node_child_process6.spawn)("git", args, { env: process.env, stdio: ["ignore", "pipe", "pipe"] });
|
|
18278
18281
|
let stdout = "";
|
|
18279
18282
|
let stderr = "";
|
|
@@ -18284,10 +18287,10 @@ function runGitProbe(args) {
|
|
|
18284
18287
|
stderr += c3.toString("utf8");
|
|
18285
18288
|
});
|
|
18286
18289
|
child.on("error", (err) => {
|
|
18287
|
-
|
|
18290
|
+
resolve3({ exitCode: 127, stdout, stderr: stderr + String(err.message ?? err) });
|
|
18288
18291
|
});
|
|
18289
18292
|
child.on("close", (code) => {
|
|
18290
|
-
|
|
18293
|
+
resolve3({ exitCode: code ?? -1, stdout, stderr });
|
|
18291
18294
|
});
|
|
18292
18295
|
});
|
|
18293
18296
|
}
|
|
@@ -18451,7 +18454,8 @@ var BUILT_IN_DEFAULTS = {
|
|
|
18451
18454
|
},
|
|
18452
18455
|
attach: {
|
|
18453
18456
|
openIn: "split",
|
|
18454
|
-
cmuxStatus: true
|
|
18457
|
+
cmuxStatus: true,
|
|
18458
|
+
herdrStatus: true
|
|
18455
18459
|
},
|
|
18456
18460
|
code: {
|
|
18457
18461
|
ide: "auto",
|
|
@@ -18755,13 +18759,18 @@ var KEY_REGISTRY = [
|
|
|
18755
18759
|
key: "attach.openIn",
|
|
18756
18760
|
type: "enum",
|
|
18757
18761
|
enumValues: ["split", "window", "tab", "same"],
|
|
18758
|
-
description: "Where `agentbox claude|codex|opencode` opens the attached session when run from tmux, cmux, or iTerm2: `split` (tmux split-window / cmux new-split / iTerm2 vertical split, default \u2014 same workspace), `window` (tmux new-window / cmux new-workspace / new iTerm2 window), `tab` (tmux new-window / cmux new-surface tab in the current
|
|
18762
|
+
description: "Where `agentbox claude|codex|opencode` opens the attached session when run from tmux, cmux, Herdr, or iTerm2: `split` (tmux split-window / cmux new-split / Herdr pane.split / iTerm2 vertical split, default \u2014 same workspace), `window` (tmux new-window / cmux new-workspace / Herdr workspace.create / new iTerm2 window), `tab` (tmux new-window / cmux new-surface / Herdr tab.create in the current workspace / new iTerm2 tab), or `same` (attach inline in the current terminal). Outside tmux/cmux/Herdr/iTerm2 every value behaves like `same`."
|
|
18759
18763
|
},
|
|
18760
18764
|
{
|
|
18761
18765
|
key: "attach.cmuxStatus",
|
|
18762
18766
|
type: "bool",
|
|
18763
18767
|
description: "When attached inside cmux, reflect the box agent's live activity on its cmux workspace (colour + description: blue=working, amber=needs input, idle clears; restored on detach) and, when the agent needs input, flag the box's own tab via a cmux notification (tab badge + reorder + desktop notification) so it stands out among sibling tabs. cmux only; no-op in other terminals."
|
|
18764
18768
|
},
|
|
18769
|
+
{
|
|
18770
|
+
key: "attach.herdrStatus",
|
|
18771
|
+
type: "bool",
|
|
18772
|
+
description: "When attached inside Herdr, report the box agent's live activity to its Herdr pane (pane.report_agent: working / blocked / idle) so it looks like a normal agent pane and Herdr handles needs-input natively, and fire a Herdr notification for AgentBox's own host-relay approval prompts (git push / PR / checkpoint \u2026) which Herdr can't otherwise see. Herdr only; no-op in other terminals."
|
|
18773
|
+
},
|
|
18765
18774
|
{
|
|
18766
18775
|
key: "code.ide",
|
|
18767
18776
|
type: "enum",
|
|
@@ -18872,7 +18881,7 @@ var KEY_REGISTRY = [
|
|
|
18872
18881
|
key: "queue.openIn",
|
|
18873
18882
|
type: "enum",
|
|
18874
18883
|
enumValues: ["none", "split", "window", "tab"],
|
|
18875
|
-
description: "When a background `-i` job finishes creating its box, where the host relay opens an attached terminal onto it: `none` (default \u2014 open nothing, just queue), `split`, `window`, or `tab`. Honored only when the submitting shell runs inside tmux, cmux, or iTerm2 (the targeting is captured at submit time). Under cmux, `split` splits the pane you submitted from (falling back to the parent workspace, then a new workspace), `tab` adds a tab in the parent workspace, and `window` opens a separate workspace; iTerm2 opens relative to the frontmost window. Unlike `attach.openIn` there is no `same` mode \u2014 the box is created asynchronously, so it is always a fresh terminal."
|
|
18884
|
+
description: "When a background `-i` job finishes creating its box, where the host relay opens an attached terminal onto it: `none` (default \u2014 open nothing, just queue), `split`, `window`, or `tab`. Honored only when the submitting shell runs inside tmux, cmux, Herdr, or iTerm2 (the targeting is captured at submit time). Under cmux, `split` splits the pane you submitted from (falling back to the parent workspace, then a new workspace), `tab` adds a tab in the parent workspace, and `window` opens a separate workspace; under Herdr, `split` splits the pane you submitted from, `tab` adds a tab in the parent workspace, and `window` opens a separate workspace; iTerm2 opens relative to the frontmost window. Unlike `attach.openIn` there is no `same` mode \u2014 the box is created asynchronously, so it is always a fresh terminal."
|
|
18876
18885
|
},
|
|
18877
18886
|
{
|
|
18878
18887
|
key: "cloud.useCurrentBranch",
|
|
@@ -19290,7 +19299,7 @@ function runHostBinary(connector, argv, cwd, timeoutMs) {
|
|
|
19290
19299
|
`
|
|
19291
19300
|
});
|
|
19292
19301
|
}
|
|
19293
|
-
return new Promise((
|
|
19302
|
+
return new Promise((resolve3) => {
|
|
19294
19303
|
const child = (0, import_node_child_process7.spawn)(connector.hostBin, [...argv], {
|
|
19295
19304
|
cwd,
|
|
19296
19305
|
env,
|
|
@@ -19302,7 +19311,7 @@ function runHostBinary(connector, argv, cwd, timeoutMs) {
|
|
|
19302
19311
|
const finish = (exitCode) => {
|
|
19303
19312
|
if (settled) return;
|
|
19304
19313
|
settled = true;
|
|
19305
|
-
|
|
19314
|
+
resolve3({ exitCode, stdout, stderr });
|
|
19306
19315
|
};
|
|
19307
19316
|
const timer = setTimeout(() => {
|
|
19308
19317
|
child.kill("SIGTERM");
|
|
@@ -19378,11 +19387,11 @@ var PendingPrompts = class {
|
|
|
19378
19387
|
return true;
|
|
19379
19388
|
}
|
|
19380
19389
|
add(boxId, ev) {
|
|
19381
|
-
return new Promise((
|
|
19390
|
+
return new Promise((resolve3) => {
|
|
19382
19391
|
this.entries.set(ev.id, {
|
|
19383
19392
|
ev,
|
|
19384
19393
|
boxId,
|
|
19385
|
-
resolve:
|
|
19394
|
+
resolve: resolve3,
|
|
19386
19395
|
createdAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
19387
19396
|
});
|
|
19388
19397
|
});
|
|
@@ -20126,6 +20135,17 @@ async function lookupCloudBox(boxId) {
|
|
|
20126
20135
|
}
|
|
20127
20136
|
return { workspacePath: hit.box.workspacePath, cloudSandboxId: sid };
|
|
20128
20137
|
}
|
|
20138
|
+
async function boxWorkspacePath(boxId) {
|
|
20139
|
+
const state = await readState();
|
|
20140
|
+
const hit = findBox(boxId, state);
|
|
20141
|
+
return hit.kind === "ok" ? hit.box.workspacePath : void 0;
|
|
20142
|
+
}
|
|
20143
|
+
function resolveHostPath(workspacePath, hostPath) {
|
|
20144
|
+
if ((0, import_node_path6.isAbsolute)(hostPath)) return hostPath;
|
|
20145
|
+
if (hostPath === "~") return (0, import_node_os4.homedir)();
|
|
20146
|
+
if (hostPath.startsWith("~/")) return (0, import_node_path6.join)((0, import_node_os4.homedir)(), hostPath.slice(2));
|
|
20147
|
+
return workspacePath ? (0, import_node_path6.resolve)(workspacePath, hostPath) : (0, import_node_path6.resolve)(hostPath);
|
|
20148
|
+
}
|
|
20129
20149
|
var cloudCpModule;
|
|
20130
20150
|
async function loadCloudCp() {
|
|
20131
20151
|
if (cloudCpModule) return cloudCpModule;
|
|
@@ -20154,27 +20174,28 @@ async function runCpRpc(action, deps) {
|
|
|
20154
20174
|
};
|
|
20155
20175
|
}
|
|
20156
20176
|
const direction = action.method === "cp.toHost" ? "box -> host" : "host -> box";
|
|
20177
|
+
const lookup = await lookupCloudBox(deps.boxId);
|
|
20178
|
+
const hostAbs = resolveHostPath(lookup.workspacePath, params.hostPath);
|
|
20157
20179
|
if (deps.prompts && deps.subscribers) {
|
|
20158
20180
|
const verdict = await askPrompt(deps.prompts, deps.subscribers, deps.boxId, {
|
|
20159
20181
|
kind: "confirm",
|
|
20160
20182
|
message: `Allow cp (${direction}) on ${deps.boxName ?? deps.boxId}?`,
|
|
20161
|
-
detail: action.method === "cp.toHost" ? `${params.boxPath} -> ${
|
|
20183
|
+
detail: action.method === "cp.toHost" ? `${params.boxPath} -> ${hostAbs}` : `${hostAbs} -> ${params.boxPath}`,
|
|
20162
20184
|
defaultAnswer: "n",
|
|
20163
20185
|
context: {
|
|
20164
20186
|
command: action.method,
|
|
20165
|
-
argv: [params.boxPath,
|
|
20187
|
+
argv: [params.boxPath, hostAbs]
|
|
20166
20188
|
}
|
|
20167
20189
|
});
|
|
20168
20190
|
if (verdict.answer !== "y") {
|
|
20169
20191
|
return { exitCode: 10, stdout: "", stderr: "denied by user\n" };
|
|
20170
20192
|
}
|
|
20171
20193
|
}
|
|
20172
|
-
const lookup = await lookupCloudBox(deps.boxId);
|
|
20173
20194
|
const backend = await resolveCloudBackend(deps.backendName);
|
|
20174
20195
|
const handle = { sandboxId: lookup.cloudSandboxId };
|
|
20175
20196
|
const cp = await loadCloudCp();
|
|
20176
20197
|
try {
|
|
20177
|
-
const result = action.method === "cp.toHost" ? await cp.downloadFromCloudBox(backend, handle, params.boxPath,
|
|
20198
|
+
const result = action.method === "cp.toHost" ? await cp.downloadFromCloudBox(backend, handle, params.boxPath, hostAbs) : await cp.uploadToCloudBox(backend, handle, hostAbs, params.boxPath);
|
|
20178
20199
|
return { exitCode: 0, stdout: `${result.finalPath}
|
|
20179
20200
|
`, stderr: "" };
|
|
20180
20201
|
} catch (err) {
|
|
@@ -20250,7 +20271,7 @@ async function runDownloadRpc(action, deps) {
|
|
|
20250
20271
|
const backend = await resolveCloudBackend(deps.backendName);
|
|
20251
20272
|
const handle = { sandboxId: lookup.cloudSandboxId };
|
|
20252
20273
|
const cp = await loadCloudCp();
|
|
20253
|
-
const hostDst = typeof params.hostPath === "string" && params.hostPath.length > 0 ? params.hostPath : lookup.workspacePath;
|
|
20274
|
+
const hostDst = typeof params.hostPath === "string" && params.hostPath.length > 0 ? resolveHostPath(lookup.workspacePath, params.hostPath) : lookup.workspacePath;
|
|
20254
20275
|
try {
|
|
20255
20276
|
const result = await cp.pullCloudDirContents(backend, handle, "/workspace", hostDst);
|
|
20256
20277
|
return { exitCode: 0, stdout: `${result.finalPath}
|
|
@@ -20491,8 +20512,8 @@ var HostActionQueue = class {
|
|
|
20491
20512
|
params,
|
|
20492
20513
|
createdAt: new Date(this.now()).toISOString()
|
|
20493
20514
|
};
|
|
20494
|
-
return new Promise((
|
|
20495
|
-
this.map.set(id, { action, resolve:
|
|
20515
|
+
return new Promise((resolve3) => {
|
|
20516
|
+
this.map.set(id, { action, resolve: resolve3, delivered: false });
|
|
20496
20517
|
});
|
|
20497
20518
|
}
|
|
20498
20519
|
/**
|
|
@@ -20744,7 +20765,7 @@ function send(res, status, body, contentType = "application/json") {
|
|
|
20744
20765
|
}
|
|
20745
20766
|
}
|
|
20746
20767
|
async function readJsonBody(req) {
|
|
20747
|
-
return new Promise((
|
|
20768
|
+
return new Promise((resolve3, reject) => {
|
|
20748
20769
|
let total = 0;
|
|
20749
20770
|
const chunks = [];
|
|
20750
20771
|
req.on("data", (chunk) => {
|
|
@@ -20759,11 +20780,11 @@ async function readJsonBody(req) {
|
|
|
20759
20780
|
req.on("end", () => {
|
|
20760
20781
|
const text = Buffer.concat(chunks).toString("utf8");
|
|
20761
20782
|
if (text.length === 0) {
|
|
20762
|
-
|
|
20783
|
+
resolve3({});
|
|
20763
20784
|
return;
|
|
20764
20785
|
}
|
|
20765
20786
|
try {
|
|
20766
|
-
|
|
20787
|
+
resolve3(JSON.parse(text));
|
|
20767
20788
|
} catch (err) {
|
|
20768
20789
|
reject(err instanceof Error ? err : new Error(String(err)));
|
|
20769
20790
|
}
|
|
@@ -20997,7 +21018,9 @@ function createRelayServer(opts) {
|
|
|
20997
21018
|
return;
|
|
20998
21019
|
}
|
|
20999
21020
|
const direction = body.method === "cp.toHost" ? "box -> host" : "host -> box";
|
|
21000
|
-
const
|
|
21021
|
+
const workspacePath = await boxWorkspacePath(reg.boxId);
|
|
21022
|
+
const hostAbs = resolveHostPath(workspacePath, params.hostPath);
|
|
21023
|
+
const pathDetail = body.method === "cp.toHost" ? `${params.boxPath} -> ${hostAbs}` : `${hostAbs} -> ${params.boxPath}`;
|
|
21001
21024
|
const detailParts = [pathDetail];
|
|
21002
21025
|
if (params.exclude && params.exclude.length > 0) {
|
|
21003
21026
|
detailParts.push(`exclude: ${params.exclude.join(", ")}`);
|
|
@@ -21011,14 +21034,17 @@ function createRelayServer(opts) {
|
|
|
21011
21034
|
defaultAnswer: "n",
|
|
21012
21035
|
context: {
|
|
21013
21036
|
command: body.method,
|
|
21014
|
-
argv: [params.boxPath,
|
|
21037
|
+
argv: [params.boxPath, hostAbs]
|
|
21015
21038
|
}
|
|
21016
21039
|
});
|
|
21017
21040
|
if (verdict.answer !== "y") {
|
|
21018
21041
|
send(res, 500, { exitCode: 10, stdout: "", stderr: "denied by user\n" });
|
|
21019
21042
|
return;
|
|
21020
21043
|
}
|
|
21021
|
-
const result = await handleCpRpc(reg, body.method, params
|
|
21044
|
+
const result = await handleCpRpc(reg, body.method, params, {
|
|
21045
|
+
hostPath: hostAbs,
|
|
21046
|
+
cwd: workspacePath
|
|
21047
|
+
});
|
|
21022
21048
|
const status = result.exitCode === 0 ? 200 : 500;
|
|
21023
21049
|
send(res, status, result);
|
|
21024
21050
|
return;
|
|
@@ -21449,10 +21475,10 @@ data: {"ts":"${(/* @__PURE__ */ new Date()).toISOString()}"}
|
|
|
21449
21475
|
},
|
|
21450
21476
|
close: async () => {
|
|
21451
21477
|
if (pollers) await pollers.stopAll();
|
|
21452
|
-
await new Promise((
|
|
21478
|
+
await new Promise((resolve3, reject) => {
|
|
21453
21479
|
server.close((err) => {
|
|
21454
21480
|
if (err) reject(err);
|
|
21455
|
-
else
|
|
21481
|
+
else resolve3();
|
|
21456
21482
|
});
|
|
21457
21483
|
});
|
|
21458
21484
|
}
|
|
@@ -21689,7 +21715,7 @@ async function handleIntegrationRpc(method, reg, params, prompts, subscribers, h
|
|
|
21689
21715
|
}
|
|
21690
21716
|
return runHostIntegration(connector, opDesc, args, worktree.hostMainRepo);
|
|
21691
21717
|
}
|
|
21692
|
-
async function handleCpRpc(reg, method, params) {
|
|
21718
|
+
async function handleCpRpc(reg, method, params, opts) {
|
|
21693
21719
|
const entry = process.env.AGENTBOX_CLI_ENTRY;
|
|
21694
21720
|
if (!entry) {
|
|
21695
21721
|
return {
|
|
@@ -21703,8 +21729,8 @@ async function handleCpRpc(reg, method, params) {
|
|
|
21703
21729
|
for (const pat of params.exclude ?? []) flags.push("--exclude", pat);
|
|
21704
21730
|
if (params.defaultExcludes === false) flags.push("--no-default-excludes");
|
|
21705
21731
|
if (params.yes) flags.push("--yes");
|
|
21706
|
-
const argv = method === "cp.toHost" ? [process.execPath, entry, "cp", boxRef,
|
|
21707
|
-
return runHostCommand(argv, CP_RPC_TIMEOUT_MS);
|
|
21732
|
+
const argv = method === "cp.toHost" ? [process.execPath, entry, "cp", boxRef, opts.hostPath, ...flags] : [process.execPath, entry, "cp", opts.hostPath, boxRef, ...flags];
|
|
21733
|
+
return runHostCommand(argv, CP_RPC_TIMEOUT_MS, opts.cwd);
|
|
21708
21734
|
}
|
|
21709
21735
|
async function handleDownloadRpc(reg, kind) {
|
|
21710
21736
|
const entry = process.env.AGENTBOX_CLI_ENTRY;
|
|
@@ -21718,7 +21744,8 @@ async function handleDownloadRpc(reg, kind) {
|
|
|
21718
21744
|
const argv = [process.execPath, entry, "download"];
|
|
21719
21745
|
if (kind !== "workspace") argv.push(kind);
|
|
21720
21746
|
argv.push(reg.name, "-y");
|
|
21721
|
-
|
|
21747
|
+
const cwd = await boxWorkspacePath(reg.boxId);
|
|
21748
|
+
return runHostCommand(argv, DOWNLOAD_RPC_TIMEOUT_MS, cwd);
|
|
21722
21749
|
}
|
|
21723
21750
|
async function handleCheckpointRpc(reg, params) {
|
|
21724
21751
|
const entry = process.env.AGENTBOX_CLI_ENTRY;
|
|
@@ -21745,16 +21772,20 @@ function isOpenableUrl(value) {
|
|
|
21745
21772
|
}
|
|
21746
21773
|
return url.protocol === "http:" || url.protocol === "https:";
|
|
21747
21774
|
}
|
|
21748
|
-
function runHostCommand(argv, timeoutMs = GIT_RPC_TIMEOUT_MS) {
|
|
21749
|
-
return new Promise((
|
|
21775
|
+
function runHostCommand(argv, timeoutMs = GIT_RPC_TIMEOUT_MS, cwd) {
|
|
21776
|
+
return new Promise((resolve3) => {
|
|
21750
21777
|
const [cmd, ...rest] = argv;
|
|
21751
21778
|
if (!cmd) {
|
|
21752
|
-
|
|
21779
|
+
resolve3({ exitCode: 64, stdout: "", stderr: "empty command" });
|
|
21753
21780
|
return;
|
|
21754
21781
|
}
|
|
21755
21782
|
const child = (0, import_node_child_process8.spawn)(cmd, rest, {
|
|
21756
21783
|
env: process.env,
|
|
21757
|
-
stdio: ["ignore", "pipe", "pipe"]
|
|
21784
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
21785
|
+
// Default to the relay daemon's CWD when unset (legacy behaviour); callers
|
|
21786
|
+
// that know the box pass its workspace so relative host paths + project
|
|
21787
|
+
// config resolve against the box, not whatever dir launched the relay.
|
|
21788
|
+
...cwd ? { cwd } : {}
|
|
21758
21789
|
});
|
|
21759
21790
|
let stdout = "";
|
|
21760
21791
|
let stderr = "";
|
|
@@ -21762,7 +21793,7 @@ function runHostCommand(argv, timeoutMs = GIT_RPC_TIMEOUT_MS) {
|
|
|
21762
21793
|
const finish = (exitCode) => {
|
|
21763
21794
|
if (settled) return;
|
|
21764
21795
|
settled = true;
|
|
21765
|
-
|
|
21796
|
+
resolve3({ exitCode, stdout, stderr });
|
|
21766
21797
|
};
|
|
21767
21798
|
const timer = setTimeout(() => {
|
|
21768
21799
|
child.kill("SIGTERM");
|
|
@@ -21790,11 +21821,11 @@ relay: command timed out after ${String(timeoutMs)}ms
|
|
|
21790
21821
|
}
|
|
21791
21822
|
async function startRelayServer(opts) {
|
|
21792
21823
|
const handle = createRelayServer(opts);
|
|
21793
|
-
await new Promise((
|
|
21824
|
+
await new Promise((resolve3, reject) => {
|
|
21794
21825
|
handle.server.once("error", reject);
|
|
21795
21826
|
handle.server.listen(opts.port, opts.host ?? "0.0.0.0", () => {
|
|
21796
21827
|
handle.server.removeListener("error", reject);
|
|
21797
|
-
|
|
21828
|
+
resolve3();
|
|
21798
21829
|
});
|
|
21799
21830
|
});
|
|
21800
21831
|
return handle;
|
|
@@ -22371,7 +22402,7 @@ function toEpoch(iso) {
|
|
|
22371
22402
|
var INSPECT_TIMEOUT_MS = 15e3;
|
|
22372
22403
|
var PAUSE_TIMEOUT_MS = 3e4;
|
|
22373
22404
|
function runDocker(args, timeoutMs) {
|
|
22374
|
-
return new Promise((
|
|
22405
|
+
return new Promise((resolve3) => {
|
|
22375
22406
|
const child = (0, import_node_child_process10.spawn)("docker", args, { stdio: ["ignore", "pipe", "pipe"] });
|
|
22376
22407
|
let stdout = "";
|
|
22377
22408
|
let stderr = "";
|
|
@@ -22379,7 +22410,7 @@ function runDocker(args, timeoutMs) {
|
|
|
22379
22410
|
const finish = (exitCode) => {
|
|
22380
22411
|
if (settled) return;
|
|
22381
22412
|
settled = true;
|
|
22382
|
-
|
|
22413
|
+
resolve3({ exitCode, stdout, stderr });
|
|
22383
22414
|
};
|
|
22384
22415
|
const timer = setTimeout(() => {
|
|
22385
22416
|
child.kill("SIGTERM");
|
|
@@ -22430,6 +22461,173 @@ async function pauseContainer(name) {
|
|
|
22430
22461
|
}
|
|
22431
22462
|
}
|
|
22432
22463
|
|
|
22464
|
+
// src/cloud-keepalive.ts
|
|
22465
|
+
var import_promises21 = require("fs/promises");
|
|
22466
|
+
function selectBoxesToRenew(entries, windowMs, now) {
|
|
22467
|
+
const out = [];
|
|
22468
|
+
for (const e of entries) {
|
|
22469
|
+
if (e.agentState == null) continue;
|
|
22470
|
+
let target = null;
|
|
22471
|
+
if (e.agentState === "active") {
|
|
22472
|
+
target = now + windowMs;
|
|
22473
|
+
} else if (e.agentState === "idle" && e.lastActivityMs != null && now - e.lastActivityMs < windowMs) {
|
|
22474
|
+
target = e.lastActivityMs + windowMs;
|
|
22475
|
+
}
|
|
22476
|
+
if (target != null) {
|
|
22477
|
+
out.push({ boxId: e.boxId, backend: e.backend, targetDeadlineEpochMs: target });
|
|
22478
|
+
}
|
|
22479
|
+
}
|
|
22480
|
+
return out;
|
|
22481
|
+
}
|
|
22482
|
+
function coarseKeepaliveState(s) {
|
|
22483
|
+
switch (s) {
|
|
22484
|
+
case "working":
|
|
22485
|
+
case "compacting":
|
|
22486
|
+
case "waiting":
|
|
22487
|
+
case "question":
|
|
22488
|
+
case "end-plan":
|
|
22489
|
+
return "active";
|
|
22490
|
+
case "idle":
|
|
22491
|
+
return "idle";
|
|
22492
|
+
default:
|
|
22493
|
+
return null;
|
|
22494
|
+
}
|
|
22495
|
+
}
|
|
22496
|
+
var DEFAULT_INTERVAL_MS3 = 6e4;
|
|
22497
|
+
var FAILURE_BACKOFF_MS = 5 * 6e4;
|
|
22498
|
+
function startCloudKeepaliveLoop(deps) {
|
|
22499
|
+
const loadConfig = deps.loadConfig ?? loadAutopauseConfig;
|
|
22500
|
+
const resolveBackend = deps.resolveBackend ?? resolveCloudBackend;
|
|
22501
|
+
const lookupBox = deps.lookupBox ?? defaultLookupBox;
|
|
22502
|
+
const fallbackCreateTimeoutMs = deps.fallbackCreateTimeoutMs ?? defaultFallbackCreateTimeoutMs;
|
|
22503
|
+
const nowFn = deps.now ?? Date.now;
|
|
22504
|
+
const intervalMs = deps.intervalMs ?? DEFAULT_INTERVAL_MS3;
|
|
22505
|
+
const { registry, statusStore, log } = deps;
|
|
22506
|
+
const tracked = /* @__PURE__ */ new Map();
|
|
22507
|
+
const backoffUntil = /* @__PURE__ */ new Map();
|
|
22508
|
+
const backendCache = /* @__PURE__ */ new Map();
|
|
22509
|
+
let ticking = false;
|
|
22510
|
+
let stopped = false;
|
|
22511
|
+
let inFlight = Promise.resolve();
|
|
22512
|
+
async function resolveCached(name) {
|
|
22513
|
+
if (backendCache.has(name)) return backendCache.get(name) ?? null;
|
|
22514
|
+
let backend = null;
|
|
22515
|
+
try {
|
|
22516
|
+
backend = await resolveBackend(name);
|
|
22517
|
+
} catch {
|
|
22518
|
+
backend = null;
|
|
22519
|
+
}
|
|
22520
|
+
backendCache.set(name, backend);
|
|
22521
|
+
return backend;
|
|
22522
|
+
}
|
|
22523
|
+
async function tick() {
|
|
22524
|
+
if (ticking) return;
|
|
22525
|
+
ticking = true;
|
|
22526
|
+
try {
|
|
22527
|
+
const cfg = await loadConfig();
|
|
22528
|
+
if (!cfg.enabled) return;
|
|
22529
|
+
const windowMs = cfg.idleMinutes * 6e4;
|
|
22530
|
+
const now = nowFn();
|
|
22531
|
+
const live = /* @__PURE__ */ new Set();
|
|
22532
|
+
const entries = [];
|
|
22533
|
+
for (const reg of registry.list()) {
|
|
22534
|
+
if (reg.kind !== "cloud" || !reg.backend) continue;
|
|
22535
|
+
const backend = await resolveCached(reg.backend);
|
|
22536
|
+
if (!backend || typeof backend.renewTimeout !== "function") continue;
|
|
22537
|
+
live.add(reg.boxId);
|
|
22538
|
+
const active = readActiveAgent(statusStore.get(reg.boxId));
|
|
22539
|
+
entries.push({
|
|
22540
|
+
boxId: reg.boxId,
|
|
22541
|
+
backend: reg.backend,
|
|
22542
|
+
agentState: coarseKeepaliveState(active.state),
|
|
22543
|
+
lastActivityMs: active.updatedAt ? toEpoch2(active.updatedAt) : null
|
|
22544
|
+
});
|
|
22545
|
+
}
|
|
22546
|
+
for (const id of [...tracked.keys()]) if (!live.has(id)) tracked.delete(id);
|
|
22547
|
+
for (const id of [...backoffUntil.keys()]) if (!live.has(id)) backoffUntil.delete(id);
|
|
22548
|
+
const decisions = selectBoxesToRenew(entries, windowMs, now);
|
|
22549
|
+
for (const d of decisions) {
|
|
22550
|
+
const until = backoffUntil.get(d.boxId);
|
|
22551
|
+
if (until != null && now < until) continue;
|
|
22552
|
+
const lookup = await lookupBox(d.boxId);
|
|
22553
|
+
if (!lookup) continue;
|
|
22554
|
+
let current = tracked.get(d.boxId);
|
|
22555
|
+
if (current == null) {
|
|
22556
|
+
const createMs = lookup.createdAtMs ?? now;
|
|
22557
|
+
const createTimeoutMs = lookup.createTimeoutMs ?? await fallbackCreateTimeoutMs(d.backend);
|
|
22558
|
+
current = createMs + createTimeoutMs;
|
|
22559
|
+
tracked.set(d.boxId, current);
|
|
22560
|
+
}
|
|
22561
|
+
if (d.targetDeadlineEpochMs <= current + intervalMs) continue;
|
|
22562
|
+
try {
|
|
22563
|
+
const backend = await resolveCached(d.backend);
|
|
22564
|
+
if (!backend?.renewTimeout) continue;
|
|
22565
|
+
await backend.renewTimeout({ sandboxId: lookup.sandboxId }, d.targetDeadlineEpochMs, current);
|
|
22566
|
+
tracked.set(d.boxId, d.targetDeadlineEpochMs);
|
|
22567
|
+
backoffUntil.delete(d.boxId);
|
|
22568
|
+
log(
|
|
22569
|
+
`cloud-keepalive: renewed box ${d.boxId} (${d.backend}) +${String(Math.round((d.targetDeadlineEpochMs - now) / 6e4))}m`
|
|
22570
|
+
);
|
|
22571
|
+
} catch (err) {
|
|
22572
|
+
backoffUntil.set(d.boxId, now + FAILURE_BACKOFF_MS);
|
|
22573
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
22574
|
+
log(`cloud-keepalive: renew box ${d.boxId} (${d.backend}) failed: ${msg}`);
|
|
22575
|
+
}
|
|
22576
|
+
}
|
|
22577
|
+
} catch (err) {
|
|
22578
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
22579
|
+
log(`cloud-keepalive: tick error: ${msg}`);
|
|
22580
|
+
} finally {
|
|
22581
|
+
ticking = false;
|
|
22582
|
+
}
|
|
22583
|
+
}
|
|
22584
|
+
const timer = setInterval(() => {
|
|
22585
|
+
if (stopped) return;
|
|
22586
|
+
inFlight = tick();
|
|
22587
|
+
}, intervalMs);
|
|
22588
|
+
timer.unref();
|
|
22589
|
+
return {
|
|
22590
|
+
stop: async () => {
|
|
22591
|
+
stopped = true;
|
|
22592
|
+
clearInterval(timer);
|
|
22593
|
+
await inFlight.catch(() => {
|
|
22594
|
+
});
|
|
22595
|
+
}
|
|
22596
|
+
};
|
|
22597
|
+
}
|
|
22598
|
+
function toEpoch2(iso) {
|
|
22599
|
+
if (!iso) return null;
|
|
22600
|
+
const t = Date.parse(iso);
|
|
22601
|
+
return Number.isNaN(t) ? null : t;
|
|
22602
|
+
}
|
|
22603
|
+
async function defaultLookupBox(boxId) {
|
|
22604
|
+
const state = await readState();
|
|
22605
|
+
const hit = findBox(boxId, state);
|
|
22606
|
+
if (hit.kind !== "ok") return null;
|
|
22607
|
+
const sandboxId = hit.box.cloud?.sandboxId;
|
|
22608
|
+
if (!sandboxId) return null;
|
|
22609
|
+
return {
|
|
22610
|
+
sandboxId,
|
|
22611
|
+
createdAtMs: toEpoch2(hit.box.createdAt),
|
|
22612
|
+
createTimeoutMs: hit.box.cloud?.sessionTimeoutMs ?? null
|
|
22613
|
+
};
|
|
22614
|
+
}
|
|
22615
|
+
async function defaultFallbackCreateTimeoutMs(backend) {
|
|
22616
|
+
const generic = 45 * 6e4;
|
|
22617
|
+
if (backend !== "vercel") return generic;
|
|
22618
|
+
const fallback = BUILT_IN_DEFAULTS.box.vercelTimeoutMs;
|
|
22619
|
+
try {
|
|
22620
|
+
const global3 = parseUserConfig(
|
|
22621
|
+
await (0, import_promises21.readFile)(GLOBAL_CONFIG_FILE, "utf8"),
|
|
22622
|
+
GLOBAL_CONFIG_FILE
|
|
22623
|
+
);
|
|
22624
|
+
const v = global3.box?.vercelTimeoutMs;
|
|
22625
|
+
return typeof v === "number" && v > 0 ? v : fallback;
|
|
22626
|
+
} catch {
|
|
22627
|
+
return fallback;
|
|
22628
|
+
}
|
|
22629
|
+
}
|
|
22630
|
+
|
|
22433
22631
|
// src/bin.ts
|
|
22434
22632
|
var program2 = new Command();
|
|
22435
22633
|
program2.name("agentbox-relay").description("Host-side HTTP relay for box\u2192host events and RPCs").version("0.0.0");
|
|
@@ -22453,6 +22651,12 @@ program2.command("serve").description("Run the HTTP relay in the foreground").op
|
|
|
22453
22651
|
statusStore: handle.statusStore,
|
|
22454
22652
|
events: handle.events,
|
|
22455
22653
|
log: (line) => process.stdout.write(`agentbox-relay: ${line}
|
|
22654
|
+
`)
|
|
22655
|
+
});
|
|
22656
|
+
const cloudKeepalive = startCloudKeepaliveLoop({
|
|
22657
|
+
registry: handle.registry,
|
|
22658
|
+
statusStore: handle.statusStore,
|
|
22659
|
+
log: (line) => process.stdout.write(`agentbox-relay: ${line}
|
|
22456
22660
|
`)
|
|
22457
22661
|
});
|
|
22458
22662
|
const queue = startQueueLoop({
|
|
@@ -22467,7 +22671,7 @@ program2.command("serve").description("Run the HTTP relay in the foreground").op
|
|
|
22467
22671
|
const shutdown = (signal) => {
|
|
22468
22672
|
process.stdout.write(`agentbox-relay: ${signal} \u2014 shutting down
|
|
22469
22673
|
`);
|
|
22470
|
-
Promise.allSettled([autopause.stop(), queue.stop()]).finally(() => handle.close()).finally(() => process.exit(0));
|
|
22674
|
+
Promise.allSettled([autopause.stop(), cloudKeepalive.stop(), queue.stop()]).finally(() => handle.close()).finally(() => process.exit(0));
|
|
22471
22675
|
};
|
|
22472
22676
|
process.on("SIGTERM", () => shutdown("SIGTERM"));
|
|
22473
22677
|
process.on("SIGINT", () => shutdown("SIGINT"));
|
|
@@ -22488,7 +22692,7 @@ program2.command("tail").description("Print recent events (in-container shim; GE
|
|
|
22488
22692
|
async function adminPost(path6, body, portStr) {
|
|
22489
22693
|
const port = Number.parseInt(portStr, 10);
|
|
22490
22694
|
const json = JSON.stringify(body);
|
|
22491
|
-
await new Promise((
|
|
22695
|
+
await new Promise((resolve3, reject) => {
|
|
22492
22696
|
const req = (0, import_node_http3.request)(
|
|
22493
22697
|
{
|
|
22494
22698
|
host: "127.0.0.1",
|
|
@@ -22506,7 +22710,7 @@ async function adminPost(path6, body, portStr) {
|
|
|
22506
22710
|
res.on("end", () => {
|
|
22507
22711
|
const status = res.statusCode ?? 0;
|
|
22508
22712
|
if (status >= 200 && status < 300) {
|
|
22509
|
-
|
|
22713
|
+
resolve3();
|
|
22510
22714
|
} else {
|
|
22511
22715
|
const text = Buffer.concat(chunks).toString("utf8");
|
|
22512
22716
|
reject(new Error(`relay ${path6} \u2192 ${String(status)}: ${text}`));
|
|
@@ -22521,7 +22725,7 @@ async function adminPost(path6, body, portStr) {
|
|
|
22521
22725
|
}
|
|
22522
22726
|
async function adminGet(path6, portStr) {
|
|
22523
22727
|
const port = Number.parseInt(portStr, 10);
|
|
22524
|
-
return new Promise((
|
|
22728
|
+
return new Promise((resolve3, reject) => {
|
|
22525
22729
|
const req = (0, import_node_http3.request)(
|
|
22526
22730
|
{ host: "127.0.0.1", port, method: "GET", path: path6 },
|
|
22527
22731
|
(res) => {
|
|
@@ -22530,7 +22734,7 @@ async function adminGet(path6, portStr) {
|
|
|
22530
22734
|
res.on("end", () => {
|
|
22531
22735
|
const text = Buffer.concat(chunks).toString("utf8");
|
|
22532
22736
|
const status = res.statusCode ?? 0;
|
|
22533
|
-
if (status >= 200 && status < 300)
|
|
22737
|
+
if (status >= 200 && status < 300) resolve3(text);
|
|
22534
22738
|
else reject(new Error(`relay ${path6} \u2192 ${String(status)}: ${text}`));
|
|
22535
22739
|
});
|
|
22536
22740
|
}
|