@chatpanel/gateway 0.1.7 → 0.1.9

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.1.7",
3
+ "version": "0.1.9",
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": {
@@ -34,7 +34,8 @@ export function publicConfig(cfg, { proUnlocked = false } = {}) {
34
34
  redaction: {
35
35
  tier: cfg.redaction?.tier,
36
36
  redactSystem: cfg.redaction?.redactSystem !== false,
37
- detection: cfg.redaction?.detection || { backend: 'off' },
37
+ // Never echo the detector's apiKey back (write-only, like the tokens).
38
+ detection: (() => { const { apiKey, ...d } = cfg.redaction?.detection || { backend: 'off' }; return d; })(),
38
39
  dictionary: Array.isArray(cfg.redaction?.dictionary) ? cfg.redaction.dictionary : [],
39
40
  },
40
41
  ner: cfg.ner,
@@ -51,6 +52,16 @@ export function applyConfigPatch(cfg, patch = {}) {
51
52
  if (typeof patch.bridge.url === 'string') cfg.bridge.url = patch.bridge.url;
52
53
  if (typeof patch.bridge.agent === 'string') cfg.bridge.agent = patch.bridge.agent;
53
54
  }
55
+ // api backend: where redacted traffic is forwarded (the client still picks the
56
+ // model + sends its own key).
57
+ if (patch.upstreams && typeof patch.upstreams === 'object') {
58
+ for (const k of ['openai', 'anthropic']) {
59
+ const u = patch.upstreams[k];
60
+ if (u && typeof u.baseUrl === 'string' && u.baseUrl.trim()) {
61
+ cfg.upstreams[k] = { ...cfg.upstreams[k], baseUrl: u.baseUrl.trim() };
62
+ }
63
+ }
64
+ }
54
65
  if (patch.redaction && typeof patch.redaction === 'object') {
55
66
  const r = patch.redaction;
56
67
  if (r.tier === 'basic' || r.tier === 'full') cfg.redaction.tier = r.tier;
package/src/ner.js CHANGED
@@ -58,17 +58,20 @@ export function startNer(cfg) {
58
58
  const n = cfg.ner;
59
59
  if (!n || !n.autostart) return null;
60
60
 
61
- // Respect an explicitly-configured detector — don't relaunch — but still apply
62
- // the full-tier bump (else a persisted config with detection-on but tier:basic
63
- // would never redact entities even though a detector is available).
61
+ const port = n.port || 9009;
62
+ const bundledUrl = `http://127.0.0.1:${port}/ner`;
63
+
64
+ // Respect a USER-configured detector pointing elsewhere (a custom NER, a local
65
+ // LLM) — don't relaunch — but still apply the full-tier bump. If detection is
66
+ // off OR points at our own bundled NER, fall through and (re)launch/adopt it,
67
+ // so a persisted "detection→bundled" config doesn't leave NER actually down.
64
68
  const det = cfg.redaction?.detection;
65
- if (det && det.backend && det.backend !== 'off') {
69
+ const userDetector = det && det.backend && det.backend !== 'off' && det.url !== bundledUrl;
70
+ if (userDetector) {
66
71
  if (n.enableFullTier && cfg.redaction.tier !== 'full') cfg.redaction.tier = 'full';
67
- console.log(`[ner] detection already configured (${det.backend}) — full tier ${cfg.redaction.tier === 'full' ? 'on' : 'off'}`);
72
+ console.log(`[ner] using configured detector (${det.backend} ${det.url || ''}) — full tier ${cfg.redaction.tier === 'full' ? 'on' : 'off'}`);
68
73
  return null;
69
74
  }
70
-
71
- const port = n.port || 9009;
72
75
  let stopped = false;
73
76
  let child = null;
74
77
  const ac = new AbortController();
@@ -121,12 +124,12 @@ export function startNer(cfg) {
121
124
  });
122
125
 
123
126
  // 3) Poll for readiness; wire detection when up.
124
- const deadline = Date.now() + 120_000; // generous: first run installs deps
127
+ const deadline = Date.now() + 300_000; // generous: first run installs deps
125
128
  while (Date.now() < deadline && !stopped) {
126
129
  if (await nerReachable(port, ac.signal)) { wire('ready'); return; }
127
130
  await sleep(1000);
128
131
  }
129
- if (!stopped) console.log('[ner] not ready after 120s — continuing deterministic-only (run ./ner/run.sh manually to debug).');
132
+ if (!stopped) console.log('[ner] not ready after 300s — continuing deterministic-only (run ./ner/run.sh manually to debug).');
130
133
  })();
131
134
 
132
135
  const stop = () => {
package/src/server.js CHANGED
@@ -31,7 +31,7 @@ import * as openai from './openai.js';
31
31
  import * as responses from './responses.js';
32
32
  import * as anthropic from './anthropic.js';
33
33
 
34
- export const VERSION = '0.1.7';
34
+ export const VERSION = '0.1.9';
35
35
 
36
36
  const KNOWN_AGENTS = new Set(['codex', 'claude', 'opencode', 'pi', 'kiro', 'antigravity']);
37
37