conbridge-agent 0.9.0 → 0.9.2

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/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # conbridge-agent
2
2
 
3
- ConBridge Desktop Agent 0.9.0: connects a computer or server to ConBridge so the AI apps you approve (ChatGPT,
3
+ ConBridge Desktop Agent 0.9.2: connects a computer or server to ConBridge so the AI apps you approve (ChatGPT,
4
4
  Claude) can use the folders you share, or, with full access, its terminal. macOS, Linux (servers too), Raspberry Pi and
5
5
  Windows; Node.js 22 or later.
6
6
 
@@ -29,7 +29,7 @@ __export(cli_exports, {
29
29
  module.exports = __toCommonJS(cli_exports);
30
30
 
31
31
  // <define:__CONBRIDGE_BUILD__>
32
- var define_CONBRIDGE_BUILD_default = { version: "0.9.0", commit: "3118837e46a8", built_at: "2026-11-20T04:41:10.179Z", keychain_helper_sha256: "5a29362ad38d1b42cab3b8c6cec774fedfd1157a1a0152d7763899a1480ea123", distribution: "npm" };
32
+ var define_CONBRIDGE_BUILD_default = { version: "0.9.2", commit: "5b372fab5c1f", built_at: "2026-11-23T16:14:56.890Z", keychain_helper_sha256: "5a29362ad38d1b42cab3b8c6cec774fedfd1157a1a0152d7763899a1480ea123", distribution: "npm" };
33
33
 
34
34
  // dist/cli.js
35
35
  var import_promises22 = require("node:readline/promises");
@@ -24584,9 +24584,10 @@ var import_node_fs = require("node:fs");
24584
24584
  var import_node_path = require("node:path");
24585
24585
  var import_node_sea = require("node:sea");
24586
24586
  var import_node_url = require("node:url");
24587
- var SOURCE_VERSION = "0.9.0";
24587
+ var SOURCE_VERSION = "0.9.2";
24588
24588
  var BUILD_INFO = typeof define_CONBRIDGE_BUILD_default === "object" && define_CONBRIDGE_BUILD_default !== null ? define_CONBRIDGE_BUILD_default : null;
24589
24589
  var AGENT_VERSION = BUILD_INFO?.version ?? SOURCE_VERSION;
24590
+ var RUNTIME_DIR_NAME = "runtime";
24590
24591
  function runningAsSea() {
24591
24592
  try {
24592
24593
  return (0, import_node_sea.isSea)();
@@ -24746,6 +24747,19 @@ function buildLaunchAgentPlist(options) {
24746
24747
  function launchAgentPath(home = (0, import_node_os.homedir)()) {
24747
24748
  return (0, import_node_path3.join)(home, "Library", "LaunchAgents", `${LAUNCH_AGENT_LABEL}.plist`);
24748
24749
  }
24750
+ function defaultStateDirIn(home) {
24751
+ return (0, import_node_path3.join)(home, ".conbridge", "agent");
24752
+ }
24753
+ function xmlUnescape(value) {
24754
+ const entities = { amp: "&", lt: "<", gt: ">", quot: '"', apos: "'" };
24755
+ return value.replace(/&(amp|lt|gt|quot|apos);/g, (_, name3) => entities[name3]);
24756
+ }
24757
+ function launchAgentStateDir(plist, home) {
24758
+ if (!/<key>Label<\/key>\s*<string>com\.conbridge\.agent<\/string>/.test(plist))
24759
+ return null;
24760
+ const custom2 = /<key>CONBRIDGE_AGENT_HOME<\/key>\s*<string>([^<]*)<\/string>/.exec(plist);
24761
+ return custom2 ? xmlUnescape(custom2[1]) : defaultStateDirIn(home);
24762
+ }
24749
24763
  function defaultLogPath(home = (0, import_node_os.homedir)()) {
24750
24764
  return (0, import_node_path3.join)(home, "Library", "Logs", "conbridge-agent.log");
24751
24765
  }
@@ -24835,6 +24849,18 @@ function buildSystemdUnit(options) {
24835
24849
  ""
24836
24850
  ].join("\n");
24837
24851
  }
24852
+ function systemdUnword(quoted2) {
24853
+ return quoted2.replace(/\\(.)|%%|\$\$/g, (match, escaped) => escaped ?? match[0]);
24854
+ }
24855
+ function systemdUnitStateDir(unit2, home) {
24856
+ if (!/^Description=ConBridge Desktop Agent$/m.test(unit2))
24857
+ return null;
24858
+ const variable = (name3) => {
24859
+ const match = new RegExp(`^Environment="${name3}=((?:[^"\\\\]|\\\\.)*)"$`, "m").exec(unit2);
24860
+ return match ? systemdUnword(match[1]) : null;
24861
+ };
24862
+ return variable("CONBRIDGE_AGENT_HOME") ?? defaultStateDirIn(variable("HOME") ?? home);
24863
+ }
24838
24864
  async function systemdRunning() {
24839
24865
  return (0, import_promises2.stat)("/run/systemd/system").then((info) => info.isDirectory(), () => false);
24840
24866
  }
@@ -24900,6 +24926,13 @@ function buildCronLine(options) {
24900
24926
  const env = options.stateDir ? `CONBRIDGE_AGENT_HOME=${shWord(options.stateDir)} ` : "";
24901
24927
  return `@reboot ${env}${args} supervise >> ${shWord(options.logPath)} 2>&1 ${CRON_MARKER}`;
24902
24928
  }
24929
+ function cronStateDir(crontab, home) {
24930
+ const line = crontab.split("\n").find((entry) => entry.includes(CRON_MARKER));
24931
+ if (line === void 0)
24932
+ return null;
24933
+ const custom2 = /^@reboot CONBRIDGE_AGENT_HOME='((?:[^']|'\\'')*)' /.exec(line);
24934
+ return custom2 ? custom2[1].replace(/'\\''/g, "'") : defaultStateDirIn(home);
24935
+ }
24903
24936
  function withCronLine(current, line) {
24904
24937
  const kept = current.split("\n").filter((entry) => entry.trim() !== "" && !entry.includes(CRON_MARKER));
24905
24938
  return [...kept, ...line ? [line] : []].join("\n") + "\n";
@@ -25508,10 +25541,43 @@ function chooseKeyStoreType(requested, helperPath, platform2 = process.platform)
25508
25541
  }
25509
25542
  return platform2 === "darwin" && helperPath !== null ? "keychain" : "file";
25510
25543
  }
25544
+ var KEPT_HELPER_NAME = `${KEYCHAIN_HELPER_NAME}.kept`;
25545
+ var KEPT_HELPER_PIN_NAME = `${KEYCHAIN_HELPER_NAME}.kept.json`;
25546
+ var keptHelperPinSchema = external_exports.strictObject({
25547
+ version: external_exports.literal(1),
25548
+ key_id: external_exports.string().regex(KEY_ID),
25549
+ sha256: external_exports.string().regex(/^[0-9a-f]{64}$/)
25550
+ });
25551
+ function keptHelperPaths(stateDir) {
25552
+ const dir = (0, import_node_path6.join)(stateDir, RUNTIME_DIR_NAME);
25553
+ return { helper: (0, import_node_path6.join)(dir, KEPT_HELPER_NAME), pin: (0, import_node_path6.join)(dir, KEPT_HELPER_PIN_NAME) };
25554
+ }
25555
+ async function keptKeychainHelper(stateDir, keyId, platform2 = process.platform) {
25556
+ if (platform2 !== "darwin")
25557
+ return null;
25558
+ const paths = keptHelperPaths(stateDir);
25559
+ let pin;
25560
+ try {
25561
+ pin = keptHelperPinSchema.parse(JSON.parse(await (0, import_promises5.readFile)(paths.pin, "utf8")));
25562
+ } catch {
25563
+ return null;
25564
+ }
25565
+ if (pin.key_id !== keyId)
25566
+ return null;
25567
+ try {
25568
+ return await verifyKeychainHelper(paths.helper, pin.sha256);
25569
+ } catch {
25570
+ return null;
25571
+ }
25572
+ }
25511
25573
  async function openKeyStore(paths, descriptor, options = {}) {
25512
25574
  if (!descriptor || descriptor.type === "file")
25513
25575
  return new FileKeyStore(paths.key);
25514
- const helperPath = options.helperPath !== void 0 ? options.helperPath : await findKeychainHelper({ ...options.env ? { env: options.env } : {}, ...options.platform ? { platform: options.platform } : {} });
25576
+ const helperPath = options.helperPath !== void 0 ? options.helperPath : await keptKeychainHelper(paths.dir, descriptor.key_id, options.platform) ?? await findKeychainHelper({
25577
+ ...options.env ? { env: options.env } : {},
25578
+ ...options.platform ? { platform: options.platform } : {},
25579
+ ...options.codeDir ? { codeDir: options.codeDir } : {}
25580
+ });
25515
25581
  if (helperPath === null) {
25516
25582
  throw new KeychainError("HELPER_INVALID", "This identity keeps its key in the Keychain, but no valid Keychain helper (conbridge-agent-keychain) was found (it must exist next to the agent, not be writable by others and match this build)");
25517
25583
  }
@@ -25857,8 +25923,21 @@ function purgePowerShell(signal) {
25857
25923
  });
25858
25924
  });
25859
25925
  }
25926
+ async function sameDirectory(a, b) {
25927
+ return (0, import_node_path8.resolve)(a) === (0, import_node_path8.resolve)(b) || await realpathLenient(a) === await realpathLenient(b);
25928
+ }
25929
+ async function ownerOf(text6, parse3, stateDir, home) {
25930
+ if (text6 === null)
25931
+ return "unknown";
25932
+ const startsStateDir = parse3(text6, home);
25933
+ return startsStateDir !== null && await sameDirectory(startsStateDir, stateDir) ? "ours" : "other";
25934
+ }
25935
+ async function definitionOwner(path, parse3, stateDir, home) {
25936
+ return ownerOf(await (0, import_promises7.readFile)(path, "utf8").catch(() => null), parse3, stateDir, home);
25937
+ }
25860
25938
  async function removeAgentAutostart(stateDir = resolveStateDir(), deps = {}, signal) {
25861
25939
  const platform2 = deps.platform ?? process.platform;
25940
+ const home = deps.home ?? (0, import_node_os4.homedir)();
25862
25941
  const run2 = deps.run ?? boundedCommand(signal);
25863
25942
  const serviceDeps = { stopRunning: false, ...deps, platform: platform2, run: run2, launchctl: deps.launchctl ?? ((args) => run2("/bin/launchctl", args)) };
25864
25943
  const failures = [];
@@ -25871,14 +25950,20 @@ async function removeAgentAutostart(stateDir = resolveStateDir(), deps = {}, sig
25871
25950
  failures.push(error63);
25872
25951
  }
25873
25952
  };
25874
- if (platform2 === "darwin")
25953
+ const ours = async (path, parse3) => await definitionOwner(path, parse3, stateDir, home) === "ours";
25954
+ if (platform2 === "darwin" && await ours(launchAgentPath(home), launchAgentStateDir))
25875
25955
  await attempt(() => uninstallLaunchAgent(serviceDeps));
25876
25956
  if (platform2 === "linux") {
25877
- await attempt(() => uninstallSystemdService({ ...serviceDeps, uid: 1 }));
25878
- await attempt(() => uninstallSystemdService({ ...serviceDeps, uid: 0 }));
25879
- await attempt(() => uninstallCronService({ ...serviceDeps, writeCrontab: deps.writeCrontab ?? boundedCronWriter(signal) }));
25957
+ if (await ours(systemdUnitPath(home), systemdUnitStateDir))
25958
+ await attempt(() => uninstallSystemdService({ ...serviceDeps, uid: 1 }));
25959
+ if (await ours(deps.systemUnitPath ?? SYSTEMD_SYSTEM_UNIT_PATH, systemdUnitStateDir))
25960
+ await attempt(() => uninstallSystemdService({ ...serviceDeps, uid: 0 }));
25961
+ const crontab = signal?.aborted ? { ok: false, output: "" } : await run2("crontab", ["-l"]);
25962
+ if (crontab.ok && await ownerOf(crontab.output, cronStateDir, stateDir, home) === "ours") {
25963
+ await attempt(() => uninstallCronService({ ...serviceDeps, writeCrontab: deps.writeCrontab ?? boundedCronWriter(signal) }));
25964
+ }
25880
25965
  }
25881
- if (platform2 === "win32")
25966
+ if (platform2 === "win32" && await (deps.exists ?? exists)(windowsLauncherPath(stateDir)))
25882
25967
  await attempt(() => uninstallWindowsTask(stateDir, serviceDeps));
25883
25968
  if (failures.length)
25884
25969
  throw new AggregateError(failures, "Some autostart files could not be removed");
@@ -26059,18 +26144,20 @@ async function purgeAgent(options, deps = {}) {
26059
26144
  throw new AggregateError(failures, "Some ConBridge files could not be removed");
26060
26145
  });
