modelrig 0.1.0 → 0.3.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.
Files changed (310) hide show
  1. package/CHANGELOG.md +158 -0
  2. package/README.md +53 -11
  3. package/data/PROVENANCE.md +19 -0
  4. package/data/pricing-manual.json +22 -0
  5. package/data/pricing-map.json +46362 -0
  6. package/data/pricing-overlay.json +419 -0
  7. package/dist/adapters/anthropic.d.ts +50 -6
  8. package/dist/adapters/anthropic.d.ts.map +1 -1
  9. package/dist/adapters/anthropic.js +123 -29
  10. package/dist/adapters/build-adapters.d.ts +11 -0
  11. package/dist/adapters/build-adapters.d.ts.map +1 -0
  12. package/dist/adapters/build-adapters.js +45 -0
  13. package/dist/adapters/deepseek.d.ts +6 -0
  14. package/dist/adapters/deepseek.d.ts.map +1 -1
  15. package/dist/adapters/deepseek.js +54 -1
  16. package/dist/adapters/gemini.d.ts +10 -0
  17. package/dist/adapters/gemini.d.ts.map +1 -1
  18. package/dist/adapters/gemini.js +78 -7
  19. package/dist/adapters/grok.d.ts +9 -0
  20. package/dist/adapters/grok.d.ts.map +1 -1
  21. package/dist/adapters/grok.js +67 -3
  22. package/dist/adapters/openai-compat.d.ts +6 -0
  23. package/dist/adapters/openai-compat.d.ts.map +1 -1
  24. package/dist/adapters/openai-compat.js +58 -1
  25. package/dist/adapters/openai-stream.d.ts +58 -0
  26. package/dist/adapters/openai-stream.d.ts.map +1 -0
  27. package/dist/adapters/openai-stream.js +120 -0
  28. package/dist/adapters/openai.d.ts +6 -0
  29. package/dist/adapters/openai.d.ts.map +1 -1
  30. package/dist/adapters/openai.js +60 -1
  31. package/dist/adapters/sampling.d.ts +28 -0
  32. package/dist/adapters/sampling.d.ts.map +1 -0
  33. package/dist/adapters/sampling.js +34 -0
  34. package/dist/adapters/tool-mapping.d.ts +92 -0
  35. package/dist/adapters/tool-mapping.d.ts.map +1 -0
  36. package/dist/adapters/tool-mapping.js +143 -0
  37. package/dist/artifacts/artifact.d.ts +137 -0
  38. package/dist/artifacts/artifact.d.ts.map +1 -0
  39. package/dist/artifacts/artifact.js +377 -0
  40. package/dist/artifacts/content-uploader.d.ts +87 -0
  41. package/dist/artifacts/content-uploader.d.ts.map +1 -0
  42. package/dist/artifacts/content-uploader.js +124 -0
  43. package/dist/artifacts/index.d.ts +63 -0
  44. package/dist/artifacts/index.d.ts.map +1 -0
  45. package/dist/artifacts/index.js +80 -0
  46. package/dist/artifacts/run-context.d.ts +129 -0
  47. package/dist/artifacts/run-context.d.ts.map +1 -0
  48. package/dist/artifacts/run-context.js +208 -0
  49. package/dist/artifacts/scrub.d.ts +60 -0
  50. package/dist/artifacts/scrub.d.ts.map +1 -0
  51. package/dist/artifacts/scrub.js +139 -0
  52. package/dist/artifacts/step.d.ts +26 -0
  53. package/dist/artifacts/step.d.ts.map +1 -0
  54. package/dist/artifacts/step.js +37 -0
  55. package/dist/artifacts/taint.d.ts +63 -0
  56. package/dist/artifacts/taint.d.ts.map +1 -0
  57. package/dist/artifacts/taint.js +76 -0
  58. package/dist/bakeoff/cache-sim.d.ts +99 -0
  59. package/dist/bakeoff/cache-sim.d.ts.map +1 -0
  60. package/dist/bakeoff/cache-sim.js +126 -0
  61. package/dist/bakeoff/eval-cases.d.ts +96 -0
  62. package/dist/bakeoff/eval-cases.d.ts.map +1 -0
  63. package/dist/bakeoff/eval-cases.js +105 -0
  64. package/dist/bakeoff/report.d.ts +41 -0
  65. package/dist/bakeoff/report.d.ts.map +1 -0
  66. package/dist/bakeoff/report.js +142 -0
  67. package/dist/bakeoff/samples.d.ts +15 -0
  68. package/dist/bakeoff/samples.d.ts.map +1 -1
  69. package/dist/bakeoff/samples.js +20 -0
  70. package/dist/cli.d.ts +1 -3
  71. package/dist/cli.d.ts.map +1 -1
  72. package/dist/cli.js +134 -116
  73. package/dist/config.d.ts +100 -0
  74. package/dist/config.d.ts.map +1 -1
  75. package/dist/config.js +104 -0
  76. package/dist/deprecations.d.ts +32 -0
  77. package/dist/deprecations.d.ts.map +1 -0
  78. package/dist/deprecations.js +59 -0
  79. package/dist/gateway/http-protocol.d.ts +175 -0
  80. package/dist/gateway/http-protocol.d.ts.map +1 -0
  81. package/dist/gateway/http-protocol.js +105 -0
  82. package/dist/index.d.ts +106 -19
  83. package/dist/index.d.ts.map +1 -1
  84. package/dist/index.js +266 -138
  85. package/dist/init/finder.d.ts +15 -0
  86. package/dist/init/finder.d.ts.map +1 -1
  87. package/dist/init/finder.js +46 -0
  88. package/dist/init/init-cli.d.ts +10 -0
  89. package/dist/init/init-cli.d.ts.map +1 -0
  90. package/dist/init/init-cli.js +86 -0
  91. package/dist/init/observe-cli.d.ts +19 -0
  92. package/dist/init/observe-cli.d.ts.map +1 -0
  93. package/dist/init/observe-cli.js +73 -0
  94. package/dist/init/observe.d.ts +81 -0
  95. package/dist/init/observe.d.ts.map +1 -0
  96. package/dist/init/observe.js +245 -0
  97. package/dist/registry/build.d.ts +94 -1
  98. package/dist/registry/build.d.ts.map +1 -1
  99. package/dist/registry/build.js +125 -4
  100. package/dist/registry/cache-policy.d.ts +94 -0
  101. package/dist/registry/cache-policy.d.ts.map +1 -0
  102. package/dist/registry/cache-policy.js +238 -0
  103. package/dist/registry/call-notes.d.ts.map +1 -1
  104. package/dist/registry/call-notes.js +40 -2
  105. package/dist/registry/effective-rate.d.ts +151 -0
  106. package/dist/registry/effective-rate.d.ts.map +1 -0
  107. package/dist/registry/effective-rate.js +156 -0
  108. package/dist/registry/facts.d.ts.map +1 -1
  109. package/dist/registry/facts.js +16 -0
  110. package/dist/registry/parity.d.ts +26 -0
  111. package/dist/registry/parity.d.ts.map +1 -1
  112. package/dist/registry/parity.js +43 -2
  113. package/dist/registry/pricing-shape.d.ts +113 -0
  114. package/dist/registry/pricing-shape.d.ts.map +1 -0
  115. package/dist/registry/pricing-shape.js +123 -0
  116. package/dist/registry/pricing.d.ts +25 -1
  117. package/dist/registry/pricing.d.ts.map +1 -1
  118. package/dist/registry/pricing.js +64 -6
  119. package/dist/rigindex/bootstrap.d.ts +36 -0
  120. package/dist/rigindex/bootstrap.d.ts.map +1 -0
  121. package/dist/rigindex/bootstrap.js +97 -0
  122. package/dist/rigindex/fit.d.ts +24 -0
  123. package/dist/rigindex/fit.d.ts.map +1 -0
  124. package/dist/rigindex/fit.js +76 -0
  125. package/dist/rigindex/gates.d.ts +52 -0
  126. package/dist/rigindex/gates.d.ts.map +1 -0
  127. package/dist/rigindex/gates.js +109 -0
  128. package/dist/rigindex/graph.d.ts +31 -0
  129. package/dist/rigindex/graph.d.ts.map +1 -0
  130. package/dist/rigindex/graph.js +120 -0
  131. package/dist/rigindex/index.d.ts +23 -0
  132. package/dist/rigindex/index.d.ts.map +1 -0
  133. package/dist/rigindex/index.js +112 -0
  134. package/dist/rigindex/types.d.ts +76 -0
  135. package/dist/rigindex/types.d.ts.map +1 -0
  136. package/dist/rigindex/types.js +8 -0
  137. package/dist/routes/cache-lint.d.ts +41 -0
  138. package/dist/routes/cache-lint.d.ts.map +1 -0
  139. package/dist/routes/cache-lint.js +81 -0
  140. package/dist/routes/loader.d.ts +48 -0
  141. package/dist/routes/loader.d.ts.map +1 -1
  142. package/dist/routes/loader.js +167 -0
  143. package/dist/routes/resolved-bundle.d.ts +79 -0
  144. package/dist/routes/resolved-bundle.d.ts.map +1 -0
  145. package/dist/routes/resolved-bundle.js +148 -0
  146. package/dist/routes/sampling-config.d.ts +32 -0
  147. package/dist/routes/sampling-config.d.ts.map +1 -0
  148. package/dist/routes/sampling-config.js +91 -0
  149. package/dist/run/ajv.d.ts +22 -0
  150. package/dist/run/ajv.d.ts.map +1 -0
  151. package/dist/run/ajv.js +32 -0
  152. package/dist/run/cache-handle.d.ts +58 -0
  153. package/dist/run/cache-handle.d.ts.map +1 -0
  154. package/dist/run/cache-handle.js +54 -0
  155. package/dist/run/cache-stamp.d.ts +65 -0
  156. package/dist/run/cache-stamp.d.ts.map +1 -0
  157. package/dist/run/cache-stamp.js +0 -0
  158. package/dist/run/capture-write.d.ts +33 -0
  159. package/dist/run/capture-write.d.ts.map +1 -0
  160. package/dist/run/capture-write.js +55 -0
  161. package/dist/run/cost.d.ts.map +1 -1
  162. package/dist/run/cost.js +1 -1
  163. package/dist/run/dispatch.d.ts +99 -0
  164. package/dist/run/dispatch.d.ts.map +1 -0
  165. package/dist/run/dispatch.js +191 -0
  166. package/dist/run/raw.d.ts +130 -0
  167. package/dist/run/raw.d.ts.map +1 -0
  168. package/dist/run/raw.js +363 -0
  169. package/dist/run/record-attempt.d.ts +40 -0
  170. package/dist/run/record-attempt.d.ts.map +1 -0
  171. package/dist/run/record-attempt.js +99 -0
  172. package/dist/run/resolve.d.ts +75 -2
  173. package/dist/run/resolve.d.ts.map +1 -1
  174. package/dist/run/resolve.js +126 -4
  175. package/dist/run/run.d.ts +14 -0
  176. package/dist/run/run.d.ts.map +1 -1
  177. package/dist/run/run.js +0 -0
  178. package/dist/run/stream.d.ts +49 -0
  179. package/dist/run/stream.d.ts.map +1 -0
  180. package/dist/run/stream.js +87 -0
  181. package/dist/run/validate.d.ts.map +1 -1
  182. package/dist/run/validate.js +6 -7
  183. package/dist/savings/cache-ledger.d.ts +108 -0
  184. package/dist/savings/cache-ledger.d.ts.map +1 -0
  185. package/dist/savings/cache-ledger.js +174 -0
  186. package/dist/savings/cache-reconcile.d.ts +64 -0
  187. package/dist/savings/cache-reconcile.d.ts.map +1 -0
  188. package/dist/savings/cache-reconcile.js +59 -0
  189. package/dist/savings/cache-stats.d.ts +63 -0
  190. package/dist/savings/cache-stats.d.ts.map +1 -0
  191. package/dist/savings/cache-stats.js +108 -0
  192. package/dist/savings/emit.d.ts +13 -0
  193. package/dist/savings/emit.d.ts.map +1 -1
  194. package/dist/savings/emit.js +25 -0
  195. package/dist/savings/swap-execute.d.ts +14 -0
  196. package/dist/savings/swap-execute.d.ts.map +1 -1
  197. package/dist/savings/swap-execute.js +44 -1
  198. package/dist/savings/swaps-client.d.ts +14 -0
  199. package/dist/savings/swaps-client.d.ts.map +1 -1
  200. package/dist/savings/swaps-client.js +16 -2
  201. package/dist/settings/api-fetcher.d.ts +39 -0
  202. package/dist/settings/api-fetcher.d.ts.map +1 -0
  203. package/dist/settings/api-fetcher.js +92 -0
  204. package/dist/settings/index.d.ts +10 -0
  205. package/dist/settings/index.d.ts.map +1 -0
  206. package/dist/settings/index.js +15 -0
  207. package/dist/settings/task-settings.d.ts +91 -0
  208. package/dist/settings/task-settings.d.ts.map +1 -0
  209. package/dist/settings/task-settings.js +116 -0
  210. package/dist/status.d.ts +77 -0
  211. package/dist/status.d.ts.map +1 -0
  212. package/dist/status.js +113 -0
  213. package/dist/telemetry/artifact-store.d.ts +48 -0
  214. package/dist/telemetry/artifact-store.d.ts.map +1 -0
  215. package/dist/telemetry/artifact-store.js +189 -0
  216. package/dist/telemetry/cache-miss-streak.d.ts +79 -0
  217. package/dist/telemetry/cache-miss-streak.d.ts.map +1 -0
  218. package/dist/telemetry/cache-miss-streak.js +99 -0
  219. package/dist/telemetry/capture.d.ts +3 -0
  220. package/dist/telemetry/capture.d.ts.map +1 -1
  221. package/dist/telemetry/capture.js +15 -8
  222. package/dist/telemetry/exporter-setup.d.ts +28 -0
  223. package/dist/telemetry/exporter-setup.d.ts.map +1 -0
  224. package/dist/telemetry/exporter-setup.js +34 -0
  225. package/dist/telemetry/exporter.d.ts +75 -0
  226. package/dist/telemetry/exporter.d.ts.map +1 -1
  227. package/dist/telemetry/exporter.js +324 -47
  228. package/dist/telemetry/health.d.ts +76 -0
  229. package/dist/telemetry/health.d.ts.map +1 -0
  230. package/dist/telemetry/health.js +92 -0
  231. package/dist/telemetry/ingest-protocol.d.ts +152 -3
  232. package/dist/telemetry/ingest-protocol.d.ts.map +1 -1
  233. package/dist/telemetry/ingest-protocol.js +204 -4
  234. package/dist/telemetry/load-error-report.d.ts +24 -0
  235. package/dist/telemetry/load-error-report.d.ts.map +1 -0
  236. package/dist/telemetry/load-error-report.js +50 -0
  237. package/dist/telemetry/otel-map.d.ts +121 -0
  238. package/dist/telemetry/otel-map.d.ts.map +1 -0
  239. package/dist/telemetry/otel-map.js +224 -0
  240. package/dist/telemetry/otel-normalize.d.ts +104 -0
  241. package/dist/telemetry/otel-normalize.d.ts.map +1 -0
  242. package/dist/telemetry/otel-normalize.js +530 -0
  243. package/dist/telemetry/otlp-emitter.d.ts +52 -0
  244. package/dist/telemetry/otlp-emitter.d.ts.map +1 -0
  245. package/dist/telemetry/otlp-emitter.js +144 -0
  246. package/dist/telemetry/otlp-proto.d.ts +29 -0
  247. package/dist/telemetry/otlp-proto.d.ts.map +1 -0
  248. package/dist/telemetry/otlp-proto.js +266 -0
  249. package/dist/telemetry/sinks.d.ts +37 -1
  250. package/dist/telemetry/sinks.d.ts.map +1 -1
  251. package/dist/telemetry/sinks.js +121 -30
  252. package/dist/telemetry/store.d.ts +28 -1
  253. package/dist/telemetry/store.d.ts.map +1 -1
  254. package/dist/telemetry/store.js +218 -3
  255. package/dist/tenancy/api-key-format.d.ts +15 -5
  256. package/dist/tenancy/api-key-format.d.ts.map +1 -1
  257. package/dist/tenancy/api-key-format.js +24 -5
  258. package/dist/types/config-teaching.d.ts +62 -0
  259. package/dist/types/config-teaching.d.ts.map +1 -0
  260. package/dist/types/config-teaching.js +183 -0
  261. package/dist/types/provider.d.ts +147 -1
  262. package/dist/types/provider.d.ts.map +1 -1
  263. package/dist/types/provider.js +21 -1
  264. package/dist/types/route.d.ts +79 -1
  265. package/dist/types/route.d.ts.map +1 -1
  266. package/dist/types/telemetry.d.ts +117 -0
  267. package/dist/types/telemetry.d.ts.map +1 -1
  268. package/dist/validate-cli.d.ts +12 -0
  269. package/dist/validate-cli.d.ts.map +1 -0
  270. package/dist/validate-cli.js +57 -0
  271. package/dist/verify/capture.d.ts +66 -0
  272. package/dist/verify/capture.d.ts.map +1 -0
  273. package/dist/verify/capture.js +180 -0
  274. package/dist/verify/cli-run.d.ts +23 -0
  275. package/dist/verify/cli-run.d.ts.map +1 -0
  276. package/dist/verify/cli-run.js +57 -0
  277. package/dist/verify/diff.d.ts +48 -0
  278. package/dist/verify/diff.d.ts.map +1 -0
  279. package/dist/verify/diff.js +157 -0
  280. package/dist/verify/index.d.ts +17 -0
  281. package/dist/verify/index.d.ts.map +1 -0
  282. package/dist/verify/index.js +24 -0
  283. package/dist/verify/report.d.ts +14 -0
  284. package/dist/verify/report.d.ts.map +1 -0
  285. package/dist/verify/report.js +88 -0
  286. package/dist/verify/types.d.ts +101 -0
  287. package/dist/verify/types.d.ts.map +1 -0
  288. package/dist/verify/types.js +17 -0
  289. package/dist/verify/verify.d.ts +29 -0
  290. package/dist/verify/verify.d.ts.map +1 -0
  291. package/dist/verify/verify.js +148 -0
  292. package/dist/watch/evaluate.d.ts +162 -3
  293. package/dist/watch/evaluate.d.ts.map +1 -1
  294. package/dist/watch/evaluate.js +61 -0
  295. package/dist/watch/monitor.d.ts +116 -0
  296. package/dist/watch/monitor.d.ts.map +1 -0
  297. package/dist/watch/monitor.js +199 -0
  298. package/dist/watch/proposals.d.ts +20 -4
  299. package/dist/watch/proposals.d.ts.map +1 -1
  300. package/dist/watch/proposals.js +31 -3
  301. package/dist/watch/run.d.ts +33 -0
  302. package/dist/watch/run.d.ts.map +1 -1
  303. package/dist/watch/run.js +39 -0
  304. package/package.json +7 -1
  305. package/registry/LICENSE +20 -0
  306. package/registry/leaderboard.json +3639 -0
  307. package/registry/registry.json +7263 -0
  308. package/dist/telemetry/supabase-exporter.d.ts +0 -64
  309. package/dist/telemetry/supabase-exporter.d.ts.map +0 -1
  310. package/dist/telemetry/supabase-exporter.js +0 -211
