@zqagent/core 0.2.6 → 0.2.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.
package/dist/cli/index.js CHANGED
@@ -552,7 +552,7 @@ var init_wire = __esm({
552
552
  // src/cli/index.ts
553
553
  init_esm_shims();
554
554
  import "dotenv/config";
555
- import * as fs33 from "fs";
555
+ import * as fs34 from "fs";
556
556
  import * as readline2 from "readline";
557
557
  import * as path43 from "path";
558
558
  import { exec } from "child_process";
@@ -11170,7 +11170,7 @@ init_esm_shims();
11170
11170
 
11171
11171
  // src/server/runtime.ts
11172
11172
  init_esm_shims();
11173
- import * as fs30 from "fs";
11173
+ import * as fs31 from "fs";
11174
11174
  import * as path38 from "path";
11175
11175
 
11176
11176
  // src/server/session.ts
@@ -13562,7 +13562,7 @@ function buildNodeInfo(store, opts) {
13562
13562
  nodeId: opts.nodeId ?? ensureNodeId2(store),
13563
13563
  platform: process.platform,
13564
13564
  mode: process.env.NODE_MODE ?? "standalone",
13565
- version: "0.2.6",
13565
+ version: "0.2.8",
13566
13566
  admin: opts.admin,
13567
13567
  projects: opts.projects
13568
13568
  };
@@ -14555,7 +14555,7 @@ function buildNodeHost(store, manager, diskPath) {
14555
14555
  arch: process.arch,
14556
14556
  release: os6.release(),
14557
14557
  uptimeSec: Math.round(os6.uptime()),
14558
- version: "0.2.6",
14558
+ version: "0.2.8",
14559
14559
  mode: process.env.NODE_MODE ?? "standalone",
14560
14560
  cpu: {
14561
14561
  count: cpus2.length,
@@ -16107,7 +16107,7 @@ function createApp(store, manager, opts = {}) {
16107
16107
  json(res, 200, {
16108
16108
  status: "ok",
16109
16109
  // 版本让运维/探针能确认线上跑的是哪个构建(更新与回滚据此判断)
16110
- version: "0.2.6",
16110
+ version: "0.2.8",
16111
16111
  features: { mcp: hasServerMcpConfig() }
16112
16112
  });
16113
16113
  return;
@@ -17745,7 +17745,7 @@ var FleetNodeBridge = class {
17745
17745
  label: this.opts.deps.store.loadNodeLabel() ?? void 0,
17746
17746
  platform: process.platform,
17747
17747
  mode: process.env.NODE_MODE ?? "standalone",
17748
- version: "0.2.6",
17748
+ version: "0.2.8",
17749
17749
  ip: primaryIp()
17750
17750
  };
17751
17751
  }
@@ -17800,7 +17800,7 @@ var FleetNodeBridge = class {
17800
17800
  label: this.opts.deps.store.loadNodeLabel() ?? void 0,
17801
17801
  platform: process.platform,
17802
17802
  mode: process.env.NODE_MODE ?? "standalone",
17803
- version: "0.2.6",
17803
+ version: "0.2.8",
17804
17804
  ip: primaryIp(),
17805
17805
  projects,
17806
17806
  totals,
@@ -19211,7 +19211,7 @@ var PairingCodeStore = class {
19211
19211
 
19212
19212
  // src/update/controller.ts
19213
19213
  init_esm_shims();
19214
- import * as fs29 from "fs";
19214
+ import * as fs30 from "fs";
19215
19215
  import * as path37 from "path";
19216
19216
 
19217
19217
  // src/update/downloader.ts
@@ -19464,10 +19464,12 @@ function selfCheck(binPath, expectedVersion) {
19464
19464
 
19465
19465
  // src/update/platform.ts
19466
19466
  init_esm_shims();
19467
+ import * as fs27 from "fs";
19467
19468
  import * as path34 from "path";
19469
+ import { spawnSync as spawnSync4 } from "child_process";
19468
19470
  import { createRequire as createRequire3 } from "module";
19469
19471
  function currentVersion() {
19470
- const injected = "0.2.6"?.trim();
19472
+ const injected = "0.2.8"?.trim();
19471
19473
  if (injected) return injected;
19472
19474
  try {
19473
19475
  const req2 = createRequire3(import.meta.url);
@@ -19482,9 +19484,62 @@ function isSeaRuntime() {
19482
19484
  const base = path34.basename(process.execPath).toLowerCase().replace(/\.exe$/, "");
19483
19485
  return base !== "node" && base !== "nodejs";
19484
19486
  }
19487
+ var DEFAULT_SERVICE_NAME = "zqagent";
19488
+ function serviceManagerFromCgroup(cgroup, serviceName = DEFAULT_SERVICE_NAME) {
19489
+ const unitName = `${serviceName}.service`;
19490
+ for (const line of cgroup.split("\n")) {
19491
+ const idx = line.lastIndexOf(":");
19492
+ if (idx < 0) continue;
19493
+ const unitPath = line.slice(idx + 1).trim();
19494
+ if (unitPath.split("/").includes(unitName)) return "systemd";
19495
+ }
19496
+ return null;
19497
+ }
19498
+ function detectServiceManager() {
19499
+ if (process.platform !== "linux") return null;
19500
+ const serviceName = process.env.ZQAGENT_SERVICE_NAME?.trim() || DEFAULT_SERVICE_NAME;
19501
+ try {
19502
+ return serviceManagerFromCgroup(
19503
+ fs27.readFileSync("/proc/self/cgroup", "utf8"),
19504
+ serviceName
19505
+ );
19506
+ } catch {
19507
+ return null;
19508
+ }
19509
+ }
19485
19510
  function serviceManager() {
19486
19511
  const v = process.env.ZQAGENT_SERVICE_MANAGER?.trim().toLowerCase();
19487
- return v === "systemd" || v === "launchd" ? v : null;
19512
+ if (v === "systemd" || v === "launchd") return v;
19513
+ return detectServiceManager();
19514
+ }
19515
+ function parseServiceEnvironment(raw) {
19516
+ const out = {};
19517
+ for (const token of raw.trim().split(/\s+/)) {
19518
+ const idx = token.indexOf("=");
19519
+ if (idx > 0) out[token.slice(0, idx)] = token.slice(idx + 1);
19520
+ }
19521
+ return out;
19522
+ }
19523
+ var cachedServiceEnv = null;
19524
+ function readServiceEnvironment() {
19525
+ const serviceName = process.env.ZQAGENT_SERVICE_NAME?.trim() || DEFAULT_SERVICE_NAME;
19526
+ try {
19527
+ const res = spawnSync4(
19528
+ "systemctl",
19529
+ ["show", serviceName, "--property=Environment", "--value", "--no-pager"],
19530
+ { encoding: "utf8", timeout: 3e3 }
19531
+ );
19532
+ if (res.status !== 0 || !res.stdout) return {};
19533
+ return parseServiceEnvironment(res.stdout);
19534
+ } catch {
19535
+ return {};
19536
+ }
19537
+ }
19538
+ function serviceEnvValue(key) {
19539
+ if (process.platform !== "linux") return void 0;
19540
+ if (serviceManager() !== "systemd") return void 0;
19541
+ cachedServiceEnv ??= readServiceEnvironment();
19542
+ return cachedServiceEnv[key];
19488
19543
  }
19489
19544
  function selfUpdateCapability(hasPublicKey) {
19490
19545
  if (!isSeaRuntime()) {
@@ -19507,12 +19562,12 @@ function selfUpdateCapability(hasPublicKey) {
19507
19562
 
19508
19563
  // src/update/installer.ts
19509
19564
  init_esm_shims();
19510
- import * as fs28 from "fs";
19565
+ import * as fs29 from "fs";
19511
19566
  import * as path36 from "path";
19512
19567
 
19513
19568
  // src/update/state.ts
19514
19569
  init_esm_shims();
19515
- import * as fs27 from "fs";
19570
+ import * as fs28 from "fs";
19516
19571
  import * as path35 from "path";
19517
19572
  function updatesDir(dataDir) {
19518
19573
  return path35.join(dataDir, "updates");
@@ -19522,7 +19577,7 @@ function statePath(dataDir) {
19522
19577
  }
19523
19578
  function loadState(dataDir) {
19524
19579
  try {
19525
- const raw = fs27.readFileSync(statePath(dataDir), "utf-8");
19580
+ const raw = fs28.readFileSync(statePath(dataDir), "utf-8");
19526
19581
  const parsed = JSON.parse(raw);
19527
19582
  if (typeof parsed === "object" && parsed !== null) return parsed;
19528
19583
  } catch {
@@ -19531,11 +19586,11 @@ function loadState(dataDir) {
19531
19586
  }
19532
19587
  function saveState(dataDir, state) {
19533
19588
  const dir = updatesDir(dataDir);
19534
- fs27.mkdirSync(dir, { recursive: true });
19589
+ fs28.mkdirSync(dir, { recursive: true });
19535
19590
  const file = statePath(dataDir);
19536
19591
  const tmp = `${file}.tmp`;
19537
- fs27.writeFileSync(tmp, JSON.stringify(state, null, 2), "utf-8");
19538
- fs27.renameSync(tmp, file);
19592
+ fs28.writeFileSync(tmp, JSON.stringify(state, null, 2), "utf-8");
19593
+ fs28.renameSync(tmp, file);
19539
19594
  }
19540
19595
  function patchState(dataDir, patch) {
19541
19596
  const next = { ...loadState(dataDir), ...patch };
@@ -19549,32 +19604,32 @@ function backupDir(dataDir) {
19549
19604
  }
19550
19605
  function backupCurrent(dataDir, execPath, version) {
19551
19606
  const dir = backupDir(dataDir);
19552
- fs28.mkdirSync(dir, { recursive: true });
19607
+ fs29.mkdirSync(dir, { recursive: true });
19553
19608
  const target = path36.join(dir, `zqagent-${version}${process.platform === "win32" ? ".exe" : ""}`);
19554
- fs28.copyFileSync(execPath, target);
19555
- fs28.chmodSync(target, 493);
19609
+ fs29.copyFileSync(execPath, target);
19610
+ fs29.chmodSync(target, 493);
19556
19611
  return target;
19557
19612
  }
19558
19613
  function replaceExecutable(execPath, stagedPath) {
19559
19614
  if (process.platform === "win32") {
19560
19615
  const oldPath = `${execPath}.old`;
19561
- fs28.rmSync(oldPath, { force: true });
19562
- fs28.renameSync(execPath, oldPath);
19563
- fs28.copyFileSync(stagedPath, execPath);
19564
- fs28.chmodSync(execPath, 493);
19616
+ fs29.rmSync(oldPath, { force: true });
19617
+ fs29.renameSync(execPath, oldPath);
19618
+ fs29.copyFileSync(stagedPath, execPath);
19619
+ fs29.chmodSync(execPath, 493);
19565
19620
  return;
19566
19621
  }
19567
19622
  const tmp = `${execPath}.new`;
19568
- fs28.rmSync(tmp, { force: true });
19623
+ fs29.rmSync(tmp, { force: true });
19569
19624
  try {
19570
- fs28.copyFileSync(stagedPath, tmp);
19571
- fs28.chmodSync(tmp, 493);
19572
- fs28.renameSync(tmp, execPath);
19625
+ fs29.copyFileSync(stagedPath, tmp);
19626
+ fs29.chmodSync(tmp, 493);
19627
+ fs29.renameSync(tmp, execPath);
19573
19628
  } catch (err) {
19574
- fs28.rmSync(tmp, { force: true });
19629
+ fs29.rmSync(tmp, { force: true });
19575
19630
  throw err;
19576
19631
  }
19577
- fs28.rmSync(stagedPath, { force: true });
19632
+ fs29.rmSync(stagedPath, { force: true });
19578
19633
  }
19579
19634
  function installStaged(opts) {
19580
19635
  const log = opts.log ?? (() => {
@@ -19601,18 +19656,18 @@ function rollback(dataDir, execPath, log = () => {
19601
19656
  }) {
19602
19657
  const state = readRollbackTarget(dataDir);
19603
19658
  if (!state?.backupPath || !state.backupVersion) return null;
19604
- if (!fs28.existsSync(state.backupPath)) return null;
19659
+ if (!fs29.existsSync(state.backupPath)) return null;
19605
19660
  log(`\u6B63\u5728\u56DE\u6EDA\u5230 v${state.backupVersion}`);
19606
19661
  if (process.platform === "win32") {
19607
- fs28.rmSync(`${execPath}.old`, { force: true });
19608
- fs28.renameSync(execPath, `${execPath}.old`);
19609
- fs28.copyFileSync(state.backupPath, execPath);
19610
- fs28.chmodSync(execPath, 493);
19662
+ fs29.rmSync(`${execPath}.old`, { force: true });
19663
+ fs29.renameSync(execPath, `${execPath}.old`);
19664
+ fs29.copyFileSync(state.backupPath, execPath);
19665
+ fs29.chmodSync(execPath, 493);
19611
19666
  } else {
19612
19667
  const tmp = `${execPath}.rollback`;
19613
- fs28.copyFileSync(state.backupPath, tmp);
19614
- fs28.chmodSync(tmp, 493);
19615
- fs28.renameSync(tmp, execPath);
19668
+ fs29.copyFileSync(state.backupPath, tmp);
19669
+ fs29.chmodSync(tmp, 493);
19670
+ fs29.renameSync(tmp, execPath);
19616
19671
  }
19617
19672
  patchState(dataDir, {
19618
19673
  pendingVersion: state.backupVersion,
@@ -19626,7 +19681,7 @@ function rollback(dataDir, execPath, log = () => {
19626
19681
  }
19627
19682
  function readRollbackTarget(dataDir) {
19628
19683
  try {
19629
- const raw = fs28.readFileSync(path36.join(updatesDir(dataDir), "state.json"), "utf-8");
19684
+ const raw = fs29.readFileSync(path36.join(updatesDir(dataDir), "state.json"), "utf-8");
19630
19685
  const s = JSON.parse(raw);
19631
19686
  if (s.backupPath && s.backupVersion) return s;
19632
19687
  } catch {
@@ -19638,7 +19693,9 @@ function readRollbackTarget(dataDir) {
19638
19693
  var DEFAULT_BASE = "https://agent.cd-zq.com/downloads/zqagent";
19639
19694
  function env(key) {
19640
19695
  const v = process.env[key]?.trim();
19641
- return v ? v : void 0;
19696
+ if (v) return v;
19697
+ const fromService = serviceEnvValue(key)?.trim();
19698
+ return fromService ? fromService : void 0;
19642
19699
  }
19643
19700
  function num(key, fallback) {
19644
19701
  const n = Number(env(key));
@@ -19675,7 +19732,7 @@ var UpdateController = class {
19675
19732
  return parsePublicKey(env("ZQAGENT_UPDATE_PUBKEY") ?? "");
19676
19733
  }
19677
19734
  get autoUpdateOff() {
19678
- return process.env.ZQAGENT_AUTO_UPDATE?.trim() === "0";
19735
+ return env("ZQAGENT_AUTO_UPDATE") === "0";
19679
19736
  }
19680
19737
  get enabled() {
19681
19738
  return !this.autoUpdateOff && selfUpdateCapability(Boolean(this.publicKey)).ok;
@@ -19709,7 +19766,7 @@ var UpdateController = class {
19709
19766
  reconcile() {
19710
19767
  const state = loadState(this.opts.dataDir);
19711
19768
  const current = this.currentVersion;
19712
- if (state.stagedPath && !fs29.existsSync(state.stagedPath)) {
19769
+ if (state.stagedPath && !fs30.existsSync(state.stagedPath)) {
19713
19770
  patchState(this.opts.dataDir, { stagedVersion: void 0, stagedPath: void 0 });
19714
19771
  }
19715
19772
  const patch = { runningVersion: current };
@@ -19724,7 +19781,7 @@ var UpdateController = class {
19724
19781
  }
19725
19782
  patchState(this.opts.dataDir, patch);
19726
19783
  if (process.platform === "win32") {
19727
- fs29.rmSync(`${process.execPath}.old`, { force: true });
19784
+ fs30.rmSync(`${process.execPath}.old`, { force: true });
19728
19785
  }
19729
19786
  }
19730
19787
  schedule(delayMs) {
@@ -19800,7 +19857,7 @@ var UpdateController = class {
19800
19857
  const bin = manifest.binaries[platformKey()];
19801
19858
  if (!bin) return `\u6E05\u5355\u6CA1\u6709\u5F53\u524D\u5E73\u53F0\uFF08${platformKey()}\uFF09\u7684\u4EA7\u7269`;
19802
19859
  let stagedPath = state.stagedPath;
19803
- if (!(state.stagedVersion === manifest.version && stagedPath && fs29.existsSync(stagedPath))) {
19860
+ if (!(state.stagedVersion === manifest.version && stagedPath && fs30.existsSync(stagedPath))) {
19804
19861
  stagedPath = path37.join(
19805
19862
  updatesDir(this.opts.dataDir),
19806
19863
  "staged",
@@ -19813,7 +19870,7 @@ var UpdateController = class {
19813
19870
  }
19814
19871
  const selfTest = selfCheck(stagedPath, manifest.version);
19815
19872
  if (!selfTest.ok) {
19816
- fs29.rmSync(stagedPath, { force: true });
19873
+ fs30.rmSync(stagedPath, { force: true });
19817
19874
  this.recordFailure(manifest.version, selfTest.error ?? "\u81EA\u68C0\u5931\u8D25");
19818
19875
  return `\u5B89\u88C5\u5305\u81EA\u68C0\u5931\u8D25\uFF1A${selfTest.error}`;
19819
19876
  }
@@ -19954,7 +20011,7 @@ function pemFile(key) {
19954
20011
  const p = env2(key);
19955
20012
  if (!p) return void 0;
19956
20013
  try {
19957
- return fs30.readFileSync(p);
20014
+ return fs31.readFileSync(p);
19958
20015
  } catch (e) {
19959
20016
  console.warn(`[tls] \u8BFB\u53D6 ${key}=${p} \u5931\u8D25: ${e instanceof Error ? e.message : e}`);
19960
20017
  return void 0;
@@ -20639,17 +20696,17 @@ async function runUpdateCommand(argv) {
20639
20696
 
20640
20697
  // src/cli/sessionMeta.ts
20641
20698
  init_esm_shims();
20642
- import * as fs31 from "fs";
20699
+ import * as fs32 from "fs";
20643
20700
  import * as path41 from "path";
20644
20701
  function updateSessionMetaFile(stateDir2, sessionId, patch) {
20645
20702
  const file = path41.join(stateDir2, `${sessionId}_state.json`);
20646
20703
  try {
20647
- const raw = fs31.readFileSync(file, "utf8");
20704
+ const raw = fs32.readFileSync(file, "utf8");
20648
20705
  const state = JSON.parse(raw);
20649
20706
  if (patch.name !== void 0) state.name = patch.name;
20650
20707
  if (patch.nameSource !== void 0) state.nameSource = patch.nameSource;
20651
20708
  if (patch.taskCount !== void 0) state.taskCount = patch.taskCount;
20652
- fs31.writeFileSync(file, JSON.stringify(state, null, 2), "utf8");
20709
+ fs32.writeFileSync(file, JSON.stringify(state, null, 2), "utf8");
20653
20710
  return true;
20654
20711
  } catch {
20655
20712
  return false;
@@ -20658,7 +20715,7 @@ function updateSessionMetaFile(stateDir2, sessionId, patch) {
20658
20715
 
20659
20716
  // src/cli/debug.ts
20660
20717
  init_esm_shims();
20661
- import * as fs32 from "fs";
20718
+ import * as fs33 from "fs";
20662
20719
  import * as os8 from "os";
20663
20720
  import * as path42 from "path";
20664
20721
  var LOG_NAME = "zqagent-debug.log";
@@ -20689,8 +20746,8 @@ function enableDebug(argv = process.argv) {
20689
20746
  enabled = true;
20690
20747
  logFile = resolveLogFile();
20691
20748
  try {
20692
- fs32.mkdirSync(path42.dirname(logFile), { recursive: true });
20693
- fs32.writeFileSync(logFile, "");
20749
+ fs33.mkdirSync(path42.dirname(logFile), { recursive: true });
20750
+ fs33.writeFileSync(logFile, "");
20694
20751
  } catch {
20695
20752
  logFile = null;
20696
20753
  }
@@ -20707,7 +20764,7 @@ function dlog(stage, message = "") {
20707
20764
  const line = `[+${String(Date.now() - startedAt).padStart(6)}ms] [${stage}] ${message}`;
20708
20765
  if (logFile) {
20709
20766
  try {
20710
- fs32.appendFileSync(logFile, line + "\n");
20767
+ fs33.appendFileSync(logFile, line + "\n");
20711
20768
  } catch {
20712
20769
  }
20713
20770
  }
@@ -20872,13 +20929,13 @@ var MAX_ITERATIONS = parseMaxIterations(process.env.MAX_ITERATIONS, 300);
20872
20929
  var STATE_DIR = stateDir();
20873
20930
  function listSessions() {
20874
20931
  try {
20875
- const files = fs33.readdirSync(STATE_DIR);
20932
+ const files = fs34.readdirSync(STATE_DIR);
20876
20933
  const sessions = [];
20877
20934
  for (const f of files) {
20878
20935
  if (!f.endsWith("_state.json")) continue;
20879
20936
  try {
20880
20937
  const parsed = JSON.parse(
20881
- fs33.readFileSync(path43.join(STATE_DIR, f), "utf8")
20938
+ fs34.readFileSync(path43.join(STATE_DIR, f), "utf8")
20882
20939
  );
20883
20940
  if (parsed && typeof parsed.sessionId === "string") {
20884
20941
  sessions.push(parsed);
@@ -20915,8 +20972,8 @@ function printLastAssistantMessage(messages) {
20915
20972
  var AGENTS_FILE = path43.join(WORKSPACE, ".agent", "agents.json");
20916
20973
  function loadAgentsFromFile() {
20917
20974
  try {
20918
- if (!fs33.existsSync(AGENTS_FILE)) return [];
20919
- const raw = fs33.readFileSync(AGENTS_FILE, "utf8");
20975
+ if (!fs34.existsSync(AGENTS_FILE)) return [];
20976
+ const raw = fs34.readFileSync(AGENTS_FILE, "utf8");
20920
20977
  const parsed = JSON.parse(raw);
20921
20978
  if (!Array.isArray(parsed)) return [];
20922
20979
  return parsed.filter(
@@ -20928,8 +20985,8 @@ function loadAgentsFromFile() {
20928
20985
  }
20929
20986
  function saveAgentsToFile(defs) {
20930
20987
  try {
20931
- fs33.mkdirSync(path43.dirname(AGENTS_FILE), { recursive: true });
20932
- fs33.writeFileSync(AGENTS_FILE, JSON.stringify(defs, null, 2) + "\n", "utf8");
20988
+ fs34.mkdirSync(path43.dirname(AGENTS_FILE), { recursive: true });
20989
+ fs34.writeFileSync(AGENTS_FILE, JSON.stringify(defs, null, 2) + "\n", "utf8");
20933
20990
  } catch (err) {
20934
20991
  cliErr(`\u26A0\uFE0F \u4FDD\u5B58 agents \u914D\u7F6E\u5931\u8D25: ${err}`);
20935
20992
  }
@@ -20942,8 +20999,8 @@ var MCP_FILE = path43.join(WORKSPACE, ".agent", "mcp.json");
20942
20999
  var COMMAND_TOOLS_FILE = path43.join(WORKSPACE, ".agent", "tools.json");
20943
21000
  function loadJsonArray(file, validate) {
20944
21001
  try {
20945
- if (!fs33.existsSync(file)) return [];
20946
- const parsed = JSON.parse(fs33.readFileSync(file, "utf8"));
21002
+ if (!fs34.existsSync(file)) return [];
21003
+ const parsed = JSON.parse(fs34.readFileSync(file, "utf8"));
20947
21004
  if (!Array.isArray(parsed)) return [];
20948
21005
  if (!validate) return parsed;
20949
21006
  return parsed.filter((v) => validate(v));
@@ -20953,8 +21010,8 @@ function loadJsonArray(file, validate) {
20953
21010
  }
20954
21011
  function saveJsonFile(file, data) {
20955
21012
  try {
20956
- fs33.mkdirSync(path43.dirname(file), { recursive: true });
20957
- fs33.writeFileSync(file, JSON.stringify(data, null, 2) + "\n", "utf8");
21013
+ fs34.mkdirSync(path43.dirname(file), { recursive: true });
21014
+ fs34.writeFileSync(file, JSON.stringify(data, null, 2) + "\n", "utf8");
20958
21015
  } catch (err) {
20959
21016
  cliErr(`\u26A0\uFE0F \u4FDD\u5B58\u914D\u7F6E\u5931\u8D25: ${err}`);
20960
21017
  }
@@ -21055,7 +21112,7 @@ function pruneEmptySessions(keepSessionId) {
21055
21112
  if (!isEmptySession(s) || s.sessionId === keepSessionId) continue;
21056
21113
  for (const suffix of ["_state.json", ".jsonl"]) {
21057
21114
  try {
21058
- fs33.unlinkSync(path43.join(STATE_DIR, `${s.sessionId}${suffix}`));
21115
+ fs34.unlinkSync(path43.join(STATE_DIR, `${s.sessionId}${suffix}`));
21059
21116
  } catch {
21060
21117
  }
21061
21118
  }
@@ -21588,7 +21645,7 @@ async function offerTerminalSetup(engine, canUseAgent) {
21588
21645
  }
21589
21646
  var KNOWN_SUBCOMMANDS = /* @__PURE__ */ new Set(["link", "serve", "update"]);
21590
21647
  function cliVersion() {
21591
- const env3 = "0.2.6"?.trim();
21648
+ const env3 = "0.2.8"?.trim();
21592
21649
  if (env3) return env3;
21593
21650
  try {
21594
21651
  const req2 = createRequire4(import.meta.url);
@@ -21793,7 +21850,7 @@ async function main() {
21793
21850
  });
21794
21851
  const savedState = resumeId ? FileLogHook.loadState(resumeId, STATE_DIR) : null;
21795
21852
  const metaStateFile = path43.join(STATE_DIR, `${SESSION_ID}_state.json`);
21796
- const stateForMeta = savedState ?? (fs33.existsSync(metaStateFile) ? FileLogHook.loadState(SESSION_ID, STATE_DIR) : null);
21853
+ const stateForMeta = savedState ?? (fs34.existsSync(metaStateFile) ? FileLogHook.loadState(SESSION_ID, STATE_DIR) : null);
21797
21854
  sessionMeta = {
21798
21855
  sessionId: SESSION_ID,
21799
21856
  name: stateForMeta?.name,