@chatpanel/gateway 0.1.4 → 0.1.6
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/ner.js +32 -2
- package/src/server.js +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@chatpanel/gateway",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.6",
|
|
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/ner.js
CHANGED
|
@@ -9,9 +9,30 @@
|
|
|
9
9
|
import { spawn } from 'node:child_process';
|
|
10
10
|
import { fileURLToPath } from 'node:url';
|
|
11
11
|
import { dirname, join } from 'node:path';
|
|
12
|
+
import { existsSync } from 'node:fs';
|
|
13
|
+
import os from 'node:os';
|
|
12
14
|
|
|
13
15
|
const NER_DIR = join(dirname(fileURLToPath(import.meta.url)), '..', 'ner');
|
|
14
16
|
|
|
17
|
+
// A login service (LaunchAgent / systemd) inherits a MINIMAL PATH — not your
|
|
18
|
+
// shell's — so `bash` and a pyenv/homebrew `python3` aren't found. Resolve bash
|
|
19
|
+
// absolutely and enrich PATH with the usual locations so run.sh + python3 work.
|
|
20
|
+
function resolveBash() {
|
|
21
|
+
for (const p of ['/bin/bash', '/usr/bin/bash', '/usr/local/bin/bash', '/opt/homebrew/bin/bash']) {
|
|
22
|
+
if (existsSync(p)) return p;
|
|
23
|
+
}
|
|
24
|
+
return 'bash';
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function enrichedPath(home = os.homedir(), base = process.env.PATH || '') {
|
|
28
|
+
const extra = [
|
|
29
|
+
'/opt/homebrew/bin', '/usr/local/bin', '/usr/bin', '/bin', '/usr/sbin', '/sbin',
|
|
30
|
+
join(home, '.pyenv', 'shims'), join(home, '.pyenv', 'bin'),
|
|
31
|
+
join(home, '.local', 'bin'),
|
|
32
|
+
];
|
|
33
|
+
return [...new Set([...base.split(':').filter(Boolean), ...extra])].join(':');
|
|
34
|
+
}
|
|
35
|
+
|
|
15
36
|
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
16
37
|
|
|
17
38
|
// Probe the ACTUAL /ner contract (POST {text} -> {entities}), not /health: many
|
|
@@ -61,9 +82,18 @@ export function startNer(cfg) {
|
|
|
61
82
|
|
|
62
83
|
// 2) Otherwise launch the bundled spaCy server.
|
|
63
84
|
try {
|
|
64
|
-
child = spawn(
|
|
85
|
+
child = spawn(resolveBash(), ['run.sh'], {
|
|
65
86
|
cwd: NER_DIR,
|
|
66
|
-
env: {
|
|
87
|
+
env: {
|
|
88
|
+
...process.env,
|
|
89
|
+
PORT: String(port),
|
|
90
|
+
PATH: enrichedPath(),
|
|
91
|
+
// Force official PyPI: a machine pinned to a private/corp index (in
|
|
92
|
+
// pip.conf) can't reach it off-VPN, which breaks the one-time install.
|
|
93
|
+
PIP_INDEX_URL: process.env.CHATPANEL_PIP_INDEX_URL || 'https://pypi.org/simple',
|
|
94
|
+
PIP_EXTRA_INDEX_URL: '',
|
|
95
|
+
PIP_DISABLE_PIP_VERSION_CHECK: '1',
|
|
96
|
+
},
|
|
67
97
|
stdio: ['ignore', 'pipe', 'pipe'],
|
|
68
98
|
});
|
|
69
99
|
} catch (e) {
|
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.
|
|
34
|
+
export const VERSION = '0.1.6';
|
|
35
35
|
|
|
36
36
|
const KNOWN_AGENTS = new Set(['codex', 'claude', 'opencode', 'pi', 'kiro', 'antigravity']);
|
|
37
37
|
|