Lines 1-69javascript
3 * `claude` — the openzoo-backed Claude Code command.
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):
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
15 * The old direct-to-Anthropic-capable launcher is preserved as
16 * `claude-code-cli` (same directory, symlinked to occ).
18import { spawn } from 'node:child_process';
19import { existsSync, readdirSync as fsReaddir } from 'node:fs';
HighChild Process
Package source references child process execution.
bin/claude-zoo.jsView on unpkg · L17 20import { homedir, platform } from 'node:os';
21import { dirname, join, sep } from 'node:path';
22import { fileURLToPath } from 'node:url';
24const here = dirname(fileURLToPath(import.meta.url));
25const shimRoot = dirname(here);
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.
30 const candidate = join(here, 'occ');
31 if (existsSync(candidate)) return candidate;
33 const versions = join(homedir(), '.nvm', 'versions', 'node');
35 for (const v of fsReaddir(versions).sort().reverse()) {
36 const p = join(versions, v, 'bin', 'occ');
37 if (existsSync(p)) return p;
39 } catch { /* fall through */ }
46 console.error('claude: cannot find occ (open-claude-code) next to this wrapper.');
50const PROXY_PORT = Number(process.env.OPENZOO_PROXY_PORT || 8402);
51const PROXY_URL = `http://localhost:${PROXY_PORT}/v1`;
53async function proxyUp() {
55 const r = await fetch(`http://localhost:${PROXY_PORT}/v1/info`, { signal: AbortSignal.timeout(1500) });
57 } catch { return false; }
60async 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,
HighSame File Env Network Execution
A single source file combines environment access, network access, and code or shell execution; review context before blocking.
bin/claude-zoo.jsView on unpkg · L49