@opensearch-project/agent-health 0.3.0 → 0.5.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (518) hide show
  1. package/README.md +77 -6
  2. package/cli/dist/index.js +10072 -4502
  3. package/deployment/cloudformation/agent-health-observability.yaml +762 -0
  4. package/dist/assets/index-CCQRDlO0.js +243 -0
  5. package/dist/assets/index-CNHQVbcj.css +1 -0
  6. package/dist/index.html +2 -2
  7. package/docs/ARCHITECTURE.md +450 -0
  8. package/docs/BACKEND_JOB_QUEUE.md +405 -0
  9. package/docs/CLAUDE_CODE_TELEMETRY.md +283 -0
  10. package/docs/CLI.md +431 -0
  11. package/docs/CODING_AGENT_ANALYTICS.md +298 -0
  12. package/docs/CONFIGURATION.md +388 -0
  13. package/docs/CONNECTORS.md +536 -0
  14. package/docs/INSTRUMENT_WITH_OTEL.md +390 -0
  15. package/docs/ML-COMMONS-SETUP.md +289 -0
  16. package/docs/NPX_PACKAGING.md +195 -0
  17. package/docs/PERFORMANCE-MONITORING.md +200 -0
  18. package/docs/PERFORMANCE.md +390 -0
  19. package/docs/PI_PROFILING.md +169 -0
  20. package/docs/PLAN-non-agui-agent-support.md +525 -0
  21. package/docs/SDK.md +577 -0
  22. package/docs/SKILLS.md +264 -0
  23. package/docs/blogs/2026-02-28-opensearch-agent-health.md +200 -0
  24. package/docs/blogs/getting-started-blog.md +608 -0
  25. package/docs/diagrams/Agent-health.excalidraw +5656 -0
  26. package/docs/diagrams/architecture.png +0 -0
  27. package/docs/plans/field-redesign.md +468 -0
  28. package/docs/rfcs/001-coding-agent-analytics.md +374 -0
  29. package/docs/rfcs/002-enterprise-leaderboard.md +267 -0
  30. package/docs/rfcs/003-remote-aggregation.md +146 -0
  31. package/docs/rfcs/004-test-sdk-v2.md +599 -0
  32. package/docs/skills/AGENT_HEALTH.md +598 -0
  33. package/docs/skills/AGENT_PROFILE.md +191 -0
  34. package/docs/skills/add-connector/SKILL.md +68 -0
  35. package/docs/skills/agent-health-profile/SKILL.md +40 -0
  36. package/docs/skills/config-auth/SKILL.md +194 -0
  37. package/docs/skills/config-auth/evals/evals.json +35 -0
  38. package/docs/skills/create-pr/SKILL.md +73 -0
  39. package/docs/skills/instrument-otel/SKILL.md +84 -0
  40. package/docs/skills/write-test/SKILL.md +124 -0
  41. package/docs/ui prd.md +376 -0
  42. package/examples/README.md +53 -0
  43. package/examples/config/agent-health.config.example.ts +155 -0
  44. package/examples/connectors/echo-connector.ts +131 -0
  45. package/examples/eval-files/demo.eval.js +128 -0
  46. package/examples/eval-files/sdk-hooks-demo.eval.js +99 -0
  47. package/examples/pi-profiling/README.md +77 -0
  48. package/examples/pi-profiling/agent-health-profile.ts +417 -0
  49. package/lib/dist/lib/agentUtils.d.ts +29 -0
  50. package/lib/dist/lib/agentUtils.d.ts.map +1 -0
  51. package/lib/dist/lib/agentUtils.js +43 -0
  52. package/lib/dist/lib/agentUtils.js.map +1 -0
  53. package/lib/dist/lib/benchmarkExport.d.ts +14 -0
  54. package/lib/dist/lib/benchmarkExport.d.ts.map +1 -0
  55. package/lib/dist/lib/benchmarkExport.js +41 -0
  56. package/lib/dist/lib/benchmarkExport.js.map +1 -0
  57. package/lib/dist/lib/benchmarkVersionUtils.d.ts +37 -0
  58. package/lib/dist/lib/benchmarkVersionUtils.d.ts.map +1 -0
  59. package/lib/dist/lib/benchmarkVersionUtils.js +68 -0
  60. package/lib/dist/lib/benchmarkVersionUtils.js.map +1 -0
  61. package/lib/dist/lib/config/defineConfig.d.ts +27 -0
  62. package/lib/dist/lib/config/defineConfig.d.ts.map +1 -0
  63. package/lib/dist/lib/config/defineConfig.js +28 -0
  64. package/lib/dist/lib/config/defineConfig.js.map +1 -0
  65. package/lib/dist/lib/config/index.d.ts +9 -0
  66. package/lib/dist/lib/config/index.d.ts.map +1 -0
  67. package/lib/dist/lib/config/index.js +8 -0
  68. package/lib/dist/lib/config/index.js.map +1 -0
  69. package/lib/dist/lib/config/loader.d.ts +39 -0
  70. package/lib/dist/lib/config/loader.d.ts.map +1 -0
  71. package/lib/dist/lib/config/loader.js +258 -0
  72. package/lib/dist/lib/config/loader.js.map +1 -0
  73. package/lib/dist/lib/config/statePaths.d.ts +61 -0
  74. package/lib/dist/lib/config/statePaths.d.ts.map +1 -0
  75. package/lib/dist/lib/config/statePaths.js +188 -0
  76. package/lib/dist/lib/config/statePaths.js.map +1 -0
  77. package/lib/dist/lib/config/types.d.ts +231 -0
  78. package/lib/dist/lib/config/types.d.ts.map +1 -0
  79. package/lib/dist/lib/config/types.js +6 -0
  80. package/lib/dist/lib/config/types.js.map +1 -0
  81. package/lib/dist/lib/config.d.ts +39 -0
  82. package/lib/dist/lib/config.d.ts.map +1 -0
  83. package/lib/dist/lib/config.js +118 -0
  84. package/lib/dist/lib/config.js.map +1 -0
  85. package/lib/dist/lib/constants.d.ts +70 -0
  86. package/lib/dist/lib/constants.d.ts.map +1 -0
  87. package/lib/dist/lib/constants.js +365 -0
  88. package/lib/dist/lib/constants.js.map +1 -0
  89. package/lib/dist/lib/contextUtilization.d.ts +23 -0
  90. package/lib/dist/lib/contextUtilization.d.ts.map +1 -0
  91. package/lib/dist/lib/contextUtilization.js +72 -0
  92. package/lib/dist/lib/contextUtilization.js.map +1 -0
  93. package/lib/dist/lib/dashboardMetrics.d.ts +87 -0
  94. package/lib/dist/lib/dashboardMetrics.d.ts.map +1 -0
  95. package/lib/dist/lib/dashboardMetrics.js +242 -0
  96. package/lib/dist/lib/dashboardMetrics.js.map +1 -0
  97. package/lib/dist/lib/dataSourceConfig.d.ts +108 -0
  98. package/lib/dist/lib/dataSourceConfig.d.ts.map +1 -0
  99. package/lib/dist/lib/dataSourceConfig.js +166 -0
  100. package/lib/dist/lib/dataSourceConfig.js.map +1 -0
  101. package/lib/dist/lib/debug.d.ts +26 -0
  102. package/lib/dist/lib/debug.d.ts.map +1 -0
  103. package/lib/dist/lib/debug.js +132 -0
  104. package/lib/dist/lib/debug.js.map +1 -0
  105. package/lib/dist/lib/diagnostics.d.ts +28 -0
  106. package/lib/dist/lib/diagnostics.d.ts.map +1 -0
  107. package/lib/dist/lib/diagnostics.js +65 -0
  108. package/lib/dist/lib/diagnostics.js.map +1 -0
  109. package/lib/dist/lib/envCompat.d.ts +27 -0
  110. package/lib/dist/lib/envCompat.d.ts.map +1 -0
  111. package/lib/dist/lib/envCompat.js +73 -0
  112. package/lib/dist/lib/envCompat.js.map +1 -0
  113. package/lib/dist/lib/findPackageRoot.d.ts +7 -0
  114. package/lib/dist/lib/findPackageRoot.d.ts.map +1 -0
  115. package/lib/dist/lib/findPackageRoot.js +57 -0
  116. package/lib/dist/lib/findPackageRoot.js.map +1 -0
  117. package/lib/dist/lib/hooks.d.ts +36 -0
  118. package/lib/dist/lib/hooks.d.ts.map +1 -0
  119. package/lib/dist/lib/hooks.js +112 -0
  120. package/lib/dist/lib/hooks.js.map +1 -0
  121. package/lib/dist/lib/index.d.ts +47 -0
  122. package/lib/dist/lib/index.d.ts.map +1 -0
  123. package/lib/dist/lib/index.js +62 -0
  124. package/lib/dist/lib/index.js.map +1 -0
  125. package/lib/dist/lib/labels.d.ts +90 -0
  126. package/lib/dist/lib/labels.d.ts.map +1 -0
  127. package/lib/dist/lib/labels.js +158 -0
  128. package/lib/dist/lib/labels.js.map +1 -0
  129. package/lib/dist/lib/markdown.d.ts +16 -0
  130. package/lib/dist/lib/markdown.d.ts.map +1 -0
  131. package/lib/dist/lib/markdown.js +42 -0
  132. package/lib/dist/lib/markdown.js.map +1 -0
  133. package/lib/dist/lib/matchers/expect.d.ts +3 -0
  134. package/lib/dist/lib/matchers/expect.d.ts.map +1 -0
  135. package/lib/dist/lib/matchers/expect.js +225 -0
  136. package/lib/dist/lib/matchers/expect.js.map +1 -0
  137. package/lib/dist/lib/matchers/index.d.ts +8 -0
  138. package/lib/dist/lib/matchers/index.d.ts.map +1 -0
  139. package/lib/dist/lib/matchers/index.js +9 -0
  140. package/lib/dist/lib/matchers/index.js.map +1 -0
  141. package/lib/dist/lib/matchers/judgeAccessor.d.ts +113 -0
  142. package/lib/dist/lib/matchers/judgeAccessor.d.ts.map +1 -0
  143. package/lib/dist/lib/matchers/judgeAccessor.js +183 -0
  144. package/lib/dist/lib/matchers/judgeAccessor.js.map +1 -0
  145. package/lib/dist/lib/matchers/session.d.ts +39 -0
  146. package/lib/dist/lib/matchers/session.d.ts.map +1 -0
  147. package/lib/dist/lib/matchers/session.js +116 -0
  148. package/lib/dist/lib/matchers/session.js.map +1 -0
  149. package/lib/dist/lib/matchers/traces.d.ts +55 -0
  150. package/lib/dist/lib/matchers/traces.d.ts.map +1 -0
  151. package/lib/dist/lib/matchers/traces.js +116 -0
  152. package/lib/dist/lib/matchers/traces.js.map +1 -0
  153. package/lib/dist/lib/matchers/types.d.ts +75 -0
  154. package/lib/dist/lib/matchers/types.d.ts.map +1 -0
  155. package/lib/dist/lib/matchers/types.js +6 -0
  156. package/lib/dist/lib/matchers/types.js.map +1 -0
  157. package/lib/dist/lib/packagePaths.d.ts +29 -0
  158. package/lib/dist/lib/packagePaths.d.ts.map +1 -0
  159. package/lib/dist/lib/packagePaths.js +63 -0
  160. package/lib/dist/lib/packagePaths.js.map +1 -0
  161. package/lib/dist/lib/performance.d.ts +51 -0
  162. package/lib/dist/lib/performance.d.ts.map +1 -0
  163. package/lib/dist/lib/performance.js +159 -0
  164. package/lib/dist/lib/performance.js.map +1 -0
  165. package/lib/dist/lib/portConfig.d.ts +29 -0
  166. package/lib/dist/lib/portConfig.d.ts.map +1 -0
  167. package/lib/dist/lib/portConfig.js +64 -0
  168. package/lib/dist/lib/portConfig.js.map +1 -0
  169. package/lib/dist/lib/preferences.d.ts +63 -0
  170. package/lib/dist/lib/preferences.d.ts.map +1 -0
  171. package/lib/dist/lib/preferences.js +117 -0
  172. package/lib/dist/lib/preferences.js.map +1 -0
  173. package/lib/dist/lib/resolveAgentModel.d.ts +22 -0
  174. package/lib/dist/lib/resolveAgentModel.d.ts.map +1 -0
  175. package/lib/dist/lib/resolveAgentModel.js +37 -0
  176. package/lib/dist/lib/resolveAgentModel.js.map +1 -0
  177. package/lib/dist/lib/runStats.d.ts +92 -0
  178. package/lib/dist/lib/runStats.d.ts.map +1 -0
  179. package/lib/dist/lib/runStats.js +160 -0
  180. package/lib/dist/lib/runStats.js.map +1 -0
  181. package/lib/dist/lib/telemetry/constants.d.ts +60 -0
  182. package/lib/dist/lib/telemetry/constants.d.ts.map +1 -0
  183. package/lib/dist/lib/telemetry/constants.js +87 -0
  184. package/lib/dist/lib/telemetry/constants.js.map +1 -0
  185. package/lib/dist/lib/telemetry/evalSpans.d.ts +61 -0
  186. package/lib/dist/lib/telemetry/evalSpans.d.ts.map +1 -0
  187. package/lib/dist/lib/telemetry/evalSpans.js +254 -0
  188. package/lib/dist/lib/telemetry/evalSpans.js.map +1 -0
  189. package/lib/dist/lib/telemetry/index.d.ts +11 -0
  190. package/lib/dist/lib/telemetry/index.d.ts.map +1 -0
  191. package/lib/dist/lib/telemetry/index.js +15 -0
  192. package/lib/dist/lib/telemetry/index.js.map +1 -0
  193. package/lib/dist/lib/telemetry/opensearchExporter.d.ts +43 -0
  194. package/lib/dist/lib/telemetry/opensearchExporter.d.ts.map +1 -0
  195. package/lib/dist/lib/telemetry/opensearchExporter.js +217 -0
  196. package/lib/dist/lib/telemetry/opensearchExporter.js.map +1 -0
  197. package/lib/dist/lib/telemetry/provider.d.ts +55 -0
  198. package/lib/dist/lib/telemetry/provider.d.ts.map +1 -0
  199. package/lib/dist/lib/telemetry/provider.js +140 -0
  200. package/lib/dist/lib/telemetry/provider.js.map +1 -0
  201. package/lib/dist/lib/testCaseLabels.d.ts +34 -0
  202. package/lib/dist/lib/testCaseLabels.d.ts.map +1 -0
  203. package/lib/dist/lib/testCaseLabels.js +88 -0
  204. package/lib/dist/lib/testCaseLabels.js.map +1 -0
  205. package/lib/dist/lib/testCaseValidation.d.ts +140 -0
  206. package/lib/dist/lib/testCaseValidation.d.ts.map +1 -0
  207. package/lib/dist/lib/testCaseValidation.js +162 -0
  208. package/lib/dist/lib/testCaseValidation.js.map +1 -0
  209. package/lib/dist/lib/testCases/agentFixture.d.ts +80 -0
  210. package/lib/dist/lib/testCases/agentFixture.d.ts.map +1 -0
  211. package/lib/dist/lib/testCases/agentFixture.js +43 -0
  212. package/lib/dist/lib/testCases/agentFixture.js.map +1 -0
  213. package/lib/dist/lib/testCases/authoringSurface.d.ts +10 -0
  214. package/lib/dist/lib/testCases/authoringSurface.d.ts.map +1 -0
  215. package/lib/dist/lib/testCases/authoringSurface.js +54 -0
  216. package/lib/dist/lib/testCases/authoringSurface.js.map +1 -0
  217. package/lib/dist/lib/testCases/codemod.d.ts +13 -0
  218. package/lib/dist/lib/testCases/codemod.d.ts.map +1 -0
  219. package/lib/dist/lib/testCases/codemod.js +169 -0
  220. package/lib/dist/lib/testCases/codemod.js.map +1 -0
  221. package/lib/dist/lib/testCases/define.d.ts +114 -0
  222. package/lib/dist/lib/testCases/define.d.ts.map +1 -0
  223. package/lib/dist/lib/testCases/define.js +253 -0
  224. package/lib/dist/lib/testCases/define.js.map +1 -0
  225. package/lib/dist/lib/testCases/evaluators.d.ts +80 -0
  226. package/lib/dist/lib/testCases/evaluators.d.ts.map +1 -0
  227. package/lib/dist/lib/testCases/evaluators.js +105 -0
  228. package/lib/dist/lib/testCases/evaluators.js.map +1 -0
  229. package/lib/dist/lib/testCases/index.d.ts +14 -0
  230. package/lib/dist/lib/testCases/index.d.ts.map +1 -0
  231. package/lib/dist/lib/testCases/index.js +12 -0
  232. package/lib/dist/lib/testCases/index.js.map +1 -0
  233. package/lib/dist/lib/testCases/judge.d.ts +165 -0
  234. package/lib/dist/lib/testCases/judge.d.ts.map +1 -0
  235. package/lib/dist/lib/testCases/judge.js +359 -0
  236. package/lib/dist/lib/testCases/judge.js.map +1 -0
  237. package/lib/dist/lib/testCases/loader.d.ts +26 -0
  238. package/lib/dist/lib/testCases/loader.d.ts.map +1 -0
  239. package/lib/dist/lib/testCases/loader.js +149 -0
  240. package/lib/dist/lib/testCases/loader.js.map +1 -0
  241. package/lib/dist/lib/testCases/types.d.ts +242 -0
  242. package/lib/dist/lib/testCases/types.d.ts.map +1 -0
  243. package/lib/dist/lib/testCases/types.js +6 -0
  244. package/lib/dist/lib/testCases/types.js.map +1 -0
  245. package/lib/dist/lib/theme.d.ts +6 -0
  246. package/lib/dist/lib/theme.d.ts.map +1 -0
  247. package/lib/dist/lib/theme.js +36 -0
  248. package/lib/dist/lib/theme.js.map +1 -0
  249. package/lib/dist/lib/uiTelemetry.d.ts +7 -0
  250. package/lib/dist/lib/uiTelemetry.d.ts.map +1 -0
  251. package/lib/dist/lib/uiTelemetry.js +25 -0
  252. package/lib/dist/lib/uiTelemetry.js.map +1 -0
  253. package/lib/dist/lib/utils.d.ts +96 -0
  254. package/lib/dist/lib/utils.d.ts.map +1 -0
  255. package/lib/dist/lib/utils.js +232 -0
  256. package/lib/dist/lib/utils.js.map +1 -0
  257. package/lib/dist/lib/workflow/consolidate.d.ts +12 -0
  258. package/lib/dist/lib/workflow/consolidate.d.ts.map +1 -0
  259. package/lib/dist/lib/workflow/consolidate.js +33 -0
  260. package/lib/dist/lib/workflow/consolidate.js.map +1 -0
  261. package/lib/dist/lib/workflow/index.d.ts +13 -0
  262. package/lib/dist/lib/workflow/index.d.ts.map +1 -0
  263. package/lib/dist/lib/workflow/index.js +12 -0
  264. package/lib/dist/lib/workflow/index.js.map +1 -0
  265. package/lib/dist/lib/workflow/ledger.d.ts +30 -0
  266. package/lib/dist/lib/workflow/ledger.d.ts.map +1 -0
  267. package/lib/dist/lib/workflow/ledger.js +41 -0
  268. package/lib/dist/lib/workflow/ledger.js.map +1 -0
  269. package/lib/dist/lib/workflow/pool.d.ts +13 -0
  270. package/lib/dist/lib/workflow/pool.d.ts.map +1 -0
  271. package/lib/dist/lib/workflow/pool.js +44 -0
  272. package/lib/dist/lib/workflow/pool.js.map +1 -0
  273. package/lib/dist/lib/workflow/source.d.ts +22 -0
  274. package/lib/dist/lib/workflow/source.d.ts.map +1 -0
  275. package/lib/dist/lib/workflow/source.js +29 -0
  276. package/lib/dist/lib/workflow/source.js.map +1 -0
  277. package/lib/dist/lib/workflow/stepB.d.ts +71 -0
  278. package/lib/dist/lib/workflow/stepB.d.ts.map +1 -0
  279. package/lib/dist/lib/workflow/stepB.js +99 -0
  280. package/lib/dist/lib/workflow/stepB.js.map +1 -0
  281. package/lib/dist/lib/workflow/types.d.ts +86 -0
  282. package/lib/dist/lib/workflow/types.d.ts.map +1 -0
  283. package/lib/dist/lib/workflow/types.js +6 -0
  284. package/lib/dist/lib/workflow/types.js.map +1 -0
  285. package/lib/dist/lib/workflow/workflow.d.ts +119 -0
  286. package/lib/dist/lib/workflow/workflow.d.ts.map +1 -0
  287. package/lib/dist/lib/workflow/workflow.js +195 -0
  288. package/lib/dist/lib/workflow/workflow.js.map +1 -0
  289. package/lib/dist/services/agent/aguiConverter.d.ts +50 -0
  290. package/lib/dist/services/agent/aguiConverter.d.ts.map +1 -0
  291. package/lib/dist/services/agent/aguiConverter.js +449 -0
  292. package/lib/dist/services/agent/aguiConverter.js.map +1 -0
  293. package/lib/dist/services/agent/index.d.ts +10 -0
  294. package/lib/dist/services/agent/index.d.ts.map +1 -0
  295. package/lib/dist/services/agent/index.js +12 -0
  296. package/lib/dist/services/agent/index.js.map +1 -0
  297. package/lib/dist/services/agent/payloadBuilder.d.ts +33 -0
  298. package/lib/dist/services/agent/payloadBuilder.d.ts.map +1 -0
  299. package/lib/dist/services/agent/payloadBuilder.js +75 -0
  300. package/lib/dist/services/agent/payloadBuilder.js.map +1 -0
  301. package/lib/dist/services/agent/sseStream.d.ts +43 -0
  302. package/lib/dist/services/agent/sseStream.d.ts.map +1 -0
  303. package/lib/dist/services/agent/sseStream.js +223 -0
  304. package/lib/dist/services/agent/sseStream.js.map +1 -0
  305. package/lib/dist/services/connectors/agui/AGUIStreamingConnector.d.ts +44 -0
  306. package/lib/dist/services/connectors/agui/AGUIStreamingConnector.d.ts.map +1 -0
  307. package/lib/dist/services/connectors/agui/AGUIStreamingConnector.js +95 -0
  308. package/lib/dist/services/connectors/agui/AGUIStreamingConnector.js.map +1 -0
  309. package/lib/dist/services/connectors/base/BaseConnector.d.ts +81 -0
  310. package/lib/dist/services/connectors/base/BaseConnector.d.ts.map +1 -0
  311. package/lib/dist/services/connectors/base/BaseConnector.js +170 -0
  312. package/lib/dist/services/connectors/base/BaseConnector.js.map +1 -0
  313. package/lib/dist/services/connectors/claude-code/ClaudeCodeConnector.d.ts +116 -0
  314. package/lib/dist/services/connectors/claude-code/ClaudeCodeConnector.d.ts.map +1 -0
  315. package/lib/dist/services/connectors/claude-code/ClaudeCodeConnector.js +403 -0
  316. package/lib/dist/services/connectors/claude-code/ClaudeCodeConnector.js.map +1 -0
  317. package/lib/dist/services/connectors/index.d.ts +13 -0
  318. package/lib/dist/services/connectors/index.d.ts.map +1 -0
  319. package/lib/dist/services/connectors/index.js +32 -0
  320. package/lib/dist/services/connectors/index.js.map +1 -0
  321. package/lib/dist/services/connectors/kiro/KiroConnector.d.ts +48 -0
  322. package/lib/dist/services/connectors/kiro/KiroConnector.d.ts.map +1 -0
  323. package/lib/dist/services/connectors/kiro/KiroConnector.js +158 -0
  324. package/lib/dist/services/connectors/kiro/KiroConnector.js.map +1 -0
  325. package/lib/dist/services/connectors/langgraph/LangGraphConnector.d.ts +36 -0
  326. package/lib/dist/services/connectors/langgraph/LangGraphConnector.d.ts.map +1 -0
  327. package/lib/dist/services/connectors/langgraph/LangGraphConnector.js +175 -0
  328. package/lib/dist/services/connectors/langgraph/LangGraphConnector.js.map +1 -0
  329. package/lib/dist/services/connectors/mock/MockConnector.d.ts +37 -0
  330. package/lib/dist/services/connectors/mock/MockConnector.d.ts.map +1 -0
  331. package/lib/dist/services/connectors/mock/MockConnector.js +120 -0
  332. package/lib/dist/services/connectors/mock/MockConnector.js.map +1 -0
  333. package/lib/dist/services/connectors/openai-compatible/OpenAICompatibleConnector.d.ts +42 -0
  334. package/lib/dist/services/connectors/openai-compatible/OpenAICompatibleConnector.d.ts.map +1 -0
  335. package/lib/dist/services/connectors/openai-compatible/OpenAICompatibleConnector.js +133 -0
  336. package/lib/dist/services/connectors/openai-compatible/OpenAICompatibleConnector.js.map +1 -0
  337. package/lib/dist/services/connectors/pi/PiConnector.d.ts +87 -0
  338. package/lib/dist/services/connectors/pi/PiConnector.d.ts.map +1 -0
  339. package/lib/dist/services/connectors/pi/PiConnector.js +274 -0
  340. package/lib/dist/services/connectors/pi/PiConnector.js.map +1 -0
  341. package/lib/dist/services/connectors/registry.d.ts +57 -0
  342. package/lib/dist/services/connectors/registry.d.ts.map +1 -0
  343. package/lib/dist/services/connectors/registry.js +106 -0
  344. package/lib/dist/services/connectors/registry.js.map +1 -0
  345. package/lib/dist/services/connectors/rest/RESTConnector.d.ts +38 -0
  346. package/lib/dist/services/connectors/rest/RESTConnector.d.ts.map +1 -0
  347. package/lib/dist/services/connectors/rest/RESTConnector.js +117 -0
  348. package/lib/dist/services/connectors/rest/RESTConnector.js.map +1 -0
  349. package/lib/dist/services/connectors/server.d.ts +13 -0
  350. package/lib/dist/services/connectors/server.d.ts.map +1 -0
  351. package/lib/dist/services/connectors/server.js +34 -0
  352. package/lib/dist/services/connectors/server.js.map +1 -0
  353. package/lib/dist/services/connectors/strands/StrandsConnector.d.ts +48 -0
  354. package/lib/dist/services/connectors/strands/StrandsConnector.d.ts.map +1 -0
  355. package/lib/dist/services/connectors/strands/StrandsConnector.js +221 -0
  356. package/lib/dist/services/connectors/strands/StrandsConnector.js.map +1 -0
  357. package/lib/dist/services/connectors/subprocess/SubprocessConnector.d.ts +88 -0
  358. package/lib/dist/services/connectors/subprocess/SubprocessConnector.d.ts.map +1 -0
  359. package/lib/dist/services/connectors/subprocess/SubprocessConnector.js +418 -0
  360. package/lib/dist/services/connectors/subprocess/SubprocessConnector.js.map +1 -0
  361. package/lib/dist/services/connectors/types.d.ts +213 -0
  362. package/lib/dist/services/connectors/types.d.ts.map +1 -0
  363. package/lib/dist/services/connectors/types.js +6 -0
  364. package/lib/dist/services/connectors/types.js.map +1 -0
  365. package/lib/dist/services/evaluation/bedrockJudge.d.ts +64 -0
  366. package/lib/dist/services/evaluation/bedrockJudge.d.ts.map +1 -0
  367. package/lib/dist/services/evaluation/bedrockJudge.js +167 -0
  368. package/lib/dist/services/evaluation/bedrockJudge.js.map +1 -0
  369. package/lib/dist/services/evaluation/evaluatorError.d.ts +56 -0
  370. package/lib/dist/services/evaluation/evaluatorError.d.ts.map +1 -0
  371. package/lib/dist/services/evaluation/evaluatorError.js +56 -0
  372. package/lib/dist/services/evaluation/evaluatorError.js.map +1 -0
  373. package/lib/dist/services/evaluation/index.d.ts +106 -0
  374. package/lib/dist/services/evaluation/index.d.ts.map +1 -0
  375. package/lib/dist/services/evaluation/index.js +684 -0
  376. package/lib/dist/services/evaluation/index.js.map +1 -0
  377. package/lib/dist/services/evaluation/mockTrajectory.d.ts +3 -0
  378. package/lib/dist/services/evaluation/mockTrajectory.d.ts.map +1 -0
  379. package/lib/dist/services/evaluation/mockTrajectory.js +72 -0
  380. package/lib/dist/services/evaluation/mockTrajectory.js.map +1 -0
  381. package/lib/dist/services/opensearch/client.d.ts +26 -0
  382. package/lib/dist/services/opensearch/client.d.ts.map +1 -0
  383. package/lib/dist/services/opensearch/client.js +131 -0
  384. package/lib/dist/services/opensearch/client.js.map +1 -0
  385. package/lib/dist/services/opensearch/index.d.ts +16 -0
  386. package/lib/dist/services/opensearch/index.d.ts.map +1 -0
  387. package/lib/dist/services/opensearch/index.js +25 -0
  388. package/lib/dist/services/opensearch/index.js.map +1 -0
  389. package/lib/dist/services/storage/asyncBenchmarkStorage.d.ts +123 -0
  390. package/lib/dist/services/storage/asyncBenchmarkStorage.d.ts.map +1 -0
  391. package/lib/dist/services/storage/asyncBenchmarkStorage.js +429 -0
  392. package/lib/dist/services/storage/asyncBenchmarkStorage.js.map +1 -0
  393. package/lib/dist/services/storage/asyncRunStorage.d.ts +127 -0
  394. package/lib/dist/services/storage/asyncRunStorage.d.ts.map +1 -0
  395. package/lib/dist/services/storage/asyncRunStorage.js +448 -0
  396. package/lib/dist/services/storage/asyncRunStorage.js.map +1 -0
  397. package/lib/dist/services/storage/asyncTestCaseStorage.d.ts +156 -0
  398. package/lib/dist/services/storage/asyncTestCaseStorage.d.ts.map +1 -0
  399. package/lib/dist/services/storage/asyncTestCaseStorage.js +285 -0
  400. package/lib/dist/services/storage/asyncTestCaseStorage.js.map +1 -0
  401. package/lib/dist/services/storage/index.d.ts +17 -0
  402. package/lib/dist/services/storage/index.d.ts.map +1 -0
  403. package/lib/dist/services/storage/index.js +20 -0
  404. package/lib/dist/services/storage/index.js.map +1 -0
  405. package/lib/dist/services/storage/migration.d.ts +54 -0
  406. package/lib/dist/services/storage/migration.d.ts.map +1 -0
  407. package/lib/dist/services/storage/migration.js +296 -0
  408. package/lib/dist/services/storage/migration.js.map +1 -0
  409. package/lib/dist/services/storage/opensearchClient.d.ts +924 -0
  410. package/lib/dist/services/storage/opensearchClient.d.ts.map +1 -0
  411. package/lib/dist/services/storage/opensearchClient.js +435 -0
  412. package/lib/dist/services/storage/opensearchClient.js.map +1 -0
  413. package/lib/dist/services/traces/browserRecovery.d.ts +26 -0
  414. package/lib/dist/services/traces/browserRecovery.d.ts.map +1 -0
  415. package/lib/dist/services/traces/browserRecovery.js +81 -0
  416. package/lib/dist/services/traces/browserRecovery.js.map +1 -0
  417. package/lib/dist/services/traces/categoryStyles.d.ts +21 -0
  418. package/lib/dist/services/traces/categoryStyles.d.ts.map +1 -0
  419. package/lib/dist/services/traces/categoryStyles.js +56 -0
  420. package/lib/dist/services/traces/categoryStyles.js.map +1 -0
  421. package/lib/dist/services/traces/executionOrderTransform.d.ts +35 -0
  422. package/lib/dist/services/traces/executionOrderTransform.d.ts.map +1 -0
  423. package/lib/dist/services/traces/executionOrderTransform.js +313 -0
  424. package/lib/dist/services/traces/executionOrderTransform.js.map +1 -0
  425. package/lib/dist/services/traces/fetchSpansForRun.d.ts +86 -0
  426. package/lib/dist/services/traces/fetchSpansForRun.d.ts.map +1 -0
  427. package/lib/dist/services/traces/fetchSpansForRun.js +69 -0
  428. package/lib/dist/services/traces/fetchSpansForRun.js.map +1 -0
  429. package/lib/dist/services/traces/flowTransform.d.ts +24 -0
  430. package/lib/dist/services/traces/flowTransform.d.ts.map +1 -0
  431. package/lib/dist/services/traces/flowTransform.js +228 -0
  432. package/lib/dist/services/traces/flowTransform.js.map +1 -0
  433. package/lib/dist/services/traces/index.d.ts +121 -0
  434. package/lib/dist/services/traces/index.d.ts.map +1 -0
  435. package/lib/dist/services/traces/index.js +255 -0
  436. package/lib/dist/services/traces/index.js.map +1 -0
  437. package/lib/dist/services/traces/intentTransform.d.ts +20 -0
  438. package/lib/dist/services/traces/intentTransform.d.ts.map +1 -0
  439. package/lib/dist/services/traces/intentTransform.js +131 -0
  440. package/lib/dist/services/traces/intentTransform.js.map +1 -0
  441. package/lib/dist/services/traces/judgeAgentsHints.d.ts +63 -0
  442. package/lib/dist/services/traces/judgeAgentsHints.d.ts.map +1 -0
  443. package/lib/dist/services/traces/judgeAgentsHints.js +89 -0
  444. package/lib/dist/services/traces/judgeAgentsHints.js.map +1 -0
  445. package/lib/dist/services/traces/messageExtraction.d.ts +15 -0
  446. package/lib/dist/services/traces/messageExtraction.d.ts.map +1 -0
  447. package/lib/dist/services/traces/messageExtraction.js +251 -0
  448. package/lib/dist/services/traces/messageExtraction.js.map +1 -0
  449. package/lib/dist/services/traces/spanCategorization.d.ts +63 -0
  450. package/lib/dist/services/traces/spanCategorization.d.ts.map +1 -0
  451. package/lib/dist/services/traces/spanCategorization.js +276 -0
  452. package/lib/dist/services/traces/spanCategorization.js.map +1 -0
  453. package/lib/dist/services/traces/spanPreprocessing.d.ts +37 -0
  454. package/lib/dist/services/traces/spanPreprocessing.d.ts.map +1 -0
  455. package/lib/dist/services/traces/spanPreprocessing.js +102 -0
  456. package/lib/dist/services/traces/spanPreprocessing.js.map +1 -0
  457. package/lib/dist/services/traces/spansToTrajectory.d.ts +36 -0
  458. package/lib/dist/services/traces/spansToTrajectory.d.ts.map +1 -0
  459. package/lib/dist/services/traces/spansToTrajectory.js +387 -0
  460. package/lib/dist/services/traces/spansToTrajectory.js.map +1 -0
  461. package/lib/dist/services/traces/toolSimilarity.d.ts +35 -0
  462. package/lib/dist/services/traces/toolSimilarity.d.ts.map +1 -0
  463. package/lib/dist/services/traces/toolSimilarity.js +203 -0
  464. package/lib/dist/services/traces/toolSimilarity.js.map +1 -0
  465. package/lib/dist/services/traces/traceComparison.d.ts +31 -0
  466. package/lib/dist/services/traces/traceComparison.d.ts.map +1 -0
  467. package/lib/dist/services/traces/traceComparison.js +318 -0
  468. package/lib/dist/services/traces/traceComparison.js.map +1 -0
  469. package/lib/dist/services/traces/traceGrouping.d.ts +19 -0
  470. package/lib/dist/services/traces/traceGrouping.d.ts.map +1 -0
  471. package/lib/dist/services/traces/traceGrouping.js +107 -0
  472. package/lib/dist/services/traces/traceGrouping.js.map +1 -0
  473. package/lib/dist/services/traces/tracePoller.d.ts +84 -0
  474. package/lib/dist/services/traces/tracePoller.d.ts.map +1 -0
  475. package/lib/dist/services/traces/tracePoller.js +309 -0
  476. package/lib/dist/services/traces/tracePoller.js.map +1 -0
  477. package/lib/dist/services/traces/traceStats.d.ts +45 -0
  478. package/lib/dist/services/traces/traceStats.d.ts.map +1 -0
  479. package/lib/dist/services/traces/traceStats.js +114 -0
  480. package/lib/dist/services/traces/traceStats.js.map +1 -0
  481. package/lib/dist/services/traces/traceSummary.d.ts +47 -0
  482. package/lib/dist/services/traces/traceSummary.d.ts.map +1 -0
  483. package/lib/dist/services/traces/traceSummary.js +68 -0
  484. package/lib/dist/services/traces/traceSummary.js.map +1 -0
  485. package/lib/dist/services/traces/utils.d.ts +33 -0
  486. package/lib/dist/services/traces/utils.d.ts.map +1 -0
  487. package/lib/dist/services/traces/utils.js +114 -0
  488. package/lib/dist/services/traces/utils.js.map +1 -0
  489. package/lib/dist/types/agui.d.ts +13 -0
  490. package/lib/dist/types/agui.d.ts.map +1 -0
  491. package/lib/dist/types/agui.js +16 -0
  492. package/lib/dist/types/agui.js.map +1 -0
  493. package/lib/dist/types/index.d.ts +1175 -0
  494. package/lib/dist/types/index.d.ts.map +1 -0
  495. package/lib/dist/types/index.js +12 -0
  496. package/lib/dist/types/index.js.map +1 -0
  497. package/lib/dist/types/skills.d.ts +146 -0
  498. package/lib/dist/types/skills.d.ts.map +1 -0
  499. package/lib/dist/types/skills.js +6 -0
  500. package/lib/dist/types/skills.js.map +1 -0
  501. package/observio-sample-agent/pi-package/README.md +112 -0
  502. package/observio-sample-agent/pi-package/extensions/agent-health.ts +373 -0
  503. package/observio-sample-agent/pi-package/package.json +17 -0
  504. package/observio-sample-agent/pi-package/prompts/agent-health.md +37 -0
  505. package/observio-sample-agent/pi-package/skills/create-pr/SKILL.md +88 -0
  506. package/observio-sample-agent/pi-package/skills/fix-bug/SKILL.md +71 -0
  507. package/observio-sample-agent/pi-package/skills/implement-feature/SKILL.md +156 -0
  508. package/observio-sample-agent/pi-package/skills/instrument-otel/SKILL.md +208 -0
  509. package/observio-sample-agent/pi-package/skills/setup-collector/SKILL.md +146 -0
  510. package/observio-sample-agent/pi-package/skills/write-test/SKILL.md +115 -0
  511. package/package.json +64 -13
  512. package/server/dist/app.js +32651 -17637
  513. package/server/dist/index.js +29875 -14638
  514. package/tsconfig.lib.json +71 -0
  515. package/dist/assets/index-EvPLSTAS.js +0 -267
  516. package/dist/assets/index-RXasQKUs.css +0 -1
  517. package/lib/dist/config/index.js +0 -404
  518. package/lib/dist/index.js +0 -1665
