niceeval 0.13.1 → 0.13.2

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 (548) hide show
  1. package/INDEX.md +25 -2
  2. package/README.md +9 -10
  3. package/README.zh.md +9 -10
  4. package/dist/agents/ai-sdk.cjs.map +1 -1
  5. package/dist/agents/ai-sdk.d.cts +1 -1
  6. package/dist/agents/ai-sdk.d.mts +1 -1
  7. package/dist/agents/ai-sdk.d.ts +1 -1
  8. package/dist/agents/bub-install-spec.cjs +19 -5
  9. package/dist/agents/bub-install-spec.cjs.map +1 -1
  10. package/dist/agents/bub-install-spec.d.cts +9 -2
  11. package/dist/agents/bub-install-spec.d.mts +9 -2
  12. package/dist/agents/bub-install-spec.d.ts +9 -2
  13. package/dist/agents/bub-install-spec.js +14 -12
  14. package/dist/agents/bub.cjs +10 -6
  15. package/dist/agents/bub.cjs.map +1 -1
  16. package/dist/agents/bub.d.cts +2 -2
  17. package/dist/agents/bub.d.mts +2 -2
  18. package/dist/agents/bub.d.ts +2 -2
  19. package/dist/agents/claude-code.cjs.map +1 -1
  20. package/dist/agents/claude-code.d.cts +2 -2
  21. package/dist/agents/claude-code.d.mts +2 -2
  22. package/dist/agents/claude-code.d.ts +2 -2
  23. package/dist/agents/codex.cjs +4 -4
  24. package/dist/agents/codex.cjs.map +1 -1
  25. package/dist/agents/codex.d.cts +3 -3
  26. package/dist/agents/codex.d.mts +3 -3
  27. package/dist/agents/codex.d.ts +3 -3
  28. package/dist/agents/coding-cli-versions.cjs +10 -1
  29. package/dist/agents/coding-cli-versions.cjs.map +1 -1
  30. package/dist/agents/coding-cli-versions.d.cts +8 -3
  31. package/dist/agents/coding-cli-versions.d.mts +8 -3
  32. package/dist/agents/coding-cli-versions.d.ts +8 -3
  33. package/dist/agents/coding-cli-versions.js +18 -12
  34. package/dist/agents/deepseek-harness.cjs +151 -0
  35. package/dist/agents/deepseek-harness.cjs.map +1 -0
  36. package/dist/agents/deepseek-harness.d.cts +14 -0
  37. package/dist/agents/deepseek-harness.d.mts +14 -0
  38. package/dist/agents/deepseek-harness.d.ts +14 -0
  39. package/dist/agents/deepseek-harness.js +7 -0
  40. package/dist/agents/deepseek-harness.js.map +1 -0
  41. package/dist/agents/exact-npm-plugins.cjs +28 -0
  42. package/dist/agents/exact-npm-plugins.cjs.map +1 -0
  43. package/dist/agents/exact-npm-plugins.d.cts +10 -0
  44. package/dist/agents/exact-npm-plugins.d.mts +10 -0
  45. package/dist/agents/exact-npm-plugins.d.ts +10 -0
  46. package/dist/agents/exact-npm-plugins.js +8 -0
  47. package/dist/agents/exact-npm-plugins.js.map +1 -0
  48. package/dist/agents/index.cjs +5 -1
  49. package/dist/agents/index.cjs.map +1 -1
  50. package/dist/agents/index.d.cts +4 -0
  51. package/dist/agents/index.d.mts +4 -0
  52. package/dist/agents/index.d.ts +4 -0
  53. package/dist/agents/index.js +54 -50
  54. package/dist/agents/index.mjs +54 -50
  55. package/dist/agents/omp.cjs +170 -0
  56. package/dist/agents/omp.cjs.map +1 -0
  57. package/dist/agents/omp.d.cts +14 -0
  58. package/dist/agents/omp.d.mts +14 -0
  59. package/dist/agents/omp.d.ts +14 -0
  60. package/dist/agents/omp.js +7 -0
  61. package/dist/agents/omp.js.map +1 -0
  62. package/dist/agents/openclaw.cjs +51 -2
  63. package/dist/agents/openclaw.cjs.map +1 -1
  64. package/dist/agents/openclaw.d.cts +2 -0
  65. package/dist/agents/openclaw.d.mts +2 -0
  66. package/dist/agents/openclaw.d.ts +2 -0
  67. package/dist/agents/types.cjs.map +1 -1
  68. package/dist/agents/types.d.cts +4 -4
  69. package/dist/agents/types.d.mts +4 -4
  70. package/dist/agents/types.d.ts +4 -4
  71. package/dist/agents/ui-message-stream.cjs +24 -7
  72. package/dist/agents/ui-message-stream.cjs.map +1 -1
  73. package/dist/analysis/api.cjs +28 -2
  74. package/dist/analysis/api.cjs.map +1 -1
  75. package/dist/analysis/api.d.cts +22 -1
  76. package/dist/analysis/api.d.mts +22 -1
  77. package/dist/analysis/api.d.ts +22 -1
  78. package/dist/analysis/api.js +8 -6
  79. package/dist/analysis/bindings.cjs +11 -18
  80. package/dist/analysis/bindings.cjs.map +1 -1
  81. package/dist/analysis/bindings.d.cts +177 -49
  82. package/dist/analysis/bindings.d.mts +177 -49
  83. package/dist/analysis/bindings.d.ts +177 -49
  84. package/dist/analysis/contracts.cjs +1 -0
  85. package/dist/analysis/contracts.cjs.map +1 -1
  86. package/dist/analysis/contracts.d.cts +43 -3
  87. package/dist/analysis/contracts.d.mts +43 -3
  88. package/dist/analysis/contracts.d.ts +43 -3
  89. package/dist/analysis/cost-projection.cjs +2 -1
  90. package/dist/analysis/cost-projection.cjs.map +1 -1
  91. package/dist/analysis/cost-projection.d.cts +1 -1
  92. package/dist/analysis/cost-projection.d.mts +1 -1
  93. package/dist/analysis/cost-projection.d.ts +1 -1
  94. package/dist/analysis/cost.cjs +13 -3
  95. package/dist/analysis/cost.cjs.map +1 -1
  96. package/dist/analysis/cost.d.cts +10 -3
  97. package/dist/analysis/cost.d.mts +10 -3
  98. package/dist/analysis/cost.d.ts +10 -3
  99. package/dist/analysis/experiment-groups.cjs +96 -0
  100. package/dist/analysis/experiment-groups.cjs.map +1 -0
  101. package/dist/analysis/experiment-groups.d.cts +9 -0
  102. package/dist/analysis/experiment-groups.d.mts +9 -0
  103. package/dist/analysis/experiment-groups.d.ts +9 -0
  104. package/dist/analysis/experiment-groups.js +10 -0
  105. package/dist/analysis/experiment-groups.js.map +1 -0
  106. package/dist/analysis/index.cjs +4 -1
  107. package/dist/analysis/index.cjs.map +1 -1
  108. package/dist/analysis/index.d.cts +4 -2
  109. package/dist/analysis/index.d.mts +4 -2
  110. package/dist/analysis/index.d.ts +4 -2
  111. package/dist/analysis/index.js +40 -36
  112. package/dist/analysis/index.mjs +40 -36
  113. package/dist/assertions/limits.cjs +4 -0
  114. package/dist/assertions/limits.cjs.map +1 -1
  115. package/dist/assertions/limits.d.cts +4 -0
  116. package/dist/assertions/limits.d.mts +4 -0
  117. package/dist/assertions/limits.d.ts +4 -0
  118. package/dist/assertions/match.cjs +63 -25
  119. package/dist/assertions/match.cjs.map +1 -1
  120. package/dist/assertions/match.d.cts +7 -0
  121. package/dist/assertions/match.d.mts +7 -0
  122. package/dist/assertions/match.d.ts +7 -0
  123. package/dist/assertions/record/attachment.cjs +32 -4
  124. package/dist/assertions/record/attachment.cjs.map +1 -1
  125. package/dist/assertions/record/diff.cjs +10 -4
  126. package/dist/assertions/record/diff.cjs.map +1 -1
  127. package/dist/assertions/record/producer.cjs +101 -4
  128. package/dist/assertions/record/producer.cjs.map +1 -1
  129. package/dist/assertions/record/producer.d.cts +4 -1
  130. package/dist/assertions/record/producer.d.mts +4 -1
  131. package/dist/assertions/record/producer.d.ts +4 -1
  132. package/dist/assertions/runtime.cjs +45 -5
  133. package/dist/assertions/runtime.cjs.map +1 -1
  134. package/dist/cli/record.cjs +113 -8
  135. package/dist/cli/record.cjs.map +1 -1
  136. package/dist/cli/record.d.cts +20 -1
  137. package/dist/cli/record.d.mts +20 -1
  138. package/dist/cli/record.d.ts +20 -1
  139. package/dist/cli/record.js +4 -2
  140. package/dist/cli.cjs +386 -31
  141. package/dist/cli.cjs.map +1 -1
  142. package/dist/cli.d.cts +10 -2
  143. package/dist/cli.d.mts +10 -2
  144. package/dist/cli.d.ts +10 -2
  145. package/dist/context/send-retry.cjs +4 -4
  146. package/dist/context/send-retry.cjs.map +1 -1
  147. package/dist/coordination/host/runtime.cjs +8 -30
  148. package/dist/coordination/host/runtime.cjs.map +1 -1
  149. package/dist/coordination/host/runtime.d.cts +3 -3
  150. package/dist/coordination/host/runtime.d.mts +3 -3
  151. package/dist/coordination/host/runtime.d.ts +3 -3
  152. package/dist/coordination/host/types.cjs.map +1 -1
  153. package/dist/coordination/host/types.d.cts +0 -5
  154. package/dist/coordination/host/types.d.mts +0 -5
  155. package/dist/coordination/host/types.d.ts +0 -5
  156. package/dist/coordination/platform/node.cjs +90 -9
  157. package/dist/coordination/platform/node.cjs.map +1 -1
  158. package/dist/define.cjs +25 -1
  159. package/dist/define.cjs.map +1 -1
  160. package/dist/experiment/host/index.cjs +1 -0
  161. package/dist/experiment/host/index.cjs.map +1 -1
  162. package/dist/i18n/en.cjs +26 -8
  163. package/dist/i18n/en.cjs.map +1 -1
  164. package/dist/i18n/en.d.cts +19 -6
  165. package/dist/i18n/en.d.mts +19 -6
  166. package/dist/i18n/en.d.ts +19 -6
  167. package/dist/index.cjs.map +1 -1
  168. package/dist/index.d.cts +1 -1
  169. package/dist/index.d.mts +1 -1
  170. package/dist/index.d.ts +1 -1
  171. package/dist/o11y/parsers/hermes.cjs +1 -1
  172. package/dist/o11y/parsers/hermes.cjs.map +1 -1
  173. package/dist/o11y/prices.json +1 -1
  174. package/dist/o11y/record/families.cjs +12 -3
  175. package/dist/o11y/record/families.cjs.map +1 -1
  176. package/dist/o11y/record/families.d.cts +8 -8
  177. package/dist/o11y/record/families.d.mts +8 -8
  178. package/dist/o11y/record/families.d.ts +8 -8
  179. package/dist/o11y/record/family-projectors.d.cts +66 -18
  180. package/dist/o11y/record/family-projectors.d.mts +66 -18
  181. package/dist/o11y/record/family-projectors.d.ts +66 -18
  182. package/dist/o11y/record/family-writers.d.cts +11 -3
  183. package/dist/o11y/record/family-writers.d.mts +11 -3
  184. package/dist/o11y/record/family-writers.d.ts +11 -3
  185. package/dist/o11y/record/runner-producer.cjs +14 -4
  186. package/dist/o11y/record/runner-producer.cjs.map +1 -1
  187. package/dist/record/codec/core.d.cts +2 -2
  188. package/dist/record/codec/core.d.mts +2 -2
  189. package/dist/record/codec/core.d.ts +2 -2
  190. package/dist/record/family/catalog.d.cts +44 -12
  191. package/dist/record/family/catalog.d.mts +44 -12
  192. package/dist/record/family/catalog.d.ts +44 -12
  193. package/dist/record/family/index.js +128 -124
  194. package/dist/record/family/observability-v1.cjs +35 -0
  195. package/dist/record/family/observability-v1.cjs.map +1 -0
  196. package/dist/record/family/observability-v1.d.cts +3 -0
  197. package/dist/record/family/observability-v1.d.mts +3 -0
  198. package/dist/record/family/observability-v1.d.ts +3 -0
  199. package/dist/record/family/observability-v1.js +6 -0
  200. package/dist/record/family/observability-v1.js.map +1 -0
  201. package/dist/record/family/observability.cjs +58 -9
  202. package/dist/record/family/observability.cjs.map +1 -1
  203. package/dist/record/family/observability.d.cts +1014 -15
  204. package/dist/record/family/observability.d.mts +1014 -15
  205. package/dist/record/family/observability.d.ts +1014 -15
  206. package/dist/record/family/observability.js +22 -18
  207. package/dist/record/host/runtime.cjs +600 -31
  208. package/dist/record/host/runtime.cjs.map +1 -1
  209. package/dist/record/host/types.cjs.map +1 -1
  210. package/dist/record/host/types.d.cts +33 -9
  211. package/dist/record/host/types.d.mts +33 -9
  212. package/dist/record/host/types.d.ts +33 -9
  213. package/dist/record/maintenance/runtime.cjs +1 -2
  214. package/dist/record/maintenance/runtime.cjs.map +1 -1
  215. package/dist/record/model/core.cjs.map +1 -1
  216. package/dist/record/model/core.d.cts +1 -1
  217. package/dist/record/model/core.d.mts +1 -1
  218. package/dist/record/model/core.d.ts +1 -1
  219. package/dist/record/model/definition.d.cts +6 -6
  220. package/dist/record/model/definition.d.mts +6 -6
  221. package/dist/record/model/definition.d.ts +6 -6
  222. package/dist/record/model/identifiers.cjs +1 -1
  223. package/dist/record/model/identifiers.cjs.map +1 -1
  224. package/dist/record/model/identifiers.d.cts +1 -1
  225. package/dist/record/model/identifiers.d.mts +1 -1
  226. package/dist/record/model/identifiers.d.ts +1 -1
  227. package/dist/record/platform/node.cjs +159 -23
  228. package/dist/record/platform/node.cjs.map +1 -1
  229. package/dist/record/platform/services.cjs.map +1 -1
  230. package/dist/record/platform/services.d.cts +15 -2
  231. package/dist/record/platform/services.d.mts +15 -2
  232. package/dist/record/platform/services.d.ts +15 -2
  233. package/dist/record/reader/errors.cjs +37 -1
  234. package/dist/record/reader/errors.cjs.map +1 -1
  235. package/dist/record/reader/errors.d.cts +49 -1
  236. package/dist/record/reader/errors.d.mts +49 -1
  237. package/dist/record/reader/errors.d.ts +49 -1
  238. package/dist/record/reader/errors.js +22 -12
  239. package/dist/record/reader/format.cjs +76 -17
  240. package/dist/record/reader/format.cjs.map +1 -1
  241. package/dist/record/reader/format.d.cts +11 -4
  242. package/dist/record/reader/format.d.mts +11 -4
  243. package/dist/record/reader/format.d.ts +11 -4
  244. package/dist/record/reader/format.js +2 -0
  245. package/dist/record/reader/index.js +32 -18
  246. package/dist/record/reader/runtime.cjs +64 -0
  247. package/dist/record/reader/runtime.cjs.map +1 -1
  248. package/dist/record/reader/runtime.d.cts +15 -0
  249. package/dist/record/reader/runtime.d.mts +15 -0
  250. package/dist/record/reader/runtime.d.ts +15 -0
  251. package/dist/record/reader/runtime.js +2 -0
  252. package/dist/report/assets/styles.css +53 -29
  253. package/dist/report/built-in/analysis-values.cjs +21 -13
  254. package/dist/report/built-in/analysis-values.cjs.map +1 -1
  255. package/dist/report/built-in/analysis-values.d.cts +11 -22
  256. package/dist/report/built-in/analysis-values.d.mts +11 -22
  257. package/dist/report/built-in/analysis-values.d.ts +11 -22
  258. package/dist/report/built-in/analysis-values.js +4 -6
  259. package/dist/report/built-in/index.cjs +1 -3
  260. package/dist/report/built-in/index.cjs.map +1 -1
  261. package/dist/report/built-in/index.d.cts +1 -1
  262. package/dist/report/built-in/index.d.mts +1 -1
  263. package/dist/report/built-in/index.d.ts +1 -1
  264. package/dist/report/built-in/index.js +4 -8
  265. package/dist/report/built-in/index.mjs +4 -8
  266. package/dist/report/built-in/machine.cjs +0 -2
  267. package/dist/report/built-in/machine.cjs.map +1 -1
  268. package/dist/report/built-in/machine.d.cts +0 -2
  269. package/dist/report/built-in/machine.d.mts +0 -2
  270. package/dist/report/built-in/machine.d.ts +0 -2
  271. package/dist/report/built-in/result-components.cjs +49 -51
  272. package/dist/report/built-in/result-components.cjs.map +1 -1
  273. package/dist/report/built-in/result-components.d.cts +16 -17
  274. package/dist/report/built-in/result-components.d.mts +16 -17
  275. package/dist/report/built-in/result-components.d.ts +16 -17
  276. package/dist/report/built-in/result-components.js +0 -4
  277. package/dist/report/built-in/run-membership-overview.cjs +126 -17
  278. package/dist/report/built-in/run-membership-overview.cjs.map +1 -1
  279. package/dist/report/built-in/run-membership-overview.d.cts +14 -0
  280. package/dist/report/built-in/run-membership-overview.d.mts +14 -0
  281. package/dist/report/built-in/run-membership-overview.d.ts +14 -0
  282. package/dist/report/built-in/run-membership-overview.js +4 -2
  283. package/dist/report/built-in/standard.cjs +80 -45
  284. package/dist/report/built-in/standard.cjs.map +1 -1
  285. package/dist/report/built-in/standard.d.cts +19 -41
  286. package/dist/report/built-in/standard.d.mts +19 -41
  287. package/dist/report/built-in/standard.d.ts +19 -41
  288. package/dist/report/built-in/standard.js +6 -6
  289. package/dist/report/components/attempt-detail/compute.cjs +78 -2
  290. package/dist/report/components/attempt-detail/compute.cjs.map +1 -1
  291. package/dist/report/components/attempt-detail/compute.d.cts +1 -1
  292. package/dist/report/components/attempt-detail/compute.d.mts +1 -1
  293. package/dist/report/components/attempt-detail/compute.d.ts +1 -1
  294. package/dist/report/components/attempt-detail/content.cjs +1 -1
  295. package/dist/report/components/attempt-detail/content.cjs.map +1 -1
  296. package/dist/report/components/entity-lists/compute.cjs +42 -5
  297. package/dist/report/components/entity-lists/compute.cjs.map +1 -1
  298. package/dist/report/components/entity-lists/compute.d.cts +10 -8
  299. package/dist/report/components/entity-lists/compute.d.mts +10 -8
  300. package/dist/report/components/entity-lists/compute.d.ts +10 -8
  301. package/dist/report/components/entity-lists/content.cjs +31 -6
  302. package/dist/report/components/entity-lists/content.cjs.map +1 -1
  303. package/dist/report/components/entity-lists/index.cjs +9 -4
  304. package/dist/report/components/entity-lists/index.cjs.map +1 -1
  305. package/dist/report/components/entity-lists/index.d.cts +4 -7
  306. package/dist/report/components/entity-lists/index.d.mts +4 -7
  307. package/dist/report/components/entity-lists/index.d.ts +4 -7
  308. package/dist/report/components/summaries/compute.cjs +8 -1
  309. package/dist/report/components/summaries/compute.cjs.map +1 -1
  310. package/dist/report/components/summaries/compute.d.cts +9 -1
  311. package/dist/report/components/summaries/compute.d.mts +9 -1
  312. package/dist/report/components/summaries/compute.d.ts +9 -1
  313. package/dist/report/components/summaries/index.cjs +48 -4
  314. package/dist/report/components/summaries/index.cjs.map +1 -1
  315. package/dist/report/components/summaries/index.d.cts +7 -4
  316. package/dist/report/components/summaries/index.d.mts +7 -4
  317. package/dist/report/components/summaries/index.d.ts +7 -4
  318. package/dist/report/definition/cell.cjs +3 -0
  319. package/dist/report/definition/cell.cjs.map +1 -1
  320. package/dist/report/definition/cell.d.cts +2 -0
  321. package/dist/report/definition/cell.d.mts +2 -0
  322. package/dist/report/definition/cell.d.ts +2 -0
  323. package/dist/report/definition/primitives/chart.cjs +8 -5
  324. package/dist/report/definition/primitives/chart.cjs.map +1 -1
  325. package/dist/report/definition/primitives/points-dataset.cjs +1 -0
  326. package/dist/report/definition/primitives/points-dataset.cjs.map +1 -1
  327. package/dist/report/definition/primitives.cjs +15 -2
  328. package/dist/report/definition/primitives.cjs.map +1 -1
  329. package/dist/report/definition/report.cjs +27 -3
  330. package/dist/report/definition/report.cjs.map +1 -1
  331. package/dist/report/definition/report.d.cts +8 -0
  332. package/dist/report/definition/report.d.mts +8 -0
  333. package/dist/report/definition/report.d.ts +8 -0
  334. package/dist/report/execution/machine.cjs +30 -14
  335. package/dist/report/execution/machine.cjs.map +1 -1
  336. package/dist/report/execution/machine.d.cts +20 -10
  337. package/dist/report/execution/machine.d.mts +20 -10
  338. package/dist/report/execution/machine.d.ts +20 -10
  339. package/dist/report/execution/machine.js +6 -6
  340. package/dist/report/host/execute.cjs +25 -16
  341. package/dist/report/host/execute.cjs.map +1 -1
  342. package/dist/report/host/execute.d.cts +4 -0
  343. package/dist/report/host/execute.d.mts +4 -0
  344. package/dist/report/host/execute.d.ts +4 -0
  345. package/dist/report/host/from-record.cjs +22 -5
  346. package/dist/report/host/from-record.cjs.map +1 -1
  347. package/dist/report/host/machine.cjs +53 -11
  348. package/dist/report/host/machine.cjs.map +1 -1
  349. package/dist/report/host/site-runtime.cjs +9 -8
  350. package/dist/report/host/site-runtime.cjs.map +1 -1
  351. package/dist/report/host/site-runtime.d.cts +1 -1
  352. package/dist/report/host/site-runtime.d.mts +1 -1
  353. package/dist/report/host/site-runtime.d.ts +1 -1
  354. package/dist/report/host/static.cjs +56 -9
  355. package/dist/report/host/static.cjs.map +1 -1
  356. package/dist/report/index.cjs.map +1 -1
  357. package/dist/report/index.d.cts +1 -1
  358. package/dist/report/index.d.mts +1 -1
  359. package/dist/report/index.d.ts +1 -1
  360. package/dist/report/model/dataset.cjs +7 -2
  361. package/dist/report/model/dataset.cjs.map +1 -1
  362. package/dist/report/model/locale.cjs +2 -0
  363. package/dist/report/model/locale.cjs.map +1 -1
  364. package/dist/report/model/locale.d.cts +1 -0
  365. package/dist/report/model/locale.d.mts +1 -0
  366. package/dist/report/model/locale.d.ts +1 -0
  367. package/dist/report/model/metrics.cjs +3 -1
  368. package/dist/report/model/metrics.cjs.map +1 -1
  369. package/dist/report/model/pricing.cjs +16 -11
  370. package/dist/report/model/pricing.cjs.map +1 -1
  371. package/dist/report/react/styles.css +53 -29
  372. package/dist/runner/adoption.cjs +1 -0
  373. package/dist/runner/adoption.cjs.map +1 -1
  374. package/dist/runner/attempt.cjs +44 -5
  375. package/dist/runner/attempt.cjs.map +1 -1
  376. package/dist/runner/attempt.d.cts +13 -1
  377. package/dist/runner/attempt.d.mts +13 -1
  378. package/dist/runner/attempt.d.ts +13 -1
  379. package/dist/runner/config-identity.cjs +10 -2
  380. package/dist/runner/config-identity.cjs.map +1 -1
  381. package/dist/runner/config-identity.d.cts +4 -2
  382. package/dist/runner/config-identity.d.mts +4 -2
  383. package/dist/runner/config-identity.d.ts +4 -2
  384. package/dist/runner/feedback/human.cjs +298 -59
  385. package/dist/runner/feedback/human.cjs.map +1 -1
  386. package/dist/runner/feedback/json.cjs +14 -6
  387. package/dist/runner/feedback/json.cjs.map +1 -1
  388. package/dist/runner/feedback/json.d.cts +3 -2
  389. package/dist/runner/feedback/json.d.mts +3 -2
  390. package/dist/runner/feedback/json.d.ts +3 -2
  391. package/dist/runner/feedback/reducer.cjs +2 -0
  392. package/dist/runner/feedback/reducer.cjs.map +1 -1
  393. package/dist/runner/judge-config.cjs +1 -1
  394. package/dist/runner/judge-config.cjs.map +1 -1
  395. package/dist/runner/ledger.cjs +124 -12
  396. package/dist/runner/ledger.cjs.map +1 -1
  397. package/dist/runner/project-current.cjs +13 -5
  398. package/dist/runner/project-current.cjs.map +1 -1
  399. package/dist/runner/run.cjs +564 -256
  400. package/dist/runner/run.cjs.map +1 -1
  401. package/dist/runner/sandbox-pool.cjs +161 -30
  402. package/dist/runner/sandbox-pool.cjs.map +1 -1
  403. package/dist/runner/sandbox-pool.d.cts +34 -2
  404. package/dist/runner/sandbox-pool.d.mts +34 -2
  405. package/dist/runner/sandbox-pool.d.ts +34 -2
  406. package/dist/runner/shared-state-lease.cjs +803 -0
  407. package/dist/runner/shared-state-lease.cjs.map +1 -0
  408. package/dist/runner/shared-state-lease.d.cts +121 -0
  409. package/dist/runner/shared-state-lease.d.mts +121 -0
  410. package/dist/runner/shared-state-lease.d.ts +121 -0
  411. package/dist/runner/shared-state-lease.js +24 -0
  412. package/dist/runner/shared-state-lease.js.map +1 -0
  413. package/dist/runner/teardown-registry.cjs +97 -34
  414. package/dist/runner/teardown-registry.cjs.map +1 -1
  415. package/dist/runner/teardown-registry.d.cts +27 -1
  416. package/dist/runner/teardown-registry.d.mts +27 -1
  417. package/dist/runner/teardown-registry.d.ts +27 -1
  418. package/dist/runner/teardown-registry.js +20 -16
  419. package/dist/runner/types.cjs.map +1 -1
  420. package/dist/runner/types.d.cts +31 -5
  421. package/dist/runner/types.d.mts +31 -5
  422. package/dist/runner/types.d.ts +31 -5
  423. package/dist/sample/analysis.cjs +249 -459
  424. package/dist/sample/analysis.cjs.map +1 -1
  425. package/dist/sample/capability.cjs +138 -7
  426. package/dist/sample/capability.cjs.map +1 -1
  427. package/dist/sample/capability.d.cts +3 -1
  428. package/dist/sample/capability.d.mts +3 -1
  429. package/dist/sample/capability.d.ts +3 -1
  430. package/dist/sample/capability.js +8 -6
  431. package/dist/sandbox/docker-agent-image.cjs +5 -1
  432. package/dist/sandbox/docker-agent-image.cjs.map +1 -1
  433. package/dist/sandbox/docker-agent-image.d.cts +2 -0
  434. package/dist/sandbox/docker-agent-image.d.mts +2 -0
  435. package/dist/sandbox/docker-agent-image.d.ts +2 -0
  436. package/dist/sandbox/docker-agent-image.js +14 -10
  437. package/dist/sandbox/docker-profile/schema.cjs +283 -534
  438. package/dist/sandbox/docker-profile/schema.cjs.map +1 -1
  439. package/dist/sandbox/docker-profile/schema.d.cts +10 -27
  440. package/dist/sandbox/docker-profile/schema.d.mts +10 -27
  441. package/dist/sandbox/docker-profile/schema.d.ts +10 -27
  442. package/dist/sandbox/e2b-agent-template.cjs +5 -2
  443. package/dist/sandbox/e2b-agent-template.cjs.map +1 -1
  444. package/dist/sandbox/index.cjs +4 -2
  445. package/dist/sandbox/index.cjs.map +1 -1
  446. package/dist/sandbox/index.d.cts +1 -1
  447. package/dist/sandbox/index.d.mts +1 -1
  448. package/dist/sandbox/index.d.ts +1 -1
  449. package/dist/sandbox/index.js +120 -116
  450. package/dist/sandbox/index.mjs +120 -116
  451. package/dist/sandbox/keep-registry.cjs +28 -66
  452. package/dist/sandbox/keep-registry.cjs.map +1 -1
  453. package/dist/sandbox/types.cjs.map +1 -1
  454. package/dist/sandbox/types.d.cts +1 -1
  455. package/dist/sandbox/types.d.mts +1 -1
  456. package/dist/sandbox/types.d.ts +1 -1
  457. package/dist/shared/aggregate.cjs +16 -6
  458. package/dist/shared/aggregate.cjs.map +1 -1
  459. package/dist/shared/aggregate.d.cts +12 -4
  460. package/dist/shared/aggregate.d.mts +12 -4
  461. package/dist/shared/aggregate.d.ts +12 -4
  462. package/dist/shared/turn-label.cjs +20 -2
  463. package/dist/shared/turn-label.cjs.map +1 -1
  464. package/dist/shared/turn-label.d.cts +2 -0
  465. package/dist/shared/turn-label.d.mts +2 -0
  466. package/dist/shared/turn-label.d.ts +2 -0
  467. package/dist/shared/turn-label.js +4 -2
  468. package/dist/vendor/remark/remark-gfm.cjs +7 -7
  469. package/dist/vendor/remark/remark-gfm.cjs.map +1 -1
  470. package/dist/vendor/remark/remark-parse.cjs +12 -12
  471. package/dist/vendor/remark/remark-parse.cjs.map +1 -1
  472. package/dist/vendor/remark/remark.cjs +13 -13
  473. package/dist/vendor/remark/remark.cjs.map +1 -1
  474. package/dist/view/server.cjs +6 -0
  475. package/dist/view/server.cjs.map +1 -1
  476. package/docs-site/images/hitl-handshake-zh.svg +3 -3
  477. package/docs-site/zh/examples/ai-agent-application.mdx +1 -1
  478. package/docs-site/zh/examples/coding-agent-extensions.mdx +1 -1
  479. package/docs-site/zh/examples/integrations/ai-sdk-v7.mdx +4 -3
  480. package/docs-site/zh/examples/integrations/claude-sdk.mdx +3 -3
  481. package/docs-site/zh/examples/integrations/codex-sdk.mdx +5 -5
  482. package/docs-site/zh/examples/integrations/langgraph.mdx +4 -4
  483. package/docs-site/zh/examples/integrations/pi-sdk.mdx +5 -5
  484. package/docs-site/zh/explanation/adapter.mdx +5 -5
  485. package/docs-site/zh/explanation/assert.mdx +7 -7
  486. package/docs-site/zh/explanation/drive.mdx +4 -2
  487. package/docs-site/zh/explanation/evals.mdx +10 -8
  488. package/docs-site/zh/explanation/experiment.mdx +2 -2
  489. package/docs-site/zh/explanation/hitl.mdx +9 -9
  490. package/docs-site/zh/explanation/judge.mdx +5 -5
  491. package/docs-site/zh/explanation/overview.mdx +3 -3
  492. package/docs-site/zh/explanation/runner.mdx +1 -1
  493. package/docs-site/zh/index.mdx +3 -3
  494. package/docs-site/zh/reference/builtin-agents.mdx +13 -13
  495. package/docs-site/zh/reference/capabilities.mdx +1 -1
  496. package/docs-site/zh/reference/cli.mdx +18 -12
  497. package/docs-site/zh/reference/define-agent.mdx +130 -5
  498. package/docs-site/zh/reference/define-config.mdx +2 -2
  499. package/docs-site/zh/reference/define-eval.mdx +4 -4
  500. package/docs-site/zh/reference/events.mdx +11 -11
  501. package/docs-site/zh/reference/official-adapters.mdx +6 -6
  502. package/docs-site/zh/reference/results-data.mdx +6 -0
  503. package/docs-site/zh/troubleshooting/debugging.mdx +1 -1
  504. package/docs-site/zh/troubleshooting/recover-after-kill.mdx +37 -5
  505. package/docs-site/zh/tutorials/accept-results.mdx +72 -0
  506. package/docs-site/zh/tutorials/agent-onboarding.mdx +6 -6
  507. package/docs-site/zh/tutorials/authoring.mdx +9 -13
  508. package/docs-site/zh/tutorials/ci-integration.mdx +6 -6
  509. package/docs-site/zh/tutorials/compare-runs.mdx +61 -0
  510. package/docs-site/zh/tutorials/concurrency.mdx +13 -12
  511. package/docs-site/zh/tutorials/configuration.mdx +4 -6
  512. package/docs-site/zh/tutorials/connect-your-agent.mdx +1 -1
  513. package/docs-site/zh/tutorials/control-run-cost.mdx +58 -0
  514. package/docs-site/zh/tutorials/criteria-files.mdx +2 -2
  515. package/docs-site/zh/tutorials/custom-reports.mdx +2 -2
  516. package/docs-site/zh/tutorials/debug-lifecycle-plan.mdx +46 -0
  517. package/docs-site/zh/tutorials/docker-in-docker.mdx +52 -43
  518. package/docs-site/zh/tutorials/eval-groups.mdx +6 -6
  519. package/docs-site/zh/tutorials/evaluation-kinds.mdx +3 -3
  520. package/docs-site/zh/tutorials/experiments.mdx +2 -3
  521. package/docs-site/zh/tutorials/handle-execution-failures.mdx +18 -10
  522. package/docs-site/zh/tutorials/install-custom-sandbox-agent.mdx +16 -8
  523. package/docs-site/zh/tutorials/nixos-managed-dind.mdx +160 -0
  524. package/docs-site/zh/tutorials/plugins.mdx +14 -0
  525. package/docs-site/zh/tutorials/rerun-and-cache.mdx +4 -2
  526. package/docs-site/zh/tutorials/sandbox-agent.mdx +17 -11
  527. package/docs-site/zh/tutorials/sandbox-providers.mdx +17 -13
  528. package/docs-site/zh/tutorials/sandbox-reuse.mdx +12 -19
  529. package/docs-site/zh/tutorials/select-and-preview.mdx +65 -0
  530. package/docs-site/zh/tutorials/verify-judge.mdx +78 -0
  531. package/docs-site/zh/tutorials/viewing-results.mdx +38 -1
  532. package/docs-site/zh/tutorials/write-experiment.mdx +7 -5
  533. package/docs-site/zh/tutorials/write-send.mdx +9 -8
  534. package/package.json +9 -5
  535. package/dist/report/built-in/overview.cjs +0 -44
  536. package/dist/report/built-in/overview.cjs.map +0 -1
  537. package/dist/report/built-in/overview.d.cts +0 -6
  538. package/dist/report/built-in/overview.d.mts +0 -6
  539. package/dist/report/built-in/overview.d.ts +0 -6
  540. package/dist/report/built-in/overview.js +0 -9
  541. package/dist/report/built-in/overview.js.map +0 -1
  542. package/dist/runner/gate-lease.cjs +0 -283
  543. package/dist/runner/gate-lease.cjs.map +0 -1
  544. package/dist/runner/gate-lease.d.cts +0 -62
  545. package/dist/runner/gate-lease.d.mts +0 -62
  546. package/dist/runner/gate-lease.d.ts +0 -62
  547. package/dist/runner/gate-lease.js +0 -22
  548. package/dist/runner/gate-lease.js.map +0 -1
