@madarco/agentbox 0.17.0 → 0.18.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 (31) hide show
  1. package/CHANGELOG.md +39 -0
  2. package/dist/{_cloud-attach-SGNR6BXP.js → _cloud-attach-3UC3IL62.js} +3 -3
  3. package/dist/{chunk-5AKAC27L.js → chunk-5BO6SGMI.js} +349 -16
  4. package/dist/chunk-5BO6SGMI.js.map +1 -0
  5. package/dist/{chunk-RXPV3OIX.js → chunk-IA6YHH52.js} +18 -14
  6. package/dist/chunk-IA6YHH52.js.map +1 -0
  7. package/dist/{chunk-KTDJ5JTE.js → chunk-OG4KMYOJ.js} +2 -2
  8. package/dist/{chunk-HFQZJO73.js → chunk-U7IZS2ZP.js} +10 -4
  9. package/dist/{chunk-HFQZJO73.js.map → chunk-U7IZS2ZP.js.map} +1 -1
  10. package/dist/{dist-BO2R55FX.js → dist-3UYQZOAO.js} +3 -3
  11. package/dist/{dist-CNABE32V.js → dist-4BHW7DCO.js} +3 -3
  12. package/dist/{dist-TEKY3GFT.js → dist-7BS2JS27.js} +3 -3
  13. package/dist/{dist-VAATGBAR.js → dist-CFSKUAS5.js} +2 -2
  14. package/dist/{dist-433ASGVG.js → dist-T7ESSBCZ.js} +4 -4
  15. package/dist/index.js +677 -277
  16. package/dist/index.js.map +1 -1
  17. package/package.json +5 -5
  18. package/runtime/docker/packages/ctl/dist/bin.cjs +9 -3
  19. package/runtime/e2b/ctl.cjs +9 -3
  20. package/runtime/hetzner/ctl.cjs +9 -3
  21. package/runtime/relay/bin.cjs +9 -3
  22. package/runtime/vercel/ctl.cjs +9 -3
  23. package/dist/chunk-5AKAC27L.js.map +0 -1
  24. package/dist/chunk-RXPV3OIX.js.map +0 -1
  25. /package/dist/{_cloud-attach-SGNR6BXP.js.map → _cloud-attach-3UC3IL62.js.map} +0 -0
  26. /package/dist/{chunk-KTDJ5JTE.js.map → chunk-OG4KMYOJ.js.map} +0 -0
  27. /package/dist/{dist-BO2R55FX.js.map → dist-3UYQZOAO.js.map} +0 -0
  28. /package/dist/{dist-CNABE32V.js.map → dist-4BHW7DCO.js.map} +0 -0
  29. /package/dist/{dist-TEKY3GFT.js.map → dist-7BS2JS27.js.map} +0 -0
  30. /package/dist/{dist-VAATGBAR.js.map → dist-CFSKUAS5.js.map} +0 -0
  31. /package/dist/{dist-433ASGVG.js.map → dist-T7ESSBCZ.js.map} +0 -0
package/CHANGELOG.md CHANGED
@@ -9,6 +9,45 @@ Entries are generated from the commit history with `/release-notes` and then
9
9
  hand-reviewed — they describe what changed for someone using the `agentbox`
10
10
  CLI, not the raw commits.
11
11
 
