@chatpanel/bridge 0.2.1 → 0.2.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/package.json +1 -1
- package/src/env.js +59 -0
- package/src/server.js +3 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@chatpanel/bridge",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.2",
|
|
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,59 @@
|
|
|
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
|
+
|
|
12
|
+
let enriched = false;
|
|
13
|
+
|
|
14
|
+
export function enrichPath() {
|
|
15
|
+
if (enriched || process.platform === 'win32') {
|
|
16
|
+
enriched = true;
|
|
17
|
+
return; // Windows scheduled tasks run as the user and inherit a fuller PATH.
|
|
18
|
+
}
|
|
19
|
+
enriched = true;
|
|
20
|
+
|
|
21
|
+
const home = os.homedir();
|
|
22
|
+
const common = [
|
|
23
|
+
'/opt/homebrew/bin',
|
|
24
|
+
'/opt/homebrew/sbin',
|
|
25
|
+
'/usr/local/bin',
|
|
26
|
+
'/usr/bin',
|
|
27
|
+
'/bin',
|
|
28
|
+
'/usr/sbin',
|
|
29
|
+
'/sbin',
|
|
30
|
+
path.join(home, '.local', 'bin'),
|
|
31
|
+
path.join(home, 'bin'),
|
|
32
|
+
path.join(home, '.npm-global', 'bin'),
|
|
33
|
+
path.join(home, '.cargo', 'bin'),
|
|
34
|
+
path.join(home, '.deno', 'bin'),
|
|
35
|
+
path.join(home, '.bun', 'bin'),
|
|
36
|
+
];
|
|
37
|
+
|
|
38
|
+
// Ask the user's login shell for its PATH — captures nvm / Homebrew / asdf, etc.
|
|
39
|
+
let shellPath = '';
|
|
40
|
+
try {
|
|
41
|
+
const shell = process.env.SHELL || '/bin/zsh';
|
|
42
|
+
const r = spawnSync(shell, ['-ilc', 'command -p echo "$PATH"'], {
|
|
43
|
+
encoding: 'utf8',
|
|
44
|
+
timeout: 4000,
|
|
45
|
+
});
|
|
46
|
+
if (r.status === 0) shellPath = (r.stdout || '').trim();
|
|
47
|
+
} catch {
|
|
48
|
+
/* fall back to common dirs below */
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const seen = new Set();
|
|
52
|
+
const merged = [
|
|
53
|
+
...(shellPath ? shellPath.split(':') : []),
|
|
54
|
+
...(process.env.PATH ? process.env.PATH.split(path.delimiter) : []),
|
|
55
|
+
...common,
|
|
56
|
+
].filter((p) => p && !seen.has(p) && (seen.add(p), true));
|
|
57
|
+
|
|
58
|
+
process.env.PATH = merged.join(path.delimiter);
|
|
59
|
+
}
|
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.
|
|
24
|
+
const VERSION = '0.2.2';
|
|
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)) {
|