@chatpanel/gateway 0.6.61 → 0.6.62
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 +42 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@chatpanel/gateway",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.62",
|
|
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
|
@@ -55,7 +55,7 @@ import * as openai from './openai.js';
|
|
|
55
55
|
import * as responses from './responses.js';
|
|
56
56
|
import * as anthropic from './anthropic.js';
|
|
57
57
|
|
|
58
|
-
export const VERSION = '0.6.
|
|
58
|
+
export const VERSION = '0.6.62';
|
|
59
59
|
|
|
60
60
|
// WARM search tier — SQLite + FTS5 record store (falls back to an encrypted-JSON
|
|
61
61
|
// store if SQLite can't load), fed by the extension's ingest sync + backup-ingest.
|
|
@@ -907,6 +907,47 @@ export function createGateway(cfg = loadConfig()) {
|
|
|
907
907
|
}
|
|
908
908
|
}
|
|
909
909
|
}
|
|
910
|
+
// WHAT THE MODEL WOULD RECEIVE. A client asks "if I sent this, what leaves the
|
|
911
|
+
// machine?" and gets back the redacted text plus the token→type map.
|
|
912
|
+
//
|
|
913
|
+
// WHY THIS IS A GATEWAY ROUTE AND NOT A CLIENT FUNCTION. A preview computed in the
|
|
914
|
+
// client is a SECOND redactor, and the day the two disagree the client is confidently
|
|
915
|
+
// showing the user something other than what was sent — which is worse than showing
|
|
916
|
+
// nothing, because it is believed. This runs the SAME redactSegments over the SAME
|
|
917
|
+
// config, tier, dictionary and detector as a real request, so it cannot drift: if the
|
|
918
|
+
// preview is wrong, the redaction is wrong too, and that is one bug rather than two.
|
|
919
|
+
//
|
|
920
|
+
// Real values NEVER appear in the response. The mapping is token→type only ('types'),
|
|
921
|
+
// never the 'values' detail an operator can opt into for their own logs: this answer
|
|
922
|
+
// crosses a process boundary to a UI, and the client already has the original text.
|
|
923
|
+
// The vault is discarded when this returns, so these tokens are not reusable.
|
|
924
|
+
if (pathname === '/redact' && req.method === 'POST') {
|
|
925
|
+
let text = '';
|
|
926
|
+
try { text = String(JSON.parse((await readBody(req, cfg.maxBodyBytes)).toString('utf8'))?.text || ''); }
|
|
927
|
+
catch { text = ''; }
|
|
928
|
+
if (!text) return sendJson(res, 200, { text: '', count: 0, sanitized: 0, entities: [] });
|
|
929
|
+
try {
|
|
930
|
+
let out = text;
|
|
931
|
+
const isPro = await resolvePro(cfg.pro?.entitlementToken);
|
|
932
|
+
const r = await redactSegments(
|
|
933
|
+
[segment(() => out, (v) => { out = v; })],
|
|
934
|
+
cfg.redaction,
|
|
935
|
+
{ isPro },
|
|
936
|
+
);
|
|
937
|
+
return sendJson(res, 200, {
|
|
938
|
+
text: out,
|
|
939
|
+
count: r.count || 0,
|
|
940
|
+
sanitized: r.sanitized || 0,
|
|
941
|
+
tier: cfg.redaction?.tier === 'full' ? 'full' : 'basic',
|
|
942
|
+
entities: redactionDetail(r.vault, 'types') || [],
|
|
943
|
+
});
|
|
944
|
+
} catch (e) {
|
|
945
|
+
// Fail LOUD. A preview that silently returns the original text would tell the user
|
|
946
|
+
// "nothing here is sensitive" at the exact moment redaction is broken.
|
|
947
|
+
return sendJson(res, 500, { error: { message: `redaction preview failed: ${e.message}`, type: 'redact_error' } });
|
|
948
|
+
}
|
|
949
|
+
}
|
|
950
|
+
|
|
910
951
|
// Model manager (the extension's Gateway settings drive these). GET lists the
|
|
911
952
|
// catalog with install state + live download progress; POST switches the active
|
|
912
953
|
// model (downloading it first if needed) and persists the choice.
|