12
+ ## [0.18.0] - 2026-06-18
13
+
14
+ ### Added
15
+
16
+ - **Herdr integration.** Running `agentbox claude|codex|opencode` inside
17
+ [Herdr](https://herdr.dev) now feels native: each box shows up as a normal
18
+ agent in Herdr's sidebar with live status (working / idle), a pending
19
+ host-relay approval (git push / PR / checkpoint) highlights the box as
20
+ **blocked** and raises a Herdr notification, and `attach.openIn` /
21
+ `queue.openIn` open boxes as Herdr splits, tabs, or workspaces — defaulting to
22
+ a new **tab** under Herdr. New `attach.herdrStatus` config key (default on)
23
+ controls the status reporting.
24
+ - **Herdr plugin** — `agentbox install herdr` (or, from Herdr,
25
+ `herdr plugin install madarco/agentbox/herdr-plugin`) installs a plugin that
26
+ adds a **boxes overlay** (`prefix a`), a **new box** shortcut
27
+ (`prefix shift a`), and **Ctrl+click** a box to open its web app.
28
+ - **Paste screenshots into a box under Herdr.** Pressing **Ctrl+V** with an
29
+ image on the clipboard while attached to a box's Claude now ships the image
30
+ into the box and attaches it (`[Image #1]`) — works on docker and cloud boxes.
31
+ - **GitHub star prompt** — a one-time nudge to star the project, shown after
32
+ `agentbox install` / `agentbox update`.
33
+
34
+ ## [0.17.1] - 2026-06-17
35
+
36
+ ### Fixed
37
+
38
+ - **The CLI no longer crashes on startup with `ERR_REQUIRE_ESM` on Node
39
+ 20.10–20.18.** Every `agentbox` command (not just the `e2b` ones) failed to
40
+ start on Node versions before 20.19, because the bundled E2B SDK loaded an
41
+ ESM-only build of `chalk` that older Node can't `require()`. E2B's `chalk` is
42
+ now pinned to a CommonJS build, so the CLI loads on every supported Node
43
+ (>=20.10).
44
+ - **`agentbox vercel login` (Sign in with Vercel) no longer dead-ends after a
45
+ successful sign-in.** Recent Vercel sandbox CLIs stopped writing the team id
46
+ to their config, so the login harvest reported "no credentials were found in
47
+ the Vercel CLI store" even though a valid token was present. Login now
48
+ resolves the team from `VERCEL_TEAM_ID`, the CLI config, or your account's
49
+ default team.
50
+
12
51
  ## [0.17.0] - 2026-06-15
13
52
 
14
53
  ### Added
@@ -3,8 +3,8 @@ import {
3
3
  buildCloudAttachInnerCommand,
4
4
  cloudAgentAttach,
5
5
  cloudAgentStartDetached
6
- } from "./chunk-5AKAC27L.js";
7
- import "./chunk-HFQZJO73.js";
6
+ } from "./chunk-5BO6SGMI.js";
7
+ import "./chunk-U7IZS2ZP.js";
8
8
  import "./chunk-6QFPYU4Z.js";
9
9
  import "./chunk-G3H2L3O2.js";
10
10
  import "./chunk-WJFZJZIM.js";
@@ -13,4 +13,4 @@ export {
13
13
  cloudAgentAttach,
14
14
  cloudAgentStartDetached
15
15
  };
16
- //# sourceMappingURL=_cloud-attach-SGNR6BXP.js.map
16
+ //# sourceMappingURL=_cloud-attach-3UC3IL62.js.map
@@ -3,7 +3,7 @@ import {
3
3
  DEFAULT_RELAY_PORT,
4
4
  loadEffectiveConfig,
5
5
  readBoxStatus
6
- } from "./chunk-HFQZJO73.js";
6
+ } from "./chunk-U7IZS2ZP.js";
7
7
 
8
8
  // src/commands/_cloud-attach.ts
9
9
  import { spawn as spawn4 } from "child_process";
