{"_id":"@agenticfi/onchain-router-routing","_rev":"5-eb9abdb03e1b4992f71c01313a4035fd","name":"@agenticfi/onchain-router-routing","dist-tags":{"alpha":"0.1.2","latest":"0.1.3"},"versions":{"0.1.0":{"name":"@agenticfi/onchain-router-routing","version":"0.1.0","keywords":["llm","routing","model-router","ai-agents","x402","cost","latency"],"author":{"name":"AgenticFI"},"license":"MIT","_id":"@agenticfi/onchain-router-routing@0.1.0","maintainers":[{"name":"sarenabg","email":"saren.abgaryan@yahoo.com"}],"homepage":"https://llm.agenticfi.wtf/docs/routing","bugs":{"url":"https://github.com/AgenticFI/onchain-router-clients/issues"},"dist":{"shasum":"28a05365515c79db75e0d275d6cf86db7e87322c","tarball":"https://registry.npmjs.org/@agenticfi/onchain-router-routing/-/onchain-router-routing-0.1.0.tgz","fileCount":7,"integrity":"sha512-BfKqnFz3wuCSKly0m0M9VDz9HO76aG/VFX+CIRr9bwimGF1mMGdGb7Bn4PtxHEYy296H6c7/s1mv9D+GwOQzbA==","signatures":[{"sig":"MEUCICGrhIGshF0j9/vC6own0LYEq+2OmZ4qA6i/Jd1+ZySOAiEAydxEnfV2EZFoyrXyWUqwDZ1yYo1ii5NjkB577biSwxI=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@agenticfi%2fonchain-router-routing@0.1.0","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":71909},"type":"module","_from":"file:/home/runner/work/onchain-router-clients/onchain-router-clients/.artifacts/npm/agenticfi-onchain-router-routing-0.1.0.tgz","types":"./dist/index.d.ts","engines":{"node":">=20.18.0"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js"}},"private":false,"scripts":{"lint":"eslint src tests","test":"vitest run","build":"tsup src/index.ts --format esm --dts --clean","clean":"rm -rf dist coverage","test:unit":"vitest run","typecheck":"tsc --noEmit","test:integration":"vitest run --passWithNoTests"},"_npmUser":{"name":"sarenabg","email":"saren.abgaryan@yahoo.com"},"_resolved":"/home/runner/work/onchain-router-clients/onchain-router-clients/.artifacts/npm/agenticfi-onchain-router-routing-0.1.0.tgz","_integrity":"sha512-BfKqnFz3wuCSKly0m0M9VDz9HO76aG/VFX+CIRr9bwimGF1mMGdGb7Bn4PtxHEYy296H6c7/s1mv9D+GwOQzbA==","repository":{"url":"git+https://github.com/AgenticFI/onchain-router-clients.git","type":"git","directory":"packages/routing"},"_npmVersion":"11.5.1","description":"Experimental deterministic model-selection core for Onchain Router","directories":{},"_nodeVersion":"22.14.0","publishConfig":{"tag":"alpha","access":"public","provenance":true},"_hasShrinkwrap":false,"devDependencies":{"tsup":"8.5.1","vitest":"4.1.0","typescript":"5.9.3"},"_npmOperationalInternal":{"tmp":"tmp/onchain-router-routing_0.1.0_1788263641051_0.44369502664675675","host":"s3://npm-registry-packages-npm-production"},"deprecated":"Moved to @onchainrouter/routing. Install @onchainrouter/routing@0.2.0."},"0.1.1":{"name":"@agenticfi/onchain-router-routing","version":"0.1.1","keywords":["llm","routing","model-router","ai-agents","x402","cost","latency"],"author":{"name":"AgenticFI"},"license":"MIT","_id":"@agenticfi/onchain-router-routing@0.1.1","maintainers":[{"name":"sarenabg","email":"saren.abgaryan@yahoo.com"}],"homepage":"https://llm.agenticfi.wtf/docs/routing","bugs":{"url":"https://github.com/AgenticFI/onchain-router-clients/issues"},"dist":{"shasum":"ad21f0326724c91c2107e72287f166f59b5b3621","tarball":"https://registry.npmjs.org/@agenticfi/onchain-router-routing/-/onchain-router-routing-0.1.1.tgz","fileCount":7,"integrity":"sha512-zz01MDqPABTrgby38gwBZciAinRROVzGPJErhmi8m4KYXSWxNhsH/hFskOq70BDEDmehtBiTJJInCCne6nPK4w==","signatures":[{"sig":"MEUCIQDHKBxSwySU8FGvinQqrBXuHOj4+zarGFsHYj2UiodiswIgc6kdGwjeOrqfkTU6MU4kih7FdX0F7FstRY5uD/qWCmg=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@agenticfi%2fonchain-router-routing@0.1.1","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":71909},"type":"module","_from":"file:/home/runner/work/onchain-router-clients/onchain-router-clients/.artifacts/npm/agenticfi-onchain-router-routing-0.1.1.tgz","types":"./dist/index.d.ts","engines":{"node":">=20.18.0"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js"}},"private":false,"scripts":{"lint":"eslint src tests","test":"vitest run","build":"tsup src/index.ts --format esm --dts --clean","clean":"rm -rf dist coverage","test:unit":"vitest run","typecheck":"tsc --noEmit","test:integration":"vitest run --passWithNoTests"},"_npmUser":{"name":"sarenabg","email":"saren.abgaryan@yahoo.com"},"_resolved":"/home/runner/work/onchain-router-clients/onchain-router-clients/.artifacts/npm/agenticfi-onchain-router-routing-0.1.1.tgz","_integrity":"sha512-zz01MDqPABTrgby38gwBZciAinRROVzGPJErhmi8m4KYXSWxNhsH/hFskOq70BDEDmehtBiTJJInCCne6nPK4w==","repository":{"url":"git+https://github.com/AgenticFI/onchain-router-clients.git","type":"git","directory":"packages/routing"},"_npmVersion":"11.5.1","description":"Experimental deterministic model-selection core for Onchain Router","directories":{},"_nodeVersion":"22.14.0","publishConfig":{"tag":"alpha","access":"public","provenance":true},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsup":"8.5.1","vitest":"4.1.0","typescript":"5.9.3"},"_npmOperationalInternal":{"tmp":"tmp/onchain-router-routing_0.1.1_1788387684193_0.40699925608553955","host":"s3://npm-registry-packages-npm-production"},"deprecated":"Moved to @onchainrouter/routing. Install @onchainrouter/routing@0.2.0."},"0.1.2":{"name":"@agenticfi/onchain-router-routing","version":"0.1.2","keywords":["llm","routing","model-router","ai-agents","x402","cost","latency"],"author":{"name":"AgenticFI"},"license":"MIT","_id":"@agenticfi/onchain-router-routing@0.1.2","maintainers":[{"name":"sarenabg","email":"saren.abgaryan@yahoo.com"}],"homepage":"https://llm.agenticfi.wtf/docs/routing","bugs":{"url":"https://github.com/AgenticFI/onchain-router-clients/issues"},"dist":{"shasum":"c6fc60e43144ec9a322f0dc723ff5fd7d3b6efa3","tarball":"https://registry.npmjs.org/@agenticfi/onchain-router-routing/-/onchain-router-routing-0.1.2.tgz","fileCount":7,"integrity":"sha512-VJVXVQdMQs6yP6GOHP2G6fnTtaZO+4UdkhJOYjEQlIJF6v6dWW2IM1GPpvFLQp2ixW3MeykScz09bSv7shyGHA==","signatures":[{"sig":"MEUCIBZIW6gfzfnZorsnKf7oaBt5vb6gUO0XVNksvRuM/sKdAiEA23JIQfBnubJSAoQyAOIuyWnUPNL1cUA0jvU94h64LRg=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@agenticfi%2fonchain-router-routing@0.1.2","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":71962},"type":"module","_from":"file:/home/runner/work/onchain-router-clients/onchain-router-clients/.artifacts/npm/agenticfi-onchain-router-routing-0.1.2.tgz","types":"./dist/index.d.ts","engines":{"node":">=20.18.0"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js"}},"private":false,"scripts":{"lint":"eslint src tests","test":"vitest run","build":"tsup src/index.ts --format esm --dts --clean","clean":"rm -rf dist coverage","test:unit":"vitest run","typecheck":"tsc --noEmit","test:integration":"vitest run --passWithNoTests"},"_npmUser":{"name":"sarenabg","email":"saren.abgaryan@yahoo.com"},"_resolved":"/home/runner/work/onchain-router-clients/onchain-router-clients/.artifacts/npm/agenticfi-onchain-router-routing-0.1.2.tgz","_integrity":"sha512-VJVXVQdMQs6yP6GOHP2G6fnTtaZO+4UdkhJOYjEQlIJF6v6dWW2IM1GPpvFLQp2ixW3MeykScz09bSv7shyGHA==","repository":{"url":"git+https://github.com/AgenticFI/onchain-router-clients.git","type":"git","directory":"packages/routing"},"_npmVersion":"11.5.1","description":"Experimental deterministic model-selection core for Onchain Router","directories":{},"_nodeVersion":"22.14.0","publishConfig":{"tag":"alpha","access":"public","provenance":true},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsup":"8.5.1","vitest":"4.1.0","typescript":"5.9.3"},"_npmOperationalInternal":{"tmp":"tmp/onchain-router-routing_0.1.2_1788443486840_0.48587219767551826","host":"s3://npm-registry-packages-npm-production"},"deprecated":"Moved to @onchainrouter/routing. Install @onchainrouter/routing@0.2.0."},"0.1.3":{"name":"@agenticfi/onchain-router-routing","version":"0.1.3","keywords":["llm","routing","model-router","ai-agents","x402","cost","latency"],"author":{"name":"AgenticFI"},"license":"MIT","_id":"@agenticfi/onchain-router-routing@0.1.3","maintainers":[{"name":"sarenabg","email":"saren.abgaryan@yahoo.com"}],"homepage":"https://onchainrouter.dev/docs/routing","bugs":{"url":"https://github.com/AgenticFI/onchain-router-clients/issues"},"dist":{"shasum":"a5449aab14ff66985d1362d5d5b4a2c0301a3456","tarball":"https://registry.npmjs.org/@agenticfi/onchain-router-routing/-/onchain-router-routing-0.1.3.tgz","fileCount":7,"integrity":"sha512-tx8L5exoSvfL/V5ddp+mp2yUqbV59m/Hf/7q5rzKrtxympom6BgAEAHCeTyEXmxbggvV894AYy33m6wNQEBWGg==","signatures":[{"sig":"MEUCIG7S+9hyXe5YUlU5bdRukP7OF4nClKVMfNJ88d3UoK4VAiEA4K+rHMoRU+nXeCs4wSfwAN6FLRkoO1dJTHRAVxv46WI=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@agenticfi%2fonchain-router-routing@0.1.3","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":71923},"type":"module","_from":"file:/home/runner/work/onchain-router-clients/onchain-router-clients/.artifacts/npm/agenticfi-onchain-router-routing-0.1.3.tgz","types":"./dist/index.d.ts","engines":{"node":">=20.18.0"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js"}},"private":false,"scripts":{"lint":"eslint src tests","test":"vitest run","build":"tsup src/index.ts --format esm --dts --clean","clean":"rm -rf dist coverage","test:unit":"vitest run","typecheck":"tsc --noEmit","test:integration":"vitest run --passWithNoTests"},"_npmUser":{"name":"sarenabg","email":"saren.abgaryan@yahoo.com"},"_resolved":"/home/runner/work/onchain-router-clients/onchain-router-clients/.artifacts/npm/agenticfi-onchain-router-routing-0.1.3.tgz","_integrity":"sha512-tx8L5exoSvfL/V5ddp+mp2yUqbV59m/Hf/7q5rzKrtxympom6BgAEAHCeTyEXmxbggvV894AYy33m6wNQEBWGg==","repository":{"url":"git+https://github.com/AgenticFI/onchain-router-clients.git","type":"git","directory":"packages/routing"},"_npmVersion":"11.5.1","description":"Experimental deterministic model-selection core for Onchain Router","directories":{},"_nodeVersion":"22.14.0","publishConfig":{"tag":"latest","access":"public","provenance":true},"_hasShrinkwrap":false,"devDependencies":{"tsup":"8.5.1","vitest":"4.1.0","typescript":"5.9.3"},"_npmOperationalInternal":{"tmp":"tmp/onchain-router-routing_0.1.3_1788514372079_0.48764641658326213","host":"s3://npm-registry-packages-npm-production"},"deprecated":"Moved to @onchainrouter/routing. Install @onchainrouter/routing@0.2.0."}},"time":{"created":"2026-09-01T11:54:00.856Z","modified":"2026-09-04T13:30:38.787Z","0.1.0":"2026-09-01T11:54:01.173Z","0.1.1":"2026-09-02T22:21:24.333Z","0.1.2":"2026-09-03T13:51:26.991Z","0.1.3":"2026-09-04T09:32:52.216Z"},"bugs":{"url":"https://github.com/AgenticFI/onchain-router-clients/issues"},"author":{"name":"AgenticFI"},"license":"MIT","homepage":"https://onchainrouter.dev/docs/routing","keywords":["llm","routing","model-router","ai-agents","x402","cost","latency"],"repository":{"url":"git+https://github.com/AgenticFI/onchain-router-clients.git","type":"git","directory":"packages/routing"},"description":"Experimental deterministic model-selection core for Onchain Router","maintainers":[{"name":"sarenabg","email":"saren.abgaryan@yahoo.com"}],"readme":"# Onchain Router Routing\n\nAn experimental, deterministic model-selection library for Onchain Router text requests. It\nhard-filters models, asks the live service for request-bound price maxima, and selects exactly one\nmodel before the Buyer Runtime starts an x402 payment.\n\nRouting is advisory. It does not own a wallet, sign or settle payments, call an AI provider, retry\na request, or authorize fallback. The human-owned Buyer Runtime policy remains final.\n\n## Release status\n\nVersion `0.1.3` is the stable npm package release for the `onchainrouter.dev` domain cutover. Routing remains experimental and advisory: it cannot\nsign, spend, retry a paid route, or widen Buyer Runtime policy. Do not describe it as\nproduction-ready automatic routing.\n\n## Requirements\n\n- Node.js 20.18 or newer;\n- macOS or Linux;\n- a `RouteQuotePort` backed by authoritative request-bound quotes;\n- an operator-reviewed model allowlist and fixed-point quality priors.\n\nAll money is `bigint` internally and decimal atomic-unit strings at serialized boundaries. Never\nuse JavaScript floating point for USDC or token accounting.\n\n## Installation\n\nInstall the stable package explicitly:\n\n```bash\nnpm install @agenticfi/onchain-router-routing@0.1.3\n```\n\nTo build and test the exact published source:\n\n```bash\ncorepack enable\npnpm install --frozen-lockfile\npnpm --filter @agenticfi/onchain-router-routing build\npnpm --filter @agenticfi/onchain-router-routing test\n```\n\n## Quick start\n\nThe quote port below is intentionally a placeholder. In an Onchain Router integration it must call\nthe canonical service's free `/v1/quotes` endpoint with the identical request that will later be\npaid. Do not substitute a local price estimate.\n\n```ts\nimport {\n  DeterministicSmartRouter,\n  createRoutingPolicy,\n  type RouteModel,\n  type RouteQuotePort,\n} from '@agenticfi/onchain-router-routing';\n\nconst models: RouteModel[] = [\n  {\n    id: 'model-from-live-catalog',\n    enabled: true,\n    category: 'text_generation',\n    capabilities: ['text', 'json'],\n    maximumOutputTokens: 8192,\n    qualityBasisPoints: { general: 8000, code: 8200, reasoning: 7800 },\n  },\n];\n\nconst policy = createRoutingPolicy({\n  allowedModels: models.map(({ id }) => id),\n  maximumCandidates: 8,\n  maximumHealthAgeMs: 60_000,\n  unknownHealthBasisPoints: 5_000,\n});\n\nconst quotes: RouteQuotePort = {\n  async quote(input) {\n    // Fetch one authoritative, unexpired quote for input.request and input.model.\n    return {\n      model: input.model,\n      maximumAtomic: 25_000n,\n      catalogVersion: 'catalog-version-from-quote',\n      expiresAt: Date.now() + 30_000,\n    };\n  },\n};\n\nconst decision = await new DeterministicSmartRouter(policy, quotes).route({\n  endpoint: '/v1/chat/completions',\n  kind: 'openai',\n  profile: 'auto',\n  body: {\n    messages: [{ role: 'user', content: 'Return one JSON object.' }],\n    max_tokens: 256,\n  },\n  models,\n  localMaximumAtomic: 100_000n,\n});\n\nconsole.log(decision.selectedModel, decision.selectedMaximumAtomic);\n```\n\nApplication developers should normally use `OnchainRouterBuyer.routedChat()` from\n`@agenticfi/onchain-router`; it connects routing to the ordinary Buyer Runtime payment and receipt\npath without creating a second wallet or settlement implementation.\n\n## Decision contract\n\nThe router applies this order:\n\n1. enforce the immutable model allowlist and capability, context, and output constraints;\n2. exclude fresh unavailable health while treating stale health as unknown;\n3. obtain an authoritative maximum for every eligible candidate;\n4. reject expired, failed, over-cap, or catalog-drifting quotes;\n5. rank the remaining candidates with integer quality, cost, latency, reliability, and preference\n   scores;\n6. return one selected model and a content-free explanation.\n\n`fallbackAuthorized` is always `false`. Prompt text is classification input only; it cannot change\nthe origin, allowlist, network, asset, recipient, maximum, quote port, or fallback behavior.\n\n## Qualification limits\n\nThe repository includes versioned calibration and held-out benchmark machinery, but the current\nheld-out qualification did not meet every quality threshold. Historical reports are retained as\nevidence and must not be tuned or rerun as fresh evidence. Do not advertise cost savings, quality\ngains, or production automatic routing until RTE-003 passes with a newly frozen suite.\n\nProvider-backed benchmark functions can consume provider credits. They are deliberately separate\nfrom automated tests and must only run under an explicit call budget. They never exercise x402 or\nUSDC settlement.\n\n## Security\n\n- Derive eligible models from live discovery intersected with the local Buyer Runtime policy.\n- Bind quotes to the exact request, model, endpoint, origin, and catalog version.\n- Reject selection when every route is unavailable, unquoted, expired, over the local cap, or on a\n  different catalog version.\n- Never route around `ProviderOutcomeUnknown` or `SettlementOutcomeUnknown` with another model.\n- Keep prompts, completions, wallet identifiers, and signatures out of routing evidence and logs.\n- Review the [routing threat model](https://github.com/AgenticFI/onchain-router-clients/blob/main/packages/routing/routing-threat-model.md) before adding a quote or health port.\n\nReport security issues using the repository [`SECURITY.md`](https://github.com/AgenticFI/onchain-router-clients/blob/main/SECURITY.md).\n\n## Troubleshooting\n\n- `no eligible routes`: compare live capabilities and output/context limits with the immutable\n  allowlist.\n- `no usable bounded quote`: refresh discovery and quotes; do not fall back to estimated pricing.\n- `catalog version`: discard the whole decision and re-quote every eligible candidate.\n- `over_local_maximum`: lower the request or ask the human to review policy outside the agent path.\n- Unexpected selection: inspect the content-free `routes`, `exclusions`, policy hash, quote maxima,\n  and fixed-point priors; never log the prompt to debug routing.\n\n## Support\n\nDocumentation: <https://onchainrouter.dev/docs/routing>\n\nIssues: <https://github.com/AgenticFI/onchain-router-clients/issues>\n\nInclude the package version, policy hash, catalog version, sanitized exclusions, and an exact\nreproduction without user content.\n\n## License\n\nMIT. See [LICENSE](LICENSE).\n","readmeFilename":"README.md"}