@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,169 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright OpenSearch Contributors
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Codemod: migrate v1 code-SDK eval files to the RFC-004 control-inversion
|
|
7
|
+
* shape (#256, phase 10 tooling).
|
|
8
|
+
*
|
|
9
|
+
* v1 bodies received a pre-populated `result` fixture (the framework invoked
|
|
10
|
+
* the agent eagerly). v2 bodies own invocation: `const result = await
|
|
11
|
+
* agent.run()`. This transform rewrites each `test(name, options, body)`
|
|
12
|
+
* whose body destructures `result` AND whose options carry a `prompt`:
|
|
13
|
+
*
|
|
14
|
+
* test('x', { prompt: 'p' }, function ({ result, judge }) { ...result... })
|
|
15
|
+
* ↓
|
|
16
|
+
* test('x', { prompt: 'p' }, async ({ agent, judge }) => {
|
|
17
|
+
* const result = await agent.run();
|
|
18
|
+
* ...result...
|
|
19
|
+
* })
|
|
20
|
+
*
|
|
21
|
+
* Tests with no `prompt` (data-only) are left untouched — their `result` is
|
|
22
|
+
* the empty placeholder, which is still valid. Bodies that already call
|
|
23
|
+
* `agent.run()` are skipped (idempotent).
|
|
24
|
+
*
|
|
25
|
+
* Uses the TypeScript compiler API for a precise, formatting-preserving
|
|
26
|
+
* transform via plain text-range edits (no full reprint), so it works on
|
|
27
|
+
* both `.eval.js` and `.eval.ts`.
|
|
28
|
+
*/
|
|
29
|
+
import * as ts from 'typescript';
|
|
30
|
+
/** Is this call expression a `test(...)` / `test.only(...)` registration? */
|
|
31
|
+
function isTestCall(node) {
|
|
32
|
+
const e = node.expression;
|
|
33
|
+
if (ts.isIdentifier(e))
|
|
34
|
+
return e.text === 'test';
|
|
35
|
+
if (ts.isPropertyAccessExpression(e) && ts.isIdentifier(e.expression)) {
|
|
36
|
+
return e.expression.text === 'test';
|
|
37
|
+
}
|
|
38
|
+
return false;
|
|
39
|
+
}
|
|
40
|
+
/** Extract the options-object literal argument (2nd arg) if present. */
|
|
41
|
+
function optionsArg(call) {
|
|
42
|
+
const a = call.arguments[1];
|
|
43
|
+
return a && ts.isObjectLiteralExpression(a) ? a : undefined;
|
|
44
|
+
}
|
|
45
|
+
/** Does the options object declare a non-empty `prompt`? */
|
|
46
|
+
function hasPrompt(opts) {
|
|
47
|
+
if (!opts)
|
|
48
|
+
return false;
|
|
49
|
+
return opts.properties.some((p) => ts.isPropertyAssignment(p) &&
|
|
50
|
+
((ts.isIdentifier(p.name) && p.name.text === 'prompt') ||
|
|
51
|
+
(ts.isStringLiteral(p.name) && p.name.text === 'prompt')));
|
|
52
|
+
}
|
|
53
|
+
/** The body is the last argument when it's a function/arrow. */
|
|
54
|
+
function bodyArg(call) {
|
|
55
|
+
const last = call.arguments[call.arguments.length - 1];
|
|
56
|
+
if (last && (ts.isFunctionExpression(last) || ts.isArrowFunction(last)))
|
|
57
|
+
return last;
|
|
58
|
+
return undefined;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Run the codemod over a single file's source text.
|
|
62
|
+
*/
|
|
63
|
+
export function migrateEvalSource(code, fileName = 'eval.ts') {
|
|
64
|
+
const sf = ts.createSourceFile(fileName, code, ts.ScriptTarget.Latest,
|
|
65
|
+
/*setParentNodes*/ true, fileName.endsWith('.ts') ? ts.ScriptKind.TS : ts.ScriptKind.JS);
|
|
66
|
+
const edits = [];
|
|
67
|
+
const notes = [];
|
|
68
|
+
const visit = (node) => {
|
|
69
|
+
if (ts.isCallExpression(node) && isTestCall(node)) {
|
|
70
|
+
processTest(node);
|
|
71
|
+
}
|
|
72
|
+
ts.forEachChild(node, visit);
|
|
73
|
+
};
|
|
74
|
+
function testName(call) {
|
|
75
|
+
const a = call.arguments[0];
|
|
76
|
+
return a && ts.isStringLiteralLike(a) ? a.text : '<anonymous>';
|
|
77
|
+
}
|
|
78
|
+
function processTest(call) {
|
|
79
|
+
const name = testName(call);
|
|
80
|
+
const body = bodyArg(call);
|
|
81
|
+
if (!body)
|
|
82
|
+
return; // no function body (e.g. test(name) stub)
|
|
83
|
+
const param = body.parameters[0];
|
|
84
|
+
// Only the object-destructuring fixture form is migrated.
|
|
85
|
+
if (!param || !ts.isObjectBindingPattern(param.name)) {
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
const binding = param.name;
|
|
89
|
+
const names = binding.elements
|
|
90
|
+
.map((el) => (ts.isIdentifier(el.name) ? el.name.text : ''))
|
|
91
|
+
.filter(Boolean);
|
|
92
|
+
const usesResult = names.includes('result');
|
|
93
|
+
const usesAgent = names.includes('agent');
|
|
94
|
+
// Idempotency / applicability guards.
|
|
95
|
+
const bodyText = body.body ? body.body.getText(sf) : '';
|
|
96
|
+
const hasAgentRun = /\bagent\s*\.\s*run\s*\(/.test(bodyText);
|
|
97
|
+
if (hasAgentRun && !usesResult) {
|
|
98
|
+
// Fully migrated: calls agent.run() and no longer destructures `result`.
|
|
99
|
+
notes.push(`skip ${name}: already migrated (calls agent.run(), no result binding)`);
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
if (hasAgentRun && usesResult) {
|
|
103
|
+
// Half-migrated: agent.run() is in, but `result` is still destructured
|
|
104
|
+
// (and almost certainly still referenced). The runner hands the body an
|
|
105
|
+
// empty placeholder `result` when `agent` is destructured separately, so
|
|
106
|
+
// those `result.*` reads silently read empties and assertions fail — the
|
|
107
|
+
// migration *looks* broken when it isn't. We can't safely rename those
|
|
108
|
+
// reads to the agent.run() return value, so surface for manual review
|
|
109
|
+
// instead of silently reporting "already migrated".
|
|
110
|
+
notes.push(`review ${name}: half-migrated — calls agent.run() but still destructures \`result\`. ` +
|
|
111
|
+
`Capture the agent.run() return value (\`const result = await agent.run()\`) and drop the \`result\` fixture.`);
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
if (!hasPrompt(optionsArg(call))) {
|
|
115
|
+
notes.push(`skip ${name}: no prompt (data-only test, result placeholder is valid)`);
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
if (!usesResult) {
|
|
119
|
+
notes.push(`skip ${name}: body does not use result`);
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
// 1) Rewrite the destructuring: replace `result` with `agent` (or add
|
|
123
|
+
// `agent` if result+agent both somehow absent). Keep other fixtures.
|
|
124
|
+
const newNames = names.map((n) => (n === 'result' ? 'agent' : n));
|
|
125
|
+
if (usesAgent) {
|
|
126
|
+
// agent already destructured — just drop `result`.
|
|
127
|
+
const filtered = names.filter((n) => n !== 'result');
|
|
128
|
+
newNames.length = 0;
|
|
129
|
+
newNames.push(...filtered);
|
|
130
|
+
}
|
|
131
|
+
const newBinding = `{ ${newNames.join(', ')} }`;
|
|
132
|
+
edits.push({ start: binding.getStart(sf), end: binding.getEnd(), text: newBinding });
|
|
133
|
+
// 2) Ensure the function is async.
|
|
134
|
+
const isAsync = body.modifiers?.some((m) => m.kind === ts.SyntaxKind.AsyncKeyword);
|
|
135
|
+
if (!isAsync) {
|
|
136
|
+
edits.push({ start: body.getStart(sf), end: body.getStart(sf), text: 'async ' });
|
|
137
|
+
}
|
|
138
|
+
// 3) Insert `const result = await agent.run();` at the top of the body.
|
|
139
|
+
// Handle both block bodies `{ ... }` and expression arrow bodies.
|
|
140
|
+
if (body.body && ts.isBlock(body.body)) {
|
|
141
|
+
const openBrace = body.body.getStart(sf) + 1; // just after `{`
|
|
142
|
+
edits.push({ start: openBrace, end: openBrace, text: `\n const result = await agent.run();` });
|
|
143
|
+
}
|
|
144
|
+
else if (body.body) {
|
|
145
|
+
// Expression-bodied arrow: wrap into a block.
|
|
146
|
+
const exprStart = body.body.getStart(sf);
|
|
147
|
+
const exprEnd = body.body.getEnd();
|
|
148
|
+
const exprText = body.body.getText(sf);
|
|
149
|
+
edits.push({
|
|
150
|
+
start: exprStart,
|
|
151
|
+
end: exprEnd,
|
|
152
|
+
text: `{\n const result = await agent.run();\n return ${exprText};\n}`,
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
notes.push(`migrate ${name}: result → agent.run()`);
|
|
156
|
+
}
|
|
157
|
+
visit(sf);
|
|
158
|
+
if (edits.length === 0) {
|
|
159
|
+
return { code, changed: false, notes };
|
|
160
|
+
}
|
|
161
|
+
// Apply edits right-to-left so offsets stay valid.
|
|
162
|
+
edits.sort((a, b) => b.start - a.start);
|
|
163
|
+
let out = code;
|
|
164
|
+
for (const e of edits) {
|
|
165
|
+
out = out.slice(0, e.start) + e.text + out.slice(e.end);
|
|
166
|
+
}
|
|
167
|
+
return { code: out, changed: true, notes };
|
|
168
|
+
}
|
|
169
|
+
//# sourceMappingURL=codemod.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"codemod.js","sourceRoot":"","sources":["../../../testCases/codemod.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,KAAK,EAAE,MAAM,YAAY,CAAC;AAiBjC,6EAA6E;AAC7E,SAAS,UAAU,CAAC,IAAuB;IACzC,MAAM,CAAC,GAAG,IAAI,CAAC,UAAU,CAAC;IAC1B,IAAI,EAAE,CAAC,YAAY,CAAC,CAAC,CAAC;QAAE,OAAO,CAAC,CAAC,IAAI,KAAK,MAAM,CAAC;IACjD,IAAI,EAAE,CAAC,0BAA0B,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,YAAY,CAAC,CAAC,CAAC,UAAU,CAAC,EAAE,CAAC;QACtE,OAAO,CAAC,CAAC,UAAU,CAAC,IAAI,KAAK,MAAM,CAAC;IACtC,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED,wEAAwE;AACxE,SAAS,UAAU,CAAC,IAAuB;IACzC,MAAM,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;IAC5B,OAAO,CAAC,IAAI,EAAE,CAAC,yBAAyB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;AAC9D,CAAC;AAED,4DAA4D;AAC5D,SAAS,SAAS,CAAC,IAA4C;IAC7D,IAAI,CAAC,IAAI;QAAE,OAAO,KAAK,CAAC;IACxB,OAAO,IAAI,CAAC,UAAU,CAAC,IAAI,CACzB,CAAC,CAAC,EAAE,EAAE,CACJ,EAAE,CAAC,oBAAoB,CAAC,CAAC,CAAC;QAC1B,CAAC,CAAC,EAAE,CAAC,YAAY,CAAC,CA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MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;YACvC,KAAK,CAAC,IAAI,CAAC;gBACT,KAAK,EAAE,SAAS;gBAChB,GAAG,EAAE,OAAO;gBACZ,IAAI,EAAE,oDAAoD,QAAQ,MAAM;aACzE,CAAC,CAAC;QACL,CAAC;QAED,KAAK,CAAC,IAAI,CAAC,WAAW,IAAI,wBAAwB,CAAC,CAAC;IACtD,CAAC;IAED,KAAK,CAAC,EAAE,CAAC,CAAC;IAEV,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACvB,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC;IACzC,CAAC;IAED,mDAAmD;IACnD,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC;IACxC,IAAI,GAAG,GAAG,IAAI,CAAC;IACf,KAAK,MAAM,CAAC,IAAI,KAAK,EAAE,CAAC;QACtB,GAAG,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;IAC1D,CAAC;IACD,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;AAC7C,CAAC"}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import type { CodeTestCase, TestOptions, EvalResult, HookFn, RegisteredHook } from './types.js';
|
|
2
|
+
/** @internal */
|
|
3
|
+
export declare function _resetExperimentalWarning(): void;
|
|
4
|
+
export declare function setActiveFile(filePath: string): void;
|
|
5
|
+
/**
|
|
6
|
+
* Register a code-based test case.
|
|
7
|
+
*
|
|
8
|
+
* Two valid signatures (Playwright-style):
|
|
9
|
+
* - `test(name, body)` — no options at all
|
|
10
|
+
* - `test(name, options, body)` — with options
|
|
11
|
+
*
|
|
12
|
+
* Only `name` is required. All TestOptions fields are optional. When
|
|
13
|
+
* `options.prompt` is absent, the runner skips agent invocation and the
|
|
14
|
+
* body receives an empty EvalResult.
|
|
15
|
+
*
|
|
16
|
+
* Throws if a test with the same name is already registered in the same
|
|
17
|
+
* source file. Cross-file duplicates are allowed (storage identity is
|
|
18
|
+
* `name + sourceFile`).
|
|
19
|
+
*
|
|
20
|
+
* @experimental The SDK shape (signature, options, body fixtures) may change
|
|
21
|
+
* in a minor release without a deprecation cycle. See `lib/index.ts`.
|
|
22
|
+
*/
|
|
23
|
+
export declare function test(name: string, body: (result: EvalResult) => Promise<void> | void): void;
|
|
24
|
+
export declare function test(name: string, options: TestOptions, body: (result: EvalResult) => Promise<void> | void): void;
|
|
25
|
+
/**
|
|
26
|
+
* Group tests under a benchmark name. Equivalent to Playwright's
|
|
27
|
+
* `describe()` — the wrapped `test()` calls inherit the describe's name as
|
|
28
|
+
* their benchmark group. Nested describes flatten with ' > '.
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* describe('RCA Suite', () => {
|
|
32
|
+
* test('payment-service is the root cause', { prompt: ... }, async ({ result, judge }) => {
|
|
33
|
+
* expect(result.trajectory).to.haveCalledTool('search_logs');
|
|
34
|
+
* await judge(result, 'identifies the failing dependency');
|
|
35
|
+
* });
|
|
36
|
+
* });
|
|
37
|
+
*
|
|
38
|
+
* The describe body MUST be synchronous (no `await`/dynamic content), like
|
|
39
|
+
* Playwright. The function is invoked once at registration time.
|
|
40
|
+
*/
|
|
41
|
+
export declare function describe(name: string, fn: () => void): void;
|
|
42
|
+
export declare function getRegisteredTests(filePath?: string): CodeTestCase[];
|
|
43
|
+
/**
|
|
44
|
+
* Return all hooks registered for the given file (or every file when no
|
|
45
|
+
* argument is given). Returns a snapshot — mutating the result has no
|
|
46
|
+
* effect on the registry.
|
|
47
|
+
*/
|
|
48
|
+
export declare function getRegisteredHooks(filePath?: string): RegisteredHook[];
|
|
49
|
+
export declare function clearRegistry(filePath?: string): void;
|
|
50
|
+
/**
|
|
51
|
+
* Register a hook that runs **once** before the first test in its scope.
|
|
52
|
+
*
|
|
53
|
+
* Scope is the surrounding `describe(...)` block, or the whole file when
|
|
54
|
+
* called at the top level. With parallel test execution (the runner
|
|
55
|
+
* dispatches up to `concurrency` tests at once), the orchestrator uses a
|
|
56
|
+
* once-latch so all parallel arrivals await the same `beforeAll` promise.
|
|
57
|
+
*
|
|
58
|
+
* @example
|
|
59
|
+
* beforeAll(async () => {
|
|
60
|
+
* await fs.mkdir('/tmp/agent-health-fixtures', { recursive: true });
|
|
61
|
+
* });
|
|
62
|
+
*/
|
|
63
|
+
export declare function beforeAll(fn: HookFn): void;
|
|
64
|
+
/**
|
|
65
|
+
* Register a hook that runs **once** after the last test in its scope.
|
|
66
|
+
*
|
|
67
|
+
* Always runs, even when every test in the scope failed. The orchestrator
|
|
68
|
+
* uses a remaining-test counter (decremented on each test completion,
|
|
69
|
+
* regardless of pass/fail) and triggers `afterAll` when it hits zero.
|
|
70
|
+
*
|
|
71
|
+
* @example
|
|
72
|
+
* afterAll(async () => {
|
|
73
|
+
* await fs.rm('/tmp/agent-health-fixtures', { recursive: true });
|
|
74
|
+
* });
|
|
75
|
+
*/
|
|
76
|
+
export declare function afterAll(fn: HookFn): void;
|
|
77
|
+
/**
|
|
78
|
+
* Register a hook that runs **before each test** in its scope.
|
|
79
|
+
*
|
|
80
|
+
* Receives the same fixtures object the body will see, plus a
|
|
81
|
+
* `provide(key, value)` function for stashing values that the test body
|
|
82
|
+
* (and `afterEach`) can read via `fixtures.provisioned[key]`. Each test
|
|
83
|
+
* gets its own provisioned bag, so concurrent tests are isolated.
|
|
84
|
+
*
|
|
85
|
+
* @example
|
|
86
|
+
* beforeEach(async ({ provide, testInfo }) => {
|
|
87
|
+
* const dir = await fs.mkdtemp(`/tmp/${testInfo.name}-`);
|
|
88
|
+
* provide('workspaceDir', dir);
|
|
89
|
+
* });
|
|
90
|
+
*/
|
|
91
|
+
export declare function beforeEach(fn: HookFn): void;
|
|
92
|
+
/**
|
|
93
|
+
* Register a hook that runs **after each test** in its scope.
|
|
94
|
+
*
|
|
95
|
+
* Always runs, even when the test body or a `beforeEach` threw. Reads
|
|
96
|
+
* provisioned values via `fixtures.provisioned[key]` for cleanup. Errors
|
|
97
|
+
* thrown from `afterEach` are captured as MatcherResult entries on the
|
|
98
|
+
* test — they don't crash the runner.
|
|
99
|
+
*
|
|
100
|
+
* @example
|
|
101
|
+
* afterEach(async ({ provisioned }) => {
|
|
102
|
+
* if (provisioned.workspaceDir) {
|
|
103
|
+
* await fs.rm(provisioned.workspaceDir as string, { recursive: true, force: true });
|
|
104
|
+
* }
|
|
105
|
+
* });
|
|
106
|
+
*/
|
|
107
|
+
export declare function afterEach(fn: HookFn): void;
|
|
108
|
+
export declare namespace test {
|
|
109
|
+
const beforeAll: (fn: HookFn) => void;
|
|
110
|
+
const afterAll: (fn: HookFn) => void;
|
|
111
|
+
const beforeEach: (fn: HookFn) => void;
|
|
112
|
+
const afterEach: (fn: HookFn) => void;
|
|
113
|
+
}
|
|
114
|
+
//# sourceMappingURL=define.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"define.d.ts","sourceRoot":"","sources":["../../../testCases/define.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EACV,YAAY,EACZ,WAAW,EACX,UAAU,EACV,MAAM,EAEN,cAAc,EACf,MAAM,YAAY,CAAC;AAiCpB,gBAAgB;AAChB,wBAAgB,yBAAyB,IAAI,IAAI,CAEhD;AAED,wBAAgB,aAAa,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAQpD;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,IAAI,CAClB,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,CAAC,MAAM,EAAE,UAAU,KAAK,OAAO,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AA4C,CAAC;CACtF"}
|
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright OpenSearch Contributors
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
5
|
+
import { readEnv } from '../envCompat.js';
|
|
6
|
+
const registries = new Map();
|
|
7
|
+
// Hooks live in a parallel registry keyed by file path, exactly matching
|
|
8
|
+
// the test() registry. The HookOrchestrator filters by describePath at
|
|
9
|
+
// run time. Cross-file hooks never leak — the loader resets per file.
|
|
10
|
+
const hookRegistries = new Map();
|
|
11
|
+
let activeFile = null;
|
|
12
|
+
const DEFAULT_KEY = '__default__';
|
|
13
|
+
// Active describe stack (synchronous push/pop). Each entry is a describe
|
|
14
|
+
// name; nested describes accumulate. When test() runs, it captures the
|
|
15
|
+
// current stack and joins with ' > ' to derive the test's benchmarkPath.
|
|
16
|
+
const describeStack = [];
|
|
17
|
+
// Emit a one-time experimental-status warning the first time the SDK is
|
|
18
|
+
// touched, unless the user opts out. This is intentionally noisy enough to be
|
|
19
|
+
// noticed but only fires once per process so it doesn't pollute test output.
|
|
20
|
+
let experimentalWarningEmitted = false;
|
|
21
|
+
function emitExperimentalWarningOnce() {
|
|
22
|
+
if (experimentalWarningEmitted)
|
|
23
|
+
return;
|
|
24
|
+
experimentalWarningEmitted = true;
|
|
25
|
+
if (readEnv('AH_SUPPRESS_EXPERIMENTAL', 'AGENT_HEALTH_SUPPRESS_EXPERIMENTAL') === '1')
|
|
26
|
+
return;
|
|
27
|
+
// eslint-disable-next-line no-console
|
|
28
|
+
console.warn('[agent-health] The code-based test SDK (test()/judge()/expect()) is ' +
|
|
29
|
+
'experimental. The API may change in a minor release without a ' +
|
|
30
|
+
'deprecation cycle. Pin your @opensearch-project/agent-health version, ' +
|
|
31
|
+
'or set AH_SUPPRESS_EXPERIMENTAL=1 to silence this notice.');
|
|
32
|
+
}
|
|
33
|
+
/** @internal */
|
|
34
|
+
export function _resetExperimentalWarning() {
|
|
35
|
+
experimentalWarningEmitted = false;
|
|
36
|
+
}
|
|
37
|
+
export function setActiveFile(filePath) {
|
|
38
|
+
activeFile = filePath;
|
|
39
|
+
if (!registries.has(filePath)) {
|
|
40
|
+
registries.set(filePath, []);
|
|
41
|
+
}
|
|
42
|
+
if (!hookRegistries.has(filePath)) {
|
|
43
|
+
hookRegistries.set(filePath, []);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
export function test(name, optionsOrBody, maybeBody) {
|
|
47
|
+
emitExperimentalWarningOnce();
|
|
48
|
+
// Resolve the two-arg / three-arg overload
|
|
49
|
+
let options;
|
|
50
|
+
let evaluate;
|
|
51
|
+
if (typeof optionsOrBody === 'function') {
|
|
52
|
+
options = {};
|
|
53
|
+
evaluate = optionsOrBody;
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
options = optionsOrBody ?? {};
|
|
57
|
+
evaluate = maybeBody;
|
|
58
|
+
}
|
|
59
|
+
if (!name || typeof name !== 'string') {
|
|
60
|
+
throw new Error('test() requires a name (the first argument)');
|
|
61
|
+
}
|
|
62
|
+
if (typeof evaluate !== 'function') {
|
|
63
|
+
throw new Error(`test("${name}") requires a body function`);
|
|
64
|
+
}
|
|
65
|
+
const key = activeFile ?? DEFAULT_KEY;
|
|
66
|
+
if (!registries.has(key)) {
|
|
67
|
+
registries.set(key, []);
|
|
68
|
+
}
|
|
69
|
+
const registry = registries.get(key);
|
|
70
|
+
// Within-file uniqueness guard: a name+benchmarkPath pair must be unique.
|
|
71
|
+
// The same name in two different describe blocks is allowed because they
|
|
72
|
+
// map to different benchmarks.
|
|
73
|
+
const benchmarkPath = describeStack.length > 0 ? describeStack.join(' > ') : undefined;
|
|
74
|
+
if (registry.some(t => t.name === name && t.benchmarkPath === benchmarkPath)) {
|
|
75
|
+
const fileLabel = activeFile ? ` in ${activeFile}` : '';
|
|
76
|
+
const groupLabel = benchmarkPath ? ` (in describe "${benchmarkPath}")` : '';
|
|
77
|
+
throw new Error(`Duplicate test name "${name}"${groupLabel}${fileLabel}. ` +
|
|
78
|
+
`Test names must be unique within their describe block. ` +
|
|
79
|
+
`Move one of the tests to a different describe() or rename it.`);
|
|
80
|
+
}
|
|
81
|
+
registry.push({
|
|
82
|
+
name,
|
|
83
|
+
options,
|
|
84
|
+
evaluate,
|
|
85
|
+
sourceFile: activeFile ?? undefined,
|
|
86
|
+
benchmarkPath,
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Group tests under a benchmark name. Equivalent to Playwright's
|
|
91
|
+
* `describe()` — the wrapped `test()` calls inherit the describe's name as
|
|
92
|
+
* their benchmark group. Nested describes flatten with ' > '.
|
|
93
|
+
*
|
|
94
|
+
* @example
|
|
95
|
+
* describe('RCA Suite', () => {
|
|
96
|
+
* test('payment-service is the root cause', { prompt: ... }, async ({ result, judge }) => {
|
|
97
|
+
* expect(result.trajectory).to.haveCalledTool('search_logs');
|
|
98
|
+
* await judge(result, 'identifies the failing dependency');
|
|
99
|
+
* });
|
|
100
|
+
* });
|
|
101
|
+
*
|
|
102
|
+
* The describe body MUST be synchronous (no `await`/dynamic content), like
|
|
103
|
+
* Playwright. The function is invoked once at registration time.
|
|
104
|
+
*/
|
|
105
|
+
export function describe(name, fn) {
|
|
106
|
+
emitExperimentalWarningOnce();
|
|
107
|
+
if (!name || typeof name !== 'string') {
|
|
108
|
+
throw new Error('describe() requires a name (the first argument)');
|
|
109
|
+
}
|
|
110
|
+
if (typeof fn !== 'function') {
|
|
111
|
+
throw new Error(`describe("${name}") requires a body function`);
|
|
112
|
+
}
|
|
113
|
+
describeStack.push(name);
|
|
114
|
+
try {
|
|
115
|
+
const result = fn();
|
|
116
|
+
if (result && typeof result.then === 'function') {
|
|
117
|
+
// Mirror Playwright — describe bodies must be synchronous because
|
|
118
|
+
// they run during registration, well before any test executes.
|
|
119
|
+
throw new Error(`describe("${name}") body returned a Promise. ` +
|
|
120
|
+
`describe blocks must be synchronous — use test() inside, not await.`);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
finally {
|
|
124
|
+
describeStack.pop();
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
export function getRegisteredTests(filePath) {
|
|
128
|
+
if (filePath)
|
|
129
|
+
return [...(registries.get(filePath) ?? [])];
|
|
130
|
+
return [...registries.values()].flatMap(r => [...r]);
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Return all hooks registered for the given file (or every file when no
|
|
134
|
+
* argument is given). Returns a snapshot — mutating the result has no
|
|
135
|
+
* effect on the registry.
|
|
136
|
+
*/
|
|
137
|
+
export function getRegisteredHooks(filePath) {
|
|
138
|
+
if (filePath)
|
|
139
|
+
return [...(hookRegistries.get(filePath) ?? [])];
|
|
140
|
+
return [...hookRegistries.values()].flatMap(r => [...r]);
|
|
141
|
+
}
|
|
142
|
+
export function clearRegistry(filePath) {
|
|
143
|
+
if (filePath) {
|
|
144
|
+
registries.delete(filePath);
|
|
145
|
+
hookRegistries.delete(filePath);
|
|
146
|
+
}
|
|
147
|
+
else {
|
|
148
|
+
registries.clear();
|
|
149
|
+
hookRegistries.clear();
|
|
150
|
+
}
|
|
151
|
+
activeFile = null;
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Internal helper used by the four public hook registrars below.
|
|
155
|
+
*
|
|
156
|
+
* Captures the live `(activeFile, [...describeStack])` so the orchestrator
|
|
157
|
+
* can filter hooks by scope at run time. Multiple hooks of the same kind
|
|
158
|
+
* in the same scope are allowed and run in registration order (reversed
|
|
159
|
+
* for `afterEach`/`afterAll`, mirroring Playwright/Jest).
|
|
160
|
+
*/
|
|
161
|
+
function registerHook(kind, fn) {
|
|
162
|
+
emitExperimentalWarningOnce();
|
|
163
|
+
if (typeof fn !== 'function') {
|
|
164
|
+
throw new Error(`${kind}() requires a function as its first argument`);
|
|
165
|
+
}
|
|
166
|
+
const key = activeFile ?? DEFAULT_KEY;
|
|
167
|
+
if (!hookRegistries.has(key)) {
|
|
168
|
+
hookRegistries.set(key, []);
|
|
169
|
+
}
|
|
170
|
+
const describePath = describeStack.length > 0 ? describeStack.join(' > ') : undefined;
|
|
171
|
+
hookRegistries.get(key).push({
|
|
172
|
+
kind,
|
|
173
|
+
fn,
|
|
174
|
+
sourceFile: activeFile ?? undefined,
|
|
175
|
+
describePath,
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Register a hook that runs **once** before the first test in its scope.
|
|
180
|
+
*
|
|
181
|
+
* Scope is the surrounding `describe(...)` block, or the whole file when
|
|
182
|
+
* called at the top level. With parallel test execution (the runner
|
|
183
|
+
* dispatches up to `concurrency` tests at once), the orchestrator uses a
|
|
184
|
+
* once-latch so all parallel arrivals await the same `beforeAll` promise.
|
|
185
|
+
*
|
|
186
|
+
* @example
|
|
187
|
+
* beforeAll(async () => {
|
|
188
|
+
* await fs.mkdir('/tmp/agent-health-fixtures', { recursive: true });
|
|
189
|
+
* });
|
|
190
|
+
*/
|
|
191
|
+
export function beforeAll(fn) { registerHook('beforeAll', fn); }
|
|
192
|
+
/**
|
|
193
|
+
* Register a hook that runs **once** after the last test in its scope.
|
|
194
|
+
*
|
|
195
|
+
* Always runs, even when every test in the scope failed. The orchestrator
|
|
196
|
+
* uses a remaining-test counter (decremented on each test completion,
|
|
197
|
+
* regardless of pass/fail) and triggers `afterAll` when it hits zero.
|
|
198
|
+
*
|
|
199
|
+
* @example
|
|
200
|
+
* afterAll(async () => {
|
|
201
|
+
* await fs.rm('/tmp/agent-health-fixtures', { recursive: true });
|
|
202
|
+
* });
|
|
203
|
+
*/
|
|
204
|
+
export function afterAll(fn) { registerHook('afterAll', fn); }
|
|
205
|
+
/**
|
|
206
|
+
* Register a hook that runs **before each test** in its scope.
|
|
207
|
+
*
|
|
208
|
+
* Receives the same fixtures object the body will see, plus a
|
|
209
|
+
* `provide(key, value)` function for stashing values that the test body
|
|
210
|
+
* (and `afterEach`) can read via `fixtures.provisioned[key]`. Each test
|
|
211
|
+
* gets its own provisioned bag, so concurrent tests are isolated.
|
|
212
|
+
*
|
|
213
|
+
* @example
|
|
214
|
+
* beforeEach(async ({ provide, testInfo }) => {
|
|
215
|
+
* const dir = await fs.mkdtemp(`/tmp/${testInfo.name}-`);
|
|
216
|
+
* provide('workspaceDir', dir);
|
|
217
|
+
* });
|
|
218
|
+
*/
|
|
219
|
+
export function beforeEach(fn) { registerHook('beforeEach', fn); }
|
|
220
|
+
/**
|
|
221
|
+
* Register a hook that runs **after each test** in its scope.
|
|
222
|
+
*
|
|
223
|
+
* Always runs, even when the test body or a `beforeEach` threw. Reads
|
|
224
|
+
* provisioned values via `fixtures.provisioned[key]` for cleanup. Errors
|
|
225
|
+
* thrown from `afterEach` are captured as MatcherResult entries on the
|
|
226
|
+
* test — they don't crash the runner.
|
|
227
|
+
*
|
|
228
|
+
* @example
|
|
229
|
+
* afterEach(async ({ provisioned }) => {
|
|
230
|
+
* if (provisioned.workspaceDir) {
|
|
231
|
+
* await fs.rm(provisioned.workspaceDir as string, { recursive: true, force: true });
|
|
232
|
+
* }
|
|
233
|
+
* });
|
|
234
|
+
*/
|
|
235
|
+
export function afterEach(fn) { registerHook('afterEach', fn); }
|
|
236
|
+
// Playwright-style sugar: `test.beforeEach(fn)` etc.
|
|
237
|
+
//
|
|
238
|
+
// Declaration merging here gives TypeScript users typed access to the four
|
|
239
|
+
// hook registrars *and* installs them as properties on the runtime `test`
|
|
240
|
+
// function value. Both `import { beforeEach }` and `test.beforeEach` route
|
|
241
|
+
// to the same internal registerHook() call.
|
|
242
|
+
// eslint-disable-next-line @typescript-eslint/no-namespace
|
|
243
|
+
(function (test) {
|
|
244
|
+
// eslint-disable-next-line @typescript-eslint/no-shadow
|
|
245
|
+
test.beforeAll = (fn) => registerHook('beforeAll', fn);
|
|
246
|
+
// eslint-disable-next-line @typescript-eslint/no-shadow
|
|
247
|
+
test.afterAll = (fn) => registerHook('afterAll', fn);
|
|
248
|
+
// eslint-disable-next-line @typescript-eslint/no-shadow
|
|
249
|
+
test.beforeEach = (fn) => registerHook('beforeEach', fn);
|
|
250
|
+
// eslint-disable-next-line @typescript-eslint/no-shadow
|
|
251
|
+
test.afterEach = (fn) => registerHook('afterEach', fn);
|
|
252
|
+
})(test || (test = {}));
|
|
253
|
+
//# sourceMappingURL=define.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"define.js","sourceRoot":"","sources":["../../../testCases/define.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAUH,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAE1C,MAAM,UAAU,GAAG,IAAI,GAAG,EAA0B,CAAC;AACrD,yEAAyE;AACzE,uEAAuE;AACvE,sEAAsE;AACtE,MAAM,cAAc,GAAG,IAAI,GAAG,EAA4B,CAAC;AAC3D,IAAI,UAAU,GAAkB,IAAI,CAAC;AACrC,MAAM,WAAW,GAAG,aAAa,CAAC;AAElC,yEAAyE;AACzE,uEAAuE;AACvE,yEAAyE;AACzE,MAAM,aAAa,GAAa,EAAE,CAAC;AAEnC,wEAAwE;AACxE,8EAA8E;AAC9E,6EAA6E;AAC7E,IAAI,0BAA0B,GAAG,KAAK,CAAC;AACvC,SAAS,2BAA2B;IAClC,IAAI,0BAA0B;QAAE,OAAO;IACvC,0BAA0B,GAAG,IAAI,CAAC;IAClC,IAAI,OAAO,CAAC,0BAA0B,EAAE,oCAAoC,CAAC,KAAK,GAAG;QAAE,OAAO;IAC9F,sCAAsC;IACtC,OAAO,CAAC,IAAI,CACV,sEAAsE;QACtE,gEAAgE;QAChE,wEAAwE;QACxE,2DAA2D,CAC5D,CAAC;AACJ,CAAC;AAED,gBAAgB;AAChB,MAAM,UAAU,yBAAyB;IACvC,0BAA0B,GAAG,KAAK,CAAC;AACrC,CAAC;AAED,MAAM,UAAU,aAAa,CAAC,QAAgB;IAC5C,UAAU,GAAG,QAAQ,CAAC;IACtB,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,QAAQ,CAAC,EA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B,CAAC,EAAE,EAAE,EAAE,CAAC,YAAY,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC;IACrF,wDAAwD;IAC3C,aAAQ,GAAyB,CAAC,EAAE,EAAE,EAAE,CAAC,YAAY,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC;IACnF,wDAAwD;IAC3C,eAAU,GAAyB,CAAC,EAAE,EAAE,EAAE,CAAC,YAAY,CAAC,YAAY,EAAE,EAAE,CAAC,CAAC;IACvF,wDAAwD;IAC3C,cAAS,GAAyB,CAAC,EAAE,EAAE,EAAE,CAAC,YAAY,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC;AACvF,CAAC,EATgB,IAAI,KAAJ,IAAI,QASpB"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `defineEvaluator()` + `evaluate()` — custom programmatic evaluators
|
|
3
|
+
* (RFC 004 §4.4, closes #244).
|
|
4
|
+
*
|
|
5
|
+
* Not every check is an LLM judge or a chai assertion. Sometimes the
|
|
6
|
+
* ground truth lives in code: a SQL result must match a golden row set, a
|
|
7
|
+
* generated diff must apply cleanly, a JSON answer must validate against a
|
|
8
|
+
* schema. A custom evaluator is a plain function that inspects the run and
|
|
9
|
+
* returns a verdict — deterministic, free, and fully under the author's
|
|
10
|
+
* control.
|
|
11
|
+
*
|
|
12
|
+
* ```js
|
|
13
|
+
* const { defineEvaluator, test } = require('@opensearch-project/agent-health');
|
|
14
|
+
*
|
|
15
|
+
* defineEvaluator('sql-matches-golden', ({ result }) => {
|
|
16
|
+
* const rows = JSON.parse(result.agentOutput);
|
|
17
|
+
* return { pass: deepEqual(rows, GOLDEN), reasoning: 'row set comparison' };
|
|
18
|
+
* });
|
|
19
|
+
*
|
|
20
|
+
* test('answers the revenue query', { prompt: '...' }, async ({ agent, evaluate }) => {
|
|
21
|
+
* const result = await agent.run();
|
|
22
|
+
* await evaluate(result, 'sql-matches-golden');
|
|
23
|
+
* });
|
|
24
|
+
* ```
|
|
25
|
+
*
|
|
26
|
+
* Evaluators are registered into a process-global registry by id (like a
|
|
27
|
+
* shared helper library), and run **in-process** when the body calls
|
|
28
|
+
* `evaluate()`. They record a `MatcherResult` with `method: 'evaluator'`,
|
|
29
|
+
* gate the test by default, and support an `.observe()` variant that feeds
|
|
30
|
+
* score/insights only — mirroring the `judge` fixture.
|
|
31
|
+
*/
|
|
32
|
+
import type { EvalResult } from './types.js';
|
|
33
|
+
import type { TracesAccessor } from '../matchers/traces.js';
|
|
34
|
+
import type { Verdict } from './judge.js';
|
|
35
|
+
/** Context handed to a custom evaluator. */
|
|
36
|
+
export interface EvaluatorContext {
|
|
37
|
+
/** The agent run under evaluation. */
|
|
38
|
+
result: EvalResult;
|
|
39
|
+
/** Optional free-form criteria string passed at the call site. */
|
|
40
|
+
criteria?: string;
|
|
41
|
+
/** Run-scoped OTel traces, when available (same as `result.traces`). */
|
|
42
|
+
traces?: TracesAccessor;
|
|
43
|
+
}
|
|
44
|
+
/** What a custom evaluator returns. */
|
|
45
|
+
export interface EvaluatorResult {
|
|
46
|
+
/** Whether the check passed. */
|
|
47
|
+
pass: boolean;
|
|
48
|
+
/** Optional normalised score on the [0, 1] interval. */
|
|
49
|
+
score?: number;
|
|
50
|
+
/** Human-readable explanation (shown in the per-matcher breakdown). */
|
|
51
|
+
reasoning?: string;
|
|
52
|
+
}
|
|
53
|
+
export type EvaluatorFn = (ctx: EvaluatorContext) => EvaluatorResult | Promise<EvaluatorResult>;
|
|
54
|
+
/**
|
|
55
|
+
* Register a custom evaluator under `id`.
|
|
56
|
+
*
|
|
57
|
+
* Registering the **same function** under an id again is a no-op (a watched
|
|
58
|
+
* file re-loading the identical module is fine). Registering a *different*
|
|
59
|
+
* function under an id that's already taken throws: the registry is
|
|
60
|
+
* process-global (shared like a helper library), so two `.eval.{js,ts}` files
|
|
61
|
+
* defining `defineEvaluator('len-check', …)` with different bodies would
|
|
62
|
+
* otherwise silently shadow each other based on load order. Fail loudly so the
|
|
63
|
+
* collision is visible at authoring time. Use distinct ids (or a shared helper
|
|
64
|
+
* module) when you need different implementations.
|
|
65
|
+
*/
|
|
66
|
+
export declare function defineEvaluator(id: string, fn: EvaluatorFn): void;
|
|
67
|
+
/** Look up a registered evaluator by id. @internal */
|
|
68
|
+
export declare function getEvaluator(id: string): EvaluatorFn | undefined;
|
|
69
|
+
/** Clear all registered evaluators (test isolation / per-load reset). @internal */
|
|
70
|
+
export declare function clearEvaluators(): void;
|
|
71
|
+
/**
|
|
72
|
+
* The `evaluate` fixture: run a registered custom evaluator against a
|
|
73
|
+
* result. Gate role by default; `.observe()` records score/insights only.
|
|
74
|
+
*/
|
|
75
|
+
export interface EvaluateFn {
|
|
76
|
+
(result: EvalResult, evaluatorId: string, criteria?: string): Promise<Verdict>;
|
|
77
|
+
observe(result: EvalResult, evaluatorId: string, criteria?: string): Promise<Verdict>;
|
|
78
|
+
}
|
|
79
|
+
export declare const evaluate: EvaluateFn;
|
|
80
|
+
//# sourceMappingURL=evaluators.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"evaluators.d.ts","sourceRoot":"","sources":["../../../testCases/evaluators.ts"],"names":[],"mappings":"AAKA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,KAAK,EAAa,OAAO,EAAE,MAAM,YAAY,CAAC;AAGrD,4CAA4C;AAC5C,MAAM,WAAW,gBAAgB;IAC/B,sCAAsC;IACtC,MAAM,EAAE,UAAU,CAAC;IACnB,kEAAkE;IAClE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,wEAAwE;IACxE,MAAM,CAAC,EAAE,cAAc,CAAC;CACzB;AAED,uCAAuC;AACvC,MAAM,WAAW,eAAe;IAC9B,gCAAgC;IAChC,IAAI,EAAE,OAAO,CAAC;IACd,w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