@polderlabs/bizar 10.0.7 → 10.1.0
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/bizar-dash/src/server/api.mjs +2 -6
- package/bizar-dash/src/server/diagnostics-store.mjs +5 -35
- package/bizar-dash/src/server/mod-security.mjs +1 -2
- package/bizar-dash/src/server/providers-store.mjs +1 -1
- package/bizar-dash/src/server/routes/_shared.mjs +0 -17
- package/bizar-dash/src/server/routes/model-router.mjs +103 -0
- package/bizar-dash/src/server/routes/model-router.test.mjs +76 -0
- package/bizar-dash/src/server/server.mjs +1 -27
- package/bizar-dash/tests/cli-bugfixes.test.mjs +1 -1
- package/bizar-dash/tests/cli-error-visibility.test.mjs +1 -1
- package/bizar-dash/tests/cli-refactor.test.mjs +0 -1
- package/bizar-dash/tests/diagnostics-store.test.mjs +0 -1
- package/cli/bin.mjs +1 -15
- package/cli/cli-commands-validation.test.mjs +1 -1
- package/cli/commands/lightrag.mjs +1 -1
- package/cli/commands/util.mjs +1 -1
- package/cli/copy.mjs +1 -47
- package/cli/doctor.mjs +3 -3
- package/cli/install.mjs +3 -37
- package/cli/service-controller.mjs +0 -192
- package/cli/service-env.mjs +2 -9
- package/cli/utils.mjs +0 -7
- package/package.json +1 -1
- package/packages/sdk/package.json +1 -1
- package/scripts/check-deps.mjs +0 -24
- package/bizar-dash/skills/headroom/SKILL.md +0 -94
- package/bizar-dash/src/server/headroom.mjs +0 -649
- package/bizar-dash/src/server/routes/headroom.mjs +0 -126
- package/bizar-dash/tests/headroom-install.test.mjs +0 -173
- package/bizar-dash/tests/headroom-settings.test.mjs +0 -126
- package/bizar-dash/tests/headroom-status.test.mjs +0 -117
- package/cli/commands/headroom.mjs +0 -204
|
@@ -1,204 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* cli/commands/headroom.mjs
|
|
3
|
-
*
|
|
4
|
-
* Headroom context compression CLI.
|
|
5
|
-
* v3.17.0+ — status, stats, install, wrap, unwrap, start, stop, doctor.
|
|
6
|
-
*/
|
|
7
|
-
import chalk from 'chalk';
|
|
8
|
-
import { existsSync, readFileSync } from 'node:fs';
|
|
9
|
-
import { join } from 'node:path';
|
|
10
|
-
import { homedir } from 'node:os';
|
|
11
|
-
import { spawn } from 'node:child_process';
|
|
12
|
-
|
|
13
|
-
const HOME = homedir();
|
|
14
|
-
const BIZAR_HOME = join(HOME, '.config', 'bizar');
|
|
15
|
-
|
|
16
|
-
// ── Dashboard connection ────────────────────────────────────────────────────────
|
|
17
|
-
|
|
18
|
-
function readDashboardConn() {
|
|
19
|
-
const portFile = join(BIZAR_HOME, 'dashboard.port');
|
|
20
|
-
const authFile = join(BIZAR_HOME, 'dashboard-secret');
|
|
21
|
-
let port = 4321;
|
|
22
|
-
let secret = '';
|
|
23
|
-
try {
|
|
24
|
-
if (existsSync(portFile)) {
|
|
25
|
-
const parsed = parseInt(readFileSync(portFile, 'utf8').trim(), 10);
|
|
26
|
-
if (Number.isFinite(parsed) && parsed > 0) port = parsed;
|
|
27
|
-
}
|
|
28
|
-
} catch { /* ignore */ }
|
|
29
|
-
try {
|
|
30
|
-
if (existsSync(authFile)) secret = readFileSync(authFile, 'utf8').trim();
|
|
31
|
-
} catch { /* ignore */ }
|
|
32
|
-
return { port, secret };
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
// ── Help ───────────────────────────────────────────────────────────────────────
|
|
36
|
-
|
|
37
|
-
export function showHeadroomHelp() {
|
|
38
|
-
console.log(`
|
|
39
|
-
bizar headroom — Manage Headroom context compression
|
|
40
|
-
|
|
41
|
-
Usage:
|
|
42
|
-
bizar headroom status Show live status (installed, proxy, wrapped)
|
|
43
|
-
bizar headroom stats Show compression stats for the last 24h
|
|
44
|
-
bizar headroom install Install headroom via pip or npm
|
|
45
|
-
bizar headroom wrap Wrap cline to route through the proxy
|
|
46
|
-
bizar headroom unwrap Unwrap cline
|
|
47
|
-
bizar headroom start Start the proxy server
|
|
48
|
-
bizar headroom stop Stop the proxy server
|
|
49
|
-
bizar headroom doctor Run headroom doctor health check
|
|
50
|
-
|
|
51
|
-
Examples:
|
|
52
|
-
bizar headroom status
|
|
53
|
-
bizar headroom stats
|
|
54
|
-
bizar headroom install
|
|
55
|
-
bizar headroom wrap
|
|
56
|
-
`);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
// ── API helpers ────────────────────────────────────────────────────────────────
|
|
60
|
-
|
|
61
|
-
async function apiGet(path) {
|
|
62
|
-
const { port, secret } = readDashboardConn();
|
|
63
|
-
const baseUrl = `http://127.0.0.1:${port}`;
|
|
64
|
-
const url = `${baseUrl}${path}`;
|
|
65
|
-
const headers = { accept: 'application/json' };
|
|
66
|
-
if (secret) headers.authorization = `Basic ${Buffer.from(`cline:${secret}`).toString('base64')}`;
|
|
67
|
-
const res = await fetch(url, { method: 'GET', headers });
|
|
68
|
-
const text = await res.text();
|
|
69
|
-
let data = null;
|
|
70
|
-
try { data = text ? JSON.parse(text) : null; } catch { /* ignore */ }
|
|
71
|
-
if (!res.ok) throw new Error(`${path}: ${data?.message || data?.error || res.statusText}`);
|
|
72
|
-
return data;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
async function apiPost(path, body = {}) {
|
|
76
|
-
const { port, secret } = readDashboardConn();
|
|
77
|
-
const baseUrl = `http://127.0.0.1:${port}`;
|
|
78
|
-
const url = `${baseUrl}${path}`;
|
|
79
|
-
const headers = { 'content-type': 'application/json', accept: 'application/json' };
|
|
80
|
-
if (secret) headers.authorization = `Basic ${Buffer.from(`cline:${secret}`).toString('base64')}`;
|
|
81
|
-
const res = await fetch(url, { method: 'POST', headers, body: JSON.stringify(body) });
|
|
82
|
-
const text = await res.text();
|
|
83
|
-
let data = null;
|
|
84
|
-
try { data = text ? JSON.parse(text) : null; } catch { /* ignore */ }
|
|
85
|
-
if (!res.ok) throw new Error(`${path}: ${data?.message || data?.error || res.statusText}`);
|
|
86
|
-
return data;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
// ── Command runner ────────────────────────────────────────────────────────────
|
|
90
|
-
|
|
91
|
-
async function runHeadroomCommand(headroomArgs) {
|
|
92
|
-
const sub = headroomArgs[0];
|
|
93
|
-
const flags = headroomArgs.slice(1).filter((a) => a.startsWith('-'));
|
|
94
|
-
const positional = headroomArgs.slice(1).filter((a) => !a.startsWith('-'));
|
|
95
|
-
|
|
96
|
-
if (!sub || sub === '--help' || sub === '-h' || flags.includes('--help') || flags.includes('-h')) {
|
|
97
|
-
showHeadroomHelp();
|
|
98
|
-
return;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
if (sub === 'status') {
|
|
102
|
-
const s = await apiGet('/api/headroom/status');
|
|
103
|
-
console.log('');
|
|
104
|
-
console.log(chalk.bold(' Headroom status'));
|
|
105
|
-
console.log('');
|
|
106
|
-
console.log(` ${chalk.dim('installed:')} ${s.installed ? chalk.green('yes') : chalk.red('no')} ${s.version || ''}`);
|
|
107
|
-
console.log(` ${chalk.dim('proxy:')} ${s.proxyRunning ? chalk.green('running') : chalk.yellow('stopped')} ${s.proxyPort ? `@ ${s.proxyPort}` : ''} ${s.proxyPid ? `(PID ${s.proxyPid})` : ''}`);
|
|
108
|
-
console.log(` ${chalk.dim('wrapped:')} ${s.wrapped ? chalk.green('yes') : chalk.yellow('no')}`);
|
|
109
|
-
console.log(` ${chalk.dim('healthy:')} ${s.healthy === 'ok' ? chalk.green('ok') : s.healthy === 'warn' ? chalk.yellow('warn') : chalk.red('fail')}`);
|
|
110
|
-
if (s.messages && s.messages.length > 0) {
|
|
111
|
-
console.log('');
|
|
112
|
-
for (const m of s.messages) {
|
|
113
|
-
console.log(` ${m}`);
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
console.log('');
|
|
117
|
-
return;
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
if (sub === 'stats') {
|
|
121
|
-
const hours = parseInt(positional[0], 10) || 24;
|
|
122
|
-
const st = await apiGet(`/api/headroom/stats?hours=${hours}`);
|
|
123
|
-
console.log('');
|
|
124
|
-
console.log(chalk.bold(` Headroom stats (${hours}h)`));
|
|
125
|
-
console.log('');
|
|
126
|
-
if (st.error) {
|
|
127
|
-
console.log(chalk.yellow(` ${st.error}`));
|
|
128
|
-
} else {
|
|
129
|
-
console.log(` ${chalk.dim('tokens saved:')} ${(st.tokensSaved || 0).toLocaleString()}`);
|
|
130
|
-
console.log(` ${chalk.dim('compression:')} ${st.compressionRatio ? `${Math.round(st.compressionRatio * 100)}%` : '—'}`);
|
|
131
|
-
console.log(` ${chalk.dim('cache hits:')} ${st.cacheHits ?? '—'}`);
|
|
132
|
-
console.log(` ${chalk.dim('transforms:')} ${st.transforms ?? '—'}`);
|
|
133
|
-
}
|
|
134
|
-
console.log('');
|
|
135
|
-
return;
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
if (sub === 'install') {
|
|
139
|
-
const r = await apiPost('/api/headroom/install', { force: true });
|
|
140
|
-
if (r.installed) {
|
|
141
|
-
console.log(chalk.green(` ✓ Headroom installed via ${r.method}${r.version ? ` (${r.version})` : ''}`));
|
|
142
|
-
} else {
|
|
143
|
-
console.log(chalk.red(' ✗ Install failed. Try: pip install "headroom-ai[all]"'));
|
|
144
|
-
}
|
|
145
|
-
return;
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
if (sub === 'wrap') {
|
|
149
|
-
const port = parseInt(positional[0], 10) || 8787;
|
|
150
|
-
const r = await apiPost('/api/headroom/wrap', { port });
|
|
151
|
-
if (r.ok) {
|
|
152
|
-
console.log(chalk.green(` ✓ cline wrapped with Headroom on port ${port}`));
|
|
153
|
-
} else {
|
|
154
|
-
console.log(chalk.red(` ✗ Wrap failed: ${r.log || 'unknown error'}`));
|
|
155
|
-
}
|
|
156
|
-
return;
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
if (sub === 'unwrap') {
|
|
160
|
-
const r = await apiPost('/api/headroom/unwrap');
|
|
161
|
-
if (r.ok) {
|
|
162
|
-
console.log(chalk.green(' ✓ cline unwrapped from Headroom'));
|
|
163
|
-
} else {
|
|
164
|
-
console.log(chalk.red(' ✗ Unwrap failed'));
|
|
165
|
-
}
|
|
166
|
-
return;
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
if (sub === 'start') {
|
|
170
|
-
const port = parseInt(positional[0], 10) || 8787;
|
|
171
|
-
const r = await apiPost('/api/headroom/proxy/start', { port, host: '127.0.0.1' });
|
|
172
|
-
if (r.ok) {
|
|
173
|
-
console.log(chalk.green(` ✓ Proxy started on 127.0.0.1:${port} (PID ${r.pid})`));
|
|
174
|
-
} else {
|
|
175
|
-
console.log(chalk.red(' ✗ Proxy start failed'));
|
|
176
|
-
}
|
|
177
|
-
return;
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
if (sub === 'stop') {
|
|
181
|
-
const r = await apiPost('/api/headroom/proxy/stop');
|
|
182
|
-
if (r.ok) {
|
|
183
|
-
console.log(chalk.green(' ✓ Proxy stopped'));
|
|
184
|
-
} else {
|
|
185
|
-
console.log(chalk.red(' ✗ Proxy stop failed'));
|
|
186
|
-
}
|
|
187
|
-
return;
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
if (sub === 'doctor') {
|
|
191
|
-
// Run `headroom doctor` locally
|
|
192
|
-
const child = spawn('headroom', ['doctor'], { stdio: 'inherit' });
|
|
193
|
-
await new Promise((resolve) => child.on('close', resolve));
|
|
194
|
-
return;
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
console.error(chalk.red(` ✗ Unknown headroom subcommand: ${sub}`));
|
|
198
|
-
showHeadroomHelp();
|
|
199
|
-
process.exit(1);
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
export async function run(name, args, isHelpRequest) {
|
|
203
|
-
await runHeadroomCommand(args);
|
|
204
|
-
}
|