@chatpanel/bridge 0.11.10 → 0.11.13
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/server.js +4 -1
- package/src/update.js +34 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@chatpanel/bridge",
|
|
3
|
-
"version": "0.11.
|
|
3
|
+
"version": "0.11.13",
|
|
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/server.js
CHANGED
|
@@ -67,7 +67,7 @@ import {
|
|
|
67
67
|
// Hardcoded (not read from package.json) so it survives Bun's single-file
|
|
68
68
|
// --compile, where package.json isn't on a readable FS. CI fails the publish if
|
|
69
69
|
// this drifts from package.json, so the two can't silently diverge.
|
|
70
|
-
const VERSION = '0.11.
|
|
70
|
+
const VERSION = '0.11.13';
|
|
71
71
|
const HOST = process.env.CHATPANEL_BRIDGE_HOST || '127.0.0.1';
|
|
72
72
|
const PORT = Number(process.env.CHATPANEL_BRIDGE_PORT) || 4319;
|
|
73
73
|
|
|
@@ -445,6 +445,9 @@ async function handleHealth(res) {
|
|
|
445
445
|
json(res, 200, {
|
|
446
446
|
ok: true, version: VERSION, agents, update,
|
|
447
447
|
workspace: DEFAULT_WORKSPACE,
|
|
448
|
+
// WHO STARTED THIS PROCESS — additive. ChatPanel Desktop sets CHATPANEL_MANAGED_BY=desktop on
|
|
449
|
+
// the login service it registers; a client can then say so instead of offering install.sh.
|
|
450
|
+
...(process.env.CHATPANEL_MANAGED_BY ? { managedBy: String(process.env.CHATPANEL_MANAGED_BY).slice(0, 32) } : {}),
|
|
448
451
|
...(skills ? { skills } : {}),
|
|
449
452
|
});
|
|
450
453
|
}
|
package/src/update.js
CHANGED
|
@@ -24,6 +24,18 @@ const LATEST_API = `https://api.github.com/repos/${REPO}/releases/latest`;
|
|
|
24
24
|
const CHECK_EVERY_MS = 6 * 60 * 60 * 1000; // 6h
|
|
25
25
|
const CACHE = path.join(os.homedir(), '.chatpanel', 'update-check.json');
|
|
26
26
|
const UA = { 'User-Agent': 'chatpanel-bridge-updater' };
|
|
27
|
+
// THIS CHECK RUNS INSIDE /health. Every client heartbeat — the extension, the desktop's
|
|
28
|
+
// supervisor, the gateway's model list — waits on it. An un-timed fetch to GitHub therefore
|
|
29
|
+
// made every one of them wait for a VPN to give up on api.github.com, and the desktop gives a
|
|
30
|
+
// health answer 2.5s before calling the bridge dead. So: a short timeout, and after a failure
|
|
31
|
+
// no retry for a while — a failed check that was re-attempted on every call kept the stall
|
|
32
|
+
// going for as long as the network was bad.
|
|
33
|
+
const FETCH_TIMEOUT_MS = Math.max(500, Number(process.env.CHATPANEL_UPDATE_TIMEOUT_MS) || 5000);
|
|
34
|
+
const RETRY_AFTER_FAILURE_MS = 10 * 60 * 1000; // 10min
|
|
35
|
+
let lastFailure = { at: 0, error: '' };
|
|
36
|
+
|
|
37
|
+
/** Test seam: forget the last failure so the next unforced check reaches the network. */
|
|
38
|
+
export function resetUpdateBackoff() { lastFailure = { at: 0, error: '' }; }
|
|
27
39
|
|
|
28
40
|
// Release asset name for THIS platform (matches release-binaries.yml outputs).
|
|
29
41
|
// macOS publishes arm64 only; Intel Macs use `npx` (managed → no self-update).
|
|
@@ -95,21 +107,41 @@ export async function checkForUpdate(current, { force = false } = {}) {
|
|
|
95
107
|
if (!force && cache && Date.now() - cache.checkedAt < CHECK_EVERY_MS) {
|
|
96
108
|
latest = cache.latest;
|
|
97
109
|
assetUrl = cache.assetUrl;
|
|
110
|
+
} else if (!force && lastFailure.at && Date.now() - lastFailure.at < RETRY_AFTER_FAILURE_MS) {
|
|
111
|
+
// The network said no a moment ago. Asking again on every health poll would make every
|
|
112
|
+
// poll as slow as the failure; the answer is what it was, and says so.
|
|
113
|
+
error = lastFailure.error;
|
|
114
|
+
fallBackToCache();
|
|
98
115
|
} else {
|
|
116
|
+
// An explicit timer, not AbortSignal.timeout: that one's timer is unref'd, so in a
|
|
117
|
+
// process with nothing else to do (a test, a CLI one-shot) the loop can exit before it
|
|
118
|
+
// fires and the fetch is neither answered nor abandoned.
|
|
119
|
+
const ctl = new AbortController();
|
|
120
|
+
const timer = setTimeout(() => ctl.abort(), FETCH_TIMEOUT_MS);
|
|
99
121
|
try {
|
|
100
|
-
const res = await fetch(LATEST_API, {
|
|
122
|
+
const res = await fetch(LATEST_API, {
|
|
123
|
+
headers: { Accept: 'application/vnd.github+json', ...UA },
|
|
124
|
+
signal: ctl.signal,
|
|
125
|
+
});
|
|
101
126
|
if (res.ok) {
|
|
102
127
|
const data = await res.json();
|
|
103
128
|
latest = parseVersion(data.tag_name) || parseVersion(data.name);
|
|
104
129
|
assetUrl = want ? (data.assets || []).find((a) => a.name === want)?.browser_download_url || null : null;
|
|
105
130
|
await writeCache({ checkedAt: Date.now(), latest, assetUrl });
|
|
131
|
+
lastFailure = { at: 0, error: '' };
|
|
106
132
|
} else {
|
|
107
133
|
error = res.status === 403 ? 'GitHub rate limit (60/hour per IP) — try again later' : `HTTP ${res.status}`;
|
|
134
|
+
lastFailure = { at: Date.now(), error };
|
|
108
135
|
fallBackToCache();
|
|
109
136
|
}
|
|
110
137
|
} catch (e) {
|
|
111
|
-
error =
|
|
138
|
+
error = ctl.signal.aborted
|
|
139
|
+
? `GitHub did not answer within ${Math.round(FETCH_TIMEOUT_MS / 1000)}s`
|
|
140
|
+
: e?.message || String(e);
|
|
141
|
+
lastFailure = { at: Date.now(), error };
|
|
112
142
|
fallBackToCache();
|
|
143
|
+
} finally {
|
|
144
|
+
clearTimeout(timer);
|
|
113
145
|
}
|
|
114
146
|
}
|
|
115
147
|
const updateAvailable = !!latest && cmp(latest, current) > 0;
|