conbridge-agent 0.9.0 → 0.9.1

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.1: 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
 
Binary file
@@ -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.1", commit: "8d2be2cfc4ba", built_at: "2026-11-23T15:05:57.439Z", keychain_helper_sha256: "0a2d65388c0acc75305386ce0d6b7ee2e522ed939f291eb5a50055197674c023", distribution: "npm" };
33
33
 
34
34
  // dist/cli.js
35
35
  var import_promises22 = require("node:readline/promises");
@@ -24584,7 +24584,7 @@ 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.1";
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
24590
  function runningAsSea() {
@@ -24746,6 +24746,19 @@ function buildLaunchAgentPlist(options) {
24746
24746
  function launchAgentPath(home = (0, import_node_os.homedir)()) {
24747
24747
  return (0, import_node_path3.join)(home, "Library", "LaunchAgents", `${LAUNCH_AGENT_LABEL}.plist`);
24748
24748
  }
24749
+ function defaultStateDirIn(home) {
24750
+ return (0, import_node_path3.join)(home, ".conbridge", "agent");
24751
+ }
24752
+ function xmlUnescape(value) {
24753
+ const entities = { amp: "&", lt: "<", gt: ">", quot: '"', apos: "'" };
24754
+ return value.replace(/&(amp|lt|gt|quot|apos);/g, (_, name3) => entities[name3]);
24755
+ }
24756
+ function launchAgentStateDir(plist, home) {
24757
+ if (!/<key>Label<\/key>\s*<string>com\.conbridge\.agent<\/string>/.test(plist))
24758
+ return null;
24759
+ const custom2 = /<key>CONBRIDGE_AGENT_HOME<\/key>\s*<string>([^<]*)<\/string>/.exec(plist);
24760
+ return custom2 ? xmlUnescape(custom2[1]) : defaultStateDirIn(home);
24761
+ }
24749
24762
  function defaultLogPath(home = (0, import_node_os.homedir)()) {
24750
24763
  return (0, import_node_path3.join)(home, "Library", "Logs", "conbridge-agent.log");
24751
24764
  }
@@ -24835,6 +24848,18 @@ function buildSystemdUnit(options) {
24835
24848
  ""
24836
24849
  ].join("\n");
24837
24850
  }
24851
+ function systemdUnword(quoted2) {
24852
+ return quoted2.replace(/\\(.)|%%|\$\$/g, (match, escaped) => escaped ?? match[0]);
24853
+ }
24854
+ function systemdUnitStateDir(unit2, home) {
24855
+ if (!/^Description=ConBridge Desktop Agent$/m.test(unit2))
24856
+ return null;
24857
+ const variable = (name3) => {
24858
+ const match = new RegExp(`^Environment="${name3}=((?:[^"\\\\]|\\\\.)*)"$`, "m").exec(unit2);
24859
+ return match ? systemdUnword(match[1]) : null;
24860
+ };
24861
+ return variable("CONBRIDGE_AGENT_HOME") ?? defaultStateDirIn(variable("HOME") ?? home);
24862
+ }
24838
24863
  async function systemdRunning() {
24839
24864
  return (0, import_promises2.stat)("/run/systemd/system").then((info) => info.isDirectory(), () => false);
24840
24865
  }
@@ -24900,6 +24925,13 @@ function buildCronLine(options) {
24900
24925
  const env = options.stateDir ? `CONBRIDGE_AGENT_HOME=${shWord(options.stateDir)} ` : "";
24901
24926
  return `@reboot ${env}${args} supervise >> ${shWord(options.logPath)} 2>&1 ${CRON_MARKER}`;
24902
24927
  }
24928
+ function cronStateDir(crontab, home) {
24929
+ const line = crontab.split("\n").find((entry) => entry.includes(CRON_MARKER));
24930
+ if (line === void 0)
24931
+ return null;
24932
+ const custom2 = /^@reboot CONBRIDGE_AGENT_HOME='((?:[^']|'\\'')*)' /.exec(line);
24933
+ return custom2 ? custom2[1].replace(/'\\''/g, "'") : defaultStateDirIn(home);
24934
+ }
24903
24935
  function withCronLine(current, line) {
24904
24936
  const kept = current.split("\n").filter((entry) => entry.trim() !== "" && !entry.includes(CRON_MARKER));
24905
24937
  return [...kept, ...line ? [line] : []].join("\n") + "\n";
@@ -25857,8 +25889,21 @@ function purgePowerShell(signal) {
25857
25889
  });
25858
25890
  });
25859
25891
  }
