@chatpanel/bridge 0.2.3 → 0.2.4

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chatpanel/bridge",
3
- "version": "0.2.3",
3
+ "version": "0.2.4",
4
4
  "type": "module",
5
5
  "description": "Local bridge that exposes the AI coding agents installed on your machine — Claude Code (Agent SDK), Codex (CLI), and Gemini CLI — to the ChatPanel Chrome extension over a localhost SSE endpoint. Bring your own agent.",
6
6
  "keywords": [
package/src/env.js CHANGED
@@ -8,10 +8,36 @@
8
8
  import os from 'node:os';
9
9
  import path from 'node:path';
10
10
  import { spawnSync } from 'node:child_process';
11
- import { readdirSync } from 'node:fs';
11
+ import { readdirSync, existsSync } from 'node:fs';
12
12
 
13
13
  let enriched = false;
14
14
 
15
+ // The agent CLIs the bridge shells out to (Claude is the in-process SDK).
16
+ const AGENT_CLIS = ['codex', 'gemini'];
17
+
18
+ // Is `name` executable somewhere on the current PATH?
19
+ function onPath(name) {
20
+ const dirs = (process.env.PATH || '').split(path.delimiter);
21
+ return dirs.some((d) => d && (existsSync(path.join(d, name)) || existsSync(path.join(d, name + '.exe'))));
22
+ }
23
+
24
+ // Ask the user's login shell to locate a command — no hardcoded locations, works
25
+ // wherever the user actually installed it.
26
+ function shellWhich(name) {
27
+ if (process.platform === 'win32') return '';
28
+ try {
29
+ const shell = process.env.SHELL || '/bin/zsh';
30
+ const r = spawnSync(shell, ['-ilc', `command -v ${name} 2>/dev/null`], {
31
+ encoding: 'utf8',
32
+ timeout: 4000,
33
+ });
34
+ const out = (r.stdout || '').trim().split('\n').pop().trim();
35
+ return out && out.startsWith('/') ? out : '';
36
+ } catch {
37
+ return '';
38
+ }
39
+ }
40
+
15
41
  // Version managers install CLIs under versioned bin dirs that a lazy-loaded
16
42
  // shell (nvm/fnm) doesn't export into a non-interactive service PATH. Add them.
17
43
  function versionManagerBins(home) {
@@ -80,4 +106,13 @@ export function enrichPath() {
80
106
  ].filter((p) => p && !seen.has(p) && (seen.add(p), true));
81
107
 
82
108
  process.env.PATH = merged.join(path.delimiter);
109
+
110
+ // Final, hardcode-free backstop: if an agent CLI still isn't on PATH, ask the
111
+ // login shell exactly where it is and prepend that dir. Covers any custom
112
+ // install location (asdf shims, a one-off prefix, etc.).
113
+ for (const cli of AGENT_CLIS) {
114
+ if (onPath(cli)) continue;
115
+ const found = shellWhich(cli);
116
+ if (found) process.env.PATH = path.dirname(found) + path.delimiter + process.env.PATH;
117
+ }
83
118
  }
package/src/server.js CHANGED
@@ -21,7 +21,7 @@ import * as gemini from './engines/gemini.js';
21
21
  import { installService, uninstallService, serviceStatus } from './service.js';
22
22
  import { enrichPath } from './env.js';
23
23
 
24
- const VERSION = '0.2.3';
24
+ const VERSION = '0.2.4';
25
25
  const HOST = process.env.CHATPANEL_BRIDGE_HOST || '127.0.0.1';
26
26
  const PORT = Number(process.env.CHATPANEL_BRIDGE_PORT) || 4319;
27
27