openzoo 0.50.37 → 0.50.39
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/bin/claude-zoo.js +100 -0
- package/bin/openzoo.js +8 -0
- package/lib/cursorbackend.js +464 -99
- package/lib/grokbotAccount.js +134 -8
- package/lib/grokbotUploads.js +168 -0
- package/lib/grokbotweb-shim.js +766 -0
- package/lib/grokbotweb.js +933 -0
- package/lib/grokcli.js +47 -22
- package/lib/ozSpendChip.js +482 -0
- package/lib/pay.js +17 -24
- package/lib/proxy.js +33 -11
- package/lib/spendProof.js +307 -0
- package/lib/x402.js +3 -1
- package/package.json +1 -1
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* `claude` — the openzoo-backed Claude Code command.
|
|
4
|
+
*
|
|
5
|
+
* Replaces the raw occ launcher. Same binary, but every request goes through
|
|
6
|
+
* the local openzoo proxy on :8402 (x402 per-call payment, no Anthropic
|
|
7
|
+
* subscription, no login):
|
|
8
|
+
*
|
|
9
|
+
* - starts the proxy if it is not already listening
|
|
10
|
+
* - applies claudeZooEnv(): ANTHROPIC_BASE_URL=localhost:PORT/v1,
|
|
11
|
+
* AUTH_TOKEN=sk-openzoo, ANTHROPIC_API_KEY deleted, compaction disabled
|
|
12
|
+
* (the proxy binds the prefix), 1M-token ceiling restored
|
|
13
|
+
* - execs occ (open-claude-code) with your original argv
|
|
14
|
+
*
|
|
15
|
+
* The old direct-to-Anthropic-capable launcher is preserved as
|
|
16
|
+
* `claude-code-cli` (same directory, symlinked to occ).
|
|
17
|
+
*/
|
|
18
|
+
import { spawn } from 'node:child_process';
|
|
19
|
+
import { existsSync, readdirSync as fsReaddir } from 'node:fs';
|
|
20
|
+
import { homedir, platform } from 'node:os';
|
|
21
|
+
import { dirname, join, sep } from 'node:path';
|
|
22
|
+
import { fileURLToPath } from 'node:url';
|
|
23
|
+
|
|
24
|
+
const here = dirname(fileURLToPath(import.meta.url));
|
|
25
|
+
const shimRoot = dirname(here);
|
|
26
|
+
|
|
27
|
+
// occ lives beside us (nvm bin/occ) or, if this wrapper is copied elsewhere,
|
|
28
|
+
// we fall back to searching the nvm tree we were installed from.
|
|
29
|
+
function findOcc() {
|
|
30
|
+
const candidate = join(here, 'occ');
|
|
31
|
+
if (existsSync(candidate)) return candidate;
|
|
32
|
+
{
|
|
33
|
+
const versions = join(homedir(), '.nvm', 'versions', 'node');
|
|
34
|
+
try {
|
|
35
|
+
for (const v of fsReaddir(versions).sort().reverse()) {
|
|
36
|
+
const p = join(versions, v, 'bin', 'occ');
|
|
37
|
+
if (existsSync(p)) return p;
|
|
38
|
+
}
|
|
39
|
+
} catch { /* fall through */ }
|
|
40
|
+
}
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const occ = findOcc();
|
|
45
|
+
if (!occ) {
|
|
46
|
+
console.error('claude: cannot find occ (open-claude-code) next to this wrapper.');
|
|
47
|
+
process.exit(1);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const PROXY_PORT = Number(process.env.OPENZOO_PROXY_PORT || 8402);
|
|
51
|
+
const PROXY_URL = `http://localhost:${PROXY_PORT}/v1`;
|
|
52
|
+
|
|
53
|
+
async function proxyUp() {
|
|
54
|
+
try {
|
|
55
|
+
const r = await fetch(`http://localhost:${PROXY_PORT}/v1/info`, { signal: AbortSignal.timeout(1500) });
|
|
56
|
+
return r.ok;
|
|
57
|
+
} catch { return false; }
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
async function ensureProxy() {
|
|
61
|
+
if (await proxyUp()) return PROXY_URL;
|
|
62
|
+
console.error(`claude: starting openzoo proxy on :${PROXY_PORT} ...`);
|
|
63
|
+
const entry = join(shimRoot, 'bin', 'openzoo.js');
|
|
64
|
+
const child = spawn(process.execPath, [entry, 'proxy'], {
|
|
65
|
+
detached: true,
|
|
66
|
+
stdio: 'ignore',
|
|
67
|
+
env: process.env,
|
|
68
|
+
});
|
|
69
|
+
child.unref();
|
|
70
|
+
for (let i = 0; i < 60; i++) {
|
|
71
|
+
await new Promise((r) => setTimeout(r, 500));
|
|
72
|
+
if (await proxyUp()) return PROXY_URL;
|
|
73
|
+
}
|
|
74
|
+
console.error(`claude: proxy did not come up on :${PROXY_PORT} — log: ~/.openzoo/proxy.log`);
|
|
75
|
+
process.exit(1);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// Mirror of lib/launch.js claudeZooEnv, inlined so this wrapper has zero
|
|
79
|
+
// imports from the shim (it must run even if the shim tree moves).
|
|
80
|
+
function zooEnv(base) {
|
|
81
|
+
const env = { ...base };
|
|
82
|
+
delete env.ANTHROPIC_API_KEY; // would win over BASE_URL and bill Anthropic
|
|
83
|
+
env.ANTHROPIC_BASE_URL = PROXY_URL;
|
|
84
|
+
env.ANTHROPIC_AUTH_TOKEN = base.ANTHROPIC_AUTH_TOKEN || 'sk-openzoo';
|
|
85
|
+
env.DISABLE_COMPACT = base.DISABLE_COMPACT || '1';
|
|
86
|
+
env.DISABLE_AUTO_COMPACT = base.DISABLE_AUTO_COMPACT || '1';
|
|
87
|
+
env.CLAUDE_CODE_MAX_CONTEXT_TOKENS = base.CLAUDE_CODE_MAX_CONTEXT_TOKENS || '1000000';
|
|
88
|
+
env.CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC = base.CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC || '1';
|
|
89
|
+
return env;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
const base = await ensureProxy();
|
|
93
|
+
const child = spawn(occ, process.argv.slice(2), {
|
|
94
|
+
stdio: 'inherit',
|
|
95
|
+
env: zooEnv(process.env),
|
|
96
|
+
});
|
|
97
|
+
child.on('exit', (code, signal) => {
|
|
98
|
+
if (signal) process.kill(process.pid, signal);
|
|
99
|
+
process.exit(code ?? 0);
|
|
100
|
+
});
|
package/bin/openzoo.js
CHANGED
|
@@ -97,6 +97,11 @@ usage:
|
|
|
97
97
|
that env — bot bounces it so send works. Already-
|
|
98
98
|
hijacked sessions are left alone.
|
|
99
99
|
--quit force bounce · --no-quit never bounce
|
|
100
|
+
--web serve the renderer in a browser instead of
|
|
101
|
+
launching the .app (http://127.0.0.1:4174)
|
|
102
|
+
npx openzoo web Grok Bot renderer in the browser. Same hijack as
|
|
103
|
+
bot (proxy :8402 + aiserver :8443) but no Electron.
|
|
104
|
+
--no-open skip launching a tab
|
|
100
105
|
npx openzoo cursor [dir] start proxy+tunnel, write MCP config + every model
|
|
101
106
|
into the picker, and LAUNCH Cursor on [dir]
|
|
102
107
|
(defaults to the current directory; ~ works;
|
|
@@ -175,6 +180,9 @@ async function main() {
|
|
|
175
180
|
case 'bot':
|
|
176
181
|
await (await import('../lib/grokcli.js')).runBot(process.argv.slice(3));
|
|
177
182
|
break;
|
|
183
|
+
case 'web':
|
|
184
|
+
await (await import('../lib/grokbotweb.js')).runGrokBotWeb(process.argv.slice(3));
|
|
185
|
+
break;
|
|
178
186
|
case 'editor':
|
|
179
187
|
case 'cursor':
|
|
180
188
|
case 'vscode':
|