Repository navigation
Conversation
- src/llm_routes.ts: native routing mirror of scw_js/sc_llm_x402.ts (challenge-before- validation, ceiling-then-usage settle, testnet-mock gate, tools/messages caps, tool_choice enum, openapi price.max override) - Deviation, decided + gated by the wall-clock spike (504 at 59.2s on bunny): the twin advertises/verifies with LLM_MAX_TIMEOUT_SECONDS=40 (vs scw's 120) and races the unbounded callLLMAPI at that bound, so the handler answers (lock released, nothing settled) before the edge kills the request. Channels funded against the scw chat's 120s advertisement stay usable (maxTimeoutSeconds is per-route, not in channelId). - test/llm.test.ts: 72 tests translated from sc_llm_x402.test.ts (Request-returning makeEvent, legacy adapter, native favicon bytes) — 237 total green - Multi-entry layout: routers searchapi_routes/llm_routes + entries searchapi/llm -> dist/searchapi.js (397.6 KB) + dist/llm.js (402.3 KB); per-entry build scripts; deploy script + workflow now target dist/searchapi.js - src/response.ts: shared toResponse/byteStringHeaderValue extracted from the searchapi router for all three twins
- src/mcp_routes.ts: stateless JSON-RPC 2.0 dispatch (initialize, tools/list, tools/call, notifications -> 202), ported from scw_js/mcp_server.ts, plus the decided GET deviation: root HTML + /favicon.png answer 200 for scanners, other GETs return an honest 404 with the stateless notice instead of the scw original's blanket 405; DELETE keeps 405 (no sessions, spec-legal) - src/mcp_tools.ts: relay layer over the REAL twin routers via synthetic Requests — payment header translation both ways (meta -> payment-signature; 402 -> isError + structuredContent; Payment-Response -> _meta receipt). @x402/mcp dropped after build showed its root-export pulls the full @modelcontextprotocol/sdk with top-level 'import "ajv"' (unresolved in the edge bundle = load-time crash); the two meta-key constants are inlined as literals, values verified against @x402/mcp 2.28.0 and pinned by the tests - src/mcp.ts entry; build:mcp wired -> dist/mcp.js 421.7 KB, externals only the five node:* builtins, zero ajv references - test/mcp.test.ts: 16 tests translated (transport tests rewritten for the GET deviation; relay tests pin mainnet-only search / testnet-chat asymmetry, usage-derived settlement of 13 atomic USDC, receipt in _meta) — after fixing stale vi.mock registration paths that silently disabled the mocks - Local deno smoke: initialize/tools/list correct; unpaid tools/call returns the real mainnet-only demands as isError; GET HTML 200, GET /mcp 404
Same recipe as the search buyer: env path ../.env (bunny_js's local .env copy), three-way SERVER selector (bunny-local :8080 / bunny-trial with TRIAL_URL / scw-deployed for the A/B), outputs cleared. The mcp notebook's findings cell pins the payoff measurement: cold initialize ~0.3 s on the twin vs the ~26-27 s measured three times on the scw function. The llm notebook's header notes the twin's 40 s completion cap (vs scw's 120 s). Typecheck: mcp buyer zero errors; llm buyer 3 pre-existing TS2551 union quirks (5 in the original — the SERVER-block rewrite removed two), same class the jupyter kernel does not enforce. Local smoke through the notebooks' own request shape: env loads, initialize negotiates 2025-06-18, unpaid chat_completion returns isError + testnet accepts (the chat's intentional asymmetry, verified end to end).
- package.json: dev:searchapi / dev:llm / dev:mcp (deno run on the source entry, --sloppy-imports for the shared packages' extensionless tsc output); 'dev' aliased to dev:searchapi — the old 'dev' still pointed at the pre-rename src/index.ts, which no longer exists - README: the three dev scripts + the --env-file=.env flag documented - notebooks: llm_mcp_buyer's three scw-era references (cd scw_js && npm run dev:mcp, port 8086) and llm_x402_buyer's dev:llmx402 reference now point at the bunny twins (port 8080) - Verified live: npm run dev:mcp serves, initialize answers 2025-06-18
npm run dev:mcp --env-file=.env does not work — npm eats unknown flags as
its own config ('Unknown cli config --env-file'), so the flag never reaches
deno; the escape hatch is 'npm run dev:<x> -- <flags>'. Since the env file
is wanted for every local run anyway, the dev scripts now include
--env-file=.env themselves; a missing .env only warns (verified), so fresh
clones do not break. README documents both the baked-in flag and the --
escape hatch.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.