@opensearch-project/agent-health 0.4.0 → 0.6.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 (551) hide show
  1. package/README.md +36 -5
  2. package/cli/dist/index.js +8292 -2938
  3. package/deployment/cloudformation/agent-health-observability.yaml +223 -32
  4. package/dist/assets/index-BfxtxmKc.css +1 -0
  5. package/dist/assets/index-CrjAfDHu.js +243 -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 +474 -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 +397 -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 +626 -0
  22. package/docs/SKILLS.md +264 -0
  23. package/docs/STORAGE_INDEX_FIELD_LIMITS.md +216 -0
  24. package/docs/blogs/2026-02-28-opensearch-agent-health.md +200 -0
  25. package/docs/blogs/getting-started-blog.md +608 -0
  26. package/docs/diagrams/Agent-health.excalidraw +5656 -0
  27. package/docs/diagrams/architecture.png +0 -0
  28. package/docs/plans/field-redesign.md +468 -0
  29. package/docs/rfcs/001-coding-agent-analytics.md +374 -0
  30. package/docs/rfcs/002-enterprise-leaderboard.md +267 -0
  31. package/docs/rfcs/003-remote-aggregation.md +146 -0
  32. package/docs/rfcs/004-test-sdk-v2.md +599 -0
  33. package/docs/skills/AGENT_HEALTH.md +652 -0
  34. package/docs/skills/AGENT_PROFILE.md +191 -0
  35. package/docs/skills/add-connector/SKILL.md +68 -0
  36. package/docs/skills/agent-health-profile/SKILL.md +40 -0
  37. package/docs/skills/config-auth/SKILL.md +194 -0
  38. package/docs/skills/config-auth/evals/evals.json +35 -0
  39. package/docs/skills/create-pr/SKILL.md +73 -0
  40. package/docs/skills/instrument-otel/SKILL.md +84 -0
  41. package/docs/skills/write-test/SKILL.md +124 -0
  42. package/docs/ui prd.md +376 -0
  43. package/examples/README.md +53 -0
  44. package/examples/config/agent-health.config.example.ts +155 -0
  45. package/examples/connectors/echo-connector.ts +131 -0
  46. package/examples/eval-files/demo.eval.js +128 -0
  47. package/examples/eval-files/ops-rca-classification.eval.js +71 -0
  48. package/examples/eval-files/ops-rca-evaluator.json +15 -0
  49. package/examples/eval-files/sdk-demo.eval.js +72 -0
  50. package/examples/eval-files/sdk-describe-demo.eval.js +50 -0
  51. package/examples/eval-files/sdk-hooks-demo.eval.js +99 -0
  52. package/examples/pi-profiling/README.md +77 -0
  53. package/examples/pi-profiling/agent-health-profile.ts +417 -0
  54. package/lib/dist/lib/agentUtils.d.ts +29 -0
  55. package/lib/dist/lib/agentUtils.d.ts.map +1 -0
  56. package/lib/dist/lib/agentUtils.js +43 -0
  57. package/lib/dist/lib/agentUtils.js.map +1 -0
  58. package/lib/dist/lib/bedrockCompat.d.ts +27 -0
  59. package/lib/dist/lib/bedrockCompat.d.ts.map +1 -0
  60. package/lib/dist/lib/bedrockCompat.js +83 -0
  61. package/lib/dist/lib/bedrockCompat.js.map +1 -0
  62. package/lib/dist/lib/benchmarkExport.d.ts +14 -0
  63. package/lib/dist/lib/benchmarkExport.d.ts.map +1 -0
  64. package/lib/dist/lib/benchmarkExport.js +41 -0
  65. package/lib/dist/lib/benchmarkExport.js.map +1 -0
  66. package/lib/dist/lib/benchmarkImage.d.ts +52 -0
  67. package/lib/dist/lib/benchmarkImage.d.ts.map +1 -0
  68. package/lib/dist/lib/benchmarkImage.js +113 -0
  69. package/lib/dist/lib/benchmarkImage.js.map +1 -0
  70. package/lib/dist/lib/benchmarkVersionUtils.d.ts +50 -0
  71. package/lib/dist/lib/benchmarkVersionUtils.d.ts.map +1 -0
  72. package/lib/dist/lib/benchmarkVersionUtils.js +89 -0
  73. package/lib/dist/lib/benchmarkVersionUtils.js.map +1 -0
  74. package/lib/dist/lib/chunkedFetch.d.ts +18 -0
  75. package/lib/dist/lib/chunkedFetch.d.ts.map +1 -0
  76. package/lib/dist/lib/chunkedFetch.js +40 -0
  77. package/lib/dist/lib/chunkedFetch.js.map +1 -0
  78. package/lib/dist/lib/comparisonInsights.d.ts +104 -0
  79. package/lib/dist/lib/comparisonInsights.d.ts.map +1 -0
  80. package/lib/dist/lib/comparisonInsights.js +212 -0
  81. package/lib/dist/lib/comparisonInsights.js.map +1 -0
  82. package/lib/dist/lib/config/defineConfig.d.ts +27 -0
  83. package/lib/dist/lib/config/defineConfig.d.ts.map +1 -0
  84. package/lib/dist/lib/config/defineConfig.js +28 -0
  85. package/lib/dist/lib/config/defineConfig.js.map +1 -0
  86. package/lib/dist/lib/config/index.d.ts +9 -0
  87. package/lib/dist/lib/config/index.d.ts.map +1 -0
  88. package/lib/dist/lib/config/index.js +8 -0
  89. package/lib/dist/lib/config/index.js.map +1 -0
  90. package/lib/dist/lib/config/loader.d.ts +39 -0
  91. package/lib/dist/lib/config/loader.d.ts.map +1 -0
  92. package/lib/dist/lib/config/loader.js +263 -0
  93. package/lib/dist/lib/config/loader.js.map +1 -0
  94. package/lib/dist/lib/config/statePaths.d.ts +61 -0
  95. package/lib/dist/lib/config/statePaths.d.ts.map +1 -0
  96. package/lib/dist/lib/config/statePaths.js +188 -0
  97. package/lib/dist/lib/config/statePaths.js.map +1 -0
  98. package/lib/dist/lib/config/types.d.ts +245 -0
  99. package/lib/dist/lib/config/types.d.ts.map +1 -0
  100. package/lib/dist/lib/config/types.js +6 -0
  101. package/lib/dist/lib/config/types.js.map +1 -0
  102. package/lib/dist/lib/config.d.ts +39 -0
  103. package/lib/dist/lib/config.d.ts.map +1 -0
  104. package/lib/dist/lib/config.js +118 -0
  105. package/lib/dist/lib/config.js.map +1 -0
  106. package/lib/dist/lib/constants.d.ts +81 -0
  107. package/lib/dist/lib/constants.d.ts.map +1 -0
  108. package/lib/dist/lib/constants.js +374 -0
  109. package/lib/dist/lib/constants.js.map +1 -0
  110. package/lib/dist/lib/contextFormat.d.ts +26 -0
  111. package/lib/dist/lib/contextFormat.d.ts.map +1 -0
  112. package/lib/dist/lib/contextFormat.js +28 -0
  113. package/lib/dist/lib/contextFormat.js.map +1 -0
  114. package/lib/dist/lib/contextUtilization.d.ts +23 -0
  115. package/lib/dist/lib/contextUtilization.d.ts.map +1 -0
  116. package/lib/dist/lib/contextUtilization.js +72 -0
  117. package/lib/dist/lib/contextUtilization.js.map +1 -0
  118. package/lib/dist/lib/dashboardMetrics.d.ts +87 -0
  119. package/lib/dist/lib/dashboardMetrics.d.ts.map +1 -0
  120. package/lib/dist/lib/dashboardMetrics.js +242 -0
  121. package/lib/dist/lib/dashboardMetrics.js.map +1 -0
  122. package/lib/dist/lib/dataSourceConfig.d.ts +108 -0
  123. package/lib/dist/lib/dataSourceConfig.d.ts.map +1 -0
  124. package/lib/dist/lib/dataSourceConfig.js +166 -0
  125. package/lib/dist/lib/dataSourceConfig.js.map +1 -0
  126. package/lib/dist/lib/debug.d.ts +26 -0
  127. package/lib/dist/lib/debug.d.ts.map +1 -0
  128. package/lib/dist/lib/debug.js +132 -0
  129. package/lib/dist/lib/debug.js.map +1 -0
  130. package/lib/dist/lib/diagnostics.d.ts +28 -0
  131. package/lib/dist/lib/diagnostics.d.ts.map +1 -0
  132. package/lib/dist/lib/diagnostics.js +65 -0
  133. package/lib/dist/lib/diagnostics.js.map +1 -0
  134. package/lib/dist/lib/envCompat.d.ts +27 -0
  135. package/lib/dist/lib/envCompat.d.ts.map +1 -0
  136. package/lib/dist/lib/envCompat.js +82 -0
  137. package/lib/dist/lib/envCompat.js.map +1 -0
  138. package/lib/dist/lib/evaluationRerun.d.ts +63 -0
  139. package/lib/dist/lib/evaluationRerun.d.ts.map +1 -0
  140. package/lib/dist/lib/evaluationRerun.js +85 -0
  141. package/lib/dist/lib/evaluationRerun.js.map +1 -0
  142. package/lib/dist/lib/findPackageRoot.d.ts +7 -0
  143. package/lib/dist/lib/findPackageRoot.d.ts.map +1 -0
  144. package/lib/dist/lib/findPackageRoot.js +57 -0
  145. package/lib/dist/lib/findPackageRoot.js.map +1 -0
  146. package/lib/dist/lib/hooks.d.ts +36 -0
  147. package/lib/dist/lib/hooks.d.ts.map +1 -0
  148. package/lib/dist/lib/hooks.js +112 -0
  149. package/lib/dist/lib/hooks.js.map +1 -0
  150. package/lib/dist/lib/index.d.ts +47 -0
  151. package/lib/dist/lib/index.d.ts.map +1 -0
  152. package/lib/dist/lib/index.js +62 -0
  153. package/lib/dist/lib/index.js.map +1 -0
  154. package/lib/dist/lib/labels.d.ts +90 -0
  155. package/lib/dist/lib/labels.d.ts.map +1 -0
  156. package/lib/dist/lib/labels.js +158 -0
  157. package/lib/dist/lib/labels.js.map +1 -0
  158. package/lib/dist/lib/markdown.d.ts +16 -0
  159. package/lib/dist/lib/markdown.d.ts.map +1 -0
  160. package/lib/dist/lib/markdown.js +42 -0
  161. package/lib/dist/lib/markdown.js.map +1 -0
  162. package/lib/dist/lib/matchers/expect.d.ts +3 -0
  163. package/lib/dist/lib/matchers/expect.d.ts.map +1 -0
  164. package/lib/dist/lib/matchers/expect.js +225 -0
  165. package/lib/dist/lib/matchers/expect.js.map +1 -0
  166. package/lib/dist/lib/matchers/index.d.ts +8 -0
  167. package/lib/dist/lib/matchers/index.d.ts.map +1 -0
  168. package/lib/dist/lib/matchers/index.js +9 -0
  169. package/lib/dist/lib/matchers/index.js.map +1 -0
  170. package/lib/dist/lib/matchers/judgeAccessor.d.ts +113 -0
  171. package/lib/dist/lib/matchers/judgeAccessor.d.ts.map +1 -0
  172. package/lib/dist/lib/matchers/judgeAccessor.js +183 -0
  173. package/lib/dist/lib/matchers/judgeAccessor.js.map +1 -0
  174. package/lib/dist/lib/matchers/session.d.ts +39 -0
  175. package/lib/dist/lib/matchers/session.d.ts.map +1 -0
  176. package/lib/dist/lib/matchers/session.js +116 -0
  177. package/lib/dist/lib/matchers/session.js.map +1 -0
  178. package/lib/dist/lib/matchers/traces.d.ts +70 -0
  179. package/lib/dist/lib/matchers/traces.d.ts.map +1 -0
  180. package/lib/dist/lib/matchers/traces.js +236 -0
  181. package/lib/dist/lib/matchers/traces.js.map +1 -0
  182. package/lib/dist/lib/matchers/tracesPricing.d.ts +38 -0
  183. package/lib/dist/lib/matchers/tracesPricing.d.ts.map +1 -0
  184. package/lib/dist/lib/matchers/tracesPricing.js +64 -0
  185. package/lib/dist/lib/matchers/tracesPricing.js.map +1 -0
  186. package/lib/dist/lib/matchers/types.d.ts +75 -0
  187. package/lib/dist/lib/matchers/types.d.ts.map +1 -0
  188. package/lib/dist/lib/matchers/types.js +6 -0
  189. package/lib/dist/lib/matchers/types.js.map +1 -0
  190. package/lib/dist/lib/packagePaths.d.ts +29 -0
  191. package/lib/dist/lib/packagePaths.d.ts.map +1 -0
  192. package/lib/dist/lib/packagePaths.js +63 -0
  193. package/lib/dist/lib/packagePaths.js.map +1 -0
  194. package/lib/dist/lib/performance.d.ts +51 -0
  195. package/lib/dist/lib/performance.d.ts.map +1 -0
  196. package/lib/dist/lib/performance.js +159 -0
  197. package/lib/dist/lib/performance.js.map +1 -0
  198. package/lib/dist/lib/portConfig.d.ts +29 -0
  199. package/lib/dist/lib/portConfig.d.ts.map +1 -0
  200. package/lib/dist/lib/portConfig.js +64 -0
  201. package/lib/dist/lib/portConfig.js.map +1 -0
  202. package/lib/dist/lib/preferences.d.ts +63 -0
  203. package/lib/dist/lib/preferences.d.ts.map +1 -0
  204. package/lib/dist/lib/preferences.js +117 -0
  205. package/lib/dist/lib/preferences.js.map +1 -0
  206. package/lib/dist/lib/resolveAgentModel.d.ts +22 -0
  207. package/lib/dist/lib/resolveAgentModel.d.ts.map +1 -0
  208. package/lib/dist/lib/resolveAgentModel.js +37 -0
  209. package/lib/dist/lib/resolveAgentModel.js.map +1 -0
  210. package/lib/dist/lib/runStats.d.ts +116 -0
  211. package/lib/dist/lib/runStats.d.ts.map +1 -0
  212. package/lib/dist/lib/runStats.js +192 -0
  213. package/lib/dist/lib/runStats.js.map +1 -0
  214. package/lib/dist/lib/telemetry/constants.d.ts +60 -0
  215. package/lib/dist/lib/telemetry/constants.d.ts.map +1 -0
  216. package/lib/dist/lib/telemetry/constants.js +87 -0
  217. package/lib/dist/lib/telemetry/constants.js.map +1 -0
  218. package/lib/dist/lib/telemetry/evalSpans.d.ts +61 -0
  219. package/lib/dist/lib/telemetry/evalSpans.d.ts.map +1 -0
  220. package/lib/dist/lib/telemetry/evalSpans.js +254 -0
  221. package/lib/dist/lib/telemetry/evalSpans.js.map +1 -0
  222. package/lib/dist/lib/telemetry/index.d.ts +11 -0
  223. package/lib/dist/lib/telemetry/index.d.ts.map +1 -0
  224. package/lib/dist/lib/telemetry/index.js +15 -0
  225. package/lib/dist/lib/telemetry/index.js.map +1 -0
  226. package/lib/dist/lib/telemetry/opensearchExporter.d.ts +43 -0
  227. package/lib/dist/lib/telemetry/opensearchExporter.d.ts.map +1 -0
  228. package/lib/dist/lib/telemetry/opensearchExporter.js +217 -0
  229. package/lib/dist/lib/telemetry/opensearchExporter.js.map +1 -0
  230. package/lib/dist/lib/telemetry/provider.d.ts +55 -0
  231. package/lib/dist/lib/telemetry/provider.d.ts.map +1 -0
  232. package/lib/dist/lib/telemetry/provider.js +140 -0
  233. package/lib/dist/lib/telemetry/provider.js.map +1 -0
  234. package/lib/dist/lib/testCaseLabels.d.ts +34 -0
  235. package/lib/dist/lib/testCaseLabels.d.ts.map +1 -0
  236. package/lib/dist/lib/testCaseLabels.js +88 -0
  237. package/lib/dist/lib/testCaseLabels.js.map +1 -0
  238. package/lib/dist/lib/testCaseValidation.d.ts +140 -0
  239. package/lib/dist/lib/testCaseValidation.d.ts.map +1 -0
  240. package/lib/dist/lib/testCaseValidation.js +162 -0
  241. package/lib/dist/lib/testCaseValidation.js.map +1 -0
  242. package/lib/dist/lib/testCases/agentFixture.d.ts +80 -0
  243. package/lib/dist/lib/testCases/agentFixture.d.ts.map +1 -0
  244. package/lib/dist/lib/testCases/agentFixture.js +43 -0
  245. package/lib/dist/lib/testCases/agentFixture.js.map +1 -0
  246. package/lib/dist/lib/testCases/authoringSurface.d.ts +10 -0
  247. package/lib/dist/lib/testCases/authoringSurface.d.ts.map +1 -0
  248. package/lib/dist/lib/testCases/authoringSurface.js +54 -0
  249. package/lib/dist/lib/testCases/authoringSurface.js.map +1 -0
  250. package/lib/dist/lib/testCases/codemod.d.ts +13 -0
  251. package/lib/dist/lib/testCases/codemod.d.ts.map +1 -0
  252. package/lib/dist/lib/testCases/codemod.js +169 -0
  253. package/lib/dist/lib/testCases/codemod.js.map +1 -0
  254. package/lib/dist/lib/testCases/define.d.ts +114 -0
  255. package/lib/dist/lib/testCases/define.d.ts.map +1 -0
  256. package/lib/dist/lib/testCases/define.js +253 -0
  257. package/lib/dist/lib/testCases/define.js.map +1 -0
  258. package/lib/dist/lib/testCases/evaluators.d.ts +80 -0
  259. package/lib/dist/lib/testCases/evaluators.d.ts.map +1 -0
  260. package/lib/dist/lib/testCases/evaluators.js +105 -0
  261. package/lib/dist/lib/testCases/evaluators.js.map +1 -0
  262. package/lib/dist/lib/testCases/index.d.ts +14 -0
  263. package/lib/dist/lib/testCases/index.d.ts.map +1 -0
  264. package/lib/dist/lib/testCases/index.js +12 -0
  265. package/lib/dist/lib/testCases/index.js.map +1 -0
  266. package/lib/dist/lib/testCases/judge.d.ts +165 -0
  267. package/lib/dist/lib/testCases/judge.d.ts.map +1 -0
  268. package/lib/dist/lib/testCases/judge.js +359 -0
  269. package/lib/dist/lib/testCases/judge.js.map +1 -0
  270. package/lib/dist/lib/testCases/loader.d.ts +36 -0
  271. package/lib/dist/lib/testCases/loader.d.ts.map +1 -0
  272. package/lib/dist/lib/testCases/loader.js +179 -0
  273. package/lib/dist/lib/testCases/loader.js.map +1 -0
  274. package/lib/dist/lib/testCases/types.d.ts +242 -0
  275. package/lib/dist/lib/testCases/types.d.ts.map +1 -0
  276. package/lib/dist/lib/testCases/types.js +6 -0
  277. package/lib/dist/lib/testCases/types.js.map +1 -0
  278. package/lib/dist/lib/theme.d.ts +6 -0
  279. package/lib/dist/lib/theme.d.ts.map +1 -0
  280. package/lib/dist/lib/theme.js +36 -0
  281. package/lib/dist/lib/theme.js.map +1 -0
  282. package/lib/dist/lib/uiTelemetry.d.ts +7 -0
  283. package/lib/dist/lib/uiTelemetry.d.ts.map +1 -0
  284. package/lib/dist/lib/uiTelemetry.js +25 -0
  285. package/lib/dist/lib/uiTelemetry.js.map +1 -0
  286. package/lib/dist/lib/utils.d.ts +111 -0
  287. package/lib/dist/lib/utils.d.ts.map +1 -0
  288. package/lib/dist/lib/utils.js +254 -0
  289. package/lib/dist/lib/utils.js.map +1 -0
  290. package/lib/dist/lib/workflow/consolidate.d.ts +12 -0
  291. package/lib/dist/lib/workflow/consolidate.d.ts.map +1 -0
  292. package/lib/dist/lib/workflow/consolidate.js +33 -0
  293. package/lib/dist/lib/workflow/consolidate.js.map +1 -0
  294. package/lib/dist/lib/workflow/index.d.ts +13 -0
  295. package/lib/dist/lib/workflow/index.d.ts.map +1 -0
  296. package/lib/dist/lib/workflow/index.js +12 -0
  297. package/lib/dist/lib/workflow/index.js.map +1 -0
  298. package/lib/dist/lib/workflow/ledger.d.ts +30 -0
  299. package/lib/dist/lib/workflow/ledger.d.ts.map +1 -0
  300. package/lib/dist/lib/workflow/ledger.js +41 -0
  301. package/lib/dist/lib/workflow/ledger.js.map +1 -0
  302. package/lib/dist/lib/workflow/pool.d.ts +13 -0
  303. package/lib/dist/lib/workflow/pool.d.ts.map +1 -0
  304. package/lib/dist/lib/workflow/pool.js +44 -0
  305. package/lib/dist/lib/workflow/pool.js.map +1 -0
  306. package/lib/dist/lib/workflow/source.d.ts +22 -0
  307. package/lib/dist/lib/workflow/source.d.ts.map +1 -0
  308. package/lib/dist/lib/workflow/source.js +29 -0
  309. package/lib/dist/lib/workflow/source.js.map +1 -0
  310. package/lib/dist/lib/workflow/stepB.d.ts +71 -0
  311. package/lib/dist/lib/workflow/stepB.d.ts.map +1 -0
  312. package/lib/dist/lib/workflow/stepB.js +99 -0
  313. package/lib/dist/lib/workflow/stepB.js.map +1 -0
  314. package/lib/dist/lib/workflow/types.d.ts +86 -0
  315. package/lib/dist/lib/workflow/types.d.ts.map +1 -0
  316. package/lib/dist/lib/workflow/types.js +6 -0
  317. package/lib/dist/lib/workflow/types.js.map +1 -0
  318. package/lib/dist/lib/workflow/workflow.d.ts +119 -0
  319. package/lib/dist/lib/workflow/workflow.d.ts.map +1 -0
  320. package/lib/dist/lib/workflow/workflow.js +195 -0
  321. package/lib/dist/lib/workflow/workflow.js.map +1 -0
  322. package/lib/dist/services/agent/aguiConverter.d.ts +50 -0
  323. package/lib/dist/services/agent/aguiConverter.d.ts.map +1 -0
  324. package/lib/dist/services/agent/aguiConverter.js +449 -0
  325. package/lib/dist/services/agent/aguiConverter.js.map +1 -0
  326. package/lib/dist/services/agent/index.d.ts +10 -0
  327. package/lib/dist/services/agent/index.d.ts.map +1 -0
  328. package/lib/dist/services/agent/index.js +12 -0
  329. package/lib/dist/services/agent/index.js.map +1 -0
  330. package/lib/dist/services/agent/payloadBuilder.d.ts +33 -0
  331. package/lib/dist/services/agent/payloadBuilder.d.ts.map +1 -0
  332. package/lib/dist/services/agent/payloadBuilder.js +75 -0
  333. package/lib/dist/services/agent/payloadBuilder.js.map +1 -0
  334. package/lib/dist/services/agent/sseStream.d.ts +43 -0
  335. package/lib/dist/services/agent/sseStream.d.ts.map +1 -0
  336. package/lib/dist/services/agent/sseStream.js +223 -0
  337. package/lib/dist/services/agent/sseStream.js.map +1 -0
  338. package/lib/dist/services/connectors/agui/AGUIStreamingConnector.d.ts +44 -0
  339. package/lib/dist/services/connectors/agui/AGUIStreamingConnector.d.ts.map +1 -0
  340. package/lib/dist/services/connectors/agui/AGUIStreamingConnector.js +95 -0
  341. package/lib/dist/services/connectors/agui/AGUIStreamingConnector.js.map +1 -0
  342. package/lib/dist/services/connectors/base/BaseConnector.d.ts +81 -0
  343. package/lib/dist/services/connectors/base/BaseConnector.d.ts.map +1 -0
  344. package/lib/dist/services/connectors/base/BaseConnector.js +170 -0
  345. package/lib/dist/services/connectors/base/BaseConnector.js.map +1 -0
  346. package/lib/dist/services/connectors/claude-code/ClaudeCodeConnector.d.ts +126 -0
  347. package/lib/dist/services/connectors/claude-code/ClaudeCodeConnector.d.ts.map +1 -0
  348. package/lib/dist/services/connectors/claude-code/ClaudeCodeConnector.js +417 -0
  349. package/lib/dist/services/connectors/claude-code/ClaudeCodeConnector.js.map +1 -0
  350. package/lib/dist/services/connectors/index.d.ts +13 -0
  351. package/lib/dist/services/connectors/index.d.ts.map +1 -0
  352. package/lib/dist/services/connectors/index.js +32 -0
  353. package/lib/dist/services/connectors/index.js.map +1 -0
  354. package/lib/dist/services/connectors/kiro/KiroConnector.d.ts +48 -0
  355. package/lib/dist/services/connectors/kiro/KiroConnector.d.ts.map +1 -0
  356. package/lib/dist/services/connectors/kiro/KiroConnector.js +158 -0
  357. package/lib/dist/services/connectors/kiro/KiroConnector.js.map +1 -0
  358. package/lib/dist/services/connectors/langgraph/LangGraphConnector.d.ts +36 -0
  359. package/lib/dist/services/connectors/langgraph/LangGraphConnector.d.ts.map +1 -0
  360. package/lib/dist/services/connectors/langgraph/LangGraphConnector.js +175 -0
  361. package/lib/dist/services/connectors/langgraph/LangGraphConnector.js.map +1 -0
  362. package/lib/dist/services/connectors/mock/MockConnector.d.ts +37 -0
  363. package/lib/dist/services/connectors/mock/MockConnector.d.ts.map +1 -0
  364. package/lib/dist/services/connectors/mock/MockConnector.js +120 -0
  365. package/lib/dist/services/connectors/mock/MockConnector.js.map +1 -0
  366. package/lib/dist/services/connectors/openai-compatible/OpenAICompatibleConnector.d.ts +42 -0
  367. package/lib/dist/services/connectors/openai-compatible/OpenAICompatibleConnector.d.ts.map +1 -0
  368. package/lib/dist/services/connectors/openai-compatible/OpenAICompatibleConnector.js +133 -0
  369. package/lib/dist/services/connectors/openai-compatible/OpenAICompatibleConnector.js.map +1 -0
  370. package/lib/dist/services/connectors/pi/PiConnector.d.ts +87 -0
  371. package/lib/dist/services/connectors/pi/PiConnector.d.ts.map +1 -0
  372. package/lib/dist/services/connectors/pi/PiConnector.js +274 -0
  373. package/lib/dist/services/connectors/pi/PiConnector.js.map +1 -0
  374. package/lib/dist/services/connectors/registry.d.ts +57 -0
  375. package/lib/dist/services/connectors/registry.d.ts.map +1 -0
  376. package/lib/dist/services/connectors/registry.js +106 -0
  377. package/lib/dist/services/connectors/registry.js.map +1 -0
  378. package/lib/dist/services/connectors/rest/RESTConnector.d.ts +38 -0
  379. package/lib/dist/services/connectors/rest/RESTConnector.d.ts.map +1 -0
  380. package/lib/dist/services/connectors/rest/RESTConnector.js +117 -0
  381. package/lib/dist/services/connectors/rest/RESTConnector.js.map +1 -0
  382. package/lib/dist/services/connectors/server.d.ts +13 -0
  383. package/lib/dist/services/connectors/server.d.ts.map +1 -0
  384. package/lib/dist/services/connectors/server.js +34 -0
  385. package/lib/dist/services/connectors/server.js.map +1 -0
  386. package/lib/dist/services/connectors/strands/StrandsConnector.d.ts +48 -0
  387. package/lib/dist/services/connectors/strands/StrandsConnector.d.ts.map +1 -0
  388. package/lib/dist/services/connectors/strands/StrandsConnector.js +221 -0
  389. package/lib/dist/services/connectors/strands/StrandsConnector.js.map +1 -0
  390. package/lib/dist/services/connectors/subprocess/SubprocessConnector.d.ts +88 -0
  391. package/lib/dist/services/connectors/subprocess/SubprocessConnector.d.ts.map +1 -0
  392. package/lib/dist/services/connectors/subprocess/SubprocessConnector.js +426 -0
  393. package/lib/dist/services/connectors/subprocess/SubprocessConnector.js.map +1 -0
  394. package/lib/dist/services/connectors/types.d.ts +213 -0
  395. package/lib/dist/services/connectors/types.d.ts.map +1 -0
  396. package/lib/dist/services/connectors/types.js +6 -0
  397. package/lib/dist/services/connectors/types.js.map +1 -0
  398. package/lib/dist/services/evaluation/bedrockJudge.d.ts +71 -0
  399. package/lib/dist/services/evaluation/bedrockJudge.d.ts.map +1 -0
  400. package/lib/dist/services/evaluation/bedrockJudge.js +169 -0
  401. package/lib/dist/services/evaluation/bedrockJudge.js.map +1 -0
  402. package/lib/dist/services/evaluation/evaluatorError.d.ts +56 -0
  403. package/lib/dist/services/evaluation/evaluatorError.d.ts.map +1 -0
  404. package/lib/dist/services/evaluation/evaluatorError.js +56 -0
  405. package/lib/dist/services/evaluation/evaluatorError.js.map +1 -0
  406. package/lib/dist/services/evaluation/index.d.ts +106 -0
  407. package/lib/dist/services/evaluation/index.d.ts.map +1 -0
  408. package/lib/dist/services/evaluation/index.js +684 -0
  409. package/lib/dist/services/evaluation/index.js.map +1 -0
  410. package/lib/dist/services/evaluation/mockTrajectory.d.ts +3 -0
  411. package/lib/dist/services/evaluation/mockTrajectory.d.ts.map +1 -0
  412. package/lib/dist/services/evaluation/mockTrajectory.js +72 -0
  413. package/lib/dist/services/evaluation/mockTrajectory.js.map +1 -0
  414. package/lib/dist/services/opensearch/client.d.ts +26 -0
  415. package/lib/dist/services/opensearch/client.d.ts.map +1 -0
  416. package/lib/dist/services/opensearch/client.js +131 -0
  417. package/lib/dist/services/opensearch/client.js.map +1 -0
  418. package/lib/dist/services/opensearch/index.d.ts +16 -0
  419. package/lib/dist/services/opensearch/index.d.ts.map +1 -0
  420. package/lib/dist/services/opensearch/index.js +25 -0
  421. package/lib/dist/services/opensearch/index.js.map +1 -0
  422. package/lib/dist/services/storage/asyncBenchmarkStorage.d.ts +123 -0
  423. package/lib/dist/services/storage/asyncBenchmarkStorage.d.ts.map +1 -0
  424. package/lib/dist/services/storage/asyncBenchmarkStorage.js +440 -0
  425. package/lib/dist/services/storage/asyncBenchmarkStorage.js.map +1 -0
  426. package/lib/dist/services/storage/asyncRunStorage.d.ts +135 -0
  427. package/lib/dist/services/storage/asyncRunStorage.d.ts.map +1 -0
  428. package/lib/dist/services/storage/asyncRunStorage.js +524 -0
  429. package/lib/dist/services/storage/asyncRunStorage.js.map +1 -0
  430. package/lib/dist/services/storage/asyncTestCaseStorage.d.ts +170 -0
  431. package/lib/dist/services/storage/asyncTestCaseStorage.d.ts.map +1 -0
  432. package/lib/dist/services/storage/asyncTestCaseStorage.js +301 -0
  433. package/lib/dist/services/storage/asyncTestCaseStorage.js.map +1 -0
  434. package/lib/dist/services/storage/index.d.ts +17 -0
  435. package/lib/dist/services/storage/index.d.ts.map +1 -0
  436. package/lib/dist/services/storage/index.js +20 -0
  437. package/lib/dist/services/storage/index.js.map +1 -0
  438. package/lib/dist/services/storage/migration.d.ts +54 -0
  439. package/lib/dist/services/storage/migration.d.ts.map +1 -0
  440. package/lib/dist/services/storage/migration.js +296 -0
  441. package/lib/dist/services/storage/migration.js.map +1 -0
  442. package/lib/dist/services/storage/opensearchClient.d.ts +947 -0
  443. package/lib/dist/services/storage/opensearchClient.d.ts.map +1 -0
  444. package/lib/dist/services/storage/opensearchClient.js +442 -0
  445. package/lib/dist/services/storage/opensearchClient.js.map +1 -0
  446. package/lib/dist/services/traces/browserRecovery.d.ts +37 -0
  447. package/lib/dist/services/traces/browserRecovery.d.ts.map +1 -0
  448. package/lib/dist/services/traces/browserRecovery.js +108 -0
  449. package/lib/dist/services/traces/browserRecovery.js.map +1 -0
  450. package/lib/dist/services/traces/categoryStyles.d.ts +21 -0
  451. package/lib/dist/services/traces/categoryStyles.d.ts.map +1 -0
  452. package/lib/dist/services/traces/categoryStyles.js +56 -0
  453. package/lib/dist/services/traces/categoryStyles.js.map +1 -0
  454. package/lib/dist/services/traces/executionOrderTransform.d.ts +35 -0
  455. package/lib/dist/services/traces/executionOrderTransform.d.ts.map +1 -0
  456. package/lib/dist/services/traces/executionOrderTransform.js +313 -0
  457. package/lib/dist/services/traces/executionOrderTransform.js.map +1 -0
  458. package/lib/dist/services/traces/fetchSpansForRun.d.ts +86 -0
  459. package/lib/dist/services/traces/fetchSpansForRun.d.ts.map +1 -0
  460. package/lib/dist/services/traces/fetchSpansForRun.js +69 -0
  461. package/lib/dist/services/traces/fetchSpansForRun.js.map +1 -0
  462. package/lib/dist/services/traces/flowTransform.d.ts +24 -0
  463. package/lib/dist/services/traces/flowTransform.d.ts.map +1 -0
  464. package/lib/dist/services/traces/flowTransform.js +228 -0
  465. package/lib/dist/services/traces/flowTransform.js.map +1 -0
  466. package/lib/dist/services/traces/index.d.ts +121 -0
  467. package/lib/dist/services/traces/index.d.ts.map +1 -0
  468. package/lib/dist/services/traces/index.js +255 -0
  469. package/lib/dist/services/traces/index.js.map +1 -0
  470. package/lib/dist/services/traces/intentTransform.d.ts +20 -0
  471. package/lib/dist/services/traces/intentTransform.d.ts.map +1 -0
  472. package/lib/dist/services/traces/intentTransform.js +131 -0
  473. package/lib/dist/services/traces/intentTransform.js.map +1 -0
  474. package/lib/dist/services/traces/judgeAgentsHints.d.ts +63 -0
  475. package/lib/dist/services/traces/judgeAgentsHints.d.ts.map +1 -0
  476. package/lib/dist/services/traces/judgeAgentsHints.js +89 -0
  477. package/lib/dist/services/traces/judgeAgentsHints.js.map +1 -0
  478. package/lib/dist/services/traces/messageExtraction.d.ts +15 -0
  479. package/lib/dist/services/traces/messageExtraction.d.ts.map +1 -0
  480. package/lib/dist/services/traces/messageExtraction.js +313 -0
  481. package/lib/dist/services/traces/messageExtraction.js.map +1 -0
  482. package/lib/dist/services/traces/spanCategorization.d.ts +63 -0
  483. package/lib/dist/services/traces/spanCategorization.d.ts.map +1 -0
  484. package/lib/dist/services/traces/spanCategorization.js +276 -0
  485. package/lib/dist/services/traces/spanCategorization.js.map +1 -0
  486. package/lib/dist/services/traces/spanPreprocessing.d.ts +37 -0
  487. package/lib/dist/services/traces/spanPreprocessing.d.ts.map +1 -0
  488. package/lib/dist/services/traces/spanPreprocessing.js +102 -0
  489. package/lib/dist/services/traces/spanPreprocessing.js.map +1 -0
  490. package/lib/dist/services/traces/spansToTrajectory.d.ts +36 -0
  491. package/lib/dist/services/traces/spansToTrajectory.d.ts.map +1 -0
  492. package/lib/dist/services/traces/spansToTrajectory.js +425 -0
  493. package/lib/dist/services/traces/spansToTrajectory.js.map +1 -0
  494. package/lib/dist/services/traces/toolSimilarity.d.ts +35 -0
  495. package/lib/dist/services/traces/toolSimilarity.d.ts.map +1 -0
  496. package/lib/dist/services/traces/toolSimilarity.js +203 -0
  497. package/lib/dist/services/traces/toolSimilarity.js.map +1 -0
  498. package/lib/dist/services/traces/traceComparison.d.ts +31 -0
  499. package/lib/dist/services/traces/traceComparison.d.ts.map +1 -0
  500. package/lib/dist/services/traces/traceComparison.js +318 -0
  501. package/lib/dist/services/traces/traceComparison.js.map +1 -0
  502. package/lib/dist/services/traces/traceGrouping.d.ts +19 -0
  503. package/lib/dist/services/traces/traceGrouping.d.ts.map +1 -0
  504. package/lib/dist/services/traces/traceGrouping.js +107 -0
  505. package/lib/dist/services/traces/traceGrouping.js.map +1 -0
  506. package/lib/dist/services/traces/tracePoller.d.ts +108 -0
  507. package/lib/dist/services/traces/tracePoller.d.ts.map +1 -0
  508. package/lib/dist/services/traces/tracePoller.js +475 -0
  509. package/lib/dist/services/traces/tracePoller.js.map +1 -0
  510. package/lib/dist/services/traces/traceStats.d.ts +45 -0
  511. package/lib/dist/services/traces/traceStats.d.ts.map +1 -0
  512. package/lib/dist/services/traces/traceStats.js +114 -0
  513. package/lib/dist/services/traces/traceStats.js.map +1 -0
  514. package/lib/dist/services/traces/traceSummary.d.ts +47 -0
  515. package/lib/dist/services/traces/traceSummary.d.ts.map +1 -0
  516. package/lib/dist/services/traces/traceSummary.js +68 -0
  517. package/lib/dist/services/traces/traceSummary.js.map +1 -0
  518. package/lib/dist/services/traces/utils.d.ts +33 -0
  519. package/lib/dist/services/traces/utils.d.ts.map +1 -0
  520. package/lib/dist/services/traces/utils.js +114 -0
  521. package/lib/dist/services/traces/utils.js.map +1 -0
  522. package/lib/dist/types/agui.d.ts +13 -0
  523. package/lib/dist/types/agui.d.ts.map +1 -0
  524. package/lib/dist/types/agui.js +16 -0
  525. package/lib/dist/types/agui.js.map +1 -0
  526. package/lib/dist/types/index.d.ts +1229 -0
  527. package/lib/dist/types/index.d.ts.map +1 -0
  528. package/lib/dist/types/index.js +12 -0
  529. package/lib/dist/types/index.js.map +1 -0
  530. package/lib/dist/types/skills.d.ts +146 -0
  531. package/lib/dist/types/skills.d.ts.map +1 -0
  532. package/lib/dist/types/skills.js +6 -0
  533. package/lib/dist/types/skills.js.map +1 -0
  534. package/observio-sample-agent/pi-package/README.md +112 -0
  535. package/observio-sample-agent/pi-package/extensions/agent-health.ts +373 -0
  536. package/observio-sample-agent/pi-package/package.json +17 -0
  537. package/observio-sample-agent/pi-package/prompts/agent-health.md +37 -0
  538. package/observio-sample-agent/pi-package/skills/create-pr/SKILL.md +88 -0
  539. package/observio-sample-agent/pi-package/skills/fix-bug/SKILL.md +71 -0
  540. package/observio-sample-agent/pi-package/skills/implement-feature/SKILL.md +156 -0
  541. package/observio-sample-agent/pi-package/skills/instrument-otel/SKILL.md +208 -0
  542. package/observio-sample-agent/pi-package/skills/setup-collector/SKILL.md +146 -0
  543. package/observio-sample-agent/pi-package/skills/write-test/SKILL.md +115 -0
  544. package/package.json +45 -9
  545. package/server/dist/app.js +34031 -18731
  546. package/server/dist/index.js +30737 -15338
  547. package/tsconfig.lib.json +71 -0
  548. package/dist/assets/index-BOIP5L7h.js +0 -246
  549. package/dist/assets/index-CU9YKpAL.css +0 -1
  550. package/lib/dist/config/index.js +0 -452
  551. package/lib/dist/index.js +0 -1725