25892
+ async function sameDirectory(a, b) {
25893
+ return (0, import_node_path8.resolve)(a) === (0, import_node_path8.resolve)(b) || await realpathLenient(a) === await realpathLenient(b);
25894
+ }
25895
+ async function ownerOf(text6, parse3, stateDir, home) {
25896
+ if (text6 === null)
25897
+ return "unknown";
25898
+ const startsStateDir = parse3(text6, home);
25899
+ return startsStateDir !== null && await sameDirectory(startsStateDir, stateDir) ? "ours" : "other";
25900
+ }
25901
+ async function definitionOwner(path, parse3, stateDir, home) {
25902
+ return ownerOf(await (0, import_promises7.readFile)(path, "utf8").catch(() => null), parse3, stateDir, home);
25903
+ }
25860
25904
  async function removeAgentAutostart(stateDir = resolveStateDir(), deps = {}, signal) {
25861
25905
  const platform2 = deps.platform ?? process.platform;
25906
+ const home = deps.home ?? (0, import_node_os4.homedir)();
25862
25907
  const run2 = deps.run ?? boundedCommand(signal);
25863
25908
  const serviceDeps = { stopRunning: false, ...deps, platform: platform2, run: run2, launchctl: deps.launchctl ?? ((args) => run2("/bin/launchctl", args)) };
25864
25909
  const failures = [];
@@ -25871,14 +25916,20 @@ async function removeAgentAutostart(stateDir = resolveStateDir(), deps = {}, sig
25871
25916
  failures.push(error63);
25872
25917
  }
25873
25918
  };
25874
- if (platform2 === "darwin")
25919
+ const ours = async (path, parse3) => await definitionOwner(path, parse3, stateDir, home) === "ours";
25920
+ if (platform2 === "darwin" && await ours(launchAgentPath(home), launchAgentStateDir))
25875
25921
  await attempt(() => uninstallLaunchAgent(serviceDeps));
25876
25922
  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) }));
25923
+ if (await ours(systemdUnitPath(home), systemdUnitStateDir))
25924
+ await attempt(() => uninstallSystemdService({ ...serviceDeps, uid: 1 }));
25925
+ if (await ours(deps.systemUnitPath ?? SYSTEMD_SYSTEM_UNIT_PATH, systemdUnitStateDir))
25926
+ await attempt(() => uninstallSystemdService({ ...serviceDeps, uid: 0 }));
25927
+ const crontab = signal?.aborted ? { ok: false, output: "" } : await run2("crontab", ["-l"]);
25928
+ if (crontab.ok && await ownerOf(crontab.output, cronStateDir, stateDir, home) === "ours") {
25929
+ await attempt(() => uninstallCronService({ ...serviceDeps, writeCrontab: deps.writeCrontab ?? boundedCronWriter(signal) }));
25930
+ }
25880
25931
  }
25881
- if (platform2 === "win32")
25932
+ if (platform2 === "win32" && await (deps.exists ?? exists)(windowsLauncherPath(stateDir)))
25882
25933
  await attempt(() => uninstallWindowsTask(stateDir, serviceDeps));
25883
25934
  if (failures.length)
25884
25935
  throw new AggregateError(failures, "Some autostart files could not be removed");
@@ -26059,18 +26110,20 @@ async function purgeAgent(options, deps = {}) {
26059
26110
  throw new AggregateError(failures, "Some ConBridge files could not be removed");
26060
26111
  });
