@chatpanel/gateway 0.6.107 → 0.6.108

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/gateway",
3
- "version": "0.6.107",
3
+ "version": "0.6.108",
4
4
  "description": "Local privacy gateway — redacts PII out of OpenAI/Anthropic API traffic before it reaches a model, then restores it in the reply. Point opencode, codex, aider, Claude Code, etc. at it.",
5
5
  "type": "module",
6
6
  "bin": {
package/src/server.js CHANGED
@@ -40,7 +40,7 @@ import { createEngineLedgerStore } from './engine-ledger-store.js';
40
40
  import { createProjectStore } from './project-store.js';
41
41
  import { applicationsFor, recruitPass } from './recruiting.js';
42
42
  import { ensureBridge } from './bridge-supervisor.js';
43
- import { checkForUpdate, startUpdate, updateJob } from './update.js';
43
+ import { checkForUpdate, updateStatus, startUpdate, updateJob } from './update.js';
44
44
  import { createHistoryStore } from './sqlite-store.js';
45
45
  import { ingestBackups } from './backup-ingest.js';
46
46
  import * as nerEngine from './ner-engine.js';
@@ -64,7 +64,7 @@ import * as openai from './openai.js';
64
64
  import * as responses from './responses.js';
65
65
  import * as anthropic from './anthropic.js';
66
66
 
67
- export const VERSION = '0.6.107';
67
+ export const VERSION = '0.6.108';
68
68
 
69
69
  // WARM search tier — SQLite + FTS5 record store (falls back to an encrypted-JSON
70
70
  // store if SQLite can't load), fed by the extension's ingest sync + backup-ingest.
@@ -794,9 +794,10 @@ export function createGateway(cfg = loadConfig()) {
794
794
  pro: { unlocked: proUnlocked }, usage: usage(cfg),
795
795
  uptimeSeconds: Math.floor((Date.now() - STARTED_AT) / 1000),
796
796
  // ADDITIVE (0.6.107): is there a newer gateway on this install's channel, and can this
797
- // process apply it itself (POST /update)? Throttled to one network check per 6 h and
798
- // never slower than its timeout; an older extension ignores the key.
799
- update: await checkForUpdate(VERSION).catch(() => ({ current: VERSION, updateAvailable: false })),
797
+ // process apply it itself (POST /update)? Answered from the last check, refreshed in
798
+ // the background (0.6.108) — /status never waits on the network; an older extension
799
+ // ignores the key.
800
+ update: updateStatus(VERSION),
800
801
  });
801
802
  }
802
803
  // --- WARM search tier. The extension pushes its DECRYPTED records to this LOCAL
package/src/update.js CHANGED
@@ -185,6 +185,29 @@ export async function checkForUpdate(current, { force = false } = {}) {
185
185
  return { current, latest, updateAvailable, mode, canSelfUpdate, assetUrl, stale, error, npmCommand, channel: mode === 'npm' ? 'npm' : 'release', service: serviceRegistered() };
186
186
  }
187
187
 
188
+ /**
189
+ * What /status reports — NEVER waits on the network. The answer is the last check (in
190
+ * memory, else the disk cache — `stale: true` until a fresh one lands), and a fresh check is
191
+ * kicked off in the background when one is due. The first /status after a start therefore
192
+ * says "unknown yet"; the next says what the registry said. A /status that waited on a 5 s
193
+ * fetch behind a VPN missed the extension's 4 s deadline and drew "Not installed" for a
194
+ * gateway that was running.
195
+ */
196
+ let known = null;
197
+ let inFlight = null;
198
+ export function updateStatus(current) {
199
+ const mode = isCompiledBinary() ? 'binary' : 'npm';
200
+ if (DISABLED) return { current, latest: null, updateAvailable: false, mode, canSelfUpdate: false, stale: false, error: '', npmCommand: null, channel: mode === 'npm' ? 'npm' : 'release', service: false, disabled: true };
201
+ const due = !known || (known.stale ? !(lastFailure.at && Date.now() - lastFailure.at < RETRY_AFTER_FAILURE_MS) : Date.now() - known.checkedAt > CHECK_EVERY_MS);
202
+ if (due && !inFlight) {
203
+ inFlight = checkForUpdate(current).then((r) => { known = { ...r, checkedAt: Date.now() }; }).catch(() => {}).finally(() => { inFlight = null; });
204
+ }
205
+ if (known) return { ...known, checkedAt: undefined, current };
206
+ return { current, latest: null, updateAvailable: false, mode, canSelfUpdate: false, stale: true, checking: true, error: '', npmCommand: null, channel: mode === 'npm' ? 'npm' : 'release', service: serviceRegistered() };
207
+ }
208
+ /** Test seam. */
209
+ export function _resetUpdateStatus() { known = null; inFlight = null; }
210
+
188
211
  // ── apply ───────────────────────────────────────────────────────────────────────────
189
212
 
190
213
  async function swapBinary(info) {