niceeval 0.9.1 → 0.10.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 (428) hide show
  1. package/INDEX.md +31 -33
  2. package/dist/agents/types.d.ts +20 -17
  3. package/dist/context/types.d.ts +21 -21
  4. package/dist/i18n/en.d.ts +10 -2
  5. package/dist/i18n/zh-CN.d.ts +14 -6
  6. package/dist/o11y/execution-tree.d.ts +103 -0
  7. package/dist/o11y/otlp/select.d.ts +22 -0
  8. package/dist/report/{react → assets}/colors.d.ts +8 -0
  9. package/dist/report/{react → assets}/colors.js +23 -0
  10. package/dist/report/built-in/index.d.ts +2 -2
  11. package/dist/report/built-in/index.js +2 -2
  12. package/dist/report/built-in/standard.d.ts +8 -1
  13. package/dist/report/built-in/standard.js +17 -7
  14. package/dist/report/components/attempt-detail/AttemptAssertions.d.ts +6 -0
  15. package/dist/report/components/attempt-detail/AttemptAssertions.js +17 -0
  16. package/dist/report/components/attempt-detail/AttemptConversation.d.ts +6 -0
  17. package/dist/report/components/attempt-detail/AttemptConversation.js +34 -0
  18. package/dist/report/components/attempt-detail/AttemptDiagnostics.d.ts +6 -0
  19. package/dist/report/components/attempt-detail/AttemptDiagnostics.js +7 -0
  20. package/dist/report/components/attempt-detail/AttemptDiff.d.ts +6 -0
  21. package/dist/report/components/attempt-detail/AttemptDiff.js +11 -0
  22. package/dist/report/components/attempt-detail/AttemptError.d.ts +6 -0
  23. package/dist/report/components/attempt-detail/AttemptError.js +16 -0
  24. package/dist/report/components/attempt-detail/AttemptFixPrompt.d.ts +6 -0
  25. package/dist/report/components/attempt-detail/AttemptFixPrompt.js +7 -0
  26. package/dist/report/components/attempt-detail/AttemptSource.d.ts +6 -0
  27. package/dist/report/components/attempt-detail/AttemptSource.js +27 -0
  28. package/dist/report/components/attempt-detail/AttemptSummary.d.ts +8 -0
  29. package/dist/report/components/attempt-detail/AttemptSummary.js +20 -0
  30. package/dist/report/components/attempt-detail/AttemptTimeline.d.ts +6 -0
  31. package/dist/report/components/attempt-detail/AttemptTimeline.js +28 -0
  32. package/dist/report/components/attempt-detail/AttemptTrace.d.ts +6 -0
  33. package/dist/report/components/attempt-detail/AttemptTrace.js +29 -0
  34. package/dist/report/components/attempt-detail/AttemptUsage.d.ts +6 -0
  35. package/dist/report/components/attempt-detail/AttemptUsage.js +20 -0
  36. package/dist/report/components/attempt-detail/compute.d.ts +24 -0
  37. package/dist/report/components/attempt-detail/compute.js +254 -0
  38. package/dist/report/components/attempt-detail/faces.d.ts +14 -0
  39. package/dist/report/components/attempt-detail/faces.js +235 -0
  40. package/dist/report/components/attempt-detail/index.d.ts +38 -0
  41. package/dist/report/components/attempt-detail/index.js +527 -0
  42. package/dist/report/{react → components}/cell.d.ts +5 -3
  43. package/dist/report/{react → components}/cell.js +3 -3
  44. package/dist/report/{react → components/entity-lists}/AttemptList.d.ts +8 -4
  45. package/dist/report/{react → components/entity-lists}/AttemptList.js +16 -10
  46. package/dist/report/{react → components/entity-lists}/EvalList.d.ts +3 -3
  47. package/dist/report/{react → components/entity-lists}/EvalList.js +0 -0
  48. package/dist/report/{react → components/entity-lists}/ExperimentList.d.ts +3 -3
  49. package/dist/report/{react → components/entity-lists}/ExperimentList.js +10 -10
  50. package/dist/report/components/entity-lists/compute.d.ts +23 -0
  51. package/dist/report/components/entity-lists/compute.js +171 -0
  52. package/dist/report/components/entity-lists/faces.d.ts +5 -0
  53. package/dist/report/components/entity-lists/faces.js +174 -0
  54. package/dist/report/components/entity-lists/index.d.ts +51 -0
  55. package/dist/report/components/entity-lists/index.js +165 -0
  56. package/dist/report/{react → components}/fixtures.d.ts +2 -2
  57. package/dist/report/{react → components}/fixtures.js +1 -1
  58. package/dist/report/{react → components/metric-views}/DeltaTable.d.ts +2 -2
  59. package/dist/report/{react → components/metric-views}/DeltaTable.js +4 -4
  60. package/dist/report/{react → components/metric-views}/MetricBars.d.ts +3 -3
  61. package/dist/report/{react → components/metric-views}/MetricBars.js +3 -3
  62. package/dist/report/{react → components/metric-views}/MetricLine.d.ts +2 -2
  63. package/dist/report/{react → components/metric-views}/MetricLine.js +8 -5
  64. package/dist/report/{react → components/metric-views}/MetricMatrix.d.ts +3 -3
  65. package/dist/report/{react → components/metric-views}/MetricMatrix.js +4 -4
  66. package/dist/report/components/metric-views/MetricScatter.d.ts +11 -0
  67. package/dist/report/{react → components/metric-views}/MetricScatter.js +26 -23
  68. package/dist/report/{react → components/metric-views}/MetricTable.d.ts +3 -3
  69. package/dist/report/{react → components/metric-views}/MetricTable.js +4 -4
  70. package/dist/report/{react → components/metric-views}/Scoreboard.d.ts +2 -2
  71. package/dist/report/{react → components/metric-views}/Scoreboard.js +3 -3
  72. package/dist/report/components/metric-views/compute.d.ts +89 -0
  73. package/dist/report/{compute.js → components/metric-views/compute.js} +32 -415
  74. package/dist/report/components/metric-views/faces.d.ts +13 -0
  75. package/dist/report/components/metric-views/faces.js +381 -0
  76. package/dist/report/components/metric-views/index.d.ts +50 -0
  77. package/dist/report/components/metric-views/index.js +273 -0
  78. package/dist/report/{text → components/metric-views}/plot.js +1 -1
  79. package/dist/report/components/shared-compute.d.ts +22 -0
  80. package/dist/report/components/shared-compute.js +47 -0
  81. package/dist/report/components/shared-faces.d.ts +9 -0
  82. package/dist/report/components/shared-faces.js +26 -0
  83. package/dist/report/components/shared.d.ts +68 -0
  84. package/dist/report/components/shared.js +125 -0
  85. package/dist/report/{react → components/site-components}/CopyFixPrompt.d.ts +2 -2
  86. package/dist/report/{react → components/site-components}/CopyFixPrompt.js +2 -2
  87. package/dist/report/{react → components/site-components}/HeroCard.d.ts +2 -2
  88. package/dist/report/{react → components/site-components}/HeroCard.js +2 -2
  89. package/dist/report/{react → components/site-components}/ScopeWarnings.d.ts +2 -2
  90. package/dist/report/{react → components/site-components}/ScopeWarnings.js +3 -3
  91. package/dist/report/{react → components/site-components}/TraceWaterfall.d.ts +3 -3
  92. package/dist/report/{react → components/site-components}/TraceWaterfall.js +5 -5
  93. package/dist/report/components/site-components/compute.d.ts +28 -0
  94. package/dist/report/components/site-components/compute.js +132 -0
  95. package/dist/report/components/site-components/faces.d.ts +21 -0
  96. package/dist/report/components/site-components/faces.js +75 -0
  97. package/dist/report/components/site-components/index.d.ts +74 -0
  98. package/dist/report/components/site-components/index.js +220 -0
  99. package/dist/report/{scope-warnings.d.ts → components/site-components/scope-warnings.d.ts} +2 -2
  100. package/dist/report/{scope-warnings.js → components/site-components/scope-warnings.js} +2 -2
  101. package/dist/report/{react → components/summaries}/ScopeSummary.d.ts +2 -2
  102. package/dist/report/{react → components/summaries}/ScopeSummary.js +17 -8
  103. package/dist/report/components/summaries/compute.d.ts +7 -0
  104. package/dist/report/components/summaries/compute.js +51 -0
  105. package/dist/report/components/summaries/faces.d.ts +7 -0
  106. package/dist/report/components/summaries/faces.js +38 -0
  107. package/dist/report/components/summaries/index.d.ts +27 -0
  108. package/dist/report/components/summaries/index.js +78 -0
  109. package/dist/report/definition/grid-layout.d.ts +50 -0
  110. package/dist/report/definition/grid-layout.js +89 -0
  111. package/dist/report/{primitives.d.ts → definition/primitives.d.ts} +34 -4
  112. package/dist/report/{primitives.js → definition/primitives.js} +101 -10
  113. package/dist/report/{report.d.ts → definition/report.d.ts} +36 -65
  114. package/dist/report/{report.js → definition/report.js} +58 -90
  115. package/dist/report/{text/table.d.ts → definition/table-text.d.ts} +2 -2
  116. package/dist/report/{text/table.js → definition/table-text.js} +2 -2
  117. package/dist/report/{tree.d.ts → definition/tree.d.ts} +43 -11
  118. package/dist/report/{tree.js → definition/tree.js} +9 -11
  119. package/dist/report/index.d.ts +33 -18
  120. package/dist/report/index.js +23 -14
  121. package/dist/report/{aggregate.d.ts → model/aggregate.d.ts} +12 -4
  122. package/dist/report/{aggregate.js → model/aggregate.js} +28 -8
  123. package/dist/report/{flag.d.ts → model/flag.d.ts} +14 -1
  124. package/dist/report/{flag.js → model/flag.js} +35 -0
  125. package/dist/report/{format.d.ts → model/format.d.ts} +11 -5
  126. package/dist/report/{format.js → model/format.js} +48 -4
  127. package/dist/report/{locale.d.ts → model/locale.d.ts} +17 -17
  128. package/dist/report/{locale.js → model/locale.js} +31 -33
  129. package/dist/report/{metrics.d.ts → model/metrics.d.ts} +2 -2
  130. package/dist/report/{metrics.js → model/metrics.js} +2 -2
  131. package/dist/report/{types.d.ts → model/types.d.ts} +140 -20
  132. package/dist/report/react/index.d.ts +32 -21
  133. package/dist/report/react/index.js +33 -21
  134. package/dist/report/{load.d.ts → runtime/load.d.ts} +1 -1
  135. package/dist/report/{load.js → runtime/load.js} +1 -1
  136. package/dist/report/runtime/text.d.ts +67 -0
  137. package/dist/report/runtime/text.js +114 -0
  138. package/dist/report/runtime/web.d.ts +35 -0
  139. package/dist/report/runtime/web.js +70 -0
  140. package/dist/results/annotated-source.d.ts +87 -0
  141. package/dist/results/attempt-evidence.d.ts +74 -0
  142. package/dist/results/attempt-source.d.ts +15 -0
  143. package/dist/results/select.d.ts +11 -1
  144. package/dist/results/select.js +27 -5
  145. package/dist/runner/eval-selection.d.ts +26 -0
  146. package/dist/runner/feedback/sink.d.ts +26 -1
  147. package/dist/runner/types.d.ts +149 -23
  148. package/dist/sandbox/docker.d.ts +6 -0
  149. package/dist/sandbox/types.d.ts +23 -21
  150. package/dist/scoring/display.d.ts +7 -2
  151. package/dist/scoring/display.js +42 -4
  152. package/dist/scoring/types.d.ts +3 -3
  153. package/dist/shared/aggregate.d.ts +14 -0
  154. package/dist/shared/aggregate.js +31 -0
  155. package/dist/shared/types.d.ts +6 -1
  156. package/docs-site/images/logo-dark.svg +7 -0
  157. package/docs-site/images/logo.svg +6 -5
  158. package/docs-site/zh/README.md +8 -7
  159. package/docs-site/zh/examples/ai-agent-application.mdx +5 -5
  160. package/docs-site/zh/examples/coding-agent-extensions.mdx +4 -4
  161. package/docs-site/zh/examples/index.mdx +3 -3
  162. package/docs-site/zh/examples/integrations/ai-sdk-v7.mdx +1 -1
  163. package/docs-site/zh/examples/integrations/claude-sdk.mdx +3 -3
  164. package/docs-site/zh/examples/integrations/codex-sdk.mdx +3 -3
  165. package/docs-site/zh/examples/integrations/langgraph.mdx +3 -3
  166. package/docs-site/zh/examples/integrations/pi-sdk.mdx +2 -2
  167. package/docs-site/zh/explanation/adapter.mdx +19 -19
  168. package/docs-site/zh/explanation/assert.mdx +9 -9
  169. package/docs-site/zh/explanation/drive.mdx +4 -4
  170. package/docs-site/zh/explanation/evals.mdx +8 -8
  171. package/docs-site/zh/explanation/experiment.mdx +8 -8
  172. package/docs-site/zh/explanation/hitl.mdx +13 -13
  173. package/docs-site/zh/explanation/judge.mdx +3 -3
  174. package/docs-site/zh/explanation/overview.mdx +7 -7
  175. package/docs-site/zh/explanation/runner.mdx +11 -11
  176. package/docs-site/zh/explanation/tier.mdx +6 -6
  177. package/docs-site/zh/index.mdx +14 -14
  178. package/docs-site/zh/introduction.mdx +13 -16
  179. package/docs-site/zh/reference/builtin-agents.mdx +61 -28
  180. package/docs-site/zh/reference/capabilities.mdx +7 -27
  181. package/docs-site/zh/reference/cli.mdx +35 -32
  182. package/docs-site/zh/reference/define-agent.mdx +32 -31
  183. package/docs-site/zh/reference/define-config.mdx +6 -6
  184. package/docs-site/zh/reference/define-eval.mdx +33 -20
  185. package/docs-site/zh/reference/events.mdx +4 -4
  186. package/docs-site/zh/reference/expect.mdx +3 -3
  187. package/docs-site/zh/reference/official-adapters.mdx +17 -17
  188. package/docs-site/zh/reference/report-components.mdx +193 -121
  189. package/docs-site/zh/reference/results-data.mdx +13 -13
  190. package/docs-site/zh/troubleshooting/debug-sandbox.mdx +11 -11
  191. package/docs-site/zh/troubleshooting/debugging.mdx +40 -16
  192. package/docs-site/zh/{how-to → tutorials}/agent-feedback-loop.mdx +38 -38
  193. package/docs-site/zh/tutorials/agent-onboarding.mdx +100 -0
  194. package/docs-site/zh/tutorials/authoring.mdx +211 -0
  195. package/docs-site/zh/{how-to → tutorials}/ci-integration.mdx +8 -8
  196. package/docs-site/zh/{how-to → tutorials}/connect-otel.mdx +22 -22
  197. package/docs-site/zh/{how-to → tutorials}/connect-your-agent.mdx +58 -63
  198. package/docs-site/zh/tutorials/custom-reports.mdx +453 -0
  199. package/docs-site/zh/{how-to → tutorials}/dataset-fanout.mdx +4 -4
  200. package/docs-site/zh/tutorials/experiments.mdx +103 -0
  201. package/docs-site/zh/{how-to → tutorials}/fixtures.mdx +9 -9
  202. package/docs-site/zh/{how-to → tutorials}/publish-report.mdx +6 -6
  203. package/docs-site/zh/tutorials/quickstart.mdx +18 -18
  204. package/docs-site/zh/{how-to → tutorials}/reporters.mdx +6 -6
  205. package/docs-site/zh/{how-to → tutorials}/sandbox-agent.mdx +6 -6
  206. package/docs-site/zh/{how-to → tutorials}/sandbox-providers.mdx +41 -19
  207. package/docs-site/zh/{how-to → tutorials}/scoring-guide.mdx +4 -4
  208. package/docs-site/zh/{how-to → tutorials}/viewing-results.mdx +49 -49
  209. package/docs-site/zh/tutorials/write-experiment.mdx +355 -0
  210. package/docs-site/zh/{how-to → tutorials}/write-send.mdx +40 -40
  211. package/package.json +8 -4
  212. package/src/agents/bub.ts +21 -8
  213. package/src/agents/claude-code.ts +23 -10
  214. package/src/agents/codex.test.ts +22 -7
  215. package/src/agents/codex.ts +22 -9
  216. package/src/agents/index.ts +2 -2
  217. package/src/agents/openai-compat.ts +1 -1
  218. package/src/agents/post-setup.ts +45 -22
  219. package/src/agents/streaming.ts +1 -1
  220. package/src/agents/types.ts +20 -17
  221. package/src/agents/ui-message-stream.test.ts +10 -0
  222. package/src/agents/ui-message-stream.ts +12 -1
  223. package/src/cli.ts +71 -57
  224. package/src/context/types.ts +21 -21
  225. package/src/define.ts +13 -0
  226. package/src/i18n/en.ts +27 -12
  227. package/src/i18n/zh-CN.ts +27 -12
  228. package/src/index.ts +2 -0
  229. package/src/report/{react → assets}/colors.ts +22 -0
  230. package/src/report/{react → assets}/enhance.js +1 -33
  231. package/src/report/{react → assets}/styles.css +124 -106
  232. package/src/report/built-in/index.tsx +2 -2
  233. package/src/report/built-in/standard.tsx +18 -6
  234. package/src/report/components/attempt-detail/AttemptAssertions.tsx +67 -0
  235. package/src/report/components/attempt-detail/AttemptConversation.tsx +110 -0
  236. package/src/report/components/attempt-detail/AttemptDiagnostics.tsx +38 -0
  237. package/src/report/components/attempt-detail/AttemptDiff.tsx +35 -0
  238. package/src/report/components/attempt-detail/AttemptError.tsx +31 -0
  239. package/src/report/components/attempt-detail/AttemptFixPrompt.tsx +26 -0
  240. package/src/report/components/attempt-detail/AttemptSource.tsx +80 -0
  241. package/src/report/components/attempt-detail/AttemptSummary.tsx +74 -0
  242. package/src/report/components/attempt-detail/AttemptTimeline.tsx +108 -0
  243. package/src/report/components/attempt-detail/AttemptTrace.tsx +63 -0
  244. package/src/report/components/attempt-detail/AttemptUsage.tsx +29 -0
  245. package/src/report/components/attempt-detail/attempt-components.test.tsx +680 -0
  246. package/src/report/components/attempt-detail/compute.ts +287 -0
  247. package/src/report/components/attempt-detail/faces.ts +257 -0
  248. package/src/report/components/attempt-detail/index.tsx +583 -0
  249. package/src/report/components/attempt-detail/validate.test.ts +235 -0
  250. package/src/report/{react → components}/cell.tsx +6 -3
  251. package/src/report/{report.test.ts → components/compute.test.ts} +316 -46
  252. package/src/report/{react → components/entity-lists}/AttemptList.tsx +24 -16
  253. package/src/report/{react → components/entity-lists}/EvalList.tsx +0 -0
  254. package/src/report/{react → components/entity-lists}/ExperimentList.tsx +23 -20
  255. package/src/report/components/entity-lists/compute.ts +196 -0
  256. package/src/report/components/entity-lists/faces.ts +207 -0
  257. package/src/report/components/entity-lists/index.tsx +241 -0
  258. package/src/report/components/entity-lists/validate.test.ts +114 -0
  259. package/src/report/{react → components}/fixtures.ts +2 -2
  260. package/src/report/{react → components/metric-views}/DeltaTable.tsx +5 -5
  261. package/src/report/{react → components/metric-views}/MetricBars.tsx +5 -5
  262. package/src/report/{react → components/metric-views}/MetricLine.tsx +9 -6
  263. package/src/report/{react → components/metric-views}/MetricMatrix.tsx +6 -6
  264. package/src/report/{react → components/metric-views}/MetricScatter.tsx +41 -33
  265. package/src/report/{react → components/metric-views}/MetricTable.tsx +6 -6
  266. package/src/report/{react → components/metric-views}/Scoreboard.tsx +4 -4
  267. package/src/report/{compute.ts → components/metric-views/compute.ts} +51 -477
  268. package/src/report/components/metric-views/faces.ts +423 -0
  269. package/src/report/components/metric-views/index.tsx +352 -0
  270. package/src/report/{text → components/metric-views}/plot.ts +1 -1
  271. package/src/report/components/metric-views/validate.test.ts +211 -0
  272. package/src/report/{react → components}/render.test.tsx +47 -17
  273. package/src/report/components/shared-compute.ts +59 -0
  274. package/src/report/components/shared-faces.ts +30 -0
  275. package/src/report/components/shared.ts +192 -0
  276. package/src/report/{react → components/site-components}/CopyFixPrompt.tsx +3 -3
  277. package/src/report/{react → components/site-components}/HeroCard.tsx +3 -3
  278. package/src/report/{react → components/site-components}/ScopeWarnings.tsx +4 -4
  279. package/src/report/{react → components/site-components}/TraceWaterfall.tsx +13 -10
  280. package/src/report/components/site-components/compute.ts +144 -0
  281. package/src/report/components/site-components/faces.ts +80 -0
  282. package/src/report/components/site-components/index.tsx +265 -0
  283. package/src/report/{scope-warnings.ts → components/site-components/scope-warnings.ts} +3 -3
  284. package/src/report/{site-components.test.tsx → components/site-components/site-components.test.tsx} +23 -21
  285. package/src/report/components/site-components/validate.test.ts +89 -0
  286. package/src/report/{react → components/summaries}/ScopeSummary.tsx +26 -11
  287. package/src/report/components/summaries/compute.ts +56 -0
  288. package/src/report/components/summaries/faces.ts +48 -0
  289. package/src/report/components/summaries/index.tsx +127 -0
  290. package/src/report/components/summaries/validate.test.ts +49 -0
  291. package/src/report/definition/grid-layout.test.ts +124 -0
  292. package/src/report/definition/grid-layout.ts +146 -0
  293. package/src/report/{primitives.tsx → definition/primitives.tsx} +168 -18
  294. package/src/report/{report.ts → definition/report.ts} +98 -165
  295. package/src/report/{shell-head.test.ts → definition/shell-head.test.ts} +2 -2
  296. package/src/report/{text/table.ts → definition/table-text.ts} +4 -4
  297. package/src/report/{tree.ts → definition/tree.ts} +56 -20
  298. package/src/report/index.ts +126 -66
  299. package/src/report/{aggregate.ts → model/aggregate.ts} +31 -9
  300. package/src/report/{flag.ts → model/flag.ts} +39 -1
  301. package/src/report/{format.ts → model/format.ts} +59 -5
  302. package/src/report/{locale.ts → model/locale.ts} +34 -36
  303. package/src/report/{metrics.ts → model/metrics.ts} +3 -3
  304. package/src/report/{types.ts → model/types.ts} +143 -22
  305. package/src/report/react/index.tsx +52 -26
  306. package/src/report/{dual-render.test.tsx → runtime/dual-render.test.tsx} +564 -49
  307. package/src/report/runtime/host.test.ts +44 -0
  308. package/src/report/runtime/host.ts +138 -0
  309. package/src/report/{load.ts → runtime/load.ts} +1 -1
  310. package/src/report/runtime/text.ts +192 -0
  311. package/src/report/runtime/web.ts +106 -0
  312. package/src/results/attempt-evidence.ts +5 -1
  313. package/src/results/host-equivalence.test.ts +53 -2
  314. package/src/results/select.ts +29 -5
  315. package/src/runner/attempt.test.ts +48 -1
  316. package/src/runner/attempt.ts +62 -42
  317. package/src/runner/cleanup-timeout.test.ts +16 -0
  318. package/src/runner/cleanup-timeout.ts +23 -0
  319. package/src/runner/discover.ts +1 -2
  320. package/src/runner/eval-selection.test.ts +187 -0
  321. package/src/runner/eval-selection.ts +109 -0
  322. package/src/runner/experiment-cleanup-registry.test.ts +89 -0
  323. package/src/runner/experiment-cleanup-registry.ts +39 -0
  324. package/src/runner/experiment-labels.test.ts +71 -0
  325. package/src/runner/feedback/agent.test.ts +33 -1
  326. package/src/runner/feedback/agent.ts +12 -16
  327. package/src/runner/feedback/ci.test.ts +35 -1
  328. package/src/runner/feedback/ci.ts +16 -18
  329. package/src/runner/feedback/coordinator.ts +28 -0
  330. package/src/runner/feedback/human.test.ts +108 -1
  331. package/src/runner/feedback/human.ts +71 -21
  332. package/src/runner/feedback/reducer.test.ts +64 -0
  333. package/src/runner/feedback/reducer.ts +26 -0
  334. package/src/runner/feedback/sink.ts +40 -1
  335. package/src/runner/fingerprint.ts +2 -1
  336. package/src/runner/report.test.ts +14 -0
  337. package/src/runner/report.ts +3 -1
  338. package/src/runner/run.test.ts +390 -12
  339. package/src/runner/run.ts +259 -26
  340. package/src/runner/sandbox-selection.test.ts +13 -3
  341. package/src/runner/sandbox-selection.ts +4 -2
  342. package/src/runner/types.ts +158 -23
  343. package/src/sandbox/docker.ts +7 -0
  344. package/src/sandbox/e2b.ts +12 -13
  345. package/src/sandbox/types.ts +23 -21
  346. package/src/scoring/display.test.ts +28 -2
  347. package/src/scoring/display.ts +38 -5
  348. package/src/scoring/types.ts +3 -3
  349. package/src/shared/aggregate.test.ts +52 -0
  350. package/src/shared/aggregate.ts +29 -0
  351. package/src/shared/types.ts +6 -1
  352. package/src/show/command.test.ts +34 -0
  353. package/src/show/command.ts +16 -0
  354. package/src/show/compose.ts +1 -1
  355. package/src/show/index.ts +56 -20
  356. package/src/show/render.ts +15 -239
  357. package/src/show/show.test.ts +127 -34
  358. package/src/view/app/App.test.tsx +1 -1
  359. package/src/view/app/App.tsx +119 -47
  360. package/src/view/app/i18n.ts +7 -147
  361. package/src/view/app/lib/attempt-dialog.test.ts +65 -0
  362. package/src/view/app/lib/attempt-dialog.ts +69 -0
  363. package/src/view/app/main.tsx +0 -1
  364. package/src/view/app/types.ts +3 -86
  365. package/src/view/artifact-serving.test.ts +22 -38
  366. package/src/view/client-dist/app.css +1 -1
  367. package/src/view/client-dist/app.js +15 -22
  368. package/src/view/data.test.ts +48 -36
  369. package/src/view/data.ts +105 -83
  370. package/src/view/index.ts +1 -1
  371. package/src/view/server.ts +32 -2
  372. package/src/view/shared/types.ts +6 -31
  373. package/src/view/site-parity.test.ts +24 -1
  374. package/src/view/site.ts +144 -17
  375. package/src/view/styles.css +0 -805
  376. package/src/view/view-report.test.ts +141 -22
  377. package/dist/report/components.d.ts +0 -179
  378. package/dist/report/components.js +0 -544
  379. package/dist/report/compute.d.ts +0 -139
  380. package/dist/report/react/ExperimentComparison.d.ts +0 -10
  381. package/dist/report/react/ExperimentComparison.js +0 -12
  382. package/dist/report/react/MetricScatter.d.ts +0 -9
  383. package/dist/report/react/format.d.ts +0 -3
  384. package/dist/report/react/format.js +0 -7
  385. package/dist/report/text/faces.d.ts +0 -45
  386. package/dist/report/text/faces.js +0 -671
  387. package/dist/report/web.d.ts +0 -32
  388. package/dist/report/web.js +0 -48
  389. package/docs-site/zh/how-to/authoring.mdx +0 -162
  390. package/docs-site/zh/how-to/custom-reports.mdx +0 -414
  391. package/docs-site/zh/how-to/experiments.mdx +0 -86
  392. package/docs-site/zh/how-to/write-experiment.mdx +0 -164
  393. package/src/report/components.tsx +0 -925
  394. package/src/report/react/ExperimentComparison.tsx +0 -73
  395. package/src/report/react/format.ts +0 -9
  396. package/src/report/text/faces.ts +0 -767
  397. package/src/report/web.ts +0 -77
  398. package/src/show/report-host.test.ts +0 -205
  399. package/src/show/report-host.ts +0 -389
  400. package/src/view/app/components/AttemptModal.tsx +0 -496
  401. package/src/view/app/components/CodeView.test.tsx +0 -142
  402. package/src/view/app/components/CodeView.tsx +0 -310
  403. package/src/view/app/components/CopyControls.tsx +0 -106
  404. package/src/view/app/components/Trace.tsx +0 -100
  405. package/src/view/app/components/Transcript.tsx +0 -157
  406. package/src/view/app/components/ui/badge.tsx +0 -21
  407. package/src/view/app/lib/artifact-url.ts +0 -17
  408. package/src/view/app/lib/attempt-route.test.ts +0 -80
  409. package/src/view/app/lib/attempt-route.ts +0 -52
  410. package/src/view/app/lib/format.ts +0 -70
  411. package/src/view/app/lib/guards.test.ts +0 -108
  412. package/src/view/app/lib/guards.ts +0 -71
  413. package/src/view/app/lib/rows.ts +0 -22
  414. package/src/view/app/lib/transcript-data.tsx +0 -151
  415. package/src/view/app/lib/verdict.ts +0 -23
  416. package/src/view/app/shared.ts +0 -8
  417. /package/dist/report/{react → components/metric-views}/chart-math.d.ts +0 -0
  418. /package/dist/report/{react → components/metric-views}/chart-math.js +0 -0
  419. /package/dist/report/{text → components/metric-views}/plot.d.ts +0 -0
  420. /package/dist/report/{react → components/site-components}/PoweredBy.d.ts +0 -0
  421. /package/dist/report/{react → components/site-components}/PoweredBy.js +0 -0
  422. /package/dist/report/{text/layout.d.ts → model/text-layout.d.ts} +0 -0
  423. /package/dist/report/{text/layout.js → model/text-layout.js} +0 -0
  424. /package/dist/report/{types.js → model/types.js} +0 -0
  425. /package/src/report/{react → components/metric-views}/chart-math.test.ts +0 -0
  426. /package/src/report/{react → components/metric-views}/chart-math.ts +0 -0
  427. /package/src/report/{react → components/site-components}/PoweredBy.tsx +0 -0
  428. /package/src/report/{text/layout.ts → model/text-layout.ts} +0 -0
