openzoo 0.33.2 → 0.33.3
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/lib/launch.js +34 -2
- package/lib/proxy.js +2 -0
- package/package.json +1 -1
package/lib/launch.js
CHANGED
|
@@ -84,6 +84,38 @@ export async function launchClaude(argv) {
|
|
|
84
84
|
if (terminal) {
|
|
85
85
|
const cli = resolveClaudeCli();
|
|
86
86
|
if (!cli) { console.error('openzoo: `claude` CLI not found on PATH — install Claude Code, or drop --terminal for the desktop app'); process.exit(1); }
|
|
87
|
+
// ALWAYS-ON HUD via Claude Code's NATIVE status line (the title bar is owned
|
|
88
|
+
// by Claude Code and gets overwritten, so OSC there is useless). We write a
|
|
89
|
+
// tiny status script that reads the proxy's /v1/info, and merge a statusLine
|
|
90
|
+
// into ~/.claude/settings.json — PRESERVING any existing one (restored on
|
|
91
|
+
// exit). Shows live spend + call count at the bottom of every turn.
|
|
92
|
+
let restoreStatus = null;
|
|
93
|
+
try {
|
|
94
|
+
const scriptPath = path.join(os.homedir(), '.openzoo', 'statusline.sh');
|
|
95
|
+
fs.mkdirSync(path.dirname(scriptPath), { recursive: true });
|
|
96
|
+
fs.writeFileSync(scriptPath,
|
|
97
|
+
'#!/bin/sh\n'
|
|
98
|
+
+ `curl -s --max-time 1 ${base}/info 2>/dev/null | `
|
|
99
|
+
+ 'awk \'{ if (match($0,/"spendUsd":[0-9.eE-]+/)) { s=substr($0,RSTART+11,RLENGTH-11) } '
|
|
100
|
+
+ 'if (match($0,/"paidCalls":[0-9]+/)) { c=substr($0,RSTART+12,RLENGTH-12) } } '
|
|
101
|
+
+ 'END { printf "\\033[38;5;208m●\\033[0m openzoo $%.4f %s call%s · x402", s+0, c+0, (c==1?"":"s") }\'\n');
|
|
102
|
+
fs.chmodSync(scriptPath, 0o755);
|
|
103
|
+
const settingsPath = path.join(os.homedir(), '.claude', 'settings.json');
|
|
104
|
+
let settings = {};
|
|
105
|
+
try { settings = JSON.parse(fs.readFileSync(settingsPath, 'utf8')) || {}; } catch { settings = {}; }
|
|
106
|
+
const prev = settings.statusLine;
|
|
107
|
+
settings.statusLine = { type: 'command', command: `sh ${scriptPath}` };
|
|
108
|
+
fs.mkdirSync(path.dirname(settingsPath), { recursive: true });
|
|
109
|
+
fs.writeFileSync(settingsPath, `${JSON.stringify(settings, null, 2)}\n`);
|
|
110
|
+
restoreStatus = () => {
|
|
111
|
+
try {
|
|
112
|
+
const cur = JSON.parse(fs.readFileSync(settingsPath, 'utf8'));
|
|
113
|
+
if (prev === undefined) delete cur.statusLine; else cur.statusLine = prev;
|
|
114
|
+
fs.writeFileSync(settingsPath, `${JSON.stringify(cur, null, 2)}\n`);
|
|
115
|
+
} catch { /* leave as-is */ }
|
|
116
|
+
};
|
|
117
|
+
} catch { /* HUD is best-effort */ }
|
|
118
|
+
|
|
87
119
|
// A CLEAR banner BEFORE Claude Code takes the screen, so it is obvious this
|
|
88
120
|
// session routes through the zoo (the terminal title then shows live spend).
|
|
89
121
|
let wallet = '';
|
|
@@ -93,11 +125,11 @@ export async function launchClaude(argv) {
|
|
|
93
125
|
console.error(` endpoint : ${base}`);
|
|
94
126
|
console.error(' auth : gateway token (ANTHROPIC_API_KEY unset — no api.anthropic.com billing)');
|
|
95
127
|
if (wallet) console.error(` wallet : ${wallet}`);
|
|
96
|
-
console.error(' spend :
|
|
128
|
+
console.error(' spend : live in the status line below (bottom of screen); receipts in ~/.openzoo/proxy.log');
|
|
97
129
|
console.error(' every turn pays x402.');
|
|
98
130
|
console.error('');
|
|
99
131
|
const child = spawn(cli, rest, { stdio: 'inherit', env });
|
|
100
|
-
child.on('exit', (c) => process.exit(c ?? 0));
|
|
132
|
+
child.on('exit', (c) => { try { restoreStatus?.(); } catch { /* ignore */ } process.exit(c ?? 0); });
|
|
101
133
|
child.on('error', (e) => { console.error(`openzoo: could not launch claude: ${e.message}`); process.exit(1); });
|
|
102
134
|
return;
|
|
103
135
|
}
|
package/lib/proxy.js
CHANGED
|
@@ -373,6 +373,8 @@ export async function startProxy({ silent = false, requireToken = null, sessionM
|
|
|
373
373
|
reachedVia: viaTunnel ? 'public tunnel' : 'localhost',
|
|
374
374
|
publicTunnel: tunnelGate?.publicUrl ? `${tunnelGate.publicUrl}/v1` : null,
|
|
375
375
|
servedRequests,
|
|
376
|
+
spendUsd: sessionSpent,
|
|
377
|
+
paidCalls,
|
|
376
378
|
mcp: `${self.replace(/\/v1$/, '')}/mcp`,
|
|
377
379
|
upstream: config.apiBase,
|
|
378
380
|
payment: 'x402 per request from the operator\'s local burner wallet — no API key, no account',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "openzoo",
|
|
3
|
-
"version": "0.33.
|
|
3
|
+
"version": "0.33.3",
|
|
4
4
|
"description": "Local x402-paying proxy + MCP server for openzoo.fun — point any OpenAI-compatible harness (Cursor, Claude Code, aider, SDKs) at localhost and it pays per call from a local burner wallet. Solana and Base rails live; Robinhood experimental.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|