niceeval 0.17.1 → 0.19.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 (692) hide show
  1. package/INDEX.md +5 -2
  2. package/dist/adapter-usage.cjs.map +1 -1
  3. package/dist/adapter-usage.d.cts +1 -1
  4. package/dist/adapter-usage.d.mts +1 -1
  5. package/dist/adapter-usage.d.ts +1 -1
  6. package/dist/adapter.cjs +8 -3
  7. package/dist/adapter.cjs.map +1 -1
  8. package/dist/adapter.d.cts +26 -15
  9. package/dist/adapter.d.mts +26 -15
  10. package/dist/adapter.d.ts +26 -15
  11. package/dist/agents/{effect-runtime.cjs → agent-effects.cjs} +12 -18
  12. package/dist/agents/agent-effects.cjs.map +1 -0
  13. package/dist/agents/agent-effects.d.cts +23 -0
  14. package/dist/agents/agent-effects.d.mts +23 -0
  15. package/dist/agents/agent-effects.d.ts +23 -0
  16. package/dist/agents/agent-effects.js +16 -0
  17. package/dist/agents/agent-effects.js.map +1 -0
  18. package/dist/agents/ai-sdk.cjs +1 -1
  19. package/dist/agents/ai-sdk.cjs.map +1 -1
  20. package/dist/agents/bub.cjs +31 -18
  21. package/dist/agents/bub.cjs.map +1 -1
  22. package/dist/agents/bub.d.cts +9 -12
  23. package/dist/agents/bub.d.mts +9 -12
  24. package/dist/agents/bub.d.ts +9 -12
  25. package/dist/agents/claude-code-native.cjs +2 -2
  26. package/dist/agents/claude-code-native.cjs.map +1 -1
  27. package/dist/agents/claude-code.cjs +17 -11
  28. package/dist/agents/claude-code.cjs.map +1 -1
  29. package/dist/agents/claude-code.d.cts +11 -11
  30. package/dist/agents/claude-code.d.mts +11 -11
  31. package/dist/agents/claude-code.d.ts +11 -11
  32. package/dist/agents/codex-app-server.cjs +2 -2
  33. package/dist/agents/codex-app-server.cjs.map +1 -1
  34. package/dist/agents/codex.cjs +18 -12
  35. package/dist/agents/codex.cjs.map +1 -1
  36. package/dist/agents/codex.d.cts +12 -12
  37. package/dist/agents/codex.d.mts +12 -12
  38. package/dist/agents/codex.d.ts +12 -12
  39. package/dist/agents/deepseek-harness.cjs +2 -2
  40. package/dist/agents/deepseek-harness.cjs.map +1 -1
  41. package/dist/agents/hermes.cjs +3 -3
  42. package/dist/agents/hermes.cjs.map +1 -1
  43. package/dist/agents/index.cjs +3 -3
  44. package/dist/agents/index.cjs.map +1 -1
  45. package/dist/agents/index.d.cts +3 -3
  46. package/dist/agents/index.d.mts +3 -3
  47. package/dist/agents/index.d.ts +3 -3
  48. package/dist/agents/index.js +2 -2
  49. package/dist/agents/index.mjs +2 -2
  50. package/dist/agents/mcp.cjs.map +1 -1
  51. package/dist/agents/mcp.d.cts +2 -2
  52. package/dist/agents/mcp.d.mts +2 -2
  53. package/dist/agents/mcp.d.ts +2 -2
  54. package/dist/agents/omp.cjs +2 -2
  55. package/dist/agents/omp.cjs.map +1 -1
  56. package/dist/agents/openai-compat.cjs +2 -2
  57. package/dist/agents/openai-compat.cjs.map +1 -1
  58. package/dist/agents/openclaw.cjs +3 -3
  59. package/dist/agents/openclaw.cjs.map +1 -1
  60. package/dist/agents/opencode.cjs +16 -4
  61. package/dist/agents/opencode.cjs.map +1 -1
  62. package/dist/agents/plugin-extensions.cjs +71 -0
  63. package/dist/agents/plugin-extensions.cjs.map +1 -0
  64. package/dist/agents/plugin-extensions.d.cts +26 -0
  65. package/dist/agents/plugin-extensions.d.mts +26 -0
  66. package/dist/agents/plugin-extensions.d.ts +26 -0
  67. package/dist/agents/plugin-extensions.js +8 -0
  68. package/dist/agents/plugin-extensions.js.map +1 -0
  69. package/dist/agents/post-setup.cjs +14 -3
  70. package/dist/agents/post-setup.cjs.map +1 -1
  71. package/dist/agents/post-setup.d.cts +4 -2
  72. package/dist/agents/post-setup.d.mts +4 -2
  73. package/dist/agents/post-setup.d.ts +4 -2
  74. package/dist/agents/post-setup.js +8 -6
  75. package/dist/agents/sdk-streams.cjs +3 -3
  76. package/dist/agents/sdk-streams.cjs.map +1 -1
  77. package/dist/agents/{session-slot.cjs → session-key.cjs} +4 -4
  78. package/dist/agents/session-key.cjs.map +1 -0
  79. package/dist/agents/session-key.d.cts +12 -0
  80. package/dist/agents/session-key.d.mts +12 -0
  81. package/dist/agents/session-key.d.ts +12 -0
  82. package/dist/agents/session-key.js +6 -0
  83. package/dist/agents/session-key.js.map +1 -0
  84. package/dist/agents/shared.cjs +2 -2
  85. package/dist/agents/shared.cjs.map +1 -1
  86. package/dist/agents/shared.d.cts +4 -4
  87. package/dist/agents/shared.d.mts +4 -4
  88. package/dist/agents/shared.d.ts +4 -4
  89. package/dist/agents/skills.cjs.map +1 -1
  90. package/dist/agents/skills.d.cts +3 -3
  91. package/dist/agents/skills.d.mts +3 -3
  92. package/dist/agents/skills.d.ts +3 -3
  93. package/dist/agents/types.cjs.map +1 -1
  94. package/dist/agents/types.d.cts +55 -54
  95. package/dist/agents/types.d.mts +55 -54
  96. package/dist/agents/types.d.ts +55 -54
  97. package/dist/agents/ui-message-stream.cjs +4 -4
  98. package/dist/agents/ui-message-stream.cjs.map +1 -1
  99. package/dist/agents/unrecognized-events.cjs +32 -0
  100. package/dist/agents/unrecognized-events.cjs.map +1 -0
  101. package/dist/agents/unrecognized-events.d.cts +8 -0
  102. package/dist/agents/unrecognized-events.d.mts +8 -0
  103. package/dist/agents/unrecognized-events.d.ts +8 -0
  104. package/dist/agents/unrecognized-events.js +6 -0
  105. package/dist/agents/unrecognized-events.js.map +1 -0
  106. package/dist/assertions/api.cjs.map +1 -1
  107. package/dist/assertions/api.d.cts +3 -0
  108. package/dist/assertions/api.d.mts +3 -0
  109. package/dist/assertions/api.d.ts +3 -0
  110. package/dist/assertions/collection.cjs +1 -1
  111. package/dist/assertions/collection.cjs.map +1 -1
  112. package/dist/assertions/judge.cjs +1 -1
  113. package/dist/assertions/judge.cjs.map +1 -1
  114. package/dist/assertions/match.cjs +52 -21
  115. package/dist/assertions/match.cjs.map +1 -1
  116. package/dist/assertions/match.d.cts +16 -5
  117. package/dist/assertions/match.d.mts +16 -5
  118. package/dist/assertions/match.d.ts +16 -5
  119. package/dist/assertions/match.js +96 -94
  120. package/dist/assertions/measurements.cjs +61 -0
  121. package/dist/assertions/measurements.cjs.map +1 -0
  122. package/dist/assertions/measurements.d.cts +24 -0
  123. package/dist/assertions/measurements.d.mts +24 -0
  124. package/dist/assertions/measurements.d.ts +24 -0
  125. package/dist/assertions/measurements.js +8 -0
  126. package/dist/assertions/measurements.js.map +1 -0
  127. package/dist/assertions/numeric.cjs +2 -0
  128. package/dist/assertions/numeric.cjs.map +1 -1
  129. package/dist/assertions/numeric.d.cts +1 -1
  130. package/dist/assertions/numeric.d.mts +1 -1
  131. package/dist/assertions/numeric.d.ts +1 -1
  132. package/dist/assertions/quantity.cjs +42 -0
  133. package/dist/assertions/quantity.cjs.map +1 -0
  134. package/dist/assertions/quantity.d.cts +18 -0
  135. package/dist/assertions/quantity.d.mts +18 -0
  136. package/dist/assertions/quantity.d.ts +18 -0
  137. package/dist/assertions/quantity.js +22 -0
  138. package/dist/assertions/quantity.js.map +1 -0
  139. package/dist/assertions/record/attachment.cjs +2 -0
  140. package/dist/assertions/record/attachment.cjs.map +1 -1
  141. package/dist/assertions/record/codec.cjs +5 -1
  142. package/dist/assertions/record/codec.cjs.map +1 -1
  143. package/dist/assertions/record/model.cjs.map +1 -1
  144. package/dist/assertions/record/model.d.cts +3 -1
  145. package/dist/assertions/record/model.d.mts +3 -1
  146. package/dist/assertions/record/model.d.ts +3 -1
  147. package/dist/assertions/runtime.cjs +11 -6
  148. package/dist/assertions/runtime.cjs.map +1 -1
  149. package/dist/cli/program.cjs +3 -0
  150. package/dist/cli/program.cjs.map +1 -1
  151. package/dist/context/assert-first.cjs +6 -4
  152. package/dist/context/assert-first.cjs.map +1 -1
  153. package/dist/context/assert-first.d.cts +9 -3
  154. package/dist/context/assert-first.d.mts +9 -3
  155. package/dist/context/assert-first.d.ts +9 -3
  156. package/dist/context/notes.cjs +47 -0
  157. package/dist/context/notes.cjs.map +1 -0
  158. package/dist/context/notes.d.cts +10 -0
  159. package/dist/context/notes.d.mts +10 -0
  160. package/dist/context/notes.d.ts +10 -0
  161. package/dist/context/notes.js +6 -0
  162. package/dist/context/notes.js.map +1 -0
  163. package/dist/context/send-failures.cjs +1 -7
  164. package/dist/context/send-failures.cjs.map +1 -1
  165. package/dist/context/send-failures.d.cts +2 -3
  166. package/dist/context/send-failures.d.mts +2 -3
  167. package/dist/context/send-failures.d.ts +2 -3
  168. package/dist/context/send-retry.cjs +0 -1
  169. package/dist/context/send-retry.cjs.map +1 -1
  170. package/dist/context/send-retry.d.cts +1 -2
  171. package/dist/context/send-retry.d.mts +1 -2
  172. package/dist/context/send-retry.d.ts +1 -2
  173. package/dist/context/session.cjs +10 -17
  174. package/dist/context/session.cjs.map +1 -1
  175. package/dist/context/session.d.cts +4 -10
  176. package/dist/context/session.d.mts +4 -10
  177. package/dist/context/session.d.ts +4 -10
  178. package/dist/define.cjs +89 -64
  179. package/dist/define.cjs.map +1 -1
  180. package/dist/define.d.cts +3 -3
  181. package/dist/define.d.mts +3 -3
  182. package/dist/define.d.ts +3 -3
  183. package/dist/eval/cli/contribution.cjs +1 -1
  184. package/dist/eval/cli/contribution.cjs.map +1 -1
  185. package/dist/eval/host/index.cjs +1 -1
  186. package/dist/eval/host/index.cjs.map +1 -1
  187. package/dist/eval/record/evaluation.cjs +1 -1
  188. package/dist/eval/record/evaluation.cjs.map +1 -1
  189. package/dist/eval/record/membership-provenance.d.cts +3 -3
  190. package/dist/eval/record/membership-provenance.d.mts +3 -3
  191. package/dist/eval/record/membership-provenance.d.ts +3 -3
  192. package/dist/eval/record/score.cjs +2 -2
  193. package/dist/eval/record/score.cjs.map +1 -1
  194. package/dist/eval/record/sealed-assertion.cjs +1 -1
  195. package/dist/eval/record/sealed-assertion.cjs.map +1 -1
  196. package/dist/eval/record/verdict.cjs +2 -2
  197. package/dist/eval/record/verdict.cjs.map +1 -1
  198. package/dist/expect/index.cjs +13 -1
  199. package/dist/expect/index.cjs.map +1 -1
  200. package/dist/expect/index.d.cts +5 -1
  201. package/dist/expect/index.d.mts +5 -1
  202. package/dist/expect/index.d.ts +5 -1
  203. package/dist/expect/index.js +92 -72
  204. package/dist/expect/index.mjs +92 -72
  205. package/dist/experiment/host/cli/contribution.cjs +52 -39
  206. package/dist/experiment/host/cli/contribution.cjs.map +1 -1
  207. package/dist/experiment/host/cli/contribution.d.cts +18 -4
  208. package/dist/experiment/host/cli/contribution.d.mts +18 -4
  209. package/dist/experiment/host/cli/contribution.d.ts +18 -4
  210. package/dist/experiment/host/cli/contribution.js +2 -2
  211. package/dist/experiment/host/cli/debug-protocol.cjs +2 -2
  212. package/dist/experiment/host/cli/debug-protocol.cjs.map +1 -1
  213. package/dist/experiment/host/cli/debug-protocol.d.cts +2 -2
  214. package/dist/experiment/host/cli/debug-protocol.d.mts +2 -2
  215. package/dist/experiment/host/cli/debug-protocol.d.ts +2 -2
  216. package/dist/experiment/host/cli/output-protocol.cjs +1 -1
  217. package/dist/experiment/host/cli/output-protocol.cjs.map +1 -1
  218. package/dist/experiment/host/cli/output-protocol.d.cts +2 -2
  219. package/dist/experiment/host/cli/output-protocol.d.mts +2 -2
  220. package/dist/experiment/host/cli/output-protocol.d.ts +2 -2
  221. package/dist/experiment/host/current.cjs +2 -2
  222. package/dist/experiment/host/current.cjs.map +1 -1
  223. package/dist/experiment/host/index.cjs +1 -1
  224. package/dist/experiment/host/index.cjs.map +1 -1
  225. package/dist/experiment/host/operations.cjs +24 -23
  226. package/dist/experiment/host/operations.cjs.map +1 -1
  227. package/dist/experiment/host/runtime.cjs +11 -10
  228. package/dist/experiment/host/runtime.cjs.map +1 -1
  229. package/dist/experiment/host/runtime.d.cts +3 -3
  230. package/dist/experiment/host/runtime.d.mts +3 -3
  231. package/dist/experiment/host/runtime.d.ts +3 -3
  232. package/dist/experiment/host/teardown.cjs +4 -3
  233. package/dist/experiment/host/teardown.cjs.map +1 -1
  234. package/dist/experiment/host/teardown.d.cts +3 -3
  235. package/dist/experiment/host/teardown.d.mts +3 -3
  236. package/dist/experiment/host/teardown.d.ts +3 -3
  237. package/dist/experiment/host/types.cjs.map +1 -1
  238. package/dist/experiment/host/types.d.cts +19 -19
  239. package/dist/experiment/host/types.d.mts +19 -19
  240. package/dist/experiment/host/types.d.ts +19 -19
  241. package/dist/index.cjs +3 -19
  242. package/dist/index.cjs.map +1 -1
  243. package/dist/index.d.cts +4 -8
  244. package/dist/index.d.mts +4 -8
  245. package/dist/index.d.ts +4 -8
  246. package/dist/index.js +12 -34
  247. package/dist/index.mjs +12 -34
  248. package/dist/inspection/assertions.cjs +1 -1
  249. package/dist/inspection/assertions.cjs.map +1 -1
  250. package/dist/inspection/cli/contribution.cjs +8 -7
  251. package/dist/inspection/cli/contribution.cjs.map +1 -1
  252. package/dist/inspection/facts.cjs +4 -4
  253. package/dist/inspection/facts.cjs.map +1 -1
  254. package/dist/inspection/index.cjs +1 -5
  255. package/dist/inspection/index.cjs.map +1 -1
  256. package/dist/inspection/index.d.cts +1 -2
  257. package/dist/inspection/index.d.mts +1 -2
  258. package/dist/inspection/index.d.ts +1 -2
  259. package/dist/inspection/index.js +20 -26
  260. package/dist/inspection/lifecycle.cjs +7 -0
  261. package/dist/inspection/lifecycle.cjs.map +1 -0
  262. package/dist/inspection/lifecycle.d.cts +4 -0
  263. package/dist/inspection/lifecycle.d.mts +4 -0
  264. package/dist/inspection/lifecycle.d.ts +4 -0
  265. package/dist/inspection/lifecycle.js +6 -0
  266. package/dist/inspection/lifecycle.js.map +1 -0
  267. package/dist/inspection/notes.cjs +40 -0
  268. package/dist/inspection/notes.cjs.map +1 -0
  269. package/dist/inspection/notes.d.cts +12 -0
  270. package/dist/inspection/notes.d.mts +12 -0
  271. package/dist/inspection/notes.d.ts +12 -0
  272. package/dist/inspection/notes.js +8 -0
  273. package/dist/inspection/notes.js.map +1 -0
  274. package/dist/inspection/overview.cjs +12 -15
  275. package/dist/inspection/overview.cjs.map +1 -1
  276. package/dist/inspection/overview.d.cts +8 -6
  277. package/dist/inspection/overview.d.mts +8 -6
  278. package/dist/inspection/overview.d.ts +8 -6
  279. package/dist/inspection/planned-attempt.cjs +45 -0
  280. package/dist/inspection/planned-attempt.cjs.map +1 -0
  281. package/dist/inspection/planned-attempt.d.cts +109 -0
  282. package/dist/inspection/planned-attempt.d.mts +109 -0
  283. package/dist/inspection/planned-attempt.d.ts +109 -0
  284. package/dist/inspection/planned-attempt.js +24 -0
  285. package/dist/inspection/planned-attempt.js.map +1 -0
  286. package/dist/inspection/project-result.cjs +5 -5
  287. package/dist/inspection/project-result.cjs.map +1 -1
  288. package/dist/inspection/project-result.d.cts +58 -57
  289. package/dist/inspection/project-result.d.mts +58 -57
  290. package/dist/inspection/project-result.d.ts +58 -57
  291. package/dist/inspection/project-result.js +4 -4
  292. package/dist/inspection/project.cjs +3 -3
  293. package/dist/inspection/project.cjs.map +1 -1
  294. package/dist/inspection/protocol-values.cjs +1 -1
  295. package/dist/inspection/protocol-values.cjs.map +1 -1
  296. package/dist/inspection/protocol-values.d.cts +1 -1
  297. package/dist/inspection/protocol-values.d.mts +1 -1
  298. package/dist/inspection/protocol-values.d.ts +1 -1
  299. package/dist/inspection/protocol.cjs +8 -8
  300. package/dist/inspection/protocol.cjs.map +1 -1
  301. package/dist/inspection/protocol.d.cts +237 -219
  302. package/dist/inspection/protocol.d.mts +237 -219
  303. package/dist/inspection/protocol.d.ts +237 -219
  304. package/dist/inspection/public.cjs +1 -5
  305. package/dist/inspection/public.cjs.map +1 -1
  306. package/dist/inspection/public.d.cts +1 -2
  307. package/dist/inspection/public.d.mts +1 -2
  308. package/dist/inspection/public.d.ts +1 -2
  309. package/dist/inspection/public.js +14 -20
  310. package/dist/inspection/public.mjs +166 -129
  311. package/dist/inspection/query.cjs +1 -1
  312. package/dist/inspection/query.cjs.map +1 -1
  313. package/dist/inspection/results.cjs +61 -52
  314. package/dist/inspection/results.cjs.map +1 -1
  315. package/dist/inspection/results.d.cts +157 -140
  316. package/dist/inspection/results.d.mts +157 -140
  317. package/dist/inspection/results.d.ts +157 -140
  318. package/dist/inspection/select.cjs +33 -28
  319. package/dist/inspection/select.cjs.map +1 -1
  320. package/dist/inspection/source.cjs +1 -1
  321. package/dist/inspection/source.cjs.map +1 -1
  322. package/dist/inspection/sources.cjs +2 -2
  323. package/dist/inspection/sources.cjs.map +1 -1
  324. package/dist/inspection/trace.cjs +9 -8
  325. package/dist/inspection/trace.cjs.map +1 -1
  326. package/dist/inspection/trace.d.cts +4 -4
  327. package/dist/inspection/trace.d.mts +4 -4
  328. package/dist/inspection/trace.d.ts +4 -4
  329. package/dist/loaders/index.cjs +7 -279
  330. package/dist/loaders/index.cjs.map +1 -1
  331. package/dist/loaders/index.d.cts +2 -95
  332. package/dist/loaders/index.d.mts +2 -95
  333. package/dist/loaders/index.d.ts +2 -95
  334. package/dist/loaders/index.js +10 -12
  335. package/dist/loaders/index.mjs +10 -12
  336. package/dist/loaders/runtime.cjs +283 -0
  337. package/dist/loaders/runtime.cjs.map +1 -0
  338. package/dist/loaders/runtime.d.cts +95 -0
  339. package/dist/loaders/runtime.d.mts +95 -0
  340. package/dist/loaders/runtime.d.ts +95 -0
  341. package/dist/loaders/runtime.js +16 -0
  342. package/dist/loaders/runtime.js.map +1 -0
  343. package/dist/migrations/judge-provider.md +6 -6
  344. package/dist/{model-slots.cjs → model-roles.cjs} +26 -7
  345. package/dist/model-roles.cjs.map +1 -0
  346. package/dist/model-roles.d.cts +26 -0
  347. package/dist/model-roles.d.mts +26 -0
  348. package/dist/model-roles.d.ts +26 -0
  349. package/dist/model-roles.js +14 -0
  350. package/dist/model-roles.js.map +1 -0
  351. package/dist/o11y/adapter-usage-projection.cjs +9 -8
  352. package/dist/o11y/adapter-usage-projection.cjs.map +1 -1
  353. package/dist/o11y/adapter-usage-projection.d.cts +23 -15
  354. package/dist/o11y/adapter-usage-projection.d.mts +23 -15
  355. package/dist/o11y/adapter-usage-projection.d.ts +23 -15
  356. package/dist/o11y/cache-read.cjs +14 -14
  357. package/dist/o11y/cache-read.cjs.map +1 -1
  358. package/dist/o11y/cache-read.d.cts +5 -5
  359. package/dist/o11y/cache-read.d.mts +5 -5
  360. package/dist/o11y/cache-read.d.ts +5 -5
  361. package/dist/o11y/derive.cjs.map +1 -1
  362. package/dist/o11y/derive.d.cts +2 -2
  363. package/dist/o11y/derive.d.mts +2 -2
  364. package/dist/o11y/derive.d.ts +2 -2
  365. package/dist/o11y/eval-usage.cjs +9 -9
  366. package/dist/o11y/eval-usage.cjs.map +1 -1
  367. package/dist/o11y/eval-usage.d.cts +7 -7
  368. package/dist/o11y/eval-usage.d.mts +7 -7
  369. package/dist/o11y/eval-usage.d.ts +7 -7
  370. package/dist/o11y/parsers/bub.cjs +57 -81
  371. package/dist/o11y/parsers/bub.cjs.map +1 -1
  372. package/dist/o11y/parsers/index.cjs.map +1 -1
  373. package/dist/o11y/parsers/index.d.cts +2 -0
  374. package/dist/o11y/parsers/index.d.mts +2 -0
  375. package/dist/o11y/parsers/index.d.ts +2 -0
  376. package/dist/o11y/parsers/opencode.cjs +129 -217
  377. package/dist/o11y/parsers/opencode.cjs.map +1 -1
  378. package/dist/o11y/parsers/opencode.d.cts +2 -5
  379. package/dist/o11y/parsers/opencode.d.mts +2 -5
  380. package/dist/o11y/parsers/opencode.d.ts +2 -5
  381. package/dist/o11y/types.cjs.map +1 -1
  382. package/dist/o11y/types.d.cts +1 -1
  383. package/dist/o11y/types.d.mts +1 -1
  384. package/dist/o11y/types.d.ts +1 -1
  385. package/dist/plugin/contracts.cjs +170 -120
  386. package/dist/plugin/contracts.cjs.map +1 -1
  387. package/dist/plugin/contracts.d.cts +102 -90
  388. package/dist/plugin/contracts.d.mts +102 -90
  389. package/dist/plugin/contracts.d.ts +102 -90
  390. package/dist/plugin/contracts.js +16 -12
  391. package/dist/plugin/index.cjs.map +1 -1
  392. package/dist/plugin/index.d.cts +1 -1
  393. package/dist/plugin/index.d.mts +1 -1
  394. package/dist/plugin/index.d.ts +1 -1
  395. package/dist/plugin/link.cjs +69 -64
  396. package/dist/plugin/link.cjs.map +1 -1
  397. package/dist/plugin/link.d.cts +5 -3
  398. package/dist/plugin/link.d.mts +5 -3
  399. package/dist/plugin/link.d.ts +5 -3
  400. package/dist/plugin/link.js +12 -8
  401. package/dist/record/codec/seal-manifest.d.cts +3 -3
  402. package/dist/record/codec/seal-manifest.d.mts +3 -3
  403. package/dist/record/codec/seal-manifest.d.ts +3 -3
  404. package/dist/record/family/attempt-note/definition.cjs +12 -0
  405. package/dist/record/family/attempt-note/definition.cjs.map +1 -0
  406. package/dist/record/family/attempt-note/definition.d.cts +6 -0
  407. package/dist/record/family/attempt-note/definition.d.mts +6 -0
  408. package/dist/record/family/attempt-note/definition.d.ts +6 -0
  409. package/dist/record/family/attempt-note/definition.js +6 -0
  410. package/dist/record/family/attempt-note/definition.js.map +1 -0
  411. package/dist/record/family/attempt-note/persistence.cjs +10 -0
  412. package/dist/record/family/attempt-note/persistence.cjs.map +1 -0
  413. package/dist/record/family/attempt-note/persistence.d.cts +6 -0
  414. package/dist/record/family/attempt-note/persistence.d.mts +6 -0
  415. package/dist/record/family/attempt-note/persistence.d.ts +6 -0
  416. package/dist/record/family/attempt-note/persistence.js +6 -0
  417. package/dist/record/family/attempt-note/persistence.js.map +1 -0
  418. package/dist/record/family/attempt-note/schema.cjs +20 -0
  419. package/dist/record/family/attempt-note/schema.cjs.map +1 -0
  420. package/dist/record/family/attempt-note/schema.d.cts +21 -0
  421. package/dist/record/family/attempt-note/schema.d.mts +21 -0
  422. package/dist/record/family/attempt-note/schema.d.ts +21 -0
  423. package/dist/record/family/attempt-note/schema.js +10 -0
  424. package/dist/record/family/attempt-note/schema.js.map +1 -0
  425. package/dist/record/family/catalog.cjs +32 -29
  426. package/dist/record/family/catalog.cjs.map +1 -1
  427. package/dist/record/family/catalog.d.cts +7 -2
  428. package/dist/record/family/catalog.d.mts +7 -2
  429. package/dist/record/family/catalog.d.ts +7 -2
  430. package/dist/record/family/current.cjs +48 -45
  431. package/dist/record/family/current.cjs.map +1 -1
  432. package/dist/record/family/current.d.cts +15 -0
  433. package/dist/record/family/current.d.mts +15 -0
  434. package/dist/record/family/current.d.ts +15 -0
  435. package/dist/record/model/index.js +66 -64
  436. package/dist/record/model/run-context.cjs +9 -3
  437. package/dist/record/model/run-context.cjs.map +1 -1
  438. package/dist/record/model/run-context.d.cts +9 -2
  439. package/dist/record/model/run-context.d.mts +9 -2
  440. package/dist/record/model/run-context.d.ts +9 -2
  441. package/dist/record/model/run-context.js +8 -6
  442. package/dist/record/model/seal-manifest.d.cts +1 -1
  443. package/dist/record/model/seal-manifest.d.mts +1 -1
  444. package/dist/record/model/seal-manifest.d.ts +1 -1
  445. package/dist/run/cli/contribution.cjs +6 -32
  446. package/dist/run/cli/contribution.cjs.map +1 -1
  447. package/dist/run/host/runtime.cjs +1 -1
  448. package/dist/run/host/runtime.cjs.map +1 -1
  449. package/dist/run/storage/sqlite.cjs +7 -7
  450. package/dist/run/storage/sqlite.cjs.map +1 -1
  451. package/dist/runner/adapter-usage.cjs +5 -3
  452. package/dist/runner/adapter-usage.cjs.map +1 -1
  453. package/dist/runner/adapter-usage.d.cts +2 -2
  454. package/dist/runner/adapter-usage.d.mts +2 -2
  455. package/dist/runner/adapter-usage.d.ts +2 -2
  456. package/dist/runner/adoption.cjs +10 -12
  457. package/dist/runner/adoption.cjs.map +1 -1
  458. package/dist/runner/attempt-notes.cjs +8 -0
  459. package/dist/runner/attempt-notes.cjs.map +1 -0
  460. package/dist/runner/attempt-notes.d.cts +4 -0
  461. package/dist/runner/attempt-notes.d.mts +4 -0
  462. package/dist/runner/attempt-notes.d.ts +4 -0
  463. package/dist/runner/attempt-notes.js +8 -0
  464. package/dist/runner/attempt-notes.js.map +1 -0
  465. package/dist/runner/attempt.cjs +61 -73
  466. package/dist/runner/attempt.cjs.map +1 -1
  467. package/dist/runner/attempt.d.cts +3 -3
  468. package/dist/runner/attempt.d.mts +3 -3
  469. package/dist/runner/attempt.d.ts +3 -3
  470. package/dist/runner/command-plan.cjs +21 -26
  471. package/dist/runner/command-plan.cjs.map +1 -1
  472. package/dist/runner/command-plan.d.cts +4 -4
  473. package/dist/runner/command-plan.d.mts +4 -4
  474. package/dist/runner/command-plan.d.ts +4 -4
  475. package/dist/runner/command-plan.js +4 -4
  476. package/dist/runner/config-identity.cjs.map +1 -1
  477. package/dist/runner/config-identity.d.cts +2 -2
  478. package/dist/runner/config-identity.d.mts +2 -2
  479. package/dist/runner/config-identity.d.ts +2 -2
  480. package/dist/runner/discover.cjs +6 -6
  481. package/dist/runner/discover.cjs.map +1 -1
  482. package/dist/runner/eval-selection.cjs +15 -1
  483. package/dist/runner/eval-selection.cjs.map +1 -1
  484. package/dist/runner/eval-selection.d.cts +4 -0
  485. package/dist/runner/eval-selection.d.mts +4 -0
  486. package/dist/runner/eval-selection.d.ts +4 -0
  487. package/dist/runner/feedback/human.cjs +1 -1
  488. package/dist/runner/feedback/human.cjs.map +1 -1
  489. package/dist/runner/feedback/json.cjs +4 -2
  490. package/dist/runner/feedback/json.cjs.map +1 -1
  491. package/dist/runner/feedback/json.d.cts +1 -1
  492. package/dist/runner/feedback/json.d.mts +1 -1
  493. package/dist/runner/feedback/json.d.ts +1 -1
  494. package/dist/runner/feedback/sink.cjs +1 -1
  495. package/dist/runner/feedback/sink.cjs.map +1 -1
  496. package/dist/runner/feedback/sink.d.cts +1 -1
  497. package/dist/runner/feedback/sink.d.mts +1 -1
  498. package/dist/runner/feedback/sink.d.ts +1 -1
  499. package/dist/runner/fingerprint.cjs +1 -1
  500. package/dist/runner/fingerprint.cjs.map +1 -1
  501. package/dist/runner/lock.cjs +1 -3
  502. package/dist/runner/lock.cjs.map +1 -1
  503. package/dist/runner/lock.d.cts +0 -2
  504. package/dist/runner/lock.d.mts +0 -2
  505. package/dist/runner/lock.d.ts +0 -2
  506. package/dist/runner/lock.js +14 -16
  507. package/dist/runner/project-target.cjs.map +1 -1
  508. package/dist/runner/project-target.d.cts +2 -2
  509. package/dist/runner/project-target.d.mts +2 -2
  510. package/dist/runner/project-target.d.ts +2 -2
  511. package/dist/runner/record/attachments.cjs +2 -2
  512. package/dist/runner/record/attachments.cjs.map +1 -1
  513. package/dist/runner/record/planning.cjs +8 -2
  514. package/dist/runner/record/planning.cjs.map +1 -1
  515. package/dist/runner/record.cjs +2 -0
  516. package/dist/runner/record.cjs.map +1 -1
  517. package/dist/runner/report.cjs +3 -3
  518. package/dist/runner/report.cjs.map +1 -1
  519. package/dist/runner/report.d.cts +1 -1
  520. package/dist/runner/report.d.mts +1 -1
  521. package/dist/runner/report.d.ts +1 -1
  522. package/dist/runner/reuse-plan.cjs +2 -2
  523. package/dist/runner/reuse-plan.cjs.map +1 -1
  524. package/dist/runner/run.cjs +10 -45
  525. package/dist/runner/run.cjs.map +1 -1
  526. package/dist/runner/sandbox-pool.cjs +1 -2
  527. package/dist/runner/sandbox-pool.cjs.map +1 -1
  528. package/dist/runner/setup-prefix-preparation.cjs +1 -1
  529. package/dist/runner/setup-prefix-preparation.cjs.map +1 -1
  530. package/dist/runner/teardown-registry.cjs +2 -2
  531. package/dist/runner/teardown-registry.cjs.map +1 -1
  532. package/dist/runner/teardown-registry.d.cts +1 -1
  533. package/dist/runner/teardown-registry.d.mts +1 -1
  534. package/dist/runner/teardown-registry.d.ts +1 -1
  535. package/dist/runner/types.cjs +4 -4
  536. package/dist/runner/types.cjs.map +1 -1
  537. package/dist/runner/types.d.cts +64 -92
  538. package/dist/runner/types.d.mts +64 -92
  539. package/dist/runner/types.d.ts +64 -92
  540. package/dist/runner/types.js +2 -2
  541. package/dist/sandbox/action.cjs +1 -1
  542. package/dist/sandbox/action.cjs.map +1 -1
  543. package/dist/sandbox/cli/contribution.cjs +17 -14
  544. package/dist/sandbox/cli/contribution.cjs.map +1 -1
  545. package/dist/sandbox/cli/contribution.d.cts +1 -1
  546. package/dist/sandbox/cli/contribution.d.mts +1 -1
  547. package/dist/sandbox/cli/contribution.d.ts +1 -1
  548. package/dist/sandbox/commands.cjs +1 -1
  549. package/dist/sandbox/commands.cjs.map +1 -1
  550. package/dist/sandbox/commands.d.cts +1 -1
  551. package/dist/sandbox/commands.d.mts +1 -1
  552. package/dist/sandbox/commands.d.ts +1 -1
  553. package/dist/sandbox/compose.cjs +2 -2
  554. package/dist/sandbox/compose.cjs.map +1 -1
  555. package/dist/sandbox/docker-profile/registry.cjs +5 -10
  556. package/dist/sandbox/docker-profile/registry.cjs.map +1 -1
  557. package/dist/sandbox/docker-profile/registry.d.cts +0 -4
  558. package/dist/sandbox/docker-profile/registry.d.mts +0 -4
  559. package/dist/sandbox/docker-profile/registry.d.ts +0 -4
  560. package/dist/sandbox/docker-profile/registry.js +6 -14
  561. package/dist/sandbox/docker-profile/runtime.cjs +1 -1
  562. package/dist/sandbox/docker-profile/runtime.cjs.map +1 -1
  563. package/dist/sandbox/docker-profile/schema.cjs +12 -16
  564. package/dist/sandbox/docker-profile/schema.cjs.map +1 -1
  565. package/dist/sandbox/docker-profile/schema.d.cts +2 -6
  566. package/dist/sandbox/docker-profile/schema.d.mts +2 -6
  567. package/dist/sandbox/docker-profile/schema.d.ts +2 -6
  568. package/dist/sandbox/docker-profile/schema.js +24 -32
  569. package/dist/sandbox/incus.cjs +2 -2
  570. package/dist/sandbox/incus.cjs.map +1 -1
  571. package/dist/sandbox/index.cjs +4 -36
  572. package/dist/sandbox/index.cjs.map +1 -1
  573. package/dist/sandbox/index.d.cts +4 -8
  574. package/dist/sandbox/index.d.mts +4 -8
  575. package/dist/sandbox/index.d.ts +4 -8
  576. package/dist/sandbox/index.js +116 -174
  577. package/dist/sandbox/index.mjs +116 -174
  578. package/dist/sandbox/layer.cjs +3 -3
  579. package/dist/sandbox/layer.cjs.map +1 -1
  580. package/dist/sandbox/link.cjs +5 -0
  581. package/dist/sandbox/link.cjs.map +1 -1
  582. package/dist/sandbox/link.d.cts +3 -0
  583. package/dist/sandbox/link.d.mts +3 -0
  584. package/dist/sandbox/link.d.ts +3 -0
  585. package/dist/sandbox/runtime.cjs +9 -4
  586. package/dist/sandbox/runtime.cjs.map +1 -1
  587. package/dist/shared/failure-class.cjs +5 -5
  588. package/dist/shared/failure-class.cjs.map +1 -1
  589. package/dist/shared/failure-class.d.cts +4 -10
  590. package/dist/shared/failure-class.d.mts +4 -10
  591. package/dist/shared/failure-class.d.ts +4 -10
  592. package/dist/shared/types.cjs.map +1 -1
  593. package/dist/shared/types.d.cts +1 -1
  594. package/dist/shared/types.d.mts +1 -1
  595. package/dist/shared/types.d.ts +1 -1
  596. package/dist/show/contribution.cjs +17 -2
  597. package/dist/show/contribution.cjs.map +1 -1
  598. package/dist/show/contribution.d.cts +14 -0
  599. package/dist/show/contribution.d.mts +14 -0
  600. package/dist/show/contribution.d.ts +14 -0
  601. package/dist/show/model.cjs +8 -5
  602. package/dist/show/model.cjs.map +1 -1
  603. package/dist/show/model.d.cts +11 -8
  604. package/dist/show/model.d.mts +11 -8
  605. package/dist/show/model.d.ts +11 -8
  606. package/dist/show/render.cjs +34 -22
  607. package/dist/show/render.cjs.map +1 -1
  608. package/dist/sources/projector.cjs +1 -1
  609. package/dist/sources/projector.cjs.map +1 -1
  610. package/dist/types.cjs +1 -1
  611. package/dist/types.cjs.map +1 -1
  612. package/dist/types.d.cts +1 -1
  613. package/dist/types.d.mts +1 -1
  614. package/dist/types.d.ts +1 -1
  615. package/dist/types.js +2 -2
  616. package/dist/view/app-dist/.vite/manifest.json +2 -2
  617. package/dist/view/app-dist/assets/{index-B3ijZRph.js → index-CxrOUvHC.js} +17 -17
  618. package/dist/view/app-dist/assets/{quality-cost-scatter-B--DfJ9s.js → quality-cost-scatter-B6Aiss7x.js} +1 -1
  619. package/dist/view/app-dist/index.html +1 -1
  620. package/dist/view/cli/contribution.cjs +1 -1
  621. package/dist/view/cli/contribution.cjs.map +1 -1
  622. package/dist/view/function-runtime.mjs +318 -121
  623. package/dist/view/http-protocol.d.cts +1 -1
  624. package/dist/view/http-protocol.d.mts +1 -1
  625. package/dist/view/http-protocol.d.ts +1 -1
  626. package/dist/view/inspection-host.cjs +2 -2
  627. package/dist/view/inspection-host.cjs.map +1 -1
  628. package/dist/view/inspection-host.d.cts +349 -331
  629. package/dist/view/inspection-host.d.mts +349 -331
  630. package/dist/view/inspection-host.d.ts +349 -331
  631. package/docs-site/zh/examples/integrations/ai-sdk-v7.mdx +9 -9
  632. package/docs-site/zh/examples/integrations/claude-sdk.mdx +8 -8
  633. package/docs-site/zh/examples/integrations/codex-sdk.mdx +4 -4
  634. package/docs-site/zh/examples/integrations/langgraph.mdx +6 -6
  635. package/docs-site/zh/examples/integrations/pi-sdk.mdx +8 -8
  636. package/docs-site/zh/explanation/adapter.mdx +6 -6
  637. package/docs-site/zh/explanation/assert.mdx +7 -7
  638. package/docs-site/zh/explanation/drive.mdx +4 -4
  639. package/docs-site/zh/explanation/hitl.mdx +2 -2
  640. package/docs-site/zh/explanation/judge.mdx +3 -3
  641. package/docs-site/zh/index.mdx +18 -0
  642. package/docs-site/zh/introduction.mdx +4 -3
  643. package/docs-site/zh/reference/builtin-agents.mdx +46 -49
  644. package/docs-site/zh/reference/cli.mdx +16 -14
  645. package/docs-site/zh/reference/define-agent.mdx +19 -19
  646. package/docs-site/zh/reference/define-config.mdx +7 -15
  647. package/docs-site/zh/reference/define-eval.mdx +20 -14
  648. package/docs-site/zh/reference/define-experiment.mdx +18 -39
  649. package/docs-site/zh/reference/events.mdx +1 -1
  650. package/docs-site/zh/reference/expect.mdx +21 -0
  651. package/docs-site/zh/reference/official-adapters.mdx +12 -5
  652. package/docs-site/zh/troubleshooting/debugging.mdx +2 -2
  653. package/docs-site/zh/troubleshooting/recover-after-kill.mdx +1 -1
  654. package/docs-site/zh/tutorials/agent-onboarding.mdx +2 -2
  655. package/docs-site/zh/tutorials/authoring.mdx +4 -3
  656. package/docs-site/zh/tutorials/compare-runs.mdx +1 -1
  657. package/docs-site/zh/tutorials/concurrency.mdx +8 -8
  658. package/docs-site/zh/tutorials/configuration.mdx +5 -5
  659. package/docs-site/zh/tutorials/control-run-cost.mdx +49 -9
  660. package/docs-site/zh/tutorials/eval-groups.mdx +1 -1
  661. package/docs-site/zh/tutorials/evaluation-kinds.mdx +5 -5
  662. package/docs-site/zh/tutorials/experiment-services.mdx +32 -32
  663. package/docs-site/zh/tutorials/handle-execution-failures.mdx +2 -28
  664. package/docs-site/zh/tutorials/plugins.mdx +49 -143
  665. package/docs-site/zh/tutorials/sandbox-agent.mdx +1 -1
  666. package/docs-site/zh/tutorials/sandbox-reuse.mdx +7 -7
  667. package/docs-site/zh/tutorials/upgrade-0-18.mdx +64 -0
  668. package/docs-site/zh/tutorials/upgrade-0-19.mdx +121 -0
  669. package/docs-site/zh/tutorials/upgrade-0-20.mdx +12 -0
  670. package/docs-site/zh/tutorials/verify-judge.mdx +4 -3
  671. package/docs-site/zh/tutorials/viewing-results.mdx +2 -2
  672. package/docs-site/zh/tutorials/write-experiment.mdx +1 -1
  673. package/docs-site/zh/tutorials/write-send.mdx +13 -13
  674. package/package.json +1 -1
  675. package/dist/agents/effect-runtime.cjs.map +0 -1
  676. package/dist/agents/effect-runtime.d.cts +0 -29
  677. package/dist/agents/effect-runtime.d.mts +0 -29
  678. package/dist/agents/effect-runtime.d.ts +0 -29
  679. package/dist/agents/effect-runtime.js +0 -16
  680. package/dist/agents/effect-runtime.js.map +0 -1
  681. package/dist/agents/session-slot.cjs.map +0 -1
  682. package/dist/agents/session-slot.d.cts +0 -12
  683. package/dist/agents/session-slot.d.mts +0 -12
  684. package/dist/agents/session-slot.d.ts +0 -12
  685. package/dist/agents/session-slot.js +0 -6
  686. package/dist/agents/session-slot.js.map +0 -1
  687. package/dist/model-slots.cjs.map +0 -1
  688. package/dist/model-slots.d.cts +0 -19
  689. package/dist/model-slots.d.mts +0 -19
  690. package/dist/model-slots.d.ts +0 -19
  691. package/dist/model-slots.js +0 -8
  692. package/dist/model-slots.js.map +0 -1