package/CHANGELOG.md ADDED
@@ -0,0 +1,158 @@
1
+ # Changelog
2
+
3
+ All notable changes to the `modelrig` npm package are recorded here. The public
4
+ surface is one thing with two halves — this package and the docs/registry site
5
+ at [modelrig.dev](https://modelrig.dev). They ship together under one release
6
+ ceremony (see `docs/ModelRig/oss-publish-policy.md`, §6). The generated docs
7
+ carry an "as of modelrig vX.Y.Z" stamp so a reader can see when the docs and the
8
+ published package diverge.
9
+
10
+ This project adheres to [Semantic Versioning](https://semver.org/). Dates are
11
+ UTC.
12
+
13
+ ## [0.3.0] — 2026-08-21
14
+
15
+ The `modelrig-oracle` MCP server ships to npm alongside this release (its own
16
+ package, 0.1.0) — `npx modelrig-oracle` now works as the docs describe.
17
+
18
+ CE-2 raw-lane parity — three new provider knobs on `rig.runRaw` /
19
+ `rig.runRawStream` (and the OpenAI-compatible `/v1/chat/completions` raw lane),
20
+ so the Lane-B report-pipeline seam (`callProvider` → `rig.runRaw`) can swap
21
+ behaviour-identically. Every knob is ADDITIVE: absent ⇒ byte-identical to the
22
+ 0.2.0 request shape.
23
+
24
+ ### Added — `RawRunInput` (all additive, absent ⇒ byte-identical)
25
+
26
+ - **`grounding?: { mode: "native" }`** — native provider web grounding on the
27
+ raw lane (F1). Maps to the adapter's native-grounding directive (gemini →
28
+ the `googleSearch` tool). GEMINI-ONLY in v1: declared on any other provider
29
+ throws `RigFailureError` with class `invariant_violation` PRE-DISPATCH (no
30
+ meter, no provider call, no telemetry row). Interplay with `cache.key` needs
31
+ no code — the gemini `cachedContent` path excludes tools by design (the
32
+ `googleSearch` tool is expected to be baked into the customer's cache resource
33
+ at creation).
34
+ - **`serviceTier?: "standard" | "flex" | "priority"`** — service tier on the raw
35
+ lane (F2). Forwarded to the adapter's tier path; `RunMeta.requestedTier` now
36
+ reports the DECLARED tier (previously hardcoded `"standard"` — an honesty fix).
37
+ ModelRig does NOT degrade flex→standard on the raw lane; a capacity rejection
38
+ surfaces classified (`capacity_shed`) for the customer's own retry ladder.
39
+ - **`reasoning?: { level: "minimal" | "low" | "medium" | "high" }`** —
40
+ provider-neutral reasoning/thinking effort (F3). Gemini maps `level` to
41
+ `thinkingConfig.thinkingLevel` (replacing the hardcoded `"high"`). GEMINI-ONLY
42
+ in v1: declared on another provider throws `invariant_violation` pre-dispatch;
43
+ declared on a non-thinking-capable gemini model is rejected classified by the
44
+ adapter (never a silent drop, never an unguarded provider 400).
45
+
46
+ ### Added — `AdapterRequest`
47
+
48
+ - **`reasoning?: ReasoningParams`** (+ exported `ReasoningParams` /
49
+ `ReasoningLevel` types) — the provider-neutral reasoning shape adapters map to
50
+ their native field.
51
+
52
+ ### Added — HTTP gateway (`/v1/chat/completions`, raw lane only)
53
+
54
+ - Top-level OpenAI-standard `temperature` / `top_p` / `max_tokens` /
55
+ `service_tier` are now forwarded onto the raw lane (the open CE-6 co-item);
56
+ `modelrig.grounding` / `modelrig.reasoning` ride in the `modelrig` body object.
57
+ A malformed `grounding.mode` / `reasoning.level` is a teaching 4xx. The SLUG
58
+ lane still ignores all generation params (the verified route owns them).
59
+
60
+ ### Added — route loader
61
+
62
+ - Load-time WARN when a route's output schema has an ARRAY root — OpenAI strict
63
+ structured output requires a top-level object, so an array-root schema cannot
64
+ use strict enforcement on OpenAI candidates (the A5 co-item). The route still
65
+ loads and serves as declared.
66
+
67
+ ### Confirmed (already true on 0.2.0, now pinned by regression tests)
68
+
69
+ - **F5** — an invalid/evicted customer `cache.key` on the raw lane surfaces as a
70
+ thrown `RigFailureError` with `.failure.class === "cache_invalid"`; the raw
71
+ lane is single-dispatch, so a silent un-cached retry is structurally
72
+ impossible.
73
+ - **F6** — success `RunMeta` carries `servedTier` / `tokensCached` / `latencyMs`
74
+ (and provider/model/cost); a per-attempt failure's class + provider/model
75
+ travel on the thrown error's `.failure`.
76
+
77
+ ## [0.2.0] — unreleased (staged for the R-A ceremony)
78
+
79
+ - Ships the probed capability registry and leaderboard (`registry/registry.json`, `registry/leaderboard.json`) so a clean install routes on the probed profile instead of the static fallback (R-1 F2 ruling). The `modelrig-oracle` MCP server remains unreleased and is flagged as such in the docs.
80
+
81
+ `0.1.0` was frozen on 2026-08-07 and shipped **dist-only** (`files: [dist,
82
+ README, LICENSE]`). The SDK grew a large public surface across the following six
83
+ weeks while the published artifact stood still, and one runtime dependency —
84
+ `data/` — was never in the tarball at all. This release makes the published
85
+ package match the workspace and self-tests that it does.
86
+
87
+ ### Fixed — packaging (the reason for this release)
88
+
89
+ - **`data/` now ships.** `getPricing()` reads `data/pricing-map.json` (and the
90
+ optional `data/pricing-overlay.json`) from the package root at runtime, with
91
+ no `existsSync` guard — so on `0.1.0` the very first cost lookup threw
92
+ `ENOENT` on a clean `npm i modelrig`, breaking the flagship "effective cost"
93
+ story out of the box. `data` is now in the `files` allowlist. It is public
94
+ pricing data (CC BY 4.0; see `data/PROVENANCE.md`), safe to distribute.
95
+ - **Regression pinned forever.** A new hermetic test (`npm pack` → install the
96
+ tarball into a temp dir → load the *installed* package) asserts
97
+ `getPricing()` returns a real rate and the `modelrig` bin runs. Packaging
98
+ breaks are now caught before publish, not by a customer.
99
+ - **`modelrig --help` / `-h` / `help` exit 0** with usage on stdout (was: fell
100
+ through to the unknown-command path and exited 1).
101
+
102
+ ### Added — public API surface accumulated since 0.1.0
103
+
104
+ None of the below existed in the published `0.1.0`; instructions written for the
105
+ current docs failed against it with missing exports. They are all in this tag:
106
+
107
+ - **Inspectable artifact store** — the `artifacts` namespace (runs → steps →
108
+ artifacts, lineaged and integrity-hashed), `resolveArtifactsConfig`,
109
+ per-artifact and per-run evaluation (`artifact.evaluate` / `run.evaluate`).
110
+ - **Run verdicts** — the automatic deterministic `run-outcome@v1` on every run,
111
+ the explicit bounded model judge `run-judge@v1` (`modelrig judge <runId>`),
112
+ and the feedback protocol (`rig.feedback`, `POST /v1/feedback`,
113
+ `computeCoverage`).
114
+ - **Cache accounting & routing** — cache-aware `estimateCostUsd` (cache-read
115
+ and cache-write buckets), `effectiveInputRate` / `classifyCacheVerdict`, the
116
+ `cache: auto` route directive with the miss-streak alert, and the customer
117
+ cache-handle pass-through `rig.run(task, { input, cache: { key, provider } })`
118
+ / `rig.runRaw({ …, cache: { key } })` (CE-1) — the customer owns the TTL
119
+ heartbeat; ModelRig never creates, refreshes, or deletes the resource.
120
+ - **Observe / init (T0–T2)** — `modelrig observe` (scaffold the record-step seam
121
+ behind `MODELRIG_ARTIFACTS=1`, no route migration), `modelrig init --scope`
122
+ (draft a route bundle per call site), `modelrig validate` (keyless structural
123
+ check of `rig.yaml` + every bundle), and `modelrig verify-swap`
124
+ (shadow-equivalence report for a same-model swap).
125
+ - **Route sampling params (CE-6)** — `policy.sampling: { temperature?, top_p?,
126
+ max_output_tokens? }` on a route, validated at load and sent to the provider
127
+ as declared; a sub-1.0 temperature on a Gemini-3 candidate loads with a
128
+ load-time advisory. **This is in the tag.**
129
+ - **OTLP ingest** — bring your own traces (`normalizeOtlpTraces`,
130
+ `startOtlpEmitterIfConfigured`, the OTel semantic-convention map).
131
+ - **Raw lane** (`runRaw` / `runRawStream`), streaming (`runStream`), the
132
+ grounding-inject rung, the `openai-compat` adapter host, and the Anthropic /
133
+ Grok adapters.
134
+ - **Bake-offs & the optimization loop** — `runBakeoff`, `replayVariant`,
135
+ `computeProposal`, the Wilson-interval stats, the swap ledger + verified-
136
+ savings odometer, and the scheduled Rig Analyst Insights surface.
137
+
138
+ ### Fixed — behaviour
139
+
140
+ - **H1 close-drain.** `rig.close()` now resolves only after the exporter's final
141
+ flush drains and after the artifacts streams drain (stores close last), so a
142
+ one-shot CLI or a serverless per-invocation `close()` can no longer lose the
143
+ last rows. One-shot callers **must** `await rig.close()`.
144
+
145
+ ### Notes
146
+
147
+ - Requires **Node ≥ 20**. Installs a native module (`better-sqlite3`), so the
148
+ machine needs a build toolchain. Assumes a long-lived process with a writable
149
+ disk; serverless and edge callers: see the Runtime requirements section of the
150
+ [quickstart](https://modelrig.dev/quickstart.html).
151
+ - Route output schemas validate under **JSON Schema 2020-12** (primary), with
152
+ **draft-07** also accepted. See the quickstart / route-bundles reference.
153
+
154
+ ## [0.1.0] — 2026-08-07
155
+
156
+ Initial public release: capability-aware gateway, routes-as-code, provider
157
+ adapters (Gemini / OpenAI / DeepSeek), typed failures, budget envelopes, and
158
+ local-first SQLite telemetry.
package/README.md CHANGED
@@ -32,25 +32,28 @@ This runs with **only a provider key** — no account, no signup.
32
32
  export GEMINI_API_KEY=... # or OPENAI_API_KEY, ANTHROPIC_API_KEY, …
33
33
  ```
34
34
 
35
- **2. Define a route** at `modelrig/routes/research.growth_scenarios.yaml`:
35
+ **2. Define a route** at `modelrig/routes/example.support_summarize.yaml` (the
36
+ example the package ships, in `modelrig/routes/`):
36
37
 
37
38
  ```yaml
38
- route: research.growth_scenarios
39
+ route: example.support_summarize
39
40
  version: 1
40
- schema: ./schemas/growth_scenarios.schema.json # JSON Schema for the output
41
+ schema: ./schemas/support_summarize.schema.json # JSON Schema (2020-12 recommended; draft-07 still accepted)
41
42
  candidates: # THE candidate set — nothing else can serve
42
- - provider: gemini
43
- model: gemini-3.1-pro-preview
44
43
  - provider: openai
45
44
  model: gpt-5.4-mini
45
+ - provider: gemini
46
+ model: gemini-3.1-flash-lite
47
+ - provider: deepseek
48
+ model: deepseek-chat
46
49
  require: [schema_conformant]
47
50
  prefer: [cost]
48
51
  prompt:
49
- system: ./prompts/growth_scenarios.system.md # {{var}} + {{#if capability.X}} blocks
50
- variables: [ticker, financials, priorSteps]
52
+ system: ./prompts/support_summarize.system.md # {{var}} + {{#if capability.X}} blocks
53
+ variables: [ticket, product, priorContext]
51
54
  policy:
52
55
  retries: { content_invalid: 2, network: 4, capacity_shed: 3 }
53
- timeout_ms: 300000
56
+ timeout_ms: 60000
54
57
  tier: flex
55
58
  json: native
56
59
  ```
@@ -61,9 +64,9 @@ policy:
61
64
  import { createRig, loadConfigFromEnv } from "modelrig";
62
65
 
63
66
  const rig = createRig(loadConfigFromEnv()); // keys from GEMINI_API_KEY etc.
64
- const result = await rig.run("research.growth_scenarios", {
65
- input: { ticker, financials, priorSteps }, // template variables
66
- tags: { run_id, step: "growth_scenarios", ticker },
67
+ const result = await rig.run("example.support_summarize", {
68
+ input: { ticket, product, priorContext }, // template variables
69
+ tags: { run_id, step: "summarize" },
67
70
  budget: { envelope: run_id }, // hard-stop cost envelope
68
71
  });
69
72
  // result.output — schema-validated JSON (ajv), regardless of serving model
@@ -72,6 +75,45 @@ const result = await rig.run("research.growth_scenarios", {
72
75
  rig.close();
73
76
  ```
74
77
 
78
+ **Data-governance routing (opt-in).** Add `zero_retention` to a route's
79
+ `require`, or pass `zeroRetention: true` on a single `rig.run(...)` call, to
80
+ route only to zero-retention–designated endpoints. It is a hard, opt-in filter
81
+ that fails closed: if no candidate is designated zero-retention, the run raises
82
+ the no-eligible-candidate error rather than dispatching to a retaining endpoint.
83
+ (Capability gating is on by default here — unlike OpenRouter's opt-in
84
+ `require_parameters`.)
85
+
86
+ **Request-time routing controls (opt-in).** A single `rig.run(...)` call can
87
+ narrow the candidate set: `maxPriceUsdPerMTok` drops any model over a price
88
+ ceiling (unknown price + a ceiling → dropped, fail-closed), and
89
+ `providers: { only, ignore }` restricts or excludes providers. `maxPrice` is a
90
+ candidate *filter* (which models are eligible) — distinct from `budget.envelope`,
91
+ which is a *spend cap* on the run's total cost; both compose, both fail closed on
92
+ unpriced models.
93
+
94
+ **Customer cache handle (opt-in).** If your code already engineered provider
95
+ caching, carry it through: `rig.run(task, { input, cache: { key, provider } })`
96
+ passes a customer-owned cache identifier (a Gemini `cachedContents/<id>`, or a
97
+ `prompt_cache_key` value) verbatim to the matching-provider candidate. It wins
98
+ over the route's `cache: auto` stamp, and a non-matching fallback dispatches
99
+ without it. ModelRig carries the handle and prices the hits — it never creates,
100
+ refreshes, or deletes the resource, so a long job needs your own TTL heartbeat
101
+ (see the [caching lifecycle](https://modelrig.dev/caching-lifecycle.html) doc).
102
+ The Lane-B `rig.runRaw({ provider, model, …, cache: { key } })` seam takes the
103
+ same field.
104
+
105
+ `rig.runRaw` also accepts
106
+ three provider knobs, each additive — absent ⇒ byte-identical dispatch:
107
+ `grounding: { mode: "native" }` (native provider web grounding, gemini-only in
108
+ v1), `serviceTier: "standard" | "flex" | "priority"`, and
109
+ `reasoning: { level: "minimal" | "low" | "medium" | "high" }` (gemini-only in
110
+ v1, mapped to the thinking level). A declared directive a provider cannot honor
111
+ FAILS CLOSED — a thrown `RigFailureError` with class `invariant_violation`,
112
+ pre-dispatch (no meter, no provider call) — never a silent drop. A grounded step
113
+ that also passes a `cache.key` keeps its cached-token ratio: bake the
114
+ `googleSearch` tool into the cache resource at creation (ModelRig sends
115
+ `cachedContent` without tools, which the provider requires).
116
+
75
117
  Every attempt is recorded in a local SQLite file (`.modelrig/telemetry.db`)
76
118
  tagged with your `tags`. Failures are typed —
77
119
  `RigFailureError.failure.class` is one of `content_invalid`, `capacity_shed`,
@@ -0,0 +1,19 @@
1
+ # data/pricing-map.json — provenance
2
+
3
+ Copied manually from `vendor/litellm-upstream/model_prices_and_context_window.json`
4
+ at the pinned SHA recorded in `upstream/litellm.pin.json` (`de706a35a6`, pinned
5
+ 2026-07-30). 2,986 model entries at time of copy.
6
+
7
+ Source: LiteLLM (https://github.com/BerriAI/litellm),
8
+ Copyright (c) 2023 Berri AI, MIT License.
9
+
10
+ NOTE (Phase 0 gap): the automated extraction script (`scripts/sync-upstream.ts`
11
+ with provenance header + diff output) was not built before Phase 1 started, so
12
+ this snapshot was copied by hand per implementation-plan §9. Replace this manual
13
+ copy with the sync script's output when Phase 0 tooling lands; until then, any
14
+ pin bump must re-copy this file and update this note.
15
+
16
+ Key naming (verified against the snapshot):
17
+ - Gemini API models: `gemini/<model>` (bare ids resolve to vertex_ai pricing — do not use)
18
+ - OpenAI models: bare `<model>`
19
+ - DeepSeek models: `deepseek/<model>` (bare ids also present)
@@ -0,0 +1,22 @@
1
+ {
2
+ "_provenance": {
3
+ "role": "Website-sourced per-token prices for hosts that do not expose pricing via an API our key can read (today: Fireworks — its /models listing rejects an inference-scoped key). Hand-read from the vendor's public model page, each entry carrying its source URL + read date. Merged into pricing-overlay.json by scripts/pricing-sweep.ts alongside the API-swept prices; both are gap-fillers beneath the pinned LiteLLM snapshot (snapshot wins on shared keys). Replace an entry here with an API/scraper adapter when one exists.",
4
+ "note": "Flat prices (input_cost_per_token / output / cache_read) are the BASE serverless standard rate. Serving-tier multipliers (Fireworks: +25% priority, +50% fast, +10% US-only) are now carried in the additive `pricing_v2` block (pricing-first-class spec) as MULTIPLIERS on base (1.25 / 1.5 / 1.1). Context-length/batch/modality bands are still uncaptured for this model and are absent (not guessed). The flat fields stay for backward compatibility."
5
+ },
6
+ "prices": {
7
+ "fireworks_ai/accounts/fireworks/models/kimi-k3": {
8
+ "input_cost_per_token": 3.0e-6,
9
+ "output_cost_per_token": 1.5e-5,
10
+ "cache_read_input_token_cost": 3.0e-7,
11
+ "source": "fireworks-website:https://fireworks.ai/models/fireworks/kimi-k3 (base serverless standard; +25% priority / +50% fast / +10% US-only)",
12
+ "as_of": "2026-08-09",
13
+ "pricing_v2": {
14
+ "base": { "input": 3.0e-6, "output": 1.5e-5, "cache_read": 3.0e-7 },
15
+ "tiers": { "priority": 1.25, "fast": 1.5, "region_us": 1.1 },
16
+ "source": "fireworks-website:https://fireworks.ai/models/fireworks/kimi-k3",
17
+ "as_of": "2026-08-09",
18
+ "basis": "base serverless · standard tier · text"
19
+ }
20
+ }
21
+ }
22
+ }