@@ -178,6 +178,46 @@ export interface Sample {
178
178
  readonly snapshot: SampleSnapshot;
179
179
  readonly [sampleCapabilityTypeId]: true;
180
180
  }
181
+ export type ExperimentGroupIdentity = {
182
+ readonly kind: "named";
183
+ readonly groupId: string;
184
+ readonly key: `named/${string}`;
185
+ } | {
186
+ readonly kind: "singleton";
187
+ readonly experimentId: ExperimentId;
188
+ readonly key: `singleton/${string}`;
189
+ };
190
+ export type NonComparableReason = "eval-population-mismatch";
191
+ export interface NonComparableIssue {
192
+ readonly reason: NonComparableReason;
193
+ readonly members: readonly ExperimentId[];
194
+ readonly actual: readonly {
195
+ readonly member: ExperimentId;
196
+ readonly population: JsonValue | null;
197
+ readonly basis: JsonValue | null;
198
+ }[];
199
+ readonly refs: readonly EvidenceRef[];
200
+ readonly params: Readonly<Record<string, JsonValue>>;
201
+ }
202
+ export type ExperimentComparisonState = {
203
+ readonly state: "comparable";
204
+ readonly members: readonly ExperimentId[];
205
+ } | {
206
+ readonly state: "non-comparable";
207
+ readonly members: readonly ExperimentId[];
208
+ readonly issues: readonly NonComparableIssue[];
209
+ };
210
+ declare const experimentComparisonScopeTypeId: unique symbol;
211
+ /** Analysis-issued comparison capability; the backing Sample remains private. */
212
+ export interface ExperimentComparisonScope {
213
+ readonly group: ExperimentGroupIdentity;
214
+ readonly comparison: ExperimentComparisonState;
215
+ readonly [experimentComparisonScopeTypeId]: true;
216
+ }
217
+ export interface AnalysisComparisonGroupMismatchError {
218
+ readonly code: "analysis-comparison-group-mismatch";
219
+ readonly groups: readonly ExperimentGroupIdentity[];
220
+ }
181
221
  export interface SampleSelector {
182
222
  readonly runIds?: readonly RunId[];
183
223
  readonly slotIds?: readonly SlotId[];
@@ -195,7 +235,7 @@ export interface AnalysisRequestError {
195
235
  readonly code: "analysis-request-invalid";
196
236
  readonly reason: string;
197
237
  }
198
- export type AnalysisInputIssueCode = "missing" | "unsupported" | "producer-incompatible" | "input-invalid" | "reduction-failed" | "relation-unmatched";
238
+ export type AnalysisInputIssueCode = "missing" | "migration-required" | "unsupported" | "producer-incompatible" | "input-invalid" | "reduction-failed" | "relation-unmatched";
199
239
  export interface EvidenceIdentity {
200
240
  readonly kind: "attempt";
201
241
  readonly locator: AttemptLocator;
@@ -218,14 +258,14 @@ export type SampleInputObservation<Value> = {
218
258
  readonly refs: readonly EvidenceRef[];
219
259
  readonly producer?: ProducerIdentity;
220
260
  } | {
221
- readonly state: "missing" | "unsupported" | "failed";
261
+ readonly state: "missing" | "migration-required" | "unsupported" | "failed";
222
262
  readonly issues: readonly AnalysisIssue[];
223
263
  readonly refs: readonly EvidenceRef[];
224
264
  readonly producer?: ProducerIdentity;
225
265
  };
226
266
  export type MetricState = "available" | "partial"
227
267
  /** A specialized closed metric may have no reportable value at all. */
228
- | "unavailable" | "empty" | "unsupported" | "failed";
268
+ | "unavailable" | "empty" | "migration-required" | "unsupported" | "failed";
229
269
  export type MetricBasis = "attempt" | "eval" | "run" | "pair" | "slot";
230
270
  export type MeasureFormat = string | {
231
271
  readonly kind: string;
@@ -178,6 +178,46 @@ export interface Sample {
178
178
  readonly snapshot: SampleSnapshot;
179
179
  readonly [sampleCapabilityTypeId]: true;
180
180
  }
181
+ export type ExperimentGroupIdentity = {
182
+ readonly kind: "named";
183
+ readonly groupId: string;
184
+ readonly key: `named/${string}`;
185
+ } | {
186
+ readonly kind: "singleton";
187
+ readonly experimentId: ExperimentId;
188
+ readonly key: `singleton/${string}`;
189
+ };
190
+ export type NonComparableReason = "eval-population-mismatch";
191
+ export interface NonComparableIssue {
192
+ readonly reason: NonComparableReason;
193
+ readonly members: readonly ExperimentId[];
194
+ readonly actual: readonly {
195
+ readonly member: ExperimentId;
196
+ readonly population: JsonValue | null;
197
+ readonly basis: JsonValue | null;
198
+ }[];
199
+ readonly refs: readonly EvidenceRef[];
200
+ readonly params: Readonly<Record<string, JsonValue>>;
201
+ }
202
+ export type ExperimentComparisonState = {
203
+ readonly state: "comparable";
204
+ readonly members: readonly ExperimentId[];
205
+ } | {
206
+ readonly state: "non-comparable";
207
+ readonly members: readonly ExperimentId[];
208
+ readonly issues: readonly NonComparableIssue[];
209
+ };
210
+ declare const experimentComparisonScopeTypeId: unique symbol;
211
+ /** Analysis-issued comparison capability; the backing Sample remains private. */
212
+ export interface ExperimentComparisonScope {
213
+ readonly group: ExperimentGroupIdentity;
214
+ readonly comparison: ExperimentComparisonState;
215
+ readonly [experimentComparisonScopeTypeId]: true;
216
+ }
217
+ export interface AnalysisComparisonGroupMismatchError {
218
+ readonly code: "analysis-comparison-group-mismatch";
219
+ readonly groups: readonly ExperimentGroupIdentity[];
220
+ }
181
221
  export interface SampleSelector {
182
222
  readonly runIds?: readonly RunId[];
183
223
  readonly slotIds?: readonly SlotId[];
@@ -195,7 +235,7 @@ export interface AnalysisRequestError {
195
235
  readonly code: "analysis-request-invalid";
196
236
  readonly reason: string;
197
237
  }
198
- export type AnalysisInputIssueCode = "missing" | "unsupported" | "producer-incompatible" | "input-invalid" | "reduction-failed" | "relation-unmatched";
238
+ export type AnalysisInputIssueCode = "missing" | "migration-required" | "unsupported" | "producer-incompatible" | "input-invalid" | "reduction-failed" | "relation-unmatched";
199
239
  export interface EvidenceIdentity {
200
240
  readonly kind: "attempt";
201
241
  readonly locator: AttemptLocator;
@@ -218,14 +258,14 @@ export type SampleInputObservation<Value> = {
218
258
  readonly refs: readonly EvidenceRef[];
219
259
  readonly producer?: ProducerIdentity;
220
260
  } | {
221
- readonly state: "missing" | "unsupported" | "failed";
261
+ readonly state: "missing" | "migration-required" | "unsupported" | "failed";
222
262
  readonly issues: readonly AnalysisIssue[];
223
263
  readonly refs: readonly EvidenceRef[];
224
264
  readonly producer?: ProducerIdentity;
225
265
  };
226
266
  export type MetricState = "available" | "partial"
227
267
  /** A specialized closed metric may have no reportable value at all. */
228
- | "unavailable" | "empty" | "unsupported" | "failed";
268
+ | "unavailable" | "empty" | "migration-required" | "unsupported" | "failed";
229
269
  export type MetricBasis = "attempt" | "eval" | "run" | "pair" | "slot";
230
270
  export type MeasureFormat = string | {
231
271
  readonly kind: string;
@@ -172,9 +172,10 @@ function aggregateCostProjection(profile, slots, mode) {
172
172
  reasons: freezeReasons(slots.flatMap((slot) => slot.reasons)),
173
173
  ledger: Object.freeze(slots.flatMap((slot) => slot.ledger).sort(compareLedger)),
174
174
  });
175
+ const migrationRequired = combined === null && slots.length > 0 && slots.every((slot) => slot.reasons.some((reason) => reason.code === "usage-migration-required"));
175
176
  const projection = combined === null
176
177
  ? Object.freeze({
177
- state: "unavailable",
178
+ state: migrationRequired ? "migration-required" : "unavailable",
178
179
  basis: "unavailable",
179
180
  observed: null,
180
181
  estimated: null,
@@ -1 +1 @@
1
- {"version":3,"file":"cost-projection.js","sourceRoot":"","sources":["cost-projection.ts"],"names":[],"mappings":";;AAqBA,kDAqBC;AAED,4CA4GC;AAED,0DA0EC;AAjOD,sDAAkI;AAIlI,uDAAgR;AAChR,uCAA8b;AAY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,SAAS;QACrB,MAAM,IAAI,KAAK,CAAC,GAAG,IAAI,qCAAqC,CAAC,CAAC;IAClE,OAAO,OAAO,CAAC;AACnB,CAAC","sourcesContent":["import type { AttemptObservabilityAttachment } from \"../record/family/observability.ts\";\nimport type { RecordAttachmentPayloadSnapshot } from \"../record/attachment/types.ts\";\nimport type { CanonicalDecimal, CurrencyCode, NonNegativeSafeInteger, SafeIdentifier, } from \"../o11y/record/model.ts\";\nimport { makeCanonicalDecimal, makeCurrencyCode, makeNonNegativeSafeInteger, makeSafeIdentifier, } from \"../o11y/record/model.ts\";\nimport type { ClosedAttemptCore } from \"./domain-view.ts\";\nimport type { LogicalSlot } from \"./definitions.ts\";\nimport type { AnalysisSlotRef, EvidenceRef } from \"./contracts.ts\";\nimport { addDecimalCoefficients, costForPerMillionTokens, divideDecimalCoefficient, multiplyCanonicalDecimalByInteger, normalizeCanonicalDecimal, parseCanonicalDecimal, rationalFromDecimal, roundDecimalRationalHalfAway, type DecimalCoefficient, } from \"./cost-decimal.ts\";\nimport { builtInPricingCoverage, builtInPricingProfile, closeCostProjectionProfile, pricingCoverageMatches, type CostBasis, type CostCoverageReason, type CostLedgerEntry, type CostProjectionValue, type CostComponent, type EstimatedRequestCostComponent, type EstimatedTokenCostComponent, type ObservedCostComponent, type ObservedOtherCurrency, type PricingCharge, type PricingCoverage, type PricingProfile, type ProjectedMoney, } from \"./cost.ts\";\n/** @internal One raw, Sample-local Slot closure before group aggregation. */\nexport interface CostSlotProjection {\n readonly slot: AnalysisSlotRef;\n readonly complete: boolean;\n readonly observed: readonly ObservedOtherCurrency[];\n readonly estimated: readonly CanonicalDecimal[];\n readonly reasons: readonly CostCoverageReason[];\n readonly ledger: readonly CostLedgerEntry[];\n readonly refs: readonly EvidenceRef[];\n}\ntype UsageSnapshot = RecordAttachmentPayloadSnapshot<AttemptObservabilityAttachment>[\"usage\"];\n/** @internal Builds a missing denominator Slot without inventing a provider. */\nexport function unavailableCostSlot(member: LogicalSlot, code: Extract<CostCoverageReason[\"code\"], \"member-not-recorded\" | \"core-invalid\" | \"origin-run-unavailable\" | \"usage-not-recorded\" | \"usage-unavailable\" | \"usage-unsupported\" | \"usage-invalid\">, refs: readonly EvidenceRef[] = []): CostSlotProjection {\n const slot = closeSlot(member);\n const reason = costReason(slot, null, code);\n return Object.freeze({\n slot,\n complete: false,\n observed: Object.freeze([]),\n estimated: Object.freeze([]),\n reasons: Object.freeze([reason]),\n ledger: Object.freeze([\n Object.freeze({\n slot,\n provider: null,\n branch: \"unavailable\" as const,\n components: Object.freeze([]) as readonly [\n ],\n estimated: null,\n }),\n ]),\n refs: freezeRefs(refs),\n });\n}\n/** @internal Closes one available Usage family with origin-only profile matching. */\nexport function projectCostUsage(input: {\n readonly member: LogicalSlot;\n readonly core: ClosedAttemptCore;\n readonly usage: UsageSnapshot;\n readonly profile: PricingProfile;\n readonly refs: readonly EvidenceRef[];\n}): CostSlotProjection {\n const slot = closeSlot(input.member);\n type UsageObservation = UsageSnapshot[\"observations\"][number];\n const byProvider = new Map<SafeIdentifier, UsageObservation[]>();\n for (const observation of input.usage.observations) {\n const provider = requiredSafeIdentifier(observation.provider, \"Usage provider\");\n const entries = byProvider.get(provider);\n if (entries === undefined)\n byProvider.set(provider, [observation]);\n else\n entries.push(observation);\n }\n const observed: ObservedOtherCurrency[] = [];\n const estimated: CanonicalDecimal[] = [];\n const reasons: CostCoverageReason[] = [];\n const ledger: CostLedgerEntry[] = [];\n let complete = input.usage.collection.state === \"complete\";\n if (!complete)\n reasons.push(costReason(slot, null, \"usage-collection-partial\"));\n for (const [provider, observations] of [...byProvider.entries()].sort(compareProviderEntry)) {\n const providerCosts = observations.filter((observation) => observation.kind === \"provider-cost\");\n if (providerCosts.length > 0) {\n const components = Object.freeze(providerCosts\n .map((observation) => Object.freeze({\n kind: \"provider-cost\" as const,\n provider,\n currency: requiredCurrencyCode(observation.currency, \"Usage provider-cost currency\"),\n amount: requiredCanonicalDecimal(observation.amount, \"Usage provider-cost amount\"),\n }))\n .sort(compareComponent)) as readonly [\n ObservedCostComponent,\n ...ObservedCostComponent[]\n ];\n observed.push(...components.map((component) => Object.freeze({\n provider: component.provider,\n currency: component.currency,\n amount: component.amount,\n })));\n if (components.some((entry) => entry.currency !== input.profile.currency)) {\n complete = false;\n reasons.push(costReason(slot, provider, \"observed-cost-other-currency\"));\n }\n ledger.push(Object.freeze({\n slot,\n provider,\n branch: \"observed\" as const,\n components,\n estimated: null,\n }));\n continue;\n }\n if (input.core.origin.execution.model === null) {\n complete = false;\n reasons.push(costReason(slot, provider, \"execution-model-not-recorded\"));\n ledger.push(unavailableLedger(slot, provider));\n continue;\n }\n const coverage = matchingCoverage(input.profile, provider, input.core);\n if (coverage === undefined) {\n complete = false;\n reasons.push(costReason(slot, provider, \"pricing-coverage-not-found\"));\n ledger.push(unavailableLedger(slot, provider));\n continue;\n }\n if (coverage.state === \"unpriced\") {\n complete = false;\n reasons.push(costReason(slot, provider, \"pricing-coverage-unpriced\"));\n ledger.push(unavailableLedger(slot, provider));\n continue;\n }\n const priced = estimateProvider(slot, provider, observations, coverage, reasons);\n if (!priced.complete || priced.components.length === 0) {\n complete = false;\n if (priced.components.length === 0 && !reasons.some((reason) => reason.slot === slot && reason.provider === provider && reason.code === \"pricing-charge-not-found\")) {\n reasons.push(costReason(slot, provider, \"pricing-charge-not-found\"));\n }\n ledger.push(unavailableLedger(slot, provider));\n continue;\n }\n estimated.push(priced.amount);\n ledger.push(Object.freeze({\n slot,\n provider,\n branch: \"estimated\" as const,\n components: priced.components,\n estimated: projectedMoneyFromDecimal(input.profile, parseCanonicalDecimal(priced.amount)),\n }));\n }\n if (byProvider.size === 0) {\n complete = false;\n reasons.push(costReason(slot, null, \"usage-unavailable\"));\n ledger.push(unavailableLedger(slot, null));\n }\n return Object.freeze({\n slot,\n complete,\n observed: Object.freeze([...observed].sort(compareObserved)),\n estimated: Object.freeze([...estimated]),\n reasons: freezeReasons(reasons),\n ledger: Object.freeze([...ledger].sort(compareLedger)),\n refs: freezeRefs(input.refs),\n });\n}\n/** @internal Exactly reduces closed raw Slot data for one requested cost Measure. */\nexport function aggregateCostProjection(profile: PricingProfile, slots: readonly CostSlotProjection[], mode: \"mean\" | \"total\"): {\n readonly projection: CostProjectionValue;\n readonly samples: number;\n readonly total: number;\n readonly refs: readonly EvidenceRef[];\n readonly value: number | null;\n} {\n // A provider-cost coordinate is only a known USD subtotal when every\n // observed component in that locked coordinate is USD. Keeping a USD\n // fragment beside an unconvertible currency would fabricate a partial\n // provider invoice rather than close the observed branch faithfully.\n const observedQuote = slots.flatMap((slot) => slot.ledger.flatMap((entry) => entry.branch !== \"observed\" || entry.components.some((component) => component.currency !== profile.currency)\n ? []\n : entry.components.map((component) => component.amount)));\n const estimatedQuote = slots.flatMap((slot) => slot.estimated);\n const contributingSlots = slots.filter((slot) => slotHasQuoteAmount(slot, profile.currency));\n const observedTotal = exactSum(observedQuote);\n const estimatedTotal = exactSum(estimatedQuote);\n const combinedTotal = exactSum([...observedQuote, ...estimatedQuote]);\n const observed = observedTotal === undefined\n ? null\n : projectedMoneyFromDecimal(profile, observedTotal, mode, contributingSlots.length);\n const estimated = estimatedTotal === undefined\n ? null\n : projectedMoneyFromDecimal(profile, estimatedTotal, mode, contributingSlots.length);\n const combined = combinedTotal === undefined\n ? null\n : projectedMoneyFromDecimal(profile, combinedTotal, mode, contributingSlots.length);\n const basis = costBasis(observed, estimated);\n const complete = slots.length > 0 && slots.every((slot) => slot.complete && slotHasQuoteAmount(slot, profile.currency));\n const common = Object.freeze({\n profile: closeCostProjectionProfile(profile),\n aggregate: combinedTotal === undefined\n ? mode === \"mean\"\n ? Object.freeze({ kind: \"mean\" as const, numerator: \"0\" as CanonicalDecimal, denominator: 0 })\n : Object.freeze({ kind: \"total\" as const, total: \"0\" as CanonicalDecimal })\n : mode === \"mean\"\n ? Object.freeze({\n kind: \"mean\" as const,\n numerator: normalizeCanonicalDecimal(combinedTotal),\n denominator: contributingSlots.length,\n })\n : Object.freeze({ kind: \"total\" as const, total: normalizeCanonicalDecimal(combinedTotal) }),\n observedOtherCurrencies: Object.freeze(slots.flatMap((slot) => slot.observed)\n .filter((entry) => entry.currency !== profile.currency)\n .sort(compareObserved)),\n reasons: freezeReasons(slots.flatMap((slot) => slot.reasons)),\n ledger: Object.freeze(slots.flatMap((slot) => slot.ledger).sort(compareLedger)),\n });\n const projection: CostProjectionValue = combined === null\n ? Object.freeze({\n state: \"unavailable\" as const,\n basis: \"unavailable\" as const,\n observed: null,\n estimated: null,\n combined: null,\n ...common,\n })\n : Object.freeze({\n state: complete ? \"available\" as const : \"partial\" as const,\n basis,\n observed,\n estimated,\n combined,\n ...common,\n });\n const numeric = combined === null ? null : Number(combined.amount);\n return Object.freeze({\n projection,\n samples: contributingSlots.length,\n total: slots.length,\n refs: freezeRefs(slots.flatMap((slot) => slot.refs)),\n value: numeric !== null && Number.isFinite(numeric) ? numeric : null,\n });\n}\nfunction matchingCoverage(profile: PricingProfile, provider: SafeIdentifier, core: ClosedAttemptCore): PricingCoverage | undefined {\n const matches = profile.coverage.filter((coverage) => pricingCoverageMatches(coverage, {\n provider,\n origin: core.origin,\n }));\n if (matches.length > 1) {\n throw new Error(\"PricingProfile validation allowed multiple matching coverage entries\");\n }\n if (matches[0] !== undefined)\n return matches[0];\n const model = core.origin.execution.model;\n return profile.contentIdentity === builtInPricingProfile.contentIdentity && model !== null\n ? builtInPricingCoverage(model)\n : undefined;\n}\nfunction estimateProvider(slot: AnalysisSlotRef, provider: SafeIdentifier, observations: UsageSnapshot[\"observations\"], coverage: Extract<PricingCoverage, {\n readonly state: \"priced\";\n}>, reasons: CostCoverageReason[]): {\n readonly amount: CanonicalDecimal;\n readonly complete: boolean;\n readonly components: readonly (EstimatedTokenCostComponent | EstimatedRequestCostComponent)[];\n} {\n const charges = new Map<string, PricingCharge>();\n for (const charge of coverage.charges) {\n charges.set(charge.kind === \"token\" ? `token:${charge.bucket}` : `request:${charge.requestKind}`, charge);\n }\n const amounts: CanonicalDecimal[] = [];\n const components: (EstimatedTokenCostComponent | EstimatedRequestCostComponent)[] = [];\n let complete = true;\n const hasReasoning = observations.some((observation) => observation.kind === \"token-bucket\" && observation.bucket === \"reasoning\");\n const hasOutput = observations.some((observation) => observation.kind === \"token-bucket\" && observation.bucket === \"output\");\n // Reasoning is a detail inside the provider's output total, not an\n // independently billable bucket. If only that detail was recorded, the\n // output subtotal is unknown; silently dropping it would understate cost.\n if (hasReasoning && !hasOutput) {\n complete = false;\n reasons.push(costReason(slot, provider, \"pricing-charge-not-found\"));\n }\n for (const observation of observations) {\n if (observation.kind === \"provider-cost\")\n continue;\n if (observation.kind === \"token-bucket\") {\n // reasoning is an output subset and cannot be independently priced.\n if (observation.bucket === \"reasoning\")\n continue;\n // `other` has no v1 independent-price coordinate and is not covered by\n // any of the billable token buckets. It therefore makes this provider\n // closure incomplete even when input/output were priced successfully.\n if (observation.bucket === \"other\") {\n complete = false;\n reasons.push(costReason(slot, provider, \"pricing-charge-not-found\"));\n continue;\n }\n const charge = charges.get(`token:${observation.bucket}`);\n if (charge === undefined || charge.kind !== \"token\") {\n complete = false;\n reasons.push(costReason(slot, provider, \"pricing-charge-not-found\"));\n }\n else {\n const tokens = requiredNonNegativeSafeInteger(observation.tokens, \"Usage token count\");\n const amount = costForPerMillionTokens(charge.perMillionTokens, tokens);\n amounts.push(amount);\n components.push(Object.freeze({\n kind: \"token\" as const,\n provider,\n bucket: charge.bucket,\n tokens,\n ratePerMillionTokens: charge.perMillionTokens,\n amount,\n }));\n }\n continue;\n }\n if (observation.kind === \"request\") {\n const charge = charges.get(`request:${observation.requestKind}`);\n if (charge === undefined || charge.kind !== \"request\") {\n complete = false;\n reasons.push(costReason(slot, provider, \"pricing-charge-not-found\"));\n }\n else {\n const amount = multiplyCanonicalDecimalByInteger(charge.ratePerRequest, 1 as NonNegativeSafeInteger);\n amounts.push(amount);\n components.push(Object.freeze({\n kind: \"request\" as const,\n provider,\n requestKind: charge.requestKind,\n ratePerRequest: charge.ratePerRequest,\n amount,\n }));\n }\n }\n }\n return Object.freeze({\n amount: exactCanonicalSum(amounts),\n complete,\n components: Object.freeze([...components].sort(compareComponent)),\n });\n}\nfunction exactSum(values: readonly CanonicalDecimal[]): DecimalCoefficient | undefined {\n return values.length === 0 ? undefined : addDecimalCoefficients(values.map(parseCanonicalDecimal));\n}\nfunction exactCanonicalSum(values: readonly CanonicalDecimal[]): CanonicalDecimal {\n return normalizeCanonicalDecimal(addDecimalCoefficients(values.map(parseCanonicalDecimal)));\n}\nfunction projectedMoneyFromDecimal(profile: PricingProfile, value: DecimalCoefficient, mode?: \"mean\" | \"total\", contributingSlots?: number): ProjectedMoney {\n if (mode === \"mean\" && (contributingSlots === undefined || contributingSlots <= 0)) {\n throw new Error(\"Cost mean cannot round without a quote-currency denominator\");\n }\n const rational = mode === \"mean\"\n ? divideDecimalCoefficient(value, contributingSlots!)\n : rationalFromDecimal(value);\n return Object.freeze({\n amount: roundDecimalRationalHalfAway(rational, profile.display.decimalPlaces),\n currency: profile.currency as CurrencyCode,\n decimalPlaces: profile.display.decimalPlaces,\n });\n}\nfunction slotHasQuoteAmount(slot: CostSlotProjection, currency: string): boolean {\n return slot.ledger.some((entry) => entry.branch === \"estimated\" ||\n (entry.branch === \"observed\" && entry.components.every((component) => component.currency === currency)));\n}\nfunction costBasis(observed: ProjectedMoney | null, estimated: ProjectedMoney | null): Exclude<CostBasis, \"unavailable\"> {\n if (observed !== null && estimated !== null)\n return \"mixed\";\n return observed !== null ? \"observed\" : \"estimated\";\n}\nfunction closeSlot(member: LogicalSlot): AnalysisSlotRef {\n return Object.freeze({\n runId: member.runId,\n slotId: member.slotId,\n experimentId: member.experimentId,\n evalId: member.evalId,\n attemptOrdinal: member.attemptOrdinal,\n executionIdentityDigest: member.executionIdentityDigest,\n });\n}\nfunction costReason(slot: AnalysisSlotRef, provider: SafeIdentifier | null, code: CostCoverageReason[\"code\"]): CostCoverageReason {\n return Object.freeze({ slot, provider, code });\n}\nfunction unavailableLedger(slot: AnalysisSlotRef, provider: SafeIdentifier | null): CostLedgerEntry {\n return Object.freeze({\n slot,\n provider,\n branch: \"unavailable\" as const,\n components: Object.freeze([]) as readonly [\n ],\n estimated: null,\n });\n}\nfunction freezeReasons(values: readonly CostCoverageReason[]): readonly CostCoverageReason[] {\n const byIdentity = new Map<string, CostCoverageReason>();\n for (const value of values) {\n const key = `${slotIdentity(value.slot)}\\u0000${value.provider ?? \"\"}\\u0000${value.code}`;\n if (!byIdentity.has(key))\n byIdentity.set(key, value);\n }\n return Object.freeze([...byIdentity.entries()].sort(([left], [right]) => compareUtf8(left, right)).map(([, value]) => value));\n}\nfunction freezeRefs(values: readonly EvidenceRef[]): readonly EvidenceRef[] {\n const byIdentity = new Map<string, EvidenceRef>();\n for (const value of values) {\n const key = `${value.identity.kind}\\u0000${value.identity.locator}`;\n if (!byIdentity.has(key)) {\n byIdentity.set(key, Object.freeze({ identity: Object.freeze({ ...value.identity }) }));\n }\n }\n return Object.freeze([...byIdentity.entries()].sort(([left], [right]) => compareUtf8(left, right)).map(([, value]) => value));\n}\nfunction compareProviderEntry([left]: readonly [\n SafeIdentifier,\n UsageSnapshot[\"observations\"][number][]\n], [right]: readonly [\n SafeIdentifier,\n UsageSnapshot[\"observations\"][number][]\n]): number {\n return compareUtf8(left, right);\n}\nfunction compareObserved(left: ObservedOtherCurrency, right: ObservedOtherCurrency): number {\n const leftKey = `${left.provider}\\u0000${left.currency}\\u0000${left.amount}`;\n const rightKey = `${right.provider}\\u0000${right.currency}\\u0000${right.amount}`;\n return compareUtf8(leftKey, rightKey);\n}\nfunction compareLedger(left: CostLedgerEntry, right: CostLedgerEntry): number {\n const leftKey = `${slotIdentity(left.slot)}\\u0000${left.provider ?? \"\"}\\u0000${left.branch}`;\n const rightKey = `${slotIdentity(right.slot)}\\u0000${right.provider ?? \"\"}\\u0000${right.branch}`;\n return compareUtf8(leftKey, rightKey);\n}\nfunction slotIdentity(slot: AnalysisSlotRef): string {\n return `${slot.runId}\\u0000${slot.slotId}`;\n}\nfunction compareComponent(left: CostComponent, right: CostComponent): number {\n const leftKey = componentKey(left);\n const rightKey = componentKey(right);\n return compareUtf8(leftKey, rightKey);\n}\nfunction componentKey(value: CostComponent): string {\n switch (value.kind) {\n case \"provider-cost\":\n return `provider-cost\\u0000${value.provider}\\u0000${value.currency}\\u0000${value.amount}`;\n case \"token\":\n return `token\\u0000${value.provider}\\u0000${value.bucket}\\u0000${value.tokens}\\u0000${value.amount}`;\n case \"request\":\n return `request\\u0000${value.provider}\\u0000${value.requestKind}\\u0000${value.amount}`;\n }\n}\nfunction compareUtf8(left: string, right: string): number {\n if (left === right)\n return 0;\n const first = new TextEncoder().encode(left);\n const second = new TextEncoder().encode(right);\n const length = Math.min(first.length, second.length);\n for (let index = 0; index < length; index += 1) {\n const difference = first[index]! - second[index]!;\n if (difference !== 0)\n return difference;\n }\n return first.length - second.length;\n}\nfunction requiredSafeIdentifier(value: string, name: string): SafeIdentifier {\n const identifier = makeSafeIdentifier(value);\n if (identifier === undefined)\n throw new Error(`${name} is not a SafeIdentifier`);\n return identifier;\n}\nfunction requiredCurrencyCode(value: string, name: string): CurrencyCode {\n const currency = makeCurrencyCode(value);\n if (currency === undefined)\n throw new Error(`${name} is not a CurrencyCode`);\n return currency;\n}\nfunction requiredCanonicalDecimal(value: string, name: string): CanonicalDecimal {\n const decimal = makeCanonicalDecimal(value);\n if (decimal === undefined)\n throw new Error(`${name} is not a canonical decimal`);\n return decimal;\n}\nfunction requiredNonNegativeSafeInteger(value: number, name: string): NonNegativeSafeInteger {\n const integer = makeNonNegativeSafeInteger(value);\n if (integer === undefined)\n throw new Error(`${name} is not a non-negative safe integer`);\n return integer;\n}\n"]}
1
+ {"version":3,"file":"cost-projection.js","sourceRoot":"","sources":["cost-projection.ts"],"names":[],"mappings":";;AAqBA,kDAqBC;AAED,4CA4GC;AAED,0DA2EC;AAlOD,sDAAkI;AAIlI,uDAAgR;AAChR,uCAA8b;AAY9b,gFAAgF;AA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A,+BAAoB,EAAC,KAAK,CAAC,CAAC;IAC5C,IAAI,OAAO,KAAK,SAAS;QACrB,MAAM,IAAI,KAAK,CAAC,GAAG,IAAI,6BAA6B,CAAC,CAAC;IAC1D,OAAO,OAAO,CAAC;AACnB,CAAC;AACD,SAAS,8BAA8B,CAAC,KAAa,EAAE,IAAY;IAC/D,MAAM,OAAO,GAAG,IAAA,qCAA0B,EAAC,KAAK,CAAC,CAAC;IAClD,IAAI,OAAO,KAAK,SAAS;QACrB,MAAM,IAAI,KAAK,CAAC,GAAG,IAAI,qCAAqC,CAAC,CAAC;IAClE,OAAO,OAAO,CAAC;AACnB,CAAC","sourcesContent":["import type { AttemptObservabilityAttachment } from \"../record/family/observability.ts\";\nimport type { RecordAttachmentPayloadSnapshot } from \"../record/attachment/types.ts\";\nimport type { CanonicalDecimal, CurrencyCode, NonNegativeSafeInteger, SafeIdentifier, } from \"../o11y/record/model.ts\";\nimport { makeCanonicalDecimal, makeCurrencyCode, makeNonNegativeSafeInteger, makeSafeIdentifier, } from \"../o11y/record/model.ts\";\nimport type { ClosedAttemptCore } from \"./domain-view.ts\";\nimport type { LogicalSlot } from \"./definitions.ts\";\nimport type { AnalysisSlotRef, EvidenceRef } from \"./contracts.ts\";\nimport { addDecimalCoefficients, costForPerMillionTokens, divideDecimalCoefficient, multiplyCanonicalDecimalByInteger, normalizeCanonicalDecimal, parseCanonicalDecimal, rationalFromDecimal, roundDecimalRationalHalfAway, type DecimalCoefficient, } from \"./cost-decimal.ts\";\nimport { builtInPricingCoverage, builtInPricingProfile, closeCostProjectionProfile, pricingCoverageMatches, type CostBasis, type CostCoverageReason, type CostLedgerEntry, type CostProjectionValue, type CostComponent, type EstimatedRequestCostComponent, type EstimatedTokenCostComponent, type ObservedCostComponent, type ObservedOtherCurrency, type PricingCharge, type PricingCoverage, type PricingProfile, type ProjectedMoney, } from \"./cost.ts\";\n/** @internal One raw, Sample-local Slot closure before group aggregation. */\nexport interface CostSlotProjection {\n readonly slot: AnalysisSlotRef;\n readonly complete: boolean;\n readonly observed: readonly ObservedOtherCurrency[];\n readonly estimated: readonly CanonicalDecimal[];\n readonly reasons: readonly CostCoverageReason[];\n readonly ledger: readonly CostLedgerEntry[];\n readonly refs: readonly EvidenceRef[];\n}\ntype UsageSnapshot = RecordAttachmentPayloadSnapshot<AttemptObservabilityAttachment>[\"usage\"];\n/** @internal Builds a missing denominator Slot without inventing a provider. */\nexport function unavailableCostSlot(member: LogicalSlot, code: Extract<CostCoverageReason[\"code\"], \"member-not-recorded\" | \"core-invalid\" | \"origin-run-unavailable\" | \"usage-not-recorded\" | \"usage-unavailable\" | \"usage-migration-required\" | \"usage-unsupported\" | \"usage-invalid\">, refs: readonly EvidenceRef[] = []): CostSlotProjection {\n const slot = closeSlot(member);\n const reason = costReason(slot, null, code);\n return Object.freeze({\n slot,\n complete: false,\n observed: Object.freeze([]),\n estimated: Object.freeze([]),\n reasons: Object.freeze([reason]),\n ledger: Object.freeze([\n Object.freeze({\n slot,\n provider: null,\n branch: \"unavailable\" as const,\n components: Object.freeze([]) as readonly [\n ],\n estimated: null,\n }),\n ]),\n refs: freezeRefs(refs),\n });\n}\n/** @internal Closes one available Usage family with origin-only profile matching. */\nexport function projectCostUsage(input: {\n readonly member: LogicalSlot;\n readonly core: ClosedAttemptCore;\n readonly usage: UsageSnapshot;\n readonly profile: PricingProfile;\n readonly refs: readonly EvidenceRef[];\n}): CostSlotProjection {\n const slot = closeSlot(input.member);\n type UsageObservation = UsageSnapshot[\"observations\"][number];\n const byProvider = new Map<SafeIdentifier, UsageObservation[]>();\n for (const observation of input.usage.observations) {\n const provider = requiredSafeIdentifier(observation.provider, \"Usage provider\");\n const entries = byProvider.get(provider);\n if (entries === undefined)\n byProvider.set(provider, [observation]);\n else\n entries.push(observation);\n }\n const observed: ObservedOtherCurrency[] = [];\n const estimated: CanonicalDecimal[] = [];\n const reasons: CostCoverageReason[] = [];\n const ledger: CostLedgerEntry[] = [];\n let complete = input.usage.collection.state === \"complete\";\n if (!complete)\n reasons.push(costReason(slot, null, \"usage-collection-partial\"));\n for (const [provider, observations] of [...byProvider.entries()].sort(compareProviderEntry)) {\n const providerCosts = observations.filter((observation) => observation.kind === \"provider-cost\");\n if (providerCosts.length > 0) {\n const components = Object.freeze(providerCosts\n .map((observation) => Object.freeze({\n kind: \"provider-cost\" as const,\n provider,\n currency: requiredCurrencyCode(observation.currency, \"Usage provider-cost currency\"),\n amount: requiredCanonicalDecimal(observation.amount, \"Usage provider-cost amount\"),\n }))\n .sort(compareComponent)) as readonly [\n ObservedCostComponent,\n ...ObservedCostComponent[]\n ];\n observed.push(...components.map((component) => Object.freeze({\n provider: component.provider,\n currency: component.currency,\n amount: component.amount,\n })));\n if (components.some((entry) => entry.currency !== input.profile.currency)) {\n complete = false;\n reasons.push(costReason(slot, provider, \"observed-cost-other-currency\"));\n }\n ledger.push(Object.freeze({\n slot,\n provider,\n branch: \"observed\" as const,\n components,\n estimated: null,\n }));\n continue;\n }\n if (input.core.origin.execution.model === null) {\n complete = false;\n reasons.push(costReason(slot, provider, \"execution-model-not-recorded\"));\n ledger.push(unavailableLedger(slot, provider));\n continue;\n }\n const coverage = matchingCoverage(input.profile, provider, input.core);\n if (coverage === undefined) {\n complete = false;\n reasons.push(costReason(slot, provider, \"pricing-coverage-not-found\"));\n ledger.push(unavailableLedger(slot, provider));\n continue;\n }\n if (coverage.state === \"unpriced\") {\n complete = false;\n reasons.push(costReason(slot, provider, \"pricing-coverage-unpriced\"));\n ledger.push(unavailableLedger(slot, provider));\n continue;\n }\n const priced = estimateProvider(slot, provider, observations, coverage, reasons);\n if (!priced.complete || priced.components.length === 0) {\n complete = false;\n if (priced.components.length === 0 && !reasons.some((reason) => reason.slot === slot && reason.provider === provider && reason.code === \"pricing-charge-not-found\")) {\n reasons.push(costReason(slot, provider, \"pricing-charge-not-found\"));\n }\n ledger.push(unavailableLedger(slot, provider));\n continue;\n }\n estimated.push(priced.amount);\n ledger.push(Object.freeze({\n slot,\n provider,\n branch: \"estimated\" as const,\n components: priced.components,\n estimated: projectedMoneyFromDecimal(input.profile, parseCanonicalDecimal(priced.amount)),\n }));\n }\n if (byProvider.size === 0) {\n complete = false;\n reasons.push(costReason(slot, null, \"usage-unavailable\"));\n ledger.push(unavailableLedger(slot, null));\n }\n return Object.freeze({\n slot,\n complete,\n observed: Object.freeze([...observed].sort(compareObserved)),\n estimated: Object.freeze([...estimated]),\n reasons: freezeReasons(reasons),\n ledger: Object.freeze([...ledger].sort(compareLedger)),\n refs: freezeRefs(input.refs),\n });\n}\n/** @internal Exactly reduces closed raw Slot data for one requested cost Measure. */\nexport function aggregateCostProjection(profile: PricingProfile, slots: readonly CostSlotProjection[], mode: \"mean\" | \"total\"): {\n readonly projection: CostProjectionValue;\n readonly samples: number;\n readonly total: number;\n readonly refs: readonly EvidenceRef[];\n readonly value: number | null;\n} {\n // A provider-cost coordinate is only a known USD subtotal when every\n // observed component in that locked coordinate is USD. Keeping a USD\n // fragment beside an unconvertible currency would fabricate a partial\n // provider invoice rather than close the observed branch faithfully.\n const observedQuote = slots.flatMap((slot) => slot.ledger.flatMap((entry) => entry.branch !== \"observed\" || entry.components.some((component) => component.currency !== profile.currency)\n ? []\n : entry.components.map((component) => component.amount)));\n const estimatedQuote = slots.flatMap((slot) => slot.estimated);\n const contributingSlots = slots.filter((slot) => slotHasQuoteAmount(slot, profile.currency));\n const observedTotal = exactSum(observedQuote);\n const estimatedTotal = exactSum(estimatedQuote);\n const combinedTotal = exactSum([...observedQuote, ...estimatedQuote]);\n const observed = observedTotal === undefined\n ? null\n : projectedMoneyFromDecimal(profile, observedTotal, mode, contributingSlots.length);\n const estimated = estimatedTotal === undefined\n ? null\n : projectedMoneyFromDecimal(profile, estimatedTotal, mode, contributingSlots.length);\n const combined = combinedTotal === undefined\n ? null\n : projectedMoneyFromDecimal(profile, combinedTotal, mode, contributingSlots.length);\n const basis = costBasis(observed, estimated);\n const complete = slots.length > 0 && slots.every((slot) => slot.complete && slotHasQuoteAmount(slot, profile.currency));\n const common = Object.freeze({\n profile: closeCostProjectionProfile(profile),\n aggregate: combinedTotal === undefined\n ? mode === \"mean\"\n ? Object.freeze({ kind: \"mean\" as const, numerator: \"0\" as CanonicalDecimal, denominator: 0 })\n : Object.freeze({ kind: \"total\" as const, total: \"0\" as CanonicalDecimal })\n : mode === \"mean\"\n ? Object.freeze({\n kind: \"mean\" as const,\n numerator: normalizeCanonicalDecimal(combinedTotal),\n denominator: contributingSlots.length,\n })\n : Object.freeze({ kind: \"total\" as const, total: normalizeCanonicalDecimal(combinedTotal) }),\n observedOtherCurrencies: Object.freeze(slots.flatMap((slot) => slot.observed)\n .filter((entry) => entry.currency !== profile.currency)\n .sort(compareObserved)),\n reasons: freezeReasons(slots.flatMap((slot) => slot.reasons)),\n ledger: Object.freeze(slots.flatMap((slot) => slot.ledger).sort(compareLedger)),\n });\n const migrationRequired = combined === null && slots.length > 0 && slots.every((slot) => slot.reasons.some((reason) => reason.code === \"usage-migration-required\"));\n const projection: CostProjectionValue = combined === null\n ? Object.freeze({\n state: migrationRequired ? \"migration-required\" as const : \"unavailable\" as const,\n basis: \"unavailable\" as const,\n observed: null,\n estimated: null,\n combined: null,\n ...common,\n })\n : Object.freeze({\n state: complete ? \"available\" as const : \"partial\" as const,\n basis,\n observed,\n estimated,\n combined,\n ...common,\n });\n const numeric = combined === null ? null : Number(combined.amount);\n return Object.freeze({\n projection,\n samples: contributingSlots.length,\n total: slots.length,\n refs: freezeRefs(slots.flatMap((slot) => slot.refs)),\n value: numeric !== null && Number.isFinite(numeric) ? numeric : null,\n });\n}\nfunction matchingCoverage(profile: PricingProfile, provider: SafeIdentifier, core: ClosedAttemptCore): PricingCoverage | undefined {\n const matches = profile.coverage.filter((coverage) => pricingCoverageMatches(coverage, {\n provider,\n origin: core.origin,\n }));\n if (matches.length > 1) {\n throw new Error(\"PricingProfile validation allowed multiple matching coverage entries\");\n }\n if (matches[0] !== undefined)\n return matches[0];\n const model = core.origin.execution.model;\n return profile.contentIdentity === builtInPricingProfile.contentIdentity && model !== null\n ? builtInPricingCoverage(model)\n : undefined;\n}\nfunction estimateProvider(slot: AnalysisSlotRef, provider: SafeIdentifier, observations: UsageSnapshot[\"observations\"], coverage: Extract<PricingCoverage, {\n readonly state: \"priced\";\n}>, reasons: CostCoverageReason[]): {\n readonly amount: CanonicalDecimal;\n readonly complete: boolean;\n readonly components: readonly (EstimatedTokenCostComponent | EstimatedRequestCostComponent)[];\n} {\n const charges = new Map<string, PricingCharge>();\n for (const charge of coverage.charges) {\n charges.set(charge.kind === \"token\" ? `token:${charge.bucket}` : `request:${charge.requestKind}`, charge);\n }\n const amounts: CanonicalDecimal[] = [];\n const components: (EstimatedTokenCostComponent | EstimatedRequestCostComponent)[] = [];\n let complete = true;\n const hasReasoning = observations.some((observation) => observation.kind === \"token-bucket\" && observation.bucket === \"reasoning\");\n const hasOutput = observations.some((observation) => observation.kind === \"token-bucket\" && observation.bucket === \"output\");\n // Reasoning is a detail inside the provider's output total, not an\n // independently billable bucket. If only that detail was recorded, the\n // output subtotal is unknown; silently dropping it would understate cost.\n if (hasReasoning && !hasOutput) {\n complete = false;\n reasons.push(costReason(slot, provider, \"pricing-charge-not-found\"));\n }\n for (const observation of observations) {\n if (observation.kind === \"provider-cost\")\n continue;\n if (observation.kind === \"token-bucket\") {\n // reasoning is an output subset and cannot be independently priced.\n if (observation.bucket === \"reasoning\")\n continue;\n // `other` has no v1 independent-price coordinate and is not covered by\n // any of the billable token buckets. It therefore makes this provider\n // closure incomplete even when input/output were priced successfully.\n if (observation.bucket === \"other\") {\n complete = false;\n reasons.push(costReason(slot, provider, \"pricing-charge-not-found\"));\n continue;\n }\n const charge = charges.get(`token:${observation.bucket}`);\n if (charge === undefined || charge.kind !== \"token\") {\n complete = false;\n reasons.push(costReason(slot, provider, \"pricing-charge-not-found\"));\n }\n else {\n const tokens = requiredNonNegativeSafeInteger(observation.tokens, \"Usage token count\");\n const amount = costForPerMillionTokens(charge.perMillionTokens, tokens);\n amounts.push(amount);\n components.push(Object.freeze({\n kind: \"token\" as const,\n provider,\n bucket: charge.bucket,\n tokens,\n ratePerMillionTokens: charge.perMillionTokens,\n amount,\n }));\n }\n continue;\n }\n if (observation.kind === \"request\") {\n const charge = charges.get(`request:${observation.requestKind}`);\n if (charge === undefined || charge.kind !== \"request\") {\n complete = false;\n reasons.push(costReason(slot, provider, \"pricing-charge-not-found\"));\n }\n else {\n const amount = multiplyCanonicalDecimalByInteger(charge.ratePerRequest, 1 as NonNegativeSafeInteger);\n amounts.push(amount);\n components.push(Object.freeze({\n kind: \"request\" as const,\n provider,\n requestKind: charge.requestKind,\n ratePerRequest: charge.ratePerRequest,\n amount,\n }));\n }\n }\n }\n return Object.freeze({\n amount: exactCanonicalSum(amounts),\n complete,\n components: Object.freeze([...components].sort(compareComponent)),\n });\n}\nfunction exactSum(values: readonly CanonicalDecimal[]): DecimalCoefficient | undefined {\n return values.length === 0 ? undefined : addDecimalCoefficients(values.map(parseCanonicalDecimal));\n}\nfunction exactCanonicalSum(values: readonly CanonicalDecimal[]): CanonicalDecimal {\n return normalizeCanonicalDecimal(addDecimalCoefficients(values.map(parseCanonicalDecimal)));\n}\nfunction projectedMoneyFromDecimal(profile: PricingProfile, value: DecimalCoefficient, mode?: \"mean\" | \"total\", contributingSlots?: number): ProjectedMoney {\n if (mode === \"mean\" && (contributingSlots === undefined || contributingSlots <= 0)) {\n throw new Error(\"Cost mean cannot round without a quote-currency denominator\");\n }\n const rational = mode === \"mean\"\n ? divideDecimalCoefficient(value, contributingSlots!)\n : rationalFromDecimal(value);\n return Object.freeze({\n amount: roundDecimalRationalHalfAway(rational, profile.display.decimalPlaces),\n currency: profile.currency as CurrencyCode,\n decimalPlaces: profile.display.decimalPlaces,\n });\n}\nfunction slotHasQuoteAmount(slot: CostSlotProjection, currency: string): boolean {\n return slot.ledger.some((entry) => entry.branch === \"estimated\" ||\n (entry.branch === \"observed\" && entry.components.every((component) => component.currency === currency)));\n}\nfunction costBasis(observed: ProjectedMoney | null, estimated: ProjectedMoney | null): Exclude<CostBasis, \"unavailable\"> {\n if (observed !== null && estimated !== null)\n return \"mixed\";\n return observed !== null ? \"observed\" : \"estimated\";\n}\nfunction closeSlot(member: LogicalSlot): AnalysisSlotRef {\n return Object.freeze({\n runId: member.runId,\n slotId: member.slotId,\n experimentId: member.experimentId,\n evalId: member.evalId,\n attemptOrdinal: member.attemptOrdinal,\n executionIdentityDigest: member.executionIdentityDigest,\n });\n}\nfunction costReason(slot: AnalysisSlotRef, provider: SafeIdentifier | null, code: CostCoverageReason[\"code\"]): CostCoverageReason {\n return Object.freeze({ slot, provider, code });\n}\nfunction unavailableLedger(slot: AnalysisSlotRef, provider: SafeIdentifier | null): CostLedgerEntry {\n return Object.freeze({\n slot,\n provider,\n branch: \"unavailable\" as const,\n components: Object.freeze([]) as readonly [\n ],\n estimated: null,\n });\n}\nfunction freezeReasons(values: readonly CostCoverageReason[]): readonly CostCoverageReason[] {\n const byIdentity = new Map<string, CostCoverageReason>();\n for (const value of values) {\n const key = `${slotIdentity(value.slot)}\\u0000${value.provider ?? \"\"}\\u0000${value.code}`;\n if (!byIdentity.has(key))\n byIdentity.set(key, value);\n }\n return Object.freeze([...byIdentity.entries()].sort(([left], [right]) => compareUtf8(left, right)).map(([, value]) => value));\n}\nfunction freezeRefs(values: readonly EvidenceRef[]): readonly EvidenceRef[] {\n const byIdentity = new Map<string, EvidenceRef>();\n for (const value of values) {\n const key = `${value.identity.kind}\\u0000${value.identity.locator}`;\n if (!byIdentity.has(key)) {\n byIdentity.set(key, Object.freeze({ identity: Object.freeze({ ...value.identity }) }));\n }\n }\n return Object.freeze([...byIdentity.entries()].sort(([left], [right]) => compareUtf8(left, right)).map(([, value]) => value));\n}\nfunction compareProviderEntry([left]: readonly [\n SafeIdentifier,\n UsageSnapshot[\"observations\"][number][]\n], [right]: readonly [\n SafeIdentifier,\n UsageSnapshot[\"observations\"][number][]\n]): number {\n return compareUtf8(left, right);\n}\nfunction compareObserved(left: ObservedOtherCurrency, right: ObservedOtherCurrency): number {\n const leftKey = `${left.provider}\\u0000${left.currency}\\u0000${left.amount}`;\n const rightKey = `${right.provider}\\u0000${right.currency}\\u0000${right.amount}`;\n return compareUtf8(leftKey, rightKey);\n}\nfunction compareLedger(left: CostLedgerEntry, right: CostLedgerEntry): number {\n const leftKey = `${slotIdentity(left.slot)}\\u0000${left.provider ?? \"\"}\\u0000${left.branch}`;\n const rightKey = `${slotIdentity(right.slot)}\\u0000${right.provider ?? \"\"}\\u0000${right.branch}`;\n return compareUtf8(leftKey, rightKey);\n}\nfunction slotIdentity(slot: AnalysisSlotRef): string {\n return `${slot.runId}\\u0000${slot.slotId}`;\n}\nfunction compareComponent(left: CostComponent, right: CostComponent): number {\n const leftKey = componentKey(left);\n const rightKey = componentKey(right);\n return compareUtf8(leftKey, rightKey);\n}\nfunction componentKey(value: CostComponent): string {\n switch (value.kind) {\n case \"provider-cost\":\n return `provider-cost\\u0000${value.provider}\\u0000${value.currency}\\u0000${value.amount}`;\n case \"token\":\n return `token\\u0000${value.provider}\\u0000${value.bucket}\\u0000${value.tokens}\\u0000${value.amount}`;\n case \"request\":\n return `request\\u0000${value.provider}\\u0000${value.requestKind}\\u0000${value.amount}`;\n }\n}\nfunction compareUtf8(left: string, right: string): number {\n if (left === right)\n return 0;\n const first = new TextEncoder().encode(left);\n const second = new TextEncoder().encode(right);\n const length = Math.min(first.length, second.length);\n for (let index = 0; index < length; index += 1) {\n const difference = first[index]! - second[index]!;\n if (difference !== 0)\n return difference;\n }\n return first.length - second.length;\n}\nfunction requiredSafeIdentifier(value: string, name: string): SafeIdentifier {\n const identifier = makeSafeIdentifier(value);\n if (identifier === undefined)\n throw new Error(`${name} is not a SafeIdentifier`);\n return identifier;\n}\nfunction requiredCurrencyCode(value: string, name: string): CurrencyCode {\n const currency = makeCurrencyCode(value);\n if (currency === undefined)\n throw new Error(`${name} is not a CurrencyCode`);\n return currency;\n}\nfunction requiredCanonicalDecimal(value: string, name: string): CanonicalDecimal {\n const decimal = makeCanonicalDecimal(value);\n if (decimal === undefined)\n throw new Error(`${name} is not a canonical decimal`);\n return decimal;\n}\nfunction requiredNonNegativeSafeInteger(value: number, name: string): NonNegativeSafeInteger {\n const integer = makeNonNegativeSafeInteger(value);\n if (integer === undefined)\n throw new Error(`${name} is not a non-negative safe integer`);\n return integer;\n}\n"]}
@@ -17,7 +17,7 @@ export interface CostSlotProjection {
17
17
  }
18
18
  type UsageSnapshot = RecordAttachmentPayloadSnapshot<AttemptObservabilityAttachment>["usage"];
19
19
  /** @internal Builds a missing denominator Slot without inventing a provider. */
20
- export declare function unavailableCostSlot(member: LogicalSlot, code: Extract<CostCoverageReason["code"], "member-not-recorded" | "core-invalid" | "origin-run-unavailable" | "usage-not-recorded" | "usage-unavailable" | "usage-unsupported" | "usage-invalid">, refs?: readonly EvidenceRef[]): CostSlotProjection;
20
+ export declare function unavailableCostSlot(member: LogicalSlot, code: Extract<CostCoverageReason["code"], "member-not-recorded" | "core-invalid" | "origin-run-unavailable" | "usage-not-recorded" | "usage-unavailable" | "usage-migration-required" | "usage-unsupported" | "usage-invalid">, refs?: readonly EvidenceRef[]): CostSlotProjection;
21
21
  /** @internal Closes one available Usage family with origin-only profile matching. */
22
22
  export declare function projectCostUsage(input: {
23
23
  readonly member: LogicalSlot;
@@ -17,7 +17,7 @@ export interface CostSlotProjection {
17
17
  }
18
18
  type UsageSnapshot = RecordAttachmentPayloadSnapshot<AttemptObservabilityAttachment>["usage"];
19
19
  /** @internal Builds a missing denominator Slot without inventing a provider. */
20
- export declare function unavailableCostSlot(member: LogicalSlot, code: Extract<CostCoverageReason["code"], "member-not-recorded" | "core-invalid" | "origin-run-unavailable" | "usage-not-recorded" | "usage-unavailable" | "usage-unsupported" | "usage-invalid">, refs?: readonly EvidenceRef[]): CostSlotProjection;
20
+ export declare function unavailableCostSlot(member: LogicalSlot, code: Extract<CostCoverageReason["code"], "member-not-recorded" | "core-invalid" | "origin-run-unavailable" | "usage-not-recorded" | "usage-unavailable" | "usage-migration-required" | "usage-unsupported" | "usage-invalid">, refs?: readonly EvidenceRef[]): CostSlotProjection;
21
21
  /** @internal Closes one available Usage family with origin-only profile matching. */
22
22
  export declare function projectCostUsage(input: {
23
23
  readonly member: LogicalSlot;
@@ -17,7 +17,7 @@ export interface CostSlotProjection {
17
17
  }
18
18
  type UsageSnapshot = RecordAttachmentPayloadSnapshot<AttemptObservabilityAttachment>["usage"];
19
19
  /** @internal Builds a missing denominator Slot without inventing a provider. */
20
- export declare function unavailableCostSlot(member: LogicalSlot, code: Extract<CostCoverageReason["code"], "member-not-recorded" | "core-invalid" | "origin-run-unavailable" | "usage-not-recorded" | "usage-unavailable" | "usage-unsupported" | "usage-invalid">, refs?: readonly EvidenceRef[]): CostSlotProjection;
20
+ export declare function unavailableCostSlot(member: LogicalSlot, code: Extract<CostCoverageReason["code"], "member-not-recorded" | "core-invalid" | "origin-run-unavailable" | "usage-not-recorded" | "usage-unavailable" | "usage-migration-required" | "usage-unsupported" | "usage-invalid">, refs?: readonly EvidenceRef[]): CostSlotProjection;
21
21
  /** @internal Closes one available Usage family with origin-only profile matching. */
22
22
  export declare function projectCostUsage(input: {
23
23
  readonly member: LogicalSlot;
@@ -183,9 +183,18 @@ function isCostProjectionValue(value) {
183
183
  !projection.ledger.every((entry) => isCostLedgerEntry(entry, profile))) {
184
184
  return false;
185
185
  }
186
- if (projection.state === "unavailable") {
187
- return projection.basis === "unavailable" && projection.observed === null &&
188
- projection.estimated === null && projection.combined === null;
186
+ if (projection.state === "unavailable" || projection.state === "migration-required") {
187
+ if (projection.basis !== "unavailable" || projection.observed !== null ||
188
+ projection.estimated !== null || projection.combined !== null)
189
+ return false;
190
+ if (projection.state === "unavailable")
191
+ return true;
192
+ const ledger = projection.ledger;
193
+ const reasons = projection.reasons;
194
+ return ledger.length > 0 &&
195
+ ledger.every((entry) => entry.branch === "unavailable" && reasons.some((reason) => reason.code === "usage-migration-required" &&
196
+ reason.slot.runId === entry.slot.runId &&
197
+ reason.slot.slotId === entry.slot.slotId));
189
198
  }
190
199
  if (projection.state !== "available" && projection.state !== "partial" ||
191
200
  !isNullableProjectedMoney(projection.observed, profile) ||
@@ -218,6 +227,7 @@ const COST_COVERAGE_REASON_CODES = new Set([
218
227
  "execution-model-not-recorded",
219
228
  "usage-not-recorded",
220
229
  "usage-unavailable",
230
+ "usage-migration-required",
221
231
  "usage-unsupported",
222
232
  "usage-invalid",
223
233
  "usage-collection-partial",