@@ -0,0 +1,132 @@
1
+ /*
2
+ * Copyright OpenSearch Contributors
3
+ * SPDX-License-Identifier: Apache-2.0
4
+ */
5
+ /**
6
+ * Simple Debug Utility
7
+ *
8
+ * Single source of truth: agent-health.config.json on server
9
+ *
10
+ * Server: Reads/writes agent-health.config.json
11
+ * Browser: Uses localStorage cache (synced via Settings page API calls)
12
+ */
13
+ import fs from 'fs';
14
+ import path from 'path';
15
+ const isBrowser = typeof window !== 'undefined';
16
+ // Config v2: debug lives in the project runtime state file
17
+ // (<cwd>/.agent-health/state.json). In code-first mode (an
18
+ // agent-health.config.ts is present) it is in-memory only (DEBUG env still honored).
19
+ // Kept fs/path-only here because this module is isomorphic (browser + server);
20
+ // statePaths.ts is server-only.
21
+ const STATE_DIR = '.agent-health';
22
+ const STATE_FILE = 'state.json';
23
+ const AUTHORED_CONFIG_NAMES = ['agent-health.config.ts', 'agent-health.config.js', 'agent-health.config.mjs'];
24
+ function debugIsCodeFirst() {
25
+ // Mirror statePaths.isCodeFirstMode: an authored config at project OR user
26
+ // scope (~/.agent-health/) means code-first. os.homedir() is avoided so this
27
+ // isomorphic module stays browser-safe; this path only runs server-side.
28
+ const home = process.env.HOME || process.env.USERPROFILE || '';
29
+ return AUTHORED_CONFIG_NAMES.some((n) => fs.existsSync(path.join(process.cwd(), n)) ||
30
+ (!!home && fs.existsSync(path.join(home, STATE_DIR, n))));
31
+ }
32
+ function debugStatePath() {
33
+ return path.join(process.cwd(), STATE_DIR, STATE_FILE);
34
+ }
35
+ // Server-side: persist debug state in the runtime state file
36
+ let serverDebugEnabled = false;
37
+ // Initialize server debug state from the state file (ui-first) or env var
38
+ if (!isBrowser) {
39
+ try {
40
+ const statePath = debugStatePath();
41
+ if (!debugIsCodeFirst() && fs.existsSync(statePath)) {
42
+ const config = JSON.parse(fs.readFileSync(statePath, 'utf-8')) || {};
43
+ serverDebugEnabled = config.debug === true;
44
+ }
45
+ else if (process.env?.DEBUG === 'true') {
46
+ serverDebugEnabled = true;
47
+ }
48
+ }
49
+ catch (err) {
50
+ // Ignore read errors, fall back to env var
51
+ if (process.env?.DEBUG === 'true') {
52
+ serverDebugEnabled = true;
53
+ }
54
+ }
55
+ }
56
+ /**
57
+ * Check if debug mode is enabled
58
+ * Server: reads from memory (loaded from agent-health.config.json)
59
+ * Browser: reads from localStorage cache (synced by Settings page)
60
+ */
61
+ export function isDebugEnabled() {
62
+ if (isBrowser) {
63
+ try {
64
+ return localStorage.getItem('agenteval_debug') === 'true';
65
+ }
66
+ catch {
67
+ return false;
68
+ }
69
+ }
70
+ return serverDebugEnabled;
71
+ }
72
+ /**
73
+ * Set debug state
74
+ * Server: updates memory + persists to agent-health.config.json
75
+ * Browser: updates localStorage cache (Settings page also calls /api/debug)
76
+ */
77
+ export function setDebugEnabled(enabled) {
78
+ if (isBrowser) {
79
+ try {
80
+ localStorage.setItem('agenteval_debug', String(enabled));
81
+ }
82
+ catch {
83
+ // Ignore errors (e.g. private browsing)
84
+ }
85
+ return;
86
+ }
87
+ // Server-side: update memory + persist to the runtime state file
88
+ serverDebugEnabled = enabled;
89
+ // Code-first mode: the state file is ignored; keep debug in-memory only.
90
+ if (debugIsCodeFirst()) {
91
+ console.info(`[Debug] code-first mode (agent-health.config.ts present): debug ${enabled ? 'enabled' : 'disabled'} in-memory only (not persisted)`);
92
+ return;
93
+ }
94
+ try {
95
+ const dir = path.join(process.cwd(), STATE_DIR);
96
+ const statePath = debugStatePath();
97
+ let config = {};
98
+ if (fs.existsSync(statePath)) {
99
+ const parsed = JSON.parse(fs.readFileSync(statePath, 'utf-8'));
100
+ if (parsed === null || typeof parsed !== 'object' || Array.isArray(parsed)) {
101
+ console.warn(`[Debug] State file contains non-object content, skipping write to avoid clobber`);
102
+ return;
103
+ }
104
+ config = parsed;
105
+ }
106
+ config.debug = enabled;
107
+ fs.mkdirSync(dir, { recursive: true });
108
+ fs.writeFileSync(statePath, JSON.stringify(config, null, 2) + '\n', 'utf-8');
109
+ console.info(`[Debug] Debug mode ${enabled ? 'enabled' : 'disabled'}, persisted to ${STATE_DIR}/${STATE_FILE}`);
110
+ }
111
+ catch (err) {
112
+ console.warn(`[Debug] Failed to persist debug state:`, err);
113
+ }
114
+ }
115
+ /**
116
+ * Debug log - only shown when debug mode is enabled
117
+ * Use for verbose/detailed logs that are noisy in normal operation
118
+ */
119
+ export function debug(module, ...args) {
120
+ if (isDebugEnabled()) {
121
+ console.debug(`[${module}]`, ...args);
122
+ }
123
+ }
124
+ /**
125
+ * Standard log levels - always available, use appropriately:
126
+ * - console.error() - errors
127
+ * - console.warn() - warnings
128
+ * - console.info() - important milestones (connection established, eval complete)
129
+ * - console.log() - normal operational logs
130
+ * - debug() - verbose details (raw data, classifications, etc.)
131
+ */
132
+ //# sourceMappingURL=debug.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"debug.js","sourceRoot":"","sources":["../../debug.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;GAOG;AAEH,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,MAAM,SAAS,GAAG,OAAO,MAAM,KAAK,WAAW,CAAC;AAEhD,2DAA2D;AAC3D,2DAA2D;AAC3D,qFAAqF;AACrF,+EAA+E;AAC/E,gCAAgC;AAChC,MAAM,SAAS,GAAG,eAAe,CAAC;AAClC,MAAM,UAAU,GAAG,YAAY,CAAC;AAChC,MAAM,qBAAqB,GAAG,CAAC,wBAAwB,EAAE,wBAAwB,EAAE,yBAAyB,CAAC,CAAC;AAE9G,SAAS,gBAAgB;IACvB,2EAA2E;IAC3E,6EAA6E;IAC7E,yEAAyE;IACzE,MAAM,IAAI,GAAG,OAAO,CAAC,GAAG,CAAC,IAAI,IAAI,OAAO,CAAC,GAAG,CAAC,WAAW,IAAI,EAAE,CAAC;IAC/D,OAAO,qBAAqB,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CACtC,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,CAAC;QAC1C,CAAC,CAAC,CAAC,IAAI,IAAI,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC,CAAC,CACz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AC,CAAC,GAAG,IAAI,EAAE,OAAO,CAAC,CAAC;QAC7E,OAAO,CAAC,IAAI,CAAC,sBAAsB,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,UAAU,kBAAkB,SAAS,IAAI,UAAU,EAAE,CAAC,CAAC;IAClH,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,OAAO,CAAC,IAAI,CAAC,wCAAwC,EAAE,GAAG,CAAC,CAAC;IAC9D,CAAC;AACH,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,KAAK,CAAC,MAAc,EAAE,GAAG,IAAe;IACtD,IAAI,cAAc,EAAE,EAAE,CAAC;QACrB,OAAO,CAAC,KAAK,CAAC,IAAI,MAAM,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC;IACxC,CAAC;AACH,CAAC;AAED;;;;;;;GAOG"}
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Startup-diagnostic gating.
3
+ *
4
+ * Informational startup lines (`[Connectors] … registered`, `[Config] …`) are
5
+ * useful in interactive use and in the long-running server's own log stream,
6
+ * but they MUST NOT corrupt machine-readable CLI output. `console.log` writes
7
+ * to stdout, which is exactly the channel `agent-health list … --output json`
8
+ * needs to keep clean for `| jq` / `python -m json.tool`.
9
+ *
10
+ * `canLogStartupDiagnosticsToStdout()` decides whether those lines may go to
11
+ * stdout. It returns false (suppress) when the current invocation is a CLI
12
+ * command whose stdout is being consumed by a machine:
13
+ * - `--output json` / `-o json` / `--output=json` was requested, or
14
+ * - `--quiet` / `-q`, or
15
+ * - stdout is not an interactive TTY (piped to `| jq`, redirected to a file).
16
+ *
17
+ * The long-running server is exempt: its stdout IS its log stream (often a
18
+ * non-TTY pipe under a process manager / tunnel), so its startup diagnostics
19
+ * always pass through.
20
+ */
21
+ export declare function canLogStartupDiagnosticsToStdout(): boolean;
22
+ /**
23
+ * Convenience: emit an informational startup diagnostic to stdout, but only
24
+ * when it won't corrupt machine-readable output (see
25
+ * `canLogStartupDiagnosticsToStdout`). A no-op otherwise.
26
+ */
27
+ export declare function logStartupDiagnostic(...args: unknown[]): void;
28
+ //# sourceMappingURL=diagnostics.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"diagnostics.d.ts","sourceRoot":"","sources":["../../diagnostics.ts"],"names":[],"mappings":"AAKA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,gCAAgC,IAAI,OAAO,CAoB1D;AAUD;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI,CAK7D"}
@@ -0,0 +1,65 @@
1
+ /*
2
+ * Copyright OpenSearch Contributors
3
+ * SPDX-License-Identifier: Apache-2.0
4
+ */
5
+ /**
6
+ * Startup-diagnostic gating.
7
+ *
8
+ * Informational startup lines (`[Connectors] … registered`, `[Config] …`) are
9
+ * useful in interactive use and in the long-running server's own log stream,
10
+ * but they MUST NOT corrupt machine-readable CLI output. `console.log` writes
11
+ * to stdout, which is exactly the channel `agent-health list … --output json`
12
+ * needs to keep clean for `| jq` / `python -m json.tool`.
13
+ *
14
+ * `canLogStartupDiagnosticsToStdout()` decides whether those lines may go to
15
+ * stdout. It returns false (suppress) when the current invocation is a CLI
16
+ * command whose stdout is being consumed by a machine:
17
+ * - `--output json` / `-o json` / `--output=json` was requested, or
18
+ * - `--quiet` / `-q`, or
19
+ * - stdout is not an interactive TTY (piped to `| jq`, redirected to a file).
20
+ *
21
+ * The long-running server is exempt: its stdout IS its log stream (often a
22
+ * non-TTY pipe under a process manager / tunnel), so its startup diagnostics
23
+ * always pass through.
24
+ */
25
+ export function canLogStartupDiagnosticsToStdout() {
26
+ // Server process: stdout is its own log stream, not the CLI's data channel.
27
+ if (isServerProcess())
28
+ return true;
29
+ const args = process.argv.slice(2);
30
+ // Explicit quiet.
31
+ if (args.includes('--quiet') || args.includes('-q'))
32
+ return false;
33
+ // Structured output requested (the documented breakage: list … --output json).
34
+ for (let i = 0; i < args.length; i++) {
35
+ const a = args[i];
36
+ if ((a === '--output' || a === '-o') && /^json$/i.test(args[i + 1] ?? ''))
37
+ return false;
38
+ if (/^--output=json$/i.test(a))
39
+ return false;
40
+ }
41
+ // Piped or redirected stdout (| jq, > file): keep it machine-clean.
42
+ if (process.stdout.isTTY !== true)
43
+ return false;
44
+ return true;
45
+ }
46
+ function isServerProcess() {
47
+ if (process.env.AGENT_HEALTH_SERVER === '1')
48
+ return true;
49
+ const entry = process.argv[1] ?? '';
50
+ // server/dist/index.js (built) or server.ts / server/index.ts (tsx dev).
51
+ return /(?:^|[/\\])server[/\\](?:dist[/\\])?index\.(?:js|ts)$/.test(entry)
52
+ || /(?:^|[/\\])server\.ts$/.test(entry);
53
+ }
54
+ /**
55
+ * Convenience: emit an informational startup diagnostic to stdout, but only
56
+ * when it won't corrupt machine-readable output (see
57
+ * `canLogStartupDiagnosticsToStdout`). A no-op otherwise.
58
+ */
59
+ export function logStartupDiagnostic(...args) {
60
+ if (canLogStartupDiagnosticsToStdout()) {
61
+ // eslint-disable-next-line no-console
62
+ console.log(...args);
63
+ }
64
+ }
65
+ //# sourceMappingURL=diagnostics.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"diagnostics.js","sourceRoot":"","sources":["../../diagnostics.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,UAAU,gCAAgC;IAC9C,4EAA4E;IAC5E,IAAI,eAAe,EAAE;QAAE,OAAO,IAAI,CAAC;IAEnC,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IAEnC,kBAAkB;IAClB,IAAI,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC;QAAE,OAAO,KAAK,CAAC;IAElE,+EAA+E;IAC/E,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACrC,MAAM,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,IAAI,CAAC,CAAC,KAAK,UAAU,IAAI,CAAC,KAAK,IAAI,CAAC,IAAI,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC;YAAE,OAAO,KAAK,CAAC;QACxF,IAAI,kBAAkB,CAAC,IAAI,CAAC,CAAC,CAAC;YAAE,OAAO,KAAK,CAAC;IAC/C,CAAC;IAED,oEAAoE;IACpE,IAAI,OAAO,CAAC,MAAM,CAAC,KAAK,KAAK,IAAI;QAAE,OAAO,KAAK,CAAC;IAEhD,OAAO,IAAI,CAAC;AACd,CAAC;AAED,SAAS,eAAe;IACtB,IAAI,OAAO,CAAC,GAAG,CAAC,mBAAmB,KAAK,GAAG;QAAE,OAAO,IAAI,CAAC;IACzD,MAAM,KAAK,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;IACpC,yEAAyE;IACzE,OAAO,uDAAuD,CAAC,IAAI,CAAC,KAAK,CAAC;WACrE,wBAAwB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AAC5C,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,oBAAoB,CAAC,GAAG,IAAe;IACrD,IAAI,gCAAgC,EAAE,EAAE,CAAC;QACvC,sCAAsC;QACtC,OAAO,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,CAAC;IACvB,CAAC;AACH,CAAC"}
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Read an env var, preferring `newName`, falling back to `oldName`.
3
+ * Returns `undefined` when neither is set.
4
+ *
5
+ * On first use of the old name in the current process, prints a one-time
6
+ * deprecation warning to stderr.
7
+ */
8
+ export declare function readEnv(newName: string, oldName: string): string | undefined;
9
+ /**
10
+ * Whether the old name is currently set (regardless of the new name).
11
+ * Useful for tests that exercise deprecation paths without triggering reads.
12
+ */
13
+ export declare function isLegacyEnvSet(oldName: string): boolean;
14
+ /**
15
+ * Emit a one-time deprecation warning for an old env var name.
16
+ * Subsequent calls for the same `oldName` are no-ops.
17
+ *
18
+ * Suppressed when AH_QUIET_DEPRECATIONS=1 (also accepts the old prefix
19
+ * AGENT_HEALTH_QUIET_DEPRECATIONS=1) so tests and CI can stay quiet.
20
+ */
21
+ export declare function warnDeprecated(oldName: string, newName: string): void;
22
+ /**
23
+ * TEST-ONLY: reset the warned set so a single test process can exercise
24
+ * multiple deprecation paths without one suppressing the next.
25
+ */
26
+ export declare function _resetDeprecationCacheForTests(): void;
27
+ //# sourceMappingURL=envCompat.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"envCompat.d.ts","sourceRoot":"","sources":["../../envCompat.ts"],"names":[],"mappings":"AAuBA;;;;;;GAMG;AACH,wBAAgB,OAAO,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAkB5E;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAGvD;AAED;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI,CAkBrE;AAED;;;GAGG;AACH,wBAAgB,8BAA8B,IAAI,IAAI,CAErD"}
@@ -0,0 +1,82 @@
1
+ /*
2
+ * Copyright OpenSearch Contributors
3
+ * SPDX-License-Identifier: Apache-2.0
4
+ */
5
+ /**
6
+ * Environment Variable Compatibility Layer
7
+ *
8
+ * Soft-deprecation helper for the `AGENT_HEALTH_*` → `AH_*` env var rename.
9
+ *
10
+ * Read sites should prefer the new `AH_*` name but fall back to the old
11
+ * `AGENT_HEALTH_*` name for one release. Old names emit a one-time
12
+ * deprecation warning per process.
13
+ *
14
+ * Example:
15
+ *
16
+ * const port = readEnv('AH_PORT', 'AGENT_HEALTH_PORT');
17
+ *
18
+ * The old name is scheduled for removal in a future major release.
19
+ */
20
+ const warned = new Set();
21
+ /**
22
+ * Read an env var, preferring `newName`, falling back to `oldName`.
23
+ * Returns `undefined` when neither is set.
24
+ *
25
+ * On first use of the old name in the current process, prints a one-time
26
+ * deprecation warning to stderr.
27
+ */
28
+ export function readEnv(newName, oldName) {
29
+ // Browser-like environments (and tests simulating them) may have no
30
+ // process.env at all; env reads must degrade to "unset", never throw,
31
+ // because this helper sits on module-load paths (lib/config,
32
+ // lib/portConfig) that browser bundles also import.
33
+ const env = typeof process !== 'undefined' ? process.env : undefined;
34
+ if (!env)
35
+ return undefined;
36
+ const newVal = env[newName];
37
+ if (newVal !== undefined)
38
+ return newVal;
39
+ const oldVal = env[oldName];
40
+ if (oldVal !== undefined) {
41
+ warnDeprecated(oldName, newName);
42
+ return oldVal;
43
+ }
44
+ return undefined;
45
+ }
46
+ /**
47
+ * Whether the old name is currently set (regardless of the new name).
48
+ * Useful for tests that exercise deprecation paths without triggering reads.
49
+ */
50
+ export function isLegacyEnvSet(oldName) {
51
+ const env = typeof process !== 'undefined' ? process.env : undefined;
52
+ return env ? env[oldName] !== undefined : false;
53
+ }
54
+ /**
55
+ * Emit a one-time deprecation warning for an old env var name.
56
+ * Subsequent calls for the same `oldName` are no-ops.
57
+ *
58
+ * Suppressed when AH_QUIET_DEPRECATIONS=1 (also accepts the old prefix
59
+ * AGENT_HEALTH_QUIET_DEPRECATIONS=1) so tests and CI can stay quiet.
60
+ */
61
+ export function warnDeprecated(oldName, newName) {
62
+ if (warned.has(oldName))
63
+ return;
64
+ warned.add(oldName);
65
+ const env = typeof process !== 'undefined' ? process.env : undefined;
66
+ if (env?.AH_QUIET_DEPRECATIONS === '1' ||
67
+ env?.AGENT_HEALTH_QUIET_DEPRECATIONS === '1') {
68
+ return;
69
+ }
70
+ // Use console.warn so this surfaces in normal stderr but doesn't crash
71
+ // structured-logging consumers. Prefix matches the rest of the codebase.
72
+ console.warn(`[agent-health] Deprecated env var ${oldName} is set; please rename it to ${newName}. ` +
73
+ `The old name will be removed in a future release.`);
74
+ }
75
+ /**
76
+ * TEST-ONLY: reset the warned set so a single test process can exercise
77
+ * multiple deprecation paths without one suppressing the next.
78
+ */
79
+ export function _resetDeprecationCacheForTests() {
80
+ warned.clear();
81
+ }
82
+ //# sourceMappingURL=envCompat.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"envCompat.js","sourceRoot":"","sources":["../../envCompat.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;;;;;;;GAcG;AAEH,MAAM,MAAM,GAAG,IAAI,GAAG,EAAU,CAAC;AAEjC;;;;;;GAMG;AACH,MAAM,UAAU,OAAO,CAAC,OAAe,EAAE,OAAe;IACtD,oEAAoE;IACpE,sEAAsE;IACtE,6DAA6D;IAC7D,oDAAoD;IACpD,MAAM,GAAG,GAAG,OAAO,OAAO,KAAK,WAAW,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,SAAS,CAAC;IACrE,IAAI,CAAC,GAAG;QAAE,OAAO,SAAS,CAAC;IAE3B,MAAM,MAAM,GAAG,GAAG,CAAC,OAAO,CAAC,CAAC;IAC5B,IAAI,MAAM,KAAK,SAAS;QAAE,OAAO,MAAM,CAAC;IAExC,MAAM,MAAM,GAAG,GAAG,CAAC,OAAO,CAAC,CAAC;IAC5B,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;QACzB,cAAc,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QACjC,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,cAAc,CAAC,OAAe;IAC5C,MAAM,GAAG,GAAG,OAAO,OAAO,KAAK,WAAW,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,SAAS,CAAC;IACrE,OAAO,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,KAAK,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC;AAClD,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,cAAc,CAAC,OAAe,EAAE,OAAe;IAC7D,IAAI,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC;QAAE,OAAO;IAChC,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IAEpB,MAAM,GAAG,GAAG,OAAO,OAAO,KAAK,WAAW,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,SAAS,CAAC;IACrE,IACE,GAAG,EAAE,qBAAqB,KAAK,GAAG;QAClC,GAAG,EAAE,+BAA+B,KAAK,GAAG,EAC5C,CAAC;QACD,OAAO;IACT,CAAC;IAED,uEAAuE;IACvE,yEAAyE;IACzE,OAAO,CAAC,IAAI,CACV,qCAAqC,OAAO,gCAAgC,OAAO,IAAI;QACvF,mDAAmD,CACpD,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,8BAA8B;IAC5C,MAAM,CAAC,KAAK,EAAE,CAAC;AACjB,CAAC"}
@@ -0,0 +1,63 @@
1
+ /**
2
+ * Pure, isomorphic helpers for "re-run an evaluation run" (duplicate the
3
+ * source run's config into a brand-new run, linked back via `rerunOf`).
4
+ *
5
+ * Split out from the route/service layer so both the server (which owns the
6
+ * real duplication + creation) and the UI (which renders a name preview in
7
+ * the confirm dialog before the user commits) can share the exact same
8
+ * naming logic without an extra network round-trip. No storage/IO here.
9
+ */
10
+ import type { EvaluationRun, TestCaseSource } from '../types/index.js';
11
+ /**
12
+ * Compute the name for a new run being created as a re-run of `sourceName`.
13
+ *
14
+ * - "My Run" -> "My Run (re-run)"
15
+ * - "My Run (re-run)" -> "My Run (re-run 2)"
16
+ * - "My Run (re-run 2)" -> "My Run (re-run 3)"
17
+ * - undefined/empty -> "Evaluation Run (re-run)"
18
+ */
19
+ export declare function computeRerunName(sourceName: string | undefined | null): string;
20
+ /**
21
+ * Fields duplicated onto the new run when re-running a source run. Mirrors
22
+ * the subset of {@link EvaluationRun} that `POST /api/storage/evaluation-runs`
23
+ * accepts as input (see server/routes/storage/evaluationRuns.ts) — i.e. the
24
+ * "config" as opposed to results/stats/timestamps, which are always fresh.
25
+ */
26
+ export interface RerunConfig {
27
+ sources: TestCaseSource[];
28
+ agentKey: string;
29
+ /** Fallback modelId if the agent's own config can't resolve one (legacy). */
30
+ modelId: string;
31
+ judgeModelId?: string;
32
+ evaluatorId?: string;
33
+ headers?: Record<string, string>;
34
+ concurrency?: number;
35
+ agentEndpoint?: string;
36
+ description?: string;
37
+ benchmarkId?: string;
38
+ benchmarkVersion?: number;
39
+ }
40
+ export interface BuildRerunConfigResult {
41
+ config: RerunConfig;
42
+ /**
43
+ * Human-readable notes on which fields were missing on the source run and
44
+ * what explicit default was substituted (empty when the source run's
45
+ * config was fully populated). Surfaced back to the caller (API response
46
+ * -> UI) so a legacy run's best-effort re-run isn't a silent guess.
47
+ */
48
+ defaultsApplied: string[];
49
+ }
50
+ export interface BuildRerunConfigError {
51
+ error: string;
52
+ }
53
+ /**
54
+ * Duplicate a source run's execution config for a re-run, applying explicit,
55
+ * reported defaults for fields missing on legacy run documents. Pure
56
+ * function — no storage access (benchmark-existence checks live in
57
+ * services/evaluationRerun.ts, which needs the storage module).
58
+ *
59
+ * Returns `{ error }` only when the source run is missing a field with no
60
+ * safe default (nothing to run, or no agent to run it against).
61
+ */
62
+ export declare function buildRerunConfig(sourceRun: EvaluationRun): BuildRerunConfigResult | BuildRerunConfigError;
63
+ //# sourceMappingURL=evaluationRerun.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"evaluationRerun.d.ts","sourceRoot":"","sources":["../../evaluationRerun.ts"],"names":[],"mappings":"AAKA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAU7D;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAAC,UAAU,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,GAAG,MAAM,CAgB9E;AAED;;;;;GAKG;AACH,MAAM,WAAW,WAAW;IAC1B,OAAO,EAAE,cAAc,EAAE,CAAC;IAC1B,QAAQ,EAAE,MAAM,CAAC;IACjB,6EAA6E;IAC7E,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED,MAAM,WAAW,sBAAsB;IACrC,MAAM,EAAE,WAAW,CAAC;IACpB;;;;;OAKG;IACH,eAAe,EAAE,MAAM,EAAE,CAAC;CAC3B;AAED,MAAM,WAAW,qBAAqB;IACpC,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;;;;;;;GAQG;AACH,wBAAgB,gBAAgB,CAC9B,SAAS,EAAE,aAAa,GACvB,sBAAsB,GAAG,qBAAqB,CAiDhD"}
@@ -0,0 +1,85 @@
1
+ /*
2
+ * Copyright OpenSearch Contributors
3
+ * SPDX-License-Identifier: Apache-2.0
4
+ */
5
+ const DEFAULT_RUN_NAME = 'Evaluation Run';
6
+ /**
7
+ * Matches a trailing "(re-run)" or "(re-run N)" suffix, case-insensitively,
8
+ * capturing the base name and the optional numeric suffix.
9
+ */
10
+ const RERUN_SUFFIX_RE = /^(.*?)\s*\(re-run(?:\s+(\d+))?\)$/i;
11
+ /**
12
+ * Compute the name for a new run being created as a re-run of `sourceName`.
13
+ *
14
+ * - "My Run" -> "My Run (re-run)"
15
+ * - "My Run (re-run)" -> "My Run (re-run 2)"
16
+ * - "My Run (re-run 2)" -> "My Run (re-run 3)"
17
+ * - undefined/empty -> "Evaluation Run (re-run)"
18
+ */
19
+ export function computeRerunName(sourceName) {
20
+ const trimmed = (sourceName || '').trim();
21
+ const base = trimmed || DEFAULT_RUN_NAME;
22
+ const match = base.match(RERUN_SUFFIX_RE);
23
+ if (!match) {
24
+ return `${base} (re-run)`;
25
+ }
26
+ const [, rawBaseName, suffixNumber] = match;
27
+ // A source named literally "(re-run)" / "(re-run 2)" (no prefix) captures
28
+ // an empty baseName — fall back to the default rather than emitting a
29
+ // leading-space name like " (re-run 2)".
30
+ const baseName = rawBaseName.trim() || DEFAULT_RUN_NAME;
31
+ const nextNumber = suffixNumber ? parseInt(suffixNumber, 10) + 1 : 2;
32
+ return `${baseName} (re-run ${nextNumber})`;
33
+ }
34
+ /**
35
+ * Duplicate a source run's execution config for a re-run, applying explicit,
36
+ * reported defaults for fields missing on legacy run documents. Pure
37
+ * function — no storage access (benchmark-existence checks live in
38
+ * services/evaluationRerun.ts, which needs the storage module).
39
+ *
40
+ * Returns `{ error }` only when the source run is missing a field with no
41
+ * safe default (nothing to run, or no agent to run it against).
42
+ */
43
+ export function buildRerunConfig(sourceRun) {
44
+ const defaultsApplied = [];
45
+ if (!sourceRun.agentKey) {
46
+ return { error: 'Source run is missing agentKey; cannot determine which agent to re-run.' };
47
+ }
48
+ let sources = sourceRun.sources;
49
+ if (!sources || sources.length === 0) {
50
+ const snapshotIds = (sourceRun.testCaseSnapshots || []).map(s => s.id);
51
+ if (snapshotIds.length === 0) {
52
+ return {
53
+ error: 'Source run has no test cases to re-run (missing both sources and testCaseSnapshots).',
54
+ };
55
+ }
56
+ sources = [{ type: 'test-case-ids', ids: snapshotIds }];
57
+ defaultsApplied.push(`sources -> derived from testCaseSnapshots (${snapshotIds.length} test case id(s); legacy run had no sources recorded)`);
58
+ }
59
+ let concurrency = sourceRun.concurrency;
60
+ if (concurrency == null) {
61
+ concurrency = 1;
62
+ defaultsApplied.push('concurrency -> 1 (default; not set on source run)');
63
+ }
64
+ const config = {
65
+ sources,
66
+ agentKey: sourceRun.agentKey,
67
+ modelId: sourceRun.modelId || '',
68
+ judgeModelId: sourceRun.judgeModelId,
69
+ evaluatorId: sourceRun.evaluatorId,
70
+ headers: sourceRun.headers,
71
+ concurrency,
72
+ agentEndpoint: sourceRun.agentEndpoint,
73
+ description: sourceRun.description,
74
+ benchmarkId: sourceRun.benchmarkId,
75
+ benchmarkVersion: sourceRun.benchmarkVersion,
76
+ };
77
+ // NOTE: evaluatorId/judgeModelId/agentEndpoint/headers/description are
78
+ // legitimately optional on ANY run (not just legacy ones), so leaving them
79
+ // `undefined` is normal behavior, not a legacy-config gap — they are NOT
80
+ // reported in `defaultsApplied` (that list is reserved for cases where we
81
+ // had to fabricate a value because the source run's config was
82
+ // incomplete).
83
+ return { config, defaultsApplied };
84
+ }
85
+ //# sourceMappingURL=evaluationRerun.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"evaluationRerun.js","sourceRoot":"","sources":["../../evaluationRerun.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAcH,MAAM,gBAAgB,GAAG,gBAAgB,CAAC;AAE1C;;;GAGG;AACH,MAAM,eAAe,GAAG,oCAAoC,CAAC;AAE7D;;;;;;;GAOG;AACH,MAAM,UAAU,gBAAgB,CAAC,UAAqC;IACpE,MAAM,OAAO,GAAG,CAAC,UAAU,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;IAC1C,MAAM,IAAI,GAAG,OAAO,IAAI,gBAAgB,CAAC;IAEzC,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC;IAC1C,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,OAAO,GAAG,IAAI,WAAW,CAAC;IAC5B,CAAC;IAED,MAAM,CAAC,EAAE,WAAW,EAAE,YAAY,CAAC,GAAG,KAAK,CAAC;IAC5C,0EAA0E;IAC1E,sEAAsE;IACtE,yCAAyC;IACzC,MAAM,QAAQ,GAAG,WAAW,CAAC,IAAI,EAAE,IAAI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AC5B,OAAO,EAAE,SAAS,CAAC,OAAO,IAAI,EAAE;QAChC,YAAY,EAAE,SAAS,CAAC,YAAY;QACpC,WAAW,EAAE,SAAS,CAAC,WAAW;QAClC,OAAO,EAAE,SAAS,CAAC,OAAO;QAC1B,WAAW;QACX,aAAa,EAAE,SAAS,CAAC,aAAa;QACtC,WAAW,EAAE,SAAS,CAAC,WAAW;QAClC,WAAW,EAAE,SAAS,CAAC,WAAW;QAClC,gBAAgB,EAAE,SAAS,CAAC,gBAAgB;KAC7C,CAAC;IAEF,uEAAuE;IACvE,2EAA2E;IAC3E,yEAAyE;IACzE,0EAA0E;IAC1E,+DAA+D;IAC/D,eAAe;IAEf,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,CAAC;AACrC,CAAC"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Walk up from `startDir` looking for the agent-health package root.
3
+ *
4
+ * @throws if no package.json is found within `maxLevels` parents.
5
+ */
6
+ export declare function findPackageRootFrom(startDir: string, maxLevels?: number): string;
7
+ //# sourceMappingURL=findPackageRoot.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"findPackageRoot.d.ts","sourceRoot":"","sources":["../../findPackageRoot.ts"],"names":[],"mappings":"AAyBA;;;;GAIG;AACH,wBAAgB,mBAAmB,CACjC,QAAQ,EAAE,MAAM,EAChB,SAAS,GAAE,MAA2B,GACrC,MAAM,CA6BR"}
@@ -0,0 +1,57 @@
1
+ /*
2
+ * Copyright OpenSearch Contributors
3
+ * SPDX-License-Identifier: Apache-2.0
4
+ */
5
+ /**
6
+ * Pure helper to locate the agent-health package root from any starting
7
+ * directory.
8
+ *
9
+ * Kept in its own file (no `import.meta.url`) so it can be unit-tested with
10
+ * ts-jest's CommonJS loader without needing module mocks.
11
+ *
12
+ * The walk preferentially anchors on the agent-health package.json (matched
13
+ * by `name`) so we don't stop at a parent monorepo root or a wrapper
14
+ * package.json. If no matching package.json is found within `maxLevels`
15
+ * (e.g., the user has forked and renamed the package), we fall back to the
16
+ * nearest package.json on the path — best-effort.
17
+ */
18
+ import { existsSync, readFileSync } from 'fs';
19
+ import { dirname, join, resolve } from 'path';
20
+ const PACKAGE_NAME = '@opensearch-project/agent-health';
21
+ const DEFAULT_MAX_LEVELS = 6;
22
+ /**
23
+ * Walk up from `startDir` looking for the agent-health package root.
24
+ *
25
+ * @throws if no package.json is found within `maxLevels` parents.
26
+ */
27
+ export function findPackageRootFrom(startDir, maxLevels = DEFAULT_MAX_LEVELS) {
28
+ // First pass: prefer a package.json with the canonical agent-health name.
29
+ let dir = resolve(startDir);
30
+ let firstPkgRoot = null;
31
+ for (let i = 0; i <= maxLevels; i++) {
32
+ const pkgPath = join(dir, 'package.json');
33
+ if (existsSync(pkgPath)) {
34
+ if (firstPkgRoot === null)
35
+ firstPkgRoot = dir;
36
+ try {
37
+ const pkg = JSON.parse(readFileSync(pkgPath, 'utf8'));
38
+ if (pkg && pkg.name === PACKAGE_NAME)
39
+ return dir;
40
+ }
41
+ catch {
42
+ /* unreadable / unparseable package.json — keep walking */
43
+ }
44
+ }
45
+ const parent = dirname(dir);
46
+ if (parent === dir)
47
+ break;
48
+ dir = parent;
49
+ }
50
+ // Fallback: nearest package.json regardless of name. Covers forks that
51
+ // rename the package and unusual local layouts.
52
+ if (firstPkgRoot !== null)
53
+ return firstPkgRoot;
54
+ throw new Error(`Could not locate package root for ${PACKAGE_NAME} from ${startDir} ` +
55
+ `within ${maxLevels} parent directories`);
56
+ }
57
+ //# sourceMappingURL=findPackageRoot.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"findPackageRoot.js","sourceRoot":"","sources":["../../findPackageRoot.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,IAAI,CAAC;AAC9C,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAE9C,MAAM,YAAY,GAAG,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AfterResponseContext, BuildTrajectoryContext, TrajectoryStep } from '../types/index.js';
6
+ /**
7
+ * Execute the beforeRequest hook if defined on the agent.
8
+ *
9
+ * - Returns the original context unchanged if no hook is defined
10
+ * - Validates the hook return value has required fields
11
+ * - Wraps errors with a descriptive message including the agent key
12
+ */
13
+ export declare function executeBeforeRequestHook(hooks: AgentHooks | undefined, context: BeforeRequestContext, agentKey: string): Promise<BeforeRequestContext>;
14
+ /**
15
+ * Execute the afterResponse hook if defined on the agent.
16
+ *
17
+ * Use this hook to extract custom runId formats from agent responses
18
+ * (e.g., PER agent's memory_id).
19
+ *
20
+ * - Returns the original context unchanged if no hook is defined
21
+ * - Validates the hook return value has required fields
22
+ * - Wraps errors with a descriptive message including the agent key
23
+ */
24
+ export declare function executeAfterResponseHook(hooks: AgentHooks | undefined, context: AfterResponseContext, agentKey: string): Promise<AfterResponseContext>;
25
+ /**
26
+ * Execute the buildTrajectory hook if defined on the agent.
27
+ *
28
+ * Use this hook to customize trajectory extraction from OTEL traces
29
+ * for agents with custom span formats.
30
+ *
31
+ * - Returns null if no hook is defined
32
+ * - Validates the hook return value is an array
33
+ * - Wraps errors with a descriptive message including the agent key
34
+ */
35
+ export declare function executeBuildTrajectoryHook(hooks: AgentHooks | undefined, context: BuildTrajectoryContext, agentKey: string): Promise<TrajectoryStep[] | null>;
36
+ //# sourceMappingURL=hooks.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hooks.d.ts","sourceRoot":"","sources":["../../hooks.ts"],"names":[],"mappings":"AAKA;;;GAGG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,sBAAsB,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAG9H;;;;;;GAMG;AACH,wBAAsB,wBAAwB,CAC5C,KAAK,EAAE,UAAU,GAAG,SAAS,EAC7B,OAAO,EAAE,oBAAoB,EAC7B,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,oBAAoB,CAAC,CA6B/B;AAED;;;;;;;;;GASG;AACH,wBAAsB,wBAAwB,CAC5C,KAAK,EAAE,UAAU,GAAG,SAAS,EAC7B,OAAO,EAAE,oBAAoB,EAC7B,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,oBAAoB,CAAC,CAoC/B;AAED;;;;;;;;;GASG;AACH,wBAAsB,0BAA0B,CAC9C,KAAK,EAAE,UAAU,GAAG,SAAS,EAC7B,OAAO,EAAE,sBAAsB,EAC/B,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,cAAc,EAAE,GAAG,IAAI,CAAC,CAkBlC"}