@@ -20,26 +20,26 @@ function isKnownProvider(name) {
20
20
  async function getProvider(name) {
21
21
  switch (name) {
22
22
  case "docker": {
23
- const mod = await import("./dist-VAATGBAR.js");
23
+ const mod = await import("./dist-CFSKUAS5.js");
24
24
  return mod.dockerProvider;
25
25
  }
26
26
  case "daytona": {
27
- const mod = await import("./dist-TEKY3GFT.js");
27
+ const mod = await import("./dist-7BS2JS27.js");
28
28
  await mod.ensureDaytonaCredentials();
29
29
  return mod.daytonaProvider;
30
30
  }
31
31
  case "hetzner": {
32
- const mod = await import("./dist-CNABE32V.js");
32
+ const mod = await import("./dist-4BHW7DCO.js");
33
33
  await mod.ensureHetznerCredentials();
34
34
  return mod.hetznerProvider;
35
35
  }
36
36
  case "vercel": {
37
- const mod = await import("./dist-433ASGVG.js");
37
+ const mod = await import("./dist-T7ESSBCZ.js");
38
38
  await mod.ensureVercelCredentials();
39
39
  return mod.vercelProvider;
40
40
  }
41
41
  case "e2b": {
42
- const mod = await import("./dist-BO2R55FX.js");
42
+ const mod = await import("./dist-3UYQZOAO.js");
43
43
  await mod.ensureE2bCredentials();
44
44
  return mod.e2bProvider;
45
45
  }
@@ -103,11 +103,105 @@ async function loadPtyBackend() {
103
103
 
104
104
  // src/terminal/host.ts
105
105
  import { spawn } from "child_process";
106
+
107
+ // src/terminal/herdr-socket.ts
108
+ import net from "net";
109
+ function herdrSocketPath(env = process.env) {
110
+ const sock = env["HERDR_SOCKET_PATH"];
111
+ return typeof sock === "string" && sock.length > 0 ? sock : void 0;
112
+ }
113
+ var reqSeq = 0;
114
+ function nextId() {
115
+ reqSeq += 1;
116
+ return `agentbox:${String(reqSeq)}`;
117
+ }
118
+ function herdrSend(method, params, env = process.env) {
119
+ const sock = herdrSocketPath(env);
120
+ if (!sock) return;
121
+ try {
122
+ const client = net.connect(sock);
123
+ client.on("error", () => {
124
+ });
125
+ client.on("connect", () => {
126
+ try {
127
+ client.write(`${JSON.stringify({ id: nextId(), method, params })}
128
+ `);
129
+ } catch {
130
+ }
131
+ client.end();
132
+ });
133
+ } catch {
134
+ }
135
+ }
136
+ function herdrRequest(method, params, env = process.env, timeoutMs = 2e3) {
137
+ const sock = herdrSocketPath(env);
138
+ if (!sock) return Promise.resolve(null);
139
+ return new Promise((resolve) => {
140
+ let settled = false;
141
+ const done = (value) => {
142
+ if (settled) return;
143
+ settled = true;
144
+ try {
145
+ client.destroy();
146
+ } catch {
147
+ }
148
+ resolve(value);
149
+ };
150
+ let buf = "";
151
+ let client;
152
+ try {
153
+ client = net.connect(sock);
154
+ } catch {
155
+ resolve(null);
156
+ return;
157
+ }
158
+ const timer = setTimeout(() => done(null), timeoutMs);
159
+ timer.unref?.();
160
+ client.on("error", () => done(null));
161
+ client.on("close", () => done(null));
162
+ client.on("connect", () => {
163
+ try {
164
+ client.write(`${JSON.stringify({ id: nextId(), method, params })}
165
+ `);
166
+ } catch {
167
+ done(null);
168
+ }
169
+ });
170
+ client.on("data", (chunk) => {
171
+ buf += chunk.toString("utf8");
172
+ const nl = buf.indexOf("\n");
173
+ if (nl === -1) return;
174
+ const line = buf.slice(0, nl);
175
+ try {
176
+ const msg = JSON.parse(line);
177
+ if (msg.error || typeof msg.result !== "object" || msg.result === null) {
178
+ done(null);
179
+ } else {
180
+ clearTimeout(timer);
181
+ done(msg.result);
182
+ }
183
+ } catch {
184
+ done(null);
185
+ }
186
+ });
187
+ });
188
+ }
189
+
190
+ // src/terminal/host.ts
191
+ function hostAwareOpenIn(cfg, env = process.env) {
192
+ const openIn = cfg.effective.attach.openIn;
193
+ if (openIn === "split" && cfg.sources["attach.openIn"] === "default" && detectHostTerminal(env) === "herdr") {
194
+ return "tab";
195
+ }
196
+ return openIn;
197
+ }
106
198
  function detectHostTerminal(env = process.env) {
107
199
  const tmux = env["TMUX"];
108
200
  if (tmux && tmux.length > 0) return "tmux";
109
201
  const cmuxSocket = env["CMUX_SOCKET_PATH"];
110
202
  if (cmuxSocket && cmuxSocket.length > 0) return "cmux";
203
+ const herdrSocket = env["HERDR_SOCKET_PATH"];
204
+ if (herdrSocket && herdrSocket.length > 0) return "herdr";
111
205
  const termProgram = env["TERM_PROGRAM"];
112
206
  if (termProgram === "iTerm.app") return "iterm2";
113
207
  return "unknown";
@@ -129,6 +223,7 @@ function shellJoin(argv) {
129
223
  async function spawnInNewTerminal(args) {
130
224
  if (args.host === "tmux") return spawnInTmux(args);
131
225
  if (args.host === "cmux") return spawnInCmux(args);
226
+ if (args.host === "herdr") return spawnInHerdr(args);
132
227
  return spawnInITerm2(args);
133
228
  }
134
229
  async function spawnInTmux(args) {
@@ -230,6 +325,62 @@ function parseCmuxRef(stdout) {
230
325
  const m = stdout.match(/\b(?:surface|pane):\d+\b/);
231
326
  return m ? m[0] : void 0;
232
327
  }
328
+ function herdrField(result, parent, key) {
329
+ const obj = result?.[parent];
330
+ if (obj && typeof obj === "object") {
331
+ const v = obj[key];
332
+ if (typeof v === "string" && v.length > 0) return v;
333
+ }
334
+ return void 0;
335
+ }
336
+ function extractHerdrPaneId(result) {
337
+ if (!result) return void 0;
338
+ const direct = result["pane_id"];
339
+ if (typeof direct === "string" && /:p\d+$/.test(direct)) return direct;
340
+ for (const parent of ["pane", "root_pane"]) {
341
+ const id = herdrField(result, parent, "pane_id");
342
+ if (id && /:p\d+$/.test(id)) return id;
343
+ }
344
+ const m = JSON.stringify(result).match(/"([^"]*:p\d+)"/);
345
+ return m ? m[1] : void 0;
346
+ }
347
+ async function spawnInHerdr(args) {
348
+ const env = args.env;
349
+ let result;
350
+ let noteKind;
351
+ if (args.mode === "split") {
352
+ const params = { direction: "right", ratio: 0.5 };
353
+ if (args.herdrTargetPane) params["pane_id"] = args.herdrTargetPane;
354
+ result = await herdrRequest("pane.split", params, env);
355
+ noteKind = "Herdr split";
356
+ } else if (args.mode === "tab") {
357
+ const params = {};
358
+ if (args.herdrTargetWorkspace) params["workspace_id"] = args.herdrTargetWorkspace;
359
+ result = await herdrRequest("tab.create", params, env);
360
+ noteKind = "Herdr tab";
361
+ } else {
362
+ result = await herdrRequest("workspace.create", { cwd: args.cwd, label: args.title }, env);
363
+ noteKind = "Herdr workspace";
364
+ }
365
+ const paneId = extractHerdrPaneId(result);
366
+ if (!paneId) {
367
+ return { launched: false, note: "", error: `herdr ${args.mode} gave no pane id` };
368
+ }
369
+ const text = `cd ${shellQuote(args.cwd)} && exec ${shellJoin(args.argv)}
370
+ `;
371
+ const sent = await herdrRequest("pane.send_text", { pane_id: paneId, text }, env);
372
+ if (sent === null) {
373
+ return { launched: false, note: "", error: "herdr pane.send_text failed" };
374
+ }
375
+ if (args.mode === "tab") {
376
+ const tabId = herdrField(result, "tab", "tab_id");
377
+ if (tabId) void herdrRequest("tab.focus", { tab_id: tabId }, env);
378
+ } else if (args.mode === "window") {
379
+ const wsId = herdrField(result, "workspace", "workspace_id");
380
+ if (wsId) void herdrRequest("workspace.focus", { workspace_id: wsId }, env);
381
+ }
382
+ return { launched: true, note: `Attached in new ${noteKind}.` };
383
+ }
233
384
  async function spawnInITerm2(args) {
234
385
  const inner = shellJoin(args.argv);
235
386
  const cmdLine = `cd ${shellQuote(args.cwd)} && exec ${inner}`;
@@ -413,6 +564,78 @@ function restoreCmuxWorkspace(orig) {
413
564
  }
414
565
  }
415
566
 
567
+ // src/terminal/herdr-status.ts
568
+ var AGENT_LABEL2 = {
569
+ claude: "claude",
570
+ codex: "codex",
571
+ opencode: "opencode"
572
+ };
573
+ function mapActivityToAgentState(mode, activity) {
574
+ if (mode === "shell") return null;
575
+ const label = AGENT_LABEL2[mode];
576
+ switch (activity) {
577
+ case "working":
578
+ case "compacting":
579
+ return { state: "working", message: `${label} \xB7 working` };
580
+ case "question":
581
+ case "waiting":
582
+ return { state: "blocked", message: `${label} \xB7 needs input` };
583
+ case "end-plan":
584
+ return { state: "blocked", message: `${label} \xB7 plan ready` };
585
+ case "error":
586
+ return { state: "blocked", message: `${label} \xB7 error` };
587
+ case "idle":
588
+ return { state: "idle", message: `${label} \xB7 idle` };
589
+ case "unknown":
590
+ case void 0:
591
+ default:
592
+ return null;
593
+ }
594
+ }
595
+ function herdrStatusActive(env = process.env) {
596
+ const sock = env["HERDR_SOCKET_PATH"];
597
+ const pane = env["HERDR_PANE_ID"];
598
+ return env["HERDR_ENV"] === "1" && typeof sock === "string" && sock.length > 0 && typeof pane === "string" && pane.length > 0;
599
+ }
600
+ async function herdrStatusEnabled(env = process.env) {
601
+ if (!herdrStatusActive(env)) return false;
602
+ try {
603
+ const cfg = await loadEffectiveConfig(process.cwd());
604
+ return cfg.effective.attach.herdrStatus;
605
+ } catch {
606
+ return true;
607
+ }
608
+ }
609
+ function sendAgentState(mode, boxName, state, message, env) {
610
+ const pane = env["HERDR_PANE_ID"];
611
+ if (!pane) return;
612
+ herdrSend(
613
+ "pane.report_agent",
614
+ { pane_id: pane, source: `agentbox:${mode}`, agent: mode, state, message, custom_status: boxName },
615
+ env
616
+ );
617
+ }
618
+ function reportHerdrAgentState(mode, activity, boxName, env = process.env) {
619
+ const view = mapActivityToAgentState(mode, activity);
620
+ if (!view) return;
621
+ sendAgentState(mode, boxName, view.state, view.message, env);
622
+ }
623
+ function reportHerdrApprovalState(mode, boxName, env = process.env) {
624
+ if (mode === "shell") return;
625
+ sendAgentState(mode, boxName, "blocked", `${AGENT_LABEL2[mode]} \xB7 approval needed`, env);
626
+ }
627
+ function clearHerdrAgentState(mode, boxName, env = process.env) {
628
+ if (mode === "shell") return;
629
+ sendAgentState(mode, boxName, "idle", `${AGENT_LABEL2[mode]} \xB7 detached`, env);
630
+ }
631
+ var NOTIFY_BODY_MAX = 200;
632
+ function notifyHerdrApprovalPrompt(boxName, prompt, env = process.env) {
633
+ const detail = prompt.detail ? ` \u2014 ${prompt.detail}` : "";
634
+ let body = `agentbox \xB7 ${prompt.message}${detail}`;
635
+ if (body.length > NOTIFY_BODY_MAX) body = `${body.slice(0, NOTIFY_BODY_MAX - 1)}\u2026`;
636
+ herdrSend("notification.show", { title: boxName, body, sound: "request" }, env);
637
+ }
638
+
416
639
  // src/terminal/title.ts
417
640
  var ESC = "\x1B";
418
641
  var BEL = "\x07";
@@ -433,6 +656,8 @@ function popTerminalTitle(stream = process.stdout) {
433
656
  }
434
657
 
435
658
  // src/wrapped-pty/input-router.ts
659
+ import { statSync } from "fs";
660
+ import { fileURLToPath } from "url";
436
661
  var KEY_ENTER = 13;
437
662
  var KEY_LF = 10;
438
663
  var KEY_ESC = 27;
@@ -445,6 +670,33 @@ var KEY_LEADER = 1;
445
670
  var KEY_CTRL_V = 22;
446
671
  var KEY_A_LOW = 97;
447
672
  var KEY_V_LOW = 118;
673
+ var BP_START = Buffer.from("\x1B[200~");
674
+ var BP_END = Buffer.from("\x1B[201~");
675
+ function bufHasAt(buf, i, needle) {
676
+ if (i + needle.length > buf.length) return false;
677
+ for (let j = 0; j < needle.length; j++) {
678
+ if (buf[i + j] !== needle[j]) return false;
679
+ }
680
+ return true;
681
+ }
682
+ function looksLikeHostImagePath(raw) {
683
+ let t = raw.trim();
684
+ if (t.length === 0 || /[\r\n]/.test(t)) return null;
685
+ if (t.startsWith("file://")) {
686
+ try {
687
+ t = fileURLToPath(t);
688
+ } catch {
689
+ return null;
690
+ }
691
+ }
692
+ if (!/\.(png|jpe?g|gif|webp|bmp)$/i.test(t)) return null;
693
+ try {
694
+ if (!statSync(t).isFile()) return null;
695
+ } catch {
696
+ return null;
697
+ }
698
+ return t;
699
+ }
448
700
  function parseCsiKey(buf, i) {
449
701
  if (buf[i] !== KEY_ESC || buf[i + 1] !== 91) return null;
450
702
  const params = [];
@@ -494,6 +746,8 @@ function createInputRouter(opts) {
494
746
  const leaderEnabled = Object.keys(leaderChords).length > 0;
495
747
  const onPasteImage = opts.onPasteImage;
496
748
  const pasteEnabled = typeof onPasteImage === "function";
749
+ const onPasteImageFile = opts.onPasteImageFile;
750
+ const pasteFileEnabled = typeof onPasteImageFile === "function";
497
751
  let pasteInFlight = false;
498
752
  const leaderTimeoutMs = opts.leaderTimeoutMs ?? DEFAULT_LEADER_TIMEOUT_MS;
499
753
  const setTimer = opts.setTimer ?? ((ms, fn) => setTimeout(fn, ms));
@@ -581,6 +835,17 @@ function createInputRouter(opts) {
581
835
  };
582
836
  void Promise.resolve().then(() => onPasteImage?.()).then(done, done);
583
837
  };
838
+ const triggerPasteFile = (hostPath) => {
839
+ if (pasteInFlight) return;
840
+ pasteInFlight = true;
841
+ const done = (boxPath) => {
842
+ pasteInFlight = false;
843
+ if (disposed) return;
844
+ const text = boxPath ?? hostPath;
845
+ opts.onForward(Buffer.concat([BP_START, Buffer.from(text, "utf8"), BP_END]));
846
+ };
847
+ void Promise.resolve().then(() => onPasteImageFile?.(hostPath) ?? null).then(done, () => done(null));
848
+ };
584
849
  const feedSteady = (buf) => {
585
850
  let chunkStart = 0;
586
851
  const flushChunk = (end) => {
@@ -650,6 +915,20 @@ function createInputRouter(opts) {
650
915
  triggerPaste(Buffer.from([KEY_CTRL_V]));
651
916
  continue;
652
917
  }
918
+ if (pasteFileEnabled && byte === KEY_ESC && bufHasAt(buf, i, BP_START)) {
919
+ const end = buf.indexOf(BP_END, i + BP_START.length);
920
+ if (end !== -1) {
921
+ const payload = buf.subarray(i + BP_START.length, end).toString("utf8");
922
+ const hostPath = looksLikeHostImagePath(payload);
923
+ if (hostPath) {
924
+ flushChunk(i);
925
+ i = end + BP_END.length;
926
+ chunkStart = i;
927
+ triggerPasteFile(hostPath);
928
+ continue;
929
+ }
930
+ }
931
+ }
653
932
  i += 1;
654
933
  }
655
934
  flushChunk(buf.length);
@@ -674,7 +953,7 @@ function createInputRouter(opts) {
674
953
  }
675
954
  return;
676
955
  }
677
- if (!leaderEnabled && !pasteEnabled) {
956
+ if (!leaderEnabled && !pasteEnabled && !pasteFileEnabled) {
678
957
  opts.onForward(buf);
679
958
  return;
680
959
  }
@@ -1599,6 +1878,33 @@ async function runWrappedAttach(opts) {
1599
1878
  recomputeFooter();
1600
1879
  redrawChrome();
1601
1880
  };
1881
+ const handlePasteImageFile = async (hostPath) => {
1882
+ if (!opts.onPasteImageFile) return null;
1883
+ if (flashTimer) {
1884
+ clearTimeout(flashTimer);
1885
+ flashTimer = null;
1886
+ }
1887
+ flashMessage = "Pasting image\u2026";
1888
+ recomputeFooter();
1889
+ redrawChrome();
1890
+ let boxPath = null;
1891
+ try {
1892
+ boxPath = await opts.onPasteImageFile(hostPath);
1893
+ } catch (e) {
1894
+ logErr(`paste-image-file failed: ${e.message}`);
1895
+ }
1896
+ flashMessage = boxPath ? "Image pasted" : "Image paste failed";
1897
+ flashTimer = setTimeout(() => {
1898
+ flashTimer = null;
1899
+ flashMessage = null;
1900
+ recomputeFooter();
1901
+ redrawChrome();
1902
+ }, FLASH_DURATION_MS);
1903
+ if (typeof flashTimer.unref === "function") flashTimer.unref();
1904
+ recomputeFooter();
1905
+ redrawChrome();
1906
+ return boxPath;
1907
+ };
1602
1908
  const router = createInputRouter({
1603
1909
  onForward: (b) => {
1604
1910
  if (reconnecting) {
@@ -1613,6 +1919,7 @@ async function runWrappedAttach(opts) {
1613
1919
  }
1614
1920
  capturingPrompt = null;
1615
1921
  applyBandChange();
1922
+ if (herdrOn) reportHerdrAgentState(opts.mode, lastActivity, opts.boxName);
1616
1923
  },
1617
1924
  leaderChords,
1618
1925
  onLeaderChange: (open) => {
@@ -1623,7 +1930,8 @@ async function runWrappedAttach(opts) {
1623
1930
  onAction: (name) => {
1624
1931
  runAction(name);
1625
1932
  },
1626
- onPasteImage: opts.onPasteImage ? handlePasteImage : void 0
1933
+ onPasteImage: opts.onPasteImage ? handlePasteImage : void 0,
1934
+ onPasteImageFile: opts.onPasteImageFile ? handlePasteImageFile : void 0
1627
1935
  });
1628
1936
  if (process.stdin.isTTY) process.stdin.setRawMode(true);
1629
1937
  process.stdin.resume();
@@ -1642,12 +1950,24 @@ async function runWrappedAttach(opts) {
1642
1950
  redrawChrome();
1643
1951
  };
1644
1952
  process.stdout.on("resize", onResize);
1953
+ let cmuxOn = false;
1954
+ let cmuxOrig = null;
1955
+ let herdrOn = false;
1956
+ if (opts.mode !== "shell") {
1957
+ cmuxOn = await cmuxStatusEnabled();
1958
+ if (cmuxOn) cmuxOrig = captureCmuxWorkspace();
1959
+ herdrOn = await herdrStatusEnabled();
1960
+ }
1645
1961
  const stream = subscribePrompts({
1646
1962
  relayBaseUrl: opts.relayBaseUrl,
1647
1963
  boxId: opts.boxId,
1648
1964
  onPrompt: (ev) => {
1649
1965
  capturingPrompt = ev;
1650
1966
  applyBandChange();
1967
+ if (herdrOn) {
1968
+ notifyHerdrApprovalPrompt(opts.boxName, ev);
1969
+ reportHerdrApprovalState(opts.mode, opts.boxName);
1970
+ }
1651
1971
  router.capture(ev).catch((e) => {
1652
1972
  const msg = e instanceof Error ? e.message : String(e);
1653
1973
  if (msg !== "resolved-elsewhere") {
@@ -1660,6 +1980,7 @@ async function runWrappedAttach(opts) {
1660
1980
  capturingPrompt = null;
1661
1981
  router.abort("resolved-elsewhere");
1662
1982
  applyBandChange();
1983
+ if (herdrOn) reportHerdrAgentState(opts.mode, lastActivity, opts.boxName);
1663
1984
  }
1664
1985
  },
1665
1986
  onNotice: (ev) => {
@@ -1677,8 +1998,6 @@ async function runWrappedAttach(opts) {
1677
1998
  }
1678
1999
  }
1679
2000
  });
1680
- let cmuxOn = false;
1681
- let cmuxOrig = null;
1682
2001
  const pollStatus = async () => {
1683
2002
  try {
1684
2003
  const status = await readBoxStatus({
@@ -1696,6 +2015,9 @@ async function runWrappedAttach(opts) {
1696
2015
  markCmuxTabAttention(opts.mode, opts.boxName, nextActivity);
1697
2016
  }
1698
2017
  }
2018
+ if (herdrOn && nextActivity !== lastActivity && !capturingPrompt) {
2019
+ reportHerdrAgentState(opts.mode, nextActivity, opts.boxName);
2020
+ }
1699
2021
  const desiredTitle = nextTitle ?? opts.boxName;
1700
2022
  if (desiredTitle !== lastEmittedTitle) {
1701
2023
  lastEmittedTitle = desiredTitle;
@@ -1720,10 +2042,6 @@ async function runWrappedAttach(opts) {
1720
2042
  logErr(`status poll failed: ${e.message}`);
1721
2043
  }
1722
2044
  };
1723
- if (opts.mode !== "shell") {
1724
- cmuxOn = await cmuxStatusEnabled();
1725
- if (cmuxOn) cmuxOrig = captureCmuxWorkspace();
1726
- }
1727
2045
  void pollStatus();
1728
2046
  const statusTimer = setInterval(() => {
1729
2047
  void pollStatus();
@@ -1813,6 +2131,7 @@ async function runWrappedAttach(opts) {
1813
2131
  process.stdout.off("resize", onResize);
1814
2132
  clearInterval(statusTimer);
1815
2133
  if (cmuxOn) restoreCmuxWorkspace(cmuxOrig);
2134
+ if (herdrOn) clearHerdrAgentState(opts.mode, opts.boxName);
1816
2135
  stopSpinner();
1817
2136
  if (flashTimer) clearTimeout(flashTimer);
1818
2137
  if (process.stdin.isTTY) process.stdin.setRawMode(false);
@@ -1970,6 +2289,16 @@ function loadClipboardScript(boxPngPath) {
1970
2289
  `setsid sh -c 'DISPLAY=:1 xclip -selection clipboard -t image/png -i ${boxPngPath}' </dev/null >/dev/null 2>&1 &`
1971
2290
  ].join("; ");
1972
2291
  }
2292
+ async function uploadImageFileToBox(provider, box, hostPath) {
2293
+ if (typeof provider.uploadPath !== "function") return null;
2294
+ const boxPng = `/tmp/agentbox-clip-${String(Date.now())}.png`;
2295
+ try {
2296
+ await provider.uploadPath(box, hostPath, boxPng);
2297
+ return boxPng;
2298
+ } catch {
2299
+ return null;
2300
+ }
2301
+ }
1973
2302
  async function pasteHostClipboardImage(provider, box) {
1974
2303
  if (typeof provider.uploadPath !== "function") return "error";
1975
2304
  const hostPng = await captureClipboardImage();
@@ -2094,7 +2423,8 @@ async function cloudAgentAttach(args) {
2094
2423
  } catch {
2095
2424
  }
2096
2425
  },
2097
- onPasteImage: canPaste ? () => pasteHostClipboardImage(provider, box) : void 0
2426
+ onPasteImage: canPaste ? () => pasteHostClipboardImage(provider, box) : void 0,
2427
+ onPasteImageFile: canPaste ? (p) => uploadImageFileToBox(provider, box, p) : void 0
2098
2428
  });
2099
2429
  process.exit(code);
2100
2430
  } finally {
@@ -2145,6 +2475,8 @@ export {
2145
2475
  getProvider,
2146
2476
  providerForBox,
2147
2477
  providerForCreate,
2478
+ herdrSend,
2479
+ hostAwareOpenIn,
2148
2480
  detectHostTerminal,
2149
2481
  cmuxBinary,
2150
2482
  spawnInNewTerminal,
@@ -2168,9 +2500,10 @@ export {
2168
2500
  postAnswer,
2169
2501
  runWrappedAttach,
2170
2502
  clipboardCaptureAvailable,
2503
+ uploadImageFileToBox,
2171
2504
  pasteHostClipboardImage,
2172
2505
  buildCloudAttachInnerCommand,
2173
2506
  cloudAgentAttach,
2174
2507
  cloudAgentStartDetached
2175
2508
  };
2176
- //# sourceMappingURL=chunk-5AKAC27L.js.map
2509
+ //# sourceMappingURL=chunk-5BO6SGMI.js.map