@botbuddy/cli 1.73.4 → 1.73.6

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 CHANGED
@@ -1,5 +1,13 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.73.6
4
+
5
+ - `bb stack run --callback-port` no longer refuses a callback tunnel just because the serving host is busy (BOT-2860). Before it opens the real `-R`, the GatewayPorts probe proves that the host keeps reverse forwards on loopback, using a spare host port. It gave up after 2 ports that already had a listener, and parallel sessions' tunnels crowd exactly the ranges it picks from. It now tries up to 20 ports (`PROBE_PORT_ATTEMPTS`), skipping busy ones, within a 60 s overall budget (`DEFAULT_PROBE_BUDGET_MS`) after which it refuses. Only a busy port moves it on: a wildcard bind, a missing `lsof`, an unconfirmed forward or a timeout still refuse at once.
6
+
7
+ ## 1.73.5
8
+
9
+ - The bb-status band's badges are compact rounded pills in Claude Code Desktop, shaped like Claude's own buttons (BOT-3230). Each status, the context alarm, every wait and the staging-red banner is one pill: a rounded rectangle in its darker colour with white words and icon. Before, a rounded border drew a whole empty row above and below the words. Each wait's and staging's `↗` link stays beside its pill. Failure notes such as `Guessed from branch · Couldn't load staging` now sit on their own line under the tree, so the first row's title keeps its full width instead of wrapping one word per line. The terminal draws its badges as before. The plugin version moves to 1.4.3, so `bb update` installs it.
10
+
3
11
  ## 1.73.4
4
12
 
5
13
  - A new Claude Code session in a repo where both the bb-session start-up hook and the bb-status band run is registered by the hook again. The band's first read at session start bootstrapped the same session at the same moment, and both bootstraps failed: the session stayed unregistered for minutes and the model never got its BB identity. For its session's first 30 seconds `bb status-band read` (with the new `--session-started-at`) now leaves the bootstrap to the hook and answers `session_starting` with `retry_after_ms`; the band shows "Connecting this session to BB…" and reads once more when told. A session the hook did not register is still bound by the band after that window. The band's plugin version moves to 1.4.2.
@@ -11,7 +11,7 @@
11
11
  "name": "bb-status",
12
12
  "source": "./bb-status",
13
13
  "description": "BB session status above the prompt: tickets, PRs with review counts, epic, staging, context use and active waits, for BotBuddy and Supply Guard sessions",
14
- "version": "1.4.2"
14
+ "version": "1.4.3"
15
15
  },
