openzoo 0.15.0 → 0.16.0

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
@@ -134,7 +134,7 @@ async function main() {
134
134
  method: 'POST',
135
135
  headers,
136
136
  body: JSON.stringify({
137
- model: (mi !== -1 && process.argv[mi + 1]) || process.env.OPENZOO_DEFAULT_MODEL || 'deepseek/deepseek-v4-pro-0813',
137
+ model: (mi !== -1 && process.argv[mi + 1]) || process.env.OPENZOO_DEFAULT_MODEL || 'anthropic/claude-opus-5',
138
138
  messages: [{ role: 'user', content: question }],
139
139
  max_tokens: Number(process.env.OPENZOO_ASK_MAX_TOKENS || 1024),
140
140
  }),
package/lib/mcp.js CHANGED
@@ -9,7 +9,11 @@ import { askWithContext, contextCacheDisabled, BIND_MIN_CHARS } from './hrr.js';
9
9
  import { listContexts } from './contexts.js';
10
10
 
11
11
  const pkg = JSON.parse(readFileSync(new URL('../package.json', import.meta.url), 'utf8'));
12
- const DEFAULT_MODEL = process.env.OPENZOO_DEMO_MODEL || 'nvidia/nemotron-3.5-lightning';
12
+ // The model zoo_ask uses when the caller does not name one. Opus 5 by default:
13
+ // an agent calling zoo_ask is usually doing real reasoning over a bound corpus,
14
+ // and a tiny model there produces answers that look cheap because they are.
15
+ // OPENZOO_DEFAULT_MODEL (or the tool's own `model` arg) overrides.
16
+ const DEFAULT_MODEL = process.env.OPENZOO_DEFAULT_MODEL || process.env.OPENZOO_DEMO_MODEL || 'anthropic/claude-opus-5';
13
17
 
14
18
  function text(obj) {
15
19
  return { content: [{ type: 'text', text: typeof obj === 'string' ? obj : JSON.stringify(obj, null, 2) }] };
@@ -35,6 +39,23 @@ export function buildMcpServer() {
35
39
  '',
36
40
  'Never search the machine for API keys or endpoints — there are none to find. zoo_wallet shows funding',
37
41
  'state, zoo_models lists what is served with live pricing.',
42
+ '',
43
+ // ROUTING, STATED UNCONDITIONALLY. An agent whose OWN inference is not
44
+ // routed through the proxy never receives lib/brief.js, so it answers
45
+ // "I have no visibility into the routing layer" while this very server
46
+ // is attached to it. These facts hold whether or not its own tokens
47
+ // flow through the zoo, so they belong here.
48
+ 'ROUTING — you can state these as fact:',
49
+ ` local proxy : ${config.apiBase ? `http://localhost:${config.port}/v1` : 'http://localhost:8402/v1'} (api key: any string; x402 pays, not keys)`,
50
+ ` upstream : ${config.apiBase}`,
51
+ ` default model for zoo_ask : ${DEFAULT_MODEL}`,
52
+ ' a cloud-run harness cannot reach localhost — it needs the public tunnel URL the',
53
+ ' proxy prints at startup. Call zoo_models for the live catalog and real pricing.',
54
+ '',
55
+ 'CONTEXT, PRECISELY: openzoo does NOT enlarge your own attention window. It binds a corpus',
56
+ 'server-side and retrieves what is relevant, so a body far past any model\'s window can be',
57
+ 'queried — that is retrieval, not a bigger window. Do not claim lossless compression and do',
58
+ 'not claim a 128M attention window; the honest line is "bind 128M, the model reads what matters".',
38
59
  ].join('\n'),
39
60
  });
40
61
 
@@ -103,8 +124,44 @@ export function buildMcpServer() {
103
124
  ...(reuse ? { context: reuse } : {}),
104
125
  });
