@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.
- package/README.md +77 -6
- package/cli/dist/index.js +10072 -4502
- package/deployment/cloudformation/agent-health-observability.yaml +762 -0
- package/dist/assets/index-CCQRDlO0.js +243 -0
- package/dist/assets/index-CNHQVbcj.css +1 -0
- package/dist/index.html +2 -2
- package/docs/ARCHITECTURE.md +450 -0
- package/docs/BACKEND_JOB_QUEUE.md +405 -0
- package/docs/CLAUDE_CODE_TELEMETRY.md +283 -0
- package/docs/CLI.md +431 -0
- package/docs/CODING_AGENT_ANALYTICS.md +298 -0
- package/docs/CONFIGURATION.md +388 -0
- package/docs/CONNECTORS.md +536 -0
- package/docs/INSTRUMENT_WITH_OTEL.md +390 -0
- package/docs/ML-COMMONS-SETUP.md +289 -0
- package/docs/NPX_PACKAGING.md +195 -0
- package/docs/PERFORMANCE-MONITORING.md +200 -0
- package/docs/PERFORMANCE.md +390 -0
- package/docs/PI_PROFILING.md +169 -0
- package/docs/PLAN-non-agui-agent-support.md +525 -0
- package/docs/SDK.md +577 -0
- package/docs/SKILLS.md +264 -0
- package/docs/blogs/2026-02-28-opensearch-agent-health.md +200 -0
- package/docs/blogs/getting-started-blog.md +608 -0
- package/docs/diagrams/Agent-health.excalidraw +5656 -0
- package/docs/diagrams/architecture.png +0 -0
- package/docs/plans/field-redesign.md +468 -0
- package/docs/rfcs/001-coding-agent-analytics.md +374 -0
- package/docs/rfcs/002-enterprise-leaderboard.md +267 -0
- package/docs/rfcs/003-remote-aggregation.md +146 -0
- package/docs/rfcs/004-test-sdk-v2.md +599 -0
- package/docs/skills/AGENT_HEALTH.md +598 -0
- package/docs/skills/AGENT_PROFILE.md +191 -0
- package/docs/skills/add-connector/SKILL.md +68 -0
- package/docs/skills/agent-health-profile/SKILL.md +40 -0
- package/docs/skills/config-auth/SKILL.md +194 -0
- package/docs/skills/config-auth/evals/evals.json +35 -0
- package/docs/skills/create-pr/SKILL.md +73 -0
- package/docs/skills/instrument-otel/SKILL.md +84 -0
- package/docs/skills/write-test/SKILL.md +124 -0
- package/docs/ui prd.md +376 -0
- package/examples/README.md +53 -0
- package/examples/config/agent-health.config.example.ts +155 -0
- package/examples/connectors/echo-connector.ts +131 -0
- package/examples/eval-files/demo.eval.js +128 -0
- package/examples/eval-files/sdk-hooks-demo.eval.js +99 -0
- package/examples/pi-profiling/README.md +77 -0
- package/examples/pi-profiling/agent-health-profile.ts +417 -0
- package/lib/dist/lib/agentUtils.d.ts +29 -0
- package/lib/dist/lib/agentUtils.d.ts.map +1 -0
- package/lib/dist/lib/agentUtils.js +43 -0
- package/lib/dist/lib/agentUtils.js.map +1 -0
- package/lib/dist/lib/benchmarkExport.d.ts +14 -0
- package/lib/dist/lib/benchmarkExport.d.ts.map +1 -0
- package/lib/dist/lib/benchmarkExport.js +41 -0
- package/lib/dist/lib/benchmarkExport.js.map +1 -0
- package/lib/dist/lib/benchmarkVersionUtils.d.ts +37 -0
- package/lib/dist/lib/benchmarkVersionUtils.d.ts.map +1 -0
- package/lib/dist/lib/benchmarkVersionUtils.js +68 -0
- package/lib/dist/lib/benchmarkVersionUtils.js.map +1 -0
- package/lib/dist/lib/config/defineConfig.d.ts +27 -0
- package/lib/dist/lib/config/defineConfig.d.ts.map +1 -0
- package/lib/dist/lib/config/defineConfig.js +28 -0
- package/lib/dist/lib/config/defineConfig.js.map +1 -0
- package/lib/dist/lib/config/index.d.ts +9 -0
- package/lib/dist/lib/config/index.d.ts.map +1 -0
- package/lib/dist/lib/config/index.js +8 -0
- package/lib/dist/lib/config/index.js.map +1 -0
- package/lib/dist/lib/config/loader.d.ts +39 -0
- package/lib/dist/lib/config/loader.d.ts.map +1 -0
- package/lib/dist/lib/config/loader.js +258 -0
- package/lib/dist/lib/config/loader.js.map +1 -0
- package/lib/dist/lib/config/statePaths.d.ts +61 -0
- package/lib/dist/lib/config/statePaths.d.ts.map +1 -0
- package/lib/dist/lib/config/statePaths.js +188 -0
- package/lib/dist/lib/config/statePaths.js.map +1 -0
- package/lib/dist/lib/config/types.d.ts +231 -0
- package/lib/dist/lib/config/types.d.ts.map +1 -0
- package/lib/dist/lib/config/types.js +6 -0
- package/lib/dist/lib/config/types.js.map +1 -0
- package/lib/dist/lib/config.d.ts +39 -0
- package/lib/dist/lib/config.d.ts.map +1 -0
- package/lib/dist/lib/config.js +118 -0
- package/lib/dist/lib/config.js.map +1 -0
- package/lib/dist/lib/constants.d.ts +70 -0
- package/lib/dist/lib/constants.d.ts.map +1 -0
- package/lib/dist/lib/constants.js +365 -0
- package/lib/dist/lib/constants.js.map +1 -0
- package/lib/dist/lib/contextUtilization.d.ts +23 -0
- package/lib/dist/lib/contextUtilization.d.ts.map +1 -0
- package/lib/dist/lib/contextUtilization.js +72 -0
- package/lib/dist/lib/contextUtilization.js.map +1 -0
- package/lib/dist/lib/dashboardMetrics.d.ts +87 -0
- package/lib/dist/lib/dashboardMetrics.d.ts.map +1 -0
- package/lib/dist/lib/dashboardMetrics.js +242 -0
- package/lib/dist/lib/dashboardMetrics.js.map +1 -0
- package/lib/dist/lib/dataSourceConfig.d.ts +108 -0
- package/lib/dist/lib/dataSourceConfig.d.ts.map +1 -0
- package/lib/dist/lib/dataSourceConfig.js +166 -0
- package/lib/dist/lib/dataSourceConfig.js.map +1 -0
- package/lib/dist/lib/debug.d.ts +26 -0
- package/lib/dist/lib/debug.d.ts.map +1 -0
- package/lib/dist/lib/debug.js +132 -0
- package/lib/dist/lib/debug.js.map +1 -0
- package/lib/dist/lib/diagnostics.d.ts +28 -0
- package/lib/dist/lib/diagnostics.d.ts.map +1 -0
- package/lib/dist/lib/diagnostics.js +65 -0
- package/lib/dist/lib/diagnostics.js.map +1 -0
- package/lib/dist/lib/envCompat.d.ts +27 -0
- package/lib/dist/lib/envCompat.d.ts.map +1 -0
- package/lib/dist/lib/envCompat.js +73 -0
- package/lib/dist/lib/envCompat.js.map +1 -0
- package/lib/dist/lib/findPackageRoot.d.ts +7 -0
- package/lib/dist/lib/findPackageRoot.d.ts.map +1 -0
- package/lib/dist/lib/findPackageRoot.js +57 -0
- package/lib/dist/lib/findPackageRoot.js.map +1 -0
- package/lib/dist/lib/hooks.d.ts +36 -0
- package/lib/dist/lib/hooks.d.ts.map +1 -0
- package/lib/dist/lib/hooks.js +112 -0
- package/lib/dist/lib/hooks.js.map +1 -0
- package/lib/dist/lib/index.d.ts +47 -0
- package/lib/dist/lib/index.d.ts.map +1 -0
- package/lib/dist/lib/index.js +62 -0
- package/lib/dist/lib/index.js.map +1 -0
- package/lib/dist/lib/labels.d.ts +90 -0
- package/lib/dist/lib/labels.d.ts.map +1 -0
- package/lib/dist/lib/labels.js +158 -0
- package/lib/dist/lib/labels.js.map +1 -0
- package/lib/dist/lib/markdown.d.ts +16 -0
- package/lib/dist/lib/markdown.d.ts.map +1 -0
- package/lib/dist/lib/markdown.js +42 -0
- package/lib/dist/lib/markdown.js.map +1 -0
- package/lib/dist/lib/matchers/expect.d.ts +3 -0
- package/lib/dist/lib/matchers/expect.d.ts.map +1 -0
- package/lib/dist/lib/matchers/expect.js +225 -0
- package/lib/dist/lib/matchers/expect.js.map +1 -0
- package/lib/dist/lib/matchers/index.d.ts +8 -0
- package/lib/dist/lib/matchers/index.d.ts.map +1 -0
- package/lib/dist/lib/matchers/index.js +9 -0
- package/lib/dist/lib/matchers/index.js.map +1 -0
- package/lib/dist/lib/matchers/judgeAccessor.d.ts +113 -0
- package/lib/dist/lib/matchers/judgeAccessor.d.ts.map +1 -0
- package/lib/dist/lib/matchers/judgeAccessor.js +183 -0
- package/lib/dist/lib/matchers/judgeAccessor.js.map +1 -0
- package/lib/dist/lib/matchers/session.d.ts +39 -0
- package/lib/dist/lib/matchers/session.d.ts.map +1 -0
- package/lib/dist/lib/matchers/session.js +116 -0
- package/lib/dist/lib/matchers/session.js.map +1 -0
- package/lib/dist/lib/matchers/traces.d.ts +55 -0
- package/lib/dist/lib/matchers/traces.d.ts.map +1 -0
- package/lib/dist/lib/matchers/traces.js +116 -0
- package/lib/dist/lib/matchers/traces.js.map +1 -0
- package/lib/dist/lib/matchers/types.d.ts +75 -0
- package/lib/dist/lib/matchers/types.d.ts.map +1 -0
- package/lib/dist/lib/matchers/types.js +6 -0
- package/lib/dist/lib/matchers/types.js.map +1 -0
- package/lib/dist/lib/packagePaths.d.ts +29 -0
- package/lib/dist/lib/packagePaths.d.ts.map +1 -0
- package/lib/dist/lib/packagePaths.js +63 -0
- package/lib/dist/lib/packagePaths.js.map +1 -0
- package/lib/dist/lib/performance.d.ts +51 -0
- package/lib/dist/lib/performance.d.ts.map +1 -0
- package/lib/dist/lib/performance.js +159 -0
- package/lib/dist/lib/performance.js.map +1 -0
- package/lib/dist/lib/portConfig.d.ts +29 -0
- package/lib/dist/lib/portConfig.d.ts.map +1 -0
- package/lib/dist/lib/portConfig.js +64 -0
- package/lib/dist/lib/portConfig.js.map +1 -0
- package/lib/dist/lib/preferences.d.ts +63 -0
- package/lib/dist/lib/preferences.d.ts.map +1 -0
- package/lib/dist/lib/preferences.js +117 -0
- package/lib/dist/lib/preferences.js.map +1 -0
- package/lib/dist/lib/resolveAgentModel.d.ts +22 -0
- package/lib/dist/lib/resolveAgentModel.d.ts.map +1 -0
- package/lib/dist/lib/resolveAgentModel.js +37 -0
- package/lib/dist/lib/resolveAgentModel.js.map +1 -0
- package/lib/dist/lib/runStats.d.ts +92 -0
- package/lib/dist/lib/runStats.d.ts.map +1 -0
- package/lib/dist/lib/runStats.js +160 -0
- package/lib/dist/lib/runStats.js.map +1 -0
- package/lib/dist/lib/telemetry/constants.d.ts +60 -0
- package/lib/dist/lib/telemetry/constants.d.ts.map +1 -0
- package/lib/dist/lib/telemetry/constants.js +87 -0
- package/lib/dist/lib/telemetry/constants.js.map +1 -0
- package/lib/dist/lib/telemetry/evalSpans.d.ts +61 -0
- package/lib/dist/lib/telemetry/evalSpans.d.ts.map +1 -0
- package/lib/dist/lib/telemetry/evalSpans.js +254 -0
- package/lib/dist/lib/telemetry/evalSpans.js.map +1 -0
- package/lib/dist/lib/telemetry/index.d.ts +11 -0
- package/lib/dist/lib/telemetry/index.d.ts.map +1 -0
- package/lib/dist/lib/telemetry/index.js +15 -0
- package/lib/dist/lib/telemetry/index.js.map +1 -0
- package/lib/dist/lib/telemetry/opensearchExporter.d.ts +43 -0
- package/lib/dist/lib/telemetry/opensearchExporter.d.ts.map +1 -0
- package/lib/dist/lib/telemetry/opensearchExporter.js +217 -0
- package/lib/dist/lib/telemetry/opensearchExporter.js.map +1 -0
- package/lib/dist/lib/telemetry/provider.d.ts +55 -0
- package/lib/dist/lib/telemetry/provider.d.ts.map +1 -0
- package/lib/dist/lib/telemetry/provider.js +140 -0
- package/lib/dist/lib/telemetry/provider.js.map +1 -0
- package/lib/dist/lib/testCaseLabels.d.ts +34 -0
- package/lib/dist/lib/testCaseLabels.d.ts.map +1 -0
- package/lib/dist/lib/testCaseLabels.js +88 -0
- package/lib/dist/lib/testCaseLabels.js.map +1 -0
- package/lib/dist/lib/testCaseValidation.d.ts +140 -0
- package/lib/dist/lib/testCaseValidation.d.ts.map +1 -0
- package/lib/dist/lib/testCaseValidation.js +162 -0
- package/lib/dist/lib/testCaseValidation.js.map +1 -0
- package/lib/dist/lib/testCases/agentFixture.d.ts +80 -0
- package/lib/dist/lib/testCases/agentFixture.d.ts.map +1 -0
- package/lib/dist/lib/testCases/agentFixture.js +43 -0
- package/lib/dist/lib/testCases/agentFixture.js.map +1 -0
- package/lib/dist/lib/testCases/authoringSurface.d.ts +10 -0
- package/lib/dist/lib/testCases/authoringSurface.d.ts.map +1 -0
- package/lib/dist/lib/testCases/authoringSurface.js +54 -0
- package/lib/dist/lib/testCases/authoringSurface.js.map +1 -0
- package/lib/dist/lib/testCases/codemod.d.ts +13 -0
- package/lib/dist/lib/testCases/codemod.d.ts.map +1 -0
- package/lib/dist/lib/testCases/codemod.js +169 -0
- package/lib/dist/lib/testCases/codemod.js.map +1 -0
- package/lib/dist/lib/testCases/define.d.ts +114 -0
- package/lib/dist/lib/testCases/define.d.ts.map +1 -0
- package/lib/dist/lib/testCases/define.js +253 -0
- package/lib/dist/lib/testCases/define.js.map +1 -0
- package/lib/dist/lib/testCases/evaluators.d.ts +80 -0
- package/lib/dist/lib/testCases/evaluators.d.ts.map +1 -0
- package/lib/dist/lib/testCases/evaluators.js +105 -0
- package/lib/dist/lib/testCases/evaluators.js.map +1 -0
- package/lib/dist/lib/testCases/index.d.ts +14 -0
- package/lib/dist/lib/testCases/index.d.ts.map +1 -0
- package/lib/dist/lib/testCases/index.js +12 -0
- package/lib/dist/lib/testCases/index.js.map +1 -0
- package/lib/dist/lib/testCases/judge.d.ts +165 -0
- package/lib/dist/lib/testCases/judge.d.ts.map +1 -0
- package/lib/dist/lib/testCases/judge.js +359 -0
- package/lib/dist/lib/testCases/judge.js.map +1 -0
- package/lib/dist/lib/testCases/loader.d.ts +26 -0
- package/lib/dist/lib/testCases/loader.d.ts.map +1 -0
- package/lib/dist/lib/testCases/loader.js +149 -0
- package/lib/dist/lib/testCases/loader.js.map +1 -0
- package/lib/dist/lib/testCases/types.d.ts +242 -0
- package/lib/dist/lib/testCases/types.d.ts.map +1 -0
- package/lib/dist/lib/testCases/types.js +6 -0
- package/lib/dist/lib/testCases/types.js.map +1 -0
- package/lib/dist/lib/theme.d.ts +6 -0
- package/lib/dist/lib/theme.d.ts.map +1 -0
- package/lib/dist/lib/theme.js +36 -0
- package/lib/dist/lib/theme.js.map +1 -0
- package/lib/dist/lib/uiTelemetry.d.ts +7 -0
- package/lib/dist/lib/uiTelemetry.d.ts.map +1 -0
- package/lib/dist/lib/uiTelemetry.js +25 -0
- package/lib/dist/lib/uiTelemetry.js.map +1 -0
- package/lib/dist/lib/utils.d.ts +96 -0
- package/lib/dist/lib/utils.d.ts.map +1 -0
- package/lib/dist/lib/utils.js +232 -0
- package/lib/dist/lib/utils.js.map +1 -0
- package/lib/dist/lib/workflow/consolidate.d.ts +12 -0
- package/lib/dist/lib/workflow/consolidate.d.ts.map +1 -0
- package/lib/dist/lib/workflow/consolidate.js +33 -0
- package/lib/dist/lib/workflow/consolidate.js.map +1 -0
- package/lib/dist/lib/workflow/index.d.ts +13 -0
- package/lib/dist/lib/workflow/index.d.ts.map +1 -0
- package/lib/dist/lib/workflow/index.js +12 -0
- package/lib/dist/lib/workflow/index.js.map +1 -0
- package/lib/dist/lib/workflow/ledger.d.ts +30 -0
- package/lib/dist/lib/workflow/ledger.d.ts.map +1 -0
- package/lib/dist/lib/workflow/ledger.js +41 -0
- package/lib/dist/lib/workflow/ledger.js.map +1 -0
- package/lib/dist/lib/workflow/pool.d.ts +13 -0
- package/lib/dist/lib/workflow/pool.d.ts.map +1 -0
- package/lib/dist/lib/workflow/pool.js +44 -0
- package/lib/dist/lib/workflow/pool.js.map +1 -0
- package/lib/dist/lib/workflow/source.d.ts +22 -0
- package/lib/dist/lib/workflow/source.d.ts.map +1 -0
- package/lib/dist/lib/workflow/source.js +29 -0
- package/lib/dist/lib/workflow/source.js.map +1 -0
- package/lib/dist/lib/workflow/stepB.d.ts +71 -0
- package/lib/dist/lib/workflow/stepB.d.ts.map +1 -0
- package/lib/dist/lib/workflow/stepB.js +99 -0
- package/lib/dist/lib/workflow/stepB.js.map +1 -0
- package/lib/dist/lib/workflow/types.d.ts +86 -0
- package/lib/dist/lib/workflow/types.d.ts.map +1 -0
- package/lib/dist/lib/workflow/types.js +6 -0
- package/lib/dist/lib/workflow/types.js.map +1 -0
- package/lib/dist/lib/workflow/workflow.d.ts +119 -0
- package/lib/dist/lib/workflow/workflow.d.ts.map +1 -0
- package/lib/dist/lib/workflow/workflow.js +195 -0
- package/lib/dist/lib/workflow/workflow.js.map +1 -0
- package/lib/dist/services/agent/aguiConverter.d.ts +50 -0
- package/lib/dist/services/agent/aguiConverter.d.ts.map +1 -0
- package/lib/dist/services/agent/aguiConverter.js +449 -0
- package/lib/dist/services/agent/aguiConverter.js.map +1 -0
- package/lib/dist/services/agent/index.d.ts +10 -0
- package/lib/dist/services/agent/index.d.ts.map +1 -0
- package/lib/dist/services/agent/index.js +12 -0
- package/lib/dist/services/agent/index.js.map +1 -0
- package/lib/dist/services/agent/payloadBuilder.d.ts +33 -0
- package/lib/dist/services/agent/payloadBuilder.d.ts.map +1 -0
- package/lib/dist/services/agent/payloadBuilder.js +75 -0
- package/lib/dist/services/agent/payloadBuilder.js.map +1 -0
- package/lib/dist/services/agent/sseStream.d.ts +43 -0
- package/lib/dist/services/agent/sseStream.d.ts.map +1 -0
- package/lib/dist/services/agent/sseStream.js +223 -0
- package/lib/dist/services/agent/sseStream.js.map +1 -0
- package/lib/dist/services/connectors/agui/AGUIStreamingConnector.d.ts +44 -0
- package/lib/dist/services/connectors/agui/AGUIStreamingConnector.d.ts.map +1 -0
- package/lib/dist/services/connectors/agui/AGUIStreamingConnector.js +95 -0
- package/lib/dist/services/connectors/agui/AGUIStreamingConnector.js.map +1 -0
- package/lib/dist/services/connectors/base/BaseConnector.d.ts +81 -0
- package/lib/dist/services/connectors/base/BaseConnector.d.ts.map +1 -0
- package/lib/dist/services/connectors/base/BaseConnector.js +170 -0
- package/lib/dist/services/connectors/base/BaseConnector.js.map +1 -0
- package/lib/dist/services/connectors/claude-code/ClaudeCodeConnector.d.ts +116 -0
- package/lib/dist/services/connectors/claude-code/ClaudeCodeConnector.d.ts.map +1 -0
- package/lib/dist/services/connectors/claude-code/ClaudeCodeConnector.js +403 -0
- package/lib/dist/services/connectors/claude-code/ClaudeCodeConnector.js.map +1 -0
- package/lib/dist/services/connectors/index.d.ts +13 -0
- package/lib/dist/services/connectors/index.d.ts.map +1 -0
- package/lib/dist/services/connectors/index.js +32 -0
- package/lib/dist/services/connectors/index.js.map +1 -0
- package/lib/dist/services/connectors/kiro/KiroConnector.d.ts +48 -0
- package/lib/dist/services/connectors/kiro/KiroConnector.d.ts.map +1 -0
- package/lib/dist/services/connectors/kiro/KiroConnector.js +158 -0
- package/lib/dist/services/connectors/kiro/KiroConnector.js.map +1 -0
- package/lib/dist/services/connectors/langgraph/LangGraphConnector.d.ts +36 -0
- package/lib/dist/services/connectors/langgraph/LangGraphConnector.d.ts.map +1 -0
- package/lib/dist/services/connectors/langgraph/LangGraphConnector.js +175 -0
- package/lib/dist/services/connectors/langgraph/LangGraphConnector.js.map +1 -0
- package/lib/dist/services/connectors/mock/MockConnector.d.ts +37 -0
- package/lib/dist/services/connectors/mock/MockConnector.d.ts.map +1 -0
- package/lib/dist/services/connectors/mock/MockConnector.js +120 -0
- package/lib/dist/services/connectors/mock/MockConnector.js.map +1 -0
- package/lib/dist/services/connectors/openai-compatible/OpenAICompatibleConnector.d.ts +42 -0
- package/lib/dist/services/connectors/openai-compatible/OpenAICompatibleConnector.d.ts.map +1 -0
- package/lib/dist/services/connectors/openai-compatible/OpenAICompatibleConnector.js +133 -0
- package/lib/dist/services/connectors/openai-compatible/OpenAICompatibleConnector.js.map +1 -0
- package/lib/dist/services/connectors/pi/PiConnector.d.ts +87 -0
- package/lib/dist/services/connectors/pi/PiConnector.d.ts.map +1 -0
- package/lib/dist/services/connectors/pi/PiConnector.js +274 -0
- package/lib/dist/services/connectors/pi/PiConnector.js.map +1 -0
- package/lib/dist/services/connectors/registry.d.ts +57 -0
- package/lib/dist/services/connectors/registry.d.ts.map +1 -0
- package/lib/dist/services/connectors/registry.js +106 -0
- package/lib/dist/services/connectors/registry.js.map +1 -0
- package/lib/dist/services/connectors/rest/RESTConnector.d.ts +38 -0
- package/lib/dist/services/connectors/rest/RESTConnector.d.ts.map +1 -0
- package/lib/dist/services/connectors/rest/RESTConnector.js +117 -0
- package/lib/dist/services/connectors/rest/RESTConnector.js.map +1 -0
- package/lib/dist/services/connectors/server.d.ts +13 -0
- package/lib/dist/services/connectors/server.d.ts.map +1 -0
- package/lib/dist/services/connectors/server.js +34 -0
- package/lib/dist/services/connectors/server.js.map +1 -0
- package/lib/dist/services/connectors/strands/StrandsConnector.d.ts +48 -0
- package/lib/dist/services/connectors/strands/StrandsConnector.d.ts.map +1 -0
- package/lib/dist/services/connectors/strands/StrandsConnector.js +221 -0
- package/lib/dist/services/connectors/strands/StrandsConnector.js.map +1 -0
- package/lib/dist/services/connectors/subprocess/SubprocessConnector.d.ts +88 -0
- package/lib/dist/services/connectors/subprocess/SubprocessConnector.d.ts.map +1 -0
- package/lib/dist/services/connectors/subprocess/SubprocessConnector.js +418 -0
- package/lib/dist/services/connectors/subprocess/SubprocessConnector.js.map +1 -0
- package/lib/dist/services/connectors/types.d.ts +213 -0
- package/lib/dist/services/connectors/types.d.ts.map +1 -0
- package/lib/dist/services/connectors/types.js +6 -0
- package/lib/dist/services/connectors/types.js.map +1 -0
- package/lib/dist/services/evaluation/bedrockJudge.d.ts +64 -0
- package/lib/dist/services/evaluation/bedrockJudge.d.ts.map +1 -0
- package/lib/dist/services/evaluation/bedrockJudge.js +167 -0
- package/lib/dist/services/evaluation/bedrockJudge.js.map +1 -0
- package/lib/dist/services/evaluation/evaluatorError.d.ts +56 -0
- package/lib/dist/services/evaluation/evaluatorError.d.ts.map +1 -0
- package/lib/dist/services/evaluation/evaluatorError.js +56 -0
- package/lib/dist/services/evaluation/evaluatorError.js.map +1 -0
- package/lib/dist/services/evaluation/index.d.ts +106 -0
- package/lib/dist/services/evaluation/index.d.ts.map +1 -0
- package/lib/dist/services/evaluation/index.js +684 -0
- package/lib/dist/services/evaluation/index.js.map +1 -0
- package/lib/dist/services/evaluation/mockTrajectory.d.ts +3 -0
- package/lib/dist/services/evaluation/mockTrajectory.d.ts.map +1 -0
- package/lib/dist/services/evaluation/mockTrajectory.js +72 -0
- package/lib/dist/services/evaluation/mockTrajectory.js.map +1 -0
- package/lib/dist/services/opensearch/client.d.ts +26 -0
- package/lib/dist/services/opensearch/client.d.ts.map +1 -0
- package/lib/dist/services/opensearch/client.js +131 -0
- package/lib/dist/services/opensearch/client.js.map +1 -0
- package/lib/dist/services/opensearch/index.d.ts +16 -0
- package/lib/dist/services/opensearch/index.d.ts.map +1 -0
- package/lib/dist/services/opensearch/index.js +25 -0
- package/lib/dist/services/opensearch/index.js.map +1 -0
- package/lib/dist/services/storage/asyncBenchmarkStorage.d.ts +123 -0
- package/lib/dist/services/storage/asyncBenchmarkStorage.d.ts.map +1 -0
- package/lib/dist/services/storage/asyncBenchmarkStorage.js +429 -0
- package/lib/dist/services/storage/asyncBenchmarkStorage.js.map +1 -0
- package/lib/dist/services/storage/asyncRunStorage.d.ts +127 -0
- package/lib/dist/services/storage/asyncRunStorage.d.ts.map +1 -0
- package/lib/dist/services/storage/asyncRunStorage.js +448 -0
- package/lib/dist/services/storage/asyncRunStorage.js.map +1 -0
- package/lib/dist/services/storage/asyncTestCaseStorage.d.ts +156 -0
- package/lib/dist/services/storage/asyncTestCaseStorage.d.ts.map +1 -0
- package/lib/dist/services/storage/asyncTestCaseStorage.js +285 -0
- package/lib/dist/services/storage/asyncTestCaseStorage.js.map +1 -0
- package/lib/dist/services/storage/index.d.ts +17 -0
- package/lib/dist/services/storage/index.d.ts.map +1 -0
- package/lib/dist/services/storage/index.js +20 -0
- package/lib/dist/services/storage/index.js.map +1 -0
- package/lib/dist/services/storage/migration.d.ts +54 -0
- package/lib/dist/services/storage/migration.d.ts.map +1 -0
- package/lib/dist/services/storage/migration.js +296 -0
- package/lib/dist/services/storage/migration.js.map +1 -0
- package/lib/dist/services/storage/opensearchClient.d.ts +924 -0
- package/lib/dist/services/storage/opensearchClient.d.ts.map +1 -0
- package/lib/dist/services/storage/opensearchClient.js +435 -0
- package/lib/dist/services/storage/opensearchClient.js.map +1 -0
- package/lib/dist/services/traces/browserRecovery.d.ts +26 -0
- package/lib/dist/services/traces/browserRecovery.d.ts.map +1 -0
- package/lib/dist/services/traces/browserRecovery.js +81 -0
- package/lib/dist/services/traces/browserRecovery.js.map +1 -0
- package/lib/dist/services/traces/categoryStyles.d.ts +21 -0
- package/lib/dist/services/traces/categoryStyles.d.ts.map +1 -0
- package/lib/dist/services/traces/categoryStyles.js +56 -0
- package/lib/dist/services/traces/categoryStyles.js.map +1 -0
- package/lib/dist/services/traces/executionOrderTransform.d.ts +35 -0
- package/lib/dist/services/traces/executionOrderTransform.d.ts.map +1 -0
- package/lib/dist/services/traces/executionOrderTransform.js +313 -0
- package/lib/dist/services/traces/executionOrderTransform.js.map +1 -0
- package/lib/dist/services/traces/fetchSpansForRun.d.ts +86 -0
- package/lib/dist/services/traces/fetchSpansForRun.d.ts.map +1 -0
- package/lib/dist/services/traces/fetchSpansForRun.js +69 -0
- package/lib/dist/services/traces/fetchSpansForRun.js.map +1 -0
- package/lib/dist/services/traces/flowTransform.d.ts +24 -0
- package/lib/dist/services/traces/flowTransform.d.ts.map +1 -0
- package/lib/dist/services/traces/flowTransform.js +228 -0
- package/lib/dist/services/traces/flowTransform.js.map +1 -0
- package/lib/dist/services/traces/index.d.ts +121 -0
- package/lib/dist/services/traces/index.d.ts.map +1 -0
- package/lib/dist/services/traces/index.js +255 -0
- package/lib/dist/services/traces/index.js.map +1 -0
- package/lib/dist/services/traces/intentTransform.d.ts +20 -0
- package/lib/dist/services/traces/intentTransform.d.ts.map +1 -0
- package/lib/dist/services/traces/intentTransform.js +131 -0
- package/lib/dist/services/traces/intentTransform.js.map +1 -0
- package/lib/dist/services/traces/judgeAgentsHints.d.ts +63 -0
- package/lib/dist/services/traces/judgeAgentsHints.d.ts.map +1 -0
- package/lib/dist/services/traces/judgeAgentsHints.js +89 -0
- package/lib/dist/services/traces/judgeAgentsHints.js.map +1 -0
- package/lib/dist/services/traces/messageExtraction.d.ts +15 -0
- package/lib/dist/services/traces/messageExtraction.d.ts.map +1 -0
- package/lib/dist/services/traces/messageExtraction.js +251 -0
- package/lib/dist/services/traces/messageExtraction.js.map +1 -0
- package/lib/dist/services/traces/spanCategorization.d.ts +63 -0
- package/lib/dist/services/traces/spanCategorization.d.ts.map +1 -0
- package/lib/dist/services/traces/spanCategorization.js +276 -0
- package/lib/dist/services/traces/spanCategorization.js.map +1 -0
- package/lib/dist/services/traces/spanPreprocessing.d.ts +37 -0
- package/lib/dist/services/traces/spanPreprocessing.d.ts.map +1 -0
- package/lib/dist/services/traces/spanPreprocessing.js +102 -0
- package/lib/dist/services/traces/spanPreprocessing.js.map +1 -0
- package/lib/dist/services/traces/spansToTrajectory.d.ts +36 -0
- package/lib/dist/services/traces/spansToTrajectory.d.ts.map +1 -0
- package/lib/dist/services/traces/spansToTrajectory.js +387 -0
- package/lib/dist/services/traces/spansToTrajectory.js.map +1 -0
- package/lib/dist/services/traces/toolSimilarity.d.ts +35 -0
- package/lib/dist/services/traces/toolSimilarity.d.ts.map +1 -0
- package/lib/dist/services/traces/toolSimilarity.js +203 -0
- package/lib/dist/services/traces/toolSimilarity.js.map +1 -0
- package/lib/dist/services/traces/traceComparison.d.ts +31 -0
- package/lib/dist/services/traces/traceComparison.d.ts.map +1 -0
- package/lib/dist/services/traces/traceComparison.js +318 -0
- package/lib/dist/services/traces/traceComparison.js.map +1 -0
- package/lib/dist/services/traces/traceGrouping.d.ts +19 -0
- package/lib/dist/services/traces/traceGrouping.d.ts.map +1 -0
- package/lib/dist/services/traces/traceGrouping.js +107 -0
- package/lib/dist/services/traces/traceGrouping.js.map +1 -0
- package/lib/dist/services/traces/tracePoller.d.ts +84 -0
- package/lib/dist/services/traces/tracePoller.d.ts.map +1 -0
- package/lib/dist/services/traces/tracePoller.js +309 -0
- package/lib/dist/services/traces/tracePoller.js.map +1 -0
- package/lib/dist/services/traces/traceStats.d.ts +45 -0
- package/lib/dist/services/traces/traceStats.d.ts.map +1 -0
- package/lib/dist/services/traces/traceStats.js +114 -0
- package/lib/dist/services/traces/traceStats.js.map +1 -0
- package/lib/dist/services/traces/traceSummary.d.ts +47 -0
- package/lib/dist/services/traces/traceSummary.d.ts.map +1 -0
- package/lib/dist/services/traces/traceSummary.js +68 -0
- package/lib/dist/services/traces/traceSummary.js.map +1 -0
- package/lib/dist/services/traces/utils.d.ts +33 -0
- package/lib/dist/services/traces/utils.d.ts.map +1 -0
- package/lib/dist/services/traces/utils.js +114 -0
- package/lib/dist/services/traces/utils.js.map +1 -0
- package/lib/dist/types/agui.d.ts +13 -0
- package/lib/dist/types/agui.d.ts.map +1 -0
- package/lib/dist/types/agui.js +16 -0
- package/lib/dist/types/agui.js.map +1 -0
- package/lib/dist/types/index.d.ts +1175 -0
- package/lib/dist/types/index.d.ts.map +1 -0
- package/lib/dist/types/index.js +12 -0
- package/lib/dist/types/index.js.map +1 -0
- package/lib/dist/types/skills.d.ts +146 -0
- package/lib/dist/types/skills.d.ts.map +1 -0
- package/lib/dist/types/skills.js +6 -0
- package/lib/dist/types/skills.js.map +1 -0
- package/observio-sample-agent/pi-package/README.md +112 -0
- package/observio-sample-agent/pi-package/extensions/agent-health.ts +373 -0
- package/observio-sample-agent/pi-package/package.json +17 -0
- package/observio-sample-agent/pi-package/prompts/agent-health.md +37 -0
- package/observio-sample-agent/pi-package/skills/create-pr/SKILL.md +88 -0
- package/observio-sample-agent/pi-package/skills/fix-bug/SKILL.md +71 -0
- package/observio-sample-agent/pi-package/skills/implement-feature/SKILL.md +156 -0
- package/observio-sample-agent/pi-package/skills/instrument-otel/SKILL.md +208 -0
- package/observio-sample-agent/pi-package/skills/setup-collector/SKILL.md +146 -0
- package/observio-sample-agent/pi-package/skills/write-test/SKILL.md +115 -0
- package/package.json +64 -13
- package/server/dist/app.js +32651 -17637
- package/server/dist/index.js +29875 -14638
- package/tsconfig.lib.json +71 -0
- package/dist/assets/index-EvPLSTAS.js +0 -267
- package/dist/assets/index-RXasQKUs.css +0 -1
- package/lib/dist/config/index.js +0 -404
- package/lib/dist/index.js +0 -1665
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../matchers/index.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,YAAY,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,yBAAyB,EAAE,MAAM,aAAa,CAAC;AAClG,YAAY,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAC/D,OAAO,EACL,sBAAsB,EACtB,qBAAqB,EACrB,wBAAwB,EACxB,sBAAsB,EACtB,6BAA6B,GAC9B,MAAM,oBAAoB,CAAC;AAC5B,YAAY,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAC7E,OAAO,EACL,YAAY,EACZ,UAAU,EACV,eAAe,EACf,aAAa,EACb,gBAAgB,EAChB,YAAY,GACb,MAAM,cAAc,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright OpenSearch Contributors
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
5
|
+
export { expect } from './expect.js';
|
|
6
|
+
export { buildTracesAccessor, emptyTracesAccessor, unavailableTracesAccessor } from './traces.js';
|
|
7
|
+
export { getJudgeMatcherResults, getJudgeReasoningText, recordJudgeMatcherResult, buildJudgeMatcherEntry, formatExpectedOutcomesAsClaim, } from './judgeAccessor.js';
|
|
8
|
+
export { startSession, endSession, isSessionActive, recordVerdict, recordWithTiming, runInSession, } from './session.js';
|
|
9
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../matchers/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC,OAAO,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,yBAAyB,EAAE,MAAM,aAAa,CAAC;AAElG,OAAO,EACL,sBAAsB,EACtB,qBAAqB,EACrB,wBAAwB,EACxB,sBAAsB,EACtB,6BAA6B,GAC9B,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EACL,YAAY,EACZ,UAAU,EACV,eAAe,EACf,aAAa,EACb,gBAAgB,EAChB,YAAY,GACb,MAAM,cAAc,CAAC"}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Unified judge accessor — single source of truth for "what the LLM judge
|
|
3
|
+
* said" on an EvaluationReport.
|
|
4
|
+
*
|
|
5
|
+
* Background: historically the judge verdict + reasoning lived in two
|
|
6
|
+
* parallel surfaces:
|
|
7
|
+
*
|
|
8
|
+
* 1. report.llmJudgeReasoning (string) — written by the legacy
|
|
9
|
+
* auto-judge path (services/evaluation/index.ts and the various
|
|
10
|
+
* runners that call callBedrockJudge against expectedOutcomes).
|
|
11
|
+
* One per report, last writer wins.
|
|
12
|
+
*
|
|
13
|
+
* 2. report.matcherResults[*] with method: 'llm-judge' — written by
|
|
14
|
+
* the SDK `judge(result, claim)` matcher. Many per report.
|
|
15
|
+
*
|
|
16
|
+
* Both ultimately come from the same Bedrock Judge endpoint. Storing
|
|
17
|
+
* them in two places caused real bugs (notably issue #230, where the
|
|
18
|
+
* trace-mode placeholder leaked into the legacy field and bled through
|
|
19
|
+
* to the UI for deterministic SDK runs).
|
|
20
|
+
*
|
|
21
|
+
* The fix: `matcherResults[]` is the canonical surface. The legacy
|
|
22
|
+
* `llmJudgeReasoning` field is kept populated as a derived
|
|
23
|
+
* convenience for backward-compat readers, but new code MUST use
|
|
24
|
+
* {@link getJudgeMatcherResults} on the read side and
|
|
25
|
+
* {@link recordJudgeMatcherResult} on the write side.
|
|
26
|
+
*/
|
|
27
|
+
import type { MatcherResult } from './types.js';
|
|
28
|
+
/** A minimal duck-typed report shape — accepts any object with the two fields. */
|
|
29
|
+
export interface JudgeAccessReport {
|
|
30
|
+
matcherResults?: MatcherResult[];
|
|
31
|
+
llmJudgeReasoning?: string;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Returns every llm-judge MatcherResult on the report, including a
|
|
35
|
+
* synthetic entry derived from the legacy `llmJudgeReasoning` field
|
|
36
|
+
* when the report pre-dates the unified surface.
|
|
37
|
+
*
|
|
38
|
+
* Read-only: nothing is written back to the report.
|
|
39
|
+
*
|
|
40
|
+
* Behaviour matrix:
|
|
41
|
+
*
|
|
42
|
+
* | matcherResults has [llm-judge] | llmJudgeReasoning | Returns |
|
|
43
|
+
* |--------------------------------|------------------------|----------------------------|
|
|
44
|
+
* | yes | anything | the existing entries |
|
|
45
|
+
* | no | empty / placeholder | [] |
|
|
46
|
+
* | no | real reasoning | [<synthetic entry>] |
|
|
47
|
+
*
|
|
48
|
+
* The placeholder string `Waiting for traces to become available...`
|
|
49
|
+
* is treated as "no judge ran yet" \u2014 see issue #230.
|
|
50
|
+
*/
|
|
51
|
+
export declare function getJudgeMatcherResults(report: JudgeAccessReport): MatcherResult[];
|
|
52
|
+
/**
|
|
53
|
+
* Convenience: the single most recent llm-judge reasoning string, or
|
|
54
|
+
* empty when no judge ran. Used by surfaces that historically read
|
|
55
|
+
* `llmJudgeReasoning` directly (HTML report, skills grader, compare
|
|
56
|
+
* view) and only need a flat string.
|
|
57
|
+
*/
|
|
58
|
+
export declare function getJudgeReasoningText(report: JudgeAccessReport): string;
|
|
59
|
+
/**
|
|
60
|
+
* Convert a `JudgeResult` from `callBedrockJudge` into a `MatcherResult`.
|
|
61
|
+
* Pure: doesn't touch any report. Used by inline-return code paths in
|
|
62
|
+
* services/evaluation/index.ts where building a fresh report object is
|
|
63
|
+
* cleaner than the mutate-then-return pattern.
|
|
64
|
+
*/
|
|
65
|
+
export declare function buildJudgeMatcherEntry(judgeResult: JudgeResultLike, options?: {
|
|
66
|
+
claim?: string;
|
|
67
|
+
model?: string;
|
|
68
|
+
}): MatcherResult;
|
|
69
|
+
/**
|
|
70
|
+
* Format an arbitrary `expectedOutcomes` value into a single description
|
|
71
|
+
* fragment suitable for the matcher entry's `description` field. Accepts
|
|
72
|
+
* the SDK's flat `string[]` *and* the legacy `{ rootCauses, requiredFacts,
|
|
73
|
+
* conclusions }` object — both shapes appear on persisted test cases.
|
|
74
|
+
*/
|
|
75
|
+
export declare function formatExpectedOutcomesAsClaim(outcomes?: unknown): string;
|
|
76
|
+
/**
|
|
77
|
+
* Convert a `JudgeResult` from `callBedrockJudge` into a `MatcherResult`
|
|
78
|
+
* and append it to `report.matcherResults`. Also keeps the legacy
|
|
79
|
+
* `report.llmJudgeReasoning` field populated as a derived
|
|
80
|
+
* backward-compat shim (it equals the reasoning of the just-pushed
|
|
81
|
+
* entry, so direct readers continue to work).
|
|
82
|
+
*
|
|
83
|
+
* Mutates the passed report and returns the matcher entry.
|
|
84
|
+
*
|
|
85
|
+
* The `claim` argument is what the auto-judge was evaluating against
|
|
86
|
+
* (the test case's expected outcomes). The matcher description ends
|
|
87
|
+
* up as `judge: <claim>` matching the SDK convention.
|
|
88
|
+
*/
|
|
89
|
+
export declare function recordJudgeMatcherResult(report: JudgeAccessReport & {
|
|
90
|
+
matcherResults?: MatcherResult[];
|
|
91
|
+
llmJudgeReasoning?: string;
|
|
92
|
+
}, judgeResult: JudgeResultLike, options?: {
|
|
93
|
+
claim?: string;
|
|
94
|
+
model?: string;
|
|
95
|
+
}): MatcherResult;
|
|
96
|
+
/** Subset of `JudgeResult` we depend on \u2014 keeps this module type-import-light. */
|
|
97
|
+
export interface JudgeResultLike {
|
|
98
|
+
passFailStatus: 'passed' | 'failed';
|
|
99
|
+
metrics: {
|
|
100
|
+
accuracy?: number;
|
|
101
|
+
[k: string]: number | undefined;
|
|
102
|
+
};
|
|
103
|
+
llmJudgeReasoning: string;
|
|
104
|
+
judgeDurationMs?: number;
|
|
105
|
+
improvementStrategies?: Array<{
|
|
106
|
+
category: string;
|
|
107
|
+
issue: string;
|
|
108
|
+
recommendation: string;
|
|
109
|
+
priority: 'high' | 'medium' | 'low';
|
|
110
|
+
}>;
|
|
111
|
+
}
|
|
112
|
+
export type { JudgeResult } from '../../types/index.js';
|
|
113
|
+
//# sourceMappingURL=judgeAccessor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"judgeAccessor.d.ts","sourceRoot":"","sources":["../../../matchers/judgeA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AC;IAChE,iBAAiB,EAAE,MAAM,CAAC;IAC1B,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,qBAAqB,CAAC,EAAE,KAAK,CAAC;QAC5B,QAAQ,EAAE,MAAM,CAAC;QACjB,KAAK,EAAE,MAAM,CAAC;QACd,cAAc,EAAE,MAAM,CAAC;QACvB,QAAQ,EAAE,MAAM,GAAG,QAAQ,GAAG,KAAK,CAAC;KACrC,CAAC,CAAC;CACJ;AA+BD,YAAY,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC"}
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright OpenSearch Contributors
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Returns every llm-judge MatcherResult on the report, including a
|
|
7
|
+
* synthetic entry derived from the legacy `llmJudgeReasoning` field
|
|
8
|
+
* when the report pre-dates the unified surface.
|
|
9
|
+
*
|
|
10
|
+
* Read-only: nothing is written back to the report.
|
|
11
|
+
*
|
|
12
|
+
* Behaviour matrix:
|
|
13
|
+
*
|
|
14
|
+
* | matcherResults has [llm-judge] | llmJudgeReasoning | Returns |
|
|
15
|
+
* |--------------------------------|------------------------|----------------------------|
|
|
16
|
+
* | yes | anything | the existing entries |
|
|
17
|
+
* | no | empty / placeholder | [] |
|
|
18
|
+
* | no | real reasoning | [<synthetic entry>] |
|
|
19
|
+
*
|
|
20
|
+
* The placeholder string `Waiting for traces to become available...`
|
|
21
|
+
* is treated as "no judge ran yet" \u2014 see issue #230.
|
|
22
|
+
*/
|
|
23
|
+
export function getJudgeMatcherResults(report) {
|
|
24
|
+
const fromMatcher = (report.matcherResults ?? []).filter(m => m.method === 'llm-judge');
|
|
25
|
+
if (fromMatcher.length > 0) {
|
|
26
|
+
return fromMatcher;
|
|
27
|
+
}
|
|
28
|
+
const legacy = report.llmJudgeReasoning?.trim();
|
|
29
|
+
if (!legacy || isPlaceholderReasoning(legacy)) {
|
|
30
|
+
return [];
|
|
31
|
+
}
|
|
32
|
+
// Old report: synthesize a single virtual matcher entry so UIs that
|
|
33
|
+
// render only matcherResults still have something to show.
|
|
34
|
+
return [
|
|
35
|
+
{
|
|
36
|
+
description: 'judge: expected outcomes',
|
|
37
|
+
pass: inferPassFromReport(report),
|
|
38
|
+
method: 'llm-judge',
|
|
39
|
+
reasoning: legacy,
|
|
40
|
+
},
|
|
41
|
+
];
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Convenience: the single most recent llm-judge reasoning string, or
|
|
45
|
+
* empty when no judge ran. Used by surfaces that historically read
|
|
46
|
+
* `llmJudgeReasoning` directly (HTML report, skills grader, compare
|
|
47
|
+
* view) and only need a flat string.
|
|
48
|
+
*/
|
|
49
|
+
export function getJudgeReasoningText(report) {
|
|
50
|
+
const entries = getJudgeMatcherResults(report);
|
|
51
|
+
if (entries.length === 0)
|
|
52
|
+
return '';
|
|
53
|
+
// Most-recent-first: prefer the last entry the runner pushed. If
|
|
54
|
+
// multiple entries exist (SDK with several judge() calls) we join
|
|
55
|
+
// them with horizontal-rule markers so a flat-string consumer still
|
|
56
|
+
// sees every claim.
|
|
57
|
+
if (entries.length === 1)
|
|
58
|
+
return entries[0].reasoning ?? '';
|
|
59
|
+
return entries
|
|
60
|
+
.map((m, i) => {
|
|
61
|
+
const claim = m.description?.replace(/^judge:\s*/, '') ?? `claim ${i + 1}`;
|
|
62
|
+
const verdict = m.pass ? 'PASS' : 'FAIL';
|
|
63
|
+
return `### ${verdict} \u2014 ${claim}\n\n${m.reasoning ?? ''}`;
|
|
64
|
+
})
|
|
65
|
+
.join('\n\n---\n\n');
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Convert a `JudgeResult` from `callBedrockJudge` into a `MatcherResult`.
|
|
69
|
+
* Pure: doesn't touch any report. Used by inline-return code paths in
|
|
70
|
+
* services/evaluation/index.ts where building a fresh report object is
|
|
71
|
+
* cleaner than the mutate-then-return pattern.
|
|
72
|
+
*/
|
|
73
|
+
export function buildJudgeMatcherEntry(judgeResult, options) {
|
|
74
|
+
const claim = options?.claim?.trim() || 'expected outcomes';
|
|
75
|
+
const accuracy = judgeResult.metrics?.accuracy;
|
|
76
|
+
const score = typeof accuracy === 'number' ? accuracy / 100 : undefined;
|
|
77
|
+
const pass = judgeResult.passFailStatus === 'passed';
|
|
78
|
+
const reasoning = judgeResult.llmJudgeReasoning ?? '';
|
|
79
|
+
return {
|
|
80
|
+
description: `judge: ${claim}`,
|
|
81
|
+
pass,
|
|
82
|
+
method: 'llm-judge',
|
|
83
|
+
durationMs: judgeResult.judgeDurationMs,
|
|
84
|
+
score,
|
|
85
|
+
reasoning,
|
|
86
|
+
...(options?.model ? { model: options.model } : {}),
|
|
87
|
+
...(pass ? {} : { errorMessage: reasoning }),
|
|
88
|
+
// Carry the rest of the judge payload through so SDK
|
|
89
|
+
// `getJudgeMatcherResults()` consumers see the same data the
|
|
90
|
+
// legacy report-level fields used to expose. See MatcherResult.
|
|
91
|
+
...(Array.isArray(judgeResult.improvementStrategies) && judgeResult.improvementStrategies.length > 0
|
|
92
|
+
? { improvementStrategies: judgeResult.improvementStrategies }
|
|
93
|
+
: {}),
|
|
94
|
+
...(judgeResult.metrics && typeof judgeResult.metrics === 'object'
|
|
95
|
+
? { judgeMetrics: { ...judgeResult.metrics } }
|
|
96
|
+
: {}),
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Format an arbitrary `expectedOutcomes` value into a single description
|
|
101
|
+
* fragment suitable for the matcher entry's `description` field. Accepts
|
|
102
|
+
* the SDK's flat `string[]` *and* the legacy `{ rootCauses, requiredFacts,
|
|
103
|
+
* conclusions }` object — both shapes appear on persisted test cases.
|
|
104
|
+
*/
|
|
105
|
+
export function formatExpectedOutcomesAsClaim(outcomes) {
|
|
106
|
+
const items = [];
|
|
107
|
+
if (Array.isArray(outcomes)) {
|
|
108
|
+
for (const o of outcomes) {
|
|
109
|
+
if (typeof o === 'string' && o.trim())
|
|
110
|
+
items.push(o.trim());
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
else if (outcomes && typeof outcomes === 'object') {
|
|
114
|
+
// Legacy shape: { rootCauses?: string[]; requiredFacts?: string[]; conclusions?: string[] }
|
|
115
|
+
for (const key of Object.keys(outcomes)) {
|
|
116
|
+
const v = outcomes[key];
|
|
117
|
+
if (Array.isArray(v)) {
|
|
118
|
+
for (const s of v) {
|
|
119
|
+
if (typeof s === 'string' && s.trim())
|
|
120
|
+
items.push(s.trim());
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
if (items.length === 0)
|
|
126
|
+
return 'expected outcomes';
|
|
127
|
+
if (items.length === 1)
|
|
128
|
+
return items[0];
|
|
129
|
+
return `${items.length} expected outcomes`;
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Convert a `JudgeResult` from `callBedrockJudge` into a `MatcherResult`
|
|
133
|
+
* and append it to `report.matcherResults`. Also keeps the legacy
|
|
134
|
+
* `report.llmJudgeReasoning` field populated as a derived
|
|
135
|
+
* backward-compat shim (it equals the reasoning of the just-pushed
|
|
136
|
+
* entry, so direct readers continue to work).
|
|
137
|
+
*
|
|
138
|
+
* Mutates the passed report and returns the matcher entry.
|
|
139
|
+
*
|
|
140
|
+
* The `claim` argument is what the auto-judge was evaluating against
|
|
141
|
+
* (the test case's expected outcomes). The matcher description ends
|
|
142
|
+
* up as `judge: <claim>` matching the SDK convention.
|
|
143
|
+
*/
|
|
144
|
+
export function recordJudgeMatcherResult(report, judgeResult, options) {
|
|
145
|
+
const entry = buildJudgeMatcherEntry(judgeResult, options);
|
|
146
|
+
const existing = report.matcherResults ?? [];
|
|
147
|
+
report.matcherResults = [...existing, entry];
|
|
148
|
+
// Backward-compat shim: keep the legacy field populated with the most
|
|
149
|
+
// recent reasoning so external readers that haven't migrated still
|
|
150
|
+
// work. Empty string is a deliberate signal for SDK-multi-judge runs
|
|
151
|
+
// (the field can't represent multiple verdicts; consumers must look
|
|
152
|
+
// at matcherResults).
|
|
153
|
+
report.llmJudgeReasoning = entry.reasoning ?? '';
|
|
154
|
+
return entry;
|
|
155
|
+
}
|
|
156
|
+
// ─── internal helpers ───────────────────────────────────────────────────────
|
|
157
|
+
/**
|
|
158
|
+
* The trace-mode init path sets `llmJudgeReasoning` to a placeholder
|
|
159
|
+
* before any real verdict exists. We must not synthesize a virtual
|
|
160
|
+
* matcher entry from that string \u2014 it's a "judge has not run yet"
|
|
161
|
+
* signal, not real reasoning.
|
|
162
|
+
*/
|
|
163
|
+
function isPlaceholderReasoning(s) {
|
|
164
|
+
return /^Waiting for traces/i.test(s);
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Best-effort guess at the verdict for a synthesized entry on an old
|
|
168
|
+
* report. Prefers an explicit `passFailStatus` if present; otherwise
|
|
169
|
+
* falls back to the report's metrics.accuracy (>=70 ~ pass), and
|
|
170
|
+
* finally defaults to `false` so a missing verdict never silently
|
|
171
|
+
* looks green.
|
|
172
|
+
*/
|
|
173
|
+
function inferPassFromReport(report) {
|
|
174
|
+
if (report.passFailStatus === 'passed')
|
|
175
|
+
return true;
|
|
176
|
+
if (report.passFailStatus === 'failed')
|
|
177
|
+
return false;
|
|
178
|
+
const acc = report.metrics?.accuracy;
|
|
179
|
+
if (typeof acc === 'number')
|
|
180
|
+
return acc >= 70;
|
|
181
|
+
return false;
|
|
182
|
+
}
|
|
183
|
+
//# sourceMappingURL=judgeAccessor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"judgeAccessor.js","sourceRoot":"","sources":["../../../matchers/judgeAccessor.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAsCH;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,UAAU,sBAAsB,CAAC,MAAyB;IAC9D,MAAM,WAAW,GAAG,CAAC,MAAM,CAAC,cAAc,IAAI,EAAE,CAAC,CA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AAC;AAC7C,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,wBAAwB,CACtC,MAA4F,EAC5F,WAA4B,EAC5B,OAA4C;IAE5C,MAAM,KAAK,GAAG,sBAAsB,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;IAE3D,MAAM,QAAQ,GAAG,MAAM,CAAC,cAAc,IAAI,EAAE,CAAC;IAC7C,MAAM,CAAC,cAAc,GAAG,CAAC,GAAG,QAAQ,EAAE,KAAK,CAAC,CAAC;IAE7C,sEAAsE;IACtE,mEAAmE;IACnE,qEAAqE;IACrE,oEAAoE;IACpE,sBAAsB;IACtB,MAAM,CAAC,iBAAiB,GAAG,KAAK,CAAC,SAAS,IAAI,EAAE,CAAC;IAEjD,OAAO,KAAK,CAAC;AACf,CAAC;AAgBD,+EAA+E;AAE/E;;;;;GAKG;AACH,SAAS,sBAAsB,CAAC,CAAS;IACvC,OAAO,sBAAsB,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AACxC,CAAC;AAED;;;;;;GAMG;AACH,SAAS,mBAAmB,CAAC,MAAwF;IACnH,IAAI,MAAM,CAAC,cAAc,KAAK,QAAQ;QAAE,OAAO,IAAI,CAAC;IACpD,IAAI,MAAM,CAAC,cAAc,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAC;IACrD,MAAM,GAAG,GAAG,MAAM,CAAC,OAAO,EAAE,QAAQ,CAAC;IACrC,IAAI,OAAO,GAAG,KAAK,QAAQ;QAAE,OAAO,GAAG,IAAI,EAAE,CAAC;IAC9C,OAAO,KAAK,CAAC;AACf,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { MatcherResult, MatcherMethod } from './types.js';
|
|
2
|
+
export interface MatcherSession {
|
|
3
|
+
results: MatcherResult[];
|
|
4
|
+
startedAt: number;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Run `fn` with a fresh, isolated matcher session and return the verdicts
|
|
8
|
+
* recorded during it. Concurrency-safe: each call gets its own session via
|
|
9
|
+
* AsyncLocalStorage, so interleaved bodies never share verdicts.
|
|
10
|
+
*
|
|
11
|
+
* Results are returned even when `fn` throws — the caller can inspect both
|
|
12
|
+
* the partial results and the error (cleanup hooks that record after a body
|
|
13
|
+
* failure therefore still surface in the breakdown).
|
|
14
|
+
*/
|
|
15
|
+
export declare function runInSession<T>(fn: () => Promise<T> | T): Promise<{
|
|
16
|
+
results: MatcherResult[];
|
|
17
|
+
value?: T;
|
|
18
|
+
error?: unknown;
|
|
19
|
+
}>;
|
|
20
|
+
/**
|
|
21
|
+
* Begin a fresh global session and make it active (legacy API).
|
|
22
|
+
*
|
|
23
|
+
* Prefer {@link runInSession} for anything that may run concurrently. This
|
|
24
|
+
* remains for synchronous, single-threaded callers.
|
|
25
|
+
*/
|
|
26
|
+
export declare function startSession(): MatcherSession;
|
|
27
|
+
/** Stop the current global session and return its results (legacy API). */
|
|
28
|
+
export declare function endSession(): MatcherResult[];
|
|
29
|
+
/** True when a session is active (ALS scope or legacy global). */
|
|
30
|
+
export declare function isSessionActive(): boolean;
|
|
31
|
+
/** Record a single matcher verdict on the active session. No-op when none. */
|
|
32
|
+
export declare function recordVerdict(result: MatcherResult): void;
|
|
33
|
+
/**
|
|
34
|
+
* Record a verdict computed from a try/catch around the matcher body.
|
|
35
|
+
* Convenience wrapper used by judge() and traces helpers; chai matchers go
|
|
36
|
+
* through the chai plugin in `./expect.ts`.
|
|
37
|
+
*/
|
|
38
|
+
export declare function recordWithTiming<T>(description: string, method: MatcherMethod, fn: () => Promise<T> | T): Promise<T>;
|
|
39
|
+
//# sourceMappingURL=session.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../../../matchers/session.ts"],"names":[],"mappings":"AA8BA,OAAO,KAAK,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAE/D,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,aAAa,EAAE,CAAC;IACzB,SAAS,EAAE,MAAM,CAAC;CACnB;AAiBD;;;;;;;;GAQG;AACH,wBAAsB,YAAY,CAAC,CAAC,EAClC,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,GACvB,OAAO,CAAC;IAAE,OAAO,EAAE,aAAa,EAAE,CAAC;IAAC,KAAK,CAAC,EAAE,CAAC,CAAC;IAAC,KAAK,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC,CAQnE;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,IAAI,cAAc,CAG7C;AAED,2EAA2E;AAC3E,wBAAgB,UAAU,IAAI,aAAa,EAAE,CAK5C;AAED,kEAAkE;AAClE,wBAAgB,eAAe,IAAI,OAAO,CAEzC;AAED,8EAA8E;AAC9E,wBAAgB,aAAa,CAAC,MAAM,EAAE,aAAa,GAAG,IAAI,CAIzD;AAED;;;;GAIG;AACH,wBAAsB,gBAAgB,CAAC,CAAC,EACtC,WAAW,EAAE,MAAM,EACnB,MAAM,EAAE,aAAa,EACrB,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,GACvB,OAAO,CAAC,CAAC,CAAC,CAqBZ"}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright OpenSearch Contributors
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Matcher session — collects MatcherResult[] for the currently-executing
|
|
7
|
+
* test body. Matchers (expect/judge/traces) record into the active session
|
|
8
|
+
* via `recordVerdict`.
|
|
9
|
+
*
|
|
10
|
+
* Concurrency model (RFC 004, "kills the global session"):
|
|
11
|
+
*
|
|
12
|
+
* The session is held in an AsyncLocalStorage so that bodies running
|
|
13
|
+
* concurrently (the runners dispatch up to `concurrency` tests at once,
|
|
14
|
+
* interleaving at every `await`) each record into their OWN session.
|
|
15
|
+
* Before this, a single module-level `activeSession` was shared by all
|
|
16
|
+
* in-flight bodies, so verdicts cross-contaminated between tests.
|
|
17
|
+
*
|
|
18
|
+
* `runInSession(fn)` is the concurrency-safe entry point and is what the
|
|
19
|
+
* runners use: it establishes a fresh session for the duration of `fn`
|
|
20
|
+
* (and everything it `await`s) and returns the collected results.
|
|
21
|
+
*
|
|
22
|
+
* The legacy `startSession()` / `endSession()` pair is retained for
|
|
23
|
+
* synchronous, non-interleaved callers (unit tests, simple scripts). It
|
|
24
|
+
* uses a module-global fallback session. When an AsyncLocalStorage scope
|
|
25
|
+
* is active (i.e. we're inside `runInSession`), the ALS session always
|
|
26
|
+
* takes precedence over the global, so the two never collide.
|
|
27
|
+
*/
|
|
28
|
+
import { AsyncLocalStorage } from 'async_hooks';
|
|
29
|
+
/** Per-async-context session. Set for the duration of `runInSession(fn)`. */
|
|
30
|
+
const sessionStore = new AsyncLocalStorage();
|
|
31
|
+
/** Legacy module-global session for direct startSession()/endSession() callers. */
|
|
32
|
+
let legacySession = null;
|
|
33
|
+
function newSession() {
|
|
34
|
+
return { results: [], startedAt: Date.now() };
|
|
35
|
+
}
|
|
36
|
+
/** The session verdicts should be recorded into right now, if any. */
|
|
37
|
+
function currentSession() {
|
|
38
|
+
return sessionStore.getStore() ?? legacySession;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Run `fn` with a fresh, isolated matcher session and return the verdicts
|
|
42
|
+
* recorded during it. Concurrency-safe: each call gets its own session via
|
|
43
|
+
* AsyncLocalStorage, so interleaved bodies never share verdicts.
|
|
44
|
+
*
|
|
45
|
+
* Results are returned even when `fn` throws — the caller can inspect both
|
|
46
|
+
* the partial results and the error (cleanup hooks that record after a body
|
|
47
|
+
* failure therefore still surface in the breakdown).
|
|
48
|
+
*/
|
|
49
|
+
export async function runInSession(fn) {
|
|
50
|
+
const session = newSession();
|
|
51
|
+
try {
|
|
52
|
+
const value = await sessionStore.run(session, fn);
|
|
53
|
+
return { results: session.results, value };
|
|
54
|
+
}
|
|
55
|
+
catch (error) {
|
|
56
|
+
return { results: session.results, error };
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Begin a fresh global session and make it active (legacy API).
|
|
61
|
+
*
|
|
62
|
+
* Prefer {@link runInSession} for anything that may run concurrently. This
|
|
63
|
+
* remains for synchronous, single-threaded callers.
|
|
64
|
+
*/
|
|
65
|
+
export function startSession() {
|
|
66
|
+
legacySession = newSession();
|
|
67
|
+
return legacySession;
|
|
68
|
+
}
|
|
69
|
+
/** Stop the current global session and return its results (legacy API). */
|
|
70
|
+
export function endSession() {
|
|
71
|
+
if (!legacySession)
|
|
72
|
+
return [];
|
|
73
|
+
const out = legacySession.results;
|
|
74
|
+
legacySession = null;
|
|
75
|
+
return out;
|
|
76
|
+
}
|
|
77
|
+
/** True when a session is active (ALS scope or legacy global). */
|
|
78
|
+
export function isSessionActive() {
|
|
79
|
+
return currentSession() !== null;
|
|
80
|
+
}
|
|
81
|
+
/** Record a single matcher verdict on the active session. No-op when none. */
|
|
82
|
+
export function recordVerdict(result) {
|
|
83
|
+
const session = currentSession();
|
|
84
|
+
if (!session)
|
|
85
|
+
return;
|
|
86
|
+
session.results.push(result);
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Record a verdict computed from a try/catch around the matcher body.
|
|
90
|
+
* Convenience wrapper used by judge() and traces helpers; chai matchers go
|
|
91
|
+
* through the chai plugin in `./expect.ts`.
|
|
92
|
+
*/
|
|
93
|
+
export async function recordWithTiming(description, method, fn) {
|
|
94
|
+
const start = Date.now();
|
|
95
|
+
try {
|
|
96
|
+
const value = await fn();
|
|
97
|
+
recordVerdict({
|
|
98
|
+
description,
|
|
99
|
+
pass: true,
|
|
100
|
+
method,
|
|
101
|
+
durationMs: Date.now() - start,
|
|
102
|
+
});
|
|
103
|
+
return value;
|
|
104
|
+
}
|
|
105
|
+
catch (err) {
|
|
106
|
+
recordVerdict({
|
|
107
|
+
description,
|
|
108
|
+
pass: false,
|
|
109
|
+
method,
|
|
110
|
+
durationMs: Date.now() - start,
|
|
111
|
+
errorMessage: err?.message || String(err),
|
|
112
|
+
});
|
|
113
|
+
throw err;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
//# sourceMappingURL=session.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session.js","sourceRoot":"","sources":["../../../matchers/session.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAQhD,6EAA6E;AAC7E,MAAM,YAAY,GAAG,IAAI,iBAAiB,EAAkB,CAAC;AAE7D,mFAAmF;AACnF,IAAI,aAAa,GAA0B,IAAI,CAAC;AAEhD,SAAS,UAAU;IACjB,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE,EAAE,CAAC;AAChD,CAAC;AAED,sEAAsE;AACtE,SAAS,cAAc;IACrB,OAAO,YAAY,CAAC,QAAQ,EAAE,IAAI,aAAa,CAAC;AAClD,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAChC,EAAwB;IAExB,MAAM,OAAO,GAAG,UAAU,EAAE,CAAC;IAC7B,IAAI,CAAC;QACH,MAAM,KAAK,GAAG,MAAM,YAAY,CAAC,GAAG,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;QAClD,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,OAAO,EAAE,KAAK,EAAE,CAAC;IAC7C,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,OAAO,EAAE,KAAK,EAAE,CAAC;IAC7C,CAAC;AACH,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,YAAY;IAC1B,aAAa,GAAG,UAAU,EAAE,CAAC;IAC7B,OAAO,aAAa,CAAC;AACvB,CAAC;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OTel traces emitted by the
|
|
3
|
+
* agent during this run. Pre-loaded by the runner before the test body
|
|
4
|
+
* starts; sync access from inside the body.
|
|
5
|
+
*
|
|
6
|
+
* Three construction modes (the runner picks one):
|
|
7
|
+
* - `buildTracesAccessor(spans)` — real spans available, real numbers.
|
|
8
|
+
* - `emptyTracesAccessor()` — agent opted out (`useTraces=false`).
|
|
9
|
+
* Every accessor returns 0/[] so user matchers don't blow up.
|
|
10
|
+
* - `unavailableTracesAccessor(reason)` — agent opted in (`useTraces=true`)
|
|
11
|
+
* but spans were not fetchable (no runId, fetch failed, or polling
|
|
12
|
+
* timed out). Every accessor *throws* so silent false-passes like
|
|
13
|
+
* `expect(traces.totalTokens).to.be.lessThan(10_000)` against an
|
|
14
|
+
* empty fixture become loud failures (see issue #230).
|
|
15
|
+
*
|
|
16
|
+
* Built on top of `services/traces/index.ts:fetchTracesByRunIds` —
|
|
17
|
+
* the runner is responsible for invoking that and constructing the
|
|
18
|
+
* accessor.
|
|
19
|
+
*/
|
|
20
|
+
import type { Span } from '../../types/index.js';
|
|
21
|
+
export interface TracesAccessor {
|
|
22
|
+
/** Sum of all `gen_ai.usage.prompt_tokens + completion_tokens` across LLM spans. */
|
|
23
|
+
totalTokens: number;
|
|
24
|
+
/** Sum of all `gen_ai.usage.cost_usd` (or derived) across LLM spans. */
|
|
25
|
+
totalCost: number;
|
|
26
|
+
/** Tool invocation summary derived from spans. */
|
|
27
|
+
toolCalls: ReadonlyArray<{
|
|
28
|
+
name: string;
|
|
29
|
+
durationMs: number;
|
|
30
|
+
}>;
|
|
31
|
+
/** Duration of the first span matching the given name, or 0 when not found. */
|
|
32
|
+
spanDuration(name: string): number;
|
|
33
|
+
/** All spans (read-only). */
|
|
34
|
+
spans: ReadonlyArray<Span>;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Empty accessor — silent zeros. Used when the agent opted out of traces
|
|
38
|
+
* (`useTraces: false`). Reading any accessor returns `0` / `[]` so user
|
|
39
|
+
* matchers in opt-out scenarios don't throw.
|
|
40
|
+
*/
|
|
41
|
+
export declare function emptyTracesAccessor(): TracesAccessor;
|
|
42
|
+
/**
|
|
43
|
+
* Loud-failure accessor — every read throws. Used when the agent opted
|
|
44
|
+
* in to traces (`useTraces: true`) but spans were not retrievable. This
|
|
45
|
+
* turns the silent false-pass described in issue #230 into an actionable
|
|
46
|
+
* error, e.g.:
|
|
47
|
+
*
|
|
48
|
+
* Error: traces fixture unavailable: no spans found for runId=…
|
|
49
|
+
*
|
|
50
|
+
* Construction never throws — only attribute / method access does.
|
|
51
|
+
*/
|
|
52
|
+
export declare function unavailableTracesAccessor(reason: string): TracesAccessor;
|
|
53
|
+
/** Build a TracesAccessor from a flat list of spans. */
|
|
54
|
+
export declare function buildTracesAccessor(spans: Span[]): TracesAccessor;
|
|
55
|
+
//# sourceMappingURL=traces.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"traces.d.ts","sourceRoot":"","sources":["../../../matchers/traces.ts"],"names":[],"mappings":"AAKA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAEjD,MAAM,WAAW,cAAc;IAC7B,oFAAoF;IACpF,WAAW,EAAE,MAAM,CAAC;IACpB,wEAAwE;IACxE,SAAS,EAAE,MAAM,CAAC;IAClB,kDAAkD;IAClD,SAAS,EAAE,aAAa,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAC/D,+EAA+E;IAC/E,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;IACnC,6BAA6B;IAC7B,KAAK,EAAE,aAAa,CAAC,IAAI,CAAC,CAAC;CAC5B;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,IAAI,cAAc,CAQpD;AAED;;;;;;;;;GASG;AACH,wBAAgB,yBAAyB,CAAC,MAAM,EAAE,MAAM,GAAG,cAAc,CAWxE;AAED,wDAAwD;AACxD,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,IAAI,EAAE,GAAG,cAAc,CA4CjE"}
|