codeam-cli 2.39.48 → 2.39.50

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
@@ -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.39.49] — 2026-06-19
8
+
9
+ ### Fixed
10
+
11
+ - **cli:** Load codespace-env.json + start savings reporter on serving daemon
12
+
13
+ ## [2.39.48] — 2026-06-19
14
+
15
+ ### Fixed
16
+
17
+ - **cli:** Per-session daemon singleton — stop duplicate codeam daemons
18
+
7
19
  ## [2.39.47] — 2026-06-19
8
20
 
9
21
  ### Fixed
package/dist/index.js CHANGED
@@ -488,6 +488,27 @@ function makeConfig(baseDir) {
488
488
  }
489
489
  return { getConfig: getConfig2, ensurePluginId: ensurePluginId2, addSession: addSession2, removeSession: removeSession2, setActiveSession: setActiveSession2, getActiveSession: getActiveSession2, getActiveSessionForAgent: getActiveSessionForAgent2, clearAll: clearAll2, saveCliConfig: saveCliConfig2, loadCliConfig: loadCliConfig2 };
490
490
  }
491
+ var CODESPACE_ENV_KEYS = [
492
+ "PREVIEW_TUNNEL_TOKEN",
493
+ "PREVIEW_TUNNEL_HOSTNAME",
494
+ "HEADROOM_ENABLED",
495
+ "HEADROOM_AGENT",
496
+ "HEADROOM_SAVINGS_INGEST_URL"
497
+ ];
498
+ function loadCodespaceEnv() {
499
+ try {
500
+ const file = path.join(os.homedir(), ".codeam", "codespace-env.json");
501
+ if (!fs.existsSync(file)) return;
502
+ const raw = JSON.parse(fs.readFileSync(file, "utf-8"));
503
+ for (const key of CODESPACE_ENV_KEYS) {
504
+ const value = raw[key];
505
+ if (typeof value === "string" && value.length > 0 && process.env[key] === void 0) {
506
+ process.env[key] = value;
507
+ }
508
+ }
509
+ } catch {
510
+ }
511
+ }
491
512
  var _default = makeConfig();
492
513
  var { getConfig, ensurePluginId, addSession, removeSession, setActiveSession, getActiveSession, getActiveSessionForAgent, clearAll, saveCliConfig, loadCliConfig } = _default;
493
514
 
@@ -5367,7 +5388,7 @@ function readAnonId() {
5367
5388
  }