@@ -0,0 +1,1175 @@
1
+ import type { Node, Edge } from '@xyflow/react';
2
+ export type Difficulty = 'Easy' | 'Medium' | 'Hard';
3
+ export type DateFormatVariant = 'date' | 'datetime' | 'detailed';
4
+ export type JudgeProvider = 'demo' | 'bedrock' | 'openai-compatible' | 'litellm' | 'claude-code' | 'agentic' | 'pi' | 'agent';
5
+ export interface AssistantMessage {
6
+ role: 'user' | 'assistant';
7
+ content: string;
8
+ timestamp: string;
9
+ }
10
+ export interface AssistantContext {
11
+ currentUrl?: string;
12
+ benchmarkId?: string;
13
+ runId?: string;
14
+ traceId?: string;
15
+ testCaseId?: string;
16
+ /**
17
+ * On comparison pages (`/compare/:benchmarkId?runs=a,b,…`), the list of run
18
+ * IDs the user is currently comparing. The assistant pre-loads these into
19
+ * the grounded snapshot so it can answer cross-run questions even before
20
+ * reaching for tools.
21
+ */
22
+ comparisonRunIds?: string[];
23
+ }
24
+ export type ConnectorProtocol = 'agui-streaming' | 'rest' | 'openai-compatible' | 'subprocess' | 'claude-code' | 'pi' | 'strands' | 'langgraph' | 'mock';
25
+ export interface ModelConfig {
26
+ model_id: string;
27
+ display_name: string;
28
+ provider: JudgeProvider;
29
+ context_window: number;
30
+ max_output_tokens: number;
31
+ }
32
+ export interface BeforeRequestContext {
33
+ endpoint: string;
34
+ payload: any;
35
+ headers: Record<string, string>;
36
+ }
37
+ export interface AfterResponseContext {
38
+ response: any;
39
+ trajectory: TrajectoryStep[];
40
+ runId?: string;
41
+ /** Full array of raw events from the connector (protocol-specific) */
42
+ rawEvents?: any[];
43
+ /** Connector metadata (e.g., threadId, sessionId, exitCode) */
44
+ metadata?: Record<string, any>;
45
+ }
46
+ export interface BuildTrajectoryContext {
47
+ spans: Span[];
48
+ runId: string;
49
+ }
50
+ /**
51
+ * Context passed to a custom judge hook.
52
+ * Contains all data needed for evaluation: trajectory, traces, and expected outcomes.
53
+ * Also provides fetchTraces as an SDK utility for additional trace fetching.
54
+ */
55
+ export interface JudgeContext {
56
+ trajectory: TrajectoryStep[];
57
+ traces: Span[];
58
+ expectedOutcomes: string[];
59
+ expectedTrajectory?: string[];
60
+ runId: string;
61
+ /** SDK utility: fetch traces by run IDs from OpenSearch */
62
+ fetchTraces: (runIds: string[]) => Promise<{
63
+ spans: Span[];
64
+ }>;
65
+ }
66
+ /**
67
+ * Result returned by a custom judge hook.
68
+ */
69
+ export interface JudgeResult {
70
+ passFailStatus: 'passed' | 'failed';
71
+ metrics: {
72
+ accuracy: number;
73
+ faithfulness?: number;
74
+ latency_score?: number;
75
+ trajectory_alignment_score?: number;
76
+ [key: string]: number | undefined;
77
+ };
78
+ llmJudgeReasoning: string;
79
+ improvementStrategies?: string[];
80
+ }
81
+ export interface AgentHooks {
82
+ /**
83
+ * Called before sending request to agent.
84
+ * Use to modify endpoint, payload, or headers.
85
+ */
86
+ beforeRequest?: (context: BeforeRequestContext) => Promise<BeforeRequestContext>;
87
+ /**
88
+ * Called after receiving response from agent.
89
+ * Use to extract runId from custom response formats (e.g., PER memory_id).
90
+ */
91
+ afterResponse?: (context: AfterResponseContext) => Promise<AfterResponseContext>;
92
+ /**
93
+ * Called when building trajectory from OTEL traces.
94
+ * Use to customize trajectory extraction for agents with custom span formats.
95
+ */
96
+ buildTrajectory?: (context: BuildTrajectoryContext) => Promise<TrajectoryStep[]>;
97
+ /**
98
+ * Custom judge hook. When defined, replaces the built-in Bedrock judge.
99
+ * Receives trajectory + traces + expected outcomes, returns pass/fail evaluation.
100
+ *
101
+ * @example
102
+ * ```typescript
103
+ * hooks: {
104
+ * judge: async ({ trajectory, traces, expectedOutcomes, fetchTraces }) => {
105
+ * // Custom evaluation logic using traces
106
+ * const relevantSpans = traces.filter(s => s.attributes?.['gen_ai.system']);
107
+ * return {
108
+ * passFailStatus: relevantSpans.length > 0 ? 'passed' : 'failed',
109
+ * metrics: { accuracy: 85 },
110
+ * llmJudgeReasoning: 'Custom evaluation based on trace analysis',
111
+ * };
112
+ * }
113
+ * }
114
+ * ```
115
+ */
116
+ judge?: (context: JudgeContext) => Promise<JudgeResult>;
117
+ }
118
+ export interface AgentConfig {
119
+ key: string;
120
+ name: string;
121
+ endpoint: string;
122
+ description?: string;
123
+ enabled?: boolean;
124
+ headers?: Record<string, string>;
125
+ auth?: ConnectorAuthConfig;
126
+ useTraces?: boolean;
127
+ /**
128
+ * Configurable trace polling settings (used when `useTraces: true`).
129
+ *
130
+ * Two distinct polling paths honour these values, with different defaults
131
+ * because they have different ergonomic constraints:
132
+ *
133
+ * - **Judge poller** (`services/traces/tracePoller.ts`, runs in the
134
+ * background after the agent finishes, before the LLM judge fires)
135
+ * defaults to `intervalMs: 10000` and `maxAttempts: 60` — a 10-minute
136
+ * total budget that's fine because the user already sees a "pending"
137
+ * badge while it polls.
138
+ * - **SDK pre-load** (`services/traces/fetchSpansForRun.ts`, runs
139
+ * synchronously inside a deterministic test body before the body's
140
+ * first assertion) defaults to `intervalMs: 1000` and `maxAttempts:
141
+ * 10` — a ~10-second total budget so the test isn't blocked.
142
+ *
143
+ * Both paths additionally honour `TRACE_POLL_INTERVAL_MS` and
144
+ * `TRACE_POLL_MAX_ATTEMPTS` env vars (the env vars override the
145
+ * code defaults), and both enforce a hard ceiling of 60 attempts so
146
+ * a misconfigured agent can't lock a test for an unbounded time.
147
+ *
148
+ * Setting either field on this object overrides the path's own default
149
+ * for that specific agent on both paths.
150
+ */
151
+ tracePolling?: {
152
+ intervalMs?: number;
153
+ maxAttempts?: number;
154
+ };
155
+ /**
156
+ * OTel `service.name` resource attribute that this agent reports under.
157
+ * Defaults to {@link AgentConfig.key} when not set, which is correct for
158
+ * agents whose OTel SDK uses the same identifier as the config key (e.g.
159
+ * `claude-code`). Override only when the agent's OTel service name differs
160
+ * from its config key, e.g. `observio` -> `observio-sample-agent`.
161
+ *
162
+ * Used by the Agent Traces page to translate the user's cross-page agent
163
+ * filter (`agent-health:prefs:agentFilter`, which stores agent keys) into
164
+ * the actual `service.name` to filter by in OpenSearch queries.
165
+ */
166
+ traceServiceName?: string;
167
+ connectorType?: ConnectorProtocol;
168
+ connectorConfig?: Record<string, any>;
169
+ hooks?: AgentHooks;
170
+ isCustom?: boolean;
171
+ builtIn?: boolean;
172
+ }
173
+ /**
174
+ * Authentication config for agents (serializable subset of ConnectorAuth).
175
+ * Used in AgentConfig for config files — avoids importing connector types.
176
+ */
177
+ export interface ConnectorAuthConfig {
178
+ type: 'none' | 'basic' | 'bearer' | 'api-key' | 'aws-sigv4';
179
+ username?: string;
180
+ password?: string;
181
+ token?: string;
182
+ awsRegion?: string;
183
+ awsService?: string;
184
+ headers?: Record<string, string>;
185
+ }
186
+ export interface AppConfig {
187
+ agents: AgentConfig[];
188
+ models: Record<string, ModelConfig>;
189
+ defaults: {
190
+ retry_attempts: number;
191
+ retry_delay_ms: number;
192
+ };
193
+ }
194
+ export declare enum ToolCallStatus {
195
+ SUCCESS = "SUCCESS",
196
+ FAILURE = "FAILURE"
197
+ }
198
+ export interface TrajectoryStep {
199
+ id: string;
200
+ timestamp: number;
201
+ type: 'tool_result' | 'assistant' | 'action' | 'response' | 'thinking';
202
+ content: string;
203
+ toolName?: string;
204
+ toolArgs?: Record<string, any>;
205
+ toolOutput?: any;
206
+ status?: ToolCallStatus;
207
+ latencyMs?: number;
208
+ }
209
+ export interface EvaluationMetrics {
210
+ accuracy?: number;
211
+ faithfulness?: number;
212
+ latency_score?: number;
213
+ trajectory_alignment_score?: number;
214
+ [key: string]: number | undefined;
215
+ }
216
+ export interface ImprovementStrategy {
217
+ category: string;
218
+ issue: string;
219
+ recommendation: string;
220
+ priority: 'high' | 'medium' | 'low';
221
+ }
222
+ /**
223
+ * Scoring metric definition for evaluators
224
+ */
225
+ export interface ScoringMetric {
226
+ name: string;
227
+ description?: string;
228
+ weight: number;
229
+ scale: number;
230
+ }
231
+ /**
232
+ * Scoring configuration for an evaluator
233
+ */
234
+ export interface ScoringConfig {
235
+ metrics: ScoringMetric[];
236
+ passThreshold: number;
237
+ scale: number;
238
+ }
239
+ /**
240
+ * Inference configuration for an evaluator
241
+ */
242
+ export interface InferenceConfig {
243
+ provider?: JudgeProvider;
244
+ modelId?: string;
245
+ temperature?: number;
246
+ maxTokens?: number;
247
+ }
248
+ /**
249
+ * Evaluator version - immutable snapshot of evaluator configuration
250
+ */
251
+ export interface EvaluatorVersion {
252
+ version: number;
253
+ createdAt: string;
254
+ systemPrompt: string;
255
+ scoringConfig: ScoringConfig;
256
+ inferenceConfig: InferenceConfig;
257
+ }
258
+ /**
259
+ * Evaluator - pluggable judge configuration
260
+ * Defines how agent performance is evaluated
261
+ */
262
+ export interface Evaluator {
263
+ id: string;
264
+ name: string;
265
+ description: string;
266
+ isSystem: boolean;
267
+ tags?: string[];
268
+ currentVersion: number;
269
+ versions: EvaluatorVersion[];
270
+ createdAt: string;
271
+ updatedAt: string;
272
+ author?: string;
273
+ systemPrompt: string;
274
+ scoringConfig: ScoringConfig;
275
+ inferenceConfig: InferenceConfig;
276
+ }
277
+ export type PassFailStatus = 'passed' | 'failed';
278
+ export interface LLMJudgeResponse {
279
+ modelId: string;
280
+ timestamp: string;
281
+ promptTokens: number;
282
+ completionTokens: number;
283
+ latencyMs: number;
284
+ /**
285
+ * Raw judge text exactly as the model returned it (pre-JSON-parse). Set
286
+ * by the routing layer from `JudgeResponse.rawResponse`. Older callers
287
+ * stuffed the parsed `llmJudgeReasoning` into this field as a fallback;
288
+ * post evaluator-prompt-plumbing the field carries the actual unparsed
289
+ * model output for debugging "prompt edited but output didn't change"
290
+ * scenarios.
291
+ */
292
+ rawResponse: string;
293
+ /**
294
+ * Parsed numeric metrics. Open-ended `[key: string]: number` so a saved
295
+ * evaluator can declare arbitrary metric names in its `scoringConfig.metrics`
296
+ * and they flow through here unchanged. Legacy keys (`accuracy`,
297
+ * `faithfulness`, `latency_score`, `trajectory_alignment_score`) remain
298
+ * conventional but are no longer required — evaluators are pluggable.
299
+ */
300
+ parsedMetrics?: {
301
+ [key: string]: number | undefined;
302
+ };
303
+ improvementStrategies?: ImprovementStrategy[];
304
+ error?: string;
305
+ /**
306
+ * Any JSON keys the judge emitted that did NOT map onto a typed wire
307
+ * field or a declared metric. Captured by
308
+ * {@link parseJudgeResponse} (server/services/judgeResponseParser) so the
309
+ * run-detail "Judge debug" surface can show prompt-iteration output (e.g.
310
+ * `improvement_candidates`, `failure_tags`, `confidence`) without a code
311
+ * change. Empty/undefined when the model emitted only typed fields.
312
+ */
313
+ extraFields?: Record<string, unknown>;
314
+ /**
315
+ * Optional debug breadcrumbs persisted when `AH_JUDGE_DEBUG=1` (or in dev
316
+ * mode). Captures exactly what the run-detail UI needs to confirm "the
317
+ * prompt I saved is the prompt that ran" — the system prompt the model
318
+ * received, the user prompt, and which provider executed the call. The
319
+ * raw response itself is on the parent {@link rawResponse}.
320
+ *
321
+ * Disabled by default to keep persisted run docs lean (system prompts
322
+ * can be 10–20 KB).
323
+ */
324
+ judgeDebug?: {
325
+ /** Provider that executed the call: 'bedrock' | 'claude-code' | 'pi' | 'agent' | 'agentic' | 'openai-compatible' | 'litellm'. */
326
+ provider?: string;
327
+ /** Effective model id passed to the provider (post-resolution). */
328
+ modelId?: string;
329
+ /** Evaluator id used (system or user). */
330
+ evaluatorId?: string;
331
+ /** The full system prompt the model received. */
332
+ systemPrompt?: string;
333
+ /** The user-message prompt the model received. */
334
+ userPrompt?: string;
335
+ };
336
+ }
337
+ export interface RunAnnotation {
338
+ id: string;
339
+ reportId: string;
340
+ text: string;
341
+ timestamp: string;
342
+ tags?: string[];
343
+ author?: string;
344
+ }
345
+ /**
346
+ * @experimental Generic sidecar metadata for coding agent sessions.
347
+ * One document per session — stores annotations, status, tags, or any
348
+ * user-defined fields. The shape is intentionally open so callers can
349
+ * store whatever debug/analysis data they need.
350
+ */
351
+ export interface SessionMetadata {
352
+ agentKind: string;
353
+ sessionId: string;
354
+ /** Open-ended — callers define the schema. */
355
+ [key: string]: unknown;
356
+ }
357
+ export type MetricsStatus = 'pending' | 'calculating' | 'ready' | 'error';
358
+ export interface TestCaseRun {
359
+ id: string;
360
+ timestamp: string;
361
+ /**
362
+ * Human-readable name for this run (e.g. "Baseline", "Claude_02").
363
+ * Set from the user-supplied value in the run config dialog, or auto-generated
364
+ * server-side as `Run <short-id>` if not provided. Optional for backwards
365
+ * compatibility with runs created before the field existed — UI consumers
366
+ * should fall back to a generated label (see `getRunDisplayName`).
367
+ */
368
+ name?: string;
369
+ /** Optional human-readable description of what this run was testing. */
370
+ description?: string;
371
+ testCaseId: string;
372
+ testCaseVersion?: number;
373
+ experimentId?: string;
374
+ experimentRunId?: string;
375
+ agentName: string;
376
+ agentKey?: string;
377
+ modelName: string;
378
+ modelId?: string;
379
+ /**
380
+ * Optional judge model id, separate from {@link modelId} (which is the
381
+ * agent's LLM). Set explicitly via the run config (UI dropdown / CLI
382
+ * `--judge-model` / API `judgeModelId` field) or left unset to fall back
383
+ * to the evaluator's `inferenceConfig.modelId`, then the server-default
384
+ * Bedrock judge model. For agentic providers (`pi`, `agent`, `agentic`,
385
+ * `claude-code`) the value is informational — the provider picks its own
386
+ * model from its credentialed registry. Stored on the run document so the
387
+ * "Judge debug" surface and audit trail show which judge model was used.
388
+ */
389
+ judgeModelId?: string;
390
+ agentEndpoint?: string;
391
+ evaluatorId?: string;
392
+ status: 'running' | 'completed' | 'failed';
393
+ passFailStatus?: PassFailStatus;
394
+ trajectory: TrajectoryStep[];
395
+ metrics: EvaluationMetrics;
396
+ /**
397
+ * @deprecated Use `getJudgeReasoningText(report)` /
398
+ * `getJudgeMatcherResults(report)` from `lib/matchers/judgeAccessor`.
399
+ * The canonical judge surface is now `matcherResults[]` with
400
+ * `method: 'llm-judge'`. This flat-string field is kept as an
401
+ * Option-B backward-compat shim — it carries the most recent judge
402
+ * reasoning so old direct readers keep working, but new code MUST
403
+ * use the accessor.
404
+ */
405
+ llmJudgeReasoning: string;
406
+ improvementStrategies?: ImprovementStrategy[];
407
+ llmJudgeResponse?: LLMJudgeResponse;
408
+ /**
409
+ * W3C OTel trace id (32 hex). Stamped onto the run document at save time
410
+ * when polled spans expose one, used as the strongest correlation key for
411
+ * the run-detail Traces tab and the agent (trace) judge's `query_spans`
412
+ * tool. See #190 (this field as a top-level shortcut over re-extracting
413
+ * from `spans[0]`) and #264 (unified trace correlation strategies).
414
+ *
415
+ * Distinct from {@link runId} (the connector's run id, e.g.
416
+ * `subprocess-<timestamp>`); pre-fix the runner mis-stamped runId here
417
+ * which broke `traceId`-based queries.
418
+ */
419
+ traceId?: string;
420
+ openSearchLogs?: OpenSearchLog[];
421
+ annotations?: RunAnnotation[];
422
+ runId?: string;
423
+ /**
424
+ * Agent-emitted session id (e.g. Claude Code stamps `session.id` on every
425
+ * span of a run). Captured from the connector result and used as a precise
426
+ * per-run trace correlator (Strategy D) for agents that emit it but don't
427
+ * propagate W3C context or tag our `agent_health.run.id`.
428
+ */
429
+ sessionId?: string;
430
+ logs?: OpenSearchLog[];
431
+ rawEvents?: any[];
432
+ connectorProtocol?: ConnectorProtocol;
433
+ matcherResults?: import('../lib/matchers/types.js').MatcherResult[];
434
+ performanceMetrics?: TestCasePerformanceMetrics;
435
+ metricsStatus?: MetricsStatus;
436
+ traceFetchAttempts?: number;
437
+ lastTraceFetchAt?: string;
438
+ traceError?: string;
439
+ spans?: Span[];
440
+ }
441
+ export type EvaluationReport = TestCaseRun;
442
+ export interface AgentContextItem {
443
+ description: string;
444
+ value: string;
445
+ }
446
+ export interface AgentToolDefinition {
447
+ name: string;
448
+ description: string;
449
+ parameters: {
450
+ type: 'object';
451
+ properties: Record<string, {
452
+ type: string;
453
+ description: string;
454
+ enum?: string[];
455
+ }>;
456
+ required?: string[];
457
+ };
458
+ }
459
+ export type Category = 'Baseline' | 'Smart Contextual Menu' | 'RCA' | 'Conversational Queries' | 'Top 10 Browsed Products' | 'Errors by Service' | 'Group by Error Type' | string;
460
+ export interface TestCaseVersion {
461
+ version: number;
462
+ createdAt: string;
463
+ initialPrompt?: string;
464
+ context: AgentContextItem[];
465
+ tools?: AgentToolDefinition[];
466
+ expectedPPL?: string;
467
+ expectedOutcomes?: string[];
468
+ expectedTrajectory?: {
469
+ step: number;
470
+ description: string;
471
+ requiredTools: string[];
472
+ }[];
473
+ followUpQuestions?: {
474
+ trigger: 'results_available' | 'error' | 'always';
475
+ question: string;
476
+ businessValue: string;
477
+ }[];
478
+ }
479
+ export interface TestCase {
480
+ id: string;
481
+ name: string;
482
+ description: string;
483
+ labels: string[];
484
+ /** @deprecated Use labels with 'category:' prefix instead */
485
+ category: Category;
486
+ /** @deprecated Use labels with 'subcategory:' prefix instead */
487
+ subcategory?: string;
488
+ /** @deprecated Use labels with 'difficulty:' prefix instead */
489
+ difficulty: Difficulty;
490
+ currentVersion: number;
491
+ versions: TestCaseVersion[];
492
+ sourceFile?: string;
493
+ sourceHash?: string;
494
+ isPromoted: boolean;
495
+ createdAt: string;
496
+ updatedAt: string;
497
+ lastRunAt?: string;
498
+ initialPrompt?: string;
499
+ context: AgentContextItem[];
500
+ tools?: AgentToolDefinition[];
501
+ expectedPPL?: string;
502
+ expectedOutcomes?: string[];
503
+ expectedTrajectory?: {
504
+ step: number;
505
+ description: string;
506
+ requiredTools: string[];
507
+ }[];
508
+ followUpQuestions?: {
509
+ trigger: 'results_available' | 'error' | 'always';
510
+ question: string;
511
+ businessValue: string;
512
+ }[];
513
+ }
514
+ export interface OpenSearchLog {
515
+ timestamp: string;
516
+ index: string;
517
+ message: string;
518
+ level?: string;
519
+ source?: string;
520
+ [key: string]: any;
521
+ }
522
+ export interface LogQueryParams {
523
+ startTime: Date;
524
+ endTime: Date;
525
+ size?: number;
526
+ query?: string;
527
+ }
528
+ export interface TraceMetrics {
529
+ runId: string;
530
+ traceId?: string;
531
+ inputTokens: number;
532
+ outputTokens: number;
533
+ totalTokens: number;
534
+ costUsd: number;
535
+ durationMs: number;
536
+ llmCalls: number;
537
+ toolCalls: number;
538
+ toolsUsed: string[];
539
+ status: 'success' | 'error' | 'pending';
540
+ }
541
+ export interface SpanEvent {
542
+ name: string;
543
+ time: string;
544
+ attributes?: Record<string, any>;
545
+ }
546
+ export interface Span {
547
+ traceId: string;
548
+ spanId: string;
549
+ parentSpanId?: string;
550
+ name: string;
551
+ startTime: string;
552
+ endTime: string;
553
+ duration?: number;
554
+ status: 'OK' | 'ERROR' | 'UNSET';
555
+ attributes?: Record<string, any>;
556
+ events?: SpanEvent[];
557
+ children?: Span[];
558
+ depth?: number;
559
+ hasChildren?: boolean;
560
+ }
561
+ export interface TimeRange {
562
+ startTime: number;
563
+ endTime: number;
564
+ duration: number;
565
+ }
566
+ export interface TraceQueryParams {
567
+ traceId?: string;
568
+ runIds?: string[];
569
+ sessionId?: string;
570
+ startTime?: number;
571
+ endTime?: number;
572
+ size?: number;
573
+ serviceName?: string;
574
+ textSearch?: string;
575
+ cursor?: string;
576
+ /**
577
+ * Strategy C (opt-in): include any spans where `serviceName` matches AND
578
+ * `startTime` falls within `[startedAt, endedAt]`. Used by the run-report
579
+ * Traces tab as a fallback for agents that don't propagate W3C trace context
580
+ * (TRACEPARENT) and don't tag spans with `gen_ai.request.id` matching our
581
+ * runId. May surface unrelated spans (concurrent runs, cross-team noise).
582
+ * See AGENTS.md → Trace correlation conventions.
583
+ *
584
+ * Strategy D: when `sessionId` is set on an entry, correlate precisely on
585
+ * `attributes.session.id` (unioned with the service.name + window fallback).
586
+ */
587
+ agents?: Array<{
588
+ serviceName: string;
589
+ startedAt: number;
590
+ endedAt: number;
591
+ sessionId?: string;
592
+ }>;
593
+ }
594
+ export interface ConversationMessage {
595
+ id: string;
596
+ timestamp: string;
597
+ role: 'user' | 'assistant' | 'tool_call' | 'tool_result' | 'system';
598
+ content: string;
599
+ metadata?: {
600
+ spanId?: string;
601
+ spanName?: string;
602
+ toolName?: string;
603
+ model?: string;
604
+ inputTokens?: number;
605
+ outputTokens?: number;
606
+ durationMs?: number;
607
+ };
608
+ }
609
+ export interface TraceSearchResult {
610
+ spans: Span[];
611
+ total: number;
612
+ warning?: string;
613
+ warningCategory?: 'auth' | 'connection' | 'index_not_found' | 'not_configured' | 'unknown';
614
+ suggestion?: string;
615
+ nextCursor?: string | null;
616
+ hasMore?: boolean;
617
+ }
618
+ /**
619
+ * Summary of a single trace (grouped spans)
620
+ * Used for trace list display before selecting one for detailed view
621
+ */
622
+ export interface TraceSummary {
623
+ traceId: string;
624
+ serviceName: string;
625
+ spanCount: number;
626
+ rootSpanName: string;
627
+ startTime: string;
628
+ duration: number;
629
+ hasErrors: boolean;
630
+ hasEvalSpans?: boolean;
631
+ spans: Span[];
632
+ }
633
+ /**
634
+ * Span category based on OTel GenAI semantic conventions
635
+ * @see https://opentelemetry.io/docs/specs/semconv/gen-ai/gen-ai-agent-spans/
636
+ */
637
+ export type SpanCategory = 'AGENT' | 'LLM' | 'TOOL' | 'EVAL' | 'ERROR' | 'OTHER';
638
+ /**
639
+ * Extended span with category metadata for tree visualization
640
+ */
641
+ export interface CategorizedSpan extends Span {
642
+ category: SpanCategory;
643
+ categoryLabel: string;
644
+ categoryColor: string;
645
+ categoryIcon: string;
646
+ displayName: string;
647
+ }
648
+ /**
649
+ * Configuration for tool similarity grouping
650
+ */
651
+ export interface ToolSimilarityConfig {
652
+ /** Which tool arguments to use for determining "sameness" */
653
+ keyArguments: string[];
654
+ /** Whether grouping is enabled */
655
+ enabled: boolean;
656
+ }
657
+ /**
658
+ * Grouped tool spans for similarity view
659
+ */
660
+ export interface ToolGroup {
661
+ toolName: string;
662
+ keyArgsValues: Record<string, any>;
663
+ spans: CategorizedSpan[];
664
+ count: number;
665
+ totalDuration: number;
666
+ avgDuration: number;
667
+ }
668
+ /**
669
+ * Aligned span pair for tree comparison
670
+ */
671
+ export interface AlignedSpanPair {
672
+ type: 'matched' | 'added' | 'removed' | 'modified';
673
+ leftSpan?: CategorizedSpan;
674
+ rightSpan?: CategorizedSpan;
675
+ similarity?: number;
676
+ children?: AlignedSpanPair[];
677
+ }
678
+ /**
679
+ * Result of comparing two trace trees
680
+ */
681
+ export interface TraceComparisonResult {
682
+ alignedTree: AlignedSpanPair[];
683
+ stats: {
684
+ totalLeft: number;
685
+ totalRight: number;
686
+ matched: number;
687
+ added: number;
688
+ removed: number;
689
+ modified: number;
690
+ };
691
+ }
692
+ /**
693
+ * Data payload for span nodes in React Flow
694
+ * Index signature required for React Flow compatibility
695
+ */
696
+ export interface SpanNodeData extends Record<string, unknown> {
697
+ span: CategorizedSpan;
698
+ totalDuration: number;
699
+ }
700
+ /**
701
+ * Result of transforming spans to React Flow format
702
+ */
703
+ export interface FlowTransformResult {
704
+ nodes: Node<SpanNodeData>[];
705
+ edges: Edge[];
706
+ }
707
+ /**
708
+ * Options for flow transformation
709
+ */
710
+ export interface FlowTransformOptions {
711
+ direction?: 'TB' | 'LR';
712
+ mode?: 'hierarchy' | 'execution-order';
713
+ nodeWidth?: number;
714
+ nodeHeight?: number;
715
+ nodeSpacingX?: number;
716
+ nodeSpacingY?: number;
717
+ }
718
+ /**
719
+ * Group of spans detected as parallel execution
720
+ */
721
+ export interface ParallelGroup {
722
+ spans: CategorizedSpan[];
723
+ startTime: number;
724
+ endTime: number;
725
+ }
726
+ /**
727
+ * Result of checking OTEL GenAI semantic convention compliance
728
+ */
729
+ export interface OTelComplianceResult {
730
+ isCompliant: boolean;
731
+ missingAttributes: string[];
732
+ }
733
+ /**
734
+ * Compressed node for Intent view - represents one or more consecutive same-category spans
735
+ */
736
+ export interface IntentNode {
737
+ id: string;
738
+ category: SpanCategory;
739
+ spans: CategorizedSpan[];
740
+ count: number;
741
+ displayName: string;
742
+ subtitle: string;
743
+ hasWarnings: boolean;
744
+ executionOrder: number;
745
+ startIndex: number;
746
+ totalDuration: number;
747
+ }
748
+ /**
749
+ * Metadata about storage availability and data source
750
+ * Included in list responses to inform clients about data provenance
751
+ */
752
+ export interface StorageMetadata {
753
+ /** Whether storage backend is configured (env vars set) */
754
+ storageConfigured: boolean;
755
+ /** Whether storage backend was reachable on this request */
756
+ storageReachable: boolean;
757
+ /** Count of items from persistent storage */
758
+ realDataCount: number;
759
+ /** Count of items from built-in sample data */
760
+ sampleDataCount: number;
761
+ /** Whether sample/demo data was included in this response */
762
+ sampleDataIncluded?: boolean;
763
+ /** Optional warning messages (e.g., connection errors) */
764
+ warnings?: string[];
765
+ }
766
+ /**
767
+ * Generic list response wrapper with metadata
768
+ */
769
+ export interface ListResponse<T> {
770
+ data: T[];
771
+ total: number;
772
+ meta: StorageMetadata;
773
+ }
774
+ /** Server-side performance metrics for a single test case evaluation */
775
+ export interface TestCasePerformanceMetrics {
776
+ durationMs: number;
777
+ agentDurationMs: number;
778
+ judgeDurationMs?: number;
779
+ judgeAttempts?: number;
780
+ }
781
+ /** Server-side performance metrics for an entire benchmark run */
782
+ export interface RunPerformanceMetrics {
783
+ durationMs: number;
784
+ concurrency: number;
785
+ avgTestCaseDurationMs: number;
786
+ maxTestCaseDurationMs: number;
787
+ minTestCaseDurationMs: number;
788
+ }
789
+ export interface RunStats {
790
+ /** Number of test cases that passed (passFailStatus === 'passed') */
791
+ passed: number;
792
+ /** Number of test cases that failed (passFailStatus === 'failed' or execution failed) */
793
+ failed: number;
794
+ /** Number of test cases still pending (running, or report not yet available) */
795
+ pending: number;
796
+ /**
797
+ * Number of test cases where the *evaluator* could not produce a verdict
798
+ * (e.g. judge validation error, trace polling timeout, post-trace callback
799
+ * failed). Excluded from `passed` and `failed` so a misconfigured evaluator
800
+ * doesn't silently poison aggregate pass rates.
801
+ *
802
+ * Optional for backward-compat: older stored runs predate this field and
803
+ * read as 0.
804
+ */
805
+ errored?: number;
806
+ /** Total number of test cases in the run */
807
+ total: number;
808
+ }
809
+ export type RunResultStatus = 'pending' | 'running' | 'completed' | 'failed' | 'cancelled';
810
+ export type BenchmarkRunStatus = 'pending' | 'running' | 'completed' | 'failed' | 'cancelled';
811
+ export interface BenchmarkVersion {
812
+ version: number;
813
+ createdAt: string;
814
+ testCaseIds: string[];
815
+ }
816
+ export interface TestCaseSnapshot {
817
+ id: string;
818
+ version: number;
819
+ name: string;
820
+ }
821
+ export interface BenchmarkRun {
822
+ id: string;
823
+ name: string;
824
+ description?: string;
825
+ createdAt: string;
826
+ status?: BenchmarkRunStatus;
827
+ error?: string;
828
+ agentKey: string;
829
+ agentEndpoint?: string;
830
+ modelId: string;
831
+ /**
832
+ * Optional judge model id, distinct from {@link modelId} (the agent's
833
+ * LLM). Customer input via the run config dialog / CLI `--judge-model` /
834
+ * API. Falls back to `evaluator.inferenceConfig.modelId`, then the
835
+ * server-default Bedrock judge model. Ignored by agentic providers
836
+ * (`pi`, `agent`, `agentic`, `claude-code`) which pick their own model.
837
+ */
838
+ judgeModelId?: string;
839
+ evaluatorId?: string;
840
+ headers?: Record<string, string>;
841
+ concurrency?: number;
842
+ benchmarkVersion?: number;
843
+ testCaseSnapshots?: TestCaseSnapshot[];
844
+ results: Record<string, {
845
+ reportId: string;
846
+ status: RunResultStatus;
847
+ error?: string;
848
+ performanceMetrics?: TestCasePerformanceMetrics;
849
+ }>;
850
+ stats?: RunStats;
851
+ performanceMetrics?: RunPerformanceMetrics;
852
+ }
853
+ export interface Benchmark {
854
+ id: string;
855
+ name: string;
856
+ description?: string;
857
+ createdAt: string;
858
+ updatedAt: string;
859
+ currentVersion: number;
860
+ versions: BenchmarkVersion[];
861
+ testCaseIds: string[];
862
+ runs: BenchmarkRun[];
863
+ }
864
+ export interface BenchmarkProgress {
865
+ currentTestCaseIndex: number;
866
+ startedCount?: number;
867
+ completedCount?: number;
868
+ totalTestCases: number;
869
+ currentRunId: string;
870
+ currentTestCaseId: string;
871
+ status: 'running' | 'completed' | 'failed' | 'cancelled';
872
+ }
873
+ export interface BenchmarkStartedEvent {
874
+ runId: string;
875
+ testCases: Array<{
876
+ id: string;
877
+ name: string;
878
+ status: 'pending';
879
+ }>;
880
+ }
881
+ /** @deprecated Use BenchmarkRunStatus instead */
882
+ export type ExperimentRunStatus = BenchmarkRunStatus;
883
+ /** @deprecated Use BenchmarkRun instead */
884
+ export type ExperimentRun = BenchmarkRun;
885
+ /** @deprecated Use Benchmark instead */
886
+ export type Experiment = Benchmark;
887
+ /** @deprecated Use BenchmarkProgress instead */
888
+ export type ExperimentProgress = BenchmarkProgress;
889
+ /** @deprecated Use BenchmarkStartedEvent instead */
890
+ export type ExperimentStartedEvent = BenchmarkStartedEvent;
891
+ /**
892
+ * Discriminator for documents in evals_benchmarks index.
893
+ * Legacy docs without this field default to 'benchmark' via normalization.
894
+ */
895
+ export type EvalDocType = 'benchmark' | 'evaluation-run';
896
+ /**
897
+ * Describes where test cases came from for an evaluation run.
898
+ * Multiple sources can be combined (union, deduplicated by test case ID).
899
+ */
900
+ export type TestCaseSource = {
901
+ type: 'benchmark';
902
+ benchmarkId: string;
903
+ benchmarkVersion?: number;
904
+ } | {
905
+ type: 'test-case-ids';
906
+ ids: string[];
907
+ } | {
908
+ type: 'file-import';
909
+ filenames: string[];
910
+ testCaseIds: string[];
911
+ } | {
912
+ type: 'code-import';
913
+ filenames: string[];
914
+ testCaseIds: string[];
915
+ } | {
916
+ type: 'directory-import';
917
+ dirPaths: string[];
918
+ testCaseIds: string[];
919
+ } | {
920
+ type: 'label-filter';
921
+ labels: string[];
922
+ };
923
+ /**
924
+ * EvaluationRun — first-class execution record.
925
+ * Stored as top-level doc in evals_benchmarks index with docType: 'evaluation-run'.
926
+ * Replaces embedded BenchmarkRun as primary execution entity.
927
+ */
928
+ export interface EvaluationRun {
929
+ id: string;
930
+ docType: 'evaluation-run';
931
+ name: string;
932
+ description?: string;
933
+ createdAt: string;
934
+ completedAt?: string;
935
+ status: BenchmarkRunStatus;
936
+ error?: string;
937
+ agentKey: string;
938
+ agentEndpoint?: string;
939
+ modelId: string;
940
+ /**
941
+ * Optional judge model id, distinct from {@link modelId} (the agent's
942
+ * LLM). Same precedence rules as on {@link BenchmarkRun.judgeModelId}.
943
+ */
944
+ judgeModelId?: string;
945
+ evaluatorId?: string;
946
+ headers?: Record<string, string>;
947
+ concurrency?: number;
948
+ sources: TestCaseSource[];
949
+ trigger: 'ui' | 'cli' | 'api' | 'schedule';
950
+ testCaseSnapshots: TestCaseSnapshot[];
951
+ results: Record<string, {
952
+ reportId: string;
953
+ status: RunResultStatus;
954
+ error?: string;
955
+ performanceMetrics?: TestCasePerformanceMetrics;
956
+ }>;
957
+ stats?: RunStats;
958
+ performanceMetrics?: RunPerformanceMetrics;
959
+ benchmarkId?: string;
960
+ benchmarkVersion?: number;
961
+ }
962
+ export interface TestCaseVersionRef {
963
+ id: string;
964
+ version: string;
965
+ hash: string;
966
+ }
967
+ export interface RunAggregateMetrics {
968
+ runId: string;
969
+ runName: string;
970
+ createdAt: string;
971
+ modelId: string;
972
+ agentKey: string;
973
+ totalTestCases: number;
974
+ passedCount: number;
975
+ failedCount: number;
976
+ /** Test cases the evaluator couldn't verdict (#242); excluded from pass rate. */
977
+ erroredCount?: number;
978
+ avgAccuracy: number;
979
+ passRatePercent: number;
980
+ totalTokens?: number;
981
+ totalInputTokens?: number;
982
+ totalOutputTokens?: number;
983
+ totalCostUsd?: number;
984
+ avgDurationMs?: number;
985
+ totalLlmCalls?: number;
986
+ totalToolCalls?: number;
987
+ }
988
+ export interface TestCaseRunResult {
989
+ reportId?: string;
990
+ status: 'completed' | 'failed' | 'missing';
991
+ passFailStatus?: PassFailStatus;
992
+ /**
993
+ * Issue #242: when the evaluator could not produce a verdict
994
+ * (`metricsStatus: 'error'` on the report), the comparison row carries
995
+ * this flag so MetricCell can render an amber `Errored` chip distinct
996
+ * from `Failed`. The legacy `passFailStatus` field on these reports is
997
+ * cleared (`null`), so without this flag the cell would silently fall
998
+ * through to `Failed` styling.
999
+ */
1000
+ errored?: boolean;
1001
+ accuracy?: number;
1002
+ faithfulness?: number;
1003
+ trajectoryAlignment?: number;
1004
+ latencyScore?: number;
1005
+ testCaseVersion?: string;
1006
+ /** Error message if status is 'failed' */
1007
+ error?: string;
1008
+ }
1009
+ export interface TestCaseComparisonRow {
1010
+ testCaseId: string;
1011
+ testCaseName: string;
1012
+ labels: string[];
1013
+ /** @deprecated Use labels instead */
1014
+ category: Category;
1015
+ /** @deprecated Use labels instead */
1016
+ difficulty: Difficulty;
1017
+ results: Record<string, TestCaseRunResult>;
1018
+ hasVersionDifference: boolean;
1019
+ versions: string[];
1020
+ }
1021
+ export type RunConfigInput = Pick<BenchmarkRun, 'name' | 'description' | 'agentKey' | 'modelId' | 'judgeModelId' | 'agentEndpoint' | 'headers' | 'concurrency' | 'evaluatorId'>;
1022
+ import type { Request, Response } from 'express';
1023
+ export interface TypedRequest<T = any> extends Request {
1024
+ body: T;
1025
+ }
1026
+ export interface TypedResponse<T = any> extends Response {
1027
+ json: (body: T) => this;
1028
+ }
1029
+ export interface ExpectedStep {
1030
+ description: string;
1031
+ requiredTools?: string[];
1032
+ }
1033
+ export interface JudgeRequest {
1034
+ trajectory: TrajectoryStep[];
1035
+ expectedTrajectory: ExpectedStep[];
1036
+ expectedOutcomes?: string[];
1037
+ logs?: OpenSearchLog[];
1038
+ modelId?: string;
1039
+ evaluatorId?: string;
1040
+ }
1041
+ export interface JudgeResponse {
1042
+ passFailStatus: PassFailStatus;
1043
+ metrics: EvaluationMetrics;
1044
+ llmJudgeReasoning: string;
1045
+ improvementStrategies: ImprovementStrategy[];
1046
+ duration: number;
1047
+ }
1048
+ export interface AgentProxyRequest {
1049
+ endpoint: string;
1050
+ payload: any;
1051
+ headers?: Record<string, string>;
1052
+ }
1053
+ export interface StorageConfig {
1054
+ endpoint?: string;
1055
+ username?: string;
1056
+ password?: string;
1057
+ indexes: {
1058
+ testCases: string;
1059
+ benchmarks: string;
1060
+ runs: string;
1061
+ analytics: string;
1062
+ evaluators: string;
1063
+ };
1064
+ }
1065
+ export interface OpenSearchConfig {
1066
+ endpoint: string;
1067
+ username: string;
1068
+ password: string;
1069
+ indexPattern: string;
1070
+ }
1071
+ export interface LogsQuery {
1072
+ runId?: string;
1073
+ query?: string;
1074
+ startTime?: number;
1075
+ endTime?: number;
1076
+ size?: number;
1077
+ }
1078
+ export interface LogsResponse {
1079
+ hits: {
1080
+ hits: any[];
1081
+ total: any;
1082
+ };
1083
+ logs: OpenSearchLog[];
1084
+ total: number;
1085
+ }
1086
+ export interface HealthStatus {
1087
+ status: 'ok' | 'error' | 'not_configured';
1088
+ error?: string;
1089
+ errorCategory?: 'auth' | 'connection' | 'index_not_found' | 'unknown';
1090
+ suggestion?: string;
1091
+ index?: string;
1092
+ cluster?: any;
1093
+ }
1094
+ export interface AggregateMetrics {
1095
+ totalRuns: number;
1096
+ successRate: number;
1097
+ totalCostUsd: number;
1098
+ avgCostUsd: number;
1099
+ avgDurationMs: number;
1100
+ p50DurationMs: number;
1101
+ p95DurationMs: number;
1102
+ avgTokens: number;
1103
+ totalInputTokens: number;
1104
+ totalOutputTokens: number;
1105
+ avgLlmCalls: number;
1106
+ avgToolCalls: number;
1107
+ }
1108
+ export interface MetricsResult {
1109
+ runId: string;
1110
+ traceId: string | null;
1111
+ inputTokens: number;
1112
+ outputTokens: number;
1113
+ totalTokens: number;
1114
+ costUsd: number;
1115
+ durationMs: number;
1116
+ llmCalls: number;
1117
+ toolCalls: number;
1118
+ toolsUsed: string[];
1119
+ status: 'pending' | 'success' | 'error';
1120
+ }
1121
+ /**
1122
+ * Authentication type for OpenSearch clusters
1123
+ * - 'none': No authentication (e.g. local development clusters)
1124
+ * - 'basic': Username/password authentication (default, backwards compatible)
1125
+ * - 'sigv4': AWS SigV4 request signing for managed OpenSearch / Serverless
1126
+ */
1127
+ export type ClusterAuthType = 'none' | 'basic' | 'sigv4';
1128
+ /**
1129
+ * Base cluster configuration (endpoint + credentials)
1130
+ * Used for connecting to OpenSearch or other data sources
1131
+ */
1132
+ export interface ClusterConfig {
1133
+ endpoint: string;
1134
+ authType?: ClusterAuthType;
1135
+ username?: string;
1136
+ password?: string;
1137
+ awsProfile?: string;
1138
+ awsRegion?: string;
1139
+ awsService?: 'es' | 'aoss';
1140
+ tlsSkipVerify?: boolean;
1141
+ }
1142
+ /**
1143
+ * Storage cluster configuration - endpoint + credentials only
1144
+ * Index names (evals_test_cases, evals_experiments, evals_runs, evals_analytics)
1145
+ * are hardcoded in the adapter and not user-configurable.
1146
+ */
1147
+ export type StorageClusterConfig = ClusterConfig;
1148
+ /**
1149
+ * Observability cluster configuration - endpoint + credentials + OTEL index patterns
1150
+ * Used for traces, logs, and metrics from OpenTelemetry instrumentation
1151
+ */
1152
+ export interface ObservabilityClusterConfig extends ClusterConfig {
1153
+ indexes?: {
1154
+ traces?: string;
1155
+ logs?: string;
1156
+ metrics?: string;
1157
+ };
1158
+ }
1159
+ /**
1160
+ * Full data source configuration stored in localStorage
1161
+ * Both storage and observability can point to the same or different clusters
1162
+ */
1163
+ export interface DataSourceConfig {
1164
+ storage?: StorageClusterConfig;
1165
+ observability?: ObservabilityClusterConfig;
1166
+ }
1167
+ /**
1168
+ * Adapter type for data sources
1169
+ * 'file' is the default (JSON files in .agent-health/data/)
1170
+ * 'opensearch' when storage cluster is configured
1171
+ * 'memory' is for testing/demo
1172
+ */
1173
+ export type DataSourceAdapterType = 'file' | 'opensearch' | 'memory';
1174
+ export * from './skills.js';
1175
+ //# sourceMappingURL=index.d.ts.map