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
package/INDEX.md CHANGED
@@ -57,14 +57,14 @@
57
57
  - `docs-site/zh/tutorials/docker-in-docker.mdx` — 让 Sandbox 使用 Docker:根据任务信任边界选择 Docker socket、raw privileged DinD 或受管 rootless DinD,并为 Agent 准备 Docker CLI 与 daemon。
58
58
  - `docs-site/zh/tutorials/eval-groups.mdx` — 用评估组让相关评估共用 Sandbox:几组评估各自需要一套很重的工具链时,用 defineEvalGroup 把它们分组:同组共用一台 Sandbox 依次执行,不同组照常并行。
59
59
  - `docs-site/zh/tutorials/evaluation-kinds.mdx` — 按完成度给分:通过制与计分制:任务只有做到和没做到两种结果时用 defineEval 读通过率;有部分进展时用 defineScoreEval 按完成的步骤累计分数。
60
- - `docs-site/zh/tutorials/experiment-services.mdx` — 启动实验共享服务:用 Experiment 的 setup / teardown 启停整个实验共用的隧道、mock server 或租约,把运行时地址交给 Agent 和 Sandbox,又不让它作废已有结果。
60
+ - `docs-site/zh/tutorials/experiment-services.mdx` — 启动实验共享服务:用 Experiment 的 before / after 启停整个实验共用的隧道、mock server 或租约,把运行时地址交给 Agent 和 Sandbox,又不让它作废已有结果。
61
61
  - `docs-site/zh/tutorials/fixtures.mdx` — 给 Coding Agent 准备任务:工作区、提示和验收:在评估用例里把一个真实项目放进 Sandbox,给 Coding Agent 发任务,再用文件内容、命令结果、diff 和 Judge 检查它做得对不对。
62
62
  - `docs-site/zh/tutorials/handle-execution-failures.mdx` — 凭据失效或服务挂掉时,及时止损:了解 NiceEval 会自动重试哪些失败;发现凭据失效、共享服务断开这类注定失败的故障时,停止剩下的 Attempt,修好后只补跑没完成的部分。
63
63
  - `docs-site/zh/tutorials/install-custom-sandbox-agent.mdx` — 为自定义 Sandbox Agent 安装 CLI:用 ensure 和 installer 检查、安装并复检自定义 coding-agent CLI 的精确版本。
64
64
  - `docs-site/zh/tutorials/niceeval-taste-application.mdx` — 自定义应用的评估判据:业务事实、领域 Match 与普通计算:被测应用提供客服记录、游戏状态这类业务事实时,让 Adapter 交付事实,用领域 Match 组合小条件,在正文里写普通计算,并保留未知状态。
65
65
  - `docs-site/zh/tutorials/niceeval-taste.mdx` — NiceEval Taste:写出一眼能看懂判据的评估:让同事只读评估用例正文,就能说出它测什么、什么算通过、证据为什么够。用已有事实、简单条件和普通算术写判据,少造新概念。
66
66
  - `docs-site/zh/tutorials/nixos-managed-dind.mdx` — 在 NixOS 上配置 Managed DinD:使用 NiceEval 的 NixOS module 部署 managed rootless Docker profile,并通过 doctor 验证宿主环境。
67
- - `docs-site/zh/tutorials/plugins.mdx` — 用 Plugin 复用一整套运行条件:同一套“先在宿主机起服务、再在 Sandbox 里准备环境”的条件要在多个 Experiment、评估组或评估用例里用时,用 definePlugin 写一次,到处挂载。
67
+ - `docs-site/zh/tutorials/plugins.mdx` — 用 Plugin 复用运行条件:把 Agent 扩展、Sandbox 步骤与宿主生命周期装进一个可复用的实验条件。
68
68
  - `docs-site/zh/tutorials/prebuilt-sandbox.mdx` — 预制 Sandbox 环境:让每次评估更快开始:把系统包、Agent CLI 和大缓存做进 Docker 镜像、Vercel 快照或 E2B template,从官方基线派生;运行时缓存用 checkpoint 在 Attempt 之间延续。
69
69
  - `docs-site/zh/tutorials/quickstart.mdx` — 快速开始:跑通第一条评估用例:安装 NiceEval,写一个 Adapter、一个 Experiment 和一条评估用例,十分钟左右对你自己的应用跑通第一条评估,并在终端和浏览器里看到结果。
70
70
  - `docs-site/zh/tutorials/reporters.mdx` — 把运行结果上报给 Braintrust 等外部系统:团队已经在用 Braintrust 或自己的看板时,用 Reporter 在运行过程中把结果发过去;CI 平台用 JUnit;后续脚本用 receipt 里的 Run ID 读取结果。
@@ -73,6 +73,9 @@
73
73
  - `docs-site/zh/tutorials/sandbox-providers.mdx` — 选择并配置 Sandbox:Docker、Vercel 或 E2B:给 Coding Agent 选一个隔离运行环境:本地 Docker、Vercel 或 E2B。按顺序准备环境,并用预制镜像和缓存让每次评估更快开始。
74
74
  - `docs-site/zh/tutorials/sandbox-reuse.mdx` — 在一批评估中复用 Sandbox:每条 Attempt 都新建 Sandbox 太慢时,用 sandboxReuse 让一批 Attempt 依次共用同一个 Sandbox。说明它省了什么、留下了什么,以及准备代码要怎么写才能安全重放。
75
75
  - `docs-site/zh/tutorials/select-and-preview.mdx` — 运行前确认跑哪些、跑几次:列出有哪些 Experiment,用 ID 前缀和 tag 缩小范围,再用 --dry 看清这次会跑哪些评估用例、多少次,确认无误再花钱。
76
+ - `docs-site/zh/tutorials/upgrade-0-18.mdx` — 升级到 0.18:共享模型用途、原生数值材料与公开入口调整
77
+ - `docs-site/zh/tutorials/upgrade-0-19.mdx` — 升级到 0.19:替换模型用途名称,迁移撤销的作者配置。
78
+ - `docs-site/zh/tutorials/upgrade-0-20.mdx` — 升级到 0.20:更新配置与固定版本协议。
76
79
  - `docs-site/zh/tutorials/verify-judge.mdx` — 配置 Judge,并确认它真的能打分:给裁判模型 Judge 选好 Provider、模型和 API Key,再用一条最小评估跑一次真实判分,确认配置无误后再大批使用。
77
80
  - `docs-site/zh/tutorials/viewing-results.mdx` — 查看运行结果:从总览找到失败原因:跑完评估后,用 niceeval show 在终端从总览逐层找到失败的那次运行,查看对话、耗时、用量和文件改动;在浏览器用 view 翻看;脚本和 CI 用 query 读 JSON。
78
81
  - `docs-site/zh/tutorials/write-experiment.mdx` — 编写实验:比较模型、prompt 和 Agent:用 defineExperiment 固定被测 Agent、模型、flags 和运行次数。同一批评估用例写两份只差一个变量的 Experiment,就能比较两个模型或两版 prompt。
