modelrig 0.0.1 → 0.2.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 (420) hide show
  1. package/CHANGELOG.md +94 -0
  2. package/LICENSE +201 -0
  3. package/README.md +145 -8
  4. package/data/PROVENANCE.md +19 -0
  5. package/data/pricing-manual.json +22 -0
  6. package/data/pricing-map.json +46362 -0
  7. package/data/pricing-overlay.json +419 -0
  8. package/dist/adapters/anthropic.d.ts +90 -0
  9. package/dist/adapters/anthropic.d.ts.map +1 -0
  10. package/dist/adapters/anthropic.js +296 -0
  11. package/dist/adapters/build-adapters.d.ts +11 -0
  12. package/dist/adapters/build-adapters.d.ts.map +1 -0
  13. package/dist/adapters/build-adapters.js +45 -0
  14. package/dist/adapters/deepseek.d.ts +47 -0
  15. package/dist/adapters/deepseek.d.ts.map +1 -0
  16. package/dist/adapters/deepseek.js +216 -0
  17. package/dist/adapters/gemini.d.ts +44 -0
  18. package/dist/adapters/gemini.d.ts.map +1 -0
  19. package/dist/adapters/gemini.js +262 -0
  20. package/dist/adapters/grok.d.ts +53 -0
  21. package/dist/adapters/grok.d.ts.map +1 -0
  22. package/dist/adapters/grok.js +232 -0
  23. package/dist/adapters/openai-compat.d.ts +80 -0
  24. package/dist/adapters/openai-compat.d.ts.map +1 -0
  25. package/dist/adapters/openai-compat.js +244 -0
  26. package/dist/adapters/openai-stream.d.ts +58 -0
  27. package/dist/adapters/openai-stream.d.ts.map +1 -0
  28. package/dist/adapters/openai-stream.js +120 -0
  29. package/dist/adapters/openai.d.ts +55 -0
  30. package/dist/adapters/openai.d.ts.map +1 -0
  31. package/dist/adapters/openai.js +281 -0
  32. package/dist/adapters/sampling.d.ts +28 -0
  33. package/dist/adapters/sampling.d.ts.map +1 -0
  34. package/dist/adapters/sampling.js +34 -0
  35. package/dist/adapters/tool-mapping.d.ts +92 -0
  36. package/dist/adapters/tool-mapping.d.ts.map +1 -0
  37. package/dist/adapters/tool-mapping.js +143 -0
  38. package/dist/artifacts/artifact.d.ts +137 -0
  39. package/dist/artifacts/artifact.d.ts.map +1 -0
  40. package/dist/artifacts/artifact.js +377 -0
  41. package/dist/artifacts/content-uploader.d.ts +87 -0
  42. package/dist/artifacts/content-uploader.d.ts.map +1 -0
  43. package/dist/artifacts/content-uploader.js +124 -0
  44. package/dist/artifacts/index.d.ts +63 -0
  45. package/dist/artifacts/index.d.ts.map +1 -0
  46. package/dist/artifacts/index.js +80 -0
  47. package/dist/artifacts/run-context.d.ts +129 -0
  48. package/dist/artifacts/run-context.d.ts.map +1 -0
  49. package/dist/artifacts/run-context.js +208 -0
  50. package/dist/artifacts/scrub.d.ts +60 -0
  51. package/dist/artifacts/scrub.d.ts.map +1 -0
  52. package/dist/artifacts/scrub.js +139 -0
  53. package/dist/artifacts/step.d.ts +26 -0
  54. package/dist/artifacts/step.d.ts.map +1 -0
  55. package/dist/artifacts/step.js +37 -0
  56. package/dist/artifacts/taint.d.ts +63 -0
  57. package/dist/artifacts/taint.d.ts.map +1 -0
  58. package/dist/artifacts/taint.js +76 -0
  59. package/dist/bakeoff/cache-sim.d.ts +99 -0
  60. package/dist/bakeoff/cache-sim.d.ts.map +1 -0
  61. package/dist/bakeoff/cache-sim.js +126 -0
  62. package/dist/bakeoff/engine.d.ts +52 -0
  63. package/dist/bakeoff/engine.d.ts.map +1 -0
  64. package/dist/bakeoff/engine.js +163 -0
  65. package/dist/bakeoff/eval-cases.d.ts +96 -0
  66. package/dist/bakeoff/eval-cases.d.ts.map +1 -0
  67. package/dist/bakeoff/eval-cases.js +105 -0
  68. package/dist/bakeoff/replay.d.ts +52 -0
  69. package/dist/bakeoff/replay.d.ts.map +1 -0
  70. package/dist/bakeoff/replay.js +94 -0
  71. package/dist/bakeoff/report.d.ts +41 -0
  72. package/dist/bakeoff/report.d.ts.map +1 -0
  73. package/dist/bakeoff/report.js +142 -0
  74. package/dist/bakeoff/samples.d.ts +77 -0
  75. package/dist/bakeoff/samples.d.ts.map +1 -0
  76. package/dist/bakeoff/samples.js +148 -0
  77. package/dist/bakeoff/stats.d.ts +13 -0
  78. package/dist/bakeoff/stats.d.ts.map +1 -0
  79. package/dist/bakeoff/stats.js +48 -0
  80. package/dist/bakeoff/types.d.ts +37 -0
  81. package/dist/bakeoff/types.d.ts.map +1 -0
  82. package/dist/bakeoff/types.js +10 -0
  83. package/dist/cli.d.ts +25 -0
  84. package/dist/cli.d.ts.map +1 -0
  85. package/dist/cli.js +590 -0
  86. package/dist/config.d.ts +204 -0
  87. package/dist/config.d.ts.map +1 -0
  88. package/dist/config.js +252 -0
  89. package/dist/deprecations.d.ts +32 -0
  90. package/dist/deprecations.d.ts.map +1 -0
  91. package/dist/deprecations.js +59 -0
  92. package/dist/feedback/coverage.d.ts +32 -0
  93. package/dist/feedback/coverage.d.ts.map +1 -0
  94. package/dist/feedback/coverage.js +95 -0
  95. package/dist/feedback/feedback.d.ts +35 -0
  96. package/dist/feedback/feedback.d.ts.map +1 -0
  97. package/dist/feedback/feedback.js +39 -0
  98. package/dist/gateway/http-protocol.d.ts +175 -0
  99. package/dist/gateway/http-protocol.d.ts.map +1 -0
  100. package/dist/gateway/http-protocol.js +105 -0
  101. package/dist/index.d.ts +242 -0
  102. package/dist/index.d.ts.map +1 -0
  103. package/dist/index.js +576 -0
  104. package/dist/init/finder.d.ts +94 -0
  105. package/dist/init/finder.d.ts.map +1 -0
  106. package/dist/init/finder.js +343 -0
  107. package/dist/init/init-cli.d.ts +10 -0
  108. package/dist/init/init-cli.d.ts.map +1 -0
  109. package/dist/init/init-cli.js +86 -0
  110. package/dist/init/observe-cli.d.ts +19 -0
  111. package/dist/init/observe-cli.d.ts.map +1 -0
  112. package/dist/init/observe-cli.js +73 -0
  113. package/dist/init/observe.d.ts +81 -0
  114. package/dist/init/observe.d.ts.map +1 -0
  115. package/dist/init/observe.js +245 -0
  116. package/dist/init/run.d.ts +99 -0
  117. package/dist/init/run.d.ts.map +1 -0
  118. package/dist/init/run.js +281 -0
  119. package/dist/init/signatures.d.ts +39 -0
  120. package/dist/init/signatures.d.ts.map +1 -0
  121. package/dist/init/signatures.js +116 -0
  122. package/dist/matrix/aggregate.d.ts +89 -0
  123. package/dist/matrix/aggregate.d.ts.map +1 -0
  124. package/dist/matrix/aggregate.js +186 -0
  125. package/dist/query/grammar.d.ts +35 -0
  126. package/dist/query/grammar.d.ts.map +1 -0
  127. package/dist/query/grammar.js +279 -0
  128. package/dist/query/run.d.ts +8 -0
  129. package/dist/query/run.d.ts.map +1 -0
  130. package/dist/query/run.js +21 -0
  131. package/dist/registry/build.d.ts +219 -0
  132. package/dist/registry/build.d.ts.map +1 -0
  133. package/dist/registry/build.js +313 -0
  134. package/dist/registry/cache-policy.d.ts +94 -0
  135. package/dist/registry/cache-policy.d.ts.map +1 -0
  136. package/dist/registry/cache-policy.js +238 -0
  137. package/dist/registry/call-notes.d.ts +11 -0
  138. package/dist/registry/call-notes.d.ts.map +1 -0
  139. package/dist/registry/call-notes.js +110 -0
  140. package/dist/registry/claims.d.ts +63 -0
  141. package/dist/registry/claims.d.ts.map +1 -0
  142. package/dist/registry/claims.js +107 -0
  143. package/dist/registry/effective-rate.d.ts +151 -0
  144. package/dist/registry/effective-rate.d.ts.map +1 -0
  145. package/dist/registry/effective-rate.js +156 -0
  146. package/dist/registry/facts.d.ts +32 -0
  147. package/dist/registry/facts.d.ts.map +1 -0
  148. package/dist/registry/facts.js +136 -0
  149. package/dist/registry/fingerprint.d.ts +20 -0
  150. package/dist/registry/fingerprint.d.ts.map +1 -0
  151. package/dist/registry/fingerprint.js +150 -0
  152. package/dist/registry/parity.d.ts +52 -0
  153. package/dist/registry/parity.d.ts.map +1 -0
  154. package/dist/registry/parity.js +82 -0
  155. package/dist/registry/pricing-shape.d.ts +113 -0
  156. package/dist/registry/pricing-shape.d.ts.map +1 -0
  157. package/dist/registry/pricing-shape.js +123 -0
  158. package/dist/registry/pricing.d.ts +43 -0
  159. package/dist/registry/pricing.d.ts.map +1 -0
  160. package/dist/registry/pricing.js +127 -0
  161. package/dist/registry/rows.d.ts +16 -0
  162. package/dist/registry/rows.d.ts.map +1 -0
  163. package/dist/registry/rows.js +57 -0
  164. package/dist/registry/seed.d.ts +43 -0
  165. package/dist/registry/seed.d.ts.map +1 -0
  166. package/dist/registry/seed.js +97 -0
  167. package/dist/registry/select.d.ts +68 -0
  168. package/dist/registry/select.d.ts.map +1 -0
  169. package/dist/registry/select.js +141 -0
  170. package/dist/registry/staleness.d.ts +18 -0
  171. package/dist/registry/staleness.d.ts.map +1 -0
  172. package/dist/registry/staleness.js +39 -0
  173. package/dist/rigindex/bootstrap.d.ts +36 -0
  174. package/dist/rigindex/bootstrap.d.ts.map +1 -0
  175. package/dist/rigindex/bootstrap.js +97 -0
  176. package/dist/rigindex/fit.d.ts +24 -0
  177. package/dist/rigindex/fit.d.ts.map +1 -0
  178. package/dist/rigindex/fit.js +76 -0
  179. package/dist/rigindex/gates.d.ts +52 -0
  180. package/dist/rigindex/gates.d.ts.map +1 -0
  181. package/dist/rigindex/gates.js +109 -0
  182. package/dist/rigindex/graph.d.ts +31 -0
  183. package/dist/rigindex/graph.d.ts.map +1 -0
  184. package/dist/rigindex/graph.js +120 -0
  185. package/dist/rigindex/index.d.ts +23 -0
  186. package/dist/rigindex/index.d.ts.map +1 -0
  187. package/dist/rigindex/index.js +112 -0
  188. package/dist/rigindex/types.d.ts +76 -0
  189. package/dist/rigindex/types.d.ts.map +1 -0
  190. package/dist/rigindex/types.js +8 -0
  191. package/dist/routes/cache-lint.d.ts +41 -0
  192. package/dist/routes/cache-lint.d.ts.map +1 -0
  193. package/dist/routes/cache-lint.js +81 -0
  194. package/dist/routes/draft.d.ts +83 -0
  195. package/dist/routes/draft.d.ts.map +1 -0
  196. package/dist/routes/draft.js +135 -0
  197. package/dist/routes/loader.d.ts +63 -0
  198. package/dist/routes/loader.d.ts.map +1 -0
  199. package/dist/routes/loader.js +574 -0
  200. package/dist/routes/manifest.d.ts +24 -0
  201. package/dist/routes/manifest.d.ts.map +1 -0
  202. package/dist/routes/manifest.js +118 -0
  203. package/dist/routes/resolved-bundle.d.ts +79 -0
  204. package/dist/routes/resolved-bundle.d.ts.map +1 -0
  205. package/dist/routes/resolved-bundle.js +148 -0
  206. package/dist/routes/sampling-config.d.ts +32 -0
  207. package/dist/routes/sampling-config.d.ts.map +1 -0
  208. package/dist/routes/sampling-config.js +91 -0
  209. package/dist/routes/serveability.d.ts +52 -0
  210. package/dist/routes/serveability.d.ts.map +1 -0
  211. package/dist/routes/serveability.js +73 -0
  212. package/dist/routes/template.d.ts +18 -0
  213. package/dist/routes/template.d.ts.map +1 -0
  214. package/dist/routes/template.js +94 -0
  215. package/dist/run/ajv.d.ts +22 -0
  216. package/dist/run/ajv.d.ts.map +1 -0
  217. package/dist/run/ajv.js +32 -0
  218. package/dist/run/cache-handle.d.ts +58 -0
  219. package/dist/run/cache-handle.d.ts.map +1 -0
  220. package/dist/run/cache-handle.js +54 -0
  221. package/dist/run/cache-stamp.d.ts +65 -0
  222. package/dist/run/cache-stamp.d.ts.map +1 -0
  223. package/dist/run/cache-stamp.js +0 -0
  224. package/dist/run/capture-write.d.ts +33 -0
  225. package/dist/run/capture-write.d.ts.map +1 -0
  226. package/dist/run/capture-write.js +55 -0
  227. package/dist/run/cost.d.ts +26 -0
  228. package/dist/run/cost.d.ts.map +1 -0
  229. package/dist/run/cost.js +41 -0
  230. package/dist/run/dispatch.d.ts +99 -0
  231. package/dist/run/dispatch.d.ts.map +1 -0
  232. package/dist/run/dispatch.js +191 -0
  233. package/dist/run/envelope.d.ts +21 -0
  234. package/dist/run/envelope.d.ts.map +1 -0
  235. package/dist/run/envelope.js +45 -0
  236. package/dist/run/grounding.d.ts +56 -0
  237. package/dist/run/grounding.d.ts.map +1 -0
  238. package/dist/run/grounding.js +89 -0
  239. package/dist/run/raw.d.ts +88 -0
  240. package/dist/run/raw.d.ts.map +1 -0
  241. package/dist/run/raw.js +286 -0
  242. package/dist/run/record-attempt.d.ts +40 -0
  243. package/dist/run/record-attempt.d.ts.map +1 -0
  244. package/dist/run/record-attempt.js +99 -0
  245. package/dist/run/repair.d.ts +36 -0
  246. package/dist/run/repair.d.ts.map +1 -0
  247. package/dist/run/repair.js +61 -0
  248. package/dist/run/resolve.d.ts +99 -0
  249. package/dist/run/resolve.d.ts.map +1 -0
  250. package/dist/run/resolve.js +203 -0
  251. package/dist/run/retry.d.ts +19 -0
  252. package/dist/run/retry.d.ts.map +1 -0
  253. package/dist/run/retry.js +50 -0
  254. package/dist/run/run.d.ts +55 -0
  255. package/dist/run/run.d.ts.map +1 -0
  256. package/dist/run/run.js +540 -0
  257. package/dist/run/stream.d.ts +49 -0
  258. package/dist/run/stream.d.ts.map +1 -0
  259. package/dist/run/stream.js +87 -0
  260. package/dist/run/validate.d.ts +15 -0
  261. package/dist/run/validate.d.ts.map +1 -0
  262. package/dist/run/validate.js +55 -0
  263. package/dist/savings/cache-ledger.d.ts +108 -0
  264. package/dist/savings/cache-ledger.d.ts.map +1 -0
  265. package/dist/savings/cache-ledger.js +174 -0
  266. package/dist/savings/cache-reconcile.d.ts +64 -0
  267. package/dist/savings/cache-reconcile.d.ts.map +1 -0
  268. package/dist/savings/cache-reconcile.js +59 -0
  269. package/dist/savings/cache-stats.d.ts +63 -0
  270. package/dist/savings/cache-stats.d.ts.map +1 -0
  271. package/dist/savings/cache-stats.js +108 -0
  272. package/dist/savings/emit.d.ts +38 -0
  273. package/dist/savings/emit.d.ts.map +1 -0
  274. package/dist/savings/emit.js +100 -0
  275. package/dist/savings/odometer.d.ts +32 -0
  276. package/dist/savings/odometer.d.ts.map +1 -0
  277. package/dist/savings/odometer.js +70 -0
  278. package/dist/savings/swap-execute.d.ts +58 -0
  279. package/dist/savings/swap-execute.d.ts.map +1 -0
  280. package/dist/savings/swap-execute.js +130 -0
  281. package/dist/savings/swaps-client.d.ts +55 -0
  282. package/dist/savings/swaps-client.d.ts.map +1 -0
  283. package/dist/savings/swaps-client.js +95 -0
  284. package/dist/settings/api-fetcher.d.ts +39 -0
  285. package/dist/settings/api-fetcher.d.ts.map +1 -0
  286. package/dist/settings/api-fetcher.js +92 -0
  287. package/dist/settings/index.d.ts +10 -0
  288. package/dist/settings/index.d.ts.map +1 -0
  289. package/dist/settings/index.js +15 -0
  290. package/dist/settings/task-settings.d.ts +91 -0
  291. package/dist/settings/task-settings.d.ts.map +1 -0
  292. package/dist/settings/task-settings.js +116 -0
  293. package/dist/status.d.ts +77 -0
  294. package/dist/status.d.ts.map +1 -0
  295. package/dist/status.js +113 -0
  296. package/dist/telemetry/artifact-store.d.ts +48 -0
  297. package/dist/telemetry/artifact-store.d.ts.map +1 -0
  298. package/dist/telemetry/artifact-store.js +189 -0
  299. package/dist/telemetry/cache-miss-streak.d.ts +79 -0
  300. package/dist/telemetry/cache-miss-streak.d.ts.map +1 -0
  301. package/dist/telemetry/cache-miss-streak.js +99 -0
  302. package/dist/telemetry/capture.d.ts +31 -0
  303. package/dist/telemetry/capture.d.ts.map +1 -0
  304. package/dist/telemetry/capture.js +81 -0
  305. package/dist/telemetry/exporter-setup.d.ts +28 -0
  306. package/dist/telemetry/exporter-setup.d.ts.map +1 -0
  307. package/dist/telemetry/exporter-setup.js +34 -0
  308. package/dist/telemetry/exporter.d.ts +137 -0
  309. package/dist/telemetry/exporter.d.ts.map +1 -0
  310. package/dist/telemetry/exporter.js +510 -0
  311. package/dist/telemetry/health.d.ts +76 -0
  312. package/dist/telemetry/health.d.ts.map +1 -0
  313. package/dist/telemetry/health.js +92 -0
  314. package/dist/telemetry/ingest-protocol.d.ts +310 -0
  315. package/dist/telemetry/ingest-protocol.d.ts.map +1 -0
  316. package/dist/telemetry/ingest-protocol.js +363 -0
  317. package/dist/telemetry/load-error-report.d.ts +24 -0
  318. package/dist/telemetry/load-error-report.d.ts.map +1 -0
  319. package/dist/telemetry/load-error-report.js +50 -0
  320. package/dist/telemetry/otel-map.d.ts +121 -0
  321. package/dist/telemetry/otel-map.d.ts.map +1 -0
  322. package/dist/telemetry/otel-map.js +224 -0
  323. package/dist/telemetry/otel-normalize.d.ts +104 -0
  324. package/dist/telemetry/otel-normalize.d.ts.map +1 -0
  325. package/dist/telemetry/otel-normalize.js +530 -0
  326. package/dist/telemetry/otlp-emitter.d.ts +52 -0
  327. package/dist/telemetry/otlp-emitter.d.ts.map +1 -0
  328. package/dist/telemetry/otlp-emitter.js +144 -0
  329. package/dist/telemetry/otlp-proto.d.ts +29 -0
  330. package/dist/telemetry/otlp-proto.d.ts.map +1 -0
  331. package/dist/telemetry/otlp-proto.js +266 -0
  332. package/dist/telemetry/sinks.d.ts +90 -0
  333. package/dist/telemetry/sinks.d.ts.map +1 -0
  334. package/dist/telemetry/sinks.js +180 -0
  335. package/dist/telemetry/store.d.ts +65 -0
  336. package/dist/telemetry/store.d.ts.map +1 -0
  337. package/dist/telemetry/store.js +547 -0
  338. package/dist/tenancy/api-key-format.d.ts +77 -0
  339. package/dist/tenancy/api-key-format.d.ts.map +1 -0
  340. package/dist/tenancy/api-key-format.js +110 -0
  341. package/dist/tenancy/constants.d.ts +23 -0
  342. package/dist/tenancy/constants.d.ts.map +1 -0
  343. package/dist/tenancy/constants.js +25 -0
  344. package/dist/tenancy/scrub.d.ts +47 -0
  345. package/dist/tenancy/scrub.d.ts.map +1 -0
  346. package/dist/tenancy/scrub.js +85 -0
  347. package/dist/types/config-teaching.d.ts +62 -0
  348. package/dist/types/config-teaching.d.ts.map +1 -0
  349. package/dist/types/config-teaching.js +183 -0
  350. package/dist/types/failures-teaching.d.ts +56 -0
  351. package/dist/types/failures-teaching.d.ts.map +1 -0
  352. package/dist/types/failures-teaching.js +177 -0
  353. package/dist/types/failures.d.ts +27 -0
  354. package/dist/types/failures.d.ts.map +1 -0
  355. package/dist/types/failures.js +41 -0
  356. package/dist/types/provider.d.ts +200 -0
  357. package/dist/types/provider.d.ts.map +1 -0
  358. package/dist/types/provider.js +40 -0
  359. package/dist/types/route.d.ts +205 -0
  360. package/dist/types/route.d.ts.map +1 -0
  361. package/dist/types/route.js +6 -0
  362. package/dist/types/telemetry.d.ts +206 -0
  363. package/dist/types/telemetry.d.ts.map +1 -0
  364. package/dist/types/telemetry.js +6 -0
  365. package/dist/validate-cli.d.ts +12 -0
  366. package/dist/validate-cli.d.ts.map +1 -0
  367. package/dist/validate-cli.js +57 -0
  368. package/dist/verify/capture.d.ts +66 -0
  369. package/dist/verify/capture.d.ts.map +1 -0
  370. package/dist/verify/capture.js +180 -0
  371. package/dist/verify/cli-run.d.ts +23 -0
  372. package/dist/verify/cli-run.d.ts.map +1 -0
  373. package/dist/verify/cli-run.js +57 -0
  374. package/dist/verify/diff.d.ts +48 -0
  375. package/dist/verify/diff.d.ts.map +1 -0
  376. package/dist/verify/diff.js +157 -0
  377. package/dist/verify/index.d.ts +17 -0
  378. package/dist/verify/index.d.ts.map +1 -0
  379. package/dist/verify/index.js +24 -0
  380. package/dist/verify/report.d.ts +14 -0
  381. package/dist/verify/report.d.ts.map +1 -0
  382. package/dist/verify/report.js +88 -0
  383. package/dist/verify/types.d.ts +101 -0
  384. package/dist/verify/types.d.ts.map +1 -0
  385. package/dist/verify/types.js +17 -0
  386. package/dist/verify/verify.d.ts +29 -0
  387. package/dist/verify/verify.d.ts.map +1 -0
  388. package/dist/verify/verify.js +148 -0
  389. package/dist/watch/budget.d.ts +19 -0
  390. package/dist/watch/budget.d.ts.map +1 -0
  391. package/dist/watch/budget.js +35 -0
  392. package/dist/watch/evaluate.d.ts +225 -0
  393. package/dist/watch/evaluate.d.ts.map +1 -0
  394. package/dist/watch/evaluate.js +155 -0
  395. package/dist/watch/monitor.d.ts +116 -0
  396. package/dist/watch/monitor.d.ts.map +1 -0
  397. package/dist/watch/monitor.js +199 -0
  398. package/dist/watch/proposals.d.ts +89 -0
  399. package/dist/watch/proposals.d.ts.map +1 -0
  400. package/dist/watch/proposals.js +197 -0
  401. package/dist/watch/run-record.d.ts +64 -0
  402. package/dist/watch/run-record.d.ts.map +1 -0
  403. package/dist/watch/run-record.js +86 -0
  404. package/dist/watch/run-reported.d.ts +20 -0
  405. package/dist/watch/run-reported.d.ts.map +1 -0
  406. package/dist/watch/run-reported.js +53 -0
  407. package/dist/watch/run.d.ts +73 -0
  408. package/dist/watch/run.d.ts.map +1 -0
  409. package/dist/watch/run.js +83 -0
  410. package/dist/watch/state-store.d.ts +48 -0
  411. package/dist/watch/state-store.d.ts.map +1 -0
  412. package/dist/watch/state-store.js +86 -0
  413. package/dist/watch/state.d.ts +21 -0
  414. package/dist/watch/state.d.ts.map +1 -0
  415. package/dist/watch/state.js +93 -0
  416. package/package.json +56 -14
  417. package/registry/LICENSE +20 -0
  418. package/registry/leaderboard.json +3639 -0
  419. package/registry/registry.json +7263 -0
  420. package/index.js +0 -3
