openzoo 0.38.5 → 0.38.7

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/openzoo.js CHANGED
@@ -25,9 +25,11 @@ usage:
25
25
  (claude, aider...) already pointed at the zoo
26
26
  npx openzoo grokbot point Grok Bot / the grok CLI at the zoo — GROK MODELS ONLY,
27
27
  paid per call by x402 instead of xAI first-party billing,
28
- then launch it with BYOK interception ON (impersonates
29
- api2.cursor.sh for that launch only no /etc/hosts, no sudo).
30
- --no-byok plain launch · --no-launch config only
28
+ then TAKE OVER the app's backend: pins api2.cursor.sh in
29
+ /etc/hosts, serves it locally on :443 with byok_enabled,
30
+ and launches Grok Bot with Node TLS override (sudo required;
31
+ ctrl-c restores /etc/hosts).
32
+ --no-takeover plain launch · --no-launch config only
31
33
  npx openzoo mcp stdio MCP server (tools: zoo_ask, zoo_bind, zoo_models, zoo_wallet, zoo_contexts)
32
34
  npx openzoo unblock restore the editor's own backend in the hosts file
33
35
  npx openzoo tunnel public-url-only mode (everything key-gated, no keyless localhost)
@@ -461,6 +461,22 @@ export function startCursorBackend({ port = 8443, models, log = () => {} } = {})
461
461
  await handleStreamChat(req, res, body, log);
462
462
  return;
463
463
  }
464
+ // FULL PASSTHROUGH MODE — observe, do not stub.
465
+ //
466
+ // Stubbing unknown methods with empty protobufs BREAKS Grok Bot: it never
467
+ // gets a sandbox from GrokBotService/EnsureSandBox, so it re-polls
468
+ // WatchSandBoxMigration forever and never reaches the chat stage. That is
469
+ // why an intercepted run showed 40 methods and ZERO StreamChat — absence
470
+ // of evidence created by our own stub, not proof that chat lives
471
+ // elsewhere.
472
+ //
473
+ // In passthrough the app runs NORMALLY against the real backend while
474
+ // every method, size and status is logged here — which is what actually
475
+ // reveals where inference goes.
476
+ if (process.env.OPENZOO_PASSTHRU === '1') {
477
+ await passthroughToRealAnthropic(req, res, body, host, full, log);
478
+ return;
479
+ }
464
480
  try {
465
481
  respond(req, res, method, models);
466
482
  const populated = ['GetPlanInfo', 'GetMe', 'GetDefaultModel', 'IsOnNewPricing'];
package/lib/grokbot.js CHANGED
@@ -147,6 +147,61 @@ export async function setupGrokBot(argv = []) {
147
147
  // model table, and the APP — the thing you actually look at — keeps talking
148
148
  // to Cursor's cloud, which is the whole problem it was meant to solve.
149
149
  // --no-byok drops back to plain launch.
150
+ // TAKEOVER IS THE DEFAULT. The --host-resolver-rules probe below is kept
151
+ // only for reference: it was PROVED not to intercept this app (flags present,
152
+ // backend listening, zero connections). Nothing routes without the hosts pin.
153
+ if (!argv.includes('--no-takeover')) {
154
+ // TAKEOVER — the Cursor recipe, because it is the only one that works.
155
+ //
156
+ // WHY NOT --host-resolver-rules: PROVED not to work here. The flag was
157
+ // verified present in the running process args for all four cursor hosts,
158
+ // the backend was listening, and ZERO connections arrived — the app kept
159
+ // talking to the real api2.cursor.sh (cert CN confirmed on its live
160
+ // sockets). That flag only steers CHROMIUM's stack; Grok Bot's Connect/gRPC
161
+ // transport runs in the Electron MAIN process on Node's DNS + Node's TLS,
162
+ // which ignore it. Same reason setup.js sets NODE_TLS_REJECT_UNAUTHORIZED
163
+ // for Cursor takeover.
164
+ //
165
+ // So: /etc/hosts (Node reads the OS resolver) + Node-side TLS override,
166
+ // and the app is spawned DIRECTLY rather than via `open`, because `open`
167
+ // does not pass an environment to the app.
168
+ const { blockBackend, unblockBackend, isBlocked } = await import('./hosts.js');
169
+ const { startCursorBackend } = await import('./cursorbackend.js');
170
+ const port = 443; // Node's DNS gives no port control — we must own :443
171
+
172
+ // --sniff: intercept but PASS EVERYTHING THROUGH to the real backend, so
173
+ // the app works normally and every method/size/status is logged. This is
174
+ // the only way to see the chat path: stubbing breaks EnsureSandBox and the
175
+ // app never reaches inference at all.
176
+ if (argv.includes('--sniff')) process.env.OPENZOO_PASSTHRU = '1';
177
+ else process.env.OPENZOO_BYOK = '1';
178
+ process.env.OPENZOO_FORCE_BLOCK = '1'; // our own guard refuses otherwise
179
+ console.error(argv.includes('--sniff')
180
+ ? 'openzoo: SNIFF — pinning api2.cursor.sh, proxying it to the REAL backend, logging everything.'
181
+ : 'openzoo: TAKEOVER — pinning api2.cursor.sh and serving it locally.');
182
+ console.error(' sudo will ask for your password (hosts file + :443).');
183
+ if (!isBlocked()) blockBackend();
184
+
185
+ startCursorBackend({ port, log: (m) => console.error(` backend: ${m}`) });
186
+
187
+ const restore = () => {
188
+ try { unblockBackend(); console.error('openzoo: /etc/hosts restored.'); } catch { /* best effort */ }
189
+ };
190
+ process.on('SIGINT', () => { restore(); process.exit(0); });
191
+ process.on('exit', restore);
192
+
193
+ console.error('openzoo: launching Grok Bot with Node TLS override...');
194
+ spawn(`${APP}/Contents/MacOS/Grok Bot`, ['--ignore-certificate-errors'], {
195
+ stdio: 'ignore',
196
+ detached: true,
197
+ env: { ...process.env, NODE_TLS_REJECT_UNAUTHORIZED: '0' },
198
+ }).unref();
199
+
200
+ console.error('openzoo: ctrl-c to stop and RESTORE /etc/hosts (do not just close the terminal).');
201
+ await new Promise(() => {});
202
+ return;
203
+ }
204
+
150
205
  if (!argv.includes('--no-byok')) {
151
206
  // BYOK PROBE — NO /etc/hosts, NO sudo.
152
207
  //
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "openzoo",
3
- "version": "0.38.5",
3
+ "version": "0.38.7",
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",