@@ -1 +1 @@
1
- {"version":3,"file":"adapter-usage.js","sourceRoot":"","sources":["adapter-usage.ts"],"names":[],"mappings":"","sourcesContent":["/** Producer declaration after all obtainable final request snapshots have been recorded. */\nexport type AdapterUsageSeal = {\n readonly state: \"complete\";\n} | {\n readonly state: \"partial\";\n readonly reason: string;\n};\n/** Final observation of one physical external request, scoped to an Adapter Attempt. */\nexport interface AdapterUsageInput {\n readonly callId: string;\n readonly retryOf?: string;\n /** Frozen application model purpose; omission records an unknown purpose. */\n readonly modelSlot?: string | null;\n /** Upstream-proven serving provider. Transport and protocol identities belong in route. */\n readonly provider: string | null;\n readonly model: string | null;\n readonly route?: {\n readonly transportProvider: string | null;\n /** Stable, non-secret endpoint identity. Never include URLs, account identifiers, or credentials. */\n readonly endpointId: string | null;\n };\n readonly status: \"succeeded\" | \"failed\" | \"cancelled\" | \"unknown\";\n /** Input tokens excluding the cache read and cache write buckets. */\n readonly inputTokens: number | null;\n /** Independently observed input total including cache buckets; never added to those buckets. */\n readonly inputTotalTokens?: number | null;\n readonly outputTokens: number | null;\n readonly cacheReadTokens?: number | null;\n readonly cacheWriteTokens?: number | null;\n /** One provider-reported effective cost. A reported zero remains preferred to estimates. */\n readonly cost?: {\n readonly amount: string;\n readonly currency: string;\n readonly source: {\n readonly kind: \"reported\";\n readonly id: string;\n };\n };\n}\n"]}
1
+ {"version":3,"file":"adapter-usage.js","sourceRoot":"","sources":["adapter-usage.ts"],"names":[],"mappings":"","sourcesContent":["/** Producer declaration after all obtainable final request snapshots have been recorded. */\nexport type AdapterUsageSeal = {\n readonly state: \"complete\";\n} | {\n readonly state: \"partial\";\n readonly reason: string;\n};\n/** Final observation of one physical external request, scoped to an Adapter Attempt. */\nexport interface AdapterUsageInput {\n readonly callId: string;\n readonly retryOf?: string;\n /** Frozen application model purpose; omission records an unknown purpose. */\n readonly modelRole?: string | null;\n /** Upstream-proven serving provider. Transport and protocol identities belong in route. */\n readonly provider: string | null;\n readonly model: string | null;\n readonly route?: {\n readonly transportProvider: string | null;\n /** Stable, non-secret endpoint identity. Never include URLs, account identifiers, or credentials. */\n readonly endpointId: string | null;\n };\n readonly status: \"succeeded\" | \"failed\" | \"cancelled\" | \"unknown\";\n /** Input tokens excluding the cache read and cache write buckets. */\n readonly inputTokens: number | null;\n /** Independently observed input total including cache buckets; never added to those buckets. */\n readonly inputTotalTokens?: number | null;\n readonly outputTokens: number | null;\n readonly cacheReadTokens?: number | null;\n readonly cacheWriteTokens?: number | null;\n /** One provider-reported effective cost. A reported zero remains preferred to estimates. */\n readonly cost?: {\n readonly amount: string;\n readonly currency: string;\n readonly source: {\n readonly kind: \"reported\";\n readonly id: string;\n };\n };\n}\n"]}
@@ -10,7 +10,7 @@ export interface AdapterUsageInput {
10
10
  readonly callId: string;
11
11
  readonly retryOf?: string;
12
12
  /** Frozen application model purpose; omission records an unknown purpose. */
13
- readonly modelSlot?: string | null;
13
+ readonly modelRole?: string | null;
14
14
  /** Upstream-proven serving provider. Transport and protocol identities belong in route. */
15
15
  readonly provider: string | null;
16
16
  readonly model: string | null;
@@ -10,7 +10,7 @@ export interface AdapterUsageInput {
10
10
  readonly callId: string;
11
11
  readonly retryOf?: string;
12
12
  /** Frozen application model purpose; omission records an unknown purpose. */
13
- readonly modelSlot?: string | null;
13
+ readonly modelRole?: string | null;
14
14
  /** Upstream-proven serving provider. Transport and protocol identities belong in route. */
15
15
  readonly provider: string | null;
16
16
  readonly model: string | null;
@@ -10,7 +10,7 @@ export interface AdapterUsageInput {
10
10
  readonly callId: string;
11
11
  readonly retryOf?: string;
12
12
  /** Frozen application model purpose; omission records an unknown purpose. */
13
- readonly modelSlot?: string | null;
13
+ readonly modelRole?: string | null;
14
14
  /** Upstream-proven serving provider. Transport and protocol identities belong in route. */
15
15
  readonly provider: string | null;
16
16
  readonly model: string | null;
package/dist/adapter.cjs CHANGED
@@ -6,6 +6,7 @@ exports.adapterIdentity = adapterIdentity;
6
6
  exports.adapterAcceptsEval = adapterAcceptsEval;
7
7
  exports.adapterContractRequiredByEval = adapterContractRequiredByEval;
8
8
  exports.bindAdapterEvalContext = bindAdapterEvalContext;
9
+ const model_roles_ts_1 = require("./model-roles.cjs");
9
10
  const adapter_cleanup_ts_1 = require("./shared/adapter-cleanup.cjs");
10
11
  const runtime_ts_1 = require("./assertions/runtime.cjs");
11
12
  const adapter_flags_ts_1 = require("./adapter-flags.cjs");
@@ -28,6 +29,7 @@ const RESERVED_ADAPTER_CONTEXT_KEYS = [
28
29
  "maxCost",
29
30
  "score",
30
31
  "group",
32
+ "note",
31
33
  "skip",
32
34
  "signal",
33
35
  "model",
@@ -79,12 +81,14 @@ function boundEvalFactories(token) {
79
81
  assertAdapterEvalInput(input, "defineEval");
80
82
  return (0, define_ts_1.defineEvalForContext)("pass", input, {
81
83
  [EVAL_ADAPTER_CONTRACT_TOKEN]: token,
84
+ requiredModelRoles: (0, model_roles_ts_1.normalizeModelRequirements)(input.requires),
82
85
  });
83
86
  },
84
87
  defineScoreEval(input) {
85
88
  assertAdapterEvalInput(input, "defineScoreEval");
86
89
  return (0, define_ts_1.defineEvalForContext)("score", input, {
87
90
  [EVAL_ADAPTER_CONTRACT_TOKEN]: token,
91
+ requiredModelRoles: (0, model_roles_ts_1.normalizeModelRequirements)(input.requires),
88
92
  });
89
93
  },
90
94
  };
@@ -113,6 +117,7 @@ function implementAdapter(token, input, factory) {
113
117
  };
114
118
  return Object.freeze({
115
119
  kind: "custom",
120
+ requiredModelRoles: (0, model_roles_ts_1.normalizeModelRequirements)(input.requires),
116
121
  parseFlags: token.parseFlags,
117
122
  name: input.name,
118
123
  contract: token.name,
@@ -123,7 +128,7 @@ function implementAdapter(token, input, factory) {
123
128
  ...boundEvalFactories(token),
124
129
  });
125
130
  }
126
- // @concord-code ne-adapter-define-adapter
131
+ // @concord-code
127
132
  // @concord-implements docs/feature/adapters/README.md
128
133
  // @concord-implements docs/feature/adapters/library/writing-an-adapter.md
129
134
  function defineAdapter(input) {
@@ -136,7 +141,7 @@ function defineAdapter(input) {
136
141
  return implementAdapter(contractToken(input.name, assertions, input.parseFlags), input, "defineAdapter");
137
142
  }
138
143
  /** Defines a reusable contract whose implementations and Evals share one runtime-only token. */
139
- // @concord-code ne-adapter-define-contract
144
+ // @concord-code
140
145
  // @concord-implements docs/feature/adapters/README.md
141
146
  // @concord-implements docs/feature/adapters/architecture/agent-contract.md
142
147
  function defineAdapterContract(input) {
@@ -349,7 +354,7 @@ function bindAdapterAssertions(core, context, factory, assertAuthorOpen) {
349
354
  return Object.freeze({ app, assertions: Object.freeze(assertions) });
350
355
  }
351
356
  /** @internal Builds the frozen single-t facade after create settles. */
352
- // @concord-code ne-adapter-bind-eval-context
357
+ // @concord-code
353
358
  // @concord-implements docs/feature/adapters/architecture/agent-contract.md
354
359
  function bindAdapterEvalContext(core, context, adapter, assertAuthorOpen) {
355
360
  assertPlainAdapterContext(context);
@@ -1 +1 @@
1
- {"version":3,"file":"adapter.js","sourceRoot":"","sources":["adapter.ts"],"names":[],"mappings":";;AAmWA,sCAgBC;AAKD,sDAKC;AAuBD,0CAaC;AAED,gDASC;AAED,sEAMC;AAmKD,wDAoBC;AA1mBD,oEAA6E;AAG7E,wDAA+D;AAI/D,yDAA2L;AAG3L,2CAAmD;AAOnD,MAAM,sBAAsB,GAAkB,MAAM,CAAC,+BAA+B,CAAC,CAAC;AACtF,MAAM,2BAA2B,GAAkB,MAAM,CAAC,mCAAmC,CAAC,CAAC;AAsB/F,gFAAgF;AAChF,MAAM,6BAA6B,GAAG;IAClC,gBAAgB;IAChB,OAAO;IACP,OAAO;IACP,YAAY;IACZ,cAAc;IACd,sBAAsB;IACtB,oBAAoB;IACpB,SAAS;IACT,OAAO;IACP,WAAW;IACX,WAAW;IACX,SAAS;IACT,OAAO;IACP,OAAO;IACP,MAAM;IACN,QAAQ;IACR,OAAO;IACP,iBAAiB;IACjB,OAAO;IACP,UAAU;IACV,YAAY;IACZ,KAAK;IACL,MAAM;IACN,QAAQ;IACR,aAAa;IACb,kBAAkB;IAClB,kBAAkB;IAClB,gBAAgB;IAChB,kBAAkB;IAClB,kBAAkB;IAClB,eAAe;IACf,sBAAsB;IACtB,UAAU;IACV,SAAS;IACT,WAAW;IACX,gBAAgB;CACV,CAAC;AA4KX,SAAS,oBAAoB,CAAC,KAAc,EAAE,KAAa,EAAE,OAAe;IACxE,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC;QACnD,MAAM,IAAI,SAAS,CAAC,GAAG,OAAO,yBAAyB,KAAK,GAAG,CAAC,CAAC;IACrE,CAAC;AACL,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C,CAAC;IAC3D,CAAC;SACI,CAAC;QACF,MAAM,KAAK,GAAG,qBAAqB,CAAC,IAAI,EAAE,OAAO,EAAE,KAAK,CAAC,UAAU,EAAE,gBAAgB,CAAC,CAAC;QACvF,GAAG,GAAG,KAAK,CAAC,GAAG,CAAC;QAChB,UAAU,GAAG,KAAK,CAAC,UAAU,CAAC;IAClC,CAAC;IACD,IAAA,iCAAoB,EAAC,IAAI,CAAC,KAAK,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC;IAC5C,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAW,CAAC;IAC7C,iBAAiB,CAAC,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,gBAAgB,CAAC,CAAC;IACzD,iBAAiB,CAAC,MAAM,EAAE,GAAG,EAAE,KAAK,EAAE,gBAAgB,CAAC,CAAC;IACxD,IAAI,UAAU,KAAK,SAAS;QACxB,iBAAiB,CAAC,MAAM,EAAE,UAAU,EAAE,KAAK,EAAE,gBAAgB,CAAC,CAAC;IACnE,OAAO,MAAM,CAAC,MAAM,CAAC,MAAM,CAA0C,CAAC;AAC1E,CAAC","sourcesContent":["import type { ResolvedModelSlots } from \"./model-slots.ts\";\nimport { resolveAdapterCleanupTimeoutMs } from \"./shared/adapter-cleanup.ts\";\nimport type { AttemptSignal } from \"./shared/attempt-lifecycle.ts\";\nexport type { AttemptCancellation, AttemptSignal } from \"./shared/attempt-lifecycle.ts\";\nimport { bindAssertionContext } from \"./assertions/runtime.ts\";\nimport type { MatchContext } from \"./assertions/context-match.ts\";\nimport type { EvalUsage } from \"./o11y/eval-usage.ts\";\nimport type { ExperimentFlags } from \"./shared/types.ts\";\nimport { assertAdapterFlagsParser, type AdapterFlagsParser, type AdapterFlagsOutput, type AdapterFlagsParserValidation, type AdapterFlagsParserValidationArgs, } from \"./adapter-flags.ts\";\nimport type { AssertionCheck, AssertionSubject, AssertionsRuntime, BooleanAssertionHandle, MeasurementAssertionHandle, PolymorphicBooleanAssertionHandle, PolymorphicMeasurementAssertionHandle, } from \"./assertions/api.ts\";\nimport type { ScoreMatch } from \"./assertions/match.ts\";\nimport { defineEvalForContext } from \"./define.ts\";\nimport type { EvalDefinition, EvalInput, ScoreEvalInput } from \"./runner/types.ts\";\nimport type { EvaluationKind } from \"./shared/evaluation.ts\";\nimport type { JudgePresetMethods } from \"./context/assert-first.ts\";\nimport type { DiagnosticInput, ProgressUpdate } from \"./shared/types.ts\";\nimport type { AdapterIdentity } from \"./record/model/run-context.ts\";\nexport type { AdapterIdentity } from \"./record/model/run-context.ts\";\nconst ADAPTER_CONTRACT_TOKEN: unique symbol = Symbol(\"niceeval.adapterContractToken\");\nconst EVAL_ADAPTER_CONTRACT_TOKEN: unique symbol = Symbol(\"niceeval.evalAdapterContractToken\");\n/**\n * Synchronously assembles Attempt-local Assertion methods from the guarded app\n * facade and the shared check registrar. The returned object must contain only\n * ordinary, synchronously returning methods. Generic and overloaded Assertion\n * sugar is intentionally not callable after binding; use ordinary named\n * parameters so argument and native handle types remain exact.\n */\nexport type AdapterAssertionsFactory<Context extends object, Assertions extends object = object> = (context: AdapterAssertionsFactoryContext<Context>) => Assertions;\n/**\n * Definition inputs for Adapter Assertion sugar. `app` becomes callable after\n * assembly, and `check` may only be called by a returned Assertion method.\n */\nexport interface AdapterAssertionsFactoryContext<Context extends object> {\n readonly app: MatchContext<Context>;\n readonly check: AssertionCheck<\"polymorphic\", Context>;\n}\ntype BoundAdapterAssertionResult<Kind extends EvaluationKind, Result> = Result extends PolymorphicBooleanAssertionHandle<infer Refined, infer HasGate> ? BooleanAssertionHandle<Kind, Refined, HasGate> : Result extends PolymorphicMeasurementAssertionHandle<infer HasCondition> ? MeasurementAssertionHandle<Kind, HasCondition> : never;\ntype BoundAdapterAssertionMethod<Kind extends EvaluationKind, Method> = Method extends (...args: infer Args) => infer Result ? ((...args: Args) => Result) extends Method ? (...args: Args) => BoundAdapterAssertionResult<Kind, Result> : never : never;\ntype AdapterAssertionsFor<Assertions extends object | undefined, Kind extends EvaluationKind> = Assertions extends object ? {\n readonly [Key in keyof Assertions]: BoundAdapterAssertionMethod<Kind, Assertions[Key]>;\n} : {};\n/** Keys owned by the neutral Eval runtime or unsafe on a merged object root. */\nconst RESERVED_ADAPTER_CONTEXT_KEYS = [\n \"evaluationKind\",\n \"check\",\n \"judge\",\n \"factuality\",\n \"faithfulness\",\n \"instructionFollowing\",\n \"pairwisePreference\",\n \"closeQA\",\n \"usage\",\n \"elapsedMs\",\n \"maxTokens\",\n \"maxCost\",\n \"score\",\n \"group\",\n \"skip\",\n \"signal\",\n \"model\",\n \"reasoningEffort\",\n \"flags\",\n \"progress\",\n \"diagnostic\",\n \"log\",\n \"then\",\n \"Object\",\n \"constructor\",\n \"__defineGetter__\",\n \"__defineSetter__\",\n \"hasOwnProperty\",\n \"__lookupGetter__\",\n \"__lookupSetter__\",\n \"isPrototypeOf\",\n \"propertyIsEnumerable\",\n \"toString\",\n \"valueOf\",\n \"__proto__\",\n \"toLocaleString\",\n] as const;\nexport type ReservedAdapterContextKey = typeof RESERVED_ADAPTER_CONTEXT_KEYS[number];\ntype InvalidContextBranch<Context> = Context extends unknown ? Context extends object ? Context extends readonly unknown[] ? Context : Context extends (...args: readonly never[]) => unknown ? Context : string extends keyof Context ? Context : Extract<keyof Context, ReservedAdapterContextKey> extends never ? never : Context : Context : never;\ntype AdapterContextValidation<Context> = unknown extends Context ? unknown : [\n InvalidContextBranch<Context>\n] extends [\n never\n] ? unknown : {\n readonly invalidAdapterContext: InvalidContextBranch<Context>;\n};\ntype InvalidAssertionMethodKey<Context extends object, Assertions> = Assertions extends object ? {\n [Key in keyof Assertions]: Key extends string ? Key extends ReservedAdapterContextKey | keyof Context ? Key : Assertions[Key] extends (...args: readonly never[]) => infer Result ? Result extends PolymorphicBooleanAssertionHandle<unknown, boolean> | PolymorphicMeasurementAssertionHandle<boolean> ? never : Key : Key : Key;\n}[keyof Assertions] : \"assertions\";\ntype InvalidAdapterAssertions<Context extends object, Assertions extends object> = InvalidAssertionMethodKey<Context, Assertions>;\ntype AdapterAssertionsValidation<Context extends object, Assertions extends object> = [\n InvalidAdapterAssertions<Context, Assertions>\n] extends [\n never\n] ? unknown : {\n readonly invalidAdapterAssertions: InvalidAdapterAssertions<Context, Assertions>;\n};\ntype AdapterAssertionsValidationArgs<Context extends object, Assertions extends object> = [\n InvalidAdapterAssertions<Context, Assertions>\n] extends [\n never\n] ? [\n] : [\n error: {\n readonly invalidAdapterAssertions: InvalidAdapterAssertions<Context, Assertions>;\n }\n];\ntype AdapterFactory<Context extends object, Flags extends AdapterFlagsParser = undefined> = (context: AdapterCreateContext<AdapterFlagsOutput<Flags>>) => (Context & ThisType<Context>) | Promise<Context & ThisType<Context>>;\nexport interface AdapterCleanupContext {\n /** 整个清理窗口的固定毫秒预算,不为每个回调续期。 */\n readonly timeoutMs: number;\n /** 清理窗口实际开始时确定的 Unix 毫秒截止时间。 */\n readonly deadlineAt: number;\n /** 独立于执行信号;整个 Adapter 清理窗口截止时中止。 */\n readonly signal: AbortSignal;\n}\nexport interface AdapterCreateContext<Flags = ExperimentFlags> {\n /** Frozen application model selections for this Attempt. */\n readonly models: ResolvedModelSlots;\n recordUsage(input: import(\"./adapter-usage.ts\").AdapterUsageInput): void;\n /** Close application usage admission and declare whether the recorded collection is complete. */\n sealUsage(input: import(\"./adapter-usage.ts\").AdapterUsageSeal): void;\n attach(input: import(\"./adapter-attachments.ts\").AdapterAttachmentInput): Promise<import(\"./adapter-attachments.ts\").AdapterAttachmentReceipt>;\n recordTrace<Event extends import(\"./adapter-execution-trace.ts\").ExecutionTraceEvent>(input: import(\"./adapter-execution-trace.ts\").ExecutionTraceInput<Event>): Promise<import(\"./adapter-execution-trace.ts\").ExecutionTraceReceipt>;\n /** 当前 Eval 的公开 ID。 */\n readonly evalId: string;\n /** 当前 Experiment 的公开 ID。 */\n readonly experimentId: string;\n /** 当前 Attempt 的零起始序号。 */\n readonly attempt: number;\n /** Attempt 执行信号;reason 区分 timeout 与 cancelled,不用于 cleanup 窗口。 */\n readonly signal: AttemptSignal;\n /** Experiment 选择的模型。 */\n readonly model?: string;\n /** Experiment 选择的推理强度。 */\n readonly reasoningEffort?: string;\n /** Experiment 传给 Adapter 的只读 flags。 */\n readonly flags: Flags;\n /** 更新当前 Attempt 的人读进度。 */\n progress(update: ProgressUpdate): void;\n /** 为当前 Attempt 追加结构化诊断。 */\n diagnostic(input: DiagnosticInput): void;\n /** 为当前 Attempt 追加日志。 */\n log(message: string): void;\n /**\n * 登记 Attempt-local 资源释放。回调按全局 LIFO 执行;一项失败不会跳过其余项。\n * 零参数回调仍可直接传入。传入的 context 已冻结,同一 cleanup 窗口的回调共享一个 signal。\n */\n onCleanup(cleanup: (context: AdapterCleanupContext) => void | Promise<void>): void;\n}\ntype EvalContextBase<Kind extends EvaluationKind, Flags, Context> = JudgePresetMethods<Kind, Context> & {\n readonly usage: EvalUsage;\n readonly elapsedMs: import(\"./assertions/match.ts\").NumericMaterial;\n maxTokens(max: number): BooleanAssertionHandle<Kind, number>;\n maxCost(usd: number | string): BooleanAssertionHandle<Kind, string>;\n readonly evaluationKind: Kind;\n readonly signal: AbortSignal;\n readonly model?: string;\n readonly reasoningEffort?: string;\n readonly flags: Flags;\n progress(update: ProgressUpdate): void;\n diagnostic(input: DiagnosticInput): void;\n log(message: string): void;\n skip(reason: string): never;\n group<Value>(title: string, body: () => Value | PromiseLike<Value>): Promise<Awaited<Value>>;\n readonly check: AssertionCheck<Kind, Context>;\n readonly judge: <Value>(value: AssertionSubject<Value>, definition: ScoreMatch<NoInfer<Value>>) => MeasurementAssertionHandle<Kind>;\n};\n/** Agent-neutral author context shared by every Adapter Eval. */\nexport type EvalContext<Kind extends EvaluationKind = \"pass\", Flags = ExperimentFlags, Context = unknown> = EvalContextBase<Kind, Flags, Context> & (Kind extends \"score\" ? {\n readonly score: AssertionsRuntime<\"score\">[\"t\"][\"score\"];\n} : {});\ntype AdapterEvalFields = Omit<EvalInput<undefined>, \"test\" | \"sandbox\" | \"diff\"> & {\n readonly sandbox?: never;\n readonly diff?: never;\n};\ntype AdapterScoreEvalFields = Omit<ScoreEvalInput<undefined>, \"test\" | \"sandbox\" | \"diff\"> & {\n readonly sandbox?: never;\n readonly diff?: never;\n};\nexport type AdapterEvalInput<Context extends object, Assertions extends object | undefined = undefined, Flags extends AdapterFlagsParser = undefined> = AdapterEvalFields & {\n test(t: EvalContext<\"pass\", AdapterFlagsOutput<Flags>, Context> & Readonly<Context> & AdapterAssertionsFor<Assertions, \"pass\">): void | Promise<void>;\n};\nexport type AdapterScoreEvalInput<Context extends object, Assertions extends object | undefined = undefined, Flags extends AdapterFlagsParser = undefined> = AdapterScoreEvalFields & {\n test(t: EvalContext<\"score\", AdapterFlagsOutput<Flags>, Context> & Readonly<Context> & AdapterAssertionsFor<Assertions, \"score\">): void | Promise<void>;\n};\ninterface AdapterContractToken<Context extends object, Assertions extends object | undefined, Flags extends AdapterFlagsParser = undefined> {\n readonly name: string;\n readonly assertions: AdapterAssertionsFactory<Context> | undefined;\n readonly parseFlags: Flags;\n /** Keeps the Assertion method shape invariant without exposing a constructible brand. */\n readonly assertionTypes: (value: Assertions) => Assertions;\n /** Keeps the context parameter invariant without exposing a constructible brand. */\n readonly context: (value: Context) => Context;\n}\nexport interface AdapterEvalDefinition<Kind extends EvaluationKind, Context extends object, Assertions extends object | undefined = undefined, Flags extends AdapterFlagsParser = undefined> extends EvalDefinition<Kind, EvalContext<Kind, AdapterFlagsOutput<Flags>, Context> & Readonly<Context> & AdapterAssertionsFor<Assertions, Kind>, undefined> {\n readonly [EVAL_ADAPTER_CONTRACT_TOKEN]: AdapterContractToken<Context, Assertions, Flags>;\n}\n/** @internal Existential discovery view; concrete bound factories retain their exact Context. */\nexport interface AdapterRuntimeEvalDefinition<Kind extends EvaluationKind> extends EvalDefinition<Kind, never, undefined> {\n readonly [EVAL_ADAPTER_CONTRACT_TOKEN]: object;\n}\n/** Common public surface for an Adapter definition with bound Eval factories. */\nexport interface AdapterDefinition<Context extends object, Assertions extends object | undefined = undefined, Flags extends AdapterFlagsParser = undefined> {\n readonly name: string;\n readonly parseFlags: Flags;\n defineEval(input: AdapterEvalInput<Context, Assertions, Flags>): AdapterEvalDefinition<\"pass\", Context, Assertions, Flags>;\n defineScoreEval(input: AdapterScoreEvalInput<Context, Assertions, Flags>): AdapterEvalDefinition<\"score\", Context, Assertions, Flags>;\n}\n/** Existential runtime view used by Experiment without erasing a concrete context to `any`. */\nexport interface AdapterRuntimeDefinition {\n readonly parseFlags?: Exclude<AdapterFlagsParser, undefined>;\n readonly kind: \"custom\";\n readonly name: string;\n readonly contract: string;\n readonly behaviorRevision: string | null;\n readonly cleanupTimeoutMs: number;\n readonly [ADAPTER_CONTRACT_TOKEN]: object;\n readonly defineEval: (...args: never[]) => unknown;\n readonly defineScoreEval: (...args: never[]) => unknown;\n create(context: AdapterCreateContext<unknown>): object | Promise<object>;\n}\nexport interface AdapterImplementation<Context extends object, Assertions extends object | undefined = undefined, Flags extends AdapterFlagsParser = undefined> extends AdapterDefinition<Context, Assertions, Flags> {\n readonly kind: \"custom\";\n readonly contract: string;\n readonly behaviorRevision: string | null;\n readonly cleanupTimeoutMs: number;\n readonly [ADAPTER_CONTRACT_TOKEN]: AdapterContractToken<Context, Assertions, Flags>;\n create(context: AdapterCreateContext<AdapterFlagsOutput<Flags>>): Context | Promise<Context>;\n}\nexport type AdapterImplementationInput<Context extends object, ImplementationContext extends Context = Context, Flags extends AdapterFlagsParser = undefined> = {\n readonly name: string;\n readonly behaviorRevision?: string;\n /** Adapter 总清理预算,默认 30000 ms;允许整数 1–300000。 */\n readonly cleanupTimeoutMs?: number;\n readonly create: AdapterFactory<ImplementationContext, Flags>;\n} & AdapterContextValidation<NoInfer<ImplementationContext>>;\nexport interface AdapterContract<Context extends object, Assertions extends object | undefined = undefined, Flags extends AdapterFlagsParser = undefined> extends AdapterDefinition<Context, Assertions, Flags> {\n readonly name: string;\n implement<ImplementationContext extends Context>(input: AdapterImplementationInput<Context, ImplementationContext, Flags>): AdapterImplementation<Context, Assertions, Flags>;\n /**\n * Returns a contract whose Eval factories and implementations share one flags parser.\n */\n withParseFlags<NextFlags extends Exclude<AdapterFlagsParser, undefined>>(parseFlags: NextFlags, ...validation: AdapterFlagsParserValidationArgs<NoInfer<NextFlags>>): AdapterContract<Context, Assertions, NextFlags>;\n /** Returns a contract whose implementations share this exact Assertion factory. */\n withAssertions<NextAssertions extends object>(factory: AdapterAssertionsFactory<Context, NextAssertions>, ...validation: AdapterAssertionsValidationArgs<Context, NoInfer<NextAssertions>>): AdapterContract<Context, NextAssertions, Flags>;\n}\nexport type Adapter = import(\"./agents/types.ts\").Agent | AdapterRuntimeDefinition;\nfunction assertNonEmptyString(value: unknown, field: string, factory: string): asserts value is string {\n if (typeof value !== \"string\" || value.trim() === \"\") {\n throw new TypeError(`${factory} requires a non-empty ${field}.`);\n }\n}\nfunction contractToken<Context extends object, Assertions extends object | undefined, Flags extends AdapterFlagsParser>(name: string, assertions: AdapterAssertionsFactory<Context> | undefined, parseFlags: Flags): AdapterContractToken<Context, Assertions, Flags> {\n return Object.freeze({\n name,\n assertions,\n parseFlags,\n assertionTypes: (value: Assertions) => value,\n context: (value: Context) => value,\n });\n}\nfunction assertAdapterEvalInput(value: {\n readonly sandbox?: unknown;\n readonly diff?: unknown;\n}, factory: \"defineEval\" | \"defineScoreEval\"): void {\n if (Object.hasOwn(value, \"sandbox\")) {\n throw new TypeError(`${factory} for an Adapter does not support sandbox.`);\n }\n if (Object.hasOwn(value, \"diff\")) {\n throw new TypeError(`${factory} for an Adapter does not support Agent workspace diff configuration.`);\n }\n}\nfunction boundEvalFactories<Context extends object, Assertions extends object | undefined, Flags extends AdapterFlagsParser>(token: AdapterContractToken<Context, Assertions, Flags>): Pick<AdapterDefinition<Context, Assertions, Flags>, \"defineEval\" | \"defineScoreEval\"> {\n return {\n defineEval(input) {\n assertAdapterEvalInput(input, \"defineEval\");\n return defineEvalForContext(\"pass\", input, {\n [EVAL_ADAPTER_CONTRACT_TOKEN]: token,\n }) as AdapterEvalDefinition<\"pass\", Context, Assertions, Flags>;\n },\n defineScoreEval(input) {\n assertAdapterEvalInput(input, \"defineScoreEval\");\n return defineEvalForContext(\"score\", input, {\n [EVAL_ADAPTER_CONTRACT_TOKEN]: token,\n }) as AdapterEvalDefinition<\"score\", Context, Assertions, Flags>;\n },\n };\n}\nfunction implementAdapter<Context extends object, Assertions extends object | undefined, Flags extends AdapterFlagsParser>(token: AdapterContractToken<Context, Assertions, Flags>, input: {\n readonly name: string;\n readonly behaviorRevision?: string;\n /** Adapter 总清理预算,默认 30000 ms;允许整数 1–300000。 */\n readonly cleanupTimeoutMs?: number;\n readonly create: AdapterFactory<Context, Flags>;\n}, factory: \"defineAdapter\" | \"AdapterContract.implement\"): AdapterImplementation<Context, Assertions, Flags> {\n assertNonEmptyString(input.name, \"name\", factory);\n if (input.behaviorRevision !== undefined) {\n assertNonEmptyString(input.behaviorRevision, \"behaviorRevision\", factory);\n }\n if (typeof input.create !== \"function\") {\n throw new TypeError(`${factory} requires create(context).`);\n }\n const cleanupTimeoutMs = resolveAdapterCleanupTimeoutMs(input.cleanupTimeoutMs);\n const authorCreate = input.create;\n const create = (context: AdapterCreateContext<AdapterFlagsOutput<Flags>>): Context | Promise<Context> => {\n const created = authorCreate(context);\n if (created instanceof Promise) {\n return created.then((value) => {\n assertPlainAdapterContext(value);\n return value;\n });\n }\n // Validate before a caller can pass a synchronous thenable to Promise adaptation.\n assertPlainAdapterContext(created);\n return created;\n };\n return Object.freeze({\n kind: \"custom\" as const,\n parseFlags: token.parseFlags,\n name: input.name,\n contract: token.name,\n behaviorRevision: input.behaviorRevision ?? null,\n cleanupTimeoutMs,\n create,\n [ADAPTER_CONTRACT_TOKEN]: token,\n ...boundEvalFactories(token),\n }) as AdapterImplementation<Context, Assertions, Flags>;\n}\n/** Defines one Adapter implementation with an automatically private contract. */\nexport function defineAdapter<Context extends object, Flags extends AdapterFlagsParser = undefined>(input: {\n readonly name: string;\n readonly behaviorRevision?: string;\n /** Adapter 总清理预算,默认 30000 ms;允许整数 1–300000。 */\n readonly cleanupTimeoutMs?: number;\n readonly create: AdapterFactory<Context, Flags>;\n readonly parseFlags?: Flags;\n readonly assertions?: undefined;\n} & AdapterContextValidation<NoInfer<Context>> & AdapterFlagsParserValidation<NoInfer<Flags>>): AdapterImplementation<Context, undefined, Flags>;\nexport function defineAdapter<Context extends object, Assertions extends object, Flags extends AdapterFlagsParser = undefined>(input: {\n readonly name: string;\n readonly behaviorRevision?: string;\n /** Adapter 总清理预算,默认 30000 ms;允许整数 1–300000。 */\n readonly cleanupTimeoutMs?: number;\n readonly create: AdapterFactory<Context, Flags>;\n readonly parseFlags?: Flags;\n /** Attempt-local Assertion sugar, assembled once after create() succeeds. */\n readonly assertions: AdapterAssertionsFactory<Context, Assertions>;\n} & AdapterContextValidation<NoInfer<Context>> & AdapterFlagsParserValidation<NoInfer<Flags>> & AdapterAssertionsValidation<Context, NoInfer<Assertions>>): AdapterImplementation<Context, Assertions, Flags>;\n// @concord-code ne-adapter-define-adapter\n// @concord-implements docs/feature/adapters/README.md\n// @concord-implements docs/feature/adapters/library/writing-an-adapter.md\nexport function defineAdapter(input: {\n readonly name: string;\n readonly behaviorRevision?: string;\n /** Adapter 总清理预算,默认 30000 ms;允许整数 1–300000。 */\n readonly cleanupTimeoutMs?: number;\n readonly create: AdapterFactory<object, AdapterFlagsParser>;\n readonly parseFlags?: Exclude<AdapterFlagsParser, undefined>;\n readonly assertions?: AdapterAssertionsFactory<object>;\n}): AdapterRuntimeDefinition {\n if (input.parseFlags !== undefined)\n assertAdapterFlagsParser(input.parseFlags);\n const assertions = input.assertions;\n if (assertions !== undefined && typeof assertions !== \"function\") {\n throw new TypeError(\"defineAdapter assertions must be a function.\");\n }\n return implementAdapter(contractToken<object, object | undefined, AdapterFlagsParser>(input.name, assertions, input.parseFlags), input, \"defineAdapter\");\n}\n/** Defines a reusable contract whose implementations and Evals share one runtime-only token. */\n// @concord-code ne-adapter-define-contract\n// @concord-implements docs/feature/adapters/README.md\n// @concord-implements docs/feature/adapters/architecture/agent-contract.md\nexport function defineAdapterContract<Context extends object>(input: {\n readonly name: string;\n} & AdapterContextValidation<NoInfer<Context>>): AdapterContract<Context> {\n assertNonEmptyString(input.name, \"name\", \"defineAdapterContract\");\n return makeAdapterContract(contractToken<Context, undefined, undefined>(input.name, undefined, undefined));\n}\nfunction makeAdapterContract<Context extends object, Assertions extends object | undefined, Flags extends AdapterFlagsParser>(token: AdapterContractToken<Context, Assertions, Flags>): AdapterContract<Context, Assertions, Flags> {\n const factories = boundEvalFactories(token);\n return Object.freeze({\n name: token.name,\n parseFlags: token.parseFlags,\n ...factories,\n implement<ImplementationContext extends Context>(implementation: AdapterImplementationInput<Context, ImplementationContext, Flags>) {\n return implementAdapter(token, implementation, \"AdapterContract.implement\");\n },\n withParseFlags<NextFlags extends Exclude<AdapterFlagsParser, undefined>>(parseFlags: NextFlags, ..._validation: AdapterFlagsParserValidationArgs<NoInfer<NextFlags>>) {\n assertAdapterFlagsParser(parseFlags);\n return makeAdapterContract(contractToken<Context, Assertions, NextFlags>(token.name, token.assertions, parseFlags));\n },\n withAssertions<NextAssertions extends object>(factory: AdapterAssertionsFactory<Context, NextAssertions>, ..._validation: AdapterAssertionsValidationArgs<Context, NoInfer<NextAssertions>>) {\n if (typeof factory !== \"function\") {\n throw new TypeError(\"AdapterContract.withAssertions requires a function.\");\n }\n return makeAdapterContract(contractToken<Context, NextAssertions, Flags>(token.name, factory, token.parseFlags));\n },\n });\n}\n/** The single credential-free persistence projection for an Adapter. */\nexport function adapterIdentity(adapter: Adapter): AdapterIdentity {\n return adapter.kind === \"custom\"\n ? Object.freeze({\n name: adapter.name,\n contract: adapter.contract,\n behaviorRevision: adapter.behaviorRevision,\n cleanupTimeoutMs: adapter.cleanupTimeoutMs,\n })\n : Object.freeze({\n name: adapter.name,\n contract: \"niceeval.agent/v1\",\n behaviorRevision: null,\n });\n}\n/** @internal Runtime contract pairing; the token itself never enters persistence. */\nexport function adapterAcceptsEval(adapter: Adapter, definition: object): boolean {\n const required = (definition as {\n readonly [EVAL_ADAPTER_CONTRACT_TOKEN]?: unknown;\n })[EVAL_ADAPTER_CONTRACT_TOKEN];\n if (adapter.kind === \"custom\") {\n const provided = adapter[ADAPTER_CONTRACT_TOKEN];\n return required !== undefined && provided !== undefined && required === provided;\n }\n return required === undefined;\n}\n/** @internal Returns the readable contract name without revealing the pairing token. */\nexport function adapterContractRequiredByEval(definition: object): string | undefined {\n return (definition as {\n readonly [EVAL_ADAPTER_CONTRACT_TOKEN]?: {\n readonly name: string;\n };\n })[EVAL_ADAPTER_CONTRACT_TOKEN]?.name;\n}\nconst RESERVED_ADAPTER_CONTEXT_KEY_SET: ReadonlySet<string> = new Set(RESERVED_ADAPTER_CONTEXT_KEYS);\nfunction assertPlainAdapterContext(value: unknown): asserts value is object {\n if (typeof value !== \"object\" || value === null || Array.isArray(value)) {\n throw new TypeError(\"Adapter create(context) must return a plain object.\");\n }\n const prototype = Object.getPrototypeOf(value);\n if (prototype !== Object.prototype && prototype !== null) {\n throw new TypeError(\"Adapter create(context) must return an explicit plain object.\");\n }\n for (const key of Reflect.ownKeys(value)) {\n if (typeof key === \"string\" && RESERVED_ADAPTER_CONTEXT_KEY_SET.has(key)) {\n throw new TypeError(`Adapter context key ${JSON.stringify(key)} is reserved.`);\n }\n }\n}\nfunction forwardProperties(target: object, source: object, guardAccess: boolean, assertAuthorOpen: () => void): void {\n for (const key of Reflect.ownKeys(source)) {\n const descriptor = Object.getOwnPropertyDescriptor(source, key);\n if (descriptor === undefined)\n continue;\n if (\"value\" in descriptor && typeof descriptor.value === \"function\") {\n const method = guardAccess\n ? function (this: unknown, ...args: readonly unknown[]) {\n assertAuthorOpen();\n return Reflect.apply(descriptor.value, source, args);\n }\n : descriptor.value.bind(source);\n Object.defineProperty(target, key, {\n enumerable: true,\n configurable: false,\n writable: false,\n value: method,\n });\n }\n else {\n Object.defineProperty(target, key, {\n enumerable: true,\n configurable: false,\n get: () => {\n if (guardAccess)\n assertAuthorOpen();\n const value = Reflect.get(source, key, source);\n if (typeof value !== \"function\")\n return value;\n return guardAccess\n ? (...args: readonly unknown[]) => {\n assertAuthorOpen();\n return Reflect.apply(value, source, args);\n }\n : value.bind(source);\n },\n });\n }\n }\n}\n/** Observes only branded native Promises without reading an arbitrary `.then` property. */\nfunction observeNativePromiseRejection(value: unknown): boolean {\n if ((typeof value !== \"object\" && typeof value !== \"function\") || value === null)\n return false;\n try {\n void Reflect.apply(Promise.prototype.then, value, [\n undefined,\n () => undefined,\n ]);\n return true;\n }\n catch {\n return false;\n }\n}\nfunction assertPlainAdapterAssertions(value: unknown, context: object): asserts value is object {\n if (typeof value !== \"object\" || value === null || Array.isArray(value)) {\n throw new TypeError(\"Adapter assertions factory must return a plain object of methods.\");\n }\n const prototype = Object.getPrototypeOf(value);\n if (prototype !== Object.prototype && prototype !== null) {\n observeNativePromiseRejection(value);\n throw new TypeError(\"Adapter assertions factory must return an explicit plain object.\");\n }\n const contextKeys = new Set(Reflect.ownKeys(context));\n for (const key of Reflect.ownKeys(value)) {\n if (typeof key !== \"string\") {\n throw new TypeError(\"Adapter assertion method names must be strings.\");\n }\n if (RESERVED_ADAPTER_CONTEXT_KEY_SET.has(key)) {\n throw new TypeError(`Adapter assertion method name ${JSON.stringify(key)} is reserved.`);\n }\n if (contextKeys.has(key)) {\n throw new TypeError(`Adapter assertion method name ${JSON.stringify(key)} conflicts with an app member.`);\n }\n const descriptor = Object.getOwnPropertyDescriptor(value, key);\n if (descriptor === undefined || !(\"value\" in descriptor) || typeof descriptor.value !== \"function\") {\n throw new TypeError(`Adapter assertion ${JSON.stringify(key)} must be an own data method.`);\n }\n }\n}\nfunction bindAdapterAppContext<Context>(context: Context, assertAppOpen: () => void): Readonly<Context> {\n const target = Object.create(null) as object;\n forwardProperties(target, context as object, true, assertAppOpen);\n return Object.freeze(target) as Readonly<Context>;\n}\nfunction bindAdapterAssertions<Kind extends EvaluationKind, Context extends object>(core: EvalContext<Kind>, context: Context, factory: AdapterAssertionsFactory<Context>, assertAuthorOpen: () => void): {\n readonly app: Readonly<Context>;\n readonly assertions: object;\n} {\n let assembled = false;\n const assertAppOpen = (): void => {\n assertAuthorOpen();\n if (!assembled) {\n throw new TypeError(\"Adapter assertions factory may only assemble methods; app access starts afterward.\");\n }\n };\n const app = bindAdapterAppContext(context, assertAppOpen);\n const handleFrames: Array<WeakSet<object>> = [];\n const check = (...args: readonly unknown[]): unknown => {\n assertAuthorOpen();\n const frame = handleFrames.at(-1);\n if (frame === undefined) {\n throw new TypeError(\"Adapter assertions factory may call check only from an assertion method.\");\n }\n const handle = Reflect.apply(core.check, undefined, args);\n if ((typeof handle !== \"object\" && typeof handle !== \"function\") || handle === null) {\n throw new TypeError(\"Adapter assertion check did not return an AssertionHandle.\");\n }\n frame.add(handle);\n return handle;\n };\n const authored = factory({ app: app as MatchContext<Context>, check: check as AssertionCheck<\"polymorphic\", Context> });\n assertPlainAdapterAssertions(authored, context);\n Object.freeze(authored);\n assembled = true;\n const assertions = Object.create(null) as object;\n for (const key of Reflect.ownKeys(authored)) {\n const descriptor = Object.getOwnPropertyDescriptor(authored, key)!;\n const method = descriptor.value as (...args: readonly unknown[]) => unknown;\n Object.defineProperty(assertions, key, {\n enumerable: true,\n configurable: false,\n writable: false,\n value: (...args: readonly unknown[]) => {\n assertAuthorOpen();\n const frame = new WeakSet<object>();\n handleFrames.push(frame);\n try {\n const handle = Reflect.apply(method, authored, args);\n if ((typeof handle !== \"object\" && typeof handle !== \"function\") || handle === null || !frame.has(handle)) {\n observeNativePromiseRejection(handle);\n throw new TypeError(`Adapter assertion ${JSON.stringify(key)} must synchronously return its own check() handle.`);\n }\n return handle;\n }\n finally {\n handleFrames.pop();\n }\n },\n });\n }\n return Object.freeze({ app, assertions: Object.freeze(assertions) });\n}\n/** @internal Builds the frozen single-t facade after create settles. */\n// @concord-code ne-adapter-bind-eval-context\n// @concord-implements docs/feature/adapters/architecture/agent-contract.md\nexport function bindAdapterEvalContext<Kind extends EvaluationKind, Context>(core: EvalContext<Kind>, context: Context, adapter: AdapterRuntimeDefinition, assertAuthorOpen: () => void): EvalContext<Kind> & Readonly<Context> {\n assertPlainAdapterContext(context);\n const token = adapter[ADAPTER_CONTRACT_TOKEN] as AdapterContractToken<Context & object, object | undefined>;\n let app: Readonly<Context>;\n let assertions: object | undefined;\n if (token.assertions === undefined) {\n app = bindAdapterAppContext(context, assertAuthorOpen);\n }\n else {\n const bound = bindAdapterAssertions(core, context, token.assertions, assertAuthorOpen);\n app = bound.app;\n assertions = bound.assertions;\n }\n bindAssertionContext(core.check, () => app);\n const target = Object.create(null) as object;\n forwardProperties(target, core, false, assertAuthorOpen);\n forwardProperties(target, app, false, assertAuthorOpen);\n if (assertions !== undefined)\n forwardProperties(target, assertions, false, assertAuthorOpen);\n return Object.freeze(target) as EvalContext<Kind> & Readonly<Context>;\n}\n"]}
1
+ {"version":3,"file":"adapter.js","sourceRoot":"","sources":["adapter.ts"],"names":[],"mappings":";;AAmXA,sCAiBC;AAKD,sDAKC;AAuBD,0CAaC;AAED,gDASC;AAED,sEAMC;AAmKD,wDAoBC;AA5nBD,qDAAuI;AACvI,oEAA6E;AAG7E,wDAA+D;AAI/D,yDAA2L;AAG3L,2CAAmD;AAOnD,MAAM,sBAAsB,GAAkB,MAAM,CAAC,+BAA+B,CAAC,CAAC;AACtF,MAAM,2BAA2B,GAAkB,MAAM,CAAC,mCAAmC,CAAC,CAAC;AAsB/F,gFAAgF;AAChF,MAAM,6BAA6B,GAAG;IAClC,gBAAgB;IAChB,OAAO;IACP,OAAO;IACP,YAAY;IACZ,cAAc;IACd,sBAAsB;IACtB,oBAAoB;IACpB,SAAS;IACT,OAAO;IACP,WAAW;IACX,WAAW;IACX,SAAS;IACT,OAAO;IACP,OAAO;IACP,MAAM;IACN,MAAM;IACN,QAAQ;IACR,OAAO;IACP,iBAAiB;IACjB,OA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AS;QACxB,iBAAiB,CAAC,MAAM,EAAE,UAAU,EAAE,KAAK,EAAE,gBAAgB,CAAC,CAAC;IACnE,OAAO,MAAM,CAAC,MAAM,CAAC,MAAM,CAA0C,CAAC;AAC1E,CAAC","sourcesContent":["import { normalizeModelRequirements, type ModelRequirements, type ResolvedModelRole, type ResolvedModelRoles } from \"./model-roles.ts\";\nimport { resolveAdapterCleanupTimeoutMs } from \"./shared/adapter-cleanup.ts\";\nimport type { AttemptSignal } from \"./shared/attempt-lifecycle.ts\";\nexport type { AttemptCancellation, AttemptSignal } from \"./shared/attempt-lifecycle.ts\";\nimport { bindAssertionContext } from \"./assertions/runtime.ts\";\nimport type { MatchContext } from \"./assertions/context-match.ts\";\nimport type { EvalUsage } from \"./o11y/eval-usage.ts\";\nimport type { ExperimentFlags } from \"./shared/types.ts\";\nimport { assertAdapterFlagsParser, type AdapterFlagsParser, type AdapterFlagsOutput, type AdapterFlagsParserValidation, type AdapterFlagsParserValidationArgs, } from \"./adapter-flags.ts\";\nimport type { AssertionCheck, AssertionSubject, AssertionsRuntime, BooleanAssertionHandle, MeasurementAssertionHandle, PolymorphicBooleanAssertionHandle, PolymorphicMeasurementAssertionHandle, } from \"./assertions/api.ts\";\nimport type { ScoreMatch } from \"./assertions/match.ts\";\nimport { defineEvalForContext } from \"./define.ts\";\nimport type { EvalDefinition, EvalInput, ScoreEvalInput } from \"./runner/types.ts\";\nimport type { EvaluationKind } from \"./shared/evaluation.ts\";\nimport type { JudgePresetMethods } from \"./context/assert-first.ts\";\nimport type { DiagnosticInput, ProgressUpdate } from \"./shared/types.ts\";\nimport type { AdapterIdentity } from \"./record/model/run-context.ts\";\nexport type { AdapterIdentity } from \"./record/model/run-context.ts\";\nconst ADAPTER_CONTRACT_TOKEN: unique symbol = Symbol(\"niceeval.adapterContractToken\");\nconst EVAL_ADAPTER_CONTRACT_TOKEN: unique symbol = Symbol(\"niceeval.evalAdapterContractToken\");\n/**\n * Synchronously assembles Attempt-local Assertion methods from the guarded app\n * facade and the shared check registrar. The returned object must contain only\n * ordinary, synchronously returning methods. Generic and overloaded Assertion\n * sugar is intentionally not callable after binding; use ordinary named\n * parameters so argument and native handle types remain exact.\n */\nexport type AdapterAssertionsFactory<Context extends object, Assertions extends object = object> = (context: AdapterAssertionsFactoryContext<Context>) => Assertions;\n/**\n * Definition inputs for Adapter Assertion sugar. `app` becomes callable after\n * assembly, and `check` may only be called by a returned Assertion method.\n */\nexport interface AdapterAssertionsFactoryContext<Context extends object> {\n readonly app: MatchContext<Context>;\n readonly check: AssertionCheck<\"polymorphic\", Context>;\n}\ntype BoundAdapterAssertionResult<Kind extends EvaluationKind, Result> = Result extends PolymorphicBooleanAssertionHandle<infer Refined, infer HasGate> ? BooleanAssertionHandle<Kind, Refined, HasGate> : Result extends PolymorphicMeasurementAssertionHandle<infer HasCondition> ? MeasurementAssertionHandle<Kind, HasCondition> : never;\ntype BoundAdapterAssertionMethod<Kind extends EvaluationKind, Method> = Method extends (...args: infer Args) => infer Result ? ((...args: Args) => Result) extends Method ? (...args: Args) => BoundAdapterAssertionResult<Kind, Result> : never : never;\ntype AdapterAssertionsFor<Assertions extends object | undefined, Kind extends EvaluationKind> = Assertions extends object ? {\n readonly [Key in keyof Assertions]: BoundAdapterAssertionMethod<Kind, Assertions[Key]>;\n} : {};\n/** Keys owned by the neutral Eval runtime or unsafe on a merged object root. */\nconst RESERVED_ADAPTER_CONTEXT_KEYS = [\n \"evaluationKind\",\n \"check\",\n \"judge\",\n \"factuality\",\n \"faithfulness\",\n \"instructionFollowing\",\n \"pairwisePreference\",\n \"closeQA\",\n \"usage\",\n \"elapsedMs\",\n \"maxTokens\",\n \"maxCost\",\n \"score\",\n \"group\",\n \"note\",\n \"skip\",\n \"signal\",\n \"model\",\n \"reasoningEffort\",\n \"flags\",\n \"progress\",\n \"diagnostic\",\n \"log\",\n \"then\",\n \"Object\",\n \"constructor\",\n \"__defineGetter__\",\n \"__defineSetter__\",\n \"hasOwnProperty\",\n \"__lookupGetter__\",\n \"__lookupSetter__\",\n \"isPrototypeOf\",\n \"propertyIsEnumerable\",\n \"toString\",\n \"valueOf\",\n \"__proto__\",\n \"toLocaleString\",\n] as const;\nexport type ReservedAdapterContextKey = typeof RESERVED_ADAPTER_CONTEXT_KEYS[number];\ntype InvalidContextBranch<Context> = Context extends unknown ? Context extends object ? Context extends readonly unknown[] ? Context : Context extends (...args: readonly never[]) => unknown ? Context : string extends keyof Context ? Context : Extract<keyof Context, ReservedAdapterContextKey> extends never ? never : Context : Context : never;\ntype AdapterContextValidation<Context> = unknown extends Context ? unknown : [\n InvalidContextBranch<Context>\n] extends [\n never\n] ? unknown : {\n readonly invalidAdapterContext: InvalidContextBranch<Context>;\n};\ntype InvalidAssertionMethodKey<Context extends object, Assertions> = Assertions extends object ? {\n [Key in keyof Assertions]: Key extends string ? Key extends ReservedAdapterContextKey | keyof Context ? Key : Assertions[Key] extends (...args: readonly never[]) => infer Result ? Result extends PolymorphicBooleanAssertionHandle<unknown, boolean> | PolymorphicMeasurementAssertionHandle<boolean> ? never : Key : Key : Key;\n}[keyof Assertions] : \"assertions\";\ntype InvalidAdapterAssertions<Context extends object, Assertions extends object> = InvalidAssertionMethodKey<Context, Assertions>;\ntype AdapterAssertionsValidation<Context extends object, Assertions extends object> = [\n InvalidAdapterAssertions<Context, Assertions>\n] extends [\n never\n] ? unknown : {\n readonly invalidAdapterAssertions: InvalidAdapterAssertions<Context, Assertions>;\n};\ntype AdapterAssertionsValidationArgs<Context extends object, Assertions extends object> = [\n InvalidAdapterAssertions<Context, Assertions>\n] extends [\n never\n] ? [\n] : [\n error: {\n readonly invalidAdapterAssertions: InvalidAdapterAssertions<Context, Assertions>;\n }\n];\ntype AdapterFactory<Context extends object, Flags extends AdapterFlagsParser = undefined> = (context: AdapterCreateContext<AdapterFlagsOutput<Flags>>) => (Context & ThisType<Context>) | Promise<Context & ThisType<Context>>;\nexport interface AdapterCleanupContext {\n /** 整个清理窗口的固定毫秒预算,不为每个回调续期。 */\n readonly timeoutMs: number;\n /** 清理窗口实际开始时确定的 Unix 毫秒截止时间。 */\n readonly deadlineAt: number;\n /** 独立于执行信号;整个 Adapter 清理窗口截止时中止。 */\n readonly signal: AbortSignal;\n}\nexport interface AdapterCreateContext<Flags = ExperimentFlags, Roles extends string = string> {\n /** Frozen application model selections for this Attempt. */\n readonly models: Readonly<Record<Roles, ResolvedModelRole>>;\n recordUsage(input: Omit<import(\"./adapter-usage.ts\").AdapterUsageInput, \"modelRole\"> & {\n readonly modelRole?: Roles | null;\n }): void;\n /** Close application usage admission and declare whether the recorded collection is complete. */\n sealUsage(input: import(\"./adapter-usage.ts\").AdapterUsageSeal): void;\n attach(input: import(\"./adapter-attachments.ts\").AdapterAttachmentInput): Promise<import(\"./adapter-attachments.ts\").AdapterAttachmentReceipt>;\n recordTrace<Event extends import(\"./adapter-execution-trace.ts\").ExecutionTraceEvent>(input: import(\"./adapter-execution-trace.ts\").ExecutionTraceInput<Event>): Promise<import(\"./adapter-execution-trace.ts\").ExecutionTraceReceipt>;\n /** 当前 Eval 的公开 ID。 */\n readonly evalId: string;\n /** 当前 Experiment 的公开 ID。 */\n readonly experimentId: string;\n /** 当前 Attempt 的零起始序号。 */\n readonly attempt: number;\n /** Attempt 执行信号;reason 区分 timeout 与 cancelled,不用于 cleanup 窗口。 */\n readonly signal: AttemptSignal;\n /** Experiment 选择的模型。 */\n readonly model?: string;\n /** Experiment 选择的推理强度。 */\n readonly reasoningEffort?: string;\n /** Experiment 传给 Adapter 的只读 flags。 */\n readonly flags: Flags;\n /** 更新当前 Attempt 的人读进度。 */\n progress(update: ProgressUpdate): void;\n /** 为当前 Attempt 追加结构化诊断。 */\n diagnostic(input: DiagnosticInput): void;\n /** 为当前 Attempt 追加日志。 */\n log(message: string): void;\n /**\n * 登记 Attempt-local 资源释放。回调按全局 LIFO 执行;一项失败不会跳过其余项。\n * 零参数回调仍可直接传入。传入的 context 已冻结,同一 cleanup 窗口的回调共享一个 signal。\n */\n onCleanup(cleanup: (context: AdapterCleanupContext) => void | Promise<void>): void;\n}\ntype EvalContextBase<Kind extends EvaluationKind, Flags, Context> = JudgePresetMethods<Kind, Context> & {\n readonly usage: EvalUsage;\n readonly elapsedMs: import(\"./assertions/match.ts\").NumericMaterial;\n maxTokens(max: number): BooleanAssertionHandle<Kind, number>;\n maxCost(usd: number | string): BooleanAssertionHandle<Kind, string>;\n readonly evaluationKind: Kind;\n readonly signal: AbortSignal;\n readonly model?: string;\n readonly reasoningEffort?: string;\n readonly flags: Flags;\n progress(update: ProgressUpdate): void;\n diagnostic(input: DiagnosticInput): void;\n log(message: string): void;\n skip(reason: string): never;\n group<Value>(title: string, body: () => Value | PromiseLike<Value>): Promise<Awaited<Value>>;\n readonly check: AssertionCheck<Kind, Context>;\n readonly judge: <Value>(value: AssertionSubject<Value>, definition: ScoreMatch<NoInfer<Value>>) => MeasurementAssertionHandle<Kind>;\n};\n/** Agent-neutral author context shared by every Adapter Eval. */\nexport type EvalContext<Kind extends EvaluationKind = \"pass\", Flags = ExperimentFlags, Context = unknown> = EvalContextBase<Kind, Flags, Context> & (Kind extends \"score\" ? {\n readonly score: AssertionsRuntime<\"score\">[\"t\"][\"score\"];\n} : {});\ntype AdapterEvalFields = Omit<EvalInput<undefined>, \"test\" | \"sandbox\" | \"diff\"> & {\n readonly sandbox?: never;\n readonly diff?: never;\n};\ntype AdapterScoreEvalFields = Omit<ScoreEvalInput<undefined>, \"test\" | \"sandbox\" | \"diff\"> & {\n readonly sandbox?: never;\n readonly diff?: never;\n};\nexport type AdapterEvalInput<Context extends object, Assertions extends object | undefined = undefined, Flags extends AdapterFlagsParser = undefined, Roles extends string = string> = AdapterEvalFields & {\n readonly requires?: ModelRequirements<Roles>;\n test(t: Omit<EvalContext<\"pass\", AdapterFlagsOutput<Flags>, Context>, \"usage\"> & {\n readonly usage: EvalUsage<NoInfer<Roles>>;\n } & Readonly<Context> & AdapterAssertionsFor<Assertions, \"pass\">): void | Promise<void>;\n};\nexport type AdapterScoreEvalInput<Context extends object, Assertions extends object | undefined = undefined, Flags extends AdapterFlagsParser = undefined, Roles extends string = string> = AdapterScoreEvalFields & {\n readonly requires?: ModelRequirements<Roles>;\n test(t: Omit<EvalContext<\"score\", AdapterFlagsOutput<Flags>, Context>, \"usage\"> & {\n readonly usage: EvalUsage<NoInfer<Roles>>;\n } & Readonly<Context> & AdapterAssertionsFor<Assertions, \"score\">): void | Promise<void>;\n};\ninterface AdapterContractToken<Context extends object, Assertions extends object | undefined, Flags extends AdapterFlagsParser = undefined> {\n readonly name: string;\n readonly assertions: AdapterAssertionsFactory<Context> | undefined;\n readonly parseFlags: Flags;\n /** Keeps the Assertion method shape invariant without exposing a constructible brand. */\n readonly assertionTypes: (value: Assertions) => Assertions;\n /** Keeps the context parameter invariant without exposing a constructible brand. */\n readonly context: (value: Context) => Context;\n}\nexport interface AdapterEvalDefinition<Kind extends EvaluationKind, Context extends object, Assertions extends object | undefined = undefined, Flags extends AdapterFlagsParser = undefined> extends EvalDefinition<Kind, EvalContext<Kind, AdapterFlagsOutput<Flags>, Context> & Readonly<Context> & AdapterAssertionsFor<Assertions, Kind>, undefined> {\n readonly [EVAL_ADAPTER_CONTRACT_TOKEN]: AdapterContractToken<Context, Assertions, Flags>;\n}\n/** @internal Existential discovery view; concrete bound factories retain their exact Context. */\nexport interface AdapterRuntimeEvalDefinition<Kind extends EvaluationKind> extends EvalDefinition<Kind, never, undefined> {\n readonly [EVAL_ADAPTER_CONTRACT_TOKEN]: object;\n}\n/** Common public surface for an Adapter definition with bound Eval factories. */\nexport interface AdapterDefinition<Context extends object, Assertions extends object | undefined = undefined, Flags extends AdapterFlagsParser = undefined> {\n readonly name: string;\n readonly parseFlags: Flags;\n defineEval<const Roles extends string = string>(input: AdapterEvalInput<Context, Assertions, Flags, Roles>): AdapterEvalDefinition<\"pass\", Context, Assertions, Flags>;\n defineScoreEval<const Roles extends string = string>(input: AdapterScoreEvalInput<Context, Assertions, Flags, Roles>): AdapterEvalDefinition<\"score\", Context, Assertions, Flags>;\n}\n/** Existential runtime view used by Experiment without erasing a concrete context to `any`. */\nexport interface AdapterRuntimeDefinition {\n readonly parseFlags?: Exclude<AdapterFlagsParser, undefined>;\n readonly kind: \"custom\";\n readonly requiredModelRoles?: readonly string[];\n readonly name: string;\n readonly contract: string;\n readonly behaviorRevision: string | null;\n readonly cleanupTimeoutMs: number;\n readonly [ADAPTER_CONTRACT_TOKEN]: object;\n readonly defineEval: (...args: never[]) => unknown;\n readonly defineScoreEval: (...args: never[]) => unknown;\n create(context: AdapterCreateContext<unknown>): object | Promise<object>;\n}\nexport interface AdapterImplementation<Context extends object, Assertions extends object | undefined = undefined, Flags extends AdapterFlagsParser = undefined> extends AdapterDefinition<Context, Assertions, Flags> {\n readonly kind: \"custom\";\n readonly contract: string;\n readonly behaviorRevision: string | null;\n readonly cleanupTimeoutMs: number;\n readonly [ADAPTER_CONTRACT_TOKEN]: AdapterContractToken<Context, Assertions, Flags>;\n create(context: AdapterCreateContext<AdapterFlagsOutput<Flags>>): Context | Promise<Context>;\n}\nexport type AdapterImplementationInput<Context extends object, ImplementationContext extends Context = Context, Flags extends AdapterFlagsParser = undefined> = {\n readonly name: string;\n readonly behaviorRevision?: string;\n /** Adapter 总清理预算,默认 30000 ms;允许整数 1–300000。 */\n readonly cleanupTimeoutMs?: number;\n readonly create: AdapterFactory<ImplementationContext, Flags>;\n} & AdapterContextValidation<NoInfer<ImplementationContext>>;\nexport interface AdapterContract<Context extends object, Assertions extends object | undefined = undefined, Flags extends AdapterFlagsParser = undefined> extends AdapterDefinition<Context, Assertions, Flags> {\n readonly name: string;\n implement<ImplementationContext extends Context>(input: AdapterImplementationInput<Context, ImplementationContext, Flags>): AdapterImplementation<Context, Assertions, Flags>;\n /**\n * Returns a contract whose Eval factories and implementations share one flags parser.\n */\n withParseFlags<NextFlags extends Exclude<AdapterFlagsParser, undefined>>(parseFlags: NextFlags, ...validation: AdapterFlagsParserValidationArgs<NoInfer<NextFlags>>): AdapterContract<Context, Assertions, NextFlags>;\n /** Returns a contract whose implementations share this exact Assertion factory. */\n withAssertions<NextAssertions extends object>(factory: AdapterAssertionsFactory<Context, NextAssertions>, ...validation: AdapterAssertionsValidationArgs<Context, NoInfer<NextAssertions>>): AdapterContract<Context, NextAssertions, Flags>;\n}\nexport type Adapter = import(\"./agents/types.ts\").Agent | AdapterRuntimeDefinition;\nfunction assertNonEmptyString(value: unknown, field: string, factory: string): asserts value is string {\n if (typeof value !== \"string\" || value.trim() === \"\") {\n throw new TypeError(`${factory} requires a non-empty ${field}.`);\n }\n}\nfunction contractToken<Context extends object, Assertions extends object | undefined, Flags extends AdapterFlagsParser>(name: string, assertions: AdapterAssertionsFactory<Context> | undefined, parseFlags: Flags): AdapterContractToken<Context, Assertions, Flags> {\n return Object.freeze({\n name,\n assertions,\n parseFlags,\n assertionTypes: (value: Assertions) => value,\n context: (value: Context) => value,\n });\n}\nfunction assertAdapterEvalInput(value: {\n readonly sandbox?: unknown;\n readonly diff?: unknown;\n}, factory: \"defineEval\" | \"defineScoreEval\"): void {\n if (Object.hasOwn(value, \"sandbox\")) {\n throw new TypeError(`${factory} for an Adapter does not support sandbox.`);\n }\n if (Object.hasOwn(value, \"diff\")) {\n throw new TypeError(`${factory} for an Adapter does not support Agent workspace diff configuration.`);\n }\n}\nfunction boundEvalFactories<Context extends object, Assertions extends object | undefined, Flags extends AdapterFlagsParser>(token: AdapterContractToken<Context, Assertions, Flags>): Pick<AdapterDefinition<Context, Assertions, Flags>, \"defineEval\" | \"defineScoreEval\"> {\n return {\n defineEval(input) {\n assertAdapterEvalInput(input, \"defineEval\");\n return defineEvalForContext(\"pass\", input, {\n [EVAL_ADAPTER_CONTRACT_TOKEN]: token,\n requiredModelRoles: normalizeModelRequirements(input.requires),\n }) as AdapterEvalDefinition<\"pass\", Context, Assertions, Flags>;\n },\n defineScoreEval(input) {\n assertAdapterEvalInput(input, \"defineScoreEval\");\n return defineEvalForContext(\"score\", input, {\n [EVAL_ADAPTER_CONTRACT_TOKEN]: token,\n requiredModelRoles: normalizeModelRequirements(input.requires),\n }) as AdapterEvalDefinition<\"score\", Context, Assertions, Flags>;\n },\n };\n}\nfunction implementAdapter<Context extends object, Assertions extends object | undefined, Flags extends AdapterFlagsParser>(token: AdapterContractToken<Context, Assertions, Flags>, input: {\n readonly name: string;\n readonly requires?: ModelRequirements;\n readonly behaviorRevision?: string;\n /** Adapter 总清理预算,默认 30000 ms;允许整数 1–300000。 */\n readonly cleanupTimeoutMs?: number;\n readonly create: AdapterFactory<Context, Flags>;\n}, factory: \"defineAdapter\" | \"AdapterContract.implement\"): AdapterImplementation<Context, Assertions, Flags> {\n assertNonEmptyString(input.name, \"name\", factory);\n if (input.behaviorRevision !== undefined) {\n assertNonEmptyString(input.behaviorRevision, \"behaviorRevision\", factory);\n }\n if (typeof input.create !== \"function\") {\n throw new TypeError(`${factory} requires create(context).`);\n }\n const cleanupTimeoutMs = resolveAdapterCleanupTimeoutMs(input.cleanupTimeoutMs);\n const authorCreate = input.create;\n const create = (context: AdapterCreateContext<AdapterFlagsOutput<Flags>>): Context | Promise<Context> => {\n const created = authorCreate(context);\n if (created instanceof Promise) {\n return created.then((value) => {\n assertPlainAdapterContext(value);\n return value;\n });\n }\n // Validate before a caller can pass a synchronous thenable to Promise adaptation.\n assertPlainAdapterContext(created);\n return created;\n };\n return Object.freeze({\n kind: \"custom\" as const,\n requiredModelRoles: normalizeModelRequirements(input.requires),\n parseFlags: token.parseFlags,\n name: input.name,\n contract: token.name,\n behaviorRevision: input.behaviorRevision ?? null,\n cleanupTimeoutMs,\n create,\n [ADAPTER_CONTRACT_TOKEN]: token,\n ...boundEvalFactories(token),\n }) as AdapterImplementation<Context, Assertions, Flags>;\n}\n/** Defines one Adapter implementation with an automatically private contract. */\nexport function defineAdapter<Context extends object, Flags extends AdapterFlagsParser = undefined, const Roles extends string = string>(input: {\n readonly name: string;\n readonly requires?: ModelRequirements<Roles>;\n readonly behaviorRevision?: string;\n /** Adapter 总清理预算,默认 30000 ms;允许整数 1–300000。 */\n readonly cleanupTimeoutMs?: number;\n readonly create: (context: AdapterCreateContext<AdapterFlagsOutput<Flags>, NoInfer<Roles>>) => (Context & ThisType<Context>) | Promise<Context & ThisType<Context>>;\n readonly parseFlags?: Flags;\n readonly assertions?: undefined;\n} & AdapterContextValidation<NoInfer<Context>> & AdapterFlagsParserValidation<NoInfer<Flags>>): AdapterImplementation<Context, undefined, Flags>;\nexport function defineAdapter<Context extends object, Assertions extends object, Flags extends AdapterFlagsParser = undefined, const Roles extends string = string>(input: {\n readonly name: string;\n readonly requires?: ModelRequirements<Roles>;\n readonly behaviorRevision?: string;\n /** Adapter 总清理预算,默认 30000 ms;允许整数 1–300000。 */\n readonly cleanupTimeoutMs?: number;\n readonly create: (context: AdapterCreateContext<AdapterFlagsOutput<Flags>, NoInfer<Roles>>) => (Context & ThisType<Context>) | Promise<Context & ThisType<Context>>;\n readonly parseFlags?: Flags;\n /** Attempt-local Assertion sugar, assembled once after create() succeeds. */\n readonly assertions: AdapterAssertionsFactory<Context, Assertions>;\n} & AdapterContextValidation<NoInfer<Context>> & AdapterFlagsParserValidation<NoInfer<Flags>> & AdapterAssertionsValidation<Context, NoInfer<Assertions>>): AdapterImplementation<Context, Assertions, Flags>;\n// @concord-code\n// @concord-implements docs/feature/adapters/README.md\n// @concord-implements docs/feature/adapters/library/writing-an-adapter.md\nexport function defineAdapter(input: {\n readonly name: string;\n readonly requires?: ModelRequirements;\n readonly behaviorRevision?: string;\n /** Adapter 总清理预算,默认 30000 ms;允许整数 1–300000。 */\n readonly cleanupTimeoutMs?: number;\n readonly create: AdapterFactory<object, AdapterFlagsParser>;\n readonly parseFlags?: Exclude<AdapterFlagsParser, undefined>;\n readonly assertions?: AdapterAssertionsFactory<object>;\n}): AdapterRuntimeDefinition {\n if (input.parseFlags !== undefined)\n assertAdapterFlagsParser(input.parseFlags);\n const assertions = input.assertions;\n if (assertions !== undefined && typeof assertions !== \"function\") {\n throw new TypeError(\"defineAdapter assertions must be a function.\");\n }\n return implementAdapter(contractToken<object, object | undefined, AdapterFlagsParser>(input.name, assertions, input.parseFlags), input, \"defineAdapter\");\n}\n/** Defines a reusable contract whose implementations and Evals share one runtime-only token. */\n// @concord-code\n// @concord-implements docs/feature/adapters/README.md\n// @concord-implements docs/feature/adapters/architecture/agent-contract.md\nexport function defineAdapterContract<Context extends object>(input: {\n readonly name: string;\n} & AdapterContextValidation<NoInfer<Context>>): AdapterContract<Context> {\n assertNonEmptyString(input.name, \"name\", \"defineAdapterContract\");\n return makeAdapterContract(contractToken<Context, undefined, undefined>(input.name, undefined, undefined));\n}\nfunction makeAdapterContract<Context extends object, Assertions extends object | undefined, Flags extends AdapterFlagsParser>(token: AdapterContractToken<Context, Assertions, Flags>): AdapterContract<Context, Assertions, Flags> {\n const factories = boundEvalFactories(token);\n return Object.freeze({\n name: token.name,\n parseFlags: token.parseFlags,\n ...factories,\n implement<ImplementationContext extends Context>(implementation: AdapterImplementationInput<Context, ImplementationContext, Flags>) {\n return implementAdapter(token, implementation, \"AdapterContract.implement\");\n },\n withParseFlags<NextFlags extends Exclude<AdapterFlagsParser, undefined>>(parseFlags: NextFlags, ..._validation: AdapterFlagsParserValidationArgs<NoInfer<NextFlags>>) {\n assertAdapterFlagsParser(parseFlags);\n return makeAdapterContract(contractToken<Context, Assertions, NextFlags>(token.name, token.assertions, parseFlags));\n },\n withAssertions<NextAssertions extends object>(factory: AdapterAssertionsFactory<Context, NextAssertions>, ..._validation: AdapterAssertionsValidationArgs<Context, NoInfer<NextAssertions>>) {\n if (typeof factory !== \"function\") {\n throw new TypeError(\"AdapterContract.withAssertions requires a function.\");\n }\n return makeAdapterContract(contractToken<Context, NextAssertions, Flags>(token.name, factory, token.parseFlags));\n },\n });\n}\n/** The single credential-free persistence projection for an Adapter. */\nexport function adapterIdentity(adapter: Adapter): AdapterIdentity {\n return adapter.kind === \"custom\"\n ? Object.freeze({\n name: adapter.name,\n contract: adapter.contract,\n behaviorRevision: adapter.behaviorRevision,\n cleanupTimeoutMs: adapter.cleanupTimeoutMs,\n })\n : Object.freeze({\n name: adapter.name,\n contract: \"niceeval.agent/v1\",\n behaviorRevision: null,\n });\n}\n/** @internal Runtime contract pairing; the token itself never enters persistence. */\nexport function adapterAcceptsEval(adapter: Adapter, definition: object): boolean {\n const required = (definition as {\n readonly [EVAL_ADAPTER_CONTRACT_TOKEN]?: unknown;\n })[EVAL_ADAPTER_CONTRACT_TOKEN];\n if (adapter.kind === \"custom\") {\n const provided = adapter[ADAPTER_CONTRACT_TOKEN];\n return required !== undefined && provided !== undefined && required === provided;\n }\n return required === undefined;\n}\n/** @internal Returns the readable contract name without revealing the pairing token. */\nexport function adapterContractRequiredByEval(definition: object): string | undefined {\n return (definition as {\n readonly [EVAL_ADAPTER_CONTRACT_TOKEN]?: {\n readonly name: string;\n };\n })[EVAL_ADAPTER_CONTRACT_TOKEN]?.name;\n}\nconst RESERVED_ADAPTER_CONTEXT_KEY_SET: ReadonlySet<string> = new Set(RESERVED_ADAPTER_CONTEXT_KEYS);\nfunction assertPlainAdapterContext(value: unknown): asserts value is object {\n if (typeof value !== \"object\" || value === null || Array.isArray(value)) {\n throw new TypeError(\"Adapter create(context) must return a plain object.\");\n }\n const prototype = Object.getPrototypeOf(value);\n if (prototype !== Object.prototype && prototype !== null) {\n throw new TypeError(\"Adapter create(context) must return an explicit plain object.\");\n }\n for (const key of Reflect.ownKeys(value)) {\n if (typeof key === \"string\" && RESERVED_ADAPTER_CONTEXT_KEY_SET.has(key)) {\n throw new TypeError(`Adapter context key ${JSON.stringify(key)} is reserved.`);\n }\n }\n}\nfunction forwardProperties(target: object, source: object, guardAccess: boolean, assertAuthorOpen: () => void): void {\n for (const key of Reflect.ownKeys(source)) {\n const descriptor = Object.getOwnPropertyDescriptor(source, key);\n if (descriptor === undefined)\n continue;\n if (\"value\" in descriptor && typeof descriptor.value === \"function\") {\n const method = guardAccess\n ? function (this: unknown, ...args: readonly unknown[]) {\n assertAuthorOpen();\n return Reflect.apply(descriptor.value, source, args);\n }\n : descriptor.value.bind(source);\n Object.defineProperty(target, key, {\n enumerable: true,\n configurable: false,\n writable: false,\n value: method,\n });\n }\n else {\n Object.defineProperty(target, key, {\n enumerable: true,\n configurable: false,\n get: () => {\n if (guardAccess)\n assertAuthorOpen();\n const value = Reflect.get(source, key, source);\n if (typeof value !== \"function\")\n return value;\n return guardAccess\n ? (...args: readonly unknown[]) => {\n assertAuthorOpen();\n return Reflect.apply(value, source, args);\n }\n : value.bind(source);\n },\n });\n }\n }\n}\n/** Observes only branded native Promises without reading an arbitrary `.then` property. */\nfunction observeNativePromiseRejection(value: unknown): boolean {\n if ((typeof value !== \"object\" && typeof value !== \"function\") || value === null)\n return false;\n try {\n void Reflect.apply(Promise.prototype.then, value, [\n undefined,\n () => undefined,\n ]);\n return true;\n }\n catch {\n return false;\n }\n}\nfunction assertPlainAdapterAssertions(value: unknown, context: object): asserts value is object {\n if (typeof value !== \"object\" || value === null || Array.isArray(value)) {\n throw new TypeError(\"Adapter assertions factory must return a plain object of methods.\");\n }\n const prototype = Object.getPrototypeOf(value);\n if (prototype !== Object.prototype && prototype !== null) {\n observeNativePromiseRejection(value);\n throw new TypeError(\"Adapter assertions factory must return an explicit plain object.\");\n }\n const contextKeys = new Set(Reflect.ownKeys(context));\n for (const key of Reflect.ownKeys(value)) {\n if (typeof key !== \"string\") {\n throw new TypeError(\"Adapter assertion method names must be strings.\");\n }\n if (RESERVED_ADAPTER_CONTEXT_KEY_SET.has(key)) {\n throw new TypeError(`Adapter assertion method name ${JSON.stringify(key)} is reserved.`);\n }\n if (contextKeys.has(key)) {\n throw new TypeError(`Adapter assertion method name ${JSON.stringify(key)} conflicts with an app member.`);\n }\n const descriptor = Object.getOwnPropertyDescriptor(value, key);\n if (descriptor === undefined || !(\"value\" in descriptor) || typeof descriptor.value !== \"function\") {\n throw new TypeError(`Adapter assertion ${JSON.stringify(key)} must be an own data method.`);\n }\n }\n}\nfunction bindAdapterAppContext<Context>(context: Context, assertAppOpen: () => void): Readonly<Context> {\n const target = Object.create(null) as object;\n forwardProperties(target, context as object, true, assertAppOpen);\n return Object.freeze(target) as Readonly<Context>;\n}\nfunction bindAdapterAssertions<Kind extends EvaluationKind, Context extends object>(core: EvalContext<Kind>, context: Context, factory: AdapterAssertionsFactory<Context>, assertAuthorOpen: () => void): {\n readonly app: Readonly<Context>;\n readonly assertions: object;\n} {\n let assembled = false;\n const assertAppOpen = (): void => {\n assertAuthorOpen();\n if (!assembled) {\n throw new TypeError(\"Adapter assertions factory may only assemble methods; app access starts afterward.\");\n }\n };\n const app = bindAdapterAppContext(context, assertAppOpen);\n const handleFrames: Array<WeakSet<object>> = [];\n const check = (...args: readonly unknown[]): unknown => {\n assertAuthorOpen();\n const frame = handleFrames.at(-1);\n if (frame === undefined) {\n throw new TypeError(\"Adapter assertions factory may call check only from an assertion method.\");\n }\n const handle = Reflect.apply(core.check, undefined, args);\n if ((typeof handle !== \"object\" && typeof handle !== \"function\") || handle === null) {\n throw new TypeError(\"Adapter assertion check did not return an AssertionHandle.\");\n }\n frame.add(handle);\n return handle;\n };\n const authored = factory({ app: app as MatchContext<Context>, check: check as AssertionCheck<\"polymorphic\", Context> });\n assertPlainAdapterAssertions(authored, context);\n Object.freeze(authored);\n assembled = true;\n const assertions = Object.create(null) as object;\n for (const key of Reflect.ownKeys(authored)) {\n const descriptor = Object.getOwnPropertyDescriptor(authored, key)!;\n const method = descriptor.value as (...args: readonly unknown[]) => unknown;\n Object.defineProperty(assertions, key, {\n enumerable: true,\n configurable: false,\n writable: false,\n value: (...args: readonly unknown[]) => {\n assertAuthorOpen();\n const frame = new WeakSet<object>();\n handleFrames.push(frame);\n try {\n const handle = Reflect.apply(method, authored, args);\n if ((typeof handle !== \"object\" && typeof handle !== \"function\") || handle === null || !frame.has(handle)) {\n observeNativePromiseRejection(handle);\n throw new TypeError(`Adapter assertion ${JSON.stringify(key)} must synchronously return its own check() handle.`);\n }\n return handle;\n }\n finally {\n handleFrames.pop();\n }\n },\n });\n }\n return Object.freeze({ app, assertions: Object.freeze(assertions) });\n}\n/** @internal Builds the frozen single-t facade after create settles. */\n// @concord-code\n// @concord-implements docs/feature/adapters/architecture/agent-contract.md\nexport function bindAdapterEvalContext<Kind extends EvaluationKind, Context>(core: EvalContext<Kind>, context: Context, adapter: AdapterRuntimeDefinition, assertAuthorOpen: () => void): EvalContext<Kind> & Readonly<Context> {\n assertPlainAdapterContext(context);\n const token = adapter[ADAPTER_CONTRACT_TOKEN] as AdapterContractToken<Context & object, object | undefined>;\n let app: Readonly<Context>;\n let assertions: object | undefined;\n if (token.assertions === undefined) {\n app = bindAdapterAppContext(context, assertAuthorOpen);\n }\n else {\n const bound = bindAdapterAssertions(core, context, token.assertions, assertAuthorOpen);\n app = bound.app;\n assertions = bound.assertions;\n }\n bindAssertionContext(core.check, () => app);\n const target = Object.create(null) as object;\n forwardProperties(target, core, false, assertAuthorOpen);\n forwardProperties(target, app, false, assertAuthorOpen);\n if (assertions !== undefined)\n forwardProperties(target, assertions, false, assertAuthorOpen);\n return Object.freeze(target) as EvalContext<Kind> & Readonly<Context>;\n}\n"]}
@@ -1,4 +1,4 @@
1
- import type { ResolvedModelSlots } from "./model-slots.cjs";
1
+ import { type ModelRequirements, type ResolvedModelRole } from "./model-roles.cjs";
2
2
  import type { AttemptSignal } from "./shared/attempt-lifecycle.cjs";
3
3
  export type { AttemptCancellation, AttemptSignal } from "./shared/attempt-lifecycle.cjs";
4
4
  import type { MatchContext } from "./assertions/context-match.cjs";
@@ -37,7 +37,7 @@ type AdapterAssertionsFor<Assertions extends object | undefined, Kind extends Ev
37
37
  readonly [Key in keyof Assertions]: BoundAdapterAssertionMethod<Kind, Assertions[Key]>;
38
38
  } : {};
39
39
  /** Keys owned by the neutral Eval runtime or unsafe on a merged object root. */
40
- declare const RESERVED_ADAPTER_CONTEXT_KEYS: readonly ["evaluationKind", "check", "judge", "factuality", "faithfulness", "instructionFollowing", "pairwisePreference", "closeQA", "usage", "elapsedMs", "maxTokens", "maxCost", "score", "group", "skip", "signal", "model", "reasoningEffort", "flags", "progress", "diagnostic", "log", "then", "Object", "constructor", "__defineGetter__", "__defineSetter__", "hasOwnProperty", "__lookupGetter__", "__lookupSetter__", "isPrototypeOf", "propertyIsEnumerable", "toString", "valueOf", "__proto__", "toLocaleString"];
40
+ declare const RESERVED_ADAPTER_CONTEXT_KEYS: readonly ["evaluationKind", "check", "judge", "factuality", "faithfulness", "instructionFollowing", "pairwisePreference", "closeQA", "usage", "elapsedMs", "maxTokens", "maxCost", "score", "group", "note", "skip", "signal", "model", "reasoningEffort", "flags", "progress", "diagnostic", "log", "then", "Object", "constructor", "__defineGetter__", "__defineSetter__", "hasOwnProperty", "__lookupGetter__", "__lookupSetter__", "isPrototypeOf", "propertyIsEnumerable", "toString", "valueOf", "__proto__", "toLocaleString"];
41
41
  export type ReservedAdapterContextKey = typeof RESERVED_ADAPTER_CONTEXT_KEYS[number];
42
42
  type InvalidContextBranch<Context> = Context extends unknown ? Context extends object ? Context extends readonly unknown[] ? Context : Context extends (...args: readonly never[]) => unknown ? Context : string extends keyof Context ? Context : Extract<keyof Context, ReservedAdapterContextKey> extends never ? never : Context : Context : never;
43
43
  type AdapterContextValidation<Context> = unknown extends Context ? unknown : [InvalidContextBranch<Context>] extends [never] ? unknown : {
@@ -62,10 +62,12 @@ export interface AdapterCleanupContext {
62
62
  /** 独立于执行信号;整个 Adapter 清理窗口截止时中止。 */
63
63
  readonly signal: AbortSignal;
64
64
  }
65
- export interface AdapterCreateContext<Flags = ExperimentFlags> {
65
+ export interface AdapterCreateContext<Flags = ExperimentFlags, Roles extends string = string> {
66
66
  /** Frozen application model selections for this Attempt. */
67
- readonly models: ResolvedModelSlots;
68
- recordUsage(input: import("./adapter-usage.cjs").AdapterUsageInput): void;
67
+ readonly models: Readonly<Record<Roles, ResolvedModelRole>>;
68
+ recordUsage(input: Omit<import("./adapter-usage.cjs").AdapterUsageInput, "modelRole"> & {
69
+ readonly modelRole?: Roles | null;
70
+ }): void;
69
71
  /** Close application usage admission and declare whether the recorded collection is complete. */
70
72
  sealUsage(input: import("./adapter-usage.cjs").AdapterUsageSeal): void;
71
73
  attach(input: import("./adapter-attachments.cjs").AdapterAttachmentInput): Promise<import("./adapter-attachments.cjs").AdapterAttachmentReceipt>;
@@ -126,11 +128,17 @@ type AdapterScoreEvalFields = Omit<ScoreEvalInput<undefined>, "test" | "sandbox"
126
128
  readonly sandbox?: never;
127
129
  readonly diff?: never;
128
130
  };
129
- export type AdapterEvalInput<Context extends object, Assertions extends object | undefined = undefined, Flags extends AdapterFlagsParser = undefined> = AdapterEvalFields & {
130
- test(t: EvalContext<"pass", AdapterFlagsOutput<Flags>, Context> & Readonly<Context> & AdapterAssertionsFor<Assertions, "pass">): void | Promise<void>;
131
+ export type AdapterEvalInput<Context extends object, Assertions extends object | undefined = undefined, Flags extends AdapterFlagsParser = undefined, Roles extends string = string> = AdapterEvalFields & {
132
+ readonly requires?: ModelRequirements<Roles>;
133
+ test(t: Omit<EvalContext<"pass", AdapterFlagsOutput<Flags>, Context>, "usage"> & {
134
+ readonly usage: EvalUsage<NoInfer<Roles>>;
135
+ } & Readonly<Context> & AdapterAssertionsFor<Assertions, "pass">): void | Promise<void>;
131
136
  };
132
- export type AdapterScoreEvalInput<Context extends object, Assertions extends object | undefined = undefined, Flags extends AdapterFlagsParser = undefined> = AdapterScoreEvalFields & {
133
- test(t: EvalContext<"score", AdapterFlagsOutput<Flags>, Context> & Readonly<Context> & AdapterAssertionsFor<Assertions, "score">): void | Promise<void>;
137
+ export type AdapterScoreEvalInput<Context extends object, Assertions extends object | undefined = undefined, Flags extends AdapterFlagsParser = undefined, Roles extends string = string> = AdapterScoreEvalFields & {
138
+ readonly requires?: ModelRequirements<Roles>;
139
+ test(t: Omit<EvalContext<"score", AdapterFlagsOutput<Flags>, Context>, "usage"> & {
140
+ readonly usage: EvalUsage<NoInfer<Roles>>;
141
+ } & Readonly<Context> & AdapterAssertionsFor<Assertions, "score">): void | Promise<void>;
134
142
  };
135
143
  interface AdapterContractToken<Context extends object, Assertions extends object | undefined, Flags extends AdapterFlagsParser = undefined> {
136
144
  readonly name: string;
@@ -152,13 +160,14 @@ export interface AdapterRuntimeEvalDefinition<Kind extends EvaluationKind> exten
152
160
  export interface AdapterDefinition<Context extends object, Assertions extends object | undefined = undefined, Flags extends AdapterFlagsParser = undefined> {
153
161
  readonly name: string;
154
162
  readonly parseFlags: Flags;
155
- defineEval(input: AdapterEvalInput<Context, Assertions, Flags>): AdapterEvalDefinition<"pass", Context, Assertions, Flags>;
156
- defineScoreEval(input: AdapterScoreEvalInput<Context, Assertions, Flags>): AdapterEvalDefinition<"score", Context, Assertions, Flags>;
163
+ defineEval<const Roles extends string = string>(input: AdapterEvalInput<Context, Assertions, Flags, Roles>): AdapterEvalDefinition<"pass", Context, Assertions, Flags>;
164
+ defineScoreEval<const Roles extends string = string>(input: AdapterScoreEvalInput<Context, Assertions, Flags, Roles>): AdapterEvalDefinition<"score", Context, Assertions, Flags>;
157
165
  }
158
166
  /** Existential runtime view used by Experiment without erasing a concrete context to `any`. */
159
167
  export interface AdapterRuntimeDefinition {
160
168
  readonly parseFlags?: Exclude<AdapterFlagsParser, undefined>;
161
169
  readonly kind: "custom";
170
+ readonly requiredModelRoles?: readonly string[];
162
171
  readonly name: string;
163
172
  readonly contract: string;
164
173
  readonly behaviorRevision: string | null;
@@ -195,21 +204,23 @@ export interface AdapterContract<Context extends object, Assertions extends obje
195
204
  }
196
205
  export type Adapter = import("./agents/types.cjs").Agent | AdapterRuntimeDefinition;
197
206
  /** Defines one Adapter implementation with an automatically private contract. */
198
- export declare function defineAdapter<Context extends object, Flags extends AdapterFlagsParser = undefined>(input: {
207
+ export declare function defineAdapter<Context extends object, Flags extends AdapterFlagsParser = undefined, const Roles extends string = string>(input: {
199
208
  readonly name: string;
209
+ readonly requires?: ModelRequirements<Roles>;
200
210
  readonly behaviorRevision?: string;
201
211
  /** Adapter 总清理预算,默认 30000 ms;允许整数 1–300000。 */
202
212
  readonly cleanupTimeoutMs?: number;
203
- readonly create: AdapterFactory<Context, Flags>;
213
+ readonly create: (context: AdapterCreateContext<AdapterFlagsOutput<Flags>, NoInfer<Roles>>) => (Context & ThisType<Context>) | Promise<Context & ThisType<Context>>;
204
214
  readonly parseFlags?: Flags;
205
215
  readonly assertions?: undefined;
206
216
  } & AdapterContextValidation<NoInfer<Context>> & AdapterFlagsParserValidation<NoInfer<Flags>>): AdapterImplementation<Context, undefined, Flags>;
207
- export declare function defineAdapter<Context extends object, Assertions extends object, Flags extends AdapterFlagsParser = undefined>(input: {
217
+ export declare function defineAdapter<Context extends object, Assertions extends object, Flags extends AdapterFlagsParser = undefined, const Roles extends string = string>(input: {
208
218
  readonly name: string;
219
+ readonly requires?: ModelRequirements<Roles>;
209
220
  readonly behaviorRevision?: string;
210
221
  /** Adapter 总清理预算,默认 30000 ms;允许整数 1–300000。 */
211
222
  readonly cleanupTimeoutMs?: number;
212
- readonly create: AdapterFactory<Context, Flags>;
223
+ readonly create: (context: AdapterCreateContext<AdapterFlagsOutput<Flags>, NoInfer<Roles>>) => (Context & ThisType<Context>) | Promise<Context & ThisType<Context>>;
213
224
  readonly parseFlags?: Flags;
214
225
  /** Attempt-local Assertion sugar, assembled once after create() succeeds. */
215
226
  readonly assertions: AdapterAssertionsFactory<Context, Assertions>;
@@ -1,4 +1,4 @@
1
- import type { ResolvedModelSlots } from "./model-slots.mjs";
1
+ import { type ModelRequirements, type ResolvedModelRole } from "./model-roles.mjs";
2
2
  import type { AttemptSignal } from "./shared/attempt-lifecycle.mjs";
3
3
  export type { AttemptCancellation, AttemptSignal } from "./shared/attempt-lifecycle.mjs";
4
4
  import type { MatchContext } from "./assertions/context-match.mjs";
@@ -37,7 +37,7 @@ type AdapterAssertionsFor<Assertions extends object | undefined, Kind extends Ev
37
37
  readonly [Key in keyof Assertions]: BoundAdapterAssertionMethod<Kind, Assertions[Key]>;
38
38
  } : {};
39
39
  /** Keys owned by the neutral Eval runtime or unsafe on a merged object root. */
40
- declare const RESERVED_ADAPTER_CONTEXT_KEYS: readonly ["evaluationKind", "check", "judge", "factuality", "faithfulness", "instructionFollowing", "pairwisePreference", "closeQA", "usage", "elapsedMs", "maxTokens", "maxCost", "score", "group", "skip", "signal", "model", "reasoningEffort", "flags", "progress", "diagnostic", "log", "then", "Object", "constructor", "__defineGetter__", "__defineSetter__", "hasOwnProperty", "__lookupGetter__", "__lookupSetter__", "isPrototypeOf", "propertyIsEnumerable", "toString", "valueOf", "__proto__", "toLocaleString"];
40
+ declare const RESERVED_ADAPTER_CONTEXT_KEYS: readonly ["evaluationKind", "check", "judge", "factuality", "faithfulness", "instructionFollowing", "pairwisePreference", "closeQA", "usage", "elapsedMs", "maxTokens", "maxCost", "score", "group", "note", "skip", "signal", "model", "reasoningEffort", "flags", "progress", "diagnostic", "log", "then", "Object", "constructor", "__defineGetter__", "__defineSetter__", "hasOwnProperty", "__lookupGetter__", "__lookupSetter__", "isPrototypeOf", "propertyIsEnumerable", "toString", "valueOf", "__proto__", "toLocaleString"];
41
41
  export type ReservedAdapterContextKey = typeof RESERVED_ADAPTER_CONTEXT_KEYS[number];
42
42
  type InvalidContextBranch<Context> = Context extends unknown ? Context extends object ? Context extends readonly unknown[] ? Context : Context extends (...args: readonly never[]) => unknown ? Context : string extends keyof Context ? Context : Extract<keyof Context, ReservedAdapterContextKey> extends never ? never : Context : Context : never;
43
43
  type AdapterContextValidation<Context> = unknown extends Context ? unknown : [InvalidContextBranch<Context>] extends [never] ? unknown : {
@@ -62,10 +62,12 @@ export interface AdapterCleanupContext {
62
62
  /** 独立于执行信号;整个 Adapter 清理窗口截止时中止。 */
63
63
  readonly signal: AbortSignal;
64
64
  }
65
- export interface AdapterCreateContext<Flags = ExperimentFlags> {
65
+ export interface AdapterCreateContext<Flags = ExperimentFlags, Roles extends string = string> {
66
66
  /** Frozen application model selections for this Attempt. */
67
- readonly models: ResolvedModelSlots;
68
- recordUsage(input: import("./adapter-usage.mjs").AdapterUsageInput): void;
67
+ readonly models: Readonly<Record<Roles, ResolvedModelRole>>;
68
+ recordUsage(input: Omit<import("./adapter-usage.mjs").AdapterUsageInput, "modelRole"> & {
69
+ readonly modelRole?: Roles | null;
70
+ }): void;
69
71
  /** Close application usage admission and declare whether the recorded collection is complete. */
70
72
  sealUsage(input: import("./adapter-usage.mjs").AdapterUsageSeal): void;
71
73
  attach(input: import("./adapter-attachments.mjs").AdapterAttachmentInput): Promise<import("./adapter-attachments.mjs").AdapterAttachmentReceipt>;
@@ -126,11 +128,17 @@ type AdapterScoreEvalFields = Omit<ScoreEvalInput<undefined>, "test" | "sandbox"
126
128
  readonly sandbox?: never;
127
129
  readonly diff?: never;
128
130
  };
129
- export type AdapterEvalInput<Context extends object, Assertions extends object | undefined = undefined, Flags extends AdapterFlagsParser = undefined> = AdapterEvalFields & {
130
- test(t: EvalContext<"pass", AdapterFlagsOutput<Flags>, Context> & Readonly<Context> & AdapterAssertionsFor<Assertions, "pass">): void | Promise<void>;
131
+ export type AdapterEvalInput<Context extends object, Assertions extends object | undefined = undefined, Flags extends AdapterFlagsParser = undefined, Roles extends string = string> = AdapterEvalFields & {
132
+ readonly requires?: ModelRequirements<Roles>;
133
+ test(t: Omit<EvalContext<"pass", AdapterFlagsOutput<Flags>, Context>, "usage"> & {
134
+ readonly usage: EvalUsage<NoInfer<Roles>>;
135
+ } & Readonly<Context> & AdapterAssertionsFor<Assertions, "pass">): void | Promise<void>;
131
136
  };
132
- export type AdapterScoreEvalInput<Context extends object, Assertions extends object | undefined = undefined, Flags extends AdapterFlagsParser = undefined> = AdapterScoreEvalFields & {
133
- test(t: EvalContext<"score", AdapterFlagsOutput<Flags>, Context> & Readonly<Context> & AdapterAssertionsFor<Assertions, "score">): void | Promise<void>;
137
+ export type AdapterScoreEvalInput<Context extends object, Assertions extends object | undefined = undefined, Flags extends AdapterFlagsParser = undefined, Roles extends string = string> = AdapterScoreEvalFields & {
138
+ readonly requires?: ModelRequirements<Roles>;
139
+ test(t: Omit<EvalContext<"score", AdapterFlagsOutput<Flags>, Context>, "usage"> & {
140
+ readonly usage: EvalUsage<NoInfer<Roles>>;
141
+ } & Readonly<Context> & AdapterAssertionsFor<Assertions, "score">): void | Promise<void>;
134
142
  };
135
143
  interface AdapterContractToken<Context extends object, Assertions extends object | undefined, Flags extends AdapterFlagsParser = undefined> {
136
144
  readonly name: string;
@@ -152,13 +160,14 @@ export interface AdapterRuntimeEvalDefinition<Kind extends EvaluationKind> exten
152
160
  export interface AdapterDefinition<Context extends object, Assertions extends object | undefined = undefined, Flags extends AdapterFlagsParser = undefined> {
153
161
  readonly name: string;
154
162
  readonly parseFlags: Flags;
155
- defineEval(input: AdapterEvalInput<Context, Assertions, Flags>): AdapterEvalDefinition<"pass", Context, Assertions, Flags>;
156
- defineScoreEval(input: AdapterScoreEvalInput<Context, Assertions, Flags>): AdapterEvalDefinition<"score", Context, Assertions, Flags>;
163
+ defineEval<const Roles extends string = string>(input: AdapterEvalInput<Context, Assertions, Flags, Roles>): AdapterEvalDefinition<"pass", Context, Assertions, Flags>;
164
+ defineScoreEval<const Roles extends string = string>(input: AdapterScoreEvalInput<Context, Assertions, Flags, Roles>): AdapterEvalDefinition<"score", Context, Assertions, Flags>;
157
165
  }
158
166
  /** Existential runtime view used by Experiment without erasing a concrete context to `any`. */
159
167
  export interface AdapterRuntimeDefinition {
160
168
  readonly parseFlags?: Exclude<AdapterFlagsParser, undefined>;
161
169
  readonly kind: "custom";
170
+ readonly requiredModelRoles?: readonly string[];
162
171
  readonly name: string;
163
172
  readonly contract: string;
164
173
  readonly behaviorRevision: string | null;
@@ -195,21 +204,23 @@ export interface AdapterContract<Context extends object, Assertions extends obje
195
204
  }
196
205
  export type Adapter = import("./agents/types.mjs").Agent | AdapterRuntimeDefinition;
197
206
  /** Defines one Adapter implementation with an automatically private contract. */
198
- export declare function defineAdapter<Context extends object, Flags extends AdapterFlagsParser = undefined>(input: {
207
+ export declare function defineAdapter<Context extends object, Flags extends AdapterFlagsParser = undefined, const Roles extends string = string>(input: {
199
208
  readonly name: string;
209
+ readonly requires?: ModelRequirements<Roles>;
200
210
  readonly behaviorRevision?: string;
201
211
  /** Adapter 总清理预算,默认 30000 ms;允许整数 1–300000。 */
202
212
  readonly cleanupTimeoutMs?: number;
203
- readonly create: AdapterFactory<Context, Flags>;
213
+ readonly create: (context: AdapterCreateContext<AdapterFlagsOutput<Flags>, NoInfer<Roles>>) => (Context & ThisType<Context>) | Promise<Context & ThisType<Context>>;
204
214
  readonly parseFlags?: Flags;
205
215
  readonly assertions?: undefined;
206
216
  } & AdapterContextValidation<NoInfer<Context>> & AdapterFlagsParserValidation<NoInfer<Flags>>): AdapterImplementation<Context, undefined, Flags>;
207
- export declare function defineAdapter<Context extends object, Assertions extends object, Flags extends AdapterFlagsParser = undefined>(input: {
217
+ export declare function defineAdapter<Context extends object, Assertions extends object, Flags extends AdapterFlagsParser = undefined, const Roles extends string = string>(input: {
208
218
  readonly name: string;
219
+ readonly requires?: ModelRequirements<Roles>;
209
220
  readonly behaviorRevision?: string;
210
221
  /** Adapter 总清理预算,默认 30000 ms;允许整数 1–300000。 */
211
222
  readonly cleanupTimeoutMs?: number;
212
- readonly create: AdapterFactory<Context, Flags>;
223
+ readonly create: (context: AdapterCreateContext<AdapterFlagsOutput<Flags>, NoInfer<Roles>>) => (Context & ThisType<Context>) | Promise<Context & ThisType<Context>>;
213
224
  readonly parseFlags?: Flags;
214
225
  /** Attempt-local Assertion sugar, assembled once after create() succeeds. */
215
226
  readonly assertions: AdapterAssertionsFactory<Context, Assertions>;