openzoo 0.38.1 → 0.38.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/bin/openzoo.js CHANGED
@@ -25,7 +25,9 @@ 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. --no-launch just writes the config.
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
29
31
  npx openzoo mcp stdio MCP server (tools: zoo_ask, zoo_bind, zoo_models, zoo_wallet, zoo_contexts)
30
32
  npx openzoo unblock restore the editor's own backend in the hosts file
31
33
  npx openzoo tunnel public-url-only mode (everything key-gated, no keyless localhost)
package/lib/cursorapi.js CHANGED
@@ -130,11 +130,40 @@ export function encodeIsOnNewPricing() {
130
130
  return new Buf().bool(1, false).bool(2, false).bool(3, false).bool(5, false).done();
131
131
  }
132
132
 
133
+ /**
134
+ * BYOK, forced on.
135
+ *
136
+ * Grok Bot (com.anysphere.sand) is Anysphere's app on the SAME aiserver.v1 API
137
+ * Cursor uses, and BYOK there is a SERVER-DELIVERED FLAG, not a local setting:
138
+ * the settings message carries `byok_enabled` at field 14 and `byok_disabled`
139
+ * at field 19 (read from the app bundle). The empty-protobuf default this
140
+ * server returns for unknown methods decodes byok_enabled = false, so BYOK
141
+ * stays hidden unless we say otherwise.
142
+ *
143
+ * UNVERIFIED, AND IT MATTERS: flipping this reveals the BYOK surface, but the
144
+ * ByokEntry message is only { enabled, models[] } — it has NO base_url field.
145
+ * So this may only let you supply an xAI key (still billing xAI) rather than
146
+ * redirect inference to the zoo. Run with OPENZOO_LOG_METHODS=1 and watch
147
+ * whether StreamChat starts arriving here before trusting it.
148
+ */
149
+ export function encodeByokConfig() {
150
+ return new Buf()
151
+ .bool(14, true) // byok_enabled
152
+ .bool(19, false) // byok_disabled (admin kill-switch)
153
+ .done();
154
+ }
155
+
133
156
  /**
134
157
  * The bare proto body for a method, or null to fall through to empty-ok.
135
158
  * Only the methods that gate entitlement or the model list are populated.
136
159
  */
137
160
  export function encodeForMethod(method, models) {
161
+ // Any settings/config-shaped method carries the feature flags; answering the
162
+ // wrong one is harmless (extra fields are ignored by proto), answering none
163
+ // leaves BYOK off.
164
+ if (process.env.OPENZOO_BYOK === '1' && /Config|Settings|FeatureFlags/i.test(method)) {
165
+ return encodeByokConfig();
166
+ }
138
167
  switch (method) {
139
168
  case 'AvailableModels': return encodeAvailableModels(models);
140
169
  case 'GetPlanInfo': return encodeGetPlanInfo();
package/lib/grokbot.js CHANGED
@@ -143,6 +143,41 @@ export async function setupGrokBot(argv = []) {
143
143
 
144
144
  // 3. launch the app if it exists, else the CLI
145
145
  if (existsSync(APP)) {
146
+ // BYOK IS THE DEFAULT. Without it this command only rewrites the CLI's
147
+ // model table, and the APP — the thing you actually look at — keeps talking
148
+ // to Cursor's cloud, which is the whole problem it was meant to solve.
149
+ // --no-byok drops back to plain launch.
150
+ if (!argv.includes('--no-byok')) {
151
+ // BYOK PROBE — NO /etc/hosts, NO sudo.
152
+ //
153
+ // Grok Bot asks aiserver.v1 whether BYOK is allowed (`byok_enabled`,
154
+ // field 14). Answering that ourselves needs us to BE api2.cursor.sh, and
155
+ // the obvious way — pinning it in /etc/hosts — is exactly what took the
156
+ // app offline for an hour with "Reconnecting to your computer", because
157
+ // the pin is machine-wide and outlives the app.
158
+ //
159
+ // Chromium's own --host-resolver-rules does the same redirect scoped to
160
+ // THIS LAUNCH ONLY. Quit and reopen normally and it is gone; nothing
161
+ // persists, nothing else on the machine is affected, no password needed.
162
+ const { startCursorBackend } = await import('./cursorbackend.js');
163
+ const port = 8443;
164
+ process.env.OPENZOO_BYOK = '1';
165
+ startCursorBackend({ port, log: (m) => console.error(` backend: ${m}`) });
166
+ console.error('openzoo: BYOK probe — impersonating api2.cursor.sh on :' + port);
167
+ console.error(' scoped to this launch only (no /etc/hosts, no sudo)');
168
+ console.error(' WATCH: if StreamChat starts arriving at the proxy, inference moved.');
169
+ console.error(' If only a BYOK settings pane appears, it is xAI-key-only and buys nothing.');
170
+ spawn('open', ['-a', APP, '--args',
171
+ '--ignore-certificate-errors',
172
+ `--host-resolver-rules=MAP api2.cursor.sh 127.0.0.1:${port}`,
173
+ ], { stdio: 'ignore', detached: true }).unref();
174
+ // keep this process alive so the backend keeps answering
175
+ console.error('openzoo: leave this running while Grok Bot is open. ctrl-c stops the');
176
+ console.error(' backend; the app then reconnects to xAI normally on next launch.');
177
+ console.error(' (skip all of this with --no-byok)');
178
+ await new Promise(() => {});
179
+ return;
180
+ }
146
181
  console.error('openzoo: launching Grok Bot...');
147
182
  spawn('open', ['-a', APP], { stdio: 'ignore', detached: true }).unref();
148
183
  } else {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "openzoo",
3
- "version": "0.38.1",
3
+ "version": "0.38.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",