@@ -1,6 +1,6 @@
1
1
  import type { ReadableAdapterUsageAttachment, AdapterUsageCall, AdapterCallPriceReceipt } from "../record/family/adapter-usage/schema.cjs";
2
2
  import type { NumericMaterial } from "../assertions/match.cjs";
3
- import type { ResolvedModelSlots } from "../model-slots.cjs";
3
+ import type { ResolvedModelRoles } from "../model-roles.cjs";
4
4
  export interface EffectiveCallCost {
5
5
  readonly amount: string;
6
6
  readonly currency: string;
@@ -10,7 +10,9 @@ export interface EffectiveCallCost {
10
10
  };
11
11
  readonly state: "complete" | "partial";
12
12
  }
13
- export type EffectiveUsageCall = AdapterUsageCall & {
13
+ export type EffectiveUsageCall = Omit<AdapterUsageCall, "modelSlot"> & {
14
+ readonly modelRole: string | null;
15
+ } & {
14
16
  readonly effectiveCost: EffectiveCallCost | null;
15
17
  };
16
18
  export declare function effectiveUsageCalls(usage: ReadableAdapterUsageAttachment): readonly EffectiveUsageCall[];
@@ -29,16 +31,22 @@ export declare function effectiveCostTotals(calls: readonly {
29
31
  }>[];
30
32
  totalCalls: number;
31
33
  }>;
32
- export declare function adapterTokenMaterial(usage: ReadableAdapterUsageAttachment, metric: "inputTokens" | "inputTotalTokens" | "outputTokens" | "cacheReadTokens" | "cacheWriteTokens" | "totalTokens"): NumericMaterial;
33
- export declare function adapterInspectionTokenTotal(usage: ReadableAdapterUsageAttachment, metric: "inputTotalTokens" | "outputTokens" | "totalTokens"): Readonly<{
34
+ export declare function adapterTokenMaterial(usage: {
35
+ readonly collection: ReadableAdapterUsageAttachment["collection"];
36
+ readonly calls: readonly Omit<AdapterUsageCall, "modelSlot">[];
37
+ }, metric: "inputTokens" | "inputTotalTokens" | "outputTokens" | "cacheReadTokens" | "cacheWriteTokens" | "totalTokens"): NumericMaterial;
38
+ export declare function adapterInspectionTokenTotal(usage: {
39
+ readonly collection: ReadableAdapterUsageAttachment["collection"];
40
+ readonly calls: readonly Omit<AdapterUsageCall, "modelSlot">[];
41
+ }, metric: "inputTotalTokens" | "outputTokens" | "totalTokens"): Readonly<{
34
42
  state: "partial" | "available" | "unavailable";
35
43
  value: number | null;
36
44
  observationCount: number;
37
45
  }>;
38
46
  /** Tuple order is stable across hosts, with missing identities before strings. */
39
- export declare function compareAdapterModelGroups(left: Pick<AdapterUsageCall, "modelSlot" | "provider" | "model">, right: Pick<AdapterUsageCall, "modelSlot" | "provider" | "model">): number;
47
+ export declare function compareAdapterModelGroups(left: Pick<EffectiveUsageCall, "modelRole" | "provider" | "model">, right: Pick<EffectiveUsageCall, "modelRole" | "provider" | "model">): number;
40
48
  /** Configuration counts and grouped statistics both consume the complete sealed ledger. */
41
- export declare function projectAdapterModelUsage(usage: ReadableAdapterUsageAttachment | null, models: ResolvedModelSlots | undefined, unavailable?: {
49
+ export declare function projectAdapterModelUsage(usage: ReadableAdapterUsageAttachment | null, models: ResolvedModelRoles | undefined, unavailable?: {
42
50
  readonly basis: "recorded-calls" | "reported-sends" | "unavailable";
43
51
  readonly reason: "source-invalid" | "usage-not-recorded" | "physical-call-identity-not-recorded";
44
52
  }, producerCompletenessKnown?: boolean): Readonly<{
@@ -59,7 +67,7 @@ export declare function projectAdapterModelUsage(usage: ReadableAdapterUsageAtta
59
67
  readonly collectionComplete: boolean;
60
68
  readonly reasons: readonly ("usage-not-recorded" | "source-invalid" | "adapter-usage-required" | "collection-incomplete" | "call-status-unknown" | "no-calls" | "cache-read-missing" | "input-total-missing" | "zero-input-total" | "unsafe-token-total")[];
61
69
  };
62
- readonly modelSlots: readonly {
70
+ readonly roles: readonly {
63
71
  readonly rate: {
64
72
  readonly state: "exact";
65
73
  readonly value: number;
@@ -74,7 +82,7 @@ export declare function projectAdapterModelUsage(usage: ReadableAdapterUsageAtta
74
82
  readonly unknownStatusCalls: number;
75
83
  readonly collectionComplete: boolean;
76
84
  readonly reasons: readonly ("usage-not-recorded" | "source-invalid" | "adapter-usage-required" | "collection-incomplete" | "call-status-unknown" | "no-calls" | "cache-read-missing" | "input-total-missing" | "zero-input-total" | "unsafe-token-total")[];
77
- readonly modelSlot: string | null;
85
+ readonly modelRole: string | null;
78
86
  }[];
79
87
  readonly models: readonly {
80
88
  readonly rate: {
@@ -91,7 +99,7 @@ export declare function projectAdapterModelUsage(usage: ReadableAdapterUsageAtta
91
99
  readonly unknownStatusCalls: number;
92
100
  readonly collectionComplete: boolean;
93
101
  readonly reasons: readonly ("usage-not-recorded" | "source-invalid" | "adapter-usage-required" | "collection-incomplete" | "call-status-unknown" | "no-calls" | "cache-read-missing" | "input-total-missing" | "zero-input-total" | "unsafe-token-total")[];
94
- readonly modelSlot: string | null;
102
+ readonly modelRole: string | null;
95
103
  readonly provider: string | null;
96
104
  readonly model: string | null;
97
105
  }[];
@@ -104,7 +112,7 @@ export declare function projectAdapterModelUsage(usage: ReadableAdapterUsageAtta
104
112
  recordedCalls: number | null;
105
113
  model: string | null;
106
114
  reasoningEffort: string | null;
107
- modelSlot: string;
115
+ modelRole: string;
108
116
  }>[];
109
117
  }>;
110
118
  modelGroups: Readonly<{
@@ -134,7 +142,7 @@ export declare function projectAdapterModelUsage(usage: ReadableAdapterUsageAtta
134
142
  readonly collectionComplete: boolean;
135
143
  readonly reasons: readonly ("usage-not-recorded" | "source-invalid" | "adapter-usage-required" | "collection-incomplete" | "call-status-unknown" | "no-calls" | "cache-read-missing" | "input-total-missing" | "zero-input-total" | "unsafe-token-total")[];
136
144
  };
137
- readonly modelSlots: readonly {
145
+ readonly roles: readonly {
138
146
  readonly rate: {
139
147
  readonly state: "exact";
140
148
  readonly value: number;
@@ -149,7 +157,7 @@ export declare function projectAdapterModelUsage(usage: ReadableAdapterUsageAtta
149
157
  readonly unknownStatusCalls: number;
150
158
  readonly collectionComplete: boolean;
151
159
  readonly reasons: readonly ("usage-not-recorded" | "source-invalid" | "adapter-usage-required" | "collection-incomplete" | "call-status-unknown" | "no-calls" | "cache-read-missing" | "input-total-missing" | "zero-input-total" | "unsafe-token-total")[];
152
- readonly modelSlot: string | null;
160
+ readonly modelRole: string | null;
153
161
  }[];
154
162
  readonly models: readonly {
155
163
  readonly rate: {
@@ -166,7 +174,7 @@ export declare function projectAdapterModelUsage(usage: ReadableAdapterUsageAtta
166
174
  readonly unknownStatusCalls: number;
167
175
  readonly collectionComplete: boolean;
168
176
  readonly reasons: readonly ("usage-not-recorded" | "source-invalid" | "adapter-usage-required" | "collection-incomplete" | "call-status-unknown" | "no-calls" | "cache-read-missing" | "input-total-missing" | "zero-input-total" | "unsafe-token-total")[];
169
- readonly modelSlot: string | null;
177
+ readonly modelRole: string | null;
170
178
  readonly provider: string | null;
171
179
  readonly model: string | null;
172
180
  }[];
@@ -179,14 +187,14 @@ export declare function projectAdapterModelUsage(usage: ReadableAdapterUsageAtta
179
187
  recordedCalls: number | null;
180
188
  model: string | null;
181
189
  reasoningEffort: string | null;
182
- modelSlot: string;
190
+ modelRole: string;
183
191
  }>[];
184
192
  }>;
185
193
  modelGroups: Readonly<{
186
194
  state: "available";
187
195
  basis: "recorded-calls";
188
196
  groups: readonly Readonly<{
189
- modelSlot: string | null;
197
+ modelRole: string | null;
190
198
  provider: string | null;
191
199
  model: string | null;
192
200
  recordedCalls: number;
@@ -1,6 +1,6 @@
1
1
  import type { ReadableAdapterUsageAttachment, AdapterUsageCall, AdapterCallPriceReceipt } from "../record/family/adapter-usage/schema.mjs";
2
2
  import type { NumericMaterial } from "../assertions/match.mjs";
3
- import type { ResolvedModelSlots } from "../model-slots.mjs";
3
+ import type { ResolvedModelRoles } from "../model-roles.mjs";
4
4
  export interface EffectiveCallCost {
5
5
  readonly amount: string;
6
6
  readonly currency: string;
@@ -10,7 +10,9 @@ export interface EffectiveCallCost {
10
10
  };
11
11
  readonly state: "complete" | "partial";
12
12
  }
13
- export type EffectiveUsageCall = AdapterUsageCall & {
13
+ export type EffectiveUsageCall = Omit<AdapterUsageCall, "modelSlot"> & {
14
+ readonly modelRole: string | null;
15
+ } & {
14
16
  readonly effectiveCost: EffectiveCallCost | null;
15
17
  };
16
18
  export declare function effectiveUsageCalls(usage: ReadableAdapterUsageAttachment): readonly EffectiveUsageCall[];
@@ -29,16 +31,22 @@ export declare function effectiveCostTotals(calls: readonly {
29
31
  }>[];
30
32
  totalCalls: number;
31
33
  }>;
32
- export declare function adapterTokenMaterial(usage: ReadableAdapterUsageAttachment, metric: "inputTokens" | "inputTotalTokens" | "outputTokens" | "cacheReadTokens" | "cacheWriteTokens" | "totalTokens"): NumericMaterial;
33
- export declare function adapterInspectionTokenTotal(usage: ReadableAdapterUsageAttachment, metric: "inputTotalTokens" | "outputTokens" | "totalTokens"): Readonly<{
34
+ export declare function adapterTokenMaterial(usage: {
35
+ readonly collection: ReadableAdapterUsageAttachment["collection"];
36
+ readonly calls: readonly Omit<AdapterUsageCall, "modelSlot">[];
37
+ }, metric: "inputTokens" | "inputTotalTokens" | "outputTokens" | "cacheReadTokens" | "cacheWriteTokens" | "totalTokens"): NumericMaterial;
38
+ export declare function adapterInspectionTokenTotal(usage: {
39
+ readonly collection: ReadableAdapterUsageAttachment["collection"];
40
+ readonly calls: readonly Omit<AdapterUsageCall, "modelSlot">[];
41
+ }, metric: "inputTotalTokens" | "outputTokens" | "totalTokens"): Readonly<{
34
42
  state: "partial" | "available" | "unavailable";
35
43
  value: number | null;
36
44
  observationCount: number;
37
45
  }>;
38
46
  /** Tuple order is stable across hosts, with missing identities before strings. */
39
- export declare function compareAdapterModelGroups(left: Pick<AdapterUsageCall, "modelSlot" | "provider" | "model">, right: Pick<AdapterUsageCall, "modelSlot" | "provider" | "model">): number;
47
+ export declare function compareAdapterModelGroups(left: Pick<EffectiveUsageCall, "modelRole" | "provider" | "model">, right: Pick<EffectiveUsageCall, "modelRole" | "provider" | "model">): number;
40
48
  /** Configuration counts and grouped statistics both consume the complete sealed ledger. */
41
- export declare function projectAdapterModelUsage(usage: ReadableAdapterUsageAttachment | null, models: ResolvedModelSlots | undefined, unavailable?: {
49
+ export declare function projectAdapterModelUsage(usage: ReadableAdapterUsageAttachment | null, models: ResolvedModelRoles | undefined, unavailable?: {
42
50
  readonly basis: "recorded-calls" | "reported-sends" | "unavailable";
43
51
  readonly reason: "source-invalid" | "usage-not-recorded" | "physical-call-identity-not-recorded";
44
52
  }, producerCompletenessKnown?: boolean): Readonly<{
@@ -59,7 +67,7 @@ export declare function projectAdapterModelUsage(usage: ReadableAdapterUsageAtta
59
67
  readonly collectionComplete: boolean;
60
68
  readonly reasons: readonly ("usage-not-recorded" | "source-invalid" | "adapter-usage-required" | "collection-incomplete" | "call-status-unknown" | "no-calls" | "cache-read-missing" | "input-total-missing" | "zero-input-total" | "unsafe-token-total")[];
61
69
  };
62
- readonly modelSlots: readonly {
70
+ readonly roles: readonly {
63
71
  readonly rate: {
64
72
  readonly state: "exact";
65
73
  readonly value: number;
@@ -74,7 +82,7 @@ export declare function projectAdapterModelUsage(usage: ReadableAdapterUsageAtta
74
82
  readonly unknownStatusCalls: number;
75
83
  readonly collectionComplete: boolean;
76
84
  readonly reasons: readonly ("usage-not-recorded" | "source-invalid" | "adapter-usage-required" | "collection-incomplete" | "call-status-unknown" | "no-calls" | "cache-read-missing" | "input-total-missing" | "zero-input-total" | "unsafe-token-total")[];
77
- readonly modelSlot: string | null;
85
+ readonly modelRole: string | null;
78
86
  }[];
79
87
  readonly models: readonly {
80
88
  readonly rate: {
@@ -91,7 +99,7 @@ export declare function projectAdapterModelUsage(usage: ReadableAdapterUsageAtta
91
99
  readonly unknownStatusCalls: number;
92
100
  readonly collectionComplete: boolean;
93
101
  readonly reasons: readonly ("usage-not-recorded" | "source-invalid" | "adapter-usage-required" | "collection-incomplete" | "call-status-unknown" | "no-calls" | "cache-read-missing" | "input-total-missing" | "zero-input-total" | "unsafe-token-total")[];
94
- readonly modelSlot: string | null;
102
+ readonly modelRole: string | null;
95
103
  readonly provider: string | null;
96
104
  readonly model: string | null;
97
105
  }[];
@@ -104,7 +112,7 @@ export declare function projectAdapterModelUsage(usage: ReadableAdapterUsageAtta
104
112
  recordedCalls: number | null;
105
113
  model: string | null;
106
114
  reasoningEffort: string | null;
107
- modelSlot: string;
115
+ modelRole: string;
108
116
  }>[];
109
117
  }>;
110
118
  modelGroups: Readonly<{
@@ -134,7 +142,7 @@ export declare function projectAdapterModelUsage(usage: ReadableAdapterUsageAtta
134
142
  readonly collectionComplete: boolean;
135
143
  readonly reasons: readonly ("usage-not-recorded" | "source-invalid" | "adapter-usage-required" | "collection-incomplete" | "call-status-unknown" | "no-calls" | "cache-read-missing" | "input-total-missing" | "zero-input-total" | "unsafe-token-total")[];
136
144
  };
137
- readonly modelSlots: readonly {
145
+ readonly roles: readonly {
138
146
  readonly rate: {
139
147
  readonly state: "exact";
140
148
  readonly value: number;
@@ -149,7 +157,7 @@ export declare function projectAdapterModelUsage(usage: ReadableAdapterUsageAtta
149
157
  readonly unknownStatusCalls: number;
150
158
  readonly collectionComplete: boolean;
151
159
  readonly reasons: readonly ("usage-not-recorded" | "source-invalid" | "adapter-usage-required" | "collection-incomplete" | "call-status-unknown" | "no-calls" | "cache-read-missing" | "input-total-missing" | "zero-input-total" | "unsafe-token-total")[];
152
- readonly modelSlot: string | null;
160
+ readonly modelRole: string | null;
153
161
  }[];
154
162
  readonly models: readonly {
155
163
  readonly rate: {
@@ -166,7 +174,7 @@ export declare function projectAdapterModelUsage(usage: ReadableAdapterUsageAtta
166
174
  readonly unknownStatusCalls: number;
167
175
  readonly collectionComplete: boolean;
168
176
  readonly reasons: readonly ("usage-not-recorded" | "source-invalid" | "adapter-usage-required" | "collection-incomplete" | "call-status-unknown" | "no-calls" | "cache-read-missing" | "input-total-missing" | "zero-input-total" | "unsafe-token-total")[];
169
- readonly modelSlot: string | null;
177
+ readonly modelRole: string | null;
170
178
  readonly provider: string | null;
171
179
  readonly model: string | null;
172
180
  }[];
@@ -179,14 +187,14 @@ export declare function projectAdapterModelUsage(usage: ReadableAdapterUsageAtta
179
187
  recordedCalls: number | null;
180
188
  model: string | null;
181
189
  reasoningEffort: string | null;
182
- modelSlot: string;
190
+ modelRole: string;
183
191
  }>[];
184
192
  }>;
185
193
  modelGroups: Readonly<{
186
194
  state: "available";
187
195
  basis: "recorded-calls";
188
196
  groups: readonly Readonly<{
189
- modelSlot: string | null;
197
+ modelRole: string | null;
190
198
  provider: string | null;
191
199
  model: string | null;
192
200
  recordedCalls: number;
@@ -1,6 +1,6 @@
1
1
  import type { ReadableAdapterUsageAttachment, AdapterUsageCall, AdapterCallPriceReceipt } from "../record/family/adapter-usage/schema.js";
2
2
  import type { NumericMaterial } from "../assertions/match.js";
3
- import type { ResolvedModelSlots } from "../model-slots.js";
3
+ import type { ResolvedModelRoles } from "../model-roles.js";
4
4
  export interface EffectiveCallCost {
5
5
  readonly amount: string;
6
6
  readonly currency: string;
@@ -10,7 +10,9 @@ export interface EffectiveCallCost {
10
10
  };
11
11
  readonly state: "complete" | "partial";
12
12
  }
13
- export type EffectiveUsageCall = AdapterUsageCall & {
13
+ export type EffectiveUsageCall = Omit<AdapterUsageCall, "modelSlot"> & {
14
+ readonly modelRole: string | null;
15
+ } & {
14
16
  readonly effectiveCost: EffectiveCallCost | null;
15
17
  };
16
18
  export declare function effectiveUsageCalls(usage: ReadableAdapterUsageAttachment): readonly EffectiveUsageCall[];
@@ -29,16 +31,22 @@ export declare function effectiveCostTotals(calls: readonly {
29
31
  }>[];
30
32
  totalCalls: number;
31
33
  }>;
32
- export declare function adapterTokenMaterial(usage: ReadableAdapterUsageAttachment, metric: "inputTokens" | "inputTotalTokens" | "outputTokens" | "cacheReadTokens" | "cacheWriteTokens" | "totalTokens"): NumericMaterial;
33
- export declare function adapterInspectionTokenTotal(usage: ReadableAdapterUsageAttachment, metric: "inputTotalTokens" | "outputTokens" | "totalTokens"): Readonly<{
34
+ export declare function adapterTokenMaterial(usage: {
35
+ readonly collection: ReadableAdapterUsageAttachment["collection"];
36
+ readonly calls: readonly Omit<AdapterUsageCall, "modelSlot">[];
37
+ }, metric: "inputTokens" | "inputTotalTokens" | "outputTokens" | "cacheReadTokens" | "cacheWriteTokens" | "totalTokens"): NumericMaterial;
38
+ export declare function adapterInspectionTokenTotal(usage: {
39
+ readonly collection: ReadableAdapterUsageAttachment["collection"];
40
+ readonly calls: readonly Omit<AdapterUsageCall, "modelSlot">[];
41
+ }, metric: "inputTotalTokens" | "outputTokens" | "totalTokens"): Readonly<{
34
42
  state: "partial" | "available" | "unavailable";
35
43
  value: number | null;
36
44
  observationCount: number;
37
45
  }>;
38
46
  /** Tuple order is stable across hosts, with missing identities before strings. */
39
- export declare function compareAdapterModelGroups(left: Pick<AdapterUsageCall, "modelSlot" | "provider" | "model">, right: Pick<AdapterUsageCall, "modelSlot" | "provider" | "model">): number;
47
+ export declare function compareAdapterModelGroups(left: Pick<EffectiveUsageCall, "modelRole" | "provider" | "model">, right: Pick<EffectiveUsageCall, "modelRole" | "provider" | "model">): number;
40
48
  /** Configuration counts and grouped statistics both consume the complete sealed ledger. */
41
- export declare function projectAdapterModelUsage(usage: ReadableAdapterUsageAttachment | null, models: ResolvedModelSlots | undefined, unavailable?: {
49
+ export declare function projectAdapterModelUsage(usage: ReadableAdapterUsageAttachment | null, models: ResolvedModelRoles | undefined, unavailable?: {
42
50
  readonly basis: "recorded-calls" | "reported-sends" | "unavailable";
43
51
  readonly reason: "source-invalid" | "usage-not-recorded" | "physical-call-identity-not-recorded";
44
52
  }, producerCompletenessKnown?: boolean): Readonly<{
@@ -59,7 +67,7 @@ export declare function projectAdapterModelUsage(usage: ReadableAdapterUsageAtta
59
67
  readonly collectionComplete: boolean;
60
68
  readonly reasons: readonly ("usage-not-recorded" | "source-invalid" | "adapter-usage-required" | "collection-incomplete" | "call-status-unknown" | "no-calls" | "cache-read-missing" | "input-total-missing" | "zero-input-total" | "unsafe-token-total")[];
61
69
  };
62
- readonly modelSlots: readonly {
70
+ readonly roles: readonly {
63
71
  readonly rate: {
64
72
  readonly state: "exact";
65
73
  readonly value: number;
@@ -74,7 +82,7 @@ export declare function projectAdapterModelUsage(usage: ReadableAdapterUsageAtta
74
82
  readonly unknownStatusCalls: number;
75
83
  readonly collectionComplete: boolean;
76
84
  readonly reasons: readonly ("usage-not-recorded" | "source-invalid" | "adapter-usage-required" | "collection-incomplete" | "call-status-unknown" | "no-calls" | "cache-read-missing" | "input-total-missing" | "zero-input-total" | "unsafe-token-total")[];
77
- readonly modelSlot: string | null;
85
+ readonly modelRole: string | null;
78
86
  }[];
79
87
  readonly models: readonly {
80
88
  readonly rate: {
@@ -91,7 +99,7 @@ export declare function projectAdapterModelUsage(usage: ReadableAdapterUsageAtta
91
99
  readonly unknownStatusCalls: number;
92
100
  readonly collectionComplete: boolean;
93
101
  readonly reasons: readonly ("usage-not-recorded" | "source-invalid" | "adapter-usage-required" | "collection-incomplete" | "call-status-unknown" | "no-calls" | "cache-read-missing" | "input-total-missing" | "zero-input-total" | "unsafe-token-total")[];
94
- readonly modelSlot: string | null;
102
+ readonly modelRole: string | null;
95
103
  readonly provider: string | null;
96
104
  readonly model: string | null;
97
105
  }[];
@@ -104,7 +112,7 @@ export declare function projectAdapterModelUsage(usage: ReadableAdapterUsageAtta
104
112
  recordedCalls: number | null;
105
113
  model: string | null;
106
114
  reasoningEffort: string | null;
107
- modelSlot: string;
115
+ modelRole: string;
108
116
  }>[];
109
117
  }>;
110
118
  modelGroups: Readonly<{
@@ -134,7 +142,7 @@ export declare function projectAdapterModelUsage(usage: ReadableAdapterUsageAtta
134
142
  readonly collectionComplete: boolean;
135
143
  readonly reasons: readonly ("usage-not-recorded" | "source-invalid" | "adapter-usage-required" | "collection-incomplete" | "call-status-unknown" | "no-calls" | "cache-read-missing" | "input-total-missing" | "zero-input-total" | "unsafe-token-total")[];
136
144
  };
137
- readonly modelSlots: readonly {
145
+ readonly roles: readonly {
138
146
  readonly rate: {
139
147
  readonly state: "exact";
140
148
  readonly value: number;
@@ -149,7 +157,7 @@ export declare function projectAdapterModelUsage(usage: ReadableAdapterUsageAtta
149
157
  readonly unknownStatusCalls: number;
150
158
  readonly collectionComplete: boolean;
151
159
  readonly reasons: readonly ("usage-not-recorded" | "source-invalid" | "adapter-usage-required" | "collection-incomplete" | "call-status-unknown" | "no-calls" | "cache-read-missing" | "input-total-missing" | "zero-input-total" | "unsafe-token-total")[];
152
- readonly modelSlot: string | null;
160
+ readonly modelRole: string | null;
153
161
  }[];
154
162
  readonly models: readonly {
155
163
  readonly rate: {
@@ -166,7 +174,7 @@ export declare function projectAdapterModelUsage(usage: ReadableAdapterUsageAtta
166
174
  readonly unknownStatusCalls: number;
167
175
  readonly collectionComplete: boolean;
168
176
  readonly reasons: readonly ("usage-not-recorded" | "source-invalid" | "adapter-usage-required" | "collection-incomplete" | "call-status-unknown" | "no-calls" | "cache-read-missing" | "input-total-missing" | "zero-input-total" | "unsafe-token-total")[];
169
- readonly modelSlot: string | null;
177
+ readonly modelRole: string | null;
170
178
  readonly provider: string | null;
171
179
  readonly model: string | null;
172
180
  }[];
@@ -179,14 +187,14 @@ export declare function projectAdapterModelUsage(usage: ReadableAdapterUsageAtta
179
187
  recordedCalls: number | null;
180
188
  model: string | null;
181
189
  reasoningEffort: string | null;
182
- modelSlot: string;
190
+ modelRole: string;
183
191
  }>[];
184
192
  }>;
185
193
  modelGroups: Readonly<{
186
194
  state: "available";
187
195
  basis: "recorded-calls";
188
196
  groups: readonly Readonly<{
189
- modelSlot: string | null;
197
+ modelRole: string | null;
190
198
  provider: string | null;
191
199
  model: string | null;
192
200
  recordedCalls: number;
@@ -36,9 +36,9 @@ const SummaryShape = effect_1.Schema.Struct(fields);
36
36
  const Summary = SummaryShape.check(effect_1.Schema.makeFilter(consistent));
37
37
  exports.CacheReadReportSchema = effect_1.Schema.Struct({
38
38
  total: Summary,
39
- modelSlots: effect_1.Schema.Array(effect_1.Schema.Struct({ modelSlot: effect_1.Schema.NullOr(effect_1.Schema.String), ...fields }).check(effect_1.Schema.makeFilter(consistent))),
40
- models: effect_1.Schema.Array(effect_1.Schema.Struct({ modelSlot: effect_1.Schema.NullOr(effect_1.Schema.String), provider: effect_1.Schema.NullOr(effect_1.Schema.String), model: effect_1.Schema.NullOr(effect_1.Schema.String), ...fields }).check(effect_1.Schema.makeFilter(consistent))),
41
- }).check(effect_1.Schema.makeFilter((value) => value.modelSlots.length <= 65 && value.models.length <= 4000));
39
+ roles: effect_1.Schema.Array(effect_1.Schema.Struct({ modelRole: effect_1.Schema.NullOr(effect_1.Schema.String), ...fields }).check(effect_1.Schema.makeFilter(consistent))),
40
+ models: effect_1.Schema.Array(effect_1.Schema.Struct({ modelRole: effect_1.Schema.NullOr(effect_1.Schema.String), provider: effect_1.Schema.NullOr(effect_1.Schema.String), model: effect_1.Schema.NullOr(effect_1.Schema.String), ...fields }).check(effect_1.Schema.makeFilter(consistent))),
41
+ }).check(effect_1.Schema.makeFilter((value) => value.roles.length <= 65 && value.models.length <= 4000));
42
42
  function summary(calls, collectionComplete, absent) {
43
43
  let numerator = 0;
44
44
  let denominator = 0;
@@ -82,18 +82,18 @@ function summary(calls, collectionComplete, absent) {
82
82
  }
83
83
  const compare = (a, b) => a === b ? 0 : a === null ? -1 : b === null ? 1 : a < b ? -1 : 1;
84
84
  /** A historical collection marked complete is not proof of an explicit producer seal. */
85
- function projectCacheRead(usage, slots, producerCompletenessKnown, absent = "usage-not-recorded") {
85
+ function projectCacheRead(usage, roles, producerCompletenessKnown, absent = "usage-not-recorded") {
86
86
  if (usage === null)
87
- return Object.freeze({ total: summary([], false, absent), modelSlots: Object.freeze([]), models: Object.freeze([]) });
87
+ return Object.freeze({ total: summary([], false, absent), roles: Object.freeze([]), models: Object.freeze([]) });
88
88
  const complete = producerCompletenessKnown && usage.collection.state === "complete";
89
- const bySlot = new Map(Object.keys(slots ?? {}).map((slot) => [slot, []]));
89
+ const byRole = new Map(Object.keys(roles ?? {}).map((role) => [role, []]));
90
90
  const byModel = new Map();
91
91
  for (const call of usage.calls) {
92
- const slot = bySlot.get(call.modelSlot);
93
- if (slot === undefined)
94
- bySlot.set(call.modelSlot, [call]);
92
+ const role = byRole.get(call.modelSlot);
93
+ if (role === undefined)
94
+ byRole.set(call.modelSlot, [call]);
95
95
  else
96
- slot.push(call);
96
+ role.push(call);
97
97
  const key = JSON.stringify([call.modelSlot, call.provider, call.model]);
98
98
  const model = byModel.get(key);
99
99
  if (model === undefined)
@@ -102,11 +102,11 @@ function projectCacheRead(usage, slots, producerCompletenessKnown, absent = "usa
102
102
  model.push(call);
103
103
  }
104
104
  const models = [...byModel.values()].map((calls) => {
105
- const { modelSlot, provider, model } = calls[0];
106
- return Object.freeze({ modelSlot, provider, model, ...summary(calls, complete) });
107
- }).sort((a, b) => compare(a.modelSlot, b.modelSlot) || compare(a.provider, b.provider) || compare(a.model, b.model));
105
+ const { modelSlot: modelRole, provider, model } = calls[0];
106
+ return Object.freeze({ modelRole, provider, model, ...summary(calls, complete) });
107
+ }).sort((a, b) => compare(a.modelRole, b.modelRole) || compare(a.provider, b.provider) || compare(a.model, b.model));
108
108
  return Object.freeze({ total: summary(usage.calls, complete),
109
- modelSlots: Object.freeze([...bySlot].sort(([a], [b]) => compare(a, b)).map(([modelSlot, calls]) => Object.freeze({ modelSlot, ...summary(calls, complete) }))),
109
+ roles: Object.freeze([...byRole].sort(([a], [b]) => compare(a, b)).map(([modelRole, calls]) => Object.freeze({ modelRole, ...summary(calls, complete) }))),
110
110
  models: Object.freeze(models),
111
111
  });
112
112
  }
@@ -1 +1 @@
1
- {"version":3,"file":"cache-read.js","sourceRoot":"","sources":["cache-read.ts"],"names":[],"mappings":";;;AAuFA,4CA2BC;AAlHD,mCAAgC;AAGhC,0DAA0E;AAC1E,MAAM,MAAM,GAAG,eAAM,CAAC,QAAQ,CAAC;IAC3B,oBAAoB,EAAE,gBAAgB,EAAE,wBAAwB,EAAE,uBAAuB;IACzF,qBAAqB,EAAE,UAAU,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,kBAAkB,EAAE,oBAAoB;CAC3H,CAAC,CAAC;AAEH,MAAM,IAAI,GAAG,eAAM,CAAC,KAAK,CAAC;IACtB,eAAM,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,eAAM,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,KAAK,EAAE,eAAM,CAAC,MAAM,CAAC,KA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C,SAAS,EAAE,CAAC,CAAC,SAAS,CAAC,IAAI,OAAO,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC,QAAQ,CAAC,IAAI,OAAO,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;IACrH,OAAO,MAAM,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,CAAC,KAAK,EAAE,QAAQ,CAAC;QACxD,UAAU,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,SAAS,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC,KAAK,EAAE,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC;QAC/J,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC;KAChC,CAAC,CAAC;AACP,CAAC","sourcesContent":["import { Schema } from \"effect\";\nimport type { ResolvedModelSlots } from \"../model-slots.ts\";\nimport type { AdapterUsageCall, ReadableAdapterUsageAttachment } from \"../record/family/adapter-usage/schema.ts\";\nimport { NonNegativeSafeIntegerSchema } from \"../record/family/common.ts\";\nconst Reason = Schema.Literals([\n \"usage-not-recorded\", \"source-invalid\", \"adapter-usage-required\", \"collection-incomplete\",\n \"call-status-unknown\", \"no-calls\", \"cache-read-missing\", \"input-total-missing\", \"zero-input-total\", \"unsafe-token-total\",\n]);\ntype Reason = typeof Reason.Type;\nconst Rate = Schema.Union([\n Schema.Struct({ state: Schema.Literal(\"exact\"), value: Schema.Number.check(Schema.makeFilter((value) => Number.isFinite(value) && value >= 0 && value <= 1)) }),\n Schema.Struct({ state: Schema.Literal(\"unavailable\"), reason: Reason }),\n]);\nconst fields = {\n rate: Rate,\n recordedCalls: NonNegativeSafeIntegerSchema,\n coveredCalls: NonNegativeSafeIntegerSchema,\n missingCacheReadCalls: NonNegativeSafeIntegerSchema,\n missingInputTotalCalls: NonNegativeSafeIntegerSchema,\n unknownStatusCalls: NonNegativeSafeIntegerSchema,\n collectionComplete: Schema.Boolean,\n reasons: Schema.Array(Reason),\n};\nconst consistent = (value: typeof SummaryShape.Type): boolean => {\n const count = value.recordedCalls;\n return count <= 4000 && value.coveredCalls <= count && value.unknownStatusCalls <= count &&\n value.missingCacheReadCalls <= count && value.missingInputTotalCalls <= count &&\n value.coveredCalls <= count - Math.max(value.missingCacheReadCalls, value.missingInputTotalCalls) &&\n value.coveredCalls >= count - value.missingCacheReadCalls - value.missingInputTotalCalls &&\n new Set(value.reasons).size === value.reasons.length &&\n (value.rate.state === \"exact\" ? value.reasons.length === 0 && value.collectionComplete && count > 0 &&\n value.coveredCalls === count && value.unknownStatusCalls === 0 : value.rate.reason === value.reasons[0]);\n};\nconst SummaryShape = Schema.Struct(fields);\nconst Summary = SummaryShape.check(Schema.makeFilter(consistent));\n/** Token-weighted cache reading, with explicit input coverage and collection completeness. */\nexport type CacheReadSummary = typeof Summary.Type;\nexport const CacheReadReportSchema = Schema.Struct({\n total: Summary,\n modelSlots: Schema.Array(Schema.Struct({ modelSlot: Schema.NullOr(Schema.String), ...fields }).check(Schema.makeFilter(consistent))),\n models: Schema.Array(Schema.Struct({ modelSlot: Schema.NullOr(Schema.String), provider: Schema.NullOr(Schema.String), model: Schema.NullOr(Schema.String), ...fields }).check(Schema.makeFilter(consistent))),\n}).check(Schema.makeFilter((value) => value.modelSlots.length <= 65 && value.models.length <= 4000));\n/** Complete per-Attempt report; unknown model identities remain null. */\nexport type CacheReadReport = typeof CacheReadReportSchema.Type;\nfunction summary(calls: readonly AdapterUsageCall[], collectionComplete: boolean, absent?: Reason): CacheReadSummary {\n let numerator = 0;\n let denominator = 0;\n let coveredCalls = 0;\n let missingCacheReadCalls = 0;\n let missingInputTotalCalls = 0;\n let unknownStatusCalls = 0;\n let unsafe = false;\n for (const call of calls) {\n const total = call.inputTotalTokens ?? (call.inputTokens !== null && call.cacheReadTokens !== null && call.cacheWriteTokens !== null\n ? call.inputTokens + call.cacheReadTokens + call.cacheWriteTokens : null);\n if (call.status === \"unknown\")\n unknownStatusCalls++;\n if (call.cacheReadTokens === null)\n missingCacheReadCalls++;\n else\n numerator += call.cacheReadTokens;\n if (total === null)\n missingInputTotalCalls++;\n else\n denominator += total;\n if (total !== null && call.cacheReadTokens !== null)\n coveredCalls++;\n if ((total !== null && !Number.isSafeInteger(total)) || !Number.isSafeInteger(numerator) || !Number.isSafeInteger(denominator))\n unsafe = true;\n }\n const reasons: Reason[] = absent === undefined ? [\n ...(!collectionComplete ? [\"collection-incomplete\" as const] : []),\n ...(unknownStatusCalls > 0 ? [\"call-status-unknown\" as const] : []),\n ...(calls.length === 0 ? [\"no-calls\" as const] : []),\n ...(missingCacheReadCalls > 0 ? [\"cache-read-missing\" as const] : []),\n ...(missingInputTotalCalls > 0 ? [\"input-total-missing\" as const] : []),\n ...(calls.length > 0 && missingInputTotalCalls === 0 && denominator === 0 ? [\"zero-input-total\" as const] : []),\n ...(unsafe ? [\"unsafe-token-total\" as const] : []),\n ] : [absent];\n const rate: CacheReadSummary[\"rate\"] = reasons.length === 0\n ? Object.freeze({ state: \"exact\", value: numerator / denominator })\n : Object.freeze({ state: \"unavailable\", reason: reasons[0]! });\n return Object.freeze({ rate, recordedCalls: calls.length, coveredCalls, missingCacheReadCalls, missingInputTotalCalls,\n unknownStatusCalls, collectionComplete, reasons: Object.freeze(reasons) });\n}\nconst compare = (a: string | null, b: string | null): number => a === b ? 0 : a === null ? -1 : b === null ? 1 : a < b ? -1 : 1;\n/** A historical collection marked complete is not proof of an explicit producer seal. */\nexport function projectCacheRead(usage: ReadableAdapterUsageAttachment | null, slots: ResolvedModelSlots | undefined, producerCompletenessKnown: boolean, absent: \"usage-not-recorded\" | \"source-invalid\" | \"adapter-usage-required\" = \"usage-not-recorded\"): CacheReadReport {\n if (usage === null)\n return Object.freeze({ total: summary([], false, absent), modelSlots: Object.freeze([]), models: Object.freeze([]) });\n const complete = producerCompletenessKnown && usage.collection.state === \"complete\";\n const bySlot = new Map<string | null, AdapterUsageCall[]>(Object.keys(slots ?? {}).map((slot) => [slot, []]));\n const byModel = new Map<string, AdapterUsageCall[]>();\n for (const call of usage.calls) {\n const slot = bySlot.get(call.modelSlot);\n if (slot === undefined)\n bySlot.set(call.modelSlot, [call]);\n else\n slot.push(call);\n const key = JSON.stringify([call.modelSlot, call.provider, call.model]);\n const model = byModel.get(key);\n if (model === undefined)\n byModel.set(key, [call]);\n else\n model.push(call);\n }\n const models = [...byModel.values()].map((calls) => {\n const { modelSlot, provider, model } = calls[0]!;\n return Object.freeze({ modelSlot, provider, model, ...summary(calls, complete) });\n }).sort((a, b) => compare(a.modelSlot, b.modelSlot) || compare(a.provider, b.provider) || compare(a.model, b.model));\n return Object.freeze({ total: summary(usage.calls, complete),\n modelSlots: Object.freeze([...bySlot].sort(([a], [b]) => compare(a, b)).map(([modelSlot, calls]) => Object.freeze({ modelSlot, ...summary(calls, complete) }))),\n models: Object.freeze(models),\n });\n}\n"]}
1
+ {"version":3,"file":"cache-read.js","sourceRoot":"","sources":["cache-read.ts"],"names":[],"mappings":";;;AAuFA,4CA2BC;AAlHD,mCAAgC;AAGhC,0DAA0E;AAC1E,MAAM,MAAM,GAAG,eAAM,CAAC,QAAQ,CAAC;IAC3B,oBAAoB,EAAE,gBAAgB,EAAE,wBAAwB,EAAE,uBAAuB;IACzF,qBAAqB,EAAE,UAAU,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,kBAAkB,EAAE,oBAAoB;CAC3H,CAAC,CAAC;AAEH,MAAM,IAAI,GAAG,eAAM,CAAC,KAAK,CAAC;IACtB,eAAM,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,eAAM,CAAC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,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,EAAE,CAAC,CAAC,SAAS,CAAC,IAAI,OAAO,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC,QAAQ,CAAC,IAAI,OAAO,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;IACrH,OAAO,MAAM,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,CAAC,KAAK,EAAE,QAAQ,CAAC;QACxD,KAAK,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,SAAS,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC,KAAK,EAAE,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC;QAC1J,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC;KAChC,CAAC,CAAC;AACP,CAAC","sourcesContent":["import { Schema } from \"effect\";\nimport type { ResolvedModelRoles } from \"../model-roles.ts\";\nimport type { AdapterUsageCall, ReadableAdapterUsageAttachment } from \"../record/family/adapter-usage/schema.ts\";\nimport { NonNegativeSafeIntegerSchema } from \"../record/family/common.ts\";\nconst Reason = Schema.Literals([\n \"usage-not-recorded\", \"source-invalid\", \"adapter-usage-required\", \"collection-incomplete\",\n \"call-status-unknown\", \"no-calls\", \"cache-read-missing\", \"input-total-missing\", \"zero-input-total\", \"unsafe-token-total\",\n]);\ntype Reason = typeof Reason.Type;\nconst Rate = Schema.Union([\n Schema.Struct({ state: Schema.Literal(\"exact\"), value: Schema.Number.check(Schema.makeFilter((value) => Number.isFinite(value) && value >= 0 && value <= 1)) }),\n Schema.Struct({ state: Schema.Literal(\"unavailable\"), reason: Reason }),\n]);\nconst fields = {\n rate: Rate,\n recordedCalls: NonNegativeSafeIntegerSchema,\n coveredCalls: NonNegativeSafeIntegerSchema,\n missingCacheReadCalls: NonNegativeSafeIntegerSchema,\n missingInputTotalCalls: NonNegativeSafeIntegerSchema,\n unknownStatusCalls: NonNegativeSafeIntegerSchema,\n collectionComplete: Schema.Boolean,\n reasons: Schema.Array(Reason),\n};\nconst consistent = (value: typeof SummaryShape.Type): boolean => {\n const count = value.recordedCalls;\n return count <= 4000 && value.coveredCalls <= count && value.unknownStatusCalls <= count &&\n value.missingCacheReadCalls <= count && value.missingInputTotalCalls <= count &&\n value.coveredCalls <= count - Math.max(value.missingCacheReadCalls, value.missingInputTotalCalls) &&\n value.coveredCalls >= count - value.missingCacheReadCalls - value.missingInputTotalCalls &&\n new Set(value.reasons).size === value.reasons.length &&\n (value.rate.state === \"exact\" ? value.reasons.length === 0 && value.collectionComplete && count > 0 &&\n value.coveredCalls === count && value.unknownStatusCalls === 0 : value.rate.reason === value.reasons[0]);\n};\nconst SummaryShape = Schema.Struct(fields);\nconst Summary = SummaryShape.check(Schema.makeFilter(consistent));\n/** Token-weighted cache reading, with explicit input coverage and collection completeness. */\nexport type CacheReadSummary = typeof Summary.Type;\nexport const CacheReadReportSchema = Schema.Struct({\n total: Summary,\n roles: Schema.Array(Schema.Struct({ modelRole: Schema.NullOr(Schema.String), ...fields }).check(Schema.makeFilter(consistent))),\n models: Schema.Array(Schema.Struct({ modelRole: Schema.NullOr(Schema.String), provider: Schema.NullOr(Schema.String), model: Schema.NullOr(Schema.String), ...fields }).check(Schema.makeFilter(consistent))),\n}).check(Schema.makeFilter((value) => value.roles.length <= 65 && value.models.length <= 4000));\n/** Complete per-Attempt report; unknown model identities remain null. */\nexport type CacheReadReport = typeof CacheReadReportSchema.Type;\nfunction summary(calls: readonly AdapterUsageCall[], collectionComplete: boolean, absent?: Reason): CacheReadSummary {\n let numerator = 0;\n let denominator = 0;\n let coveredCalls = 0;\n let missingCacheReadCalls = 0;\n let missingInputTotalCalls = 0;\n let unknownStatusCalls = 0;\n let unsafe = false;\n for (const call of calls) {\n const total = call.inputTotalTokens ?? (call.inputTokens !== null && call.cacheReadTokens !== null && call.cacheWriteTokens !== null\n ? call.inputTokens + call.cacheReadTokens + call.cacheWriteTokens : null);\n if (call.status === \"unknown\")\n unknownStatusCalls++;\n if (call.cacheReadTokens === null)\n missingCacheReadCalls++;\n else\n numerator += call.cacheReadTokens;\n if (total === null)\n missingInputTotalCalls++;\n else\n denominator += total;\n if (total !== null && call.cacheReadTokens !== null)\n coveredCalls++;\n if ((total !== null && !Number.isSafeInteger(total)) || !Number.isSafeInteger(numerator) || !Number.isSafeInteger(denominator))\n unsafe = true;\n }\n const reasons: Reason[] = absent === undefined ? [\n ...(!collectionComplete ? [\"collection-incomplete\" as const] : []),\n ...(unknownStatusCalls > 0 ? [\"call-status-unknown\" as const] : []),\n ...(calls.length === 0 ? [\"no-calls\" as const] : []),\n ...(missingCacheReadCalls > 0 ? [\"cache-read-missing\" as const] : []),\n ...(missingInputTotalCalls > 0 ? [\"input-total-missing\" as const] : []),\n ...(calls.length > 0 && missingInputTotalCalls === 0 && denominator === 0 ? [\"zero-input-total\" as const] : []),\n ...(unsafe ? [\"unsafe-token-total\" as const] : []),\n ] : [absent];\n const rate: CacheReadSummary[\"rate\"] = reasons.length === 0\n ? Object.freeze({ state: \"exact\", value: numerator / denominator })\n : Object.freeze({ state: \"unavailable\", reason: reasons[0]! });\n return Object.freeze({ rate, recordedCalls: calls.length, coveredCalls, missingCacheReadCalls, missingInputTotalCalls,\n unknownStatusCalls, collectionComplete, reasons: Object.freeze(reasons) });\n}\nconst compare = (a: string | null, b: string | null): number => a === b ? 0 : a === null ? -1 : b === null ? 1 : a < b ? -1 : 1;\n/** A historical collection marked complete is not proof of an explicit producer seal. */\nexport function projectCacheRead(usage: ReadableAdapterUsageAttachment | null, roles: ResolvedModelRoles | undefined, producerCompletenessKnown: boolean, absent: \"usage-not-recorded\" | \"source-invalid\" | \"adapter-usage-required\" = \"usage-not-recorded\"): CacheReadReport {\n if (usage === null)\n return Object.freeze({ total: summary([], false, absent), roles: Object.freeze([]), models: Object.freeze([]) });\n const complete = producerCompletenessKnown && usage.collection.state === \"complete\";\n const byRole = new Map<string | null, AdapterUsageCall[]>(Object.keys(roles ?? {}).map((role) => [role, []]));\n const byModel = new Map<string, AdapterUsageCall[]>();\n for (const call of usage.calls) {\n const role = byRole.get(call.modelSlot);\n if (role === undefined)\n byRole.set(call.modelSlot, [call]);\n else\n role.push(call);\n const key = JSON.stringify([call.modelSlot, call.provider, call.model]);\n const model = byModel.get(key);\n if (model === undefined)\n byModel.set(key, [call]);\n else\n model.push(call);\n }\n const models = [...byModel.values()].map((calls) => {\n const { modelSlot: modelRole, provider, model } = calls[0]!;\n return Object.freeze({ modelRole, provider, model, ...summary(calls, complete) });\n }).sort((a, b) => compare(a.modelRole, b.modelRole) || compare(a.provider, b.provider) || compare(a.model, b.model));\n return Object.freeze({ total: summary(usage.calls, complete),\n roles: Object.freeze([...byRole].sort(([a], [b]) => compare(a, b)).map(([modelRole, calls]) => Object.freeze({ modelRole, ...summary(calls, complete) }))),\n models: Object.freeze(models),\n });\n}\n"]}
@@ -1,5 +1,5 @@
1
1
  import { Schema } from "effect";
2
- import type { ResolvedModelSlots } from "../model-slots.cjs";
2
+ import type { ResolvedModelRoles } from "../model-roles.cjs";
3
3
  import type { ReadableAdapterUsageAttachment } from "../record/family/adapter-usage/schema.cjs";
4
4
  declare const Summary: Schema.Struct<{
5
5
  rate: Schema.Union<readonly [Schema.Struct<{
@@ -36,7 +36,7 @@ export declare const CacheReadReportSchema: Schema.Struct<{
36
36
  collectionComplete: Schema.Boolean;
37
37
  reasons: Schema.$Array<Schema.Literals<readonly ["usage-not-recorded", "source-invalid", "adapter-usage-required", "collection-incomplete", "call-status-unknown", "no-calls", "cache-read-missing", "input-total-missing", "zero-input-total", "unsafe-token-total"]>>;
38
38
  }>;
39
- readonly modelSlots: Schema.$Array<Schema.Struct<{
39
+ readonly roles: Schema.$Array<Schema.Struct<{
40
40
  readonly rate: Schema.Union<readonly [Schema.Struct<{
41
41
  readonly state: Schema.Literal<"exact">;
42
42
  readonly value: Schema.Number;
@@ -51,7 +51,7 @@ export declare const CacheReadReportSchema: Schema.Struct<{
51
51
  readonly unknownStatusCalls: Schema.Number;
52
52
  readonly collectionComplete: Schema.Boolean;
53
53
  readonly reasons: Schema.$Array<Schema.Literals<readonly ["usage-not-recorded", "source-invalid", "adapter-usage-required", "collection-incomplete", "call-status-unknown", "no-calls", "cache-read-missing", "input-total-missing", "zero-input-total", "unsafe-token-total"]>>;
54
- readonly modelSlot: Schema.NullOr<Schema.String>;
54
+ readonly modelRole: Schema.NullOr<Schema.String>;
55
55
  }>>;
56
56
  readonly models: Schema.$Array<Schema.Struct<{
57
57
  readonly rate: Schema.Union<readonly [Schema.Struct<{
@@ -68,7 +68,7 @@ export declare const CacheReadReportSchema: Schema.Struct<{
68
68
  readonly unknownStatusCalls: Schema.Number;
69
69
  readonly collectionComplete: Schema.Boolean;
70
70
  readonly reasons: Schema.$Array<Schema.Literals<readonly ["usage-not-recorded", "source-invalid", "adapter-usage-required", "collection-incomplete", "call-status-unknown", "no-calls", "cache-read-missing", "input-total-missing", "zero-input-total", "unsafe-token-total"]>>;
71
- readonly modelSlot: Schema.NullOr<Schema.String>;
71
+ readonly modelRole: Schema.NullOr<Schema.String>;
72
72
  readonly provider: Schema.NullOr<Schema.String>;
73
73
  readonly model: Schema.NullOr<Schema.String>;
74
74
  }>>;
@@ -76,5 +76,5 @@ export declare const CacheReadReportSchema: Schema.Struct<{
76
76
  /** Complete per-Attempt report; unknown model identities remain null. */
77
77
  export type CacheReadReport = typeof CacheReadReportSchema.Type;
78
78
  /** A historical collection marked complete is not proof of an explicit producer seal. */
79
- export declare function projectCacheRead(usage: ReadableAdapterUsageAttachment | null, slots: ResolvedModelSlots | undefined, producerCompletenessKnown: boolean, absent?: "usage-not-recorded" | "source-invalid" | "adapter-usage-required"): CacheReadReport;
79
+ export declare function projectCacheRead(usage: ReadableAdapterUsageAttachment | null, roles: ResolvedModelRoles | undefined, producerCompletenessKnown: boolean, absent?: "usage-not-recorded" | "source-invalid" | "adapter-usage-required"): CacheReadReport;
80
80
  export {};
@@ -1,5 +1,5 @@
1
1
  import { Schema } from "effect";
2
- import type { ResolvedModelSlots } from "../model-slots.mjs";
2
+ import type { ResolvedModelRoles } from "../model-roles.mjs";
3
3
  import type { ReadableAdapterUsageAttachment } from "../record/family/adapter-usage/schema.mjs";
4
4
  declare const Summary: Schema.Struct<{
5
5
  rate: Schema.Union<readonly [Schema.Struct<{
@@ -36,7 +36,7 @@ export declare const CacheReadReportSchema: Schema.Struct<{
36
36
  collectionComplete: Schema.Boolean;
37
37
  reasons: Schema.$Array<Schema.Literals<readonly ["usage-not-recorded", "source-invalid", "adapter-usage-required", "collection-incomplete", "call-status-unknown", "no-calls", "cache-read-missing", "input-total-missing", "zero-input-total", "unsafe-token-total"]>>;
38
38
  }>;
39
- readonly modelSlots: Schema.$Array<Schema.Struct<{
39
+ readonly roles: Schema.$Array<Schema.Struct<{
40
40
  readonly rate: Schema.Union<readonly [Schema.Struct<{
41
41
  readonly state: Schema.Literal<"exact">;
42
42
  readonly value: Schema.Number;
@@ -51,7 +51,7 @@ export declare const CacheReadReportSchema: Schema.Struct<{
51
51
  readonly unknownStatusCalls: Schema.Number;
52
52
  readonly collectionComplete: Schema.Boolean;
53
53
  readonly reasons: Schema.$Array<Schema.Literals<readonly ["usage-not-recorded", "source-invalid", "adapter-usage-required", "collection-incomplete", "call-status-unknown", "no-calls", "cache-read-missing", "input-total-missing", "zero-input-total", "unsafe-token-total"]>>;
54
- readonly modelSlot: Schema.NullOr<Schema.String>;
54
+ readonly modelRole: Schema.NullOr<Schema.String>;
55
55
  }>>;
56
56
  readonly models: Schema.$Array<Schema.Struct<{
57
57
  readonly rate: Schema.Union<readonly [Schema.Struct<{
@@ -68,7 +68,7 @@ export declare const CacheReadReportSchema: Schema.Struct<{
68
68
  readonly unknownStatusCalls: Schema.Number;
69
69
  readonly collectionComplete: Schema.Boolean;
70
70
  readonly reasons: Schema.$Array<Schema.Literals<readonly ["usage-not-recorded", "source-invalid", "adapter-usage-required", "collection-incomplete", "call-status-unknown", "no-calls", "cache-read-missing", "input-total-missing", "zero-input-total", "unsafe-token-total"]>>;
71
- readonly modelSlot: Schema.NullOr<Schema.String>;
71
+ readonly modelRole: Schema.NullOr<Schema.String>;
72
72
  readonly provider: Schema.NullOr<Schema.String>;
73
73
  readonly model: Schema.NullOr<Schema.String>;
74
74
  }>>;
@@ -76,5 +76,5 @@ export declare const CacheReadReportSchema: Schema.Struct<{
76
76
  /** Complete per-Attempt report; unknown model identities remain null. */
77
77
  export type CacheReadReport = typeof CacheReadReportSchema.Type;
78
78
  /** A historical collection marked complete is not proof of an explicit producer seal. */
79
- export declare function projectCacheRead(usage: ReadableAdapterUsageAttachment | null, slots: ResolvedModelSlots | undefined, producerCompletenessKnown: boolean, absent?: "usage-not-recorded" | "source-invalid" | "adapter-usage-required"): CacheReadReport;
79
+ export declare function projectCacheRead(usage: ReadableAdapterUsageAttachment | null, roles: ResolvedModelRoles | undefined, producerCompletenessKnown: boolean, absent?: "usage-not-recorded" | "source-invalid" | "adapter-usage-required"): CacheReadReport;
80
80
  export {};