codeam-cli 2.65.3 → 2.65.5

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 (3) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/dist/index.js +186 -40
  3. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -4,6 +4,19 @@ All notable changes to `codeam-cli` are documented here.
4
4
 
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
6
 
7
+ ## [2.65.4] — 2026-08-14
8
+
9
+ ### Fixed
10
+
11
+ - **cli:** Handoff protocol tolerates display-name targets + inline degenerate fences
12
+ - **cli:** Degenerate handoff form must be reply-trailing (kills fabricated-proposal false positive)
13
+
14
+ ## [2.65.3] — 2026-08-14
15
+
16
+ ### Fixed
17
+
18
+ - **cli:** Strip squad-context + agent meta blocks from codex hydration (title/summary leak)
19
+
7
20
  ## [2.65.2] — 2026-08-14
8
21
 
9
22
  ### Added
package/dist/index.js CHANGED
@@ -976,6 +976,12 @@ var PUBLIC_TO_INTERNAL = {
976
976
  // MiniMax proxy). Its internal runtime is therefore `claude`.
977
977
  [HOUSE_AGENT_ID]: "claude"
978
978
  };
979
+ function isPublicToInternalKey(v) {
980
+ return Object.prototype.hasOwnProperty.call(PUBLIC_TO_INTERNAL, v);
981
+ }
982
+ function publicToInternal(publicId) {
983
+ return isPublicToInternalKey(publicId) ? PUBLIC_TO_INTERNAL[publicId] : null;
984
+ }
979
985
  var TERMINAL_AGENT_PREFIX = "__terminal__:";
