@chatpanel/gateway 0.6.9 → 0.6.10
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/config.js +11 -0
- package/src/server.js +15 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@chatpanel/gateway",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.10",
|
|
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/config.js
CHANGED
|
@@ -139,5 +139,16 @@ export function loadConfig(env = process.env) {
|
|
|
139
139
|
if (env.ANTHROPIC_BASE_URL) cfg = deepMerge(cfg, { upstreams: { anthropic: { baseUrl: env.ANTHROPIC_BASE_URL } } });
|
|
140
140
|
if (env.CHATPANEL_REDACTION_TIER) cfg = deepMerge(cfg, { redaction: { tier: env.CHATPANEL_REDACTION_TIER } });
|
|
141
141
|
|
|
142
|
+
// A persisted port of 0 means "let the OS pick a random port" — fatal for a
|
|
143
|
+
// service that clients reach at a FIXED address: the extension, install.sh, and
|
|
144
|
+
// OpenCode/Pi all hardcode 4320. A stale/corrupt config that wrote 0 would bind a
|
|
145
|
+
// random ephemeral port and look "running but unreachable". Coerce 0 / NaN / out-
|
|
146
|
+
// of-range back to the default so the gateway is always where clients expect it.
|
|
147
|
+
const p = Number(cfg.port);
|
|
148
|
+
if (!Number.isInteger(p) || p < 1 || p > 65535) {
|
|
149
|
+
if (cfg.port !== DEFAULTS.port) console.warn(`[gateway] ignoring invalid port ${JSON.stringify(cfg.port)} — using ${DEFAULTS.port}`);
|
|
150
|
+
cfg = deepMerge(cfg, { port: DEFAULTS.port });
|
|
151
|
+
}
|
|
152
|
+
|
|
142
153
|
return cfg;
|
|
143
154
|
}
|
package/src/server.js
CHANGED
|
@@ -37,7 +37,7 @@ import * as openai from './openai.js';
|
|
|
37
37
|
import * as responses from './responses.js';
|
|
38
38
|
import * as anthropic from './anthropic.js';
|
|
39
39
|
|
|
40
|
-
export const VERSION = '0.6.
|
|
40
|
+
export const VERSION = '0.6.10';
|
|
41
41
|
|
|
42
42
|
const KNOWN_AGENTS = new Set(['codex', 'claude', 'opencode', 'pi', 'kiro', 'antigravity']);
|
|
43
43
|
|
|
@@ -712,6 +712,20 @@ export function start(cfg = loadConfig()) {
|
|
|
712
712
|
// revoked subscription drops the gateway to Free instead of riding the offline
|
|
713
713
|
// token to its exp (see entitlement-refresh.js).
|
|
714
714
|
const entitlement = startEntitlementRefresh(cfg);
|
|
715
|
+
// Fail LOUD on a port clash instead of crashing with a raw stack trace. We bind a
|
|
716
|
+
// FIXED port (4320) so the extension / install.sh / OpenCode can always find us; if
|
|
717
|
+
// something else already holds it, tell the user exactly how to recover (pick a new
|
|
718
|
+
// port, restart, and point the extension's Gateway tab at it) rather than silently
|
|
719
|
+
// dying or drifting to a random port.
|
|
720
|
+
server.on('error', (e) => {
|
|
721
|
+
if (e && e.code === 'EADDRINUSE') {
|
|
722
|
+
console.error(`Port ${cfg.port} is already in use — another app (or a second gateway) has it.`);
|
|
723
|
+
console.error(`Fix: free the port, or set a different one — edit "port" in ${configPath()} (or the extension's Gateway tab) and restart. The extension must point at the same port.`);
|
|
724
|
+
process.exit(1);
|
|
725
|
+
}
|
|
726
|
+
console.error(`Gateway server error: ${e?.message || e}`);
|
|
727
|
+
process.exit(1);
|
|
728
|
+
});
|
|
715
729
|
server.listen(cfg.port, cfg.host, () => {
|
|
716
730
|
console.log(`ChatPanel Privacy Gateway v${VERSION} on http://${cfg.host}:${cfg.port}`);
|
|
717
731
|
console.log(` backend : ${cfg.backend}` + (cfg.backend === 'bridge' ? ` (agent: ${cfg.bridge.agent}, via ${cfg.bridge.url})` : ''));
|