105
126
  } catch (err) {
106
- if (err instanceof UnderfundedError || err instanceof QuoteTooHighError) {
107
- return { ...text(err.message), isError: true };
127
+ // PAYMENT FAILURES MUST REACH THE CHAT, ACTIONABLY. A bare throw shows an
128
+ // agent "tool failed" with no reason and no fix, so it retries blindly or
129
+ // gives up; the human never learns the wallet is empty. Every failure
130
+ // returns WHY it failed and exactly how to fund, with live addresses.
131
+ const fail = async (why, hint) => {
132
+ let balances = null; let addr = null; let evm = null;
133
+ try {
134
+ addr = client.address;
135
+ evm = client.evmAddress;
136
+ const bals = await Promise.all(
137
+ FUNDING_ASSETS.map((a) => tokenBalance(client.connection, client.keypair.publicKey, a.mint)),
138
+ );
139
+ balances = Object.fromEntries(FUNDING_ASSETS.map((a, i) => [a.symbol, bals[i].ui ?? 0]));
140
+ } catch { /* advisory — never let the diagnostic itself fail */ }
141
+ const rails = await liveRails().catch(() => null);
142
+ return {
143
+ ...text({
144
+ error: why,
145
+ x402: 'this call was NOT paid and NOT served',
146
+ detail: hint,
147
+ wallet: { solana: addr, evm },
148
+ balances,
149
+ fundWith: rails ? railFundingHint(rails.live) : 'USDC or TOKEN on Solana',
150
+ solanaMints: Object.fromEntries(FUNDING_ASSETS.map((a) => [a.symbol, a.mint])),
151
+ tellTheUser: 'Report this verbatim — the operator must fund the wallet above; you cannot fix it yourself, and retrying will fail identically until they do.',
152
+ }),
153
+ isError: true,
154
+ };
155
+ };
156
+ if (err instanceof UnderfundedError) {
157
+ return fail('x402 payment failed: wallet underfunded', err.message);
158
+ }
159
+ if (err instanceof QuoteTooHighError) {
160
+ return fail('x402 payment refused: quote above the local per-call cap', `${err.message} (raise OPENZOO_MAX_USD_PER_CALL, or ask a cheaper model)`);
161
+ }
162
+ // Anything else that mentions payment/402 still deserves the funding card.
163
+ if (/402|payment|underfunded|insufficient/i.test(err?.message || '')) {
164
+ return fail('x402 payment failed', err.message);
108
165
  }
109
166
  throw err;
110
167
  }
package/lib/setup.js CHANGED
@@ -147,6 +147,22 @@ export async function setupEditor(which, target) {
147
147
  console.log('');
148
148
  console.log(`mcp: ${mcpFile} (openzoo: zoo_bind, zoo_ask, zoo_models, zoo_wallet, zoo_contexts)`);
149
149
  console.log(`local: ${base} api_key sk-openzoo`);
150
+ console.log('');
151
+ // THE ONE THING THE EDITOR WILL NOT INHERIT. Cursor's BUILT-IN models
152
+ // (Opus 5, GPT, Composer) go to Cursor's own backend and ignore
153
+ // ANTHROPIC_BASE_URL — Cursor has no Anthropic base-URL override, only an
154
+ // OpenAI one. So routing a Claude model through the zoo means adding it as a
155
+ // CUSTOM model under the OpenAI override, where the proxy serves it and maps
156
+ // the name. Env alone cannot do this; say so plainly instead of implying the
157
+ // launch handled everything.
158
+ console.log('one manual step — Cursor Settings → Models (built-ins bypass the zoo):');
159
+ console.log(` 1. Override OpenAI Base URL -> ${base}`);
160
+ console.log(' 2. OpenAI API Key -> sk-openzoo (any value; x402 pays)');
161
+ console.log(' 3. Add model -> anthropic/claude-opus-5');
162
+ console.log(' (or deepseek/deepseek-v4-pro-0813 — ~34x cheaper output)');
163
+ console.log(' 4. Toggle OFF the built-in models (Opus 5 / GPT / Composer) — those');
164
+ console.log(' resolve against Cursor\'s backend and never touch the zoo.');
165
+ console.log(' The embedded terminal + Claude Code extension DO inherit the env above.');
150
166
  if (publicUrl) {
151
167
  console.log(`tunnel: ${publicUrl}/v1 api_key ${tunnelKey}`);
152
168
  console.log(' (use the tunnel for any cloud-run harness — it cannot reach localhost)');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "openzoo",
3
- "version": "0.15.0",
3
+ "version": "0.16.0",
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",