@chatpanel/bridge 0.11.21 → 0.11.23
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/engines/claude.js +6 -1
- package/src/engines/codex.js +3 -1
- package/src/env.js +7 -2
- package/src/relay-timeout.js +21 -0
- package/src/server.js +3 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@chatpanel/bridge",
|
|
3
|
-
"version": "0.11.
|
|
3
|
+
"version": "0.11.23",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Local bridge that exposes the AI coding agents installed on your machine — Claude Code (CLI), Codex (CLI), and Antigravity CLI (formerly Gemini CLI, which remains available for business/enterprise) — to the ChatPanel Chrome extension over a localhost SSE endpoint. Bring your own agent.",
|
|
6
6
|
"keywords": [
|
package/src/engines/claude.js
CHANGED
|
@@ -23,6 +23,7 @@ import { buildCliPrompt } from './prompt.js';
|
|
|
23
23
|
import { summarizeCliError } from '../cli-errors.js';
|
|
24
24
|
import { killOnAbort } from '../proc.js';
|
|
25
25
|
import { pushExtraArgs, FORBIDDEN } from './args.js';
|
|
26
|
+
import { relayTimeoutMax } from '../relay-timeout.js';
|
|
26
27
|
import { displayPath, resolveWorkdir } from '../workdir.js';
|
|
27
28
|
import { connectorsFor } from '../connectors.js';
|
|
28
29
|
|
|
@@ -435,7 +436,11 @@ export async function chat({ messages, system, options, images }, emit, { signal
|
|
|
435
436
|
// Never let caller-supplied extras re-open the read-only boundary the mode flags
|
|
436
437
|
// above establish (shared sanitizer — see args.js).
|
|
437
438
|
pushExtraArgs(args, options.extraArgs, FORBIDDEN.claude, emit);
|
|
438
|
-
|
|
439
|
+
// The CLI's own MCP tool timeout matches the relay's longest tool (a team run's budget), or
|
|
440
|
+
// Claude Code gives up on the call before the bridge does. The user's own setting wins.
|
|
441
|
+
const mcpEnv = mcpConfig && !process.env.MCP_TOOL_TIMEOUT ? { MCP_TOOL_TIMEOUT: String(relayTimeoutMax(options.mcp?.specs)) } : null;
|
|
442
|
+
const runEnv = mcpEnv || options.runEnv ? { ...(options.runEnv || {}), ...(mcpEnv || {}) } : null;
|
|
443
|
+
const run = runClaude({ prompt, args, cwd, env: runEnv, emit, signal });
|
|
439
444
|
if (run === null) {
|
|
440
445
|
cleanup(); // SDK fallback doesn't take images yet
|
|
441
446
|
return sdkChat({ messages, system, options }, emit, { signal });
|
package/src/engines/codex.js
CHANGED
|
@@ -21,6 +21,7 @@ import { existsSync, mkdirSync, symlinkSync, readFileSync } from 'node:fs';
|
|
|
21
21
|
import os from 'node:os';
|
|
22
22
|
import path from 'node:path';
|
|
23
23
|
import { findAgentBin, selfMcpStdio, resolveCommand } from '../env.js';
|
|
24
|
+
import { relayTimeoutMax } from '../relay-timeout.js';
|
|
24
25
|
import { buildCliPrompt } from './prompt.js';
|
|
25
26
|
import { pushExtraArgs, FORBIDDEN } from './args.js';
|
|
26
27
|
import { resolveWorkdir } from '../workdir.js';
|
|
@@ -117,7 +118,8 @@ export function codexMcpConfigArgs(mcp) {
|
|
|
117
118
|
'-c',
|
|
118
119
|
`mcp_servers.${name}.startup_timeout_sec=30`,
|
|
119
120
|
'-c',
|
|
120
|
-
|
|
121
|
+
// Matches the relay's longest tool (a team run's budget) — see relay-timeout.js.
|
|
122
|
+
`mcp_servers.${name}.tool_timeout_sec=${Math.ceil(relayTimeoutMax(mcp.specs) / 1000)}`,
|
|
121
123
|
];
|
|
122
124
|
const toolNames = [...new Set((mcp.specs || []).map((s) => s?.name).filter(Boolean))];
|
|
123
125
|
if (toolNames.length) {
|
package/src/env.js
CHANGED
|
@@ -53,9 +53,14 @@ export function isCompiledBinary() {
|
|
|
53
53
|
export function selfMcpStdio(url) {
|
|
54
54
|
const args = ['--mcp-stdio', url];
|
|
55
55
|
if (isCompiledBinary()) return { command: process.execPath, args };
|
|
56
|
-
// Node/Bun: re-run this same entry script
|
|
56
|
+
// Node/Bun: re-run this same entry script under the same runtime. Embedded in the
|
|
57
|
+
// gateway (CHATPANEL_BRIDGE_EMBEDDED=1) that script is the GATEWAY's bin, which only
|
|
58
|
+
// hands argv to us behind its `--bridge` flag — without it the gateway CLI answers
|
|
59
|
+
// "unknown option: --mcp-stdio", the proxy exits 2, and every CLI agent sees the
|
|
60
|
+
// per-turn ChatPanel tools as "Connection closed".
|
|
57
61
|
const entry = process.argv[1] || path.join(process.cwd(), 'src', 'server.js');
|
|
58
|
-
|
|
62
|
+
const via = process.env.CHATPANEL_BRIDGE_EMBEDDED === '1' ? ['--bridge'] : [];
|
|
63
|
+
return { command: process.execPath, args: [entry, ...via, ...args] };
|
|
59
64
|
}
|
|
60
65
|
|
|
61
66
|
// Ask the user's login shell to locate a command — no hardcoded locations, works
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// How long a relayed tool call may take — one rule for the relay and for the CLIs' own
|
|
2
|
+
// MCP timeouts, so neither gives up before the other.
|
|
3
|
+
//
|
|
4
|
+
// A spec may declare `timeoutMs` (additive to the /chat contract — older extensions send
|
|
5
|
+
// none and keep the two-minute default): a team run declares its budget plus the merge. Before
|
|
6
|
+
// this, a 300 s team hit the relay's flat 120 s, Claude Code was handed "tool call timed out"
|
|
7
|
+
// while the extension was still working, and ran the team a SECOND time; the first run's
|
|
8
|
+
// result then had nowhere to go.
|
|
9
|
+
export const RELAY_TIMEOUT_DEFAULT_MS = 120_000;
|
|
10
|
+
export const RELAY_TIMEOUT_MAX_MS = 60 * 60_000;
|
|
11
|
+
|
|
12
|
+
/** The relay's timeout for one tool of a session. */
|
|
13
|
+
export function relayTimeoutFor(specs, name) {
|
|
14
|
+
const declared = Number((specs || []).find((s) => s?.name === name)?.timeoutMs) || 0;
|
|
15
|
+
return Math.min(RELAY_TIMEOUT_MAX_MS, Math.max(RELAY_TIMEOUT_DEFAULT_MS, declared));
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/** The longest any tool of a session may take — what a CLI's own MCP tool timeout is set to. */
|
|
19
|
+
export function relayTimeoutMax(specs) {
|
|
20
|
+
return Math.max(RELAY_TIMEOUT_DEFAULT_MS, ...(specs || []).map((s) => relayTimeoutFor(specs, s?.name)));
|
|
21
|
+
}
|
package/src/server.js
CHANGED
|
@@ -47,6 +47,7 @@ import * as custom from './engines/custom.js';
|
|
|
47
47
|
import { installService, uninstallService, serviceStatus, restartService } from './service.js';
|
|
48
48
|
import { skillIndex, listRecords, readRecord, readPackageFile, skillsHealth, quarantinedSkills } from './skills.js';
|
|
49
49
|
import { capabilityToolSpecs, runCapabilityTool } from './mcp-capabilities.js';
|
|
50
|
+
import { relayTimeoutFor } from './relay-timeout.js';
|
|
50
51
|
import { DEFAULT_WORKSPACE, isDefaultWorkdir, resolveWorkdir, writeScopeNote } from './workdir.js';
|
|
51
52
|
import { gitState, gitDelta } from './scm.js';
|
|
52
53
|
import { listConnections, putConnection, removeConnection, runEnvFor, testConnection, secretBackend } from './connections.js';
|
|
@@ -78,7 +79,7 @@ import {
|
|
|
78
79
|
// Hardcoded (not read from package.json) so it survives Bun's single-file
|
|
79
80
|
// --compile, where package.json isn't on a readable FS. CI fails the publish if
|
|
80
81
|
// this drifts from package.json, so the two can't silently diverge.
|
|
81
|
-
const VERSION = '0.11.
|
|
82
|
+
const VERSION = '0.11.23';
|
|
82
83
|
const HOST = process.env.CHATPANEL_BRIDGE_HOST || '127.0.0.1';
|
|
83
84
|
const PORT = Number(process.env.CHATPANEL_BRIDGE_PORT) || 4319;
|
|
84
85
|
|
|
@@ -141,7 +142,7 @@ function relayToolCall(session, name, input) {
|
|
|
141
142
|
const timer = setTimeout(() => {
|
|
142
143
|
session.pending.delete(id);
|
|
143
144
|
reject(new Error('tool call timed out'));
|
|
144
|
-
},
|
|
145
|
+
}, relayTimeoutFor(session.specs, name)); // a team run declares its budget; see relay-timeout.js
|
|
145
146
|
session.pending.set(id, {
|
|
146
147
|
resolve: (result) => { clearTimeout(timer); resolve(toMcpContent(result)); },
|
|
147
148
|
reject: (e) => { clearTimeout(timer); reject(e); },
|