@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.
Files changed (60) hide show
  1. package/CHANGELOG.md +78 -0
  2. package/README.md +4 -3
  3. package/dist/{_cloud-attach-RUD4W33P.js → _cloud-attach-YM2KOWHO.js} +4 -4
  4. package/dist/{chunk-6QFPYU4Z.js → chunk-7K2A3NLE.js} +8 -5
  5. package/dist/chunk-7K2A3NLE.js.map +1 -0
  6. package/dist/{chunk-HFQZJO73.js → chunk-A5OFRJDI.js} +1322 -216
  7. package/dist/chunk-A5OFRJDI.js.map +1 -0
  8. package/dist/{chunk-YUGLNTT2.js → chunk-JK5V4OLT.js} +349 -16
  9. package/dist/chunk-JK5V4OLT.js.map +1 -0
  10. package/dist/{chunk-IA6YHH52.js → chunk-MODNW54N.js} +6 -3
  11. package/dist/{chunk-IA6YHH52.js.map → chunk-MODNW54N.js.map} +1 -1
  12. package/dist/{chunk-46NXCJ6Z.js → chunk-NXX3KQZ6.js} +2 -2
  13. package/dist/{chunk-3JXSW6PN.js → chunk-P6UT5XGE.js} +2 -2
  14. package/dist/{chunk-KTDJ5JTE.js → chunk-SPUUOEW2.js} +273 -54
  15. package/dist/chunk-SPUUOEW2.js.map +1 -0
  16. package/dist/{chunk-XWBFWUY2.js → chunk-Y6PUCLOE.js} +2 -2
  17. package/dist/{dist-VAATGBAR.js → dist-EKSNZHDY.js} +13 -3
  18. package/dist/{dist-TEKY3GFT.js → dist-FTCDWRAL.js} +18 -7
  19. package/dist/dist-FTCDWRAL.js.map +1 -0
  20. package/dist/{dist-CNABE32V.js → dist-PRDYMXCX.js} +10 -5
  21. package/dist/dist-PRDYMXCX.js.map +1 -0
  22. package/dist/{dist-BO2R55FX.js → dist-U2BHTWG4.js} +17 -5
  23. package/dist/dist-U2BHTWG4.js.map +1 -0
  24. package/dist/{dist-CROGTJ7N.js → dist-VQSZVBT3.js} +20 -6
  25. package/dist/dist-VQSZVBT3.js.map +1 -0
  26. package/dist/index.js +1009 -449
  27. package/dist/index.js.map +1 -1
  28. package/dist/{prepared-state-MQHD3M5F-OVABNV66.js → prepared-state-MQHD3M5F-5ZMCNY43.js} +2 -2
  29. package/package.json +3 -3
  30. package/runtime/docker/apps/cli/share/agentbox-setup/SKILL.md +1 -1
  31. package/runtime/docker/packages/ctl/dist/bin.cjs +142 -110
  32. package/runtime/docker/packages/sandbox-docker/scripts/agentbox-dockerd-start +13 -0
  33. package/runtime/e2b/agentbox-setup-skill.md +1 -1
  34. package/runtime/e2b/ctl.cjs +142 -110
  35. package/runtime/hetzner/agentbox-dockerd-start +13 -0
  36. package/runtime/hetzner/agentbox-setup-skill.md +1 -1
  37. package/runtime/hetzner/ctl.cjs +142 -110
  38. package/runtime/relay/bin.cjs +270 -66
  39. package/runtime/vercel/agentbox-dockerd-start +145 -0
  40. package/runtime/vercel/agentbox-setup-skill.md +1 -1
  41. package/runtime/vercel/ctl.cjs +142 -110
  42. package/runtime/vercel/custom-system-CLAUDE.md +5 -4
  43. package/runtime/vercel/scripts/provision.sh +20 -5
  44. package/share/agentbox-setup/SKILL.md +1 -1
  45. package/share/host-skills/agentbox/SKILL.md +2 -2
  46. package/share/host-skills/codex/agentbox.md +10 -2
  47. package/dist/chunk-6QFPYU4Z.js.map +0 -1
  48. package/dist/chunk-HFQZJO73.js.map +0 -1
  49. package/dist/chunk-KTDJ5JTE.js.map +0 -1
  50. package/dist/chunk-YUGLNTT2.js.map +0 -1
  51. package/dist/dist-BO2R55FX.js.map +0 -1
  52. package/dist/dist-CNABE32V.js.map +0 -1
  53. package/dist/dist-CROGTJ7N.js.map +0 -1
  54. package/dist/dist-TEKY3GFT.js.map +0 -1
  55. /package/dist/{_cloud-attach-RUD4W33P.js.map → _cloud-attach-YM2KOWHO.js.map} +0 -0
  56. /package/dist/{chunk-46NXCJ6Z.js.map → chunk-NXX3KQZ6.js.map} +0 -0
  57. /package/dist/{chunk-3JXSW6PN.js.map → chunk-P6UT5XGE.js.map} +0 -0
  58. /package/dist/{chunk-XWBFWUY2.js.map → chunk-Y6PUCLOE.js.map} +0 -0
  59. /package/dist/{dist-VAATGBAR.js.map → dist-EKSNZHDY.js.map} +0 -0
  60. /package/dist/{prepared-state-MQHD3M5F-OVABNV66.js.map → prepared-state-MQHD3M5F-5ZMCNY43.js.map} +0 -0