@@ -0,0 +1,574 @@
1
+ "use strict";
2
+ /**
3
+ * Routes-as-code loader — spec §3, plan step 3.
4
+ * Scans a routes directory for *.yaml bundles, validates structurally,
5
+ * resolves schema/prompt paths relative to the bundle file, freezes.
6
+ */
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ exports.RouteConfigError = void 0;
9
+ exports.loadRoutesWithExtra = loadRoutesWithExtra;
10
+ exports.mergeLoadedRoutes = mergeLoadedRoutes;
11
+ exports.validateRoutesDir = validateRoutesDir;
12
+ exports.loadRoutes = loadRoutes;
13
+ const node_fs_1 = require("node:fs");
14
+ const node_path_1 = require("node:path");
15
+ const yaml_1 = require("yaml");
16
+ const failures_1 = require("../types/failures");
17
+ const fingerprint_1 = require("../registry/fingerprint");
18
+ const template_1 = require("./template");
19
+ const cache_lint_1 = require("./cache-lint");
20
+ const sampling_config_1 = require("./sampling-config");
21
+ /**
22
+ * Structured config error thrown for any invalid bundle (never a raw Error).
23
+ * Load-time problems are deliberately NOT RigFailures — the failure taxonomy
24
+ * classifies inference attempts; a malformed bundle means the rig was never
25
+ * runnable for that route.
26
+ */
27
+ class RouteConfigError extends Error {
28
+ constructor(message, opts = {}) {
29
+ const problems = opts.problems ?? [];
30
+ super(problems.length > 0 ? `${message}: ${problems.join("; ")}` : message);
31
+ this.name = "RouteConfigError";
32
+ this.file = opts.file ?? null;
33
+ this.problems = problems;
34
+ }
35
+ }
36
+ exports.RouteConfigError = RouteConfigError;
37
+ const PROVIDERS = new Set([
38
+ "gemini",
39
+ "openai",
40
+ "deepseek",
41
+ "anthropic",
42
+ "grok",
43
+ ]);
44
+ const REQUIREMENTS = new Set([
45
+ "schema_conformant",
46
+ "grounded",
47
+ "zero_retention",
48
+ "trace_visible",
49
+ ]);
50
+ const PREFERENCES = new Set(["cost", "latency"]);
51
+ const TIERS = new Set(["standard", "flex", "priority"]);
52
+ const JSON_MODES = new Set(["native", "json_mode"]);
53
+ // config_auth is deliberately absent (F2): non-retryable by contract — a
54
+ // bundle configuring retries for it is a config error, same as terminals.
55
+ const RETRYABLE_CLASSES = new Set([
56
+ "content_invalid",
57
+ "capacity_shed",
58
+ "network",
59
+ "refusal",
60
+ "cache_invalid",
61
+ "timeout",
62
+ ].filter((c) => !failures_1.TERMINAL_CLASSES.has(c)));
63
+ function isRecord(v) {
64
+ return typeof v === "object" && v !== null && !Array.isArray(v);
65
+ }
66
+ function parseCandidates(raw, problems) {
67
+ if (!Array.isArray(raw) || raw.length === 0) {
68
+ problems.push("candidates must be a non-empty list");
69
+ return [];
70
+ }
71
+ const out = [];
72
+ for (const [i, c] of raw.entries()) {
73
+ if (!isRecord(c) || typeof c.provider !== "string" || typeof c.model !== "string" || c.model === "") {
74
+ problems.push(`candidates[${i}] must be {provider, model}`);
75
+ continue;
76
+ }
77
+ if (!PROVIDERS.has(c.provider)) {
78
+ problems.push(`candidates[${i}].provider "${c.provider}" is not a known provider`);
79
+ continue;
80
+ }
81
+ out.push(Object.freeze({ provider: c.provider, model: c.model }));
82
+ }
83
+ return out;
84
+ }
85
+ function parseStringList(raw, field, allowed, problems) {
86
+ if (raw === undefined || raw === null)
87
+ return [];
88
+ if (!Array.isArray(raw)) {
89
+ problems.push(`${field} must be a list`);
90
+ return [];
91
+ }
92
+ const out = [];
93
+ for (const v of raw) {
94
+ if (typeof v !== "string" || !allowed.has(v)) {
95
+ problems.push(`${field} entry "${String(v)}" is not one of [${[...allowed].join(", ")}]`);
96
+ continue;
97
+ }
98
+ out.push(v);
99
+ }
100
+ return out;
101
+ }
102
+ function parsePolicy(raw, problems) {
103
+ const fallback = Object.freeze({
104
+ retries: Object.freeze({}),
105
+ timeoutMs: 300000,
106
+ tier: "standard",
107
+ json: "native",
108
+ });
109
+ if (!isRecord(raw)) {
110
+ problems.push("policy must be an object");
111
+ return fallback;
112
+ }
113
+ const retries = {};
114
+ if (raw.retries !== undefined) {
115
+ if (!isRecord(raw.retries)) {
116
+ problems.push("policy.retries must be an object");
117
+ }
118
+ else {
119
+ for (const [cls, n] of Object.entries(raw.retries)) {
120
+ if (!RETRYABLE_CLASSES.has(cls)) {
121
+ problems.push(`policy.retries key "${cls}" is not a retryable failure class`);
122
+ continue;
123
+ }
124
+ if (typeof n !== "number" || !Number.isInteger(n) || n < 0) {
125
+ problems.push(`policy.retries.${cls} must be a non-negative integer`);
126
+ continue;
127
+ }
128
+ retries[cls] = n;
129
+ }
130
+ }
131
+ }
132
+ const timeoutMs = raw.timeout_ms;
133
+ if (typeof timeoutMs !== "number" || !Number.isInteger(timeoutMs) || timeoutMs <= 0) {
134
+ problems.push("policy.timeout_ms must be a positive integer");
135
+ }
136
+ const tier = raw.tier ?? "standard";
137
+ if (typeof tier !== "string" || !TIERS.has(tier)) {
138
+ problems.push(`policy.tier "${String(tier)}" is not one of [${[...TIERS].join(", ")}]`);
139
+ }
140
+ const json = raw.json ?? "native";
141
+ if (typeof json !== "string" || !JSON_MODES.has(json)) {
142
+ problems.push(`policy.json "${String(json)}" is not one of [native, json_mode]`);
143
+ }
144
+ const sampling = (0, sampling_config_1.parseSampling)(raw.sampling, "policy.sampling", problems);
145
+ if (problems.length > 0)
146
+ return fallback;
147
+ return Object.freeze({
148
+ retries: Object.freeze(retries),
149
+ timeoutMs: timeoutMs,
150
+ tier: tier,
151
+ json: json,
152
+ ...(sampling !== undefined ? { sampling } : {}),
153
+ });
154
+ }
155
+ /** "provider/model" string or {provider, model} mapping → CandidateSpec. */
156
+ function parseRepairModel(raw, field, problems) {
157
+ let provider;
158
+ let model;
159
+ if (typeof raw === "string") {
160
+ const slash = raw.indexOf("/");
161
+ if (slash <= 0 || slash === raw.length - 1) {
162
+ problems.push(`${field} must be "provider/model" or {provider, model}`);
163
+ return null;
164
+ }
165
+ provider = raw.slice(0, slash);
166
+ model = raw.slice(slash + 1);
167
+ }
168
+ else if (isRecord(raw)) {
169
+ provider = raw.provider;
170
+ model = raw.model;
171
+ }
172
+ else {
173
+ problems.push(`${field} must be "provider/model" or {provider, model}`);
174
+ return null;
175
+ }
176
+ if (typeof provider !== "string" || !PROVIDERS.has(provider) || typeof model !== "string" || model === "") {
177
+ problems.push(`${field} has an unknown provider or empty model`);
178
+ return null;
179
+ }
180
+ return Object.freeze({ provider: provider, model });
181
+ }
182
+ function parseRepair(raw, field, candidates, problems) {
183
+ if (raw === undefined || raw === null)
184
+ return undefined;
185
+ if (!isRecord(raw)) {
186
+ problems.push(`${field} must be an object {max_repairs, repair_model?}`);
187
+ return undefined;
188
+ }
189
+ const maxRepairs = raw.max_repairs;
190
+ if (typeof maxRepairs !== "number" || !Number.isInteger(maxRepairs) || maxRepairs < 1 || maxRepairs > 2) {
191
+ problems.push(`${field}.max_repairs must be 1 or 2 (retry-with-errors, then optional repair model)`);
192
+ return undefined;
193
+ }
194
+ let repairModel = null;
195
+ if (raw.repair_model !== undefined) {
196
+ repairModel = parseRepairModel(raw.repair_model, `${field}.repair_model`, problems);
197
+ if (repairModel !== null &&
198
+ !candidates.some((c) => c.provider === repairModel?.provider && c.model === repairModel?.model)) {
199
+ // Candidate-set invariant: the repair model must be a declared candidate.
200
+ problems.push(`${field}.repair_model (${repairModel.provider}/${repairModel.model}) is not in the route's declared candidates`);
201
+ repairModel = null;
202
+ }
203
+ }
204
+ if (maxRepairs === 2 && repairModel === null) {
205
+ problems.push(`${field}.max_repairs=2 requires repair_model (attempt 2 is the designated repair model)`);
206
+ }
207
+ return Object.freeze({
208
+ maxRepairs,
209
+ ...(repairModel !== null ? { repairModel } : {}),
210
+ });
211
+ }
212
+ function parseVariants(raw, routeCandidates, problems) {
213
+ if (raw === undefined || raw === null)
214
+ return [];
215
+ if (!Array.isArray(raw)) {
216
+ problems.push("variants must be a list");
217
+ return [];
218
+ }
219
+ const seen = new Set();
220
+ const out = [];
221
+ const inDeclared = (c) => routeCandidates.some((rc) => rc.provider === c.provider && rc.model === c.model);
222
+ for (const [i, v] of raw.entries()) {
223
+ const field = `variants[${i}]`;
224
+ if (!isRecord(v)) {
225
+ problems.push(`${field} must be a mapping`);
226
+ continue;
227
+ }
228
+ if (typeof v.name !== "string" || v.name === "") {
229
+ problems.push(`${field}.name must be a non-empty string`);
230
+ continue;
231
+ }
232
+ if (v.name === "default") {
233
+ problems.push(`${field}.name "default" is reserved (the route's base config)`);
234
+ continue;
235
+ }
236
+ if (seen.has(v.name)) {
237
+ problems.push(`duplicate variant name "${v.name}"`);
238
+ continue;
239
+ }
240
+ seen.add(v.name);
241
+ let candidates;
242
+ if (v.candidates !== undefined) {
243
+ candidates = parseCandidates(v.candidates, problems);
244
+ for (const c of candidates) {
245
+ if (!inDeclared(c)) {
246
+ // Candidate-set invariant: variants narrow, never widen.
247
+ problems.push(`${field} candidate (${c.provider}, ${c.model}) is not in the route's declared candidates`);
248
+ }
249
+ }
250
+ }
251
+ if (v.prompt_override !== undefined && v.prompt_append !== undefined) {
252
+ problems.push(`${field} sets both prompt_override and prompt_append — they are mutually exclusive`);
253
+ }
254
+ for (const key of ["prompt_override", "prompt_append", "scaffold"]) {
255
+ if (v[key] !== undefined && typeof v[key] !== "string") {
256
+ problems.push(`${field}.${key} must be a string`);
257
+ }
258
+ }
259
+ if (v.json !== undefined && (typeof v.json !== "string" || !JSON_MODES.has(v.json))) {
260
+ problems.push(`${field}.json must be one of [native, json_mode]`);
261
+ }
262
+ const repair = parseRepair(v.repair, `${field}.repair`, routeCandidates, problems);
263
+ out.push(Object.freeze({
264
+ name: v.name,
265
+ ...(candidates !== undefined ? { candidates: Object.freeze(candidates) } : {}),
266
+ ...(typeof v.prompt_override === "string" ? { promptOverride: v.prompt_override } : {}),
267
+ ...(typeof v.prompt_append === "string" ? { promptAppend: v.prompt_append } : {}),
268
+ ...(typeof v.scaffold === "string" ? { scaffold: v.scaffold } : {}),
269
+ ...(typeof v.json === "string" && JSON_MODES.has(v.json)
270
+ ? { json: v.json }
271
+ : {}),
272
+ ...(repair !== undefined ? { repair } : {}),
273
+ }));
274
+ }
275
+ return out;
276
+ }
277
+ function readSchema(schemaRaw, bundleDir, problems) {
278
+ if (schemaRaw === null || schemaRaw === undefined)
279
+ return null;
280
+ if (typeof schemaRaw !== "string" || schemaRaw === "") {
281
+ problems.push("schema must be a relative path or null");
282
+ return null;
283
+ }
284
+ const schemaPath = (0, node_path_1.resolve)(bundleDir, schemaRaw);
285
+ if (!(0, node_fs_1.existsSync)(schemaPath)) {
286
+ problems.push(`schema file not found: ${schemaRaw}`);
287
+ return null;
288
+ }
289
+ try {
290
+ const parsed = JSON.parse((0, node_fs_1.readFileSync)(schemaPath, "utf8"));
291
+ if (!isRecord(parsed)) {
292
+ problems.push(`schema file ${schemaRaw} must contain a JSON object`);
293
+ return null;
294
+ }
295
+ return parsed;
296
+ }
297
+ catch (err) {
298
+ problems.push(`schema file ${schemaRaw} is not valid JSON: ${err.message}`);
299
+ return null;
300
+ }
301
+ }
302
+ function loadBundleFile(filePath) {
303
+ const problems = [];
304
+ let doc;
305
+ try {
306
+ doc = (0, yaml_1.parse)((0, node_fs_1.readFileSync)(filePath, "utf8"));
307
+ }
308
+ catch (err) {
309
+ throw new RouteConfigError(`invalid YAML in route bundle`, {
310
+ file: filePath,
311
+ problems: [err.message],
312
+ });
313
+ }
314
+ if (!isRecord(doc)) {
315
+ throw new RouteConfigError("route bundle must be a YAML mapping", { file: filePath });
316
+ }
317
+ const route = doc.route;
318
+ if (typeof route !== "string" || route === "")
319
+ problems.push("route must be a non-empty string");
320
+ const version = doc.version;
321
+ if (typeof version !== "number" || !Number.isInteger(version) || version < 1) {
322
+ problems.push("version must be an integer >= 1");
323
+ }
324
+ const bundleDir = (0, node_path_1.dirname)(filePath);
325
+ const candidates = parseCandidates(doc.candidates, problems);
326
+ const require = parseStringList(doc.require, "require", REQUIREMENTS, problems);
327
+ const prefer = parseStringList(doc.prefer, "prefer", PREFERENCES, problems);
328
+ const outputSchema = readSchema(doc.schema, bundleDir, problems);
329
+ const policy = parsePolicy(doc.policy, problems);
330
+ // Phase 3 (bundle v2, all additive): variants, repair, capture opt-in,
331
+ // grounding-inject query template.
332
+ const variants = parseVariants(doc.variants, candidates, problems);
333
+ const repair = parseRepair(doc.repair, "repair", candidates, problems);
334
+ const capture = doc.capture ?? false;
335
+ if (typeof capture !== "boolean") {
336
+ problems.push("capture must be a boolean");
337
+ }
338
+ // Request-path caching opt-in (cache-aware-routing WS-C). Exactly one value
339
+ // is supported in v1 — `cache: auto`. Anything else is a config error (a typo
340
+ // must not silently ship an un-cached route). Gemini is NOT excluded here: a
341
+ // mixed-provider route may opt in, and the run-loop's policy gate skips
342
+ // gemini's request path (cache-stamp.ts) while its implicit hit rate still
343
+ // arrives passively — the exclusion is code-enforced, not author-policed.
344
+ let cache = false;
345
+ if (doc.cache !== undefined && doc.cache !== null) {
346
+ if (doc.cache === "auto") {
347
+ cache = true;
348
+ }
349
+ else {
350
+ problems.push(`cache "${String(doc.cache)}" is not supported — use "cache: auto" or omit it`);
351
+ }
352
+ }
353
+ let groundingQuery;
354
+ if (doc.grounding !== undefined) {
355
+ if (!isRecord(doc.grounding) || typeof doc.grounding.query !== "string" || doc.grounding.query === "") {
356
+ problems.push("grounding must be an object {query: <template string>}");
357
+ }
358
+ else {
359
+ groundingQuery = doc.grounding.query;
360
+ }
361
+ }
362
+ let systemTemplate = "";
363
+ let variables = [];
364
+ if (!isRecord(doc.prompt) || typeof doc.prompt.system !== "string") {
365
+ problems.push("prompt.system must be a relative path");
366
+ }
367
+ else {
368
+ const promptPath = (0, node_path_1.resolve)(bundleDir, doc.prompt.system);
369
+ if (!(0, node_fs_1.existsSync)(promptPath)) {
370
+ problems.push(`prompt.system file not found: ${doc.prompt.system}`);
371
+ }
372
+ else {
373
+ systemTemplate = (0, node_fs_1.readFileSync)(promptPath, "utf8");
374
+ }
375
+ const rawVars = doc.prompt.variables ?? [];
376
+ if (!Array.isArray(rawVars) || rawVars.some((v) => typeof v !== "string")) {
377
+ problems.push("prompt.variables must be a list of strings");
378
+ }
379
+ else {
380
+ variables = rawVars;
381
+ }
382
+ }
383
+ if (systemTemplate !== "") {
384
+ const declared = new Set(variables);
385
+ for (const ref of (0, template_1.scanTemplateVariables)(systemTemplate)) {
386
+ if (!declared.has(ref)) {
387
+ problems.push(`template references undeclared variable "${ref}" (declare it in prompt.variables)`);
388
+ }
389
+ }
390
+ }
391
+ if (groundingQuery !== undefined) {
392
+ const declared = new Set(variables);
393
+ for (const ref of (0, template_1.scanTemplateVariables)(groundingQuery)) {
394
+ if (!declared.has(ref)) {
395
+ problems.push(`grounding.query references undeclared variable "${ref}"`);
396
+ }
397
+ }
398
+ }
399
+ if (problems.length > 0) {
400
+ throw new RouteConfigError("invalid route bundle", { file: filePath, problems });
401
+ }
402
+ // Prompt-stability lint (WS-C step 4, spec §5.3): a non-fatal warning — a
403
+ // volatile interpolation before the stable tail defeats prompt caching. Only
404
+ // meaningful once the route opted into `cache: auto`, so scoped to it to keep
405
+ // the signal high (same console-warn posture as manifest dimension warnings).
406
+ if (cache) {
407
+ for (const w of (0, cache_lint_1.lintCacheTemplate)(systemTemplate)) {
408
+ console.warn(`modelrig: route "${String(route)}" (${filePath}): ${w.message}`);
409
+ }
410
+ }
411
+ // CE-6 sampling advisory: a sub-1.0 temperature on a Gemini-3 candidate loads
412
+ // and is sent as declared, but Google recommends 1.0 for the family — warn so
413
+ // the choice is deliberate, never silent (spec §3/§6).
414
+ const geminiTempWarning = (0, sampling_config_1.gemini3LowTemperatureWarning)(route, policy, candidates);
415
+ if (geminiTempWarning !== null) {
416
+ console.warn(`modelrig: ${geminiTempWarning}`);
417
+ }
418
+ return Object.freeze({
419
+ route: route,
420
+ version: version,
421
+ outputSchema: outputSchema === null ? null : Object.freeze(outputSchema),
422
+ candidates: Object.freeze(candidates),
423
+ require: Object.freeze(require),
424
+ prefer: Object.freeze(prefer),
425
+ systemTemplate,
426
+ variables: Object.freeze(variables),
427
+ policy,
428
+ ...(repair !== undefined ? { repair } : {}),
429
+ variants: Object.freeze(variants),
430
+ capture: capture === true,
431
+ cache,
432
+ ...(groundingQuery !== undefined ? { groundingQuery } : {}),
433
+ // Network-effect instrumentation (spec WS6): computed once at load,
434
+ // stamped on every telemetry row for this route.
435
+ fingerprintCell: (0, fingerprint_1.fingerprintSchema)(outputSchema)?.cellKey ?? null,
436
+ });
437
+ }
438
+ /**
439
+ * Merge two loaded route sets into one store — a UNION, collision is a loud
440
+ * error. Used to fold a deployment's bundled INTERNAL infra routes (e.g. the
441
+ * server's run-judge@v1 / analyst-summarize@v1) into the operator's configured
442
+ * routes without replacing them (index.ts createRig, extraRoutesDir). The
443
+ * reserved `@v<n>` infra namespace never collides with customer/demo routes;
444
+ * if it ever did, failing at boot is correct.
445
+ */
446
+ /**
447
+ * Load a routes directory and OPTIONALLY union a second (deployment-bundled
448
+ * infra) directory into it — the one call createRig makes so the extra-routes
449
+ * merge does not grow index.ts. `extraDir` absent/empty ⇒ exactly loadRoutes.
450
+ */
451
+ function loadRoutesWithExtra(routesDir, extraDir) {
452
+ const base = loadRoutes(routesDir);
453
+ if (extraDir === undefined || extraDir === "")
454
+ return base;
455
+ return mergeLoadedRoutes(base, loadRoutes(extraDir));
456
+ }
457
+ function mergeLoadedRoutes(primary, extra) {
458
+ const byName = new Map();
459
+ for (const b of primary.list())
460
+ byName.set(b.route, b);
461
+ for (const b of extra.list()) {
462
+ if (byName.has(b.route)) {
463
+ throw new RouteConfigError(`duplicate route "${b.route}" — an internal infra route collides with a configured route`);
464
+ }
465
+ byName.set(b.route, b);
466
+ }
467
+ return {
468
+ get(route) {
469
+ const bundle = byName.get(route);
470
+ if (!bundle) {
471
+ throw new RouteConfigError(`unknown route "${route}" — known routes: [${[...byName.keys()].join(", ")}]`);
472
+ }
473
+ return bundle;
474
+ },
475
+ list() {
476
+ return Object.freeze([...byName.values()]);
477
+ },
478
+ };
479
+ }
480
+ /**
481
+ * Structurally validate every route bundle in a directory WITHOUT requiring any
482
+ * provider key (CE-6 `modelrig validate`). Unlike {@link loadRoutes}, one bad
483
+ * bundle does NOT abort the rest — each file is loaded independently and its
484
+ * outcome collected, so a newbie sees every problem in one pass. Duplicate route
485
+ * handles across files are reported per the later file. This deliberately does
486
+ * NOT run the serveable-candidate gate (serveability.ts) — that needs keys and
487
+ * stays fail-closed for SERVING; validation only checks authoring.
488
+ *
489
+ * A missing directory is still a hard error (nothing to validate) — it throws
490
+ * the same teaching RouteConfigError as loadRoutes.
491
+ */
492
+ function validateRoutesDir(routesDir) {
493
+ if (!(0, node_fs_1.existsSync)(routesDir)) {
494
+ throw new RouteConfigError(`routes directory not found: ${routesDir}\n\n` +
495
+ "There are no route bundles to validate here. Create your first with\n" +
496
+ " modelrig init . draft routes from the provider calls in this repo\n" +
497
+ "or point elsewhere with MODELRIG_ROUTES_DIR. Docs: https://modelrig.dev/quickstart.html");
498
+ }
499
+ const files = (0, node_fs_1.readdirSync)(routesDir)
500
+ .filter((f) => f.endsWith(".yaml") || f.endsWith(".yml"))
501
+ .sort()
502
+ .map((f) => (0, node_path_1.join)(routesDir, f));
503
+ const results = [];
504
+ const seen = new Map();
505
+ for (const file of files) {
506
+ try {
507
+ const bundle = loadBundleFile(file);
508
+ const prior = seen.get(bundle.route);
509
+ if (prior !== undefined) {
510
+ results.push({
511
+ file,
512
+ route: bundle.route,
513
+ ok: false,
514
+ problems: [`duplicate route "${bundle.route}" — already declared in ${prior}`],
515
+ });
516
+ continue;
517
+ }
518
+ seen.set(bundle.route, file);
519
+ results.push({ file, route: bundle.route, ok: true, problems: [] });
520
+ }
521
+ catch (err) {
522
+ if (err instanceof RouteConfigError) {
523
+ results.push({
524
+ file,
525
+ route: null,
526
+ ok: false,
527
+ problems: err.problems.length > 0 ? err.problems : [err.message],
528
+ });
529
+ }
530
+ else {
531
+ results.push({ file, route: null, ok: false, problems: [err.message] });
532
+ }
533
+ }
534
+ }
535
+ return results;
536
+ }
537
+ function loadRoutes(routesDir) {
538
+ if (!(0, node_fs_1.existsSync)(routesDir)) {
539
+ // First-run moment (Phase 5 WS4): this is the most likely error a new
540
+ // user ever sees, so it teaches instead of just reporting.
541
+ throw new RouteConfigError(`routes directory not found: ${routesDir}\n\n` +
542
+ "A route is a task your code calls by name — one small YAML file each, in that\n" +
543
+ "directory. There isn't one here yet. Two ways to get your first:\n\n" +
544
+ " modelrig init . draft routes from the provider calls already in this repo\n" +
545
+ " mkdir -p " +
546
+ routesDir +
547
+ " start empty and write one by hand\n\n" +
548
+ "Point somewhere else with MODELRIG_ROUTES_DIR. Docs: https://modelrig.dev/quickstart.html");
549
+ }
550
+ const files = (0, node_fs_1.readdirSync)(routesDir)
551
+ .filter((f) => f.endsWith(".yaml") || f.endsWith(".yml"))
552
+ .sort()
553
+ .map((f) => (0, node_path_1.join)(routesDir, f));
554
+ const byName = new Map();
555
+ for (const file of files) {
556
+ const bundle = loadBundleFile(file);
557
+ if (byName.has(bundle.route)) {
558
+ throw new RouteConfigError(`duplicate route "${bundle.route}"`, { file });
559
+ }
560
+ byName.set(bundle.route, bundle);
561
+ }
562
+ return {
563
+ get(route) {
564
+ const bundle = byName.get(route);
565
+ if (!bundle) {
566
+ throw new RouteConfigError(`unknown route "${route}" — known routes: [${[...byName.keys()].join(", ")}]`);
567
+ }
568
+ return bundle;
569
+ },
570
+ list() {
571
+ return Object.freeze([...byName.values()]);
572
+ },
573
+ };
574
+ }
@@ -0,0 +1,24 @@
1
+ /**
2
+ * The rig manifest (modelrig/rig.yaml) — cost-dimensions-design.md §2a.
3
+ * Project-level, optional; absence means "no declared dimensions" and
4
+ * everything continues to work (declaration upgrades, never gates).
5
+ */
6
+ import type { RunTags } from "../types/route";
7
+ export interface DimensionSpec {
8
+ readonly key: string;
9
+ readonly label: string;
10
+ readonly required: boolean;
11
+ }
12
+ export interface RigManifest {
13
+ readonly name: string;
14
+ readonly dimensions: readonly DimensionSpec[];
15
+ /** Conformance Matrix contribution consent — default false (Phase 2: flag
16
+ * + mirror only; no pipeline consumes it yet). */
17
+ readonly contribution: boolean;
18
+ }
19
+ export declare function loadManifest(rigDir: string): RigManifest | null;
20
+ /** Required dimensions with no (non-empty) value in the run's tags — pure. */
21
+ export declare function missingRequiredDimensions(manifest: RigManifest | null, tags: RunTags): readonly string[];
22
+ export declare function warnMissingRequiredDimensions(manifest: RigManifest | null, tags: RunTags, log?: (message: string) => void): void;
23
+ export declare function resetDimensionWarningsForTest(): void;
24
+ //# sourceMappingURL=manifest.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"manifest.d.ts","sourceRoot":"","sources":["../../src/routes/manifest.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAMH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAE9C,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;CAC5B;AAED,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,UAAU,EAAE,SAAS,aAAa,EAAE,CAAC;IAC9C;sDACkD;IAClD,QAAQ,CAAC,YAAY,EAAE,OAAO,CAAC;CAChC;AA+CD,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,WAAW,GAAG,IAAI,CAoC/D;AAED,8EAA8E;AAC9E,wBAAgB,yBAAyB,CACvC,QAAQ,EAAE,WAAW,GAAG,IAAI,EAC5B,IAAI,EAAE,OAAO,GACZ,SAAS,MAAM,EAAE,CASnB;AAMD,wBAAgB,6BAA6B,CAC3C,QAAQ,EAAE,WAAW,GAAG,IAAI,EAC5B,IAAI,EAAE,OAAO,EACb,GAAG,GAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAmB,GAC5C,IAAI,CASN;AAED,wBAAgB,6BAA6B,IAAI,IAAI,CAEpD"}