@@ -0,0 +1,110 @@
1
+ // AttemptConversation:标准事件流按轮组织的完整分轮事件卡。没有 events 时零输出
2
+ // (docs/feature/reports/library/attempt-detail.md)。
3
+
4
+ import type { ReactElement, ReactNode } from "react";
5
+ import type { AttemptConversationData, AttemptConversationReply, AttemptConversationRound } from "../../model/types.ts";
6
+ import { cx } from "../shared.ts";
7
+
8
+ function ReplyRow({ reply }: { reply: AttemptConversationReply }): ReactNode {
9
+ switch (reply.kind) {
10
+ case "assistant":
11
+ return (
12
+ <div className="nre-conv-assistant">
13
+ <span className="nre-conv-role">assistant</span>
14
+ <div className="nre-conv-text">{reply.text}</div>
15
+ </div>
16
+ );
17
+ case "user":
18
+ return (
19
+ <div className="nre-conv-user">
20
+ <span className="nre-conv-role">user</span>
21
+ <div className="nre-conv-text">{reply.text}</div>
22
+ </div>
23
+ );
24
+ case "thinking":
25
+ return (
26
+ <details className="nre-conv-thinking">
27
+ <summary>thinking</summary>
28
+ <div className="nre-conv-text">{reply.text}</div>
29
+ </details>
30
+ );
31
+ case "error":
32
+ return <div className="nre-conv-error">! {reply.text}</div>;
33
+ case "skill":
34
+ return (
35
+ <div className="nre-conv-skill">
36
+ <span className="nre-conv-role">skill loaded</span> {reply.skill}
37
+ </div>
38
+ );
39
+ case "tool":
40
+ return (
41
+ <details className="nre-conv-tool">
42
+ <summary>
43
+ {reply.name}
44
+ {reply.status ? ` · ${reply.status}` : ""}
45
+ </summary>
46
+ <pre className="nre-conv-tool-io">{JSON.stringify(reply.input, null, 2)}</pre>
47
+ {reply.output !== undefined ? <pre className="nre-conv-tool-io">{JSON.stringify(reply.output, null, 2)}</pre> : null}
48
+ </details>
49
+ );
50
+ case "subagent":
51
+ return (
52
+ <details className="nre-conv-subagent">
53
+ <summary>
54
+ subagent {reply.name}
55
+ {reply.status ? ` · ${reply.status}` : ""}
56
+ </summary>
57
+ {reply.output !== undefined ? <pre className="nre-conv-tool-io">{JSON.stringify(reply.output, null, 2)}</pre> : null}
58
+ </details>
59
+ );
60
+ case "input":
61
+ return <div className="nre-conv-input">input requested{reply.request.prompt ? `: ${reply.request.prompt}` : ""}</div>;
62
+ case "compaction":
63
+ return <div className="nre-conv-compaction">compaction{reply.reason ? `: ${reply.reason}` : ""}</div>;
64
+ case "raw":
65
+ return (
66
+ <details className="nre-conv-raw">
67
+ <summary>unrecognized event</summary>
68
+ <pre className="nre-conv-tool-io">{JSON.stringify(reply.raw, null, 2)}</pre>
69
+ </details>
70
+ );
71
+ }
72
+ }
73
+
74
+ function RoundCard({ round, index }: { round: AttemptConversationRound; index: number }): ReactElement {
75
+ return (
76
+ <div className="nre-conv-round">
77
+ <div className="nre-conv-round-head">
78
+ round {index + 1}
79
+ {round.loc ? (
80
+ <span className="nre-conv-round-loc" title={`${round.loc.file}:${round.loc.line}`}>
81
+ {round.loc.file.split("/").pop()}:{round.loc.line}
82
+ </span>
83
+ ) : null}
84
+ </div>
85
+ {round.sentText ? <div className="nre-conv-sent">{round.sentText}</div> : null}
86
+ <div className="nre-conv-replies">
87
+ {round.replies.map((reply, i) => (
88
+ <ReplyRow key={i} reply={reply} />
89
+ ))}
90
+ </div>
91
+ </div>
92
+ );
93
+ }
94
+
95
+ export function AttemptConversation({
96
+ data,
97
+ className,
98
+ }: {
99
+ data: AttemptConversationData | null;
100
+ className?: string;
101
+ }): ReactElement | null {
102
+ if (data === null) return null;
103
+ return (
104
+ <div className={cx("nre", "nre-attempt-conversation", className)}>
105
+ {data.rounds.map((round, i) => (
106
+ <RoundCard key={i} round={round} index={i} />
107
+ ))}
108
+ </div>
109
+ );
110
+ }
@@ -0,0 +1,38 @@
1
+ // AttemptDiagnostics:lifecycle 分组的 diagnostics。没有 diagnostics 时零输出
2
+ // (docs/feature/reports/library/attempt-detail.md)。
3
+
4
+ import type { ReactElement } from "react";
5
+ import type { AttemptDiagnosticsData } from "../../model/types.ts";
6
+ import { cx } from "../shared.ts";
7
+
8
+ export function AttemptDiagnostics({
9
+ data,
10
+ className,
11
+ }: {
12
+ data: AttemptDiagnosticsData | null;
13
+ className?: string;
14
+ }): ReactElement | null {
15
+ if (data === null) return null;
16
+ return (
17
+ <div className={cx("nre", "nre-attempt-diagnostics", className)}>
18
+ {data.groups.map(({ phase, items }) => (
19
+ <div key={phase} className="nre-diagnostics-group">
20
+ <div className="nre-diagnostics-phase">{phase}</div>
21
+ <ul>
22
+ {items.map((d, i) => (
23
+ <li key={i} className={`nre-diagnostics-item nre-tone-${d.level === "error" ? "bad" : "warn"}`}>
24
+ <span className="nre-diagnostics-meta">
25
+ {d.level} · {d.code}
26
+ </span>
27
+ <div>
28
+ {d.message}
29
+ {d.count && d.count > 1 ? ` (${d.count} occurrences)` : ""}
30
+ </div>
31
+ </li>
32
+ ))}
33
+ </ul>
34
+ </div>
35
+ ))}
36
+ </div>
37
+ );
38
+ }
@@ -0,0 +1,35 @@
1
+ // AttemptDiff:generated / modified / deleted 文件摘要与展开的行变化统计。没有变更时零输出
2
+ // (docs/feature/reports/library/attempt-detail.md)。
3
+
4
+ import type { ReactElement } from "react";
5
+ import type { AttemptDiffData, AttemptDiffFileEntry } from "../../model/types.ts";
6
+ import { cx } from "../shared.ts";
7
+
8
+ const NET_LABEL: Record<AttemptDiffFileEntry["net"], string> = { added: "generated", modified: "modified", deleted: "deleted" };
9
+
10
+ function FileRow({ file }: { file: AttemptDiffFileEntry }): ReactElement {
11
+ return (
12
+ <li className={cx("nre-diff-file", `nre-diff-${file.net}`)}>
13
+ <span className="nre-diff-net">{NET_LABEL[file.net]}</span>
14
+ <span className="nre-diff-path">{file.path}</span>
15
+ {file.binary ? (
16
+ <span className="nre-diff-lines">binary</span>
17
+ ) : (
18
+ <span className="nre-diff-lines">
19
+ +{file.lines.added} / -{file.lines.deleted}
20
+ </span>
21
+ )}
22
+ </li>
23
+ );
24
+ }
25
+
26
+ export function AttemptDiff({ data, className }: { data: AttemptDiffData | null; className?: string }): ReactElement | null {
27
+ if (data === null) return null;
28
+ return (
29
+ <ul className={cx("nre", "nre-attempt-diff", className)}>
30
+ {data.files.map((f) => (
31
+ <FileRow key={f.path} file={f} />
32
+ ))}
33
+ </ul>
34
+ );
35
+ }
@@ -0,0 +1,31 @@
1
+ // AttemptError:结构化 error 明细。没有 error 时零输出(docs/feature/reports/library/attempt-detail.md)。
2
+ // 字段标签是低层技术标识,与终端 `niceeval show` 一样保持英文,不进 view 的 i18n 词典。
3
+
4
+ import type { ReactElement } from "react";
5
+ import { Fragment } from "react";
6
+ import type { AttemptErrorData } from "../../model/types.ts";
7
+ import { cx } from "../shared.ts";
8
+
9
+ export function AttemptError({ data, className }: { data: AttemptErrorData | null; className?: string }): ReactElement | null {
10
+ if (data === null) return null;
11
+ const rows: [string, string][] = [
12
+ ["phase", data.phase],
13
+ ["code", data.code],
14
+ ["message", data.message],
15
+ ];
16
+ if (data.cause) rows.push(["cause", data.cause.name ? `${data.cause.name} · ${data.cause.message}` : data.cause.message]);
17
+ const stack = data.stack?.replace(/\n+$/, "") ?? "";
18
+ return (
19
+ <div className={cx("nre", "nre-attempt-error", className)}>
20
+ <dl className="nre-attempt-error-fields">
21
+ {rows.map(([k, v]) => (
22
+ <Fragment key={k}>
23
+ <dt>{k}</dt>
24
+ <dd>{v}</dd>
25
+ </Fragment>
26
+ ))}
27
+ </dl>
28
+ {stack ? <pre className="nre-attempt-error-stack">{stack}</pre> : null}
29
+ </div>
30
+ );
31
+ }
@@ -0,0 +1,26 @@
1
+ // AttemptFixPrompt:单条 attempt 的复制修复 prompt。passed 或没有可操作失败时零输出
2
+ // (docs/feature/reports/library/attempt-detail.md)。与 CopyFixPrompt 同一套增强约定:
3
+ // prompt 在 resolve 阶段算好、烘进静态 HTML,复制按钮是 enhance.js 的增强行为。
4
+
5
+ import type { ReactElement } from "react";
6
+ import type { AttemptFixPromptData } from "../../model/types.ts";
7
+ import { cx } from "../shared.ts";
8
+
9
+ export function AttemptFixPrompt({
10
+ data,
11
+ className,
12
+ }: {
13
+ data: AttemptFixPromptData | null;
14
+ className?: string;
15
+ }): ReactElement | null {
16
+ if (data === null) return null;
17
+ return (
18
+ <details className={cx("nre", "nre-attempt-fix-prompt", className)}>
19
+ <summary className="nre-attempt-fix-prompt-summary">Fix prompt</summary>
20
+ <button type="button" className="nre-attempt-fix-prompt-copy" data-nre-copy={data.prompt}>
21
+ Copy fix prompt
22
+ </button>
23
+ <pre className="nre-attempt-fix-prompt-text">{data.prompt}</pre>
24
+ </details>
25
+ );
26
+ }
@@ -0,0 +1,80 @@
1
+ // AttemptSource:带 send / assertion 标注的 eval 源码;行内展开 assertion 细节。
2
+ // 没有 source 时零输出(docs/feature/reports/library/attempt-detail.md)。send 标注只是
3
+ // 指向 AttemptConversation 完整回复的指针(status/耗时),不复制轮内内容——区块按事实
4
+ // 边界拆分,同一批事实不在两个组件里各展一份。
5
+
6
+ import type { ReactElement } from "react";
7
+ import type { AttemptSourceData } from "../../model/types.ts";
8
+ import type { AssertionResult } from "../../../types.ts";
9
+ import { cx } from "../shared.ts";
10
+
11
+ function assertTone(a: AssertionResult): "good" | "warn" | "bad" | "na" {
12
+ if (a.outcome === "unavailable") return "na";
13
+ if (a.outcome === "passed") return "good";
14
+ return a.severity === "soft" ? "warn" : "bad";
15
+ }
16
+
17
+ export function AttemptSource({ data, className }: { data: AttemptSourceData | null; className?: string }): ReactElement | null {
18
+ if (data === null) return null;
19
+ return (
20
+ <div className={cx("nre", "nre-attempt-source", className)}>
21
+ <div className="nre-attempt-source-head">{data.sourcePath}</div>
22
+ <div className="nre-attempt-source-lines">
23
+ {data.lines.map((line) => {
24
+ const hasAsserts = line.assertions.length > 0;
25
+ const hasSends = line.sends.length > 0;
26
+ const worstTone = hasAsserts
27
+ ? line.assertions.some((a) => assertTone(a) === "bad")
28
+ ? "bad"
29
+ : line.assertions.some((a) => assertTone(a) === "warn")
30
+ ? "warn"
31
+ : line.assertions.some((a) => assertTone(a) === "na")
32
+ ? "na"
33
+ : "good"
34
+ : undefined;
35
+ return (
36
+ <details
37
+ key={line.line}
38
+ className={cx("nre-source-line", worstTone ? `nre-tone-${worstTone}` : undefined, hasSends ? "nre-source-line-send" : undefined)}
39
+ open={hasAsserts && (worstTone === "bad" || worstTone === "warn")}
40
+ >
41
+ <summary>
42
+ <span className="nre-source-ln">{line.line}</span>
43
+ <code className="nre-source-text">{line.text}</code>
44
+ {hasSends ? <span className="nre-source-send-mark">↳ {line.sends.map((s) => s.label).join(", ")}</span> : null}
45
+ </summary>
46
+ {hasAsserts ? (
47
+ <div className="nre-source-line-detail">
48
+ {line.assertions.map((a, i) => (
49
+ <div key={i} className={`nre-assertion-row nre-tone-${assertTone(a)}`}>
50
+ <span className="nre-assertion-name">{a.name}</span>
51
+ {a.outcome === "unavailable" ? (
52
+ <span>{a.reason}</span>
53
+ ) : (
54
+ <>
55
+ {a.expected !== undefined ? <span>expected: {a.expected}</span> : null}
56
+ {a.received !== undefined ? <span>received: {a.received}</span> : null}
57
+ </>
58
+ )}
59
+ </div>
60
+ ))}
61
+ </div>
62
+ ) : null}
63
+ </details>
64
+ );
65
+ })}
66
+ </div>
67
+ {data.unmapped.length > 0 ? (
68
+ <div className="nre-attempt-source-unmapped">
69
+ <div className="nre-attempt-source-unmapped-head">Other assertions</div>
70
+ {data.unmapped.map((a, i) => (
71
+ <div key={i} className={`nre-assertion-row nre-tone-${assertTone(a)}`}>
72
+ {a.groupPath?.length ? `${a.groupPath.join(" > ")} · ` : ""}
73
+ {a.name}
74
+ </div>
75
+ ))}
76
+ </div>
77
+ ) : null}
78
+ </div>
79
+ );
80
+ }
@@ -0,0 +1,74 @@
1
+ // AttemptSummary:恒非空的身份/verdict/时间/成本卡(docs/feature/reports/library/attempt-detail.md)。
2
+
3
+ import type { ReactElement } from "react";
4
+ import type { AttemptSummaryData } from "../../model/types.ts";
5
+ import { DEFAULT_REPORT_LOCALE, localeText, type ReportLocale } from "../../model/locale.ts";
6
+ import { cx } from "../shared.ts";
7
+
8
+ const CAPABILITY_LABEL: Record<keyof AttemptSummaryData["capabilities"], string> = {
9
+ source: "source",
10
+ execution: "execution",
11
+ timing: "timing",
12
+ diff: "diff",
13
+ };
14
+
15
+ export function AttemptSummary({
16
+ data,
17
+ locale = DEFAULT_REPORT_LOCALE,
18
+ className,
19
+ }: {
20
+ data: AttemptSummaryData;
21
+ locale?: ReportLocale;
22
+ className?: string;
23
+ }): ReactElement {
24
+ const caps = (Object.keys(data.capabilities) as (keyof AttemptSummaryData["capabilities"])[]).filter(
25
+ (k) => data.capabilities[k],
26
+ );
27
+ return (
28
+ <div className={cx("nre", "nre-attempt-summary", className)}>
29
+ <div className="nre-attempt-summary-head">
30
+ <span className={`nre-verdict-pill nre-verdict-${data.verdict}`}>{localeText(locale, `verdict.${data.verdict}`)}</span>
31
+ <span className="nre-attempt-summary-locator">{data.locator}</span>
32
+ </div>
33
+ <dl className="nre-attempt-summary-kpis">
34
+ <div>
35
+ <dt>Experiment</dt>
36
+ <dd>{data.identity.experimentId}</dd>
37
+ </div>
38
+ <div>
39
+ <dt>Eval</dt>
40
+ <dd>{data.identity.evalId}</dd>
41
+ </div>
42
+ <div>
43
+ <dt>Attempt</dt>
44
+ <dd>{data.identity.attempt + 1}</dd>
45
+ </div>
46
+ {data.startedAt ? (
47
+ <div>
48
+ <dt>Started</dt>
49
+ <dd>{data.startedAt}</dd>
50
+ </div>
51
+ ) : null}
52
+ <div>
53
+ <dt>Duration</dt>
54
+ <dd>{formatDurationMs(data.durationMs)}</dd>
55
+ </div>
56
+ {data.costUSD !== null ? (
57
+ <div>
58
+ <dt>Cost</dt>
59
+ <dd>${data.costUSD.toFixed(4)}</dd>
60
+ </div>
61
+ ) : null}
62
+ </dl>
63
+ {caps.length > 0 ? (
64
+ <p className="nre-attempt-summary-caps">{caps.map((k) => CAPABILITY_LABEL[k]).join(" · ")}</p>
65
+ ) : null}
66
+ </div>
67
+ );
68
+ }
69
+
70
+ function formatDurationMs(ms: number): string {
71
+ if (ms >= 60_000) return `${Math.floor(ms / 60_000)}m ${Math.round((ms % 60_000) / 1000)}s`;
72
+ if (ms >= 1000) return `${(ms / 1000).toFixed(1)}s`;
73
+ return `${ms}ms`;
74
+ }
@@ -0,0 +1,108 @@
1
+ // AttemptTimeline:runner phases 主链 + 收尾段,children(hook/command/turn)默认收合、
2
+ // 失败节点带标记;turn 节点按 traceId 关联同一轮的 agent/model/tool span。没有 phase 时
3
+ // 零输出(docs/feature/reports/library/attempt-detail.md)。
4
+
5
+ import type { ReactElement } from "react";
6
+ import type { AttemptTimelineData } from "../../model/types.ts";
7
+ import type { TimingNode, TraceSpan } from "../../../types.ts";
8
+ import { formatDurationMs } from "../../model/format.ts";
9
+ import { cx } from "../shared.ts";
10
+
11
+ const CLOSING_PHASES = new Set(["eval.teardown", "agent.teardown", "sandbox.teardown", "sandbox.suspend", "sandbox.stop"]);
12
+
13
+ function TimingNodeRow({ node, trace }: { node: TimingNode; trace: readonly TraceSpan[] | null }): ReactElement {
14
+ const kids = node.children ?? [];
15
+ const spans = node.kind === "turn" && node.traceId && trace ? trace.filter((s) => s.traceId === node.traceId) : [];
16
+ const label = node.kind === "command" && node.command ? `shell · ${node.command.display}` : node.label;
17
+ if (kids.length === 0 && spans.length === 0) {
18
+ return (
19
+ <li className={cx("nre-timeline-node", node.failed ? "nre-timeline-failed" : undefined)}>
20
+ <span title={label}>{label}</span> <span className="nre-timeline-dur">{formatDurationMs(node.durationMs)}</span>
21
+ {node.failed ? " ✗" : ""}
22
+ </li>
23
+ );
24
+ }
25
+ return (
26
+ <li>
27
+ <details open={Boolean(node.failed)}>
28
+ <summary className={cx("nre-timeline-node", node.failed ? "nre-timeline-failed" : undefined)}>
29
+ <span title={label}>{label}</span> <span className="nre-timeline-dur">{formatDurationMs(node.durationMs)}</span>
30
+ {node.failed ? " ✗" : ""}
31
+ </summary>
32
+ {kids.length > 0 ? (
33
+ <ul className="nre-timeline-children">
34
+ {kids.map((child) => (
35
+ <TimingNodeRow key={child.id} node={child} trace={trace} />
36
+ ))}
37
+ </ul>
38
+ ) : null}
39
+ {spans.length > 0 ? (
40
+ <ul className="nre-timeline-spans">
41
+ {spans.map((s) => (
42
+ <li key={s.spanId}>
43
+ {s.kind} · {s.name} · {formatDurationMs(s.endMs - s.startMs)}
44
+ </li>
45
+ ))}
46
+ </ul>
47
+ ) : null}
48
+ </details>
49
+ </li>
50
+ );
51
+ }
52
+
53
+ export function AttemptTimeline({ data, className }: { data: AttemptTimelineData | null; className?: string }): ReactElement | null {
54
+ if (data === null) return null;
55
+ const main = data.phases.filter((p) => !CLOSING_PHASES.has(p.name));
56
+ const closing = data.phases.filter((p) => CLOSING_PHASES.has(p.name));
57
+ const total = main.reduce((sum, p) => sum + p.durationMs, 0);
58
+ const anyFailed = data.phases.some((p) => p.failed);
59
+ return (
60
+ <details className={cx("nre", "nre-attempt-timeline", className)} open={anyFailed}>
61
+ <summary>
62
+ Timing <span className="nre-timeline-dur">{formatDurationMs(total)}</span>
63
+ {anyFailed ? " ✗" : ""}
64
+ </summary>
65
+ <ul className="nre-timeline-phases">
66
+ {main.map((p, i) => {
67
+ const kids = p.children ?? [];
68
+ if (kids.length === 0) {
69
+ return (
70
+ <li key={i} className={cx("nre-timeline-phase", p.failed ? "nre-timeline-failed" : undefined)}>
71
+ {p.name} <span className="nre-timeline-dur">{formatDurationMs(p.durationMs)}</span>
72
+ {p.failed ? " ✗" : ""}
73
+ </li>
74
+ );
75
+ }
76
+ return (
77
+ <li key={i}>
78
+ <details open={Boolean(p.failed)}>
79
+ <summary className={cx("nre-timeline-phase", p.failed ? "nre-timeline-failed" : undefined)}>
80
+ {p.name} <span className="nre-timeline-dur">{formatDurationMs(p.durationMs)}</span>
81
+ {p.failed ? " ✗" : ""}
82
+ </summary>
83
+ <ul className="nre-timeline-children">
84
+ {kids.map((node) => (
85
+ <TimingNodeRow key={node.id} node={node} trace={data.trace} />
86
+ ))}
87
+ </ul>
88
+ </details>
89
+ </li>
90
+ );
91
+ })}
92
+ </ul>
93
+ {closing.length > 0 ? (
94
+ <div className="nre-timeline-closing">
95
+ <div className="nre-timeline-closing-head">teardown</div>
96
+ <ul className="nre-timeline-phases">
97
+ {closing.map((p, i) => (
98
+ <li key={i} className={cx("nre-timeline-phase", p.failed ? "nre-timeline-failed" : undefined)}>
99
+ {p.name} <span className="nre-timeline-dur">{formatDurationMs(p.durationMs)}</span>
100
+ {p.failed ? " ✗" : ""}
101
+ </li>
102
+ ))}
103
+ </ul>
104
+ </div>
105
+ ) : null}
106
+ </details>
107
+ );
108
+ }
@@ -0,0 +1,63 @@
1
+ // AttemptTrace:不与 runner 节点混合的原始 OTel span 树。没有 trace 时零输出
2
+ // (docs/feature/reports/library/attempt-detail.md)。
3
+
4
+ import type { ReactElement } from "react";
5
+ import type { AttemptTraceData } from "../../model/types.ts";
6
+ import type { TraceSpan } from "../../../types.ts";
7
+ import { formatDurationMs } from "../../model/format.ts";
8
+ import { cx } from "../shared.ts";
9
+
10
+ interface SpanNode {
11
+ span: TraceSpan;
12
+ children: SpanNode[];
13
+ }
14
+
15
+ function buildForest(spans: readonly TraceSpan[]): SpanNode[] {
16
+ const byId = new Map<string, SpanNode>(spans.map((s) => [s.spanId, { span: s, children: [] }]));
17
+ const roots: SpanNode[] = [];
18
+ for (const node of byId.values()) {
19
+ const parent = node.span.parentSpanId ? byId.get(node.span.parentSpanId) : undefined;
20
+ if (parent) parent.children.push(node);
21
+ else roots.push(node);
22
+ }
23
+ return roots;
24
+ }
25
+
26
+ function SpanRow({ node }: { node: SpanNode }): ReactElement {
27
+ const failed = node.span.status === "error";
28
+ const body = (
29
+ <>
30
+ <span className={cx("nre-span-kind", node.span.kind ? `nre-span-${node.span.kind}` : undefined)}>{node.span.kind ?? "other"}</span>
31
+ <span title={node.span.name}>{node.span.name}</span>
32
+ <span className="nre-span-dur">{formatDurationMs(node.span.endMs - node.span.startMs)}</span>
33
+ {failed ? " ✗" : ""}
34
+ </>
35
+ );
36
+ if (node.children.length === 0) {
37
+ return <li className="nre-trace-span">{body}</li>;
38
+ }
39
+ return (
40
+ <li>
41
+ <details open={failed}>
42
+ <summary className="nre-trace-span">{body}</summary>
43
+ <ul className="nre-trace-children">
44
+ {node.children.map((child) => (
45
+ <SpanRow key={child.span.spanId} node={child} />
46
+ ))}
47
+ </ul>
48
+ </details>
49
+ </li>
50
+ );
51
+ }
52
+
53
+ export function AttemptTrace({ data, className }: { data: AttemptTraceData | null; className?: string }): ReactElement | null {
54
+ if (data === null) return null;
55
+ const forest = buildForest(data.spans);
56
+ return (
57
+ <ul className={cx("nre", "nre-attempt-trace", className)}>
58
+ {forest.map((node) => (
59
+ <SpanRow key={node.span.spanId} node={node} />
60
+ ))}
61
+ </ul>
62
+ );
63
+ }
@@ -0,0 +1,29 @@
1
+ // AttemptUsage:token / cache token / 成本 / provider usage 明细。没有 usage 时零输出
2
+ // (docs/feature/reports/library/attempt-detail.md)。
3
+
4
+ import type { ReactElement } from "react";
5
+ import type { AttemptUsageData } from "../../model/types.ts";
6
+ import { cx } from "../shared.ts";
7
+
8
+ export function AttemptUsage({ data, className }: { data: AttemptUsageData | null; className?: string }): ReactElement | null {
9
+ if (data === null) return null;
10
+ const { usage } = data;
11
+ const rows: [string, string][] = [
12
+ ["input tokens", usage.inputTokens.toLocaleString()],
13
+ ["output tokens", usage.outputTokens.toLocaleString()],
14
+ ];
15
+ if (usage.cacheReadTokens !== undefined) rows.push(["cache read", usage.cacheReadTokens.toLocaleString()]);
16
+ if (usage.cacheWriteTokens !== undefined) rows.push(["cache write", usage.cacheWriteTokens.toLocaleString()]);
17
+ if (usage.requests !== undefined) rows.push(["requests", String(usage.requests)]);
18
+ if (data.costUSD !== null) rows.push(["cost", `$${data.costUSD.toFixed(4)}`]);
19
+ return (
20
+ <dl className={cx("nre", "nre-attempt-usage", className)}>
21
+ {rows.map(([k, v]) => (
22
+ <div key={k} className="nre-attempt-usage-row">
23
+ <dt>{k}</dt>
24
+ <dd>{v}</dd>
25
+ </div>
26
+ ))}
27
+ </dl>
28
+ );
29
+ }