Releases: davccavalcante/bayesroute
Release list
[PUBLISHED ON NPMJS] @takk/bayesroute@1.0.0
STATUS: PUBLISHED ON NPMJS. This version was published to the npm registry on 2026-06-20T15:56:59Z with provenance attestation. View on npm: https://www.npmjs.com/package/@takk/bayesroute/v/1.0.0
STATUS: REVIEW REQUIRED, NOT YET ON NPMJS. This GitHub Release was created by the
release.ymlworkflow. The Creator must review the contents (tag, changelog, attached commit, pack-smoke result in the workflow logs) and then explicitly runnpm-publish.ymlto publish this version to the npm registry.
[1.0.0] - 2026-06-20T14:57:44Z
Initial stable release. BayesRoute is a zero-runtime-dependency, TypeScript-first Thompson-sampling Bayesian router that picks the right model for every query across quality, cost, and latency for Massive Intelligence (IM) products and agents. Model selection becomes a calibrated probabilistic decision with bounded regret, not a static rule or a greedy top-model heuristic.
Added
Core router
createBayesRoute({ models, ... })facade wiring the query classifier, posterior store, Thompson sampler, multi-objective utility, safe-exploration guard, optional time-decay, and the tamper-evident audit log into one object.route(features)classifies the domain, Thompson-samples the (model, domain) arms, and applies the safe-exploration guard.run(features, call)one-call path: route, call the chosen model, measure latency with the configured clock, and fold the outcome back in a single await.observe,observeDecision,arm,summary,rank,models,domains,snapshot,load,auditLog,seal, andverify.
Conjugate posteriors
./beta: the Beta-Bernoulli quality posterior, exact moments, density, CDF via the regularized incomplete beta, quantile, equal-tailed credible interval, conjugate update, and seeded sampling../gamma: the Gamma-Exponential latency and cost posteriors, prior-from-mean, expected-value mean, conjugate update, seeded sampling, and exact value credible intervals via the regularized incomplete gamma.- Internal special functions: lgamma (Lanczos), the regularized incomplete beta and gamma and both quantiles, exact to numerical precision.
Decision layers
./arms: the per (model, domain) posterior bundle, init, observe, and calibrated summary../sampler: the Thompson sampler and the greedy incumbent../utility: the multi-objective expected utility with configurable weights and reference scales../classify: default, static, and keyword query classifiers, plus support for any custom function../outcome: scorer-agnostic outcome constructors plus heuristic evaluators (lengthEvaluator,regexEvaluator,jsonValidEvaluator,combineAll,combineAny,evaluate) and an async LLM-as-judge type../policy: the safe-exploration guard that bounds how far a single decision may stray from the greedy incumbent../decay: time-decay of evidence for non-stationary models and silent provider deprecations.
Persistence and audit
./store: thePosteriorStoreinterface, an in-memory store, and JSON snapshot encode, decode, and load with full field validation../node:createFileStore, atomic file persistence, the only entry that touches a Node built-in../edge: the node-free core re-exported for edge runtimes and the browser../audit: an append-only SHA-256 hash-chain audit log built on the Web Crypto API, with seal and verify for tamper evidence.
CLI
- Binary
bayesroutewithroute,observe,rank,inspect,verify,help, and--version. JSON output; sysexits-style exit codes (0 ok, 1 error, 64 usage, 65 data, 66 no input).
Distribution and quality
- Dual ESM and CJS with per-subpath type definitions; fourteen subpath exports plus the CLI; a
filesallowlist;enginesnode >= 20. - 511 tests across 22 suites; coverage statements 98%, branches 96%, functions 99%, lines 98%.
- TypeScript 6 in maximum strict mode, Biome 2,
publintandattwclean across all subpaths,size-limitbudgets (the core is about 5 kB brotli), a distribution smoke test that exercises the compiled ESM and CJS artifacts and the compiled CLI, validated on the CI matrix across Node 20, 22, and 24. - Release publishing uses provenance (SLSA attestation) through GitHub Actions.
Documentation and examples
- README, SPEC, SECURITY, PRIVACY, NOTICE, CLA, CODE_OF_CONDUCT, the issue and pull-request templates, and the GitHub Pages site written for BayesRoute.
- Runnable examples: basic routing, the
runone-liner, the built-in quality evaluators, a deterministic savings benchmark against always-frontier and always-cheapest baselines, and a Vercel AI SDK and Mastra integration guide. - A real-data benchmark (
benchmarks/) on the public RouterBench dataset (36,497 real queries across 11 models): replaying the stream through BayesRoute, it matches the spend of always-using GPT-3.5 at higher accuracy (69.6% versus 66.6%) and reaches 73.1% accuracy at 13% of GPT-4's cost, learning per-domain online with no hand-written rules. The benchmark and its dataset are development-only and excluded from the published tarball.