@chatpanel/bridge 0.2.2 → 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/README.md CHANGED
@@ -36,6 +36,9 @@ to start it once in the foreground instead.
36
36
 
37
37
  > Until these binaries are code-signed, macOS Gatekeeper / Windows SmartScreen may
38
38
  > warn on first run (on macOS, right-click the file → **Open**). Signing is on the way.
39
+ >
40
+ > **Intel Mac?** There's no x64 binary yet — use **Option B** (`npx @chatpanel/bridge`).
41
+ > Apple Silicon (`uname -m` → `arm64`) uses `chatpanel-bridge-macos-arm64`.
39
42
 
40
43
  ### Option B — via npm (needs Node.js 18+)
41
44
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chatpanel/bridge",
3
- "version": "0.2.2",
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,9 +8,58 @@
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, existsSync } from 'node:fs';
11
12
 
12
13
  let enriched = false;
13
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
+
41
+ // Version managers install CLIs under versioned bin dirs that a lazy-loaded
42
+ // shell (nvm/fnm) doesn't export into a non-interactive service PATH. Add them.
43
+ function versionManagerBins(home) {
44
+ const bins = [];
45
+ const tryDir = (dir, sub) => {
46
+ try {
47
+ for (const v of readdirSync(dir)) bins.push(path.join(dir, v, sub));
48
+ } catch {
49
+ /* dir absent */
50
+ }
51
+ };
52
+ // nvm: ~/.nvm/versions/node/<v>/bin
53
+ tryDir(path.join(process.env.NVM_DIR || path.join(home, '.nvm'), 'versions', 'node'), 'bin');
54
+ // fnm: ~/.local/share/fnm/node-versions/<v>/installation/bin (+ macOS app-support)
55
+ tryDir(path.join(home, '.local', 'share', 'fnm', 'node-versions'), path.join('installation', 'bin'));
56
+ tryDir(path.join(home, 'Library', 'Application Support', 'fnm', 'node-versions'), path.join('installation', 'bin'));
57
+ // volta / asdf shims
58
+ bins.push(path.join(home, '.volta', 'bin'));
59
+ bins.push(path.join(home, '.asdf', 'shims'));
60
+ return bins;
61
+ }
62
+
14
63
  export function enrichPath() {
15
64
  if (enriched || process.platform === 'win32') {
16
65
  enriched = true;
@@ -33,6 +82,7 @@ export function enrichPath() {
33
82
  path.join(home, '.cargo', 'bin'),
34
83
  path.join(home, '.deno', 'bin'),
35
84
  path.join(home, '.bun', 'bin'),
85
+ ...versionManagerBins(home),
36
86
  ];
37
87
 
38
88
  // Ask the user's login shell for its PATH — captures nvm / Homebrew / asdf, etc.
@@ -56,4 +106,13 @@ export function enrichPath() {
56
106
  ].filter((p) => p && !seen.has(p) && (seen.add(p), true));
57
107
 
58
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
+ }
59
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.2';
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