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,81 @@
1
+ /**
2
+ * `modelrig observe` — the observe-first (T0/T1) scaffold.
3
+ *
4
+ * Onboarding-test run-1's headline finding (F-1): the ONLY documented observe
5
+ * on-ramp (`instrumentation.md`) is a hand-wired SDK seam with NO CLI. Every
6
+ * customer-facing surface points a migrating customer at `modelrig init`, which
7
+ * is route extraction (T2) — so "just show me my runs first" had no CLI
8
+ * affordance at all. This command closes that gap.
9
+ *
10
+ * It does for OBSERVE what `init` does for MIGRATE, and obeys the same hard
11
+ * rule: it NEVER edits the target's source. It writes exactly two things under
12
+ * `modelrig/observe/` — a self-contained `record-step` seam (generated fresh,
13
+ * per the doc's "write your own; do not resurrect a deleted one" rule) and an
14
+ * `OBSERVE.md` plan whose per-call-site wiring is emitted as a `diff` for the
15
+ * agent (or human) to apply with judgment, one step at a time.
16
+ *
17
+ * Observe is deliberately NOT migration: it drafts no routes, reroutes no
18
+ * model calls, and changes no behaviour. With `MODELRIG_ARTIFACTS` off the
19
+ * pipeline is byte-for-byte identical (instrumentation.md).
20
+ */
21
+ import type { CallSite, FileSystemLike } from "./finder";
22
+ import type { FinderOptions } from "./finder";
23
+ /** One instrumented step the scaffold proposes: a detected model call site
24
+ * becomes a step boundary whose work products (prompt, raw, parsed) are saved. */
25
+ export interface ObservePlan {
26
+ readonly site: CallSite;
27
+ /** Stable, human-legible step key used in `recordStep(...)` and the console. */
28
+ readonly stepKey: string;
29
+ /** The `recordStep(...)` line proposed at this site. */
30
+ readonly snippet: string;
31
+ }
32
+ export interface ObserveResult {
33
+ readonly plans: readonly ObservePlan[];
34
+ readonly sitesFound: number;
35
+ readonly filesScanned: number;
36
+ readonly filesSkipped: readonly string[];
37
+ /** Where the generated seam helper lives (repo-relative). */
38
+ readonly seamPath: string;
39
+ /** The generated, self-contained seam helper source. */
40
+ readonly seamContent: string;
41
+ /** The OBSERVE.md plan (wiring diffs + the human key-mint handoff). */
42
+ readonly scaffoldMarkdown: string;
43
+ readonly written: readonly string[];
44
+ readonly skipped: readonly string[];
45
+ }
46
+ export interface ObserveOptions extends FinderOptions {
47
+ /** Plan without writing (`--dry-run`). */
48
+ readonly dryRun?: boolean;
49
+ }
50
+ export interface ObserveDeps {
51
+ readonly root: string;
52
+ /** Directory the scaffold writes into (repo-relative), e.g. modelrig/observe. */
53
+ readonly outDir: string;
54
+ readonly fs: FileSystemLike & {
55
+ existsSync: (p: string) => boolean;
56
+ mkdirSync: (p: string, o: {
57
+ recursive: boolean;
58
+ }) => void;
59
+ writeFileSync: (p: string, c: string, e: "utf8") => void;
60
+ };
61
+ readonly path: {
62
+ join: (...parts: string[]) => string;
63
+ relative: (from: string, to: string) => string;
64
+ dirname: (p: string) => string;
65
+ basename: (p: string, ext?: string) => string;
66
+ };
67
+ }
68
+ /** A stable step key from a call site: `<dir>_<file>_<line>`, deduped so two
69
+ * sites never collide. Deterministic, so a second run proposes the same keys. */
70
+ export declare function stepKeyFor(site: CallSite, used: Set<string>): string;
71
+ /** The generated seam. Self-contained and fresh (never resurrected from git
72
+ * history — that is the point of onboarding-test run-2). Mirrors the reference
73
+ * `recordStep` in instrumentation.md, plus a `withRun` boundary wrapper. */
74
+ export declare function seamContent(): string;
75
+ export declare function buildObserveMarkdown(plans: readonly ObservePlan[], seamPath: string, result: {
76
+ sitesFound: number;
77
+ filesScanned: number;
78
+ filesSkipped: readonly string[];
79
+ }, path: ObserveDeps["path"]): string;
80
+ export declare function runObserve(deps: ObserveDeps, options?: ObserveOptions): ObserveResult;
81
+ //# sourceMappingURL=observe.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"observe.d.ts","sourceRoot":"","sources":["../../src/init/observe.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAGH,OAAO,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AACzD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAE9C;kFACkF;AAClF,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IACxB,gFAAgF;IAChF,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,wDAAwD;IACxD,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B;AAED,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,KAAK,EAAE,SAAS,WAAW,EAAE,CAAC;IACvC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,YAAY,EAAE,SAAS,MAAM,EAAE,CAAC;IACzC,6DAA6D;IAC7D,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,wDAAwD;IACxD,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,uEAAuE;IACvE,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAC;IAClC,QAAQ,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;IACpC,QAAQ,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;CACrC;AAED,MAAM,WAAW,cAAe,SAAQ,aAAa;IACnD,0CAA0C;IAC1C,QAAQ,CAAC,MAAM,CAAC,EAAE,OA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EACrF,IAAI,EAAE,WAAW,CAAC,MAAM,CAAC,GACxB,MAAM,CA+GR;AAED,wBAAgB,UAAU,CAAC,IAAI,EAAE,WAAW,EAAE,OAAO,GAAE,cAAmB,GAAG,aAAa,CA6DzF"}
@@ -0,0 +1,245 @@
1
+ "use strict";
2
+ /**
3
+ * `modelrig observe` — the observe-first (T0/T1) scaffold.
4
+ *
5
+ * Onboarding-test run-1's headline finding (F-1): the ONLY documented observe
6
+ * on-ramp (`instrumentation.md`) is a hand-wired SDK seam with NO CLI. Every
7
+ * customer-facing surface points a migrating customer at `modelrig init`, which
8
+ * is route extraction (T2) — so "just show me my runs first" had no CLI
9
+ * affordance at all. This command closes that gap.
10
+ *
11
+ * It does for OBSERVE what `init` does for MIGRATE, and obeys the same hard
12
+ * rule: it NEVER edits the target's source. It writes exactly two things under
13
+ * `modelrig/observe/` — a self-contained `record-step` seam (generated fresh,
14
+ * per the doc's "write your own; do not resurrect a deleted one" rule) and an
15
+ * `OBSERVE.md` plan whose per-call-site wiring is emitted as a `diff` for the
16
+ * agent (or human) to apply with judgment, one step at a time.
17
+ *
18
+ * Observe is deliberately NOT migration: it drafts no routes, reroutes no
19
+ * model calls, and changes no behaviour. With `MODELRIG_ARTIFACTS` off the
20
+ * pipeline is byte-for-byte identical (instrumentation.md).
21
+ */
22
+ Object.defineProperty(exports, "__esModule", { value: true });
23
+ exports.stepKeyFor = stepKeyFor;
24
+ exports.seamContent = seamContent;
25
+ exports.buildObserveMarkdown = buildObserveMarkdown;
26
+ exports.runObserve = runObserve;
27
+ const finder_1 = require("./finder");
28
+ const normalize = (s) => s.replace(/[^A-Za-z0-9]+/g, "_").replace(/^_|_$/g, "").toLowerCase();
29
+ /** A stable step key from a call site: `<dir>_<file>_<line>`, deduped so two
30
+ * sites never collide. Deterministic, so a second run proposes the same keys. */
31
+ function stepKeyFor(site, used) {
32
+ const parts = site.file.split("/").filter((p) => p !== "" && p !== "." && p !== "src");
33
+ const fileStem = (parts[parts.length - 1] ?? "step").replace(/\.[jt]sx?$/, "");
34
+ const dir = parts.length > 1 ? parts[parts.length - 2] : "app";
35
+ let key = `${normalize(dir)}_${normalize(fileStem)}_${site.line}`;
36
+ while (used.has(key))
37
+ key = `${key}_x`;
38
+ used.add(key);
39
+ return key;
40
+ }
41
+ /** The generated seam. Self-contained and fresh (never resurrected from git
42
+ * history — that is the point of onboarding-test run-2). Mirrors the reference
43
+ * `recordStep` in instrumentation.md, plus a `withRun` boundary wrapper. */
44
+ function seamContent() {
45
+ return `/**
46
+ * ModelRig observe seam — generated by \`modelrig observe\`.
47
+ *
48
+ * This is YOURS to keep and edit; it is generated fresh (not copied from any
49
+ * deleted seam) so it always matches the current SDK. It records each pipeline
50
+ * run as a run -> step -> artifact chain you click through in the console.
51
+ *
52
+ * Observe-only: no routes move, no model calls are rerouted. With
53
+ * MODELRIG_ARTIFACTS off (or no control plane configured) every call here is
54
+ * inert and your pipeline behaves byte-for-byte as before. Nothing here ever
55
+ * throws into your pipeline — a telemetry write that fails is logged and
56
+ * dropped (instrumentation.md, "Never throws into your pipeline").
57
+ *
58
+ * Docs: https://modelrig.dev/instrumentation.html
59
+ */
60
+
61
+ import { createRig, loadConfigFromEnv, type Rig } from "modelrig";
62
+
63
+ const rig: Rig = createRig(loadConfigFromEnv());
64
+
65
+ /** Open a run context around a whole pipeline, close it on success/failure.
66
+ * \`episodeKey\` is a grouping key (a natural choice: your per-run attempt id),
67
+ * not a unique id. Pass \`environment\` (e.g. your NODE_ENV) to tag the run.
68
+ * Use \`rig.artifacts.run.scope(...)\` instead for concurrent runs in one
69
+ * process. */
70
+ export async function withRun<T>(
71
+ opts: { pipeline: string; episodeKey: string; environment?: string },
72
+ body: () => Promise<T>,
73
+ ): Promise<T> {
74
+ const run = rig.artifacts.run.start({
75
+ pipeline: opts.pipeline,
76
+ episodeKey: opts.episodeKey,
77
+ ...(opts.environment !== undefined ? { environment: opts.environment } : {}),
78
+ });
79
+ try {
80
+ const out = await body();
81
+ run.end("succeeded");
82
+ return out;
83
+ } catch (err) {
84
+ run.end("failed");
85
+ throw err;
86
+ }
87
+ }
88
+
89
+ /** Save prompt + raw + parsed for one step, link lineage, flag conformance.
90
+ * A stage whose model call does NOT go through the rig still produces
91
+ * artifacts (with \`stepKey\` set and no step row) — correct and honest; the
92
+ * console renders "cost n/a" rather than inventing a number. */
93
+ export function recordStep(
94
+ stepKey: string,
95
+ work: { prompt: string; rawText: string; json: unknown; conforms: boolean },
96
+ ): void {
97
+ const p = rig.artifacts.artifact.save(work.prompt, { name: \`\${stepKey}.prompt\`, type: "prompt", stepKey });
98
+ const raw = rig.artifacts.artifact.save(work.rawText, { name: \`\${stepKey}.raw\`, type: "raw_response", stepKey });
99
+ const parsed = rig.artifacts.artifact.save(work.json, { name: \`\${stepKey}.output\`, type: "step_output", task: stepKey, stepKey });
100
+ if (p && parsed) rig.artifacts.artifact.link(parsed, p, "derived_from");
101
+ if (raw && parsed) rig.artifacts.artifact.link(parsed, raw, "derived_from");
102
+ if (parsed) rig.artifacts.artifact.evaluate(parsed, { evaluator: "schema-check", kind: "deterministic", passed: work.conforms });
103
+ }
104
+ `;
105
+ }
106
+ /** The import specifier a source file uses to reach the seam. Best-effort
107
+ * relative path; a coding agent adjusts it to the project's alias if needed. */
108
+ function importSpecifier(fromFile, seamPath, path) {
109
+ const noExt = seamPath.replace(/\.[jt]sx?$/, "");
110
+ const rel = path.relative(path.dirname(fromFile), noExt);
111
+ return rel.startsWith(".") ? rel : `./${rel}`;
112
+ }
113
+ function recordStepSnippet(stepKey) {
114
+ return (`recordStep(${JSON.stringify(stepKey)}, {\n` +
115
+ ` prompt, // the assembled prompt string\n` +
116
+ ` rawText, // the model's raw text, pre-parse\n` +
117
+ ` json: parsed, // your parsed/validated output\n` +
118
+ ` conforms, // did it satisfy your schema?\n` +
119
+ `});`);
120
+ }
121
+ /** The run boundary is most likely the shallowest detected file (the entry
122
+ * that drives the pipeline). A heuristic, flagged as such — never asserted. */
123
+ function runBoundaryFile(plans) {
124
+ let best = null;
125
+ let bestDepth = Number.POSITIVE_INFINITY;
126
+ for (const plan of plans) {
127
+ const depth = plan.site.file.split("/").length;
128
+ if (depth < bestDepth) {
129
+ bestDepth = depth;
130
+ best = plan.site.file;
131
+ }
132
+ }
133
+ return best;
134
+ }
135
+ function buildObserveMarkdown(plans, seamPath, result, path) {
136
+ const lines = [
137
+ "# ModelRig observe — wire up run/step/artifact telemetry",
138
+ "",
139
+ "**Nothing in your source has changed.** `modelrig observe` generated one seam helper",
140
+ `(\`${seamPath}\`) and this plan. Observe is **not migration**: no routes were drafted, no`,
141
+ "model calls rerouted. Applying the wiring below records each run as a run → step →",
142
+ "artifact chain you click through in the console — and with the flag off, your pipeline",
143
+ "behaves **byte-for-byte** as before.",
144
+ "",
145
+ `Detected **${result.sitesFound} model call site(s)** across ${result.filesScanned} scanned file(s);`,
146
+ "each is proposed as one instrumented **step**. Apply the diffs one step at a time — a step",
147
+ "you do not understand yet is a step you can leave for later.",
148
+ "",
149
+ "## 1. Turn the namespace on",
150
+ "",
151
+ "```bash",
152
+ "export MODELRIG_ARTIFACTS=1 # enable the artifact namespace",
153
+ "# export MODELRIG_ARTIFACT_STEPS=step_a,step_b # optional: instrument a subset",
154
+ "```",
155
+ "",
156
+ "> **Human handoff (one step, once).** Seeing these runs **in the console** needs a free",
157
+ "> account + an API key minted at <https://app.modelrig.ai> (`/keys`) — a console login a",
158
+ "> coding agent cannot perform. Set `MODELRIG_API_KEY=<key>` once a human provides it; the",
159
+ "> default ingest host (`https://api.modelrig.ai`) needs no other config. Everything else",
160
+ "> below an agent can do now — plan the handoff, do not stall on it.",
161
+ "",
162
+ ];
163
+ if (plans.length === 0) {
164
+ lines.push("## No model call sites found", "", "Nothing matched in the scanned files. If you know there are model calls here, they may sit", "behind a helper that hides the SDK — point `modelrig observe` at the file that actually", "calls the provider, or wire `withRun` / `recordStep` by hand from the seam helper above.", "");
165
+ return `${lines.join("\n")}\n`;
166
+ }
167
+ const boundary = runBoundaryFile(plans);
168
+ const seamNoExt = seamPath.replace(/\.[jt]sx?$/, "");
169
+ const boundaryImport = boundary === null ? seamNoExt : importSpecifier(boundary, seamPath, path);
170
+ lines.push("## 2. Open a run context around the pipeline", "", boundary === null
171
+ ? "Wrap your pipeline's entry point in `withRun(...)` from the seam helper:"
172
+ : `Your pipeline entry looks like \`${boundary}\` (the shallowest detected call site — a` +
173
+ " heuristic; move this if your real entry is elsewhere). Wrap it in `withRun(...)`:", "", "```diff", `+ import { withRun } from "${boundaryImport}";`, "", "- export async function runPipeline(input) {", "- /* ... your steps ... */", "- }", "+ export async function runPipeline(input) {", "+ return withRun(", '+ { pipeline: "my-pipeline", episodeKey: input.attemptId },', "+ async () => {", "+ /* ... your steps ... */", "+ },", "+ );", "+ }", "```", "", "## 3. Record each step's work products", "", "Each detected model call is one step. After the call parses its output, add a `recordStep`", "(the diffs below quote the call line so you can find it):", "");
174
+ // Group the per-site wiring diffs by file so each file gets one import line.
175
+ const byFile = new Map();
176
+ for (const plan of plans) {
177
+ const list = byFile.get(plan.site.file) ?? [];
178
+ list.push(plan);
179
+ byFile.set(plan.site.file, list);
180
+ }
181
+ for (const [file, filePlans] of byFile) {
182
+ lines.push(`### \`${file}\``, "", "```diff", `+ import { recordStep } from "${importSpecifier(file, seamPath, path)}";`, "");
183
+ for (const plan of filePlans) {
184
+ lines.push(` // line ${plan.site.line}: ${plan.site.provider}` +
185
+ `${plan.site.model !== null ? ` ${plan.site.model}` : ""} call — save its work products`, ...plan.snippet.split("\n").map((l) => `+ ${l}`), "");
186
+ }
187
+ lines.push("```", "");
188
+ }
189
+ lines.push("## 4. See it", "", "Run your pipeline once, then open the console: **Runs** lists the run, `/runs/[id]` renders", "the semantic chain (artifacts grouped by step, with hashes and evaluation badges), and", "`/artifacts/[id]` shows one artifact's lineage. Un-routed steps show **cost n/a** — correct", "for observe-only; nothing routes through the rig yet.", "", "## When you are ready to migrate (later, optional)", "", "Observe answers *what is my pipeline doing?* When you want to *change what serves a step*,", "that is route extraction (T2) — a separate, behaviour-affecting move behind its own review:", "`modelrig init --scope <this pipeline>`. Observe first is the safer order.", "");
190
+ return `${lines.join("\n")}\n`;
191
+ }
192
+ function runObserve(deps, options = {}) {
193
+ const scan = (0, finder_1.scanRepoForCallSites)(deps.root, deps.fs, deps.path, options);
194
+ const used = new Set();
195
+ const plans = scan.sites.map((site) => {
196
+ const stepKey = stepKeyFor(site, used);
197
+ return { site, stepKey, snippet: recordStepSnippet(stepKey) };
198
+ });
199
+ const seamPath = deps.path.join(deps.outDir, "record-step.ts");
200
+ // Import specifiers and prose are computed root-relative — call sites come
201
+ // back relative to `root`, so the seam must be expressed the same way for
202
+ // `path.relative` to yield a sane `../../modelrig/observe/...` specifier.
203
+ const seamRel = deps.path.relative(deps.root, seamPath);
204
+ const content = seamContent();
205
+ const scaffoldMarkdown = buildObserveMarkdown(plans, seamRel, { sitesFound: scan.sites.length, filesScanned: scan.filesScanned, filesSkipped: scan.filesSkipped }, deps.path);
206
+ if (options.dryRun === true) {
207
+ return {
208
+ plans,
209
+ sitesFound: scan.sites.length,
210
+ filesScanned: scan.filesScanned,
211
+ filesSkipped: scan.filesSkipped,
212
+ seamPath,
213
+ seamContent: content,
214
+ scaffoldMarkdown,
215
+ written: [],
216
+ skipped: [],
217
+ };
218
+ }
219
+ deps.fs.mkdirSync(deps.outDir, { recursive: true });
220
+ const written = [];
221
+ const skipped = [];
222
+ // The seam is the customer's to edit — never clobber an existing one.
223
+ if (deps.fs.existsSync(seamPath)) {
224
+ skipped.push(seamPath);
225
+ }
226
+ else {
227
+ deps.fs.writeFileSync(seamPath, content, "utf8");
228
+ written.push(seamPath);
229
+ }
230
+ // OBSERVE.md is a regenerated report, not a hand-edited draft — always rewrite.
231
+ const planPath = deps.path.join(deps.outDir, "OBSERVE.md");
232
+ deps.fs.writeFileSync(planPath, scaffoldMarkdown, "utf8");
233
+ written.push(planPath);
234
+ return {
235
+ plans,
236
+ sitesFound: scan.sites.length,
237
+ filesScanned: scan.filesScanned,
238
+ filesSkipped: scan.filesSkipped,
239
+ seamPath,
240
+ seamContent: content,
241
+ scaffoldMarkdown,
242
+ written,
243
+ skipped,
244
+ };
245
+ }
@@ -0,0 +1,99 @@
1
+ /**
2
+ * `modelrig init` v0 — spec WS2.
3
+ *
4
+ * Finds provider call sites in a repo, drafts a route bundle per site, and
5
+ * writes a MIGRATION.md mapping call site → route → the `rig.run` line that
6
+ * would replace it.
7
+ *
8
+ * THE HARD RULE, restated because it is the whole design: init NEVER edits
9
+ * the target's source. It writes under `modelrig/routes/drafts/` and nothing
10
+ * else. The diff is the human's to apply — spec §4 puts writing-to-source
11
+ * permanently out of scope for this phase, and the drafts-only property is
12
+ * tested, not just documented.
13
+ */
14
+ import type { CallSite, FileSystemLike, FinderOptions } from "./finder";
15
+ import type { ModelSelectRow, CapabilityPredicate } from "../registry/select";
16
+ import type { RouteDraft } from "../routes/draft";
17
+ /**
18
+ * The cost opportunity at a call site — SHOWN, never taken.
19
+ *
20
+ * A migration draft routes to the incumbent so the first run reproduces
21
+ * today's behavior (see draft.ts on why `prefer` is empty). That is a
22
+ * sequencing decision, not a decision to ignore cost: the saving is the
23
+ * whole point of the product, so the migration map names it and hands over
24
+ * the one command that would prove it.
25
+ *
26
+ * The number is INDICATIVE. It comes from probe runs on a generic schema
27
+ * task, not from the caller's traffic — which is exactly why the honest move
28
+ * is to show it next to a bake-off command rather than act on it.
29
+ */
30
+ export interface CostOutlook {
31
+ readonly incumbentEffectiveUsdPer1k: number | null;
32
+ readonly bestChallenger: {
33
+ readonly model: string;
34
+ readonly effectiveUsdPer1k: number;
35
+ } | null;
36
+ /** Indicative only; null when the incumbent is unprobed. */
37
+ readonly indicativeSavingsPct: number | null;
38
+ /** Why the number is, or is not, available. */
39
+ readonly note: string;
40
+ }
41
+ export interface InitDraft {
42
+ readonly route: string;
43
+ readonly site: CallSite;
44
+ readonly draft: RouteDraft;
45
+ readonly candidateReasoning: readonly string[];
46
+ /** The rig.run(...) call that would replace this site. */
47
+ readonly replacement: string;
48
+ readonly costOutlook: CostOutlook;
49
+ }
50
+ export interface InitResult {
51
+ readonly drafts: readonly InitDraft[];
52
+ readonly sitesFound: number;
53
+ readonly filesScanned: number;
54
+ readonly filesSkipped: readonly string[];
55
+ readonly written: readonly string[];
56
+ readonly skipped: readonly string[];
57
+ readonly migrationMarkdown: string;
58
+ }
59
+ export interface InitOptions extends FinderOptions {
60
+ /** Registry rows for candidate seeding; empty = incumbent-only drafts. */
61
+ readonly registryRows?: readonly ModelSelectRow[];
62
+ readonly challengerCount?: number;
63
+ /** Plan without writing (`--dry-run`). */
64
+ readonly dryRun?: boolean;
65
+ }
66
+ export interface InitDeps {
67
+ readonly root: string;
68
+ readonly draftsDir: string;
69
+ readonly fs: FileSystemLike & {
70
+ existsSync: (p: string) => boolean;
71
+ mkdirSync: (p: string, o: {
72
+ recursive: boolean;
73
+ }) => void;
74
+ writeFileSync: (p: string, c: string, e: "utf8") => void;
75
+ };
76
+ readonly path: {
77
+ join: (...parts: string[]) => string;
78
+ relative: (from: string, to: string) => string;
79
+ dirname: (p: string) => string;
80
+ basename: (p: string, ext?: string) => string;
81
+ };
82
+ }
83
+ /** Route name from a call site: `<file stem>.<line>` namespaced by its
84
+ * directory, e.g. "services.asset_classifier_42". Deterministic so a second
85
+ * run produces the same names and therefore skips the same drafts. */
86
+ export declare function routeNameFor(site: CallSite, basename: (p: string, ext?: string) => string): string;
87
+ /** What the site's structured-output usage implies about capability needs.
88
+ * Conservative: a json_schema request implies native enforcement is wanted;
89
+ * bare JSON mode only implies conformance. */
90
+ export declare function capabilitiesFor(site: CallSite): CapabilityPredicate[];
91
+ /** Price the incumbent against the cheapest probed challenger, honestly. */
92
+ export declare function buildCostOutlook(incumbentKey: string | null, challengerKeys: readonly string[], rows: readonly ModelSelectRow[]): CostOutlook;
93
+ export declare function buildMigrationMarkdown(drafts: readonly InitDraft[], result: {
94
+ sitesFound: number;
95
+ filesScanned: number;
96
+ filesSkipped: readonly string[];
97
+ }): string;
98
+ export declare function runInit(deps: InitDeps, options?: InitOptions): InitResult;
99
+ //# sourceMappingURL=run.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../../src/init/run.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAKH,OAAO,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACxE,OAAO,KAAK,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAC9E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAElD;;;;;;;;;;;;GAYG;AACH,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,0BAA0B,EAAE,MAAM,GAAG,IAAI,CAAC;IACnD,QAAQ,CAAC,cAAc,EAAE;QACvB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;QACvB,QAAQ,CAAC,iBAAiB,EAAE,MAAM,CAAC;KACpC,GAAG,IAAI,CAAC;IACT,4DAA4D;IAC5D,QAAQ,CAAC,oBAAoB,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7C,+CAA+C;IAC/C,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IACxB,QAAQ,CAAC,KAAK,EAAE,UAAU,CAAC;IAC3B,QAAQ,CAAC,kBAAkB,EAAE,SAAS,MAAM,EAAE,CAAC;IAC/C,0DAA0D;IAC1D,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,WAAW,EAAE,WAAW,CAAC;CACnC;AAED,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,MAAM,EAAE,SAAS,SAAS,EAAE,CAAC;IACtC,QAAQ,CAAC,UAAU,EAAE,MAAM,CA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