5368
5389
  function superProperties() {
5369
5390
  return {
5370
- cliVersion: true ? "2.39.48" : "0.0.0-dev",
5391
+ cliVersion: true ? "2.39.50" : "0.0.0-dev",
5371
5392
  nodeVersion: process.version,
5372
5393
  platform: process.platform,
5373
5394
  arch: process.arch,
@@ -5526,7 +5547,7 @@ var os4 = __toESM(require("os"));
5526
5547
  // package.json
5527
5548
  var package_default = {
5528
5549
  name: "codeam-cli",
5529
- version: "2.39.48",
5550
+ version: "2.39.50",
5530
5551
  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.",
5531
5552
  type: "commonjs",
5532
5553
  main: "dist/index.js",
@@ -17097,12 +17118,15 @@ function provisionAgentCredentials(publicAgentId, auth, homeDir2 = os30.homedir(
17097
17118
  // src/services/headroom/stats-reporter.ts
17098
17119
  var ZERO = { rawTokensEst: 0, sentTokensEst: 0, cachedTokens: 0, retrieveHops: 0 };
17099
17120
  function read(stats) {
17100
- const p2 = stats.persistent_savings ?? {};
17121
+ const totals = stats.agent_usage?.totals;
17122
+ const compression = stats.summary?.compression;
17123
+ const rawTokensEst = totals?.before_tokens ?? compression?.total_tokens_before_with_cli_filtering ?? 0;
17124
+ const sentTokensEst = totals?.after_tokens ?? rawTokensEst - (compression?.total_tokens_removed ?? 0);
17101
17125
  return {
17102
- rawTokensEst: p2.tokens_before ?? p2.input_tokens ?? p2.tokensBefore ?? 0,
17103
- sentTokensEst: p2.tokens_after ?? p2.output_tokens ?? p2.tokensAfter ?? 0,
17104
- cachedTokens: p2.cached_tokens ?? p2.cache_read_input_tokens ?? p2.cachedTokens ?? 0,
17105
- retrieveHops: p2.retrieve_hops ?? p2.retrieveHops ?? 0
17126
+ rawTokensEst,
17127
+ sentTokensEst,
17128
+ cachedTokens: 0,
17129
+ retrieveHops: stats.summary?.mcp?.retrievals ?? 0
17106
17130
  };
17107
17131
  }
17108
17132
  function mapStatsToSavings(stats, prev) {
@@ -24822,6 +24846,15 @@ async function start(requestedAgent) {
24822
24846
  "pluginAuth",
24823
24847
  `boot triple sessionId=${session.id} pluginId=${pluginId} tokenLen=${tokenForLog.length} tokenHead=${tokenForLog.slice(0, 12)} tokenTail=${tokenForLog.slice(-8)} mintedEqualsCached=${refreshed === session.pluginAuthToken}`
24824
24848
  );
24849
+ const headroomReporter = session.pluginAuthToken ? maybeStartHeadroomReporter({
24850
+ sessionId: session.id,
24851
+ pluginId,
24852
+ pluginAuthToken: session.pluginAuthToken,
24853
+ codespaceId: process.env["CODESPACE_NAME"] ?? session.id
24854
+ }) : null;
24855
+ process.once("exit", () => {
24856
+ headroomReporter?.stop();
24857
+ });
24825
24858
  if (process.env.CODESPACES === "true") ensureClaudeOnboarded();
24826
24859
  let beads = null;
24827
24860
  const getBeads = () => beads;
@@ -27534,7 +27567,7 @@ function checkChokidar() {
27534
27567
  }
27535
27568
  async function doctor(args2 = []) {
27536
27569
  const json = args2.includes("--json");
27537
- const cliVersion = true ? "2.39.48" : "0.0.0-dev";
27570
+ const cliVersion = true ? "2.39.50" : "0.0.0-dev";
27538
27571
  const apiBase2 = resolveApiBaseUrl();
27539
27572
  const diagnosticId = (0, import_node_crypto8.randomUUID)();
27540
27573
  log.info("doctor", `run id=${diagnosticId} cli=${cliVersion}`);
@@ -27733,7 +27766,7 @@ async function completion(args2) {
27733
27766
  // src/commands/version.ts
27734
27767
  var import_picocolors13 = __toESM(require("picocolors"));
27735
27768
  function version2() {
27736
- const v = true ? "2.39.48" : "unknown";
27769
+ const v = true ? "2.39.50" : "unknown";
27737
27770
  console.log(`${import_picocolors13.default.bold("codeam-cli")} ${import_picocolors13.default.cyan(v)}`);
27738
27771
  }
27739
27772
 
@@ -28019,7 +28052,7 @@ function checkForUpdates() {
28019
28052
  if (process.env.CODEAM_DISABLE_UPDATE_CHECK === "1") return;
28020
28053
  if (process.env.CI) return;
28021
28054
  if (!process.stdout.isTTY) return;
28022
- const current = true ? "2.39.48" : null;
28055
+ const current = true ? "2.39.50" : null;
28023
28056
  if (!current) return;
28024
28057
  const cache = readCache();
28025
28058
  const fresh = cache && Date.now() - cache.fetchedAt < TTL_MS;
@@ -28058,6 +28091,7 @@ if (!process.env.HOME) {
28058
28091
  } catch {
28059
28092
  }
28060
28093
  }
28094
+ loadCodespaceEnv();
28061
28095
  var [, , command, ...args] = process.argv;
28062
28096
  async function main() {
28063
28097
  const isMetaCommand = command === "--version" || command === "-v" || command === "version" || command === "--help" || command === "-h" || command === "help";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codeam-cli",
3
- "version": "2.39.48",
3
+ "version": "2.39.50",
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",