16
16
  {
17
17
  "name": "bb-session",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bb-status",
3
- "version": "1.4.2",
3
+ "version": "1.4.3",
4
4
  "description": "BB session status above the prompt: tickets, PRs with review counts, epic, staging, context use and active waits, live only while the session is on screen.",
5
5
  "author": {
6
6
  "name": "BotBuddy"
@@ -206,3 +206,11 @@ rounded (`borderStyle: "round"`) outside the terminal; the staging banner is the
206
206
  same red badge as the context alarm. PRs nest by indent with no trunk line, and
207
207
  rows sit in one column Box with an even `rowGap`. The read runs from the
208
208
  worktree root even when Claude's working directory is a subfolder.
209
+
210
+ **BOT-3230 pills.** On Desktop and the other graphical surfaces every badge
211
+ (status, context alarm, wait, staging red) is one SVG pill: a rounded rect
212
+ (6px radius, 22px tall) in the badge's darker fill, with the white icon and
213
+ words inside, its width estimated from the words. A Claude Code `Box` has no
214
+ corner radius, and a border draws a whole row above and below. Links stay
215
+ `Link` elements beside the pill. Failure notes are their own dim line under
216
+ the tree. The terminal keeps filled `Box` badges.
@@ -812,10 +812,76 @@ function inked(source, bg) {
812
812
  .replace(/#[0-9a-f]{6}\b/gi, "#ffffff")
813
813
  .replace(/@BG@/g, bg);
814
814
  }
815
- function rounded() {
816
- return surface === "terminal" ? {} : { borderStyle: "round" };
815
+ // BOT-3230: off the terminal every badge is one SVG pill — a rounded rect in
816
+ // its fill, the icon and words in white — the only element that can draw a
817
+ // corner radius (Jono, 2026-11-14: "I want it to look like Details"). A Box
818
+ // border drew a whole row above and below the words. The terminal keeps the
819
+ // filled Box.
820
+ const PILL = { h: 22, rx: 6, pad: 8, icon: 12, gap: 5, font: 13 };
821
+ const RED = "#c62828"; // the context alarm's and staging red's one fill
822
+ function pills() {
823
+ return surface !== "terminal";
817
824
  }
818
- function statusBadge(el, key, spec) {
825
+ // The system font's advance at 13px, estimated per character, slightly over
826
+ // so the words never touch the rounded end.
827
+ function glyphPx(ch) {
828
+ if (ch === " ") return 3.6;
829
+ if (/[il.,:;'|!·]/.test(ch)) return 3.3;
830
+ if (/[fjrt\/()\[\]]/.test(ch)) return 4.4;
831
+ if (/[mw]/.test(ch)) return 10.2;
832
+ if (/[MW%]/.test(ch)) return 11;
833
+ if (/[A-Z]/.test(ch)) return 8.1;
834
+ if (/[0-9]/.test(ch)) return 7.1;
835
+ if (/[a-z]/.test(ch)) return 6.5;
836
+ if (ch.codePointAt(0) > 0x2000) return 15; // ⏳ ▲ and other symbols
837
+ return 7.1;
838
+ }
839
+ function textPx(text, bold) {
840
+ const w = [...String(text)].reduce((n, ch) => n + glyphPx(ch), 0);
841
+ return Math.ceil(w * (bold ? 1.06 : 1));
842
+ }
843
+ function xml(text) {
844
+ return String(text).replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;");
845
+ }
846
+ // The pill's own width; `slot` (≥ it) widens the drawing, never the pill, so
847
+ // a column of pills lines up.
848
+ function pillWidth({ text, icon, bold }) {
849
+ return PILL.pad * 2 + (icon ? PILL.icon + (text ? PILL.gap : 0) : 0) + (text ? textPx(text, bold) : 0);
850
+ }
851
+ function pillSource({ text, icon, fill, bold }, slot) {
852
+ const w = pillWidth({ text, icon, bold });
853
+ const outer = Math.max(w, slot || 0);
854
+ let x = PILL.pad;
855
+ let body = `<rect x="0" y="0" width="${w}" height="${PILL.h}" rx="${PILL.rx}" fill="${fill}"/>`;
856
+ if (icon) {
857
+ body += String(icon).replace(/^<svg /, `<svg x="${x}" y="${(PILL.h - PILL.icon) / 2}" `);
858
+ x += PILL.icon + (text ? PILL.gap : 0);
859
+ }
860
+ if (text)
861
+ body += `<text x="${x}" y="15" font-family="-apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif" font-size="${PILL.font}"${bold ? ' font-weight="600"' : ""} fill="#ffffff">${xml(text)}</text>`;
862
+ return { width: outer, source: `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${outer} ${PILL.h}" width="${outer}" height="${PILL.h}">${body}</svg>` };
863
+ }
864
+ function pillSvg(el, pill, slot) {
865
+ const { width, source } = pillSource(pill, slot);
866
+ return el.Svg({ alt: pill.alt || pill.text, width, height: PILL.h, source });
867
+ }
868
+ function statusText(spec) {
869
+ return spec.status.map((part) => part.text).join(" · ");
870
+ }
871
+ // The pill's alt: what its icon said (kind and state), then any further parts
872
+ // (a PR's review count, a project's done/total). When the pill shows a status
873
+ // the icon does not say (a conflicted open PR reads "Conflict"), that status
874
+ // leads the parts, so the alt never drops a warning (Codex P2, PR #1662).
875
+ function statusPill(spec) {
876
+ const said = (spec.iconAlt || "").toLowerCase();
877
+ const first = (spec.status[0]?.text || "").toLowerCase();
878
+ const rest = spec.status.slice(first && said.endsWith(first) ? 1 : 0).map((part) => part.text);
879
+ const alt = spec.iconAlt ? [spec.iconAlt, ...rest].join(" · ") : statusText(spec);
880
+ return { text: statusText(spec), icon: spec.iconSource, fill: badgeColors(spec.hex).bg, alt };
881
+ }
882
+ function statusBadge(el, key, spec, slot) {
883
+ if (pills() && spec.iconSource && typeof el.Svg === "function")
884
+ return [el.Box({ key, flexDirection: "row", flexShrink: 0, children: [pillSvg(el, statusPill(spec), slot)] })];
819
885
  if (!spec.status.length) return spec.icon ? [spec.icon] : [];
820
886
  const { bg, fg, muted } = badgeColors(spec.hex);
821
887
  const children = spec.icon ? [spec.icon] : [];
@@ -823,7 +889,7 @@ function statusBadge(el, key, spec) {
823
889
  if (i) children.push(el.Text({ color: muted, children: [" · "] }));
824
890
  children.push(el.Text({ color: part.muted ? muted : fg, children: [part.text] }));
825
891
  });
826
- return [el.Box({ key, flexDirection: "row", flexShrink: 0, backgroundColor: bg, ...rounded(), borderColor: bg, paddingX: 1, children })];
892
+ return [el.Box({ key, flexDirection: "row", flexShrink: 0, backgroundColor: bg, paddingX: 1, children })];
827
893
  }
828
894
  function bandLine(el, spec, widths, right) {
829
895
  const ids = [];
@@ -837,7 +903,9 @@ function bandLine(el, spec, widths, right) {
837
903
  if (spec.note) title.push(dim(el, " " + spec.note));
838
904
  const children = [
839
905
  el.Box({ key: spec.key + "-ids", flexDirection: "row", width: widths.ids, flexShrink: 0, children: ids }),
840
- el.Box({ key: spec.key + "-status", flexDirection: "row", width: widths.status, flexShrink: 0, children: statusBadge(el, spec.key + "-badge", spec) }),
906
+ // Off the terminal every pill is drawn at the widest pill's width (pixels),
907
+ // so the column needs no cell width of its own.
908
+ el.Box({ key: spec.key + "-status", flexDirection: "row", ...(widths.statusPx ? {} : { width: widths.status }), flexShrink: 0, children: statusBadge(el, spec.key + "-badge", spec, widths.statusPx) }),
841
909
  el.Box({ key: spec.key + "-title", flexDirection: "row", flexGrow: 1, flexShrink: 1, minWidth: 0, flexWrap: "wrap", children: title }),
842
910
  ];
843
911
  if (right && right.length)
@@ -869,24 +937,37 @@ function waitBadges(el, key, w, now) {
869
937
  if (!w || !Number.isSafeInteger(w.count) || w.count < 1) return [];
870
938
  const style = pulsing ? { bold: true } : {};
871
939
  const { bg, fg } = badgeColors(ICON.violet);
872
- const shape = { backgroundColor: bg, ...rounded(), borderColor: bg, paddingX: 1 };
940
+ const shape = { backgroundColor: bg, paddingX: 1 };
941
+ const svg = pills() && typeof el.Svg === "function";
873
942
  // An older BB lists no items: the one count badge, as before.
874
943
  if (!Array.isArray(w.items) || !w.items.length) {
875
944
  const text = waitsText(w, now);
876
- return text ? [el.Box({ key: key + "-waits", flexDirection: "row", flexShrink: 0, ...shape, children: [el.Text({ color: fg, ...style, children: [text] })] })] : [];
945
+ if (!text) return [];
946
+ if (svg) return [el.Box({ key: key + "-waits", flexDirection: "row", flexShrink: 0, children: [pillSvg(el, { text, fill: bg, bold: pulsing })] })];
947
+ return [el.Box({ key: key + "-waits", flexDirection: "row", flexShrink: 0, ...shape, children: [el.Text({ color: fg, ...style, children: [text] })] })];
877
948
  }
878
- const out = w.items.slice(0, MAX_WAIT_BADGES).map((i) =>
879
- el.Box({
949
+ const out = w.items.slice(0, MAX_WAIT_BADGES).map((i) => {
950
+ const text = "⏳ " + i.label + " · " + shortAge(i.created_at, now);
951
+ if (svg)
952
+ return el.Box({
953
+ key: key + "-wait-" + i.id,
954
+ flexDirection: "row",
955
+ flexShrink: 0,
956
+ alignItems: "center",
957
+ columnGap: 1,
958
+ children: [pillSvg(el, { text, fill: bg, bold: pulsing }), el.Link({ href: LINKS.wait(i.id), label: "↗" })],
959
+ });
960
+ return el.Box({
880
961
  key: key + "-wait-" + i.id,
881
962
  flexDirection: "row",
882
963
  flexShrink: 0,
883
964
  ...shape,
884
965
  children: [
885
- el.Text({ color: fg, ...style, children: ["⏳ " + i.label + " · " + shortAge(i.created_at, now) + " "] }),
966
+ el.Text({ color: fg, ...style, children: [text + " "] }),
886
967
  el.Link({ href: LINKS.wait(i.id), label: "↗" }),
887
968
  ],
888
- }),
889
- );
969
+ });
970
+ });
890
971
  if (w.count > out.length) out.push(dim(el, "+" + (w.count - out.length) + " more"));
891
972
  return out;
892
973
  }
@@ -895,11 +976,13 @@ function contextLine(el, key, waits = null) {
895
976
  const alarm = contextAlarm(context);
896
977
  if (alarm)
897
978
  children.push(
898
- el.Box({ key: key + "-ctx", flexDirection: "row", flexShrink: 0, backgroundColor: "error", ...rounded(), borderColor: "error", paddingX: 1, children: [el.Text({ color: "#ffffff", bold: true, children: [alarm] })] }),
979
+ pills() && typeof el.Svg === "function"
980
+ ? el.Box({ key: key + "-ctx", flexDirection: "row", flexShrink: 0, children: [pillSvg(el, { text: alarm, fill: RED, bold: true })] })
981
+ : el.Box({ key: key + "-ctx", flexDirection: "row", flexShrink: 0, backgroundColor: "error", paddingX: 1, children: [el.Text({ color: "#ffffff", bold: true, children: [alarm] })] }),
899
982
  );
900
983
  children.push(...waitBadges(el, key, waits, currentTime));
901
984
  if (!children.length) return null;
902
- return el.Box({ key, flexDirection: "row", flexWrap: "wrap", columnGap: 1, rowGap: 0, children });
985
+ return el.Box({ key, flexDirection: "row", flexWrap: "wrap", alignItems: "center", columnGap: 1, rowGap: 0, children });
903
986
  }
904
987
  async function readContext($) {
905
988
  try {
@@ -925,22 +1008,24 @@ function shortAge(fromIso, now) {
925
1008
  return hours < 48 ? hours + "h" : Math.floor(hours / 24) + "d";
926
1009
  }
927
1010
  function stagingBanner(el, key, since) {
1011
+ const text = "▲ Staging red" + (since ? " " + shortAge(since, currentTime) : "");
928
1012
  return el.Box({
929
1013
  key,
930
1014
  flexDirection: "row",
1015
+ alignItems: "center",
931
1016
  columnGap: 1,
932
1017
  children: [
933
1018
  // BOT-3228: the same red badge, white lettering, as the context alarm.
934
- el.Box({
935
- key: key + "-badge",
936
- flexDirection: "row",
937
- flexShrink: 0,
938
- backgroundColor: "error",
939
- ...rounded(),
940
- borderColor: "error",
941
- paddingX: 1,
942
- children: [el.Text({ color: "#ffffff", bold: true, children: ["▲ Staging red" + (since ? " " + shortAge(since, currentTime) : "")] })],
943
- }),
1019
+ pills() && typeof el.Svg === "function"
1020
+ ? el.Box({ key: key + "-badge", flexDirection: "row", flexShrink: 0, children: [pillSvg(el, { text, fill: RED, bold: true })] })
1021
+ : el.Box({
1022
+ key: key + "-badge",
1023
+ flexDirection: "row",
1024
+ flexShrink: 0,
1025
+ backgroundColor: "error",
1026
+ paddingX: 1,
1027
+ children: [el.Text({ color: "#ffffff", bold: true, children: [text] })],
1028
+ }),
944
1029
  el.Link({ href: LINKS.staging, label: "Open staging ↗" }),
945
1030
  ],
946
1031
  });
@@ -977,6 +1062,8 @@ function bandLines(el, $, inPane) {
977
1062
  prefix,
978
1063
  ids: [{ label: t.key, href: LINKS.ticket(t.key), out: OUT.ticket(s.tenant, t.key) }],
979
1064
  icon: lead(el, "◆", "#ffffff", "ticket " + t.status, inked(ticketIcon(t.status), badgeColors(ticketHex(t.status)).bg)),
1065
+ iconSource: inked(ticketIcon(t.status), badgeColors(ticketHex(t.status)).bg),
1066
+ iconAlt: "ticket " + t.status,
980
1067
  hex: ticketHex(t.status),
981
1068
  status: [{ text: t.status }],
982
1069
  title: t.title,
@@ -993,6 +1080,8 @@ function bandLines(el, $, inPane) {
993
1080
  prefix,
994
1081
  ids: [{ label: "PR " + p.number, href: LINKS.pr(p.repo, p.number), out: OUT.pr(p.repo, p.number) }],
995
1082
  icon: lead(el, "⎇", "#ffffff", "pr " + p.state, inked(prIcon(p.state), badgeColors(hex).bg)),
1083
+ iconSource: inked(prIcon(p.state), badgeColors(hex).bg),
1084
+ iconAlt: "pr " + p.state,
996
1085
  hex,
997
1086
  status,
998
1087
  title: p.title,
@@ -1012,6 +1101,8 @@ function bandLines(el, $, inPane) {
1012
1101
  },
1013
1102
  ],
1014
1103
  icon: lead(el, "◇", "#ffffff", "project " + s.epic.state + " " + s.epic.percent + "%", inked(epicIcon(s.epic.state, s.epic.percent), badgeColors(epicHex(s.epic.state)).bg)),
1104
+ iconSource: inked(epicIcon(s.epic.state, s.epic.percent), badgeColors(epicHex(s.epic.state)).bg),
1105
+ iconAlt: "project " + s.epic.state + " " + s.epic.percent + "%",
1015
1106
  hex: epicHex(s.epic.state),
1016
1107
  status: [{ text: s.epic.percent + "%" }, ...(Number.isSafeInteger(s.epic.total) && s.epic.total > 0 ? [{ text: s.epic.done + "/" + s.epic.total, muted: true }] : [])],
1017
1108
  // BOT-3213: the project a coordinator session runs, with its tickets by state.
@@ -1053,15 +1144,24 @@ function bandLines(el, $, inPane) {
1053
1144
  if (s.staging == null) notes.push(UNREAD.staging);
1054
1145
  const right = [...tag];
1055
1146
  if (stale()) right.push(el.Text({ color: "warning", children: ["STALE"] }));
1056
- if (notes.length) right.push(el.Text({ key: k("line-notes"), dimColor: true, children: [notes.join(" · ")] }));
1147
+ // BOT-3230: the notes are their own line under the tree. In the first row
1148
+ // they were a column that never shrank, squeezing the title to a word a line.
1149
+ const noteLine = notes.length
1150
+ ? el.Box({ key: k("line-notes-row"), flexDirection: "row", children: [el.Text({ key: k("line-notes"), dimColor: true, wrap: "wrap", children: [notes.join(" · ")] })] })
1151
+ : null;
1057
1152
  if (details) right.push(details);
1153
+ const svgPills = pills() && typeof el.Svg === "function";
1058
1154
  const widths = {
1059
1155
  ids: Math.max(0, ...specs.map((x) => idsWidth(x.ids, x.prefix))),
1060
1156
  status: Math.max(0, ...specs.map(statusWidth)),
1157
+ statusPx: svgPills ? Math.max(0, ...specs.filter((x) => x.iconSource).map((x) => pillWidth(statusPill(x)))) : 0,
1061
1158
  };
1062
1159
  const lines = specs.length
1063
1160
  ? specs.map((spec, i) => bandLine(el, spec, widths, i === 0 ? right : null))
1064
- : [el.Box({ key: k("line-notes-only"), flexDirection: "row", columnGap: 1, children: right })];
1161
+ : right.length
1162
+ ? [el.Box({ key: k("line-notes-only"), flexDirection: "row", columnGap: 1, children: right })]
1163
+ : [];
1164
+ if (noteLine) lines.push(noteLine);
1065
1165
  // BOT-3223 AC-1: context alarm and wait badges lead, on one wrapping line.
1066
1166
  const ctx = contextLine(el, k("line-context"), s.waits);
1067
1167
  if (ctx) lines.unshift(ctx);
@@ -1,7 +1,7 @@
1
1
  {
2
- "release_version": "1.73.4",
3
- "source_commit": "0b33bfa2eb6de470d62b9f6bff2a9c60713a4d18",
4
- "source_sha256": "d48572c37a0929ac8800bbc8cca933ecd915557e4e2f99d129dafd3ffc3816ca",
2
+ "release_version": "1.73.6",
3
+ "source_commit": "8723f67290b9eea90d6c618a2472431c302e45ce",
4
+ "source_sha256": "62a99d9813094a12205e3e3384f21b71077069ebb039966614cc64ca7117576b",
5
5
  "target": "darwin-arm64",
6
- "sha256": "282e1f7777f12b54bb31969b3d34b808f83c149eefe3a03056de93d724439de2"
6
+ "sha256": "4b3005f197c53290306a9671740784f6080fd4b999168cbf0004d445b69091a1"
7
7
  }
@@ -1,7 +1,7 @@
1
1
  {
2
- "release_version": "1.73.4",
3
- "source_commit": "0b33bfa2eb6de470d62b9f6bff2a9c60713a4d18",
4
- "source_sha256": "d48572c37a0929ac8800bbc8cca933ecd915557e4e2f99d129dafd3ffc3816ca",
2
+ "release_version": "1.73.6",
3
+ "source_commit": "8723f67290b9eea90d6c618a2472431c302e45ce",
4
+ "source_sha256": "62a99d9813094a12205e3e3384f21b71077069ebb039966614cc64ca7117576b",
5
5
  "target": "linux-x64",
6
- "sha256": "4be7b327985e1cad4d60c5c6ae01d1976c60156dd1bba24282cc82469fe5a9b1"
6
+ "sha256": "994535444d843cf29e359e447b376f14725714d46f214430bcddb05617711165"
7
7
  }
@@ -1,21 +1,21 @@
1
1
  {
2
2
  "schema_version": 1,
3
- "release_version": "1.73.4",
4
- "source_commit": "0b33bfa2eb6de470d62b9f6bff2a9c60713a4d18",
5
- "source_sha256": "d48572c37a0929ac8800bbc8cca933ecd915557e4e2f99d129dafd3ffc3816ca",
3
+ "release_version": "1.73.6",
4
+ "source_commit": "8723f67290b9eea90d6c618a2472431c302e45ce",
5
+ "source_sha256": "62a99d9813094a12205e3e3384f21b71077069ebb039966614cc64ca7117576b",
6
6
  "targets": {
7
7
  "darwin-arm64": {
8
8
  "goos": "darwin",
9
9
  "goarch": "arm64",
10
10
  "binary": "daemon/bin/darwin-arm64/botbuddy-daemon",
11
- "sha256": "282e1f7777f12b54bb31969b3d34b808f83c149eefe3a03056de93d724439de2",
11
+ "sha256": "4b3005f197c53290306a9671740784f6080fd4b999168cbf0004d445b69091a1",
12
12
  "mode": "0755"
13
13
  },
14
14
  "linux-x64": {
15
15
  "goos": "linux",
16
16
  "goarch": "amd64",
17
17
  "binary": "daemon/bin/linux-x64/botbuddy-daemon",
18
- "sha256": "4be7b327985e1cad4d60c5c6ae01d1976c60156dd1bba24282cc82469fe5a9b1",
18
+ "sha256": "994535444d843cf29e359e447b376f14725714d46f214430bcddb05617711165",
19
19
  "mode": "0755"
20
20
  }
21
21
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@botbuddy/cli",
3
- "version": "1.73.4",
3
+ "version": "1.73.6",
4
4
  "description": "BotBuddy — Swarm coordination CLI for multi-agent workflows",
5
5
  "type": "module",
6
6
  "bin": {
@@ -400,6 +400,19 @@ export function randomProbePort(random = Math.random) {
400
400
 
401
401
  const REMOTE_FORWARD_BUSY = /remote port forwarding failed|address already in use|cannot listen/i;
402
402
  export const DEFAULT_PROBE_READY_MS = 10_000;
403
+ /**
404
+ * BOT-2860: how many host ports the GatewayPorts probe may try. Only a BUSY port (a listener before
405
+ * the probe, a foreign listener beside it, or sshd refusing the bind) moves on to another port;
406
+ * every other outcome refuses at once, so a larger budget never weakens fail-closed. Parallel
407
+ * sessions' tunnels crowd TUNNEL_PORT_RANGES on a busy host, and two picks were not enough there.
408
+ */
409
+ export const PROBE_PORT_ATTEMPTS = TUNNEL_PORT_PICKS;
410
+ /**
411
+ * BOT-2860 (review): the whole probe's time budget. With PROBE_PORT_ATTEMPTS tries on a slow host
412
+ * (each remote check may take up to its spawnSync timeout), the probe could otherwise run for
413
+ * minutes; once this is spent no further port is tried and the probe refuses.
414
+ */
415
+ export const DEFAULT_PROBE_BUDGET_MS = 60_000;
403
416
 
404
417
  /**
405
418
  * Codex #1134 P1: the probe's LOCAL destination is a port this process holds for the whole probe —
@@ -439,11 +452,13 @@ function listenSilent(port) {
439
452
  * exposed even if sshd binds it wildcard), asks
440
453
  * the host which address P really holds (`verifyCallbackLoopback` with `port: P`), and kills the
441
454
  * probe. Fail closed: an exposed bind, lsof missing, or a listener that never appears is
442
- * CALLBACK_NOT_LOOPBACK; a busy P is retried once on another port, then refused.
455
+ * CALLBACK_NOT_LOOPBACK; a busy P is retried on another port, at most PROBE_PORT_ATTEMPTS ports in
456
+ * all, then refused.
443
457
  */
444
458
  export async function probeGatewayPorts({
445
459
  sshBin = "ssh", sshTarget, env = process.env, spawnImpl = spawn, run = spawnSync, pickProbePort = randomProbePort,
446
- holdLocalPort = holdSilentLocalPort, readyTimeoutMs = DEFAULT_PROBE_READY_MS, attempts = 2,
460
+ holdLocalPort = holdSilentLocalPort, readyTimeoutMs = DEFAULT_PROBE_READY_MS, attempts = PROBE_PORT_ATTEMPTS,
461
+ budgetMs = DEFAULT_PROBE_BUDGET_MS, now = Date.now,
447
462
  sleep = (ms) => new Promise((r) => setTimeout(r, ms)),
448
463
  }) {
449
464
  const fail = (why) => tunnelError("CALLBACK_NOT_LOOPBACK",
@@ -452,7 +467,13 @@ export async function probeGatewayPorts({
452
467
  "(or clientspecified) on the host, or run without --callback-port.");
453
468
  const tried = new Set();
454
469
  let busyTail = "";
470
+ const budgetEnds = now() + budgetMs;
471
+ let spent = 0;
455
472
  for (let attempt = 1; attempt <= attempts; attempt++) {
473
+ if (attempt > 1 && now() > budgetEnds) {
474
+ throw fail(`the host refused ${spent} probe ports and the probe's ${Math.round(budgetMs / 1000)}s budget is spent: ${busyTail}`);
475
+ }
476
+ spent = attempt;
456
477
  // BOT-2503: an invalid or serving-band pick never reaches ssh; at most TUNNEL_PORT_PICKS picks.
457
478
  let port = null;
458
479
  for (let i = 0; port == null && i < TUNNEL_PORT_PICKS; i++) {