codeam-cli 2.74.6 → 2.74.8

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 +12 -0
  2. package/dist/index.js +107 -47
  3. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -4,6 +4,18 @@ 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.74.7] — 2026-09-06
8
+
9
+ ### Fixed
10
+
11
+ - **cli:** Daemon lock no longer defers to a reused pid — warm-codespace resume left the session dead (#715)
12
+
13
+ ## [2.74.6] — 2026-09-05
14
+
15
+ ### Fixed
16
+
17
+ - **cli:** Expo preview reads the tunnel URL a non-TTY Expo actually emits (exp.direct) (#713)
18
+
7
19
  ## [2.74.5] — 2026-09-04
8
20
 
9
21
  ### Chore
package/dist/index.js CHANGED
@@ -8136,7 +8136,7 @@ function readAnonId() {
8136
8136
  }
8137
8137
  function superProperties() {
8138
8138
  return {
8139
- cliVersion: true ? "2.74.6" : "0.0.0-dev",
8139
+ cliVersion: true ? "2.74.8" : "0.0.0-dev",
8140
8140
  nodeVersion: process.version,
8141
8141
  platform: process.platform,
8142
8142
  arch: process.arch,
@@ -8378,7 +8378,7 @@ var http = __toESM(require("http"));
8378
8378
  // package.json
8379
8379
  var package_default = {
8380
8380
  name: "codeam-cli",
8381
- version: "2.74.6",
8381
+ version: "2.74.8",
8382
8382
  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.",
8383
8383
  type: "commonjs",
8384
8384
  main: "dist/index.js",
@@ -9971,7 +9971,7 @@ var CommandRelayService = class _CommandRelayService {
9971
9971
  // fresh + clear the "CLI update available" banner after a self-update
9972
9972
  // (a codespace that reinstalls @latest reconnects via heartbeat, not
9973
9973
  // pair/reconnect). Older backends ignore the extra field.
9974
- ..."2.74.6" ? { ideVersion: "2.74.6" } : {}
9974
+ ..."2.74.8" ? { ideVersion: "2.74.8" } : {}
9975
9975
  }).then(() => log.trace("relay", `heartbeat ok online=${online}`)).catch((err) => log.trace("relay", `heartbeat failed online=${online}`, err));
9976
9976
  }
9977
9977
  /**
@@ -18410,14 +18410,14 @@ function defaultSdkDir() {
18410
18410
  return resolveSdkDirViaRequire();
18411
18411
  }
18412
18412
  function resolveClaudeNativeBinary(deps = {}) {
18413
- const existsSync30 = deps.existsSync ?? import_fs.default.existsSync;
18413
+ const existsSync29 = deps.existsSync ?? import_fs.default.existsSync;
18414
18414
  const platformKey = deps.platformKey ?? currentPlatformKey();
18415
18415
  const sdkDir = deps.sdkDir !== void 0 ? deps.sdkDir : defaultSdkDir();
18416
18416
  if (!sdkDir) return null;
18417
18417
  const scopeDir = import_path4.default.dirname(sdkDir);
18418
18418
  const binName = platformKey.startsWith("win32-") ? "claude.exe" : "claude";
18419
18419
  const candidate = import_path4.default.join(scopeDir, `claude-agent-sdk-${platformKey}`, binName);
18420
- return existsSync30(candidate) ? candidate : null;
18420
+ return existsSync29(candidate) ? candidate : null;
18421
18421
  }
18422
18422
  var realSleep = (ms) => new Promise((resolve11) => setTimeout(resolve11, ms));
18423
18423
  async function waitForClaudeNativeBinary(opts = {}) {
@@ -18499,18 +18499,18 @@ function augmentUserLocalBinPaths(deps = {}) {
18499
18499
  env.PATH = [...additions, ...parts].join(p2.delimiter);
18500
18500
  }
18501
18501
  function resolveCursorAgentBinary(deps = {}) {
18502
- const existsSync30 = deps.existsSync ?? import_fs.default.existsSync;
18502
+ const existsSync29 = deps.existsSync ?? import_fs.default.existsSync;
18503
18503
  const platform3 = deps.platform ?? process.platform;
18504
18504
  const env = deps.env ?? process.env;
18505
18505
  if (platform3 === "win32") {
18506
18506
  const localAppData = env.LOCALAPPDATA;
18507
18507
  if (!localAppData) return null;
18508
18508
  const exe = import_path4.default.win32.join(localAppData, "cursor-agent", "cursor-agent.exe");
18509
- return existsSync30(exe) ? exe : null;
18509
+ return existsSync29(exe) ? exe : null;
18510
18510
  }
18511
18511
  const home = deps.homedir ?? import_os4.default.homedir();
18512
18512
  const unix = import_path4.default.posix.join(home, ".local", "bin", "cursor-agent");
18513
- return existsSync30(unix) ? unix : null;
18513
+ return existsSync29(unix) ? unix : null;
18514
18514
  }
18515
18515
  async function waitForCursorAgent(opts = {}) {
18516
18516
  const timeoutMs = opts.timeoutMs ?? 18e4;
@@ -22272,7 +22272,7 @@ async function autoUpgradeBeforeCriticalCommand() {
22272
22272
  if (process.env.NODE_ENV === "test") return;
22273
22273
  if (process.env.CODEAM_DISABLE_UPDATE_CHECK === "1") return;
22274
22274
  if (process.env.CI) return;
22275
- const current2 = true ? "2.74.6" : null;
22275
+ const current2 = true ? "2.74.8" : null;
22276
22276
  if (!current2) return;
22277
22277
  const cache = readCache();
22278
22278
  const fresh = cache && Date.now() - cache.fetchedAt < TTL_MS;
@@ -22289,7 +22289,7 @@ function checkForUpdates() {
22289
22289
  if (process.env.CODEAM_DISABLE_UPDATE_CHECK === "1") return;
22290
22290
  if (process.env.CI) return;
22291
22291
  if (!process.stdout.isTTY) return;
22292
- const current2 = true ? "2.74.6" : null;
22292
+ const current2 = true ? "2.74.8" : null;
22293
22293
  if (!current2) return;
22294
22294
  const cache = readCache();
22295
22295
  const fresh = cache && Date.now() - cache.fetchedAt < TTL_MS;
@@ -22312,7 +22312,7 @@ var SELF_UPDATE_INSTALL_TIMEOUT_MS = 18e4;
22312
22312
  var SELF_UPDATE_LS_TIMEOUT_MS = 15e3;
22313
22313
  var SUDO_PREFLIGHT_TIMEOUT_MS = 5e3;
22314
22314
  function currentCliVersion() {
22315
- return true ? "2.74.6" : null;
22315
+ return true ? "2.74.8" : null;
22316
22316
  }
22317
22317
  async function installedVersion(deps) {
22318
22318
  const ls = await deps.run(
@@ -23279,7 +23279,9 @@ var HostAgentSupervisor = class {
23279
23279
  );
23280
23280
  return;
23281
23281
  }
23282
- if (!await this.fleetBoxImageStale(containerName)) {
23282
+ const stale = await this.fleetBoxImageStale(containerName);
23283
+ if (stale === null) return;
23284
+ if (!stale) {
23283
23285
  log.info("host-agent", `fleet_migrate_box_image: ${containerName} already current`);
23284
23286
  return;
23285
23287
  }
@@ -23362,7 +23364,7 @@ var HostAgentSupervisor = class {
23362
23364
  * current registry `:latest` (a stale runtime), or the container is gone.
23363
23365
  * Pulls `:latest` first so the comparison is against the freshest image.
23364
23366
  * Best-effort + fail-SAFE: a local-image override (int test / operator) or any
23365
- * pull/inspect error returns false → the caller falls back to a plain
23367
+ * pull/inspect error returns false (null for a failed pull, logged) → the caller falls back to a plain
23366
23368
  * `docker start`, so a transient docker hiccup can never wedge a wake.
23367
23369
  */
23368
23370
  async fleetBoxImageStale(containerName) {
@@ -23372,8 +23374,16 @@ var HostAgentSupervisor = class {
23372
23374
  if (cur.code !== 0) {
23373
23375
  return isMissingContainerError(cur.stderr);
23374
23376
  }
23375
- const pull = await this.docker.run(["pull", image], { timeoutMs: DOCKER_RUN_TIMEOUT_MS });
23376
- if (pull.code !== 0) return false;
23377
+ const pull = await this.docker.run(["pull", image], {
23378
+ timeoutMs: DOCKER_RUN_WITH_PULL_TIMEOUT_MS
23379
+ });
23380
+ if (pull.code !== 0) {
23381
+ log.warn(
23382
+ "host-agent",
23383
+ `fleet image pull failed (code=${pull.code}) \u2014 cannot tell whether ${containerName} is stale, leaving it: ` + pull.stderr.trim().slice(-300)
23384
+ );
23385
+ return null;
23386
+ }
23377
23387
  const latest = await this.docker.run(["inspect", "--format", "{{.Id}}", image]);
23378
23388
  if (latest.code !== 0) return false;
23379
23389
  return cur.stdout.trim() !== "" && cur.stdout.trim() !== latest.stdout.trim();
@@ -23738,11 +23748,16 @@ var HostAgentSupervisor = class {
23738
23748
  };
23739
23749
  proc.stdout?.on("data", appendTail);
23740
23750
  proc.stderr?.on("data", appendTail);
23741
- proc.once("exit", (code) => {
23751
+ proc.once("exit", (code, signal) => {
23742
23752
  if (this.children.get(deployId)?.proc === proc) this.children.delete(deployId);
23743
23753
  if (typeof code === "number" && code !== 0) {
23744
23754
  this.onResumeChildExit(session, code, tail.trim().slice(-300));
23755
+ return;
23745
23756
  }
23757
+ log.warn(
23758
+ "host-agent",
23759
+ `resumed session ${session.id.slice(0, 8)} exited ${signal ?? code ?? 0} without taking over \u2014 tail: ${tail.trim().slice(-300) || "(no output)"}`
23760
+ );
23746
23761
  });
23747
23762
  log.info(
23748
23763
  "host-agent",
@@ -30153,6 +30168,52 @@ async function claim(token, pluginId, pluginSecretHash) {
30153
30168
  function pairAutoLockPath() {
30154
30169
  return path72.join(os55.homedir(), ".codeam", "pair-auto.lock");
30155
30170
  }
30171
+ var procRoot = "/proc";
30172
+ function readProcFile(rel) {
30173
+ try {
30174
+ return fs66.readFileSync(path72.join(procRoot, rel), "utf8");
30175
+ } catch {
30176
+ return void 0;
30177
+ }
30178
+ }
30179
+ function procStartTicks(pid) {
30180
+ const stat3 = readProcFile(`${pid}/stat`);
30181
+ if (!stat3) return void 0;
30182
+ const afterComm = stat3.slice(stat3.lastIndexOf(")") + 2).trim().split(/\s+/);
30183
+ return afterComm[19];
30184
+ }
30185
+ function procTgid(pid) {
30186
+ const m = readProcFile(`${pid}/status`)?.match(/^Tgid:\s+(\d+)/m);
30187
+ return m ? Number(m[1]) : void 0;
30188
+ }
30189
+ function currentBootId() {
30190
+ return readProcFile("sys/kernel/random/boot_id")?.trim() || void 0;
30191
+ }
30192
+ function readLockRecord(lockPath) {
30193
+ let raw;
30194
+ try {
30195
+ raw = fs66.readFileSync(lockPath, "utf8");
30196
+ } catch {
30197
+ return void 0;
30198
+ }
30199
+ const [first = "", second = ""] = raw.split("\n");
30200
+ const pid = Number(first.trim());
30201
+ if (!Number.isInteger(pid) || pid <= 0) return void 0;
30202
+ const rec = { pid };
30203
+ const start2 = /(?:^|\s)start=(\S+)/.exec(second)?.[1];
30204
+ const boot = /(?:^|\s)boot=(\S+)/.exec(second)?.[1];
30205
+ if (start2) rec.start = start2;
30206
+ if (boot) rec.boot = boot;
30207
+ return rec;
30208
+ }
30209
+ function ownLockBody() {
30210
+ const start2 = procStartTicks(process.pid);
30211
+ const boot = currentBootId();
30212
+ const tags = [start2 ? `start=${start2}` : "", boot ? `boot=${boot}` : ""].filter(Boolean);
30213
+ return tags.length ? `${process.pid}
30214
+ ${tags.join(" ")}
30215
+ ` : String(process.pid);
30216
+ }
30156
30217
  function isLivePairAuto(pid) {
30157
30218
  if (!Number.isInteger(pid) || pid <= 0 || pid === process.pid) return false;
30158
30219
  try {
@@ -30160,15 +30221,30 @@ function isLivePairAuto(pid) {
30160
30221
  } catch (e) {
30161
30222
  if (e.code !== "EPERM") return false;
30162
30223
  }
30224
+ const cmdline = readProcFile(`${pid}/cmdline`);
30225
+ if (cmdline === void 0) return true;
30226
+ const tgid = procTgid(pid);
30227
+ if (tgid !== void 0 && tgid !== pid) return false;
30228
+ return cmdline.includes("codeam");
30229
+ }
30230
+ function isLiveLockHolder(rec) {
30231
+ if (!rec || rec.pid === process.pid) return false;
30232
+ if (rec.boot) {
30233
+ const boot = currentBootId();
30234
+ if (boot && boot !== rec.boot) return false;
30235
+ }
30236
+ if (rec.start) {
30237
+ const start2 = procStartTicks(rec.pid);
30238
+ if (start2 !== void 0 && start2 !== rec.start) return false;
30239
+ }
30240
+ return isLivePairAuto(rec.pid);
30241
+ }
30242
+ function releaseOwnLock(lockPath) {
30163
30243
  try {
30164
- return fs66.readFileSync(`/proc/${pid}/cmdline`, "utf8").includes("codeam");
30244
+ if (readLockRecord(lockPath)?.pid === process.pid) fs66.unlinkSync(lockPath);
30165
30245
  } catch {
30166
- return true;
30167
30246
  }
30168
30247
  }
30169
- function isLiveCodeam(pid) {
30170
- return isLivePairAuto(pid);
30171
- }
30172
30248
  function daemonLockPath(sessionId) {
30173
30249
  const safe = sessionId.replace(/[^a-zA-Z0-9_-]/g, "_");
30174
30250
  return path72.join(os55.homedir(), ".codeam", `daemon-${safe}.lock`);
@@ -30178,21 +30254,13 @@ function acquireDaemonLock(sessionId) {
30178
30254
  try {
30179
30255
  fs66.mkdirSync(path72.dirname(lockPath), { recursive: true });
30180
30256
  try {
30181
- fs66.writeFileSync(lockPath, String(process.pid), { flag: "wx" });
30257
+ fs66.writeFileSync(lockPath, ownLockBody(), { flag: "wx" });
30182
30258
  } catch (e) {
30183
30259
  if (e.code !== "EEXIST") throw e;
30184
- const holder = Number(fs66.readFileSync(lockPath, "utf8").trim());
30185
- if (holder && holder !== process.pid && isLiveCodeam(holder)) return false;
30186
- fs66.writeFileSync(lockPath, String(process.pid));
30260
+ if (isLiveLockHolder(readLockRecord(lockPath))) return false;
30261
+ fs66.writeFileSync(lockPath, ownLockBody());
30187
30262
  }
30188
- const release3 = () => {
30189
- try {
30190
- if (fs66.existsSync(lockPath) && Number(fs66.readFileSync(lockPath, "utf8").trim()) === process.pid) {
30191
- fs66.unlinkSync(lockPath);
30192
- }
30193
- } catch {
30194
- }
30195
- };
30263
+ const release3 = () => releaseOwnLock(lockPath);
30196
30264
  process.once("exit", release3);
30197
30265
  process.once("SIGTERM", () => {
30198
30266
  release3();
@@ -30212,21 +30280,13 @@ function acquireSingletonLock() {
30212
30280
  try {
30213
30281
  fs66.mkdirSync(path72.dirname(lockPath), { recursive: true });
30214
30282
  try {
30215
- fs66.writeFileSync(lockPath, String(process.pid), { flag: "wx" });
30283
+ fs66.writeFileSync(lockPath, ownLockBody(), { flag: "wx" });
30216
30284
  } catch (e) {
30217
30285
  if (e.code !== "EEXIST") throw e;
30218
- const holder = Number(fs66.readFileSync(lockPath, "utf8").trim());
30219
- if (isLivePairAuto(holder)) return false;
30220
- fs66.writeFileSync(lockPath, String(process.pid));
30286
+ if (isLiveLockHolder(readLockRecord(lockPath))) return false;
30287
+ fs66.writeFileSync(lockPath, ownLockBody());
30221
30288
  }
30222
- process.once("exit", () => {
30223
- try {
30224
- if (fs66.existsSync(lockPath) && Number(fs66.readFileSync(lockPath, "utf8").trim()) === process.pid) {
30225
- fs66.unlinkSync(lockPath);
30226
- }
30227
- } catch {
30228
- }
30229
- });
30289
+ process.once("exit", () => releaseOwnLock(lockPath));
30230
30290
  return true;
30231
30291
  } catch {
30232
30292
  return true;
@@ -47540,7 +47600,7 @@ function checkChokidar() {
47540
47600
  }
47541
47601
  async function doctor(args2 = []) {
47542
47602
  const json = args2.includes("--json");
47543
- const cliVersion = true ? "2.74.6" : "0.0.0-dev";
47603
+ const cliVersion = true ? "2.74.8" : "0.0.0-dev";
47544
47604
  const apiBase2 = resolveApiBaseUrl();
47545
47605
  const diagnosticId = (0, import_node_crypto13.randomUUID)();
47546
47606
  log.info("doctor", `run id=${diagnosticId} cli=${cliVersion}`);
@@ -48064,7 +48124,7 @@ async function mcpWarm(argv = [], opts = {}) {
48064
48124
  // src/commands/version.ts
48065
48125
  var import_picocolors15 = __toESM(require("picocolors"));
48066
48126
  function version2() {
48067
- const v = true ? "2.74.6" : "unknown";
48127
+ const v = true ? "2.74.8" : "unknown";
48068
48128
  console.log(`${import_picocolors15.default.bold("codeam-cli")} ${import_picocolors15.default.cyan(v)}`);
48069
48129
  }
48070
48130
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codeam-cli",
3
- "version": "2.74.6",
3
+ "version": "2.74.8",
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",