@@ -3114,7 +3114,7 @@ var init_chunk_YVJLTAM3 = __esm({
3114
3114
  stderr: result.stderr
3115
3115
  };
3116
3116
  const payload = JSON.stringify(body);
3117
- await new Promise((resolve2, reject) => {
3117
+ await new Promise((resolve3, reject) => {
3118
3118
  const headers = {
3119
3119
  "Content-Type": "application/json",
3120
3120
  "Content-Length": Buffer.byteLength(payload).toString(),
@@ -3134,7 +3134,7 @@ var init_chunk_YVJLTAM3 = __esm({
3134
3134
  },
3135
3135
  (res) => {
3136
3136
  res.resume();
3137
- if ((res.statusCode ?? 0) >= 200 && (res.statusCode ?? 0) < 300) resolve2();
3137
+ if ((res.statusCode ?? 0) >= 200 && (res.statusCode ?? 0) < 300) resolve3();
3138
3138
  else reject(new Error(`bridge/action-result \u2192 ${String(res.statusCode)}`));
3139
3139
  }
3140
3140
  );
@@ -3239,7 +3239,7 @@ var init_chunk_YVJLTAM3 = __esm({
3239
3239
  const transport = isHttps ? import_https.request : import_http.request;
3240
3240
  const port = url.port.length > 0 ? Number.parseInt(url.port, 10) : isHttps ? 443 : 80;
3241
3241
  const timeoutMs = this.fastModePolls > 0 ? FAST_REQUEST_TIMEOUT_MS : REQUEST_TIMEOUT_MS;
3242
- return new Promise((resolve2, reject) => {
3242
+ return new Promise((resolve3, reject) => {
3243
3243
  const headers = {
3244
3244
  Authorization: `Bearer ${this.deps.bridgeToken}`,
3245
3245
  Accept: "application/json"
@@ -3268,7 +3268,7 @@ var init_chunk_YVJLTAM3 = __esm({
3268
3268
  }
3269
3269
  try {
3270
3270
  const parsed = JSON.parse(text);
3271
- resolve2({
3271
+ resolve3({
3272
3272
  actions: Array.isArray(parsed.actions) ? parsed.actions : [],
3273
3273
  events: Array.isArray(parsed.events) ? parsed.events : [],
3274
3274
  status: parsed.status ?? null,
@@ -10744,12 +10744,12 @@ var require_isexe = __commonJS({
10744
10744
  if (typeof Promise !== "function") {
10745
10745
  throw new TypeError("callback not provided");
10746
10746
  }
10747
- return new Promise(function(resolve2, reject) {
10747
+ return new Promise(function(resolve3, reject) {
10748
10748
  isexe(path6, options || {}, function(er, is) {
10749
10749
  if (er) {
10750
10750
  reject(er);
10751
10751
  } else {
10752
- resolve2(is);
10752
+ resolve3(is);
10753
10753
  }
10754
10754
  });
10755
10755
  });
@@ -10816,27 +10816,27 @@ var require_which = __commonJS({
10816
10816
  opt = {};
10817
10817
  const { pathEnv, pathExt, pathExtExe } = getPathInfo(cmd, opt);
10818
10818
  const found = [];
10819
- const step = (i2) => new Promise((resolve2, reject) => {
10819
+ const step = (i2) => new Promise((resolve3, reject) => {
10820
10820
  if (i2 === pathEnv.length)
10821
- return opt.all && found.length ? resolve2(found) : reject(getNotFoundError(cmd));
10821
+ return opt.all && found.length ? resolve3(found) : reject(getNotFoundError(cmd));
10822
10822
  const ppRaw = pathEnv[i2];
10823
10823
  const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw;
10824
10824
  const pCmd = path6.join(pathPart, cmd);
10825
10825
  const p = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd : pCmd;
10826
- resolve2(subStep(p, i2, 0));
10826
+ resolve3(subStep(p, i2, 0));
10827
10827
  });
10828
- const subStep = (p, i2, ii) => new Promise((resolve2, reject) => {
10828
+ const subStep = (p, i2, ii) => new Promise((resolve3, reject) => {
10829
10829
  if (ii === pathExt.length)
10830
- return resolve2(step(i2 + 1));
10830
+ return resolve3(step(i2 + 1));
10831
10831
  const ext = pathExt[ii];
10832
10832
  isexe(p + ext, { pathExt: pathExtExe }, (er, is) => {
10833
10833
  if (!er && is) {
10834
10834
  if (opt.all)
10835
10835
  found.push(p + ext);
10836
10836
  else
10837
- return resolve2(p + ext);
10837
+ return resolve3(p + ext);
10838
10838
  }
10839
- return resolve2(subStep(p, i2, ii + 1));
10839
+ return resolve3(subStep(p, i2, ii + 1));
10840
10840
  });
10841
10841
  });
10842
10842
  return cb ? step(0).then((res) => cb(null, res), cb) : step(0);
@@ -11201,14 +11201,14 @@ async function tryReviveDaemon(socketPath) {
11201
11201
  }
11202
11202
  async function connectOnce(opts) {
11203
11203
  const sock = (0, import_node_net.createConnection)(opts.socketPath);
11204
- await new Promise((resolve2, reject) => {
11204
+ await new Promise((resolve3, reject) => {
11205
11205
  const timer = setTimeout(() => {
11206
11206
  sock.destroy();
11207
11207
  reject(new Error(`connect ${opts.socketPath} timed out`));
11208
11208
  }, opts.timeoutMs ?? 3e3);
11209
11209
  sock.once("connect", () => {
11210
11210
  clearTimeout(timer);
11211
- resolve2();
11211
+ resolve3();
11212
11212
  });
11213
11213
  sock.once("error", (err) => {
11214
11214
  clearTimeout(timer);
@@ -11443,33 +11443,33 @@ function normalizeQuestion(raw) {
11443
11443
  return out;
11444
11444
  }
11445
11445
  function readStdinJson() {
11446
- return new Promise((resolve2) => {
11446
+ return new Promise((resolve3) => {
11447
11447
  if (process.stdin.isTTY) {
11448
- resolve2(null);
11448
+ resolve3(null);
11449
11449
  return;
11450
11450
  }
11451
11451
  const chunks = [];
11452
11452
  const cap = setTimeout(() => {
11453
11453
  process.stdin.removeAllListeners();
11454
- resolve2(null);
11454
+ resolve3(null);
11455
11455
  }, 1e3);
11456
11456
  cap.unref();
11457
11457
  process.stdin.on("data", (b) => chunks.push(b));
11458
11458
  process.stdin.on("end", () => {
11459
11459
  clearTimeout(cap);
11460
11460
  if (chunks.length === 0) {
11461
- resolve2(null);
11461
+ resolve3(null);
11462
11462
  return;
11463
11463
  }
11464
11464
  try {
11465
- resolve2(JSON.parse(Buffer.concat(chunks).toString("utf8")));
11465
+ resolve3(JSON.parse(Buffer.concat(chunks).toString("utf8")));
11466
11466
  } catch {
11467
- resolve2(null);
11467
+ resolve3(null);
11468
11468
  }
11469
11469
  });
11470
11470
  process.stdin.on("error", () => {
11471
11471
  clearTimeout(cap);
11472
- resolve2(null);
11472
+ resolve3(null);
11473
11473
  });
11474
11474
  });
11475
11475
  }
@@ -11511,7 +11511,7 @@ function postRpc(method, params, opts = {}) {
11511
11511
  const isHttps = url.protocol === "https:";
11512
11512
  const transport = isHttps ? import_node_https.request : import_node_http.request;
11513
11513
  const port = url.port.length > 0 ? Number.parseInt(url.port, 10) : isHttps ? 443 : 80;
11514
- return new Promise((resolve2) => {
11514
+ return new Promise((resolve3) => {
11515
11515
  const req = transport(
11516
11516
  {
11517
11517
  host: url.hostname,
@@ -11539,14 +11539,14 @@ function postRpc(method, params, opts = {}) {
11539
11539
  } catch {
11540
11540
  parsed = null;
11541
11541
  }
11542
- resolve2({ status: status2, parsed, raw: text, internalExitCode: null });
11542
+ resolve3({ status: status2, parsed, raw: text, internalExitCode: null });
11543
11543
  });
11544
11544
  }
11545
11545
  );
11546
11546
  req.on("error", (err) => {
11547
11547
  process.stderr.write(`${prefix}: ${String(err.message ?? err)}
11548
11548
  `);
11549
- resolve2({ status: 0, parsed: null, raw: "", internalExitCode: 126 });
11549
+ resolve3({ status: 0, parsed: null, raw: "", internalExitCode: 126 });
11550
11550
  });
11551
11551
  req.write(body);
11552
11552
  req.end();
@@ -11580,14 +11580,14 @@ function buildCpParams(boxPath, hostPath, opts) {
11580
11580
  return params;
11581
11581
  }
11582
11582
  var cpCommand = new Command("cp").description("Copy a file/dir between this box and the host (gated by user prompt on the host wrapper)").addCommand(
11583
- new Command("toHost").description("Copy box:<boxPath> -> host:<hostPath>").argument("<boxPath>", "source path inside the container").argument("<hostPath>", "destination path on the host").option("--no-recursive", "reserved; current implementation is always recursive (docker cp -a)").option("--exclude <pattern>", "exclude paths matching <pattern> (repeatable)", collectExclude, []).option("--no-default-excludes", "keep heavy dirs the host drops by default (.git, node_modules, ...)").option("-y, --yes", "copy even if the source is over the host size limit").action(async (boxPath, hostPath, opts) => {
11583
+ new Command("toHost").description("Copy box:<boxPath> -> host:<hostPath>").argument("<boxPath>", "source path inside the container").argument("<hostPath>", "destination on the host (relative resolves against the box workspace)").option("--no-recursive", "reserved; current implementation is always recursive (docker cp -a)").option("--exclude <pattern>", "exclude paths matching <pattern> (repeatable)", collectExclude, []).option("--no-default-excludes", "keep heavy dirs the host drops by default (.git, node_modules, ...)").option("-y, --yes", "copy even if the source is over the host size limit").action(async (boxPath, hostPath, opts) => {
11584
11584
  const code = await postRpcAndExit("cp.toHost", buildCpParams(boxPath, hostPath, opts), {
11585
11585
  errorPrefix: "agentbox-ctl cp"
11586
11586
  });
11587
11587
  process.exit(code);
11588
11588
  })
11589
11589
  ).addCommand(
11590
- new Command("fromHost").description("Copy host:<hostPath> -> box:<boxPath>").argument("<hostPath>", "source path on the host").argument("<boxPath>", "destination path inside the container").option("--no-recursive", "reserved; current implementation is always recursive (docker cp -a)").option("--exclude <pattern>", "exclude paths matching <pattern> (repeatable)", collectExclude, []).option("--no-default-excludes", "keep heavy dirs the host drops by default (.git, node_modules, ...)").option("-y, --yes", "copy even if the source is over the host size limit").action(async (hostPath, boxPath, opts) => {
11590
+ new Command("fromHost").description("Copy host:<hostPath> -> box:<boxPath>").argument("<hostPath>", "source on the host (relative resolves against the box workspace)").argument("<boxPath>", "destination path inside the container").option("--no-recursive", "reserved; current implementation is always recursive (docker cp -a)").option("--exclude <pattern>", "exclude paths matching <pattern> (repeatable)", collectExclude, []).option("--no-default-excludes", "keep heavy dirs the host drops by default (.git, node_modules, ...)").option("-y, --yes", "copy even if the source is over the host size limit").action(async (hostPath, boxPath, opts) => {
11591
11591
  const code = await postRpcAndExit("cp.fromHost", buildCpParams(boxPath, hostPath, opts), {
11592
11592
  errorPrefix: "agentbox-ctl cp"
11593
11593
  });
@@ -11687,7 +11687,8 @@ var BUILT_IN_DEFAULTS = {
11687
11687
  },
11688
11688
  attach: {
11689
11689
  openIn: "split",
11690
- cmuxStatus: true
11690
+ cmuxStatus: true,
11691
+ herdrStatus: true
11691
11692
  },
11692
11693
  code: {
11693
11694
  ide: "auto",
@@ -11991,13 +11992,18 @@ var KEY_REGISTRY = [
11991
11992
  key: "attach.openIn",
11992
11993
  type: "enum",
11993
11994
  enumValues: ["split", "window", "tab", "same"],
11994
- 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 pane, same workspace / new iTerm2 tab), or `same` (attach inline in the current terminal). Outside tmux/cmux/iTerm2 every value behaves like `same`."
11995
+ 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`."
11995
11996
  },
11996
11997
  {
11997
11998
  key: "attach.cmuxStatus",
11998
11999
  type: "bool",
11999
12000
  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."
12000
12001
  },
12002
+ {
12003
+ key: "attach.herdrStatus",
12004
+ type: "bool",
12005
+ 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."
12006
+ },
12001
12007
  {
12002
12008
  key: "code.ide",
12003
12009
  type: "enum",
@@ -12108,7 +12114,7 @@ var KEY_REGISTRY = [
12108
12114
  key: "queue.openIn",
12109
12115
  type: "enum",
12110
12116
  enumValues: ["none", "split", "window", "tab"],
12111
- 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."
12117
+ 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."
12112
12118
  },
12113
12119
  {
12114
12120
  key: "cloud.useCurrentBranch",
@@ -14004,8 +14010,8 @@ var disconnect = (anyProcess) => {
14004
14010
  // ../../node_modules/.pnpm/execa@9.6.1/node_modules/execa/lib/utils/deferred.js
14005
14011
  var createDeferred = () => {
14006
14012
  const methods = {};
14007
- const promise = new Promise((resolve2, reject) => {
14008
- Object.assign(methods, { resolve: resolve2, reject });
14013
+ const promise = new Promise((resolve3, reject) => {
14014
+ Object.assign(methods, { resolve: resolve3, reject });
14009
14015
  });
14010
14016
  return Object.assign(promise, methods);
14011
14017
  };
@@ -18642,11 +18648,11 @@ var addConcurrentStream = (concurrentStreams, stream, waitName) => {
18642
18648
  const promises = weakMap.get(stream);
18643
18649
  const promise = createDeferred();
18644
18650
  promises.push(promise);
18645
- const resolve2 = promise.resolve.bind(promise);
18646
- return { resolve: resolve2, promises };
18651
+ const resolve3 = promise.resolve.bind(promise);
18652
+ return { resolve: resolve3, promises };
18647
18653
  };
18648
- var waitForConcurrentStreams = async ({ resolve: resolve2, promises }, subprocess) => {
18649
- resolve2();
18654
+ var waitForConcurrentStreams = async ({ resolve: resolve3, promises }, subprocess) => {
18655
+ resolve3();
18650
18656
  const [isSubprocessExit] = await Promise.race([
18651
18657
  Promise.allSettled([true, subprocess]),
18652
18658
  Promise.all([false, ...promises])
@@ -19248,8 +19254,11 @@ var PLACEHOLDER_KEYS = [
19248
19254
  "AGENTBOX_BOX_KIND",
19249
19255
  "AGENTBOX_HOST_WORKSPACE",
19250
19256
  "AGENTBOX_PROJECT_ROOT",
19251
- // Convenience: the portless host this box publishes (`<box-name>.localhost`).
19252
- // Derived from AGENTBOX_BOX_NAME when not set explicitly.
19257
+ // Convenience: the host this box is reachable at. Derived from
19258
+ // AGENTBOX_BOX_NAME as `<box-name>.localhost` when not set explicitly (the
19259
+ // portless host for docker/hetzner). Public-URL cloud providers
19260
+ // (vercel/daytona/e2b) set it explicitly at boot to the real preview host
19261
+ // (e.g. `<sub>.vercel.run`), which then wins over the derived fallback.
19253
19262
  "AGENTBOX_BOX_HOST"
19254
19263
  ];
19255
19264
  var PLACEHOLDER_SET = new Set(PLACEHOLDER_KEYS);
@@ -19759,8 +19768,8 @@ var HostActionQueue = class {
19759
19768
  params,
19760
19769
  createdAt: new Date(this.now()).toISOString()
19761
19770
  };
19762
- return new Promise((resolve2) => {
19763
- this.map.set(id, { action, resolve: resolve2, delivered: false });
19771
+ return new Promise((resolve22) => {
19772
+ this.map.set(id, { action, resolve: resolve22, delivered: false });
19764
19773
  });
19765
19774
  }
19766
19775
  /**
@@ -19893,11 +19902,11 @@ var PendingPrompts = class {
19893
19902
  return true;
19894
19903
  }
19895
19904
  add(boxId, ev) {
19896
- return new Promise((resolve2) => {
19905
+ return new Promise((resolve22) => {
19897
19906
  this.entries.set(ev.id, {
19898
19907
  ev,
19899
19908
  boxId,
19900
- resolve: resolve2,
19909
+ resolve: resolve22,
19901
19910
  createdAt: (/* @__PURE__ */ new Date()).toISOString()
19902
19911
  });
19903
19912
  });
@@ -20204,7 +20213,7 @@ function runHostBinary(connector, argv, cwd, timeoutMs) {
20204
20213
  `
20205
20214
  });
20206
20215
  }
20207
- return new Promise((resolve2) => {
20216
+ return new Promise((resolve22) => {
20208
20217
  const child = (0, import_child_process.spawn)(connector.hostBin, [...argv], {
20209
20218
  cwd,
20210
20219
  env,
@@ -20216,7 +20225,7 @@ function runHostBinary(connector, argv, cwd, timeoutMs) {
20216
20225
  const finish = (exitCode) => {
20217
20226
  if (settled) return;
20218
20227
  settled = true;
20219
- resolve2({ exitCode, stdout, stderr });
20228
+ resolve22({ exitCode, stdout, stderr });
20220
20229
  };
20221
20230
  const timer = setTimeout(() => {
20222
20231
  child.kill("SIGTERM");
@@ -20421,7 +20430,7 @@ async function probeGh() {
20421
20430
  return null;
20422
20431
  }
20423
20432
  function runHostGh(args, cwd, timeoutMs = GH_RPC_TIMEOUT_MS) {
20424
- return new Promise((resolve2) => {
20433
+ return new Promise((resolve22) => {
20425
20434
  const child = (0, import_child_process2.spawn)("gh", args, {
20426
20435
  cwd,
20427
20436
  env: process.env,
@@ -20433,7 +20442,7 @@ function runHostGh(args, cwd, timeoutMs = GH_RPC_TIMEOUT_MS) {
20433
20442
  const finish = (exitCode) => {
20434
20443
  if (settled) return;
20435
20444
  settled = true;
20436
- resolve2({ exitCode, stdout, stderr });
20445
+ resolve22({ exitCode, stdout, stderr });
20437
20446
  };
20438
20447
  const timer = setTimeout(() => {
20439
20448
  child.kill("SIGTERM");
@@ -20497,7 +20506,7 @@ async function checkoutGuards(hostMainRepo, registeredBranches) {
20497
20506
  return null;
20498
20507
  }
20499
20508
  function runGitProbe(args) {
20500
- return new Promise((resolve2) => {
20509
+ return new Promise((resolve22) => {
20501
20510
  const child = (0, import_child_process2.spawn)("git", args, { env: process.env, stdio: ["ignore", "pipe", "pipe"] });
20502
20511
  let stdout = "";
20503
20512
  let stderr = "";
@@ -20508,10 +20517,10 @@ function runGitProbe(args) {
20508
20517
  stderr += c3.toString("utf8");
20509
20518
  });
20510
20519
  child.on("error", (err) => {
20511
- resolve2({ exitCode: 127, stdout, stderr: stderr + String(err.message ?? err) });
20520
+ resolve22({ exitCode: 127, stdout, stderr: stderr + String(err.message ?? err) });
20512
20521
  });
20513
20522
  child.on("close", (code) => {
20514
- resolve2({ exitCode: code ?? -1, stdout, stderr });
20523
+ resolve22({ exitCode: code ?? -1, stdout, stderr });
20515
20524
  });
20516
20525
  });
20517
20526
  }
@@ -20938,6 +20947,17 @@ async function lookupCloudBox(boxId) {
20938
20947
  }
20939
20948
  return { workspacePath: hit.box.workspacePath, cloudSandboxId: sid };
20940
20949
  }
20950
+ async function boxWorkspacePath(boxId) {
20951
+ const state = await readState();
20952
+ const hit = findBox(boxId, state);
20953
+ return hit.kind === "ok" ? hit.box.workspacePath : void 0;
20954
+ }
20955
+ function resolveHostPath(workspacePath, hostPath) {
20956
+ if ((0, import_path5.isAbsolute)(hostPath)) return hostPath;
20957
+ if (hostPath === "~") return (0, import_os4.homedir)();
20958
+ if (hostPath.startsWith("~/")) return (0, import_path5.join)((0, import_os4.homedir)(), hostPath.slice(2));
20959
+ return workspacePath ? (0, import_path5.resolve)(workspacePath, hostPath) : (0, import_path5.resolve)(hostPath);
20960
+ }
20941
20961
  var cloudCpModule;
20942
20962
  async function loadCloudCp() {
20943
20963
  if (cloudCpModule) return cloudCpModule;
@@ -20966,27 +20986,28 @@ async function runCpRpc(action, deps) {
20966
20986
  };
20967
20987
  }
20968
20988
  const direction = action.method === "cp.toHost" ? "box -> host" : "host -> box";
20989
+ const lookup = await lookupCloudBox(deps.boxId);
20990
+ const hostAbs = resolveHostPath(lookup.workspacePath, params.hostPath);
20969
20991
  if (deps.prompts && deps.subscribers) {
20970
20992
  const verdict = await askPrompt(deps.prompts, deps.subscribers, deps.boxId, {
20971
20993
  kind: "confirm",
20972
20994
  message: `Allow cp (${direction}) on ${deps.boxName ?? deps.boxId}?`,
20973
- detail: action.method === "cp.toHost" ? `${params.boxPath} -> ${params.hostPath}` : `${params.hostPath} -> ${params.boxPath}`,
20995
+ detail: action.method === "cp.toHost" ? `${params.boxPath} -> ${hostAbs}` : `${hostAbs} -> ${params.boxPath}`,
20974
20996
  defaultAnswer: "n",
20975
20997
  context: {
20976
20998
  command: action.method,
20977
- argv: [params.boxPath, params.hostPath]
20999
+ argv: [params.boxPath, hostAbs]
20978
21000
  }
20979
21001
  });
20980
21002
  if (verdict.answer !== "y") {
20981
21003
  return { exitCode: 10, stdout: "", stderr: "denied by user\n" };
20982
21004
  }
20983
21005
  }
20984
- const lookup = await lookupCloudBox(deps.boxId);
20985
21006
  const backend = await resolveCloudBackend(deps.backendName);
20986
21007
  const handle = { sandboxId: lookup.cloudSandboxId };
20987
21008
  const cp = await loadCloudCp();
20988
21009
  try {
20989
- const result = action.method === "cp.toHost" ? await cp.downloadFromCloudBox(backend, handle, params.boxPath, params.hostPath) : await cp.uploadToCloudBox(backend, handle, params.hostPath, params.boxPath);
21010
+ const result = action.method === "cp.toHost" ? await cp.downloadFromCloudBox(backend, handle, params.boxPath, hostAbs) : await cp.uploadToCloudBox(backend, handle, hostAbs, params.boxPath);
20990
21011
  return { exitCode: 0, stdout: `${result.finalPath}
20991
21012
  `, stderr: "" };
20992
21013
  } catch (err) {
@@ -21062,7 +21083,7 @@ async function runDownloadRpc(action, deps) {
21062
21083
  const backend = await resolveCloudBackend(deps.backendName);
21063
21084
  const handle = { sandboxId: lookup.cloudSandboxId };
21064
21085
  const cp = await loadCloudCp();
21065
- const hostDst = typeof params.hostPath === "string" && params.hostPath.length > 0 ? params.hostPath : lookup.workspacePath;
21086
+ const hostDst = typeof params.hostPath === "string" && params.hostPath.length > 0 ? resolveHostPath(lookup.workspacePath, params.hostPath) : lookup.workspacePath;
21066
21087
  try {
21067
21088
  const result = await cp.pullCloudDirContents(backend, handle, "/workspace", hostDst);
21068
21089
  return { exitCode: 0, stdout: `${result.finalPath}
@@ -21296,7 +21317,7 @@ function send(res, status2, body, contentType = "application/json") {
21296
21317
  }
21297
21318
  }
21298
21319
  async function readJsonBody(req) {
21299
- return new Promise((resolve2, reject) => {
21320
+ return new Promise((resolve22, reject) => {
21300
21321
  let total = 0;
21301
21322
  const chunks = [];
21302
21323
  req.on("data", (chunk) => {
@@ -21311,11 +21332,11 @@ async function readJsonBody(req) {
21311
21332
  req.on("end", () => {
21312
21333
  const text = Buffer.concat(chunks).toString("utf8");
21313
21334
  if (text.length === 0) {
21314
- resolve2({});
21335
+ resolve22({});
21315
21336
  return;
21316
21337
  }
21317
21338
  try {
21318
- resolve2(JSON.parse(text));
21339
+ resolve22(JSON.parse(text));
21319
21340
  } catch (err) {
21320
21341
  reject(err instanceof Error ? err : new Error(String(err)));
21321
21342
  }
@@ -21549,7 +21570,9 @@ function createRelayServer(opts) {
21549
21570
  return;
21550
21571
  }
21551
21572
  const direction = body.method === "cp.toHost" ? "box -> host" : "host -> box";
21552
- const pathDetail = body.method === "cp.toHost" ? `${params.boxPath} -> ${params.hostPath}` : `${params.hostPath} -> ${params.boxPath}`;
21573
+ const workspacePath = await boxWorkspacePath(reg.boxId);
21574
+ const hostAbs = resolveHostPath(workspacePath, params.hostPath);
21575
+ const pathDetail = body.method === "cp.toHost" ? `${params.boxPath} -> ${hostAbs}` : `${hostAbs} -> ${params.boxPath}`;
21553
21576
  const detailParts = [pathDetail];
21554
21577
  if (params.exclude && params.exclude.length > 0) {
21555
21578
  detailParts.push(`exclude: ${params.exclude.join(", ")}`);
@@ -21563,14 +21586,17 @@ function createRelayServer(opts) {
21563
21586
  defaultAnswer: "n",
21564
21587
  context: {
21565
21588
  command: body.method,
21566
- argv: [params.boxPath, params.hostPath]
21589
+ argv: [params.boxPath, hostAbs]
21567
21590
  }
21568
21591
  });
21569
21592
  if (verdict.answer !== "y") {
21570
21593
  send(res, 500, { exitCode: 10, stdout: "", stderr: "denied by user\n" });
21571
21594
  return;
21572
21595
  }
21573
- const result = await handleCpRpc(reg, body.method, params);
21596
+ const result = await handleCpRpc(reg, body.method, params, {
21597
+ hostPath: hostAbs,
21598
+ cwd: workspacePath
21599
+ });
21574
21600
  const status2 = result.exitCode === 0 ? 200 : 500;
21575
21601
  send(res, status2, result);
21576
21602
  return;
@@ -22001,10 +22027,10 @@ data: {"ts":"${(/* @__PURE__ */ new Date()).toISOString()}"}
22001
22027
  },
22002
22028
  close: async () => {
22003
22029
  if (pollers) await pollers.stopAll();
22004
- await new Promise((resolve2, reject) => {
22030
+ await new Promise((resolve22, reject) => {
22005
22031
  server.close((err) => {
22006
22032
  if (err) reject(err);
22007
- else resolve2();
22033
+ else resolve22();
22008
22034
  });
22009
22035
  });
22010
22036
  }
@@ -22241,7 +22267,7 @@ async function handleIntegrationRpc(method, reg, params, prompts, subscribers, h
22241
22267
  }
22242
22268
  return runHostIntegration(connector, opDesc, args, worktree.hostMainRepo);
22243
22269
  }
22244
- async function handleCpRpc(reg, method, params) {
22270
+ async function handleCpRpc(reg, method, params, opts) {
22245
22271
  const entry = process.env.AGENTBOX_CLI_ENTRY;
22246
22272
  if (!entry) {
22247
22273
  return {
@@ -22255,8 +22281,8 @@ async function handleCpRpc(reg, method, params) {
22255
22281
  for (const pat of params.exclude ?? []) flags.push("--exclude", pat);
22256
22282
  if (params.defaultExcludes === false) flags.push("--no-default-excludes");
22257
22283
  if (params.yes) flags.push("--yes");
22258
- const argv = method === "cp.toHost" ? [process.execPath, entry, "cp", boxRef, params.hostPath, ...flags] : [process.execPath, entry, "cp", params.hostPath, boxRef, ...flags];
22259
- return runHostCommand(argv, CP_RPC_TIMEOUT_MS);
22284
+ const argv = method === "cp.toHost" ? [process.execPath, entry, "cp", boxRef, opts.hostPath, ...flags] : [process.execPath, entry, "cp", opts.hostPath, boxRef, ...flags];
22285
+ return runHostCommand(argv, CP_RPC_TIMEOUT_MS, opts.cwd);
22260
22286
  }
22261
22287
  async function handleDownloadRpc(reg, kind) {
22262
22288
  const entry = process.env.AGENTBOX_CLI_ENTRY;
@@ -22270,7 +22296,8 @@ async function handleDownloadRpc(reg, kind) {
22270
22296
  const argv = [process.execPath, entry, "download"];
22271
22297
  if (kind !== "workspace") argv.push(kind);
22272
22298
  argv.push(reg.name, "-y");
22273
- return runHostCommand(argv, DOWNLOAD_RPC_TIMEOUT_MS);
22299
+ const cwd = await boxWorkspacePath(reg.boxId);
22300
+ return runHostCommand(argv, DOWNLOAD_RPC_TIMEOUT_MS, cwd);
22274
22301
  }
22275
22302
  async function handleCheckpointRpc(reg, params) {
22276
22303
  const entry = process.env.AGENTBOX_CLI_ENTRY;
@@ -22297,16 +22324,20 @@ function isOpenableUrl(value) {
22297
22324
  }
22298
22325
  return url.protocol === "http:" || url.protocol === "https:";
22299
22326
  }
22300
- function runHostCommand(argv, timeoutMs = GIT_RPC_TIMEOUT_MS) {
22301
- return new Promise((resolve2) => {
22327
+ function runHostCommand(argv, timeoutMs = GIT_RPC_TIMEOUT_MS, cwd) {
22328
+ return new Promise((resolve22) => {
22302
22329
  const [cmd, ...rest] = argv;
22303
22330
  if (!cmd) {
22304
- resolve2({ exitCode: 64, stdout: "", stderr: "empty command" });
22331
+ resolve22({ exitCode: 64, stdout: "", stderr: "empty command" });
22305
22332
  return;
22306
22333
  }
22307
22334
  const child = (0, import_child_process3.spawn)(cmd, rest, {
22308
22335
  env: process.env,
22309
- stdio: ["ignore", "pipe", "pipe"]
22336
+ stdio: ["ignore", "pipe", "pipe"],
22337
+ // Default to the relay daemon's CWD when unset (legacy behaviour); callers
22338
+ // that know the box pass its workspace so relative host paths + project
22339
+ // config resolve against the box, not whatever dir launched the relay.
22340
+ ...cwd ? { cwd } : {}
22310
22341
  });
22311
22342
  let stdout = "";
22312
22343
  let stderr = "";
@@ -22314,7 +22345,7 @@ function runHostCommand(argv, timeoutMs = GIT_RPC_TIMEOUT_MS) {
22314
22345
  const finish = (exitCode) => {
22315
22346
  if (settled) return;
22316
22347
  settled = true;
22317
- resolve2({ exitCode, stdout, stderr });
22348
+ resolve22({ exitCode, stdout, stderr });
22318
22349
  };
22319
22350
  const timer = setTimeout(() => {
22320
22351
  child.kill("SIGTERM");
@@ -22342,11 +22373,11 @@ relay: command timed out after ${String(timeoutMs)}ms
22342
22373
  }
22343
22374
  async function startRelayServer(opts) {
22344
22375
  const handle = createRelayServer(opts);
22345
- await new Promise((resolve2, reject) => {
22376
+ await new Promise((resolve22, reject) => {
22346
22377
  handle.server.once("error", reject);
22347
22378
  handle.server.listen(opts.port, opts.host ?? "0.0.0.0", () => {
22348
22379
  handle.server.removeListener("error", reject);
22349
- resolve2();
22380
+ resolve22();
22350
22381
  });
22351
22382
  });
22352
22383
  return handle;
@@ -22355,6 +22386,7 @@ var QUEUE_DIR = (0, import_path6.join)(STATE_DIR2, "queue");
22355
22386
  var TERMINAL_RETENTION_MS = 60 * 60 * 1e3;
22356
22387
  var SWEEP_INTERVAL_MS = 60 * 1e3;
22357
22388
  var QUEUE_LOGS_DIR = (0, import_path6.join)(STATE_DIR2, "logs");
22389
+ var FAILURE_BACKOFF_MS = 5 * 6e4;
22358
22390
 
22359
22391
  // src/config.ts
22360
22392
  var import_promises19 = require("fs/promises");
@@ -23032,16 +23064,16 @@ function matchState(pane) {
23032
23064
  return null;
23033
23065
  }
23034
23066
  function defaultCapturePane(sessionName) {
23035
- return new Promise((resolve2) => {
23067
+ return new Promise((resolve3) => {
23036
23068
  const child = (0, import_node_child_process7.spawn)("tmux", ["capture-pane", "-p", "-t", sessionName], {
23037
23069
  stdio: ["ignore", "pipe", "ignore"]
23038
23070
  });
23039
23071
  let stdout = "";
23040
23072
  child.stdout.on("data", (b) => stdout += b.toString("utf8"));
23041
- child.on("error", () => resolve2(null));
23073
+ child.on("error", () => resolve3(null));
23042
23074
  child.on("close", (code) => {
23043
- if (code === 0) resolve2(stdout);
23044
- else resolve2(null);
23075
+ if (code === 0) resolve3(stdout);
23076
+ else resolve3(null);
23045
23077
  });
23046
23078
  });
23047
23079
  }
@@ -23092,16 +23124,16 @@ function matchWaiting(pane) {
23092
23124
  return WAITING_PATTERNS.some((re) => re.test(region));
23093
23125
  }
23094
23126
  function defaultCapturePane2(sessionName) {
23095
- return new Promise((resolve2) => {
23127
+ return new Promise((resolve3) => {
23096
23128
  const child = (0, import_node_child_process8.spawn)("tmux", ["capture-pane", "-p", "-t", sessionName], {
23097
23129
  stdio: ["ignore", "pipe", "ignore"]
23098
23130
  });
23099
23131
  let stdout = "";
23100
23132
  child.stdout.on("data", (b) => stdout += b.toString("utf8"));
23101
- child.on("error", () => resolve2(null));
23133
+ child.on("error", () => resolve3(null));
23102
23134
  child.on("close", (code) => {
23103
- if (code === 0) resolve2(stdout);
23104
- else resolve2(null);
23135
+ if (code === 0) resolve3(stdout);
23136
+ else resolve3(null);
23105
23137
  });
23106
23138
  });
23107
23139
  }
@@ -23459,13 +23491,13 @@ var ServiceRunner = class extends import_node_events15.EventEmitter {
23459
23491
  const child = this.child;
23460
23492
  if (child && child.exitCode === null) {
23461
23493
  child.kill("SIGTERM");
23462
- await new Promise((resolve2) => {
23494
+ await new Promise((resolve3) => {
23463
23495
  const timer = setTimeout(() => {
23464
23496
  if (child.exitCode === null) child.kill("SIGKILL");
23465
23497
  }, 5e3);
23466
23498
  child.once("exit", () => {
23467
23499
  clearTimeout(timer);
23468
- resolve2();
23500
+ resolve3();
23469
23501
  });
23470
23502
  });
23471
23503
  }
@@ -23726,7 +23758,7 @@ var TaskRunner = class extends import_node_events15.EventEmitter {
23726
23758
  }
23727
23759
  /** Run the `run_once.check` probe. Resolves true when it exits 0. */
23728
23760
  runCheck(command, cwd) {
23729
- return new Promise((resolve2) => {
23761
+ return new Promise((resolve3) => {
23730
23762
  let child;
23731
23763
  try {
23732
23764
  child = this.spawnFn("bash", ["-c", command], {
@@ -23739,7 +23771,7 @@ var TaskRunner = class extends import_node_events15.EventEmitter {
23739
23771
  "stderr",
23740
23772
  `[ctl] run_once check spawn failed: ${err instanceof Error ? err.message : String(err)}`
23741
23773
  );
23742
- resolve2(false);
23774
+ resolve3(false);
23743
23775
  return;
23744
23776
  }
23745
23777
  const onLine = (stream) => (chunk) => {
@@ -23749,8 +23781,8 @@ var TaskRunner = class extends import_node_events15.EventEmitter {
23749
23781
  };
23750
23782
  child.stdout?.on("data", onLine("stdout"));
23751
23783
  child.stderr?.on("data", onLine("stderr"));
23752
- child.on("error", () => resolve2(false));
23753
- child.on("exit", (code) => resolve2(code === 0));
23784
+ child.on("error", () => resolve3(false));
23785
+ child.on("exit", (code) => resolve3(code === 0));
23754
23786
  });
23755
23787
  }
23756
23788
  /** Returns a human reason if the task is already satisfied (skip), else null. */
@@ -24033,11 +24065,11 @@ var Supervisor = class extends import_node_events15.EventEmitter {
24033
24065
  const targets = args.units && args.units.length > 0 ? args.units : this.autostartNames();
24034
24066
  const timeoutMs = args.timeoutMs ?? 6e4;
24035
24067
  if (targets.length === 0 || this.areAllReady(targets)) return { ready: true };
24036
- return new Promise((resolve2) => {
24068
+ return new Promise((resolve3) => {
24037
24069
  const onChange = () => {
24038
24070
  if (this.areAllReady(targets)) {
24039
24071
  cleanup();
24040
- resolve2({ ready: true });
24072
+ resolve3({ ready: true });
24041
24073
  }
24042
24074
  };
24043
24075
  const cleanup = () => {
@@ -24047,7 +24079,7 @@ var Supervisor = class extends import_node_events15.EventEmitter {
24047
24079
  const timer = setTimeout(() => {
24048
24080
  cleanup();
24049
24081
  const d = this.diagnose(targets);
24050
- resolve2({ ready: false, timedOut: d.notYet, failed: d.failed });
24082
+ resolve3({ ready: false, timedOut: d.notYet, failed: d.failed });
24051
24083
  }, timeoutMs);
24052
24084
  this.on("change", onChange);
24053
24085
  });
@@ -24339,14 +24371,14 @@ function sanitizePaneTitle(raw, ctx) {
24339
24371
  return t.length > MAX_TITLE_LEN ? t.slice(0, MAX_TITLE_LEN) : t;
24340
24372
  }
24341
24373
  function runTool(cmd, args) {
24342
- return new Promise((resolve2) => {
24374
+ return new Promise((resolve3) => {
24343
24375
  const child = (0, import_node_child_process10.spawn)(cmd, args, { stdio: ["ignore", "pipe", "pipe"] });
24344
24376
  let stdout = "";
24345
24377
  let stderr = "";
24346
24378
  child.stdout.on("data", (b) => stdout += b.toString("utf8"));
24347
24379
  child.stderr.on("data", (b) => stderr += b.toString("utf8"));
24348
- child.on("error", () => resolve2({ exitCode: 127, stdout, stderr }));
24349
- child.on("close", (code) => resolve2({ exitCode: code ?? -1, stdout, stderr }));
24380
+ child.on("error", () => resolve3({ exitCode: 127, stdout, stderr }));
24381
+ child.on("close", (code) => resolve3({ exitCode: code ?? -1, stdout, stderr }));
24350
24382
  });
24351
24383
  }
24352
24384
  async function probeAgentSession(sessionName) {
@@ -24551,12 +24583,12 @@ async function collectPorts(supervisor) {
24551
24583
  }));
24552
24584
  }
24553
24585
  function run(cmd, args) {
24554
- return new Promise((resolve2) => {
24586
+ return new Promise((resolve3) => {
24555
24587
  const child = (0, import_node_child_process11.spawn)(cmd, args, { stdio: ["ignore", "pipe", "ignore"] });
24556
24588
  let stdout = "";
24557
24589
  child.stdout.on("data", (b) => stdout += b.toString("utf8"));
24558
- child.on("error", () => resolve2({ exitCode: 127, stdout }));
24559
- child.on("close", (code) => resolve2({ exitCode: code ?? -1, stdout }));
24590
+ child.on("error", () => resolve3({ exitCode: 127, stdout }));
24591
+ child.on("close", (code) => resolve3({ exitCode: code ?? -1, stdout }));
24560
24592
  });
24561
24593
  }
24562
24594
  async function discoverListeningPorts() {
@@ -24592,11 +24624,11 @@ async function startServer(opts) {
24592
24624
  sock.end();
24593
24625
  });
24594
24626
  });
24595
- await new Promise((resolve2, reject) => {
24627
+ await new Promise((resolve3, reject) => {
24596
24628
  server.once("error", reject);
24597
24629
  server.listen(opts.socketPath, () => {
24598
24630
  server.removeListener("error", reject);
24599
- resolve2();
24631
+ resolve3();
24600
24632
  });
24601
24633
  });
24602
24634
  await (0, import_promises23.chmod)(opts.socketPath, 432).catch(() => {
@@ -24840,14 +24872,14 @@ function startBoxRelayForwarder(opts) {
24840
24872
  });
24841
24873
  req.pipe(upstreamReq);
24842
24874
  });
24843
- return new Promise((resolve2, reject) => {
24875
+ return new Promise((resolve3, reject) => {
24844
24876
  const onError = (err) => {
24845
24877
  reject(err);
24846
24878
  };
24847
24879
  server.once("error", onError);
24848
24880
  server.listen(opts.port, "127.0.0.1", () => {
24849
24881
  server.removeListener("error", onError);
24850
- resolve2({
24882
+ resolve3({
24851
24883
  url: `http://127.0.0.1:${String(opts.port)}`,
24852
24884
  close: () => new Promise((res) => {
24853
24885
  server.close(() => res());
@@ -25156,26 +25188,26 @@ function buildParams(opts, extra) {
25156
25188
  return params;
25157
25189
  }
25158
25190
  function runLocalGit(args, cwd) {
25159
- return new Promise((resolve2) => {
25191
+ return new Promise((resolve3) => {
25160
25192
  const child = (0, import_node_child_process12.spawn)("git", args, { cwd, stdio: "inherit" });
25161
- child.on("close", (code) => resolve2(code ?? 1));
25193
+ child.on("close", (code) => resolve3(code ?? 1));
25162
25194
  child.on("error", (err) => {
25163
25195
  process.stderr.write(`agentbox-ctl git: ${String(err.message ?? err)}
25164
25196
  `);
25165
- resolve2(126);
25197
+ resolve3(126);
25166
25198
  });
25167
25199
  });
25168
25200
  }
25169
25201
  function hasGitIdentity(cwd) {
25170
- return new Promise((resolve2) => {
25202
+ return new Promise((resolve3) => {
25171
25203
  const child = (0, import_node_child_process12.spawn)("git", ["config", "user.email"], {
25172
25204
  cwd,
25173
25205
  stdio: ["ignore", "pipe", "ignore"]
25174
25206
  });
25175
25207
  let out = "";
25176
25208
  child.stdout.on("data", (c3) => out += c3.toString("utf8"));
25177
- child.on("close", (code) => resolve2(code === 0 && out.trim().length > 0));
25178
- child.on("error", () => resolve2(false));
25209
+ child.on("close", (code) => resolve3(code === 0 && out.trim().length > 0));
25210
+ child.on("error", () => resolve3(false));
25179
25211
  });
25180
25212
  }
25181
25213
  var gitCommand = new Command("git").description("Git operations that need host credentials (routed through the agentbox relay)").addCommand(
@@ -25314,7 +25346,7 @@ function isHttpUrl(value) {
25314
25346
  }
25315
25347
  }
25316
25348
  function openInBoxBrowser(url) {
25317
- return new Promise((resolve2) => {
25349
+ return new Promise((resolve3) => {
25318
25350
  const child = (0, import_node_child_process13.spawn)("agent-browser", ["open", "--headed", url], { stdio: "inherit" });
25319
25351
  const timer = setTimeout(() => {
25320
25352
  child.kill("SIGTERM");
@@ -25322,18 +25354,18 @@ function openInBoxBrowser(url) {
25322
25354
  `agentbox-ctl open: agent-browser timed out after ${String(OPEN_TIMEOUT_MS)}ms
25323
25355
  `
25324
25356
  );
25325
- resolve2(124);
25357
+ resolve3(124);
25326
25358
  }, OPEN_TIMEOUT_MS);
25327
25359
  if (typeof timer.unref === "function") timer.unref();
25328
25360
  child.on("close", (code) => {
25329
25361
  clearTimeout(timer);
25330
- resolve2(code ?? 1);
25362
+ resolve3(code ?? 1);
25331
25363
  });
25332
25364
  child.on("error", (err) => {
25333
25365
  clearTimeout(timer);
25334
25366
  process.stderr.write(`agentbox-ctl open: ${String(err.message ?? err)}
25335
25367
  `);
25336
- resolve2(126);
25368
+ resolve3(126);
25337
25369
  });
25338
25370
  });
25339
25371
  }