26061
26146
  await step2("leftovers", async (signal) => {
26062
- if (platform2 === "darwin" && await has("/usr/local/lib/conbridge-agent/uninstall.sh")) {
26147
+ if (platform2 === "darwin" && await has("/usr/local/lib/conbridge-agent/uninstall.sh") && await definitionOwner(launchAgentPath(home), launchAgentStateDir, stateDir, home) !== "other") {
26063
26148
  leftovers.push("sudo /usr/local/lib/conbridge-agent/uninstall.sh");
26064
26149
  }
26065
26150
  const quote = (path) => `'${path.replace(/'/g, "'\\''")}'`;
26151
+ const remains = async (path, parse3) => await has(path) && await definitionOwner(path, parse3, stateDir, home) === "ours";
26066
26152
  if (platform2 === "linux") {
26067
- if (await has(systemdUnitPath(home)))
26153
+ if (await remains(systemdUnitPath(home), systemdUnitStateDir)) {
26068
26154
  leftovers.push(`systemctl --user disable --now conbridge-agent.service; rm -f -- ${quote(systemdUnitPath(home))}; systemctl --user daemon-reload`);
26155
+ }
26069
26156
  const systemUnit = deps.systemUnitPath ?? SYSTEMD_SYSTEM_UNIT_PATH;
26070
- if (await has(systemUnit))
26157
+ if (await remains(systemUnit, systemdUnitStateDir))
26071
26158
  leftovers.push(`sudo systemctl disable --now conbridge-agent.service; sudo rm -f -- ${quote(systemUnit)}; sudo systemctl daemon-reload`);
26072
26159
  }
26073
- if (platform2 === "darwin" && await has(launchAgentPath(home)))
26160
+ if (platform2 === "darwin" && await remains(launchAgentPath(home), launchAgentStateDir))
26074
26161
  leftovers.push(`rm -f -- ${quote(launchAgentPath(home))}`);
26075
26162
  if (!deferred) {
26076
26163
  const owned = dedicated ? [stateDir] : await stateEntries(stateDir, false, options.keepRuntime ?? false, pathApi).catch(() => []);
@@ -26098,7 +26185,7 @@ async function purgeAgent(options, deps = {}) {
26098
26185
 
26099
26186
  // dist/cli.js
26100
26187
  var import_node_child_process12 = require("node:child_process");
26101
- var import_node_crypto13 = require("node:crypto");
26188
+ var import_node_crypto14 = require("node:crypto");
26102
26189
  var import_node_fs5 = require("node:fs");
26103
26190
  var import_promises23 = require("node:fs/promises");
26104
26191
  var import_node_os15 = require("node:os");
@@ -27050,12 +27137,13 @@ var Journal = class _Journal {
27050
27137
  };
27051
27138
 
27052
27139
  // dist/install.js
27140
+ var import_node_crypto7 = require("node:crypto");
27053
27141
  var import_promises10 = require("node:fs/promises");
27054
27142
  var import_node_path13 = require("node:path");
27055
27143
  var import_node_url2 = require("node:url");
27056
27144
  var RUNTIME_ENTRY = "conbridge-agent.cjs";
27057
27145
  function runtimeDir(stateDir) {
27058
- return (0, import_node_path13.join)(stateDir, "runtime");
27146
+ return (0, import_node_path13.join)(stateDir, RUNTIME_DIR_NAME);
27059
27147
  }
27060
27148
  function runtimeEntry(stateDir) {
27061
27149
  return (0, import_node_path13.join)(runtimeDir(stateDir), RUNTIME_ENTRY);
@@ -27108,6 +27196,65 @@ async function installRuntime(stateDir, from = {}) {
27108
27196
  }
27109
27197
  return { entry, changed };
27110
27198
  }
27199
+ async function helperReadsKey(helperPath, descriptor) {
27200
+ if (helperPath === null)
27201
+ return false;
27202
+ try {
27203
+ const store = new KeychainKeyStore({
27204
+ helperPath,
27205
+ keyId: descriptor.key_id,
27206
+ ...descriptor.keychain !== void 0 ? { keychainPath: descriptor.keychain } : {}
27207
+ });
27208
+ return await store.load() !== null;
27209
+ } catch {
27210
+ return false;
27211
+ }
27212
+ }
27213
+ async function dropKeptHelper(stateDir) {
27214
+ const kept = keptHelperPaths(stateDir);
27215
+ for (const path of [kept.pin, kept.helper]) {
27216
+ await (0, import_promises10.unlink)(path).catch((error63) => {
27217
+ if (errorCode2(error63) !== "ENOENT")
27218
+ throw error63;
27219
+ });
27220
+ }
27221
+ }
27222
+ async function keepKeychainHelper(stateDir, descriptor, options = {}) {
27223
+ if (!descriptor || descriptor.type !== "keychain")
27224
+ return "not-keychain";
27225
+ const platform2 = options.platform ?? process.platform;
27226
+ if (await helperReadsKey(await keptKeychainHelper(stateDir, descriptor.key_id, platform2), descriptor))
27227
+ return "kept";
27228
+ const shipped = await findKeychainHelper({
27229
+ platform: platform2,
27230
+ ...options.env ? { env: options.env } : {},
27231
+ ...options.codeDir ? { codeDir: options.codeDir } : {}
27232
+ });
27233
+ if (await helperReadsKey(shipped, descriptor)) {
27234
+ await dropKeptHelper(stateDir);
27235
+ return "shipped";
27236
+ }
27237
+ if (platform2 !== "darwin")
27238
+ return "unreadable";
27239
+ let installed;
27240
+ try {
27241
+ installed = await verifyKeychainHelper((0, import_node_path13.join)(runtimeDir(stateDir), KEYCHAIN_HELPER_NAME), null);
27242
+ } catch {
27243
+ return "unreadable";
27244
+ }
27245
+ if (!await helperReadsKey(installed, descriptor))
27246
+ return "unreadable";
27247
+ const bytes3 = await (0, import_promises10.readFile)(installed);
27248
+ const pin = { version: 1, key_id: descriptor.key_id, sha256: (0, import_node_crypto7.createHash)("sha256").update(bytes3).digest("hex") };
27249
+ const kept = keptHelperPaths(stateDir);
27250
+ await dropKeptHelper(stateDir);
27251
+ await writeFileAtomic(kept.helper, bytes3, 493);
27252
+ await writeFileAtomic(kept.pin, JSON.stringify(pin) + "\n", 384);
27253
+ if (await helperReadsKey(await keptKeychainHelper(stateDir, descriptor.key_id, platform2), descriptor))
27254
+ return "kept";
27255
+ await dropKeptHelper(stateDir);
27256
+ return "unreadable";
27257
+ }
27111
27258
  async function snapshotRuntime(stateDir) {
27112
27259
  const dir = runtimeDir(stateDir);
27113
27260
  const backup = `${dir}.previous`;
@@ -27383,12 +27530,12 @@ async function acquireLock(path) {
27383
27530
  }
27384
27531
 
27385
27532
  // dist/envelope.js
27386
- var import_node_crypto7 = require("node:crypto");
27387
- function buildEnvelope(identity, kind, taskId2, body, correlationId = (0, import_node_crypto7.randomUUID)()) {
27533
+ var import_node_crypto8 = require("node:crypto");
27534
+ function buildEnvelope(identity, kind, taskId2, body, correlationId = (0, import_node_crypto8.randomUUID)()) {
27388
27535
  return {
27389
27536
  version: 1,
27390
27537
  kind,
27391
- message_id: (0, import_node_crypto7.randomUUID)(),
27538
+ message_id: (0, import_node_crypto8.randomUUID)(),
27392
27539
  correlation_id: correlationId,
27393
27540
  tenant_id: identity.tenant_id,
27394
27541
  user_id: identity.user_id,
@@ -27432,12 +27579,12 @@ function excerpt(value) {
27432
27579
  var import_node_os14 = require("node:os");
27433
27580
 
27434
27581
  // dist/dispatcher.js
27435
- var import_node_crypto9 = require("node:crypto");
27582
+ var import_node_crypto10 = require("node:crypto");
27436
27583
 
27437
27584
  // dist/fileops.js
27438
27585
  var import_node_fs3 = require("node:fs");
27439
27586
  var import_promises12 = require("node:fs/promises");
27440
- var import_node_crypto8 = require("node:crypto");
27587
+ var import_node_crypto9 = require("node:crypto");
27441
27588
  var import_node_path15 = require("node:path");
27442
27589
 
27443
27590
  // dist/glob.js
@@ -27597,7 +27744,7 @@ function decodeText(bytes3) {
27597
27744
  }
27598
27745
  }
27599
27746
  async function hashHandle(handle) {
27600
- const hash2 = (0, import_node_crypto8.createHash)("sha256");
27747
+ const hash2 = (0, import_node_crypto9.createHash)("sha256");
27601
27748
  const buffer = Buffer.allocUnsafe(READ_BLOCK);
27602
27749
  let position2 = 0;
27603
27750
  for (; ; ) {
@@ -27610,7 +27757,7 @@ async function hashHandle(handle) {
27610
27757
  return hash2.digest("hex");
27611
27758
  }
27612
27759
  function sha256OfBytes(bytes3) {
27613
- return (0, import_node_crypto8.createHash)("sha256").update(bytes3).digest("hex");
27760
+ return (0, import_node_crypto9.createHash)("sha256").update(bytes3).digest("hex");
27614
27761
  }
27615
27762
  var RootedFs = class {
27616
27763
  #root;
@@ -27727,7 +27874,7 @@ var RootedFs = class {
27727
27874
  try {
27728
27875
  if (!info.isFile())
27729
27876
  throw new FileOpError("NOT_A_FILE", "Path is not a regular file", { path: rel });
27730
- const hash2 = (0, import_node_crypto8.createHash)("sha256");
27877
+ const hash2 = (0, import_node_crypto9.createHash)("sha256");
27731
27878
  const kept = [];
27732
27879
  let keptBytes = 0;
27733
27880
  let size = 0;
@@ -28668,7 +28815,7 @@ var Dispatcher = class {
28668
28815
  const state2 = { phase: "pending", cancelled: false, stopRequested: false, meta: meta3 };
28669
28816
  this.#inFlight.set(taskId2, state2);
28670
28817
  try {
28671
- const executionNonce = (0, import_node_crypto9.randomUUID)();
28818
+ const executionNonce = (0, import_node_crypto10.randomUUID)();
28672
28819
  this.#sendAck(dispatch2, "RECEIVED", executionNonce);
28673
28820
  let fileTask = isSshTask(authorized) || isShellTask(authorized) || isAgentTask(authorized) || isDiagTask(authorized) ? null : authorized;
28674
28821
  let fs = fileTask ? new RootedFs(fileTask.root, effectiveDenyGlobs(config2), { protectedPaths: this.#protectedPaths }) : null;
@@ -29118,7 +29265,7 @@ var MonitorLoop = class {
29118
29265
  };
29119
29266
 
29120
29267
  // dist/inventory/loop.js
29121
- var import_node_crypto11 = require("node:crypto");
29268
+ var import_node_crypto12 = require("node:crypto");
29122
29269
  var import_node_os9 = require("node:os");
29123
29270
  var import_node_zlib2 = require("node:zlib");
29124
29271
 
@@ -32178,7 +32325,7 @@ function socketOwnerOf(listener, exeByPid, packageByPath, options) {
32178
32325
  }
32179
32326
  return { kind: "process", name: "systemd" };
32180
32327
  }
32181
- function ownerOf(listener, exeByPid, packageByPath, containerByPort, options) {
32328
+ function ownerOf2(listener, exeByPid, packageByPath, containerByPort, options) {
32182
32329
  const name3 = processNameOf(listener.process);
32183
32330
  if (name3 !== null && CONTAINER_PLUMBING.has(name3)) {
32184
32331
  const containerId = containerByPort.get(listener.port);
@@ -32222,7 +32369,7 @@ function resolveListenerOwners(listeners, exeByPid, packageByPath, containers, o
32222
32369
  const out = [];
32223
32370
  const byKey = /* @__PURE__ */ new Map();
32224
32371
  for (const listener of listeners) {
32225
- const owner = ownerOf(listener, exeByPid, packageByPath, containerByPort, options);
32372
+ const owner = ownerOf2(listener, exeByPid, packageByPath, containerByPort, options);
32226
32373
  const stale = options?.markStale === true && listener.pids.some((pid) => options.stalePids?.has(pid) === true);
32227
32374
  const item = { proto: listener.proto, port: listener.port, bind: listener.bind, owner, ...stale ? { stale: true } : {} };
32228
32375
  const key = `${item.proto}\0${item.port}\0${item.bind}\0${JSON.stringify(item.owner)}`;
@@ -32502,13 +32649,13 @@ async function collectPlatformFacts(c) {
32502
32649
  var import_node_zlib = require("node:zlib");
32503
32650
 
32504
32651
  // dist/inventory/parsers/kernel-facts.js
32505
- var import_node_crypto10 = require("node:crypto");
32652
+ var import_node_crypto11 = require("node:crypto");
32506
32653
  var SYMBOL2 = /^[A-Z0-9_]{1,80}$/;
32507
32654
  var MODULE2 = /^[A-Za-z0-9_]{1,64}$/;
32508
32655
  var MODULE_SUFFIX = /\.ko(?:\.(?:zst|xz|gz))?$/;
32509
32656
  var sortUnique = (values) => [...new Set(values)].sort();
32510
32657
  function kernelConfigSha256(raw) {
32511
- return (0, import_node_crypto10.createHash)("sha256").update(raw).digest("hex");
32658
+ return (0, import_node_crypto11.createHash)("sha256").update(raw).digest("hex");
32512
32659
  }
32513
32660
  function parseKernelConfig(text6) {
32514
32661
  const builtin = [];
@@ -34240,7 +34387,7 @@ function mergeQueued(earlier, later) {
34240
34387
  return { requestId: null };
34241
34388
  }
34242
34389
  function partsOf(gz, requestId, runId, resourceId) {
34243
- const sha2563 = (0, import_node_crypto11.createHash)("sha256").update(gz).digest("hex");
34390
+ const sha2563 = (0, import_node_crypto12.createHash)("sha256").update(gz).digest("hex");
34244
34391
  const data = gz.toString("base64");
34245
34392
  const total = Math.max(1, Math.ceil(data.length / INVENTORY_PART_CHARS));
34246
34393
  return Array.from({ length: total }, (_, sequence) => ({
@@ -34303,7 +34450,7 @@ function contentSha256(snapshot) {
34303
34450
  const parsed = inventorySnapshotSchema.safeParse(JSON.parse(JSON.stringify(snapshot)));
34304
34451
  if (!parsed.success)
34305
34452
  return null;
34306
- return (0, import_node_crypto11.createHash)("sha256").update(inventoryContentCanonical(parsed.data), "utf8").digest("hex");
34453
+ return (0, import_node_crypto12.createHash)("sha256").update(inventoryContentCanonical(parsed.data), "utf8").digest("hex");
34307
34454
  }
34308
34455
  function sshFailureReason(reason2) {
34309
34456
  if (reason2 === "ssh could not be started")
@@ -34559,7 +34706,7 @@ var InventoryLoop = class {
34559
34706
  if (!this.#features.has("inventory_status.v1") || !this.#options.sendStatus)
34560
34707
  return;
34561
34708
  try {
34562
- this.#options.sendStatus({ run_id: (0, import_node_crypto11.randomUUID)(), ...body });
34709
+ this.#options.sendStatus({ run_id: (0, import_node_crypto12.randomUUID)(), ...body });
34563
34710
  } catch (error63) {
34564
34711
  this.#logger.warn("software inventory status not sent", { error: error63 instanceof Error ? error63.name : "unknown" });
34565
34712
  }
@@ -34600,7 +34747,7 @@ var InventoryLoop = class {
34600
34747
  if (!fitted)
34601
34748
  return "too_large";
34602
34749
  const sentDigest = fitted.snapshot === snapshot ? digest : contentSha256(fitted.snapshot);
34603
- const runId = (0, import_node_crypto11.randomUUID)();
34750
+ const runId = (0, import_node_crypto12.randomUUID)();
34604
34751
  const parts = partsOf(fitted.gz, requestId, runId, target.resourceId ?? void 0);
34605
34752
  return this.#exclusive(async () => {
34606
34753
  if (!await this.#awaitSpacing() || !stillWanted())
@@ -34643,7 +34790,7 @@ var InventoryLoop = class {
34643
34790
  const sendUnchanged = this.#options.sendUnchanged;
34644
34791
  if (!sendUnchanged)
34645
34792
  return "not_sent";
34646
- const runId = (0, import_node_crypto11.randomUUID)();
34793
+ const runId = (0, import_node_crypto12.randomUUID)();
34647
34794
  const body = {
34648
34795
  run_id: runId,
34649
34796
  request_id: null,
@@ -37128,7 +37275,7 @@ function jittered(base2, spread, random = Math.random) {
37128
37275
  }
37129
37276
 
37130
37277
  // dist/ssh/handler.js
37131
- var import_node_crypto12 = require("node:crypto");
37278
+ var import_node_crypto13 = require("node:crypto");
37132
37279
 
37133
37280
  // dist/diagnostics/parsers.js
37134
37281
  var failed2 = (status, facts = {}) => ({ status, facts });
@@ -38337,7 +38484,7 @@ var SshExecutor = class {
38337
38484
  stdout_bytes: result2.stdoutBytes,
38338
38485
  stderr_bytes: result2.stderrBytes,
38339
38486
  output_truncated: result2.truncated,
38340
- output_sha256: (0, import_node_crypto12.createHash)("sha256").update(result2.stdout).update("\0").update(result2.stderr).digest("hex"),
38487
+ output_sha256: (0, import_node_crypto13.createHash)("sha256").update(result2.stdout).update("\0").update(result2.stderr).digest("hex"),
38341
38488
  duration_ms: result2.durationMs
38342
38489
  };
38343
38490
  }
@@ -39471,7 +39618,11 @@ var AgentRunner = class {
39471
39618
  const actions = this.#options.lifecycleActions;
39472
39619
  try {
39473
39620
  if (reason2 === "removed:destroyed") {
39474
- await (actions?.purge() ?? purgeAgent({ reason: "destroyed", stateDir: this.#options.paths.dir, ...this.#options.stopKeepAwake ? { stopKeepAwake: this.#options.stopKeepAwake } : {} }));
39621
+ await (actions?.purge() ?? purgeAgent({
39622
+ reason: "destroyed",
39623
+ stateDir: this.#options.paths.dir,
39624
+ ...this.#options.stopKeepAwake ? { stopKeepAwake: this.#options.stopKeepAwake } : {}
39625
+ }, this.#options.lifecycleDeps));
39475
39626
  const dispatch2 = this.#destroyDispatch;
39476
39627
  if (dispatch2 && this.#session)
39477
39628
  this.#session.sendFrame(encode3(buildEnvelope(this.#options.identity, "RESULT", dispatch2.task_id, {
@@ -39480,9 +39631,9 @@ var AgentRunner = class {
39480
39631
  output_excerpt: JSON.stringify({ state: "removed" })
39481
39632
  }, dispatch2.correlation_id)));
39482
39633
  } else {
39483
- await (actions?.removeAutostart() ?? removeAgentAutostart(this.#options.paths.dir)).catch((error63) => this.#logger.warn("autostart removal failed", { error: errorMessage(error63) }));
39634
+ await (actions?.removeAutostart() ?? removeAgentAutostart(this.#options.paths.dir, this.#options.lifecycleDeps)).catch((error63) => this.#logger.warn("autostart removal failed", { error: errorMessage(error63) }));
39484
39635
  if (!passive)
39485
- await (actions?.removeIdentity() ?? removeAgentIdentity({ stateDir: this.#options.paths.dir }));
39636
+ await (actions?.removeIdentity() ?? removeAgentIdentity({ stateDir: this.#options.paths.dir }, this.#options.lifecycleDeps));
39486
39637
  }
39487
39638
  } catch (error63) {
39488
39639
  this.#logger.warn("lifecycle cleanup failed", { error: errorMessage(error63) });
@@ -39888,13 +40039,14 @@ async function runInstalledCopy(paths, argv, io, keepsIdentity = true) {
39888
40039
  if (!runningFromNpm() || await runningFromRuntime(paths.dir))
39889
40040
  return null;
39890
40041
  const previous = await loadIdentity(paths).catch(() => null);
40042
+ const kept = await keepKeychainHelper(paths.dir, previous?.key_store, { env: io.env }).catch(() => "unreadable");
39891
40043
  const blocked = await keychainUpdateProblem(previous, (descriptor) => openKeyStore(paths, descriptor, { env: io.env }));
39892
40044
  if (blocked && keepsIdentity) {
39893
40045
  io.err(blocked);
39894
40046
  return 2;
39895
40047
  }
39896
40048
  await ensureStateDir(paths.dir);
39897
- const snapshot = blocked ? await snapshotRuntime(paths.dir) : null;
40049
+ const snapshot = blocked || kept === "kept" ? await snapshotRuntime(paths.dir) : null;
39898
40050
  let status;
39899
40051
  try {
39900
40052
  const { entry } = await installRuntime(paths.dir);
@@ -39921,9 +40073,9 @@ async function keychainUpdateProblem(identity, open8) {
39921
40073
  await (await open8(descriptor)).load();
39922
40074
  return null;
39923
40075
  } catch (error63) {
39924
- const reason2 = error63 instanceof KeychainError && error63.code === "DENIED" ? `macOS does not let agent ${AGENT_VERSION} read this Mac's device key (it was created by an older agent build, or the Keychain is locked)` : `agent ${AGENT_VERSION} could not check this Mac's device key (${errorMessage(error63)})`;
40076
+ const reason2 = error63 instanceof KeychainError && error63.code === "DENIED" ? `macOS does not let agent ${AGENT_VERSION} or the installed agent read this Mac's device key (the Keychain is locked, for example in an SSH session while nobody is logged in to the Mac, or the key was created by another agent install)` : `agent ${AGENT_VERSION} could not check this Mac's device key (${errorMessage(error63)})`;
39925
40077
  return `${reason2}. Nothing was changed; the installed agent keeps running.
39926
- To move to ${AGENT_VERSION}, create a pairing code in the ConBridge Console and run: npx --yes conbridge-agent@latest pair --force --code XXXX-XXXX (then remove the old device in the Console).`;
40078
+ Log in to the Mac and run the update again. If it still fails, create a pairing code in the ConBridge Console and run: npx --yes conbridge-agent@latest pair --force --code XXXX-XXXX (then remove the old device in the Console).`;
39927
40079
  }
39928
40080
  }
39929
40081
  function pendingKeyPath(paths) {
@@ -39947,7 +40099,7 @@ async function newKeyStore(paths, values, env) {
39947
40099
  throw new UsageError("--keychain needs an absolute path");
39948
40100
  return new KeychainKeyStore({
39949
40101
  helperPath: helper,
39950
- keyId: (0, import_node_crypto13.randomUUID)(),
40102
+ keyId: (0, import_node_crypto14.randomUUID)(),
39951
40103
  ...values.keychain !== void 0 ? { keychainPath: (0, import_node_path22.resolve)(values.keychain) } : {}
39952
40104
  });
39953
40105
  }
@@ -40256,6 +40408,9 @@ async function cmdStatus(paths, args, io) {
40256
40408
  io.out(` Fingerprint: ${identity.fingerprint}`);
40257
40409
  const store = identity.key_store ?? { type: "file" };
40258
40410
  io.out(` Key store: ${store.type === "keychain" ? `macOS Keychain (key id ${store.key_id}${store.keychain ? `, keychain ${store.keychain}` : ""})` : `file ${paths.key}`}`);
40411
+ if (store.type === "keychain" && await keptKeychainHelper(paths.dir, store.key_id)) {
40412
+ io.out(" Keychain helper: kept from the agent build that created the key (macOS trusts only that build)");
40413
+ }
40259
40414
  io.out(` Device key: ${await keyStatus(paths, identity, io.env)}`);
40260
40415
  }
40261
40416
  io.out(`Roots: ${config2.roots.length}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "conbridge-agent",
3
- "version": "0.9.0",
3
+ "version": "0.9.2",
4
4
  "description": "ConBridge Desktop Agent: connect this computer to ConBridge so approved AI apps can use the folders you share.",
5
5
  "license": "UNLICENSED",
6
6
  "homepage": "https://conbridge.app",