@chatpanel/bridge 0.2.1 → 0.2.3

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.1",
3
+ "version": "0.2.3",
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 ADDED
@@ -0,0 +1,83 @@
1
+ // Resolve a usable PATH for spawning the agent CLIs (codex, gemini).
2
+ //
3
+ // When the bridge runs as a login service (LaunchAgent / Scheduled Task) — or as
4
+ // a double-clicked app — it inherits a MINIMAL PATH, not your interactive shell's.
5
+ // So CLIs installed via Homebrew, npm-global, nvm, etc. aren't found. We fix that
6
+ // by (1) asking your login shell for its PATH and (2) adding common bin dirs.
7
+
8
+ import os from 'node:os';
9
+ import path from 'node:path';
10
+ import { spawnSync } from 'node:child_process';
11
+ import { readdirSync } from 'node:fs';
12
+
13
+ let enriched = false;
14
+
15
+ // Version managers install CLIs under versioned bin dirs that a lazy-loaded
16
+ // shell (nvm/fnm) doesn't export into a non-interactive service PATH. Add them.
17
+ function versionManagerBins(home) {
18
+ const bins = [];
19
+ const tryDir = (dir, sub) => {
20
+ try {
21
+ for (const v of readdirSync(dir)) bins.push(path.join(dir, v, sub));
22
+ } catch {
23
+ /* dir absent */
24
+ }
25
+ };
26
+ // nvm: ~/.nvm/versions/node/<v>/bin
27
+ tryDir(path.join(process.env.NVM_DIR || path.join(home, '.nvm'), 'versions', 'node'), 'bin');
28
+ // fnm: ~/.local/share/fnm/node-versions/<v>/installation/bin (+ macOS app-support)
29
+ tryDir(path.join(home, '.local', 'share', 'fnm', 'node-versions'), path.join('installation', 'bin'));
30
+ tryDir(path.join(home, 'Library', 'Application Support', 'fnm', 'node-versions'), path.join('installation', 'bin'));
31
+ // volta / asdf shims
32
+ bins.push(path.join(home, '.volta', 'bin'));
33
+ bins.push(path.join(home, '.asdf', 'shims'));
34
+ return bins;
35
+ }
36
+
37
+ export function enrichPath() {
38
+ if (enriched || process.platform === 'win32') {
39
+ enriched = true;
40
+ return; // Windows scheduled tasks run as the user and inherit a fuller PATH.
41
+ }
42
+ enriched = true;
43
+
44
+ const home = os.homedir();
45
+ const common = [
46
+ '/opt/homebrew/bin',
47
+ '/opt/homebrew/sbin',
48
+ '/usr/local/bin',
49
+ '/usr/bin',
50
+ '/bin',
51
+ '/usr/sbin',
52
+ '/sbin',
53
+ path.join(home, '.local', 'bin'),
54
+ path.join(home, 'bin'),
55
+ path.join(home, '.npm-global', 'bin'),
56
+ path.join(home, '.cargo', 'bin'),
57
+ path.join(home, '.deno', 'bin'),
58
+ path.join(home, '.bun', 'bin'),
59
+ ...versionManagerBins(home),
60
+ ];
61
+
62
+ // Ask the user's login shell for its PATH — captures nvm / Homebrew / asdf, etc.
63
+ let shellPath = '';
64
+ try {
65
+ const shell = process.env.SHELL || '/bin/zsh';
66
+ const r = spawnSync(shell, ['-ilc', 'command -p echo "$PATH"'], {
67
+ encoding: 'utf8',
68
+ timeout: 4000,
69
+ });
70
+ if (r.status === 0) shellPath = (r.stdout || '').trim();
71
+ } catch {
72
+ /* fall back to common dirs below */
73
+ }
74
+
75
+ const seen = new Set();
76
+ const merged = [
77
+ ...(shellPath ? shellPath.split(':') : []),
78
+ ...(process.env.PATH ? process.env.PATH.split(path.delimiter) : []),
79
+ ...common,
80
+ ].filter((p) => p && !seen.has(p) && (seen.add(p), true));
81
+
82
+ process.env.PATH = merged.join(path.delimiter);
83
+ }
package/src/server.js CHANGED
@@ -19,8 +19,9 @@ import * as claude from './engines/claude.js';
19
19
  import * as codex from './engines/codex.js';
20
20
  import * as gemini from './engines/gemini.js';
21
21
  import { installService, uninstallService, serviceStatus } from './service.js';
22
+ import { enrichPath } from './env.js';
22
23
 
23
- const VERSION = '0.2.1';
24
+ const VERSION = '0.2.3';
24
25
  const HOST = process.env.CHATPANEL_BRIDGE_HOST || '127.0.0.1';
25
26
  const PORT = Number(process.env.CHATPANEL_BRIDGE_PORT) || 4319;
26
27
 
@@ -188,6 +189,7 @@ function log(level, msg) {
188
189
  }
189
190
 
190
191
  function startServer() {
192
+ enrichPath(); // so codex/gemini are found even under a minimal service PATH
191
193
  server.listen(PORT, HOST, async () => {
192
194
  log('info', `listening on http://${HOST}:${PORT}`);
193
195
  for (const [, { engine, label }] of Object.entries(ENGINES)) {