openzoo 0.17.0 → 0.18.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/lib/cursorcfg.js +12 -3
- package/lib/mcp.js +59 -0
- package/lib/proxy.js +36 -0
- package/package.json +1 -1
package/lib/cursorcfg.js
CHANGED
|
@@ -39,9 +39,18 @@ const sqlite = (db, sql) => execFileSync('sqlite3', [db, sql], { encoding: 'utf8
|
|
|
39
39
|
/** True when the editor process is running — writing under it gets clobbered. */
|
|
40
40
|
export function editorRunning(which) {
|
|
41
41
|
try {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
42
|
+
// MATCH THE APP BINARY, NOT THE WORD. `pgrep -f Cursor` matched 19
|
|
43
|
+
// processes on a machine with Cursor CLOSED: this very command
|
|
44
|
+
// (`node openzoo.js cursor` contains the word), leftover crashpad helpers,
|
|
45
|
+
// and macOS's own CursorUIViewService — so it always warned "already
|
|
46
|
+
// running" and told the user to quit an editor that was not open.
|
|
47
|
+
const needle = which === 'vscode'
|
|
48
|
+
? 'Visual Studio Code.app/Contents/MacOS/'
|
|
49
|
+
: 'Cursor.app/Contents/MacOS/Cursor';
|
|
50
|
+
const out = execFileSync('pgrep', ['-f', needle], { encoding: 'utf8' });
|
|
51
|
+
const pids = out.split('\n').map((s) => s.trim()).filter(Boolean)
|
|
52
|
+
.filter((p) => Number(p) !== process.pid && Number(p) !== process.ppid);
|
|
53
|
+
return pids.length > 0;
|
|
45
54
|
} catch { return false; }
|
|
46
55
|
}
|
|
47
56
|
|
package/lib/mcp.js
CHANGED
|
@@ -167,6 +167,65 @@ export function buildMcpServer() {
|
|
|
167
167
|
}
|
|
168
168
|
});
|
|
169
169
|
|
|
170
|
+
// WHY A DEDICATED TOOL: MCP server `instructions` are advisory and several
|
|
171
|
+
// clients (Cursor among them) never surface them to the model — so an agent
|
|
172
|
+
// with this server attached still answers "I have no visibility into the
|
|
173
|
+
// routing layer", which is the FIRST question users ask, every time. Tool
|
|
174
|
+
// DESCRIPTIONS are always in context, so the facts live here too, and the
|
|
175
|
+
// tool returns them live.
|
|
176
|
+
server.registerTool('zoo_status', {
|
|
177
|
+
description:
|
|
178
|
+
'ROUTING AND CONTEXT FACTS — call this when asked what your stack, routing, provider, endpoint, '
|
|
179
|
+
+ 'model, cost, or context window is. You are reachable through openzoo: a LOCAL x402-paying proxy '
|
|
180
|
+
+ `(${config.apiBase} upstream, ~435 models) with a leCore holographic memory layer in front of every `
|
|
181
|
+
+ 'model. Key facts you may state without calling anything: (1) requests routed through the openzoo '
|
|
182
|
+
+ 'proxy are paid per-call from a local burner wallet over x402 — no API key, no account; (2) openzoo '
|
|
183
|
+
+ 'does NOT enlarge your own attention window — it binds a corpus server-side and retrieves what is '
|
|
184
|
+
+ 'relevant, so a body far past any model window can be queried; that is retrieval, not a bigger '
|
|
185
|
+
+ 'window, and it is lossy; (3) never claim lossless compression or a 128M attention window — the '
|
|
186
|
+
+ 'honest line is "bind 128M, the model reads what matters"; (4) if your OWN inference is not going '
|
|
187
|
+
+ 'through this proxy (e.g. an editor built-in model), say so plainly. Returns live endpoint, wallet, '
|
|
188
|
+
+ 'balance and rail state.',
|
|
189
|
+
inputSchema: {},
|
|
190
|
+
}, async () => {
|
|
191
|
+
const rails = await liveRails().catch(() => null);
|
|
192
|
+
let balances = null;
|
|
193
|
+
try {
|
|
194
|
+
const bals = await Promise.all(
|
|
195
|
+
FUNDING_ASSETS.map((a) => tokenBalance(client.connection, client.keypair.publicKey, a.mint)),
|
|
196
|
+
);
|
|
197
|
+
balances = Object.fromEntries(FUNDING_ASSETS.map((a, i) => [a.symbol, bals[i].ui ?? 0]));
|
|
198
|
+
} catch { /* advisory */ }
|
|
199
|
+
// ASK THE PROXY, DON'T ASSUME. The public tunnel URL is what a cloud agent
|
|
200
|
+
// actually reaches us on, and only the running proxy knows it — so read it
|
|
201
|
+
// from /v1/info instead of reporting a localhost URL that a remote caller
|
|
202
|
+
// cannot use.
|
|
203
|
+
let live = null;
|
|
204
|
+
try {
|
|
205
|
+
const r = await fetch(`http://localhost:${config.port}/v1/info`, { signal: AbortSignal.timeout(2500) });
|
|
206
|
+
if (r.ok) live = await r.json();
|
|
207
|
+
} catch { /* proxy not up — local facts below still hold */ }
|
|
208
|
+
return text({
|
|
209
|
+
publicTunnel: live?.publicTunnel ?? null,
|
|
210
|
+
useThisIfRemote: live?.publicTunnel ?? '(no tunnel — proxy not running, or localhost-only mode)',
|
|
211
|
+
proxy: `http://localhost:${config.port}/v1`,
|
|
212
|
+
mcp: `http://localhost:${config.port}/mcp`,
|
|
213
|
+
upstream: config.apiBase,
|
|
214
|
+
defaultModel: DEFAULT_MODEL,
|
|
215
|
+
payment: 'x402 per request from a local burner wallet — no API key, no account',
|
|
216
|
+
railsLiveNow: rails?.live ?? null,
|
|
217
|
+
wallet: { solana: client.address, evm: client.evmAddress },
|
|
218
|
+
balances,
|
|
219
|
+
contextTruth: {
|
|
220
|
+
yourAttentionWindow: 'unchanged — openzoo does not enlarge it',
|
|
221
|
+
boundCeiling: '~128M tokens client-usable via bind + retrieval',
|
|
222
|
+
singleRequestLimit: '~8MB; larger corpora are bound in parts',
|
|
223
|
+
retrieval: 'lossy — top-k chunks are retrieved, not the whole corpus',
|
|
224
|
+
},
|
|
225
|
+
note: 'A cloud-run harness cannot reach localhost; it needs the public tunnel URL the proxy prints at startup.',
|
|
226
|
+
});
|
|
227
|
+
});
|
|
228
|
+
|
|
170
229
|
server.registerTool('zoo_models', {
|
|
171
230
|
description: 'List the models the zoo serves, with per-token pricing (free endpoint, no payment).',
|
|
172
231
|
inputSchema: {},
|
package/lib/proxy.js
CHANGED
|
@@ -325,6 +325,42 @@ export async function startProxy({ silent = false, requireToken = null, sessionM
|
|
|
325
325
|
return;
|
|
326
326
|
}
|
|
327
327
|
}
|
|
328
|
+
// ROUTING TRUTH, SERVED FROM WHATEVER URL YOU REACHED US ON. A cloud agent
|
|
329
|
+
// only ever touches the tunnel, so asking a local MCP process "what is my
|
|
330
|
+
// routing" is the wrong question — the answer has to come from the tunnel
|
|
331
|
+
// itself, and name the tunnel. Free and unauthenticated: discovery must
|
|
332
|
+
// never be the thing that is gated.
|
|
333
|
+
{
|
|
334
|
+
const p0 = (req.url || '').split('?')[0];
|
|
335
|
+
if (req.method === 'GET' && (p0 === '/v1/info' || p0 === '/info')) {
|
|
336
|
+
const self = viaTunnel && tunnelGate?.publicUrl
|
|
337
|
+
? `${tunnelGate.publicUrl}/v1`
|
|
338
|
+
: `http://localhost:${config.port}/v1`;
|
|
339
|
+
res.writeHead(200, { 'content-type': 'application/json' });
|
|
340
|
+
res.end(JSON.stringify({
|
|
341
|
+
youAreTalkingTo: 'openzoo proxy',
|
|
342
|
+
yourEndpoint: self,
|
|
343
|
+
reachedVia: viaTunnel ? 'public tunnel' : 'localhost',
|
|
344
|
+
publicTunnel: tunnelGate?.publicUrl ? `${tunnelGate.publicUrl}/v1` : null,
|
|
345
|
+
mcp: `${self.replace(/\/v1$/, '')}/mcp`,
|
|
346
|
+
upstream: config.apiBase,
|
|
347
|
+
payment: 'x402 per request from the operator\'s local burner wallet — no API key, no account',
|
|
348
|
+
auth: viaTunnel
|
|
349
|
+
? 'this public URL requires the oz_… bearer for paid endpoints; /v1/models and /v1/hrr/bind are free'
|
|
350
|
+
: 'localhost is keyless',
|
|
351
|
+
context: {
|
|
352
|
+
yourAttentionWindow: 'unchanged — openzoo does not enlarge it',
|
|
353
|
+
boundCeiling: '~128M tokens client-usable via bind + retrieval',
|
|
354
|
+
singleRequestLimit: '~8MB per request; larger corpora bind in parts',
|
|
355
|
+
retrieval: 'lossy top-k retrieval, NOT lossless compression',
|
|
356
|
+
},
|
|
357
|
+
tools: ['zoo_bind', 'zoo_ask', 'zoo_status', 'zoo_models', 'zoo_wallet', 'zoo_contexts'],
|
|
358
|
+
docs: 'https://openzoo.fun',
|
|
359
|
+
}, null, 2));
|
|
360
|
+
return;
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
|
|
328
364
|
if (viaTunnel) {
|
|
329
365
|
const got = (req.headers.authorization || '').replace(/^Bearer\s+/i, '').trim();
|
|
330
366
|
const authed = got === tunnelGate.token;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "openzoo",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.18.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",
|