980
986
  var AGENT_ID_ALIASES = {
981
987
  claude_code: "claude",
@@ -8073,7 +8079,7 @@ function readAnonId() {
8073
8079
  }
8074
8080
  function superProperties() {
8075
8081
  return {
8076
- cliVersion: true ? "2.65.3" : "0.0.0-dev",
8082
+ cliVersion: true ? "2.65.5" : "0.0.0-dev",
8077
8083
  nodeVersion: process.version,
8078
8084
  platform: process.platform,
8079
8085
  arch: process.arch,
@@ -8254,7 +8260,7 @@ var os4 = __toESM(require("os"));
8254
8260
  // package.json
8255
8261
  var package_default = {
8256
8262
  name: "codeam-cli",
8257
- version: "2.65.3",
8263
+ version: "2.65.5",
8258
8264
  description: "Workflow-continuity bridge for AI coding agents. Wrap Claude Code or Codex in a PTY and supervise, approve, and redirect the session from any device \u2014 async. The terminal companion for CodeAgent Mobile.",
8259
8265
  type: "commonjs",
8260
8266
  main: "dist/index.js",
@@ -9706,7 +9712,7 @@ var CommandRelayService = class _CommandRelayService {
9706
9712
  // fresh + clear the "CLI update available" banner after a self-update
9707
9713
  // (a codespace that reinstalls @latest reconnects via heartbeat, not
9708
9714
  // pair/reconnect). Older backends ignore the extra field.
9709
- ..."2.65.3" ? { ideVersion: "2.65.3" } : {}
9715
+ ..."2.65.5" ? { ideVersion: "2.65.5" } : {}
9710
9716
  }).then(() => log.trace("relay", `heartbeat ok online=${online}`)).catch((err) => log.trace("relay", `heartbeat failed online=${online}`, err));
9711
9717
  }
9712
9718
  /**
@@ -15717,11 +15723,17 @@ var TEAM_PREAMBLE_MARKER = "[Team context]";
15717
15723
  var TEAM_PREAMBLE_LINES = [
15718
15724
  "[Team context] You are the active agent in a CodeAgent Mobile session where the user",
15719
15725
  "has a squad of agents and can pass work between them. Your available teammates:",
15720
- "If a task clearly fits a teammate better than you, you MAY propose a handoff by ending",
15721
- `your reply with a fenced code block tagged ${HANDOFF_FENCE_TAG} containing ONE JSON object:`,
15726
+ "If a task clearly fits a teammate better than you, you MAY propose a handoff. The fence",
15727
+ `MUST be a three-backtick code block with the info string exactly ${HANDOFF_FENCE_TAG}`,
15728
+ "(never a single backtick, never bare text) with the JSON alone on its own line inside",
15729
+ "it, exactly like this:",
15730
+ "```" + HANDOFF_FENCE_TAG,
15722
15731
  '{"to":"<teammate id>","reason":"<one sentence>","prompt":"<the prompt they should run>"}',
15723
- "Propose at most one handoff per reply, only when genuinely better, and never announce",
15724
- "the block in prose \u2014 the app renders it as a card the user can accept."
15732
+ "```",
15733
+ '"to" MUST be one of the ids shown above, written EXACTLY as shown (e.g. "claude", never',
15734
+ 'a display name like "Claude Code"). Propose at most one handoff per reply, only when',
15735
+ "genuinely better, and never announce the block in prose \u2014 the app renders it as a card",
15736
+ "the user can accept."
15725
15737
  ];
15726
15738
  var TEAM_PREAMBLE_BULLET_RE = /^- .+ — best at: /;
15727
15739
  var BRIEFING_MARKER = "[Team update]";
@@ -15733,7 +15745,9 @@ function buildTeamPreamble(roster, currentAgent, opts) {
15733
15745
  const lines = [
15734
15746
  TEAM_PREAMBLE_LINES[0],
15735
15747
  TEAM_PREAMBLE_LINES[1],
15736
- ...others.map((a) => `- ${a.displayName} \u2014 best at: ${specialtyFor(a.agentId)}`)
15748
+ ...others.map(
15749
+ (a) => `- ${a.displayName} (id: ${a.agentId}) \u2014 best at: ${specialtyFor(a.agentId)}`
15750
+ )
15737
15751
  ];
15738
15752
  if (opts.handoffInstructions) {
15739
15753
  lines.push(...TEAM_PREAMBLE_LINES.slice(2));
@@ -21627,7 +21641,7 @@ async function autoUpgradeBeforeCriticalCommand() {
21627
21641
  if (process.env.NODE_ENV === "test") return;
21628
21642
  if (process.env.CODEAM_DISABLE_UPDATE_CHECK === "1") return;
21629
21643
  if (process.env.CI) return;
21630
- const current2 = true ? "2.65.3" : null;
21644
+ const current2 = true ? "2.65.5" : null;
21631
21645
  if (!current2) return;
21632
21646
  const cache = readCache();
21633
21647
  const fresh = cache && Date.now() - cache.fetchedAt < TTL_MS;
@@ -21644,7 +21658,7 @@ function checkForUpdates() {
21644
21658
  if (process.env.CODEAM_DISABLE_UPDATE_CHECK === "1") return;
21645
21659
  if (process.env.CI) return;
21646
21660
  if (!process.stdout.isTTY) return;
21647
- const current2 = true ? "2.65.3" : null;
21661
+ const current2 = true ? "2.65.5" : null;
21648
21662
  if (!current2) return;
21649
21663
  const cache = readCache();
21650
21664
  const fresh = cache && Date.now() - cache.fetchedAt < TTL_MS;
@@ -21664,7 +21678,7 @@ var SELF_UPDATE_INTERVAL_MS = 60 * 60 * 1e3;
21664
21678
  var SELF_UPDATE_VIEW_TIMEOUT_MS = 3e4;
21665
21679
  var SELF_UPDATE_INSTALL_TIMEOUT_MS = 18e4;
21666
21680
  function currentCliVersion() {
21667
- return true ? "2.65.3" : null;
21681
+ return true ? "2.65.5" : null;
21668
21682
  }
21669
21683
  function runCmd(cmd, args2, timeoutMs) {
21670
21684
  return new Promise((resolve9) => {
@@ -35365,6 +35379,13 @@ var REASON_MAX = 1e3;
35365
35379
  var PROMPT_MAX2 = 8e3;
35366
35380
  var FENCE_OPEN = "```" + HANDOFF_FENCE_TAG;
35367
35381
  var FENCE_RE = new RegExp("```" + HANDOFF_FENCE_TAG + "\\s*\\n([\\s\\S]*?)\\n?```", "g");
35382
+ var DEGENERATE_LINE_RE = new RegExp(
35383
+ "^[ \\t]*(`{0,2})[ \\t]*" + HANDOFF_FENCE_TAG + "[ \\t]+(\\{.*\\})[ \\t]*\\1[ \\t]*\\r?$"
35384
+ );
35385
+ var TAG_ONLY_LINE_RE = new RegExp(
35386
+ "^[ \\t]*`{0,2}[ \\t]*" + HANDOFF_FENCE_TAG + "[ \\t]*`{0,2}[ \\t]*\\r?$"
35387
+ );
35388
+ var CLOSING_BACKTICK_LINE_RE = /^[ \t]*`+[ \t]*\r?$/;
35368
35389
  var OUTER_FENCE_RE = /(`{4,})[\s\S]*?\1/g;
35369
35390
  var outerFencePlaceholder = (i) => `@@HANDOFF_MASK_${i}@@`;
35370
35391
  function maskOuterFences(text) {
@@ -35377,62 +35398,187 @@ function maskOuterFences(text) {
35377
35398
  const restore = (s) => spans.reduce((acc, span, i) => acc.split(outerFencePlaceholder(i)).join(span), s);
35378
35399
  return { masked, restore };
35379
35400
  }
35380
- function parseProposal(raw, currentAgent, validTargets) {
35401
+ function parseProposalShape(raw) {
35381
35402
  let parsed;
35382
35403
  try {
35383
35404
  parsed = JSON.parse(raw);
35384
35405
  } catch {
35385
- log.debug("handoffProtocol", "dropped proposal: malformed JSON");
35386
- return null;
35387
- }
35388
- if (typeof parsed !== "object" || parsed === null) {
35389
- log.debug("handoffProtocol", "dropped proposal: not a JSON object");
35390
35406
  return null;
35391
35407
  }
35408
+ if (typeof parsed !== "object" || parsed === null) return null;
35392
35409
  const { to, reason, prompt } = parsed;
35393
- if (typeof to !== "string" || to.length === 0) {
35394
- log.debug("handoffProtocol", 'dropped proposal: missing/invalid "to"');
35410
+ if (typeof to !== "string" || to.length === 0) return null;
35411
+ if (typeof reason !== "string" || reason.length === 0 || reason.length > REASON_MAX) {
35395
35412
  return null;
35396
35413
  }
35397
- if (!validTargets.has(to)) {
35398
- log.debug("handoffProtocol", `dropped proposal: unknown target "${to}"`);
35414
+ if (typeof prompt !== "string" || prompt.length === 0 || prompt.length > PROMPT_MAX2) {
35399
35415
  return null;
35400
35416
  }
35401
- if (to === currentAgent) {
35402
- log.debug("handoffProtocol", "dropped proposal: target is the current agent");
35417
+ return { to, reason, prompt };
35418
+ }
35419
+ function resolveHandoffTarget(raw, validTargets) {
35420
+ const trimmed = (raw ?? "").trim();
35421
+ if (!trimmed) return null;
35422
+ const lower = trimmed.toLowerCase();
35423
+ for (const target of validTargets) {
35424
+ if (target.toLowerCase() === lower) return target;
35425
+ }
35426
+ const viaAlias = normalizeAgentId(trimmed);
35427
+ if (viaAlias && validTargets.has(viaAlias)) return viaAlias;
35428
+ const viaPublic = publicToInternal(lower);
35429
+ if (viaPublic && validTargets.has(viaPublic)) return viaPublic;
35430
+ for (const meta of Object.values(AGENT_REGISTRY)) {
35431
+ if (meta.displayName.toLowerCase() === lower && validTargets.has(meta.id)) {
35432
+ return meta.id;
35433
+ }
35434
+ }
35435
+ return null;
35436
+ }
35437
+ function parseProposal(raw, currentAgent, validTargets) {
35438
+ const shape = parseProposalShape(raw);
35439
+ if (!shape) {
35440
+ log.debug("handoffProtocol", "dropped proposal: malformed JSON or invalid shape");
35403
35441
  return null;
35404
35442
  }
35405
- if (typeof reason !== "string" || reason.length === 0 || reason.length > REASON_MAX) {
35406
- log.debug("handoffProtocol", 'dropped proposal: invalid "reason"');
35443
+ const to = resolveHandoffTarget(shape.to, validTargets);
35444
+ if (!to) {
35445
+ log.debug("handoffProtocol", `dropped proposal: unknown target "${shape.to}"`);
35407
35446
  return null;
35408
35447
  }
35409
- if (typeof prompt !== "string" || prompt.length === 0 || prompt.length > PROMPT_MAX2) {
35410
- log.debug("handoffProtocol", 'dropped proposal: invalid "prompt"');
35448
+ if (to === currentAgent) {
35449
+ log.debug("handoffProtocol", "dropped proposal: target is the current agent");
35411
35450
  return null;
35412
35451
  }
35413
- return { to, reason, prompt };
35452
+ return { to, reason: shape.reason, prompt: shape.prompt };
35453
+ }
35454
+ function collapseSeams(s) {
35455
+ return s.replace(/(?:\r?\n){3,}/g, "\n\n").trim();
35414
35456
  }
35415
35457
  function stripFences(masked) {
35416
- const stripped = masked.replace(FENCE_RE, "");
35417
- return stripped.replace(/(?:\r?\n){3,}/g, "\n\n").trim();
35458
+ return collapseSeams(masked.replace(FENCE_RE, ""));
35459
+ }
35460
+ function lineStarts(parts) {
35461
+ const starts = [];
35462
+ let offset = 0;
35463
+ for (const p2 of parts) {
35464
+ starts.push(offset);
35465
+ offset += p2.length + 1;
35466
+ }
35467
+ return starts;
35468
+ }
35469
+ function lastNonBlankLine(masked) {
35470
+ const parts = masked.split("\n");
35471
+ const starts = lineStarts(parts);
35472
+ for (let i = parts.length - 1; i >= 0; i--) {
35473
+ if (parts[i].trim().length > 0) return { line: parts[i], start: starts[i] };
35474
+ }
35475
+ return null;
35476
+ }
35477
+ function trailingSameLineMatch(masked) {
35478
+ const last = lastNonBlankLine(masked);
35479
+ if (!last) return null;
35480
+ const m = last.line.match(DEGENERATE_LINE_RE);
35481
+ if (!m) return null;
35482
+ return { jsonRaw: m[2], start: last.start, end: last.start + m[0].length };
35483
+ }
35484
+ function trailingBlockMatch(masked) {
35485
+ const lines = masked.split("\n");
35486
+ const starts = lineStarts(lines);
35487
+ let tagLineIdx = -1;
35488
+ for (let i = lines.length - 1; i >= 0; i--) {
35489
+ if (TAG_ONLY_LINE_RE.test(lines[i])) {
35490
+ tagLineIdx = i;
35491
+ break;
35492
+ }
35493
+ }
35494
+ if (tagLineIdx === -1) return null;
35495
+ let end = lines.length - 1;
35496
+ while (end > tagLineIdx && lines[end].trim().length === 0) end--;
35497
+ if (end > tagLineIdx && CLOSING_BACKTICK_LINE_RE.test(lines[end])) {
35498
+ end--;
35499
+ while (end > tagLineIdx && lines[end].trim().length === 0) end--;
35500
+ }
35501
+ if (end <= tagLineIdx) return null;
35502
+ const jsonRaw = lines.slice(tagLineIdx + 1, end + 1).join("\n");
35503
+ return { jsonRaw, start: starts[tagLineIdx], end: masked.length };
35504
+ }
35505
+ function trailingDegenerateMatch(masked) {
35506
+ return trailingSameLineMatch(masked) ?? trailingBlockMatch(masked);
35507
+ }
35508
+ function earlierShapeValidDegenerateSpans(masked, beforeOffset) {
35509
+ const lines = masked.split("\n");
35510
+ const starts = lineStarts(lines);
35511
+ const spans = [];
35512
+ for (let i = 0; i < lines.length && starts[i] < beforeOffset; i++) {
35513
+ const same = lines[i].match(DEGENERATE_LINE_RE);
35514
+ if (same) {
35515
+ const end = starts[i] + same[0].length;
35516
+ if (end <= beforeOffset && parseProposalShape(same[2].trim())) {
35517
+ spans.push({ start: starts[i], end });
35518
+ }
35519
+ continue;
35520
+ }
35521
+ if (TAG_ONLY_LINE_RE.test(lines[i])) {
35522
+ let j2 = i + 1;
35523
+ while (j2 < lines.length && lines[j2].trim().length === 0) j2++;
35524
+ if (j2 >= lines.length || starts[j2] >= beforeOffset) continue;
35525
+ if (!parseProposalShape(lines[j2].trim())) continue;
35526
+ let end = starts[j2] + lines[j2].length;
35527
+ let k2 = j2 + 1;
35528
+ if (k2 < lines.length && starts[k2] < beforeOffset && CLOSING_BACKTICK_LINE_RE.test(lines[k2])) {
35529
+ end = starts[k2] + lines[k2].length;
35530
+ }
35531
+ if (end <= beforeOffset) spans.push({ start: starts[i], end });
35532
+ }
35533
+ }
35534
+ return spans;
35535
+ }
35536
+ function removeSpans(text, spans) {
35537
+ const sorted = [...spans].sort((a, b) => a.start - b.start);
35538
+ let result = "";
35539
+ let cursor = 0;
35540
+ for (const span of sorted) {
35541
+ result += text.slice(cursor, span.start);
35542
+ cursor = span.end;
35543
+ }
35544
+ result += text.slice(cursor);
35545
+ return result;
35418
35546
  }
35419
35547
  function extractHandoffProposal(text, currentAgent, validTargets) {
35420
35548
  const { masked, restore } = maskOuterFences(text);
35421
35549
  const matches = [...masked.matchAll(FENCE_RE)];
35422
- if (matches.length === 0) {
35550
+ if (matches.length > 0) {
35551
+ const last = matches[matches.length - 1];
35552
+ const proposal = parseProposal(last[1].trim(), currentAgent, validTargets);
35553
+ const cleanText = restore(stripFences(masked));
35554
+ return { cleanText, proposal };
35555
+ }
35556
+ const degenerate = trailingDegenerateMatch(masked);
35557
+ if (degenerate) {
35558
+ const proposal = parseProposal(degenerate.jsonRaw.trim(), currentAgent, validTargets);
35559
+ if (proposal) {
35560
+ const earlier = earlierShapeValidDegenerateSpans(masked, degenerate.start);
35561
+ const stripped = removeSpans(masked, [
35562
+ ...earlier,
35563
+ { start: degenerate.start, end: degenerate.end }
35564
+ ]);
35565
+ return { cleanText: restore(collapseSeams(stripped)), proposal };
35566
+ }
35423
35567
  return { cleanText: text, proposal: null };
35424
35568
  }
35425
- const last = matches[matches.length - 1];
35426
- const proposal = parseProposal(last[1].trim(), currentAgent, validTargets);
35427
- const cleanText = restore(stripFences(masked));
35428
- return { cleanText, proposal };
35569
+ return { cleanText: text, proposal: null };
35429
35570
  }
35430
35571
  function stripHandoffFences(text) {
35431
35572
  const { masked, restore } = maskOuterFences(text);
35432
- if (masked.search(FENCE_RE) === -1) {
35433
- return text;
35573
+ if (masked.search(FENCE_RE) !== -1) {
35574
+ return restore(stripFences(masked));
35575
+ }
35576
+ const degenerate = trailingDegenerateMatch(masked);
35577
+ if (degenerate && parseProposalShape(degenerate.jsonRaw.trim())) {
35578
+ const stripped = masked.slice(0, degenerate.start) + masked.slice(degenerate.end);
35579
+ return restore(collapseSeams(stripped));
35434
35580
  }
35435
- return restore(stripFences(masked));
35581
+ return text;
35436
35582
  }
35437
35583
  function handoffFenceStartMasked(text) {
35438
35584
  const { masked } = maskOuterFences(text);
@@ -44499,7 +44645,7 @@ function checkChokidar() {
44499
44645
  }
44500
44646
  async function doctor(args2 = []) {
44501
44647
  const json = args2.includes("--json");
44502
- const cliVersion = true ? "2.65.3" : "0.0.0-dev";
44648
+ const cliVersion = true ? "2.65.5" : "0.0.0-dev";
44503
44649
  const apiBase2 = resolveApiBaseUrl();
44504
44650
  const diagnosticId = (0, import_node_crypto13.randomUUID)();
44505
44651
  log.info("doctor", `run id=${diagnosticId} cli=${cliVersion}`);
@@ -44890,7 +45036,7 @@ async function mcpRun(args2) {
44890
45036
  // src/commands/version.ts
44891
45037
  var import_picocolors15 = __toESM(require("picocolors"));
44892
45038
  function version2() {
44893
- const v = true ? "2.65.3" : "unknown";
45039
+ const v = true ? "2.65.5" : "unknown";
44894
45040
  console.log(`${import_picocolors15.default.bold("codeam-cli")} ${import_picocolors15.default.cyan(v)}`);
44895
45041
  }
44896
45042
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codeam-cli",
3
- "version": "2.65.3",
3
+ "version": "2.65.5",
4
4
  "description": "Workflow-continuity bridge for AI coding agents. Wrap Claude Code or Codex in a PTY and supervise, approve, and redirect the session from any device — async. The terminal companion for CodeAgent Mobile.",
5
5
  "type": "commonjs",
6
6
  "main": "dist/index.js",