26061
26112
  await step2("leftovers", async (signal) => {
26062
- if (platform2 === "darwin" && await has("/usr/local/lib/conbridge-agent/uninstall.sh")) {
26113
+ if (platform2 === "darwin" && await has("/usr/local/lib/conbridge-agent/uninstall.sh") && await definitionOwner(launchAgentPath(home), launchAgentStateDir, stateDir, home) !== "other") {
26063
26114
  leftovers.push("sudo /usr/local/lib/conbridge-agent/uninstall.sh");
26064
26115
  }
26065
26116
  const quote = (path) => `'${path.replace(/'/g, "'\\''")}'`;
26117
+ const remains = async (path, parse3) => await has(path) && await definitionOwner(path, parse3, stateDir, home) === "ours";
26066
26118
  if (platform2 === "linux") {
26067
- if (await has(systemdUnitPath(home)))
26119
+ if (await remains(systemdUnitPath(home), systemdUnitStateDir)) {
26068
26120
  leftovers.push(`systemctl --user disable --now conbridge-agent.service; rm -f -- ${quote(systemdUnitPath(home))}; systemctl --user daemon-reload`);
26121
+ }
26069
26122
  const systemUnit = deps.systemUnitPath ?? SYSTEMD_SYSTEM_UNIT_PATH;
26070
- if (await has(systemUnit))
26123
+ if (await remains(systemUnit, systemdUnitStateDir))
26071
26124
  leftovers.push(`sudo systemctl disable --now conbridge-agent.service; sudo rm -f -- ${quote(systemUnit)}; sudo systemctl daemon-reload`);
26072
26125
  }
26073
- if (platform2 === "darwin" && await has(launchAgentPath(home)))
26126
+ if (platform2 === "darwin" && await remains(launchAgentPath(home), launchAgentStateDir))
26074
26127
  leftovers.push(`rm -f -- ${quote(launchAgentPath(home))}`);
26075
26128
  if (!deferred) {
26076
26129
  const owned = dedicated ? [stateDir] : await stateEntries(stateDir, false, options.keepRuntime ?? false, pathApi).catch(() => []);
@@ -32178,7 +32231,7 @@ function socketOwnerOf(listener, exeByPid, packageByPath, options) {
32178
32231
  }
32179
32232
  return { kind: "process", name: "systemd" };
32180
32233
  }
32181
- function ownerOf(listener, exeByPid, packageByPath, containerByPort, options) {
32234
+ function ownerOf2(listener, exeByPid, packageByPath, containerByPort, options) {
32182
32235
  const name3 = processNameOf(listener.process);
32183
32236
  if (name3 !== null && CONTAINER_PLUMBING.has(name3)) {
32184
32237
  const containerId = containerByPort.get(listener.port);
@@ -32222,7 +32275,7 @@ function resolveListenerOwners(listeners, exeByPid, packageByPath, containers, o
32222
32275
  const out = [];
32223
32276
  const byKey = /* @__PURE__ */ new Map();
32224
32277
  for (const listener of listeners) {
32225
- const owner = ownerOf(listener, exeByPid, packageByPath, containerByPort, options);
32278
+ const owner = ownerOf2(listener, exeByPid, packageByPath, containerByPort, options);
32226
32279
  const stale = options?.markStale === true && listener.pids.some((pid) => options.stalePids?.has(pid) === true);
32227
32280
  const item = { proto: listener.proto, port: listener.port, bind: listener.bind, owner, ...stale ? { stale: true } : {} };
32228
32281
  const key = `${item.proto}\0${item.port}\0${item.bind}\0${JSON.stringify(item.owner)}`;
@@ -39471,7 +39524,11 @@ var AgentRunner = class {
39471
39524
  const actions = this.#options.lifecycleActions;
39472
39525
  try {
39473
39526
  if (reason2 === "removed:destroyed") {
39474
- await (actions?.purge() ?? purgeAgent({ reason: "destroyed", stateDir: this.#options.paths.dir, ...this.#options.stopKeepAwake ? { stopKeepAwake: this.#options.stopKeepAwake } : {} }));
39527
+ await (actions?.purge() ?? purgeAgent({
39528
+ reason: "destroyed",
39529
+ stateDir: this.#options.paths.dir,
39530
+ ...this.#options.stopKeepAwake ? { stopKeepAwake: this.#options.stopKeepAwake } : {}
39531
+ }, this.#options.lifecycleDeps));
39475
39532
  const dispatch2 = this.#destroyDispatch;
39476
39533
  if (dispatch2 && this.#session)
39477
39534
  this.#session.sendFrame(encode3(buildEnvelope(this.#options.identity, "RESULT", dispatch2.task_id, {
@@ -39480,9 +39537,9 @@ var AgentRunner = class {
39480
39537
  output_excerpt: JSON.stringify({ state: "removed" })
39481
39538
  }, dispatch2.correlation_id)));
39482
39539
  } else {
39483
- await (actions?.removeAutostart() ?? removeAgentAutostart(this.#options.paths.dir)).catch((error63) => this.#logger.warn("autostart removal failed", { error: errorMessage(error63) }));
39540
+ await (actions?.removeAutostart() ?? removeAgentAutostart(this.#options.paths.dir, this.#options.lifecycleDeps)).catch((error63) => this.#logger.warn("autostart removal failed", { error: errorMessage(error63) }));
39484
39541
  if (!passive)
39485
- await (actions?.removeIdentity() ?? removeAgentIdentity({ stateDir: this.#options.paths.dir }));
39542
+ await (actions?.removeIdentity() ?? removeAgentIdentity({ stateDir: this.#options.paths.dir }, this.#options.lifecycleDeps));
39486
39543
  }
39487
39544
  } catch (error63) {
39488
39545
  this.#logger.warn("lifecycle cleanup failed", { error: errorMessage(error63) });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "conbridge-agent",
3
- "version": "0.9.0",
3
+ "version": "0.9.1",
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",