modelrig 0.0.1 → 0.1.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 (220) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +115 -8
  3. package/dist/adapters/anthropic.d.ts +46 -0
  4. package/dist/adapters/anthropic.d.ts.map +1 -0
  5. package/dist/adapters/anthropic.js +202 -0
  6. package/dist/adapters/deepseek.d.ts +41 -0
  7. package/dist/adapters/deepseek.d.ts.map +1 -0
  8. package/dist/adapters/deepseek.js +163 -0
  9. package/dist/adapters/gemini.d.ts +44 -0
  10. package/dist/adapters/gemini.d.ts.map +1 -0
  11. package/dist/adapters/gemini.js +222 -0
  12. package/dist/adapters/grok.d.ts +44 -0
  13. package/dist/adapters/grok.d.ts.map +1 -0
  14. package/dist/adapters/grok.js +168 -0
  15. package/dist/adapters/openai-compat.d.ts +74 -0
  16. package/dist/adapters/openai-compat.d.ts.map +1 -0
  17. package/dist/adapters/openai-compat.js +187 -0
  18. package/dist/adapters/openai.d.ts +49 -0
  19. package/dist/adapters/openai.d.ts.map +1 -0
  20. package/dist/adapters/openai.js +222 -0
  21. package/dist/bakeoff/engine.d.ts +52 -0
  22. package/dist/bakeoff/engine.d.ts.map +1 -0
  23. package/dist/bakeoff/engine.js +163 -0
  24. package/dist/bakeoff/replay.d.ts +52 -0
  25. package/dist/bakeoff/replay.d.ts.map +1 -0
  26. package/dist/bakeoff/replay.js +94 -0
  27. package/dist/bakeoff/samples.d.ts +62 -0
  28. package/dist/bakeoff/samples.d.ts.map +1 -0
  29. package/dist/bakeoff/samples.js +128 -0
  30. package/dist/bakeoff/stats.d.ts +13 -0
  31. package/dist/bakeoff/stats.d.ts.map +1 -0
  32. package/dist/bakeoff/stats.js +48 -0
  33. package/dist/bakeoff/types.d.ts +37 -0
  34. package/dist/bakeoff/types.d.ts.map +1 -0
  35. package/dist/bakeoff/types.js +10 -0
  36. package/dist/cli.d.ts +27 -0
  37. package/dist/cli.d.ts.map +1 -0
  38. package/dist/cli.js +572 -0
  39. package/dist/config.d.ts +104 -0
  40. package/dist/config.d.ts.map +1 -0
  41. package/dist/config.js +148 -0
  42. package/dist/feedback/coverage.d.ts +32 -0
  43. package/dist/feedback/coverage.d.ts.map +1 -0
  44. package/dist/feedback/coverage.js +95 -0
  45. package/dist/feedback/feedback.d.ts +35 -0
  46. package/dist/feedback/feedback.d.ts.map +1 -0
  47. package/dist/feedback/feedback.js +39 -0
  48. package/dist/index.d.ts +155 -0
  49. package/dist/index.d.ts.map +1 -0
  50. package/dist/index.js +448 -0
  51. package/dist/init/finder.d.ts +79 -0
  52. package/dist/init/finder.d.ts.map +1 -0
  53. package/dist/init/finder.js +297 -0
  54. package/dist/init/run.d.ts +99 -0
  55. package/dist/init/run.d.ts.map +1 -0
  56. package/dist/init/run.js +281 -0
  57. package/dist/init/signatures.d.ts +39 -0
  58. package/dist/init/signatures.d.ts.map +1 -0
  59. package/dist/init/signatures.js +116 -0
  60. package/dist/matrix/aggregate.d.ts +89 -0
  61. package/dist/matrix/aggregate.d.ts.map +1 -0
  62. package/dist/matrix/aggregate.js +186 -0
  63. package/dist/query/grammar.d.ts +35 -0
  64. package/dist/query/grammar.d.ts.map +1 -0
  65. package/dist/query/grammar.js +279 -0
  66. package/dist/query/run.d.ts +8 -0
  67. package/dist/query/run.d.ts.map +1 -0
  68. package/dist/query/run.js +21 -0
  69. package/dist/registry/build.d.ts +126 -0
  70. package/dist/registry/build.d.ts.map +1 -0
  71. package/dist/registry/build.js +192 -0
  72. package/dist/registry/call-notes.d.ts +11 -0
  73. package/dist/registry/call-notes.d.ts.map +1 -0
  74. package/dist/registry/call-notes.js +72 -0
  75. package/dist/registry/claims.d.ts +63 -0
  76. package/dist/registry/claims.d.ts.map +1 -0
  77. package/dist/registry/claims.js +107 -0
  78. package/dist/registry/facts.d.ts +32 -0
  79. package/dist/registry/facts.d.ts.map +1 -0
  80. package/dist/registry/facts.js +120 -0
  81. package/dist/registry/fingerprint.d.ts +20 -0
  82. package/dist/registry/fingerprint.d.ts.map +1 -0
  83. package/dist/registry/fingerprint.js +150 -0
  84. package/dist/registry/parity.d.ts +26 -0
  85. package/dist/registry/parity.d.ts.map +1 -0
  86. package/dist/registry/parity.js +41 -0
  87. package/dist/registry/pricing.d.ts +19 -0
  88. package/dist/registry/pricing.d.ts.map +1 -0
  89. package/dist/registry/pricing.js +69 -0
  90. package/dist/registry/rows.d.ts +16 -0
  91. package/dist/registry/rows.d.ts.map +1 -0
  92. package/dist/registry/rows.js +57 -0
  93. package/dist/registry/seed.d.ts +43 -0
  94. package/dist/registry/seed.d.ts.map +1 -0
  95. package/dist/registry/seed.js +97 -0
  96. package/dist/registry/select.d.ts +68 -0
  97. package/dist/registry/select.d.ts.map +1 -0
  98. package/dist/registry/select.js +141 -0
  99. package/dist/registry/staleness.d.ts +18 -0
  100. package/dist/registry/staleness.d.ts.map +1 -0
  101. package/dist/registry/staleness.js +39 -0
  102. package/dist/routes/draft.d.ts +83 -0
  103. package/dist/routes/draft.d.ts.map +1 -0
  104. package/dist/routes/draft.js +135 -0
  105. package/dist/routes/loader.d.ts +26 -0
  106. package/dist/routes/loader.d.ts.map +1 -0
  107. package/dist/routes/loader.js +436 -0
  108. package/dist/routes/manifest.d.ts +24 -0
  109. package/dist/routes/manifest.d.ts.map +1 -0
  110. package/dist/routes/manifest.js +118 -0
  111. package/dist/routes/serveability.d.ts +52 -0
  112. package/dist/routes/serveability.d.ts.map +1 -0
  113. package/dist/routes/serveability.js +73 -0
  114. package/dist/routes/template.d.ts +18 -0
  115. package/dist/routes/template.d.ts.map +1 -0
  116. package/dist/routes/template.js +94 -0
  117. package/dist/run/cost.d.ts +26 -0
  118. package/dist/run/cost.d.ts.map +1 -0
  119. package/dist/run/cost.js +41 -0
  120. package/dist/run/envelope.d.ts +21 -0
  121. package/dist/run/envelope.d.ts.map +1 -0
  122. package/dist/run/envelope.js +45 -0
  123. package/dist/run/grounding.d.ts +56 -0
  124. package/dist/run/grounding.d.ts.map +1 -0
  125. package/dist/run/grounding.js +89 -0
  126. package/dist/run/repair.d.ts +36 -0
  127. package/dist/run/repair.d.ts.map +1 -0
  128. package/dist/run/repair.js +61 -0
  129. package/dist/run/resolve.d.ts +26 -0
  130. package/dist/run/resolve.d.ts.map +1 -0
  131. package/dist/run/resolve.js +81 -0
  132. package/dist/run/retry.d.ts +19 -0
  133. package/dist/run/retry.d.ts.map +1 -0
  134. package/dist/run/retry.js +50 -0
  135. package/dist/run/run.d.ts +41 -0
  136. package/dist/run/run.d.ts.map +1 -0
  137. package/dist/run/run.js +0 -0
  138. package/dist/run/validate.d.ts +15 -0
  139. package/dist/run/validate.d.ts.map +1 -0
  140. package/dist/run/validate.js +56 -0
  141. package/dist/savings/emit.d.ts +25 -0
  142. package/dist/savings/emit.d.ts.map +1 -0
  143. package/dist/savings/emit.js +75 -0
  144. package/dist/savings/odometer.d.ts +32 -0
  145. package/dist/savings/odometer.d.ts.map +1 -0
  146. package/dist/savings/odometer.js +70 -0
  147. package/dist/savings/swap-execute.d.ts +44 -0
  148. package/dist/savings/swap-execute.d.ts.map +1 -0
  149. package/dist/savings/swap-execute.js +87 -0
  150. package/dist/savings/swaps-client.d.ts +41 -0
  151. package/dist/savings/swaps-client.d.ts.map +1 -0
  152. package/dist/savings/swaps-client.js +81 -0
  153. package/dist/telemetry/capture.d.ts +28 -0
  154. package/dist/telemetry/capture.d.ts.map +1 -0
  155. package/dist/telemetry/capture.js +74 -0
  156. package/dist/telemetry/exporter.d.ts +62 -0
  157. package/dist/telemetry/exporter.d.ts.map +1 -0
  158. package/dist/telemetry/exporter.js +233 -0
  159. package/dist/telemetry/ingest-protocol.d.ts +161 -0
  160. package/dist/telemetry/ingest-protocol.d.ts.map +1 -0
  161. package/dist/telemetry/ingest-protocol.js +163 -0
  162. package/dist/telemetry/sinks.d.ts +54 -0
  163. package/dist/telemetry/sinks.d.ts.map +1 -0
  164. package/dist/telemetry/sinks.js +89 -0
  165. package/dist/telemetry/store.d.ts +38 -0
  166. package/dist/telemetry/store.d.ts.map +1 -0
  167. package/dist/telemetry/store.js +332 -0
  168. package/dist/telemetry/supabase-exporter.d.ts +64 -0
  169. package/dist/telemetry/supabase-exporter.d.ts.map +1 -0
  170. package/dist/telemetry/supabase-exporter.js +211 -0
  171. package/dist/tenancy/api-key-format.d.ts +67 -0
  172. package/dist/tenancy/api-key-format.d.ts.map +1 -0
  173. package/dist/tenancy/api-key-format.js +91 -0
  174. package/dist/tenancy/constants.d.ts +23 -0
  175. package/dist/tenancy/constants.d.ts.map +1 -0
  176. package/dist/tenancy/constants.js +25 -0
  177. package/dist/tenancy/scrub.d.ts +47 -0
  178. package/dist/tenancy/scrub.d.ts.map +1 -0
  179. package/dist/tenancy/scrub.js +85 -0
  180. package/dist/types/failures-teaching.d.ts +56 -0
  181. package/dist/types/failures-teaching.d.ts.map +1 -0
  182. package/dist/types/failures-teaching.js +177 -0
  183. package/dist/types/failures.d.ts +27 -0
  184. package/dist/types/failures.d.ts.map +1 -0
  185. package/dist/types/failures.js +41 -0
  186. package/dist/types/provider.d.ts +79 -0
  187. package/dist/types/provider.d.ts.map +1 -0
  188. package/dist/types/provider.js +20 -0
  189. package/dist/types/route.d.ts +127 -0
  190. package/dist/types/route.d.ts.map +1 -0
  191. package/dist/types/route.js +6 -0
  192. package/dist/types/telemetry.d.ts +89 -0
  193. package/dist/types/telemetry.d.ts.map +1 -0
  194. package/dist/types/telemetry.js +6 -0
  195. package/dist/watch/budget.d.ts +19 -0
  196. package/dist/watch/budget.d.ts.map +1 -0
  197. package/dist/watch/budget.js +35 -0
  198. package/dist/watch/evaluate.d.ts +66 -0
  199. package/dist/watch/evaluate.d.ts.map +1 -0
  200. package/dist/watch/evaluate.js +94 -0
  201. package/dist/watch/proposals.d.ts +73 -0
  202. package/dist/watch/proposals.d.ts.map +1 -0
  203. package/dist/watch/proposals.js +169 -0
  204. package/dist/watch/run-record.d.ts +64 -0
  205. package/dist/watch/run-record.d.ts.map +1 -0
  206. package/dist/watch/run-record.js +86 -0
  207. package/dist/watch/run-reported.d.ts +20 -0
  208. package/dist/watch/run-reported.d.ts.map +1 -0
  209. package/dist/watch/run-reported.js +53 -0
  210. package/dist/watch/run.d.ts +40 -0
  211. package/dist/watch/run.d.ts.map +1 -0
  212. package/dist/watch/run.js +44 -0
  213. package/dist/watch/state-store.d.ts +48 -0
  214. package/dist/watch/state-store.d.ts.map +1 -0
  215. package/dist/watch/state-store.js +86 -0
  216. package/dist/watch/state.d.ts +21 -0
  217. package/dist/watch/state.d.ts.map +1 -0
  218. package/dist/watch/state.js +93 -0
  219. package/package.json +50 -14
  220. package/index.js +0 -3
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,KAAK,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAEnE,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;IACjC,QAAQ,CAAC,IAAI,EAAE;QACb,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;QACzB,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;QACzB,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;QAC3B,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;QAC5B,qDAAqD;QACrD,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;QACvB,+DAA+D;QAC/D,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;QAC5B,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;KAC7B,CAAC;IACF,kFAAkF;IAClF,QAAQ,CAAC,iBAAiB,CAAC,EAAE,MAAM,CAAC;IACpC;8EAC0E;IAC1E,QAAQ,CAAC,sBAAsB,CAAC,EAAE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;IACnC,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACpC;AAED;;kEAEkE;AAClE,eAAO,MAAM,gBAAgB,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAQ7D,CAAC;AAKF,wBAAgB,iBAAiB,CAAC,SAAS,CAAC,EAAE,OAAO,CAAC,SAAS,CAAC,GAAG,SAAS,CAwG3E;AAED;;;;;;;;GAQG;AACH,wBAAgB,cAAc,CAC5B,MAAM,EAAE,SAAS,EACjB,IAAI,EAAE,MAAM,GACX;IAAE,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAE,CAgB/F"}
package/dist/config.js ADDED
@@ -0,0 +1,148 @@
1
+ "use strict";
2
+ /**
3
+ * Configuration — plan §3. THE ONLY FILE that reads process.env in this
4
+ * package (adapters receive keys via constructors; enforced by
5
+ * __tests__/package-invariants.test.ts).
6
+ */
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ exports.PROVIDER_KEY_ENV = void 0;
9
+ exports.loadConfigFromEnv = loadConfigFromEnv;
10
+ exports.directExportOf = directExportOf;
11
+ const ingest_protocol_1 = require("./telemetry/ingest-protocol");
12
+ /** Provider → the env var that keys it. One table so error surfaces can say
13
+ * WHICH variable to set rather than "no key configured" (F1 / WS3: errors
14
+ * that teach). `loadConfigFromEnv` below reads the same names. */
15
+ exports.PROVIDER_KEY_ENV = {
16
+ gemini: "GEMINI_API_KEY",
17
+ openai: "OPENAI_API_KEY",
18
+ deepseek: "DEEPSEEK_API_KEY",
19
+ anthropic: "ANTHROPIC_API_KEY",
20
+ grok: "XAI_API_KEY",
21
+ deepinfra: "MODELRIG_DEEPINFRA_API_KEY",
22
+ fireworks: "MODELRIG_FIREWORKS_API_KEY",
23
+ };
24
+ const DEFAULT_ROUTES_DIR = "./modelrig/routes";
25
+ const DEFAULT_TELEMETRY_DB = "./.modelrig/telemetry.db";
26
+ function loadConfigFromEnv(overrides) {
27
+ const env = process.env;
28
+ const budgetRaw = env.MODELRIG_ENVELOPE_BUDGET_USD;
29
+ const budget = budgetRaw !== undefined && budgetRaw !== "" ? Number(budgetRaw) : undefined;
30
+ const supabaseUrl = env.MODELRIG_SUPABASE_URL;
31
+ const serviceRoleKey = env.MODELRIG_SUPABASE_SERVICE_ROLE_KEY;
32
+ const apiKey = env.MODELRIG_API_KEY;
33
+ const fromEnv = {
34
+ routesDir: env.MODELRIG_ROUTES_DIR ?? DEFAULT_ROUTES_DIR,
35
+ telemetryDbPath: env.MODELRIG_TELEMETRY_DB ?? DEFAULT_TELEMETRY_DB,
36
+ ...(env.MODELRIG_REGISTRY_PATH ? { registryPath: env.MODELRIG_REGISTRY_PATH } : {}),
37
+ keys: {
38
+ ...(env.GEMINI_API_KEY ? { gemini: env.GEMINI_API_KEY } : {}),
39
+ ...(env.OPENAI_API_KEY ? { openai: env.OPENAI_API_KEY } : {}),
40
+ ...(env.DEEPSEEK_API_KEY ? { deepseek: env.DEEPSEEK_API_KEY } : {}),
41
+ ...(env.ANTHROPIC_API_KEY ? { anthropic: env.ANTHROPIC_API_KEY } : {}),
42
+ ...(env.XAI_API_KEY ? { grok: env.XAI_API_KEY } : {}),
43
+ // A1 hosts: ModelRig-scoped names on purpose (same doctrine as Tavily).
44
+ ...(env.MODELRIG_DEEPINFRA_API_KEY ? { deepinfra: env.MODELRIG_DEEPINFRA_API_KEY } : {}),
45
+ ...(env.MODELRIG_FIREWORKS_API_KEY ? { fireworks: env.MODELRIG_FIREWORKS_API_KEY } : {}),
46
+ },
47
+ ...(budget !== undefined && Number.isFinite(budget) ? { envelopeBudgetUsd: budget } : {}),
48
+ ...(env.MODELRIG_UNPRICED_RATE_USD_PER_MTOK &&
49
+ Number.isFinite(Number(env.MODELRIG_UNPRICED_RATE_USD_PER_MTOK))
50
+ ? { unpricedRateUsdPerMTok: Number(env.MODELRIG_UNPRICED_RATE_USD_PER_MTOK) }
51
+ : {}),
52
+ // Grounding-inject search (WS3). ModelRig-scoped key on purpose — never
53
+ // silently reusing another app's TAVILY_API_KEY.
54
+ ...(env.MODELRIG_TAVILY_API_KEY
55
+ ? {
56
+ search: {
57
+ tavilyApiKey: env.MODELRIG_TAVILY_API_KEY,
58
+ ...(env.MODELRIG_SEARCH_COST_USD && Number.isFinite(Number(env.MODELRIG_SEARCH_COST_USD))
59
+ ? { costPerSearchUsd: Number(env.MODELRIG_SEARCH_COST_USD) }
60
+ : {}),
61
+ ...(env.MODELRIG_SEARCH_DEPTH === "advanced" ? { searchDepth: "advanced" } : {}),
62
+ },
63
+ }
64
+ : {}),
65
+ // Watch loop caps (Phase 4 WS1) — folded only when either env is set.
66
+ ...(() => {
67
+ const monthly = env.MODELRIG_WATCH_MONTHLY_USD;
68
+ const threshold = env.MODELRIG_WATCH_THRESHOLD_PCT;
69
+ const monthlyNum = monthly !== undefined && monthly !== "" ? Number(monthly) : undefined;
70
+ const thresholdNum = threshold !== undefined && threshold !== "" ? Number(threshold) : undefined;
71
+ const watch = {
72
+ ...(monthlyNum !== undefined && Number.isFinite(monthlyNum) && monthlyNum > 0
73
+ ? { monthlyUsd: monthlyNum }
74
+ : {}),
75
+ ...(thresholdNum !== undefined && Number.isFinite(thresholdNum) && thresholdNum > 0
76
+ ? { thresholdPct: thresholdNum }
77
+ : {}),
78
+ };
79
+ return Object.keys(watch).length > 0 ? { watch } : {};
80
+ })(),
81
+ // The sink is optional and never required for the run loop (spec §5).
82
+ // Selection follows telemetry-ingestion-boundary.md §2.1 exactly.
83
+ ...(() => {
84
+ const common = {
85
+ ...(env.MODELRIG_SOURCE_ID ? { sourceId: env.MODELRIG_SOURCE_ID } : {}),
86
+ };
87
+ if (apiKey) {
88
+ if (supabaseUrl && serviceRoleKey) {
89
+ // Both configured. api wins — it is the mode that does not hand a
90
+ // service-role key to a client — and the warning is loud because a
91
+ // silent choice between two live sinks is how telemetry ends up in
92
+ // the wrong place with nobody looking.
93
+ console.warn("[modelrig] both MODELRIG_API_KEY and MODELRIG_SUPABASE_URL are set — using api mode. " +
94
+ "Remove the MODELRIG_SUPABASE_* pair unless this deployment is self-hosting its own " +
95
+ "control plane.");
96
+ }
97
+ return {
98
+ export: {
99
+ mode: "api",
100
+ apiKey,
101
+ ingestUrl: env.MODELRIG_INGEST_URL || ingest_protocol_1.DEFAULT_INGEST_URL,
102
+ ...common,
103
+ },
104
+ };
105
+ }
106
+ if (supabaseUrl && serviceRoleKey) {
107
+ return {
108
+ export: {
109
+ mode: "direct",
110
+ supabaseUrl,
111
+ serviceRoleKey,
112
+ ...(env.MODELRIG_ORG_ID ? { orgId: env.MODELRIG_ORG_ID } : {}),
113
+ ...(env.MODELRIG_PROJECT_ID ? { projectId: env.MODELRIG_PROJECT_ID } : {}),
114
+ ...common,
115
+ },
116
+ };
117
+ }
118
+ return {};
119
+ })(),
120
+ };
121
+ return {
122
+ ...fromEnv,
123
+ ...overrides,
124
+ keys: { ...fromEnv.keys, ...overrides?.keys },
125
+ };
126
+ }
127
+ /**
128
+ * Narrow `config.export` to DIRECT mode, or explain why the command cannot run.
129
+ *
130
+ * Phase 6 WS2 gave the export config two modes. Every command below needs a
131
+ * service-role control-plane client — proposals, swap events, bake-off
132
+ * mirrors, sample purges — and none of those has an ingest endpoint. A rig
133
+ * configured in api mode therefore genuinely cannot run them, and saying so is
134
+ * better than the `undefined` deref this used to be one refactor away from.
135
+ */
136
+ function directExportOf(config, what) {
137
+ const exp = config.export;
138
+ if (exp === undefined) {
139
+ throw new Error(`${what} needs the control plane: set MODELRIG_SUPABASE_URL and ` +
140
+ "MODELRIG_SUPABASE_SERVICE_ROLE_KEY");
141
+ }
142
+ if (exp.mode !== "direct") {
143
+ throw new Error(`${what} needs direct control-plane access, and this rig is in api mode ` +
144
+ "(MODELRIG_API_KEY). Telemetry ingest goes through the hosted API; this command does " +
145
+ "not — run it where MODELRIG_SUPABASE_URL and MODELRIG_SUPABASE_SERVICE_ROLE_KEY are set.");
146
+ }
147
+ return exp;
148
+ }
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Optimization coverage, rungs 0–1 — Phase 4 WS2. Pure aggregation over
3
+ * telemetry + feedback rows; no store access, so the console, the server
4
+ * and tests all compute identically.
5
+ *
6
+ * Rungs (the eval ladder's bottom, per plan §4):
7
+ * rung 0 — implicit signals only: conformance / repair / refusal rates
8
+ * from telemetry. Enough confidence for schema-mechanical swap
9
+ * proposals (the bake-off gate).
10
+ * rung 1 — ≥ RUNG1_MIN_FEEDBACK human/agent verdicts attached: prose
11
+ * routes (no schema to conform to) gain proposal confidence.
12
+ * rung 2+ — judges; Phase 5+, out of scope by decision.
13
+ */
14
+ import type { FeedbackRow, TelemetryRow } from "../types/telemetry";
15
+ export declare const RUNG1_MIN_FEEDBACK = 10;
16
+ export interface RouteCoverage {
17
+ readonly route: string;
18
+ readonly samples: number;
19
+ /** Share of rows with no failure class — the implicit conformance signal. */
20
+ readonly conformRate: number;
21
+ readonly repairRate: number;
22
+ readonly refusalRate: number;
23
+ readonly feedbackCount: number;
24
+ readonly rung: 0 | 1;
25
+ /** Teaching copy: what reaching the next rung takes and unlocks. */
26
+ readonly nextRungUnlock: string;
27
+ }
28
+ /** Attribution: a feedback row joins a route via its inference id, or via
29
+ * its episode key matching a row's run_id tag. Unmatched feedback attaches
30
+ * to nothing (never guessed). */
31
+ export declare function computeCoverage(rows: readonly TelemetryRow[], feedback: readonly FeedbackRow[]): RouteCoverage[];
32
+ //# sourceMappingURL=coverage.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"coverage.d.ts","sourceRoot":"","sources":["../../src/feedback/coverage.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAEpE,eAAO,MAAM,kBAAkB,KAAK,CAAC;AAErC,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,6EAA6E;IAC7E,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,CAAC;IACrB,oEAAoE;IACpE,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;CACjC;AAED;;iCAEiC;AACjC,wBAAgB,eAAe,CAC7B,IAAI,EAAE,SAAS,YAAY,EAAE,EAC7B,QAAQ,EAAE,SAAS,WAAW,EAAE,GAC/B,aAAa,EAAE,CA2EjB"}
@@ -0,0 +1,95 @@
1
+ "use strict";
2
+ /**
3
+ * Optimization coverage, rungs 0–1 — Phase 4 WS2. Pure aggregation over
4
+ * telemetry + feedback rows; no store access, so the console, the server
5
+ * and tests all compute identically.
6
+ *
7
+ * Rungs (the eval ladder's bottom, per plan §4):
8
+ * rung 0 — implicit signals only: conformance / repair / refusal rates
9
+ * from telemetry. Enough confidence for schema-mechanical swap
10
+ * proposals (the bake-off gate).
11
+ * rung 1 — ≥ RUNG1_MIN_FEEDBACK human/agent verdicts attached: prose
12
+ * routes (no schema to conform to) gain proposal confidence.
13
+ * rung 2+ — judges; Phase 5+, out of scope by decision.
14
+ */
15
+ Object.defineProperty(exports, "__esModule", { value: true });
16
+ exports.RUNG1_MIN_FEEDBACK = void 0;
17
+ exports.computeCoverage = computeCoverage;
18
+ exports.RUNG1_MIN_FEEDBACK = 10;
19
+ /** Attribution: a feedback row joins a route via its inference id, or via
20
+ * its episode key matching a row's run_id tag. Unmatched feedback attaches
21
+ * to nothing (never guessed). */
22
+ function computeCoverage(rows, feedback) {
23
+ const routeByInferenceId = new Map();
24
+ const routeByEpisode = new Map();
25
+ const byRoute = new Map();
26
+ for (const row of rows) {
27
+ // Exclude replay/shadow traffic (same convention as the console /routes
28
+ // view): bake-off replays are candidate-variant experiments, not the
29
+ // route's production serving — counting them skews conformance/repair
30
+ // rates with losing variants that never served a real request.
31
+ let replayTagged = false;
32
+ try {
33
+ replayTagged = JSON.parse(row.tagsJson).replay !== undefined;
34
+ }
35
+ catch {
36
+ replayTagged = false;
37
+ }
38
+ if (replayTagged)
39
+ continue;
40
+ const agg = byRoute.get(row.route) ?? {
41
+ samples: 0,
42
+ conform: 0,
43
+ repaired: 0,
44
+ refused: 0,
45
+ feedback: 0,
46
+ };
47
+ agg.samples += 1;
48
+ if (row.failureClass === null)
49
+ agg.conform += 1;
50
+ if (row.repairedBy !== null)
51
+ agg.repaired += 1;
52
+ if (row.failureClass === "refusal")
53
+ agg.refused += 1;
54
+ byRoute.set(row.route, agg);
55
+ routeByInferenceId.set(row.id, row.route);
56
+ try {
57
+ const tags = JSON.parse(row.tagsJson);
58
+ if (typeof tags.run_id === "string" && tags.run_id !== "") {
59
+ routeByEpisode.set(tags.run_id, row.route);
60
+ }
61
+ }
62
+ catch {
63
+ // Unparseable tags never break coverage — the row still counts above.
64
+ }
65
+ }
66
+ for (const f of feedback) {
67
+ const route = (f.inferenceId !== null ? routeByInferenceId.get(f.inferenceId) : undefined) ??
68
+ (f.episodeKey !== null ? routeByEpisode.get(f.episodeKey) : undefined);
69
+ if (route === undefined)
70
+ continue;
71
+ const agg = byRoute.get(route);
72
+ if (agg !== undefined)
73
+ agg.feedback += 1;
74
+ }
75
+ return [...byRoute.entries()]
76
+ .sort(([a], [b]) => a.localeCompare(b))
77
+ .map(([route, agg]) => {
78
+ const rung = agg.feedback >= exports.RUNG1_MIN_FEEDBACK ? 1 : 0;
79
+ const nextRungUnlock = rung === 0
80
+ ? `Attach ${exports.RUNG1_MIN_FEEDBACK - agg.feedback} more rig.feedback() verdicts ` +
81
+ `(${agg.feedback}/${exports.RUNG1_MIN_FEEDBACK}) to reach rung 1 — human-verdict confidence ` +
82
+ "for routes without a schema to conform to."
83
+ : "Rung 2 (LLM judges — value accuracy beyond mechanical conformance) arrives in Phase 5.";
84
+ return {
85
+ route,
86
+ samples: agg.samples,
87
+ conformRate: agg.samples === 0 ? 0 : agg.conform / agg.samples,
88
+ repairRate: agg.samples === 0 ? 0 : agg.repaired / agg.samples,
89
+ refusalRate: agg.samples === 0 ? 0 : agg.refused / agg.samples,
90
+ feedbackCount: agg.feedback,
91
+ rung,
92
+ nextRungUnlock,
93
+ };
94
+ });
95
+ }
@@ -0,0 +1,35 @@
1
+ /**
2
+ * rig.feedback() — Phase 4 WS2 (spec: judgment starts accumulating).
3
+ * The SDK surface normalizes a target (inference id or {episode}) + opts
4
+ * into a FeedbackRow; the write is a synchronous local SQLite insert
5
+ * (fire-and-forget from the caller's view — no network, never throws for
6
+ * sink reasons). The Supabase mirror rides the exporter, dual-store style.
7
+ */
8
+ import type { FeedbackRow } from "../types/telemetry";
9
+ export type FeedbackTarget = string | {
10
+ readonly episode: string;
11
+ };
12
+ export interface FeedbackOpts {
13
+ readonly verdict: "up" | "down";
14
+ /** Optional graded signal in [0, 1]; verdict remains the primary axis. */
15
+ readonly score?: number;
16
+ readonly note?: string;
17
+ /** Who judged: "sdk" (default), a review-agent name, "human", … */
18
+ readonly source?: string;
19
+ /**
20
+ * The org this verdict belongs to (Phase 6 WS2). Omit from application code
21
+ * — a rig has one org and the exporter knows it.
22
+ *
23
+ * Supplied by modelrig-server, and only ever with an org it has ALREADY
24
+ * authorized the caller into: a value that arrived in a request body and was
25
+ * passed through here would be a tenant chosen by the client (T3). Setting
26
+ * it is what lets one hosted server hold verdicts for many orgs without
27
+ * misfiling any of them (QA-P6-010).
28
+ */
29
+ readonly orgId?: string;
30
+ /** Authenticated user who recorded it. Same provenance rule as `orgId`:
31
+ * resolved from a session, never read off a request body. */
32
+ readonly createdBy?: string | null;
33
+ }
34
+ export declare function buildFeedbackRow(target: FeedbackTarget, opts: FeedbackOpts): FeedbackRow;
35
+ //# sourceMappingURL=feedback.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"feedback.d.ts","sourceRoot":"","sources":["../../src/feedback/feedback.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAEtD,MAAM,MAAM,cAAc,GAAG,MAAM,GAAG;IAAE,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC;AAEnE,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,OAAO,EAAE,IAAI,GAAG,MAAM,CAAC;IAChC,0EAA0E;IAC1E,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,mEAAmE;IACnE,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB;;;;;;;;;OASG;IACH,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB;iEAC6D;IAC7D,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACpC;AAED,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,cAAc,EAAE,IAAI,EAAE,YAAY,GAAG,WAAW,CA0BxF"}
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ /**
3
+ * rig.feedback() — Phase 4 WS2 (spec: judgment starts accumulating).
4
+ * The SDK surface normalizes a target (inference id or {episode}) + opts
5
+ * into a FeedbackRow; the write is a synchronous local SQLite insert
6
+ * (fire-and-forget from the caller's view — no network, never throws for
7
+ * sink reasons). The Supabase mirror rides the exporter, dual-store style.
8
+ */
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.buildFeedbackRow = buildFeedbackRow;
11
+ const node_crypto_1 = require("node:crypto");
12
+ function buildFeedbackRow(target, opts) {
13
+ let inferenceId = null;
14
+ let episodeKey = null;
15
+ if (typeof target === "string") {
16
+ inferenceId = target;
17
+ }
18
+ else {
19
+ episodeKey = target.episode;
20
+ }
21
+ if ((inferenceId === null || inferenceId === "") && (episodeKey === null || episodeKey === "")) {
22
+ throw new Error("feedback target must be a non-empty inference id or {episode}");
23
+ }
24
+ if (opts.score !== undefined && (!Number.isFinite(opts.score) || opts.score < 0 || opts.score > 1)) {
25
+ throw new Error(`feedback score must be in [0, 1], got ${opts.score}`);
26
+ }
27
+ return {
28
+ id: (0, node_crypto_1.randomUUID)(),
29
+ ts: new Date().toISOString(),
30
+ inferenceId,
31
+ episodeKey,
32
+ verdict: opts.verdict,
33
+ score: opts.score ?? null,
34
+ note: opts.note ?? null,
35
+ source: opts.source ?? "sdk",
36
+ orgId: opts.orgId !== undefined && opts.orgId !== "" ? opts.orgId : null,
37
+ createdBy: opts.createdBy ?? null,
38
+ };
39
+ }
@@ -0,0 +1,155 @@
1
+ /**
2
+ * modelrig public surface — plan step 7.
3
+ * Usage sketch (normative):
4
+ * const rig = createRig(loadConfigFromEnv());
5
+ * const result = await rig.run("research.growth_scenarios", {
6
+ * input: { ticker, financials, priorSteps },
7
+ * tags: { run_id, step: "growth_scenarios", ticker },
8
+ * budget: { envelope: run_id },
9
+ * });
10
+ */
11
+ import type { RigConfig } from "./config";
12
+ import type { ServeabilityWarning } from "./routes/serveability";
13
+ import type { FeedbackOpts, FeedbackTarget } from "./feedback/feedback";
14
+ import type { FeedbackRow } from "./types/telemetry";
15
+ import type { ReplaySampleResult } from "./bakeoff/replay";
16
+ import type { KeepOutputsMode } from "./bakeoff/samples";
17
+ import type { BakeoffArtifact } from "./bakeoff/types";
18
+ import type { RunOptions, RunResult } from "./types/route";
19
+ export interface Rig {
20
+ run(route: string, opts: RunOptions): Promise<RunResult>;
21
+ /** Attach a judgment to an inference or an episode (= run) — Phase 4 WS2.
22
+ * Synchronous local write, mirrored to the cloud sink by the exporter;
23
+ * never a network call, never blocks or fails the caller's path. */
24
+ feedback(target: FeedbackTarget, opts: FeedbackOpts): FeedbackRow;
25
+ /** Offline shadow replay (Phase 3 WS4/WS5, closed core): re-run the last N
26
+ * captured inputs through a named variant. Real billed calls under a hard
27
+ * envelope; rows land in the replay tag namespace, never in captures. */
28
+ replay(route: string, opts: {
29
+ readonly variant: string;
30
+ readonly lastN: number;
31
+ readonly envelopeUsd?: number;
32
+ }): Promise<readonly ReplaySampleResult[]>;
33
+ /** Conformance bake-off (Phase 3 WS5): replay captures through each
34
+ * variant, aggregate the matrix, return the artifact. */
35
+ bakeoff(route: string, opts: {
36
+ readonly variants: readonly string[];
37
+ readonly replayLastN: number;
38
+ readonly envelopeUsdPerVariant?: number;
39
+ /** Addendum A3: retain outputs for a value review ("winner" = incumbent
40
+ * + winner; "all" = every arm). Persists to bakeoff_samples via the
41
+ * cloud sink; a no-op without an export config. */
42
+ readonly keepOutputs?: KeepOutputsMode;
43
+ }): Promise<BakeoffArtifact>;
44
+ /** Inert (keyless) candidates found at load time — F1. Exposed so the
45
+ * server boot banner and /status can NAME them with their fix, instead of
46
+ * the warning existing only as a console line nobody scrolls back to. */
47
+ readonly serveability: readonly ServeabilityWarning[];
48
+ close(): void;
49
+ }
50
+ export declare function createRig(config: RigConfig): Rig;
51
+ export { loadConfigFromEnv } from "./config";
52
+ export type { RigConfig, ApiExportConfig, DirectExportConfig } from "./config";
53
+ export { stampBatch, foreignOrgFeedback, INGEST_PATH, INGEST_PROTOCOL_VERSION, DEFAULT_INGEST_URL, } from "./telemetry/ingest-protocol";
54
+ export type { IngestBatch, IngestOutcome, TableWrite, Tenancy, WireInference, WireFeedback, WireEnvelope, WireRoute, WireManifest, } from "./telemetry/ingest-protocol";
55
+ export { createTelemetryExporter } from "./telemetry/exporter";
56
+ export type { Exporter, ExporterConfig, ExportedRouteMirror } from "./telemetry/exporter";
57
+ export { createApiSink, createDirectSink } from "./telemetry/sinks";
58
+ export { API_KEY_PREFIX, API_KEY_SCOPES, API_KEY_SECRET_BYTES, hashApiKeySecret, looksLikeApiKey, redactApiKey, parseScopes, hasScope, } from "./tenancy/api-key-format";
59
+ export type { ApiKeyScope } from "./tenancy/api-key-format";
60
+ export { scrubSecrets, containsKeyShapedString, KEY_SHAPED_PREFIXES } from "./tenancy/scrub";
61
+ export type { TelemetrySink, ApiSinkConfig, DirectSinkConfig } from "./telemetry/sinks";
62
+ export type { RunOptions, RunResult, RunMeta, RouteBundle, RouteVariant, RepairPolicy, RunTags, } from "./types/route";
63
+ export { openCaptureStore } from "./telemetry/capture";
64
+ export { openTelemetryStore } from "./telemetry/store";
65
+ export type { CaptureStore, CaptureRow } from "./telemetry/capture";
66
+ export { replayVariant } from "./bakeoff/replay";
67
+ export type { ReplayRequest, ReplaySampleResult } from "./bakeoff/replay";
68
+ export { runBakeoff, mirrorBakeoff, computeProposal } from "./bakeoff/engine";
69
+ export type { BakeoffRequest, BakeoffMirrorConfig, BakeoffSamplesSink } from "./bakeoff/engine";
70
+ export { createBakeoffSamplesClient, buildBakeoffSamples, selectArmsToKeep, truncateOutput, retentionExpiry, OUTPUT_MAX_BYTES, } from "./bakeoff/samples";
71
+ export type { BakeoffSample, BakeoffSamplesClient, ArmSamples, KeepOutputsMode, } from "./bakeoff/samples";
72
+ export { aggregateVariantMetrics, wilson95 } from "./bakeoff/stats";
73
+ export type { BakeoffArtifact, VariantMetrics } from "./bakeoff/types";
74
+ export { createTavilySearchProvider, extractCitations } from "./run/grounding";
75
+ export type { SearchProvider, SearchResponse, SearchResultItem, UrlCitation, } from "./run/grounding";
76
+ export type { RigFailure, FailureClass } from "./types/failures";
77
+ export { RigFailureError, isRigFailure } from "./types/failures";
78
+ export { FAILURE_TEACHING, teach, renderFailureForTerminal } from "./types/failures-teaching";
79
+ export type { FailureTeaching, TeachableFailure, SuggestedChange } from "./types/failures-teaching";
80
+ export { RouteConfigError, loadRoutes } from "./routes/loader";
81
+ export type { LoadedRoutes } from "./routes/loader";
82
+ export { runInit, buildMigrationMarkdown, routeNameFor, capabilitiesFor } from "./init/run";
83
+ export type { InitResult, InitDraft, InitOptions, InitDeps } from "./init/run";
84
+ export { scanRepoForCallSites, findCallSitesInText, readObjectLiteral } from "./init/finder";
85
+ export type { CallSite, ScanResult, FinderOptions, FileSystemLike } from "./init/finder";
86
+ export { PROVIDER_SIGNATURES, signatureFor } from "./init/signatures";
87
+ export type { ProviderSignature } from "./init/signatures";
88
+ export { loadRegistryRows } from "./registry/rows";
89
+ export { seedCandidates, splitModelKey } from "./registry/seed";
90
+ export type { SeedCandidatesInput, SeededCandidates } from "./registry/seed";
91
+ export { buildRouteDraft, writeRouteDraft } from "./routes/draft";
92
+ export type { RouteDraft, RouteDraftSpec, DraftCandidate, DraftFile, WriteDraftResult, } from "./routes/draft";
93
+ export { checkServeability, serveabilityWarnings } from "./routes/serveability";
94
+ export type { ServeabilityWarning } from "./routes/serveability";
95
+ export { PROVIDER_KEY_ENV } from "./config";
96
+ export { createGeminiAdapter } from "./adapters/gemini";
97
+ export { createOpenAIAdapter } from "./adapters/openai";
98
+ export { createDeepSeekAdapter } from "./adapters/deepseek";
99
+ export { createAnthropicAdapter } from "./adapters/anthropic";
100
+ export { createGrokAdapter } from "./adapters/grok";
101
+ export { createOpenAICompatAdapter, buildOpenAICompatParams, classifyCompatFailure, shapeFireworksModelId, OPENAI_COMPAT_HOSTS, } from "./adapters/openai-compat";
102
+ export type { OpenAICompatAdapterConfig, OpenAICompatHost } from "./adapters/openai-compat";
103
+ export { resolveCandidates } from "./run/resolve";
104
+ export type { CandidateIterator, CapabilityLookup } from "./run/resolve";
105
+ export { getPricing, estimateCostUsd } from "./registry/pricing";
106
+ export type { ModelPricing } from "./registry/pricing";
107
+ export type { CandidateRef, CapabilityFlag, ProviderId, ServiceTier, AdapterUsage } from "./types/provider";
108
+ export { loadManifest } from "./routes/manifest";
109
+ export type { RigManifest, DimensionSpec } from "./routes/manifest";
110
+ export { fingerprintSchema } from "./registry/fingerprint";
111
+ export { loadRegistryFacts, capabilityFactsFromEntry } from "./registry/facts";
112
+ export { parseCapabilityQuery, selectModels, hasCapability, explainEmptySelection, ALL_CAPABILITY_PREDICATES, PREDICATE_GLOSS, } from "./registry/select";
113
+ export type { CapabilityPredicate, ModelSelectRow, ParsedQuery, SelectCriteria, } from "./registry/select";
114
+ export { callNotesFor } from "./registry/call-notes";
115
+ export { probeFreshness, stalenessSentence, PROBE_FRESHNESS_SLO_DAYS } from "./registry/staleness";
116
+ export type { ProbeFreshness } from "./registry/staleness";
117
+ export { factsFor, factsUnderCredential } from "./registry/claims";
118
+ export type { ModelFacts, ScopedFact, CredentialOwnership, CredentialScopedFact, } from "./registry/claims";
119
+ export { computeParity } from "./registry/parity";
120
+ export type { ParityListEntry, ParityReport, ParityGap } from "./registry/parity";
121
+ export type { RegistryFacts } from "./registry/facts";
122
+ export { ALL_CAPABILITY_FLAGS } from "./types/provider";
123
+ export type { SchemaFingerprint, TaskCategory } from "./registry/fingerprint";
124
+ export type { ProviderAdapter, AdapterRequest, AdapterResult } from "./types/provider";
125
+ export type { TelemetryStore, TelemetryRow, FeedbackRow } from "./types/telemetry";
126
+ export { buildFeedbackRow } from "./feedback/feedback";
127
+ export type { FeedbackTarget, FeedbackOpts } from "./feedback/feedback";
128
+ export { computeCoverage, RUNG1_MIN_FEEDBACK } from "./feedback/coverage";
129
+ export type { RouteCoverage } from "./feedback/coverage";
130
+ export { evaluateEvents, triggerHash, PROPOSAL_TTL_DAYS } from "./watch/evaluate";
131
+ export type { WatchEvent, ProposalDraft, ProposalTrigger, RouteEconomics, TokenRates, } from "./watch/evaluate";
132
+ export { createProposalsClient, assertTransition } from "./watch/proposals";
133
+ export type { ProposalsClient, ProposalRecord, ProposalStatus } from "./watch/proposals";
134
+ export { runWatchCycle } from "./watch/run";
135
+ export type { WatchCycleOptions, WatchCycleResult } from "./watch/run";
136
+ export { buildPriceUniverse, computeWatchEvents, loadWatchState, saveWatchState } from "./watch/state";
137
+ export { createWatchStateStore, createControlPlaneWatchStateStore, createFileWatchStateStore, WATCH_STATE_KEY, } from "./watch/state-store";
138
+ export type { WatchStateStore, ControlPlaneStateConfig } from "./watch/state-store";
139
+ export type { PriceUniverse } from "./watch/state";
140
+ export { reserveWatchBudget, watchEnvelopeKey, DEFAULT_WATCH_MONTHLY_USD } from "./watch/budget";
141
+ export type { WatchBudgetReservation } from "./watch/budget";
142
+ export { aggregatePriors, aggregatePairwiseFromTelemetry, writePriorsCells } from "./matrix/aggregate";
143
+ export type { PriorsCell, PriorsCellStats, PairwiseRecord, PairwiseByModel, AggregateOptions, } from "./matrix/aggregate";
144
+ export { compileQuery, QueryGrammarError } from "./query/grammar";
145
+ export type { QueryScope, CompiledQuery } from "./query/grammar";
146
+ export { runTelemetryQuery } from "./query/run";
147
+ export { buildSwapChange } from "./savings/emit";
148
+ export type { SwapChange } from "./savings/emit";
149
+ export { executeSwap } from "./savings/swap-execute";
150
+ export type { SwapExecuteDeps, SwapExecuteResult } from "./savings/swap-execute";
151
+ export { createSwapsClient } from "./savings/swaps-client";
152
+ export type { SwapsClient, SwapEventRecord, SwapBaseline } from "./savings/swaps-client";
153
+ export { computeOdometer } from "./savings/odometer";
154
+ export type { Odometer, SwapSavings } from "./savings/odometer";
155
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAQH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAG1C,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAejE,OAAO,KAAK,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACxE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAKrD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAM3D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,m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