@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,191 @@
1
+ <!--
2
+ * Copyright OpenSearch Contributors
3
+ * SPDX-License-Identifier: Apache-2.0
4
+ -->
5
+
6
+ # Agent Profiling — improve an agent from its own sessions
7
+
8
+ **Agent profiling** is to an AI agent what a CPU/JVM profiler is to a running
9
+ program: you attach to a *real session*, sample its execution (OpenTelemetry
10
+ traces), and get back a report of where the agent went wrong and what to fix —
11
+ in the agent's **own codebase**. Instead of profiling for performance hotspots,
12
+ it profiles for *behavioral* problems, scored against an evaluator you choose as
13
+ the rubric.
14
+
15
+ No synthetic test cases. The session you just ran is the input, and the
16
+ corrections you made while steering it are part of the signal. Because it reads
17
+ **traces**, not chat logs, it works for non-chat agents too.
18
+
19
+ It reuses the same pluggable `Evaluator` definitions and the same
20
+ `improvementStrategies[]` shape as the batch eval pipeline — it just points them
21
+ at a live session's traces.
22
+
23
+ ---
24
+
25
+ ## Setup (once per project)
26
+
27
+ ```bash
28
+ # 1. Install the agent-profiling hook + skill into Claude Code.
29
+ # - a PreToolUse hook that records the current session id to
30
+ # .claude/agent-health/current-session (deterministic — no mtime guessing)
31
+ # - the /agent-health:profile slash command
32
+ # - the curated customer skills (agent-health-profile, agent-health-assistant,
33
+ # instrument-otel)
34
+ npx @opensearch-project/agent-health setup
35
+
36
+ # 2. Stream Claude Code telemetry into Agent Health's OpenSearch.
37
+ npx @opensearch-project/agent-health setup-telemetry
38
+ ```
39
+
40
+ `setup` is idempotent — re-running won't duplicate the hook, and won't overwrite
41
+ skill/command files unless you pass `--force`. For **Kiro**, drop
42
+ `docs/skills/AGENT_PROFILE.md` under `.kiro/steering/`; for other tools, tell the
43
+ assistant "read AGENT_PROFILE.md and follow it".
44
+
45
+ ### pi (pi.dev)
46
+
47
+ pi has no native telemetry, so a **zero-dependency, single-file extension**
48
+ ([examples/pi-profiling/agent-health-profile.ts](../../examples/pi-profiling/agent-health-profile.ts))
49
+ both *instruments* the live pi session (emitting `invoke_agent` / `chat` /
50
+ `execute_tool` spans stamped with `session.id`, service `pi-agent`) and registers
51
+ the profiling command. It speaks OTLP over `fetch` — nothing to `npm install`.
52
+ Full guide: [docs/PI_PROFILING.md](../PI_PROFILING.md).
53
+
54
+ ```bash
55
+ # 1. Drop the extension in (global = every pi session).
56
+ cp examples/pi-profiling/agent-health-profile.ts ~/.pi/agent/extensions/
57
+
58
+ # 2. Point telemetry at a trace store BEFORE starting pi. Simplest is
59
+ # Agent Health in FILE mode (no OpenSearch) — its embedded receiver persists
60
+ # spans and matches sessions out of the box:
61
+ export OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4001 # /v1/traces is appended
62
+ ```
63
+
64
+ The extension records the session id to `.pi/agent-health/current-session` on
65
+ `session_start`, so `agent-health profile` resolves it with no guessing and
66
+ defaults `--service` to `pi-agent`. When done, run `/agent-health-profile -e
67
+ <evaluator-id>` from inside pi (or `agent-health profile --service pi-agent
68
+ --output json` from a shell). See [examples/pi-profiling/README.md](../../examples/pi-profiling/README.md)
69
+ for OpenSearch-backed routing notes (export to the cluster's own OTLP ingest;
70
+ the embedded receiver drops payloads when a cluster is configured).
71
+
72
+ ---
73
+
74
+ ## Usage
75
+
76
+ Use your agent normally and steer it as you like. When the session is done:
77
+
78
+ ```bash
79
+ # From inside the coding session (slash command):
80
+ /agent-health:profile -e <evaluator-id>
81
+
82
+ # …or directly, optionally with upfront feedback to steer the analysis:
83
+ npx @opensearch-project/agent-health profile -e <evaluator-id> --feedback "focus on routing; it ignored the SOP"
84
+ ```
85
+
86
+ If `-e` is omitted it defaults to `system-rca-default`. `--feedback "<text>"` is
87
+ optional upfront human steering — context the traces can't capture; the reasoner
88
+ weights it above the deterministic signals. List evaluators with
89
+ `agent-health list` (or the `/api/storage/evaluators` API).
90
+
91
+ ---
92
+
93
+ ## How it works
94
+
95
+ ```
96
+ your session ──OTel spans──▶ Agent Health (OpenSearch)
97
+ │
98
+ agent-health profile -e <id> │ resolves: evaluator rubric (by id)
99
+ ▼ samples: this session's spans → trajectory
100
+ { evaluator, trajectory, signals } + a deterministic signal scan
101
+ │
102
+ the coding agent adds: the live chat + the codebase it's sitting in
103
+ ▼
104
+ prioritized edits → applied on a branch → you review
105
+ ```
106
+
107
+ `profile` supplies only the half the agent can't see — the **traces** and the
108
+ **rubric**. The agent already has the conversation and the code, so it does the
109
+ reasoning and the edits. (For a headless context the JSON profile can be fed to
110
+ any reasoner.)
111
+
112
+ ### What the profile contains (`--output json`)
113
+
114
+ ```jsonc
115
+ {
116
+ "session": { "sessionId", "serviceName", "traceIds", "spanCount", "trajectorySteps", "durationMs", "tokens" },
117
+ "evaluator": { "id", "name", "systemPrompt", "metrics", "passThreshold" },
118
+ "signals": [ { "id", "title", "severity", "count", "evidence" } ],
119
+ "userFeedback": "<your --feedback text, if given>",
120
+ "trajectory":[ /* TrajectoryStep[] reconstructed from spans */ ],
121
+ "instructions": "Using the rubric + feedback, review trajectory + signals + chat + codebase; propose edits…"
122
+ }
123
+ ```
124
+
125
+ It is also written to `.agent-health/data/profiles/<sessionId>/profile.json`.
126
+
127
+ ### Signals scanned (deterministic, pre-LLM)
128
+
129
+ | id | meaning |
130
+ |---|---|
131
+ | `user_rejection` | you rejected/aborted a tool the agent proposed (Claude Code permission denial — always available, no prompt logging needed) |
132
+ | `user_redirect` | you corrected/redirected the agent mid-session (requires `OTEL_LOG_USER_PROMPTS=1`) |
133
+ | `tool_error_retry` | a tool failed, then was retried — tool-usage / description gap |
134
+ | `repeated_tool_calls` | identical tool+args invoked more than once — loop / distrust |
135
+ | `long_session` | unusually many interactions — confusion or scope creep |
136
+ | `write_before_read` | mutated state before reading — safety / grounding gap |
137
+
138
+ Signals are evidence handed to the rubric, not the verdict — the evaluator's
139
+ `systemPrompt` decides what to improve. The adapter reads real Claude Code
140
+ telemetry (attribute-based `claude_code.*` spans) and falls back to generic OTel
141
+ GenAI event-based spans for other agents.
142
+
143
+ ---
144
+
145
+ ## Session identification
146
+
147
+ `profile` resolves the session id in priority order:
148
+ 1. `--session <id>` if you pass it,
149
+ 2. `.pi/agent-health/current-session` (written by the pi `agent-health-profile`
150
+ extension on `session_start` — exact),
151
+ 3. `.claude/agent-health/current-session` (written by the Claude setup hook — exact),
152
+ 4. newest Claude Code transcript for this cwd (heuristic fallback).
153
+
154
+ Every Claude Code span carries `session.id`, and the pi extension stamps the
155
+ same `session.id` on the spans it emits, so once resolved the fetch is exact
156
+ (`fetchTracesBySessionId`). When the session is resolved from the pi marker,
157
+ `--service` defaults to `pi-agent`.
158
+
159
+ ---
160
+
161
+ ## The loop
162
+
163
+ ```
164
+ profile → read findings → fix on a branch → merge → next session → re-profile
165
+ ```
166
+
167
+ Run it after any session, or on a schedule (cron) over production sessions to
168
+ get a continuous improvement signal at production distribution.
169
+
170
+ ---
171
+
172
+ ## Guardrails
173
+
174
+ - `profile` is read-only — it never edits code; it produces the profile + a plan.
175
+ - Apply edits on a **branch**, never the working tree, and keep them minimal and
176
+ generalizable.
177
+ - The rubric is the customer's evaluator, so improvements track *their*
178
+ definition of good.
179
+
180
+ ---
181
+
182
+ ## Prerequisites
183
+
184
+ `profile` reads traces from, and the judge scores against, the same backend the
185
+ rest of Agent Health uses:
186
+ - **OpenSearch** for traces (`OPENSEARCH_LOGS_*` or `agent-health.config.json`
187
+ → `observability`) — the *same* cluster your telemetry is exported to.
188
+ - **AWS Bedrock** credentials for the LLM judge (`AWS_PROFILE` / `AWS_REGION`).
189
+
190
+ Verify with `agent-health doctor`. Litmus test: if your session shows up in the
191
+ **Traces** tab, `profile` will find it.
@@ -0,0 +1,68 @@
1
+ ---
2
+ name: add-connector
3
+ description: Use when adding, modifying, or debugging agent connectors. Provides connector architecture, built-in types, and custom connector template.
4
+ ---
5
+
6
+ ## Connector System (`services/connectors/`)
7
+
8
+ Pluggable abstraction for agent communication protocols.
9
+
10
+ ### Key Files
11
+ - `types.ts`: `AgentConnector`, `ConnectorRequest`, `ConnectorResponse` interfaces
12
+ - `registry.ts`: Singleton `connectorRegistry` — `get()`, `getForAgent()`
13
+ - `base/BaseConnector.ts`: Abstract base with auth header building
14
+ - `index.ts`: Browser-safe exports (no Node.js deps)
15
+ - `server.ts`: All connectors including Node.js-only (subprocess, claude-code)
16
+
17
+ ### Built-in Connectors
18
+
19
+ | Connector | Protocol | Use Case |
20
+ |-----------|----------|----------|
21
+ | `agui-streaming` | AG-UI SSE | ML-Commons agents (default) |
22
+ | `rest` | HTTP POST | Non-streaming REST APIs |
23
+ | `openai-compatible` | OpenAI Chat Completions | LiteLLM, Ollama, vLLM |
24
+ | `langgraph` | LangGraph REST `/invoke` | Non-AG-UI LangGraph instances |
25
+ | `strands` | Bedrock Agent Runtime | Amazon Strands agents (server-only) |
26
+ | `subprocess` | CLI stdin/stdout | Generic command-line tools |
27
+ | `claude-code` | Claude CLI | Claude Code agent (extends `subprocess`) |
28
+ | `kiro` | Kiro CLI | Kiro coding agent (extends `subprocess`; parses `[tool]` stderr markers) |
29
+ | `pi` | Pi CLI | Pi coding agent (extends `subprocess`) |
30
+ | `mock` | In-memory | Demo and testing |
31
+
32
+ ### Usage
33
+ ```typescript
34
+ import { connectorRegistry } from '@/services/connectors';
35
+ const connector = connectorRegistry.getForAgent(agentConfig);
36
+ const response = await connector.execute(endpoint, request, auth, onProgress);
37
+ ```
38
+
39
+ ### Creating a Custom Connector
40
+ ```typescript
41
+ import { BaseConnector } from '@/services/connectors';
42
+
43
+ class CustomConnector extends BaseConnector {
44
+ readonly type = 'custom' as const;
45
+ readonly name = 'My Custom Agent';
46
+ readonly supportsStreaming = true;
47
+
48
+ async execute(endpoint, request, auth, onProgress) {
49
+ // Your protocol implementation
50
+ }
51
+ }
52
+
53
+ connectorRegistry.register(new CustomConnector());
54
+ ```
55
+
56
+ ### Trace correlation & subprocess hooks
57
+
58
+ - **Trace context propagation** is handled by `BaseConnector` — set
59
+ `connectorConfig.traceContext` so the agent's spans join the eval `test_case`
60
+ trace tree:
61
+ - `propagateEnv: true` → inject `TRACEPARENT` env into subprocess agents (`buildTraceparentEnv()`).
62
+ - `propagateHeader: true` → inject a `traceparent` HTTP header into HTTP/SSE agents (`injectTraceparentHeaders()`).
63
+ - `serviceName: '<otel-service-name>'` → service-name + time-window fallback. Defaults: `claude-code-agent`, `kiro-agent`, `pi-agent`, `observio-sample-agent`. See the "Trace correlation conventions" section in `AGENTS.md`.
64
+ - **Subprocess connectors** (`SubprocessConnector` subclasses) can override
65
+ `parseStderrChunk(chunk)` to turn stderr markers into trajectory steps (how
66
+ `kiro` surfaces `[tool] Running:` / `[tool] status:` as `action` +
67
+ `tool_result` steps). The base class persists `stderr` to `rawOutput` and
68
+ honors per-request `connectorConfig` overrides (`args` / `inputMode` / `timeout`).
@@ -0,0 +1,40 @@
1
+ ---
2
+ name: agent-health-profile
3
+ description: Use when the user wants to profile or improve the agent/codebase based on the current session. Profiles this session's traces against a chosen evaluator and proposes concrete edits.
4
+ ---
5
+
6
+ # Agent Health — Profile this session
7
+
8
+ When the user asks to profile/improve the agent (or runs `/agent-health:profile`):
9
+
10
+ 1. Determine the evaluator id (the rubric). If the user gave one (e.g. `-e my-eval`),
11
+ use it; otherwise default to `system-rca-default`. You can list options with
12
+ `agent-health list` if needed.
13
+
14
+ 1b. **Ask the user for any upfront feedback** on the session before profiling
15
+ (e.g. "anything you want me to focus on — a wrong decision, a skipped step?").
16
+ If they give some, pass it via `--feedback "..."`; it becomes the primary lens
17
+ over the deterministic signals. Skip if they have nothing to add.
18
+
19
+ 2. Run:
20
+ ```bash
21
+ __AH_CLI__ profile -e <evaluator-id> [--feedback "<their feedback>"] --output json
22
+ ```
23
+ It auto-detects the current session id (from `.claude/agent-health/current-session`,
24
+ written by the setup hook) and prints a JSON profile: the evaluator rubric,
25
+ the session trajectory (reconstructed from traces), deterministic signals, and
26
+ your `userFeedback`.
27
+
28
+ 3. Using `evaluator.systemPrompt` as the rubric, review together:
29
+ - the `userFeedback` (weight it highest, if present),
30
+ - the `trajectory` and `signals` from the JSON profile,
31
+ - THIS conversation (including any corrections the user made while steering you),
32
+ - the codebase in the current working directory.
33
+
34
+ 4. Produce a prioritized list of concrete edits. For each: the file, the change,
35
+ why (tie it to a signal or a rubric criterion), a priority, and **cite the
36
+ evidence** — the signal that triggered it and the session's `traceIds`
37
+ (open them in the Traces tab to verify).
38
+
39
+ 5. Apply the edits on a new branch (never the working tree directly), then
40
+ summarize the diff for the user to review.
@@ -0,0 +1,194 @@
1
+ ---
2
+ name: config-auth
3
+ description: Use when working on config loading, authentication, AWS profiles, or data source resolution. Explains the two config systems (TS vs JSON), auth priority, and multi-profile setup.
4
+ ---
5
+
6
+ ## Config & Auth Architecture
7
+
8
+ Agent Health uses **two separate config systems** for different purposes. Understanding when each applies prevents auth confusion when users have multiple AWS profiles.
9
+
10
+ ### Two Config Systems
11
+
12
+ | System | File | Format | Purpose | Managed By |
13
+ |--------|------|--------|---------|------------|
14
+ | **Agent/Model Config** | `agent-health.config.ts` | TS/JS/MJS | Agents, models, connectors, hooks, judge | User edits manually |
15
+ | **Data Source Config** | `agent-health.config.json` | JSON only | OpenSearch credentials (storage + observability) | CLI `setup-telemetry` / Settings UI |
16
+
17
+ **Priority for TS/JS config loading** (`lib/config/loader.ts`):
18
+ 1. `agent-health.config.ts` (highest)
19
+ 2. `agent-health.config.js`
20
+ 3. `agent-health.config.mjs`
21
+ 4. Built-in defaults — **only merged when `extends: false` is NOT set**; setting `extends: false` in your config disables default merging entirely
22
+
23
+ **Why two systems?**
24
+ - TS config can contain executable code (hooks, dynamic values, custom connectors)
25
+ - JSON config stores credentials that the server persists and the Settings UI manages
26
+ - **Browser never sees JSON credentials** — the server only exposes metadata (endpoint, authType, hasPassword) to the browser; all authenticated requests are proxied server-side
27
+
28
+ ---
29
+
30
+ ### Auth Resolution Per Service
31
+
32
+ #### OpenSearch (Storage & Observability)
33
+
34
+ **Resolution order** (`server/middleware/dataSourceConfig.ts`):
35
+ 1. **`agent-health.config.json`** (file) — highest priority
36
+ 2. **Environment variables** (`OPENSEARCH_STORAGE_*` / `OPENSEARCH_LOGS_*`) — fallback
37
+ 3. **null** — features degrade gracefully
38
+
39
+ **JSON config structure:**
40
+ ```json
41
+ {
42
+ "storage": {
43
+ "endpoint": "https://search-....es.amazonaws.com",
44
+ "authType": "sigv4",
45
+ "awsProfile": "default",
46
+ "awsRegion": "us-west-2",
47
+ "awsService": "es"
48
+ },
49
+ "observability": {
50
+ "endpoint": "https://search-....es.amazonaws.com",
51
+ "authType": "sigv4",
52
+ "awsProfile": "default",
53
+ "awsRegion": "us-west-2",
54
+ "awsService": "es",
55
+ "tracesIndex": "otel-v1-apm-span-*"
56
+ }
57
+ }
58
+ ```
59
+
60
+ **Observability config** is where Agent Health reads OTel traces from. This is configured by:
61
+ 1. `npx @opensearch-project/agent-health setup-telemetry` (writes to JSON automatically)
62
+ 2. Manual edit of `agent-health.config.json` (add `observability` block with endpoint + auth)
63
+
64
+ The `tracesIndex` field defaults to `otel-v1-apm-span-*` if omitted. See `/instrument-otel` skill for the full instrumentation flow.
65
+
66
+ **Auth types** (`server/services/opensearchClientFactory.ts`):
67
+
68
+ | authType | Fields needed | How it works |
69
+ |----------|--------------|--------------|
70
+ | `none` | endpoint only | No auth headers |
71
+ | `basic` | endpoint, username, password | HTTP Basic Auth |
72
+ | `sigv4` | endpoint, awsRegion, awsService, awsProfile (optional) | AWS SigV4 credential chain |
73
+
74
+ **SigV4 credential resolution:**
75
+ ```typescript
76
+ // If awsProfile specified → use that profile
77
+ // If omitted → use default AWS credential chain
78
+ const provider = fromNodeProviderChain({
79
+ ...(config.awsProfile && { profile: config.awsProfile })
80
+ });
81
+ ```
82
+
83
+ #### Bedrock Judge (LLM Evaluation)
84
+
85
+ **Resolution** (`server/services/bedrockService.ts`):
86
+ - Uses AWS SDK **default credential chain** — picks up whatever `AWS_PROFILE` is set in the server's environment
87
+ - Region: `process.env.AWS_REGION || 'us-west-2'`
88
+ - Model: `process.env.BEDROCK_MODEL_ID || 'us.anthropic.claude-sonnet-4-5-20250929-v1:0'`
89
+ - No explicit `awsProfile` field — relies on environment
90
+
91
+ #### Claude Code Agent (Subprocess)
92
+
93
+ **Resolution** (`agent-health.config.ts` → agent `connectorConfig.env`):
94
+ ```typescript
95
+ {
96
+ key: "claude-code",
97
+ connectorConfig: {
98
+ env: {
99
+ CLAUDE_CODE_USE_BEDROCK: "1",
100
+ AWS_PROFILE: "Bedrock", // ← explicit profile for Claude subprocess
101
+ AWS_REGION: "us-west-2",
102
+ },
103
+ },
104
+ }
105
+ ```
106
+ These env vars are set **inside the spawned Claude Code process** — isolated from the server's own credentials.
107
+
108
+ ---
109
+
110
+ ### Multi-Profile Setup Pattern
111
+
112
+ A user with separate profiles for separate concerns:
113
+
114
+ | Purpose | AWS Profile | Account | Used By |
115
+ |---------|-------------|---------|---------|
116
+ | OpenSearch reads | `default` | 651304888251 | Server → `agent-health.config.json` (awsProfile: "default") |
117
+ | Bedrock judge | `Bedrock` | 070785328308 | Server env: `AWS_PROFILE=Bedrock` |
118
+ | Claude Code agent | `Bedrock` | 070785328308 | TS config: `connectorConfig.env.AWS_PROFILE` |
119
+ | Telemetry sending | (none needed) | — | API Gateway is public (no SigV4 on client) |
120
+
121
+ **Problem:** The server process can only have ONE `AWS_PROFILE` env var. If Bedrock judge needs profile "Bedrock" but OpenSearch needs profile "default", you must:
122
+
123
+ 1. Set `AWS_PROFILE=Bedrock` for the server (judge uses default chain)
124
+ 2. Set `"awsProfile": "default"` in `agent-health.config.json` for OpenSearch (explicit override via `fromNodeProviderChain({ profile })`)
125
+
126
+ This works because OpenSearch SigV4 uses **explicit profile from config**, while Bedrock uses **ambient credentials from environment**.
127
+
128
+ ---
129
+
130
+ ### Key Files
131
+
132
+ | File | Purpose |
133
+ |------|---------|
134
+ | `lib/config/loader.ts` | Load + merge TS/JS config with defaults |
135
+ | `lib/config/types.ts` | `AgentHealthConfig`, `UserAgentConfig`, `UserModelConfig` |
136
+ | `server/middleware/dataSourceConfig.ts` | Resolve OpenSearch config (file → env → null) |
137
+ | `server/services/configService.ts` | Read/write `agent-health.config.json` |
138
+ | `server/services/opensearchClientFactory.ts` | Build OpenSearch client with correct auth |
139
+ | `server/services/bedrockService.ts` | Bedrock client init (uses ambient AWS creds) |
140
+ | `server/config/index.ts` | Server environment variable defaults |
141
+ | `agent-health.config.example.ts` | Reference TS config |
142
+
143
+ ---
144
+
145
+ ### Environment Variables Reference
146
+
147
+ **OpenSearch Storage (fallback when not in JSON):**
148
+ ```bash
149
+ OPENSEARCH_STORAGE_ENDPOINT=https://...
150
+ OPENSEARCH_STORAGE_AUTH_TYPE=sigv4|basic|none
151
+ OPENSEARCH_STORAGE_USERNAME=admin
152
+ OPENSEARCH_STORAGE_PASSWORD=secret
153
+ OPENSEARCH_STORAGE_AWS_REGION=us-west-2
154
+ OPENSEARCH_STORAGE_AWS_PROFILE=default
155
+ OPENSEARCH_STORAGE_AWS_SERVICE=es|aoss
156
+ ```
157
+
158
+ **OpenSearch Observability (fallback when not in JSON):**
159
+ ```bash
160
+ OPENSEARCH_LOGS_ENDPOINT=https://...
161
+ OPENSEARCH_LOGS_AUTH_TYPE=sigv4|basic|none
162
+ OPENSEARCH_LOGS_AWS_REGION=us-west-2
163
+ OPENSEARCH_LOGS_AWS_PROFILE=default
164
+ OPENSEARCH_LOGS_AWS_SERVICE=es|aoss
165
+ ```
166
+
167
+ **Bedrock Judge:**
168
+ ```bash
169
+ AWS_PROFILE=Bedrock # Profile with Bedrock access
170
+ AWS_REGION=us-west-2 # Bedrock region
171
+ BEDROCK_MODEL_ID=us.anthropic.claude-sonnet-4-5-20250929-v1:0
172
+ ```
173
+
174
+ **Telemetry (Client-side, in shell RC):**
175
+ ```bash
176
+ CLAUDE_CODE_ENABLE_TELEMETRY=1
177
+ OTEL_EXPORTER_OTLP_ENDPOINT=https://<api-gw>.execute-api.<region>.amazonaws.com
178
+ OTEL_EXPORTER_OTLP_PROTOCOL=http/protobuf
179
+ OTEL_TRACES_EXPORTER=otlp
180
+ OTEL_LOGS_EXPORTER=otlp
181
+ OTEL_METRICS_EXPORTER=otlp
182
+ ```
183
+
184
+ ---
185
+
186
+ ### Design Principles
187
+
188
+ 1. **JSON for credentials, TS for behavior** — never put secrets in TS config (it's committed to git)
189
+ 2. **Explicit profile wins** — `awsProfile` in JSON config overrides ambient `AWS_PROFILE`
190
+ 3. **Each service resolves independently** — OpenSearch can use profile A while Bedrock uses profile B
191
+ 4. **Degrade gracefully** — missing config means features are unavailable, not errors
192
+ 5. **Browser never sees secrets** — the server proxies all authenticated requests; the browser only receives safe metadata (endpoint URL, authType, hasPassword boolean), never raw credentials
193
+ 6. **`setup-telemetry` writes JSON** — it's the only automated way to populate credentials
194
+ 7. **`extends: false` opts out of defaults** — without this flag, built-in defaults are always merged into your config; with it, you take full control of every value
@@ -0,0 +1,35 @@
1
+ {
2
+ "skill_name": "config-auth",
3
+ "evals": [
4
+ {
5
+ "id": 1,
6
+ "prompt": "Where does Agent Health store OpenSearch credentials and what file format does it use?",
7
+ "expected_output": "A clear explanation that OpenSearch credentials are stored in agent-health.config.json (JSON format, not TypeScript), managed by the CLI setup-telemetry command or Settings UI, and distinct from the agent-health.config.ts file which handles agents/models/hooks.",
8
+ "assertions": [
9
+ "Response identifies agent-health.config.json as the file storing OpenSearch credentials, not agent-health.config.ts",
10
+ "Response explains that agent-health.config.json is managed by the CLI `setup-telemetry` command or the Settings UI, not manually edited like the TS config",
11
+ "Response mentions that the browser never sees the JSON credentials — only metadata like endpoint, authType, and hasPassword"
12
+ ]
13
+ },
14
+ {
15
+ "id": 2,
16
+ "prompt": "I have two AWS profiles: 'default' for my OpenSearch cluster and 'Bedrock' for the LLM judge. How do I configure Agent Health so each service uses the right profile? The server can only have one AWS_PROFILE set.",
17
+ "expected_output": "A concrete multi-profile setup: set AWS_PROFILE=Bedrock in the server environment (so the Bedrock judge uses its default credential chain), and set awsProfile: 'default' inside the storage block of agent-health.config.json (so OpenSearch SigV4 explicitly overrides the ambient profile). Explains why this works — OpenSearch uses fromNodeProviderChain with an explicit profile override while Bedrock uses ambient credentials.",
18
+ "assertions": [
19
+ "Response instructs setting AWS_PROFILE=Bedrock as the server environment variable so the Bedrock judge picks it up via default credential chain",
20
+ "Response instructs setting `awsProfile: 'default'` inside agent-health.config.json under the storage block to override the ambient AWS_PROFILE for OpenSearch SigV4 auth",
21
+ "Response explains that OpenSearch uses fromNodeProviderChain with an explicit profile parameter (from the JSON config) while Bedrock relies on the ambient environment — this is why the two services can use different profiles simultaneously"
22
+ ]
23
+ },
24
+ {
25
+ "id": 3,
26
+ "prompt": "My agent config TypeScript file isn't being picked up. I have agent-health.config.mjs but Agent Health seems to be using defaults. What's the config loading priority and which file takes precedence?",
27
+ "expected_output": "Explanation of the four-level priority order for TS/JS config loading from lib/config/loader.ts: agent-health.config.ts (highest) → agent-health.config.js → agent-health.config.mjs → built-in defaults. Since .mjs is third priority, if a .ts or .js file exists it would shadow the .mjs file. Also notes that built-in defaults are only applied if `extends: false` is NOT set.",
28
+ "assertions": [
29
+ "Response states the exact priority order: agent-health.config.ts > agent-health.config.js > agent-health.config.mjs > built-in defaults, identifying .mjs as third priority",
30
+ "Response identifies lib/config/loader.ts as the file responsible for this loading priority logic",
31
+ "Response mentions that built-in defaults are only merged in when `extends: false` is NOT present in the config, meaning setting extends: false disables default merging"
32
+ ]
33
+ }
34
+ ]
35
+ }
@@ -0,0 +1,73 @@
1
+ ---
2
+ name: create-pr
3
+ description: Prepare and create a pull request against the upstream repository with all OpenSearch project compliance checks.
4
+ disable-model-invocation: true
5
+ argument-hint: "[branch-name]"
6
+ ---
7
+
8
+ ## PR Workflow for opensearch-project/agent-health
9
+
10
+ **IMPORTANT:** PRs are created from your personal fork, NOT from branches on `opensearch-project/agent-health` directly. Push to your fork remote (e.g., `fork` or your GitHub username), then open a PR targeting `opensearch-project/agent-health:main`.
11
+
12
+ **MANDATORY:** Every commit MUST have DCO (Developer Certificate of Origin) signoff. Always use `git commit -s`. CI will reject commits without signoff. Never use `--no-verify` to bypass this.
13
+
14
+ ### 1. Fetch latest and create branch
15
+ ```bash
16
+ git fetch origin main
17
+ git checkout -b <branch-name> origin/main
18
+ ```
19
+
20
+ ### 2. Cherry-pick commits (if from a dev branch)
21
+ ```bash
22
+ git cherry-pick <oldest-commit>^..<newest-commit>
23
+ ```
24
+
25
+ ### 3. Verify DCO sign-off on ALL commits
26
+ ```bash
27
+ git log --format="%h %s" origin/main..HEAD
28
+ git log origin/main..HEAD | grep -c "Signed-off-by"
29
+ # If missing: git rebase origin/main --signoff
30
+ ```
31
+
32
+ ### 4. Add changelog entry (REQUIRED — CI will fail without this)
33
+ Update `CHANGELOG.md` under `## [Unreleased]` with appropriate category (`Added`, `Changed`, `Fixed`, `Removed`, `Security`). Include PR link:
34
+ ```markdown
35
+ ### Added
36
+ - Description of change ([#PR](https://github.com/opensearch-project/agent-health/pull/PR))
37
+ ```
38
+
39
+ ### 5. Run pre-PR checks (ALL must pass)
40
+ ```bash
41
+ npm run build:all && npm run test:all
42
+ npm audit --audit-level=high
43
+ ```
44
+
45
+ ### 6. Pre-PR Checklist
46
+ - [ ] All commits have DCO signoff
47
+ - [ ] `CHANGELOG.md` updated under `## [Unreleased]` with PR link
48
+ - [ ] `npm run build:all` succeeds
49
+ - [ ] `npm run test:all` passes (unit + integration + e2e)
50
+ - [ ] `npm audit --audit-level=high` reports no vulnerabilities
51
+ - [ ] New source files have SPDX license headers
52
+ - [ ] No secrets committed (`.env`, credentials, tokens)
53
+
54
+ ### 7. Push to your fork and create PR
55
+ ```bash
56
+ # Push to your personal fork (NOT opensearch-project directly)
57
+ git push -u fork <branch-name>
58
+ # Create PR targeting the upstream repo
59
+ gh pr create --repo opensearch-project/agent-health --base main
60
+ ```
61
+
62
+ ### License Headers (for new files)
63
+ ```typescript
64
+ // .ts, .tsx, .js, .jsx, .cjs, .mjs, .css:
65
+ /*
66
+ * Copyright OpenSearch Contributors
67
+ * SPDX-License-Identifier: Apache-2.0
68
+ */
69
+ ```
70
+
71
+ ### DCO Signoff
72
+ All commits need `-s` flag: `git commit -s -m "message"`
73
+ Signoff: `Signed-off-by: Megha Goyal <goyamegh@amazon.com>`