@chatpanel/bridge 0.11.2 → 0.11.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chatpanel/bridge",
3
- "version": "0.11.2",
3
+ "version": "0.11.3",
4
4
  "type": "module",
5
5
  "description": "Local bridge that exposes the AI coding agents installed on your machine \u2014 Claude Code (CLI), Codex (CLI), and Antigravity CLI (formerly Gemini CLI, which remains available for business/enterprise) \u2014 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.2';
70
+ const VERSION = '0.11.3';
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
 
package/src/update.js CHANGED
@@ -78,7 +78,20 @@ export async function checkForUpdate(current, { force = false } = {}) {
78
78
 
79
79
  let latest = null;
80
80
  let assetUrl = null;
81
+ // Whether `latest` is a real answer or yesterday's. GitHub's unauthenticated API is 60
82
+ // requests/hour per IP, and a developer machine burns that easily — so the fallback below
83
+ // is not rare, it fires regularly. Saying WHICH it is matters: acting on a stale "latest"
84
+ // is how a forced check reported "already on the latest version" minutes after a newer one
85
+ // was published, and how an earlier update landed on a version that was not the newest and
86
+ // called it a success.
87
+ let stale = false;
88
+ let error = '';
81
89
  const cache = await readCache();
90
+ const fallBackToCache = () => {
91
+ latest = cache?.latest || null;
92
+ assetUrl = cache?.assetUrl || null;
93
+ stale = true;
94
+ };
82
95
  if (!force && cache && Date.now() - cache.checkedAt < CHECK_EVERY_MS) {
83
96
  latest = cache.latest;
84
97
  assetUrl = cache.assetUrl;
@@ -91,12 +104,12 @@ export async function checkForUpdate(current, { force = false } = {}) {
91
104
  assetUrl = want ? (data.assets || []).find((a) => a.name === want)?.browser_download_url || null : null;
92
105
  await writeCache({ checkedAt: Date.now(), latest, assetUrl });
93
106
  } else {
94
- latest = cache?.latest || null;
95
- assetUrl = cache?.assetUrl || null;
107
+ error = res.status === 403 ? 'GitHub rate limit (60/hour per IP) — try again later' : `HTTP ${res.status}`;
108
+ fallBackToCache();
96
109
  }
97
- } catch {
98
- latest = cache?.latest || null;
99
- assetUrl = cache?.assetUrl || null;
110
+ } catch (e) {
111
+ error = e?.message || String(e);
112
+ fallBackToCache();
100
113
  }
101
114
  }
102
115
  const updateAvailable = !!latest && cmp(latest, current) > 0;
@@ -110,6 +123,8 @@ export async function checkForUpdate(current, { force = false } = {}) {
110
123
  mode,
111
124
  canSelfUpdate,
112
125
  assetUrl,
126
+ stale,
127
+ error,
113
128
  npmCommand: mode === 'npm' ? 'npm i -g @chatpanel/bridge@latest' : null,
114
129
  };
115
130
  }
@@ -122,10 +137,16 @@ export async function selfUpdate(current) {
122
137
  throw new Error('Self-update applies only to the standalone binary. Update the npm/npx version with npm.');
123
138
  }
124
139
  const info = await checkForUpdate(current, { force: true });
125
- if (!info.assetUrl) throw new Error('No downloadable build for this platform use `npx @chatpanel/bridge`.');
126
- if (!info.updateAvailable) {
127
- throw new Error(info.latest ? `Already on the latest version (v${current}).` : 'Could not reach the update server.');
140
+ // A forced check that fell back to the cache has not checked anything. Acting on it is how
141
+ // an update reported success while installing a version that was already superseded, and how
142
+ // it later refused with "already on the latest version" while a newer one sat published.
143
+ // Say what actually happened and leave the binary alone.
144
+ if (info.stale) {
145
+ throw new Error(`Could not reach the update server${info.error ? ` (${info.error})` : ''}. `
146
+ + 'Refusing to act on a stale check — try again in a few minutes.');
128
147
  }
148
+ if (!info.assetUrl) throw new Error('No downloadable build for this platform — use `npx @chatpanel/bridge`.');
149
+ if (!info.updateAvailable) throw new Error(`Already on the latest version (v${current}).`);
129
150
 
130
151
  const target = process.execPath; // the running binary's own path
131
152
  const dir = path.dirname(target);