@od-oneapp/ai-platform 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +235 -0
- package/dist/agents-base.d.mts +12 -0
- package/dist/agents-base.d.mts.map +1 -0
- package/dist/agents-base.mjs +20 -0
- package/dist/agents-base.mjs.map +1 -0
- package/dist/agents-control-flow.d.mts +115 -0
- package/dist/agents-control-flow.d.mts.map +1 -0
- package/dist/agents-control-flow.mjs +514 -0
- package/dist/agents-control-flow.mjs.map +1 -0
- package/dist/agents-coordinator.d.mts +11 -0
- package/dist/agents-coordinator.d.mts.map +1 -0
- package/dist/agents-coordinator.mjs +12 -0
- package/dist/agents-coordinator.mjs.map +1 -0
- package/dist/agents-experimental.d.mts +153 -0
- package/dist/agents-experimental.d.mts.map +1 -0
- package/dist/agents-experimental.mjs +580 -0
- package/dist/agents-experimental.mjs.map +1 -0
- package/dist/agents-fallback.d.mts +10 -0
- package/dist/agents-fallback.d.mts.map +1 -0
- package/dist/agents-fallback.mjs +15 -0
- package/dist/agents-fallback.mjs.map +1 -0
- package/dist/agents-multi-swarm.d.mts +9 -0
- package/dist/agents-multi-swarm.d.mts.map +1 -0
- package/dist/agents-multi-swarm.mjs +44 -0
- package/dist/agents-multi-swarm.mjs.map +1 -0
- package/dist/agents-multi.d.mts +10 -0
- package/dist/agents-multi.d.mts.map +1 -0
- package/dist/agents-multi.mjs +44 -0
- package/dist/agents-multi.mjs.map +1 -0
- package/dist/agents-observability.d.mts +161 -0
- package/dist/agents-observability.d.mts.map +1 -0
- package/dist/agents-observability.mjs +550 -0
- package/dist/agents-observability.mjs.map +1 -0
- package/dist/agents-patterns.d.mts +9 -0
- package/dist/agents-patterns.d.mts.map +1 -0
- package/dist/agents-patterns.mjs +18 -0
- package/dist/agents-patterns.mjs.map +1 -0
- package/dist/agents-persistence.d.mts +234 -0
- package/dist/agents-persistence.d.mts.map +1 -0
- package/dist/agents-persistence.mjs +447 -0
- package/dist/agents-persistence.mjs.map +1 -0
- package/dist/agents-triage.d.mts +11 -0
- package/dist/agents-triage.d.mts.map +1 -0
- package/dist/agents-triage.mjs +13 -0
- package/dist/agents-triage.mjs.map +1 -0
- package/dist/agents-workflows.d.mts +9 -0
- package/dist/agents-workflows.d.mts.map +1 -0
- package/dist/agents-workflows.mjs +9 -0
- package/dist/agents-workflows.mjs.map +1 -0
- package/dist/agents.d.mts +30 -0
- package/dist/agents.d.mts.map +1 -0
- package/dist/agents.mjs +50 -0
- package/dist/agents.mjs.map +1 -0
- package/dist/aggregation-8KJF1uzp.d.mts +276 -0
- package/dist/aggregation-8KJF1uzp.d.mts.map +1 -0
- package/dist/aggregation-BDop87kL.mjs +1180 -0
- package/dist/aggregation-BDop87kL.mjs.map +1 -0
- package/dist/ai-runtime-CDzQztTt.mjs +85 -0
- package/dist/ai-runtime-CDzQztTt.mjs.map +1 -0
- package/dist/ai-runtime-DIwOEc6g.d.mts +56 -0
- package/dist/ai-runtime-DIwOEc6g.d.mts.map +1 -0
- package/dist/ai-sdk-error-integration-D0GDqrM0.d.mts +553 -0
- package/dist/ai-sdk-error-integration-D0GDqrM0.d.mts.map +1 -0
- package/dist/approval-queue-BcDDQ4oQ.mjs +104 -0
- package/dist/approval-queue-BcDDQ4oQ.mjs.map +1 -0
- package/dist/approval-queue-CiKiFT9z.d.mts +21 -0
- package/dist/approval-queue-CiKiFT9z.d.mts.map +1 -0
- package/dist/audio-BzvN7r10.d.mts +79 -0
- package/dist/audio-BzvN7r10.d.mts.map +1 -0
- package/dist/audio-vBG_62ME.mjs +226 -0
- package/dist/audio-vBG_62ME.mjs.map +1 -0
- package/dist/audit-logger-Bb2JIcIk.d.mts +12 -0
- package/dist/audit-logger-Bb2JIcIk.d.mts.map +1 -0
- package/dist/audit-logger-CHIP8bRO.mjs +596 -0
- package/dist/audit-logger-CHIP8bRO.mjs.map +1 -0
- package/dist/auto-resume-BpUNbPtp.d.mts +160 -0
- package/dist/auto-resume-BpUNbPtp.d.mts.map +1 -0
- package/dist/auto-resume-BuFRNvAX.mjs +638 -0
- package/dist/auto-resume-BuFRNvAX.mjs.map +1 -0
- package/dist/budget-guard-C83KCH9V.d.mts +52 -0
- package/dist/budget-guard-C83KCH9V.d.mts.map +1 -0
- package/dist/budget-guard-d_b5rq4u.mjs +158 -0
- package/dist/budget-guard-d_b5rq4u.mjs.map +1 -0
- package/dist/budget-guard-gyhJS00s.mjs +234 -0
- package/dist/budget-guard-gyhJS00s.mjs.map +1 -0
- package/dist/buffer-BC8mvXHE.d.mts +98 -0
- package/dist/buffer-BC8mvXHE.d.mts.map +1 -0
- package/dist/buffer-CefJGbRy.mjs +289 -0
- package/dist/buffer-CefJGbRy.mjs.map +1 -0
- package/dist/caching-adapters.d.mts +5 -0
- package/dist/caching-adapters.mjs +3 -0
- package/dist/caching-strategies.d.mts +52 -0
- package/dist/caching-strategies.d.mts.map +1 -0
- package/dist/caching-strategies.mjs +703 -0
- package/dist/caching-strategies.mjs.map +1 -0
- package/dist/caching.d.mts +14 -0
- package/dist/caching.d.mts.map +1 -0
- package/dist/caching.mjs +15 -0
- package/dist/caching.mjs.map +1 -0
- package/dist/catalog.d.mts +19 -0
- package/dist/catalog.d.mts.map +1 -0
- package/dist/catalog.mjs +1114 -0
- package/dist/catalog.mjs.map +1 -0
- package/dist/chunk-CkzbjWQW.mjs +20 -0
- package/dist/circuit-breaker-DoKWPORd.mjs +262 -0
- package/dist/circuit-breaker-DoKWPORd.mjs.map +1 -0
- package/dist/circuit-breaker-Mey3E7tW.d.mts +64 -0
- package/dist/circuit-breaker-Mey3E7tW.d.mts.map +1 -0
- package/dist/citation-generator-C-9RpbHq.mjs +103 -0
- package/dist/citation-generator-C-9RpbHq.mjs.map +1 -0
- package/dist/citation-generator-CDSymDs_.d.mts +18 -0
- package/dist/citation-generator-CDSymDs_.d.mts.map +1 -0
- package/dist/client-CpacYDIE.mjs +882 -0
- package/dist/client-CpacYDIE.mjs.map +1 -0
- package/dist/client.d.mts +103 -0
- package/dist/client.d.mts.map +1 -0
- package/dist/client.mjs +470 -0
- package/dist/client.mjs.map +1 -0
- package/dist/compliance-approval-queue-DQGLojAm.mjs +172 -0
- package/dist/compliance-approval-queue-DQGLojAm.mjs.map +1 -0
- package/dist/compliance-approval-queue-IrMxFfSJ.d.mts +99 -0
- package/dist/compliance-approval-queue-IrMxFfSJ.d.mts.map +1 -0
- package/dist/compliance-wrapper-CrOMHhHN.mjs +528 -0
- package/dist/compliance-wrapper-CrOMHhHN.mjs.map +1 -0
- package/dist/conditions-DmQ6Y1Wt.mjs +179 -0
- package/dist/conditions-DmQ6Y1Wt.mjs.map +1 -0
- package/dist/conditions-zDrKfrc3.d.mts +42 -0
- package/dist/conditions-zDrKfrc3.d.mts.map +1 -0
- package/dist/console-BGMxxPZN.mjs +181 -0
- package/dist/console-BGMxxPZN.mjs.map +1 -0
- package/dist/console-DqEqZd4A.d.mts +76 -0
- package/dist/console-DqEqZd4A.d.mts.map +1 -0
- package/dist/controller-BOy3-xbC.mjs +501 -0
- package/dist/controller-BOy3-xbC.mjs.map +1 -0
- package/dist/controller-Y0NGosbJ.d.mts +104 -0
- package/dist/controller-Y0NGosbJ.d.mts.map +1 -0
- package/dist/coordinator-agent-BglqZLwo.d.mts +54 -0
- package/dist/coordinator-agent-BglqZLwo.d.mts.map +1 -0
- package/dist/coordinator-agent-WFWBRL-G.mjs +236 -0
- package/dist/coordinator-agent-WFWBRL-G.mjs.map +1 -0
- package/dist/crypto-8ABhc3TD.mjs +40 -0
- package/dist/crypto-8ABhc3TD.mjs.map +1 -0
- package/dist/environment-CSoJb0SW.mjs +255 -0
- package/dist/environment-CSoJb0SW.mjs.map +1 -0
- package/dist/error-handling-DNVkm6RY.mjs +1334 -0
- package/dist/error-handling-DNVkm6RY.mjs.map +1 -0
- package/dist/errors-CQ8tF4dP.mjs +985 -0
- package/dist/errors-CQ8tF4dP.mjs.map +1 -0
- package/dist/errors-CfYdVeum.d.mts +212 -0
- package/dist/errors-CfYdVeum.d.mts.map +1 -0
- package/dist/errors-Dtn-UeRi.mjs +61 -0
- package/dist/errors-Dtn-UeRi.mjs.map +1 -0
- package/dist/evaluator-Cs84qkr8.mjs +91 -0
- package/dist/evaluator-Cs84qkr8.mjs.map +1 -0
- package/dist/evaluator-optimizer-De67_mJC.mjs +1086 -0
- package/dist/evaluator-optimizer-De67_mJC.mjs.map +1 -0
- package/dist/evaluator-optimizer-pattern-B5939s2Z.mjs +367 -0
- package/dist/evaluator-optimizer-pattern-B5939s2Z.mjs.map +1 -0
- package/dist/evaluator-optimizer-pattern-D1AJrzBD.d.mts +72 -0
- package/dist/evaluator-optimizer-pattern-D1AJrzBD.d.mts.map +1 -0
- package/dist/factory-DP6VSl8C.mjs +307 -0
- package/dist/factory-DP6VSl8C.mjs.map +1 -0
- package/dist/generative-ui-catalog.d.mts +8 -0
- package/dist/generative-ui-catalog.d.mts.map +1 -0
- package/dist/generative-ui-catalog.mjs +679 -0
- package/dist/generative-ui-catalog.mjs.map +1 -0
- package/dist/generative-ui-registry.d.mts +195 -0
- package/dist/generative-ui-registry.d.mts.map +1 -0
- package/dist/generative-ui-registry.mjs +250 -0
- package/dist/generative-ui-registry.mjs.map +1 -0
- package/dist/generative-ui-stream.d.mts +23 -0
- package/dist/generative-ui-stream.d.mts.map +1 -0
- package/dist/generative-ui-stream.mjs +219 -0
- package/dist/generative-ui-stream.mjs.map +1 -0
- package/dist/generative-ui-types.d.mts +123 -0
- package/dist/generative-ui-types.d.mts.map +1 -0
- package/dist/generative-ui-types.mjs +1 -0
- package/dist/generative-ui.d.mts +13 -0
- package/dist/generative-ui.d.mts.map +1 -0
- package/dist/generative-ui.mjs +21 -0
- package/dist/generative-ui.mjs.map +1 -0
- package/dist/governance-audit.d.mts +3 -0
- package/dist/governance-audit.mjs +3 -0
- package/dist/governance-compliance.d.mts +5 -0
- package/dist/governance-compliance.mjs +4 -0
- package/dist/governance-policies.d.mts +4 -0
- package/dist/governance-policies.mjs +4 -0
- package/dist/governance-tenancy.d.mts +3 -0
- package/dist/governance-tenancy.mjs +3 -0
- package/dist/governance.d.mts +88 -0
- package/dist/governance.d.mts.map +1 -0
- package/dist/governance.mjs +432 -0
- package/dist/governance.mjs.map +1 -0
- package/dist/grounding-attribution.d.mts +63 -0
- package/dist/grounding-attribution.d.mts.map +1 -0
- package/dist/grounding-attribution.mjs +259 -0
- package/dist/grounding-attribution.mjs.map +1 -0
- package/dist/grounding-citation.d.mts +2 -0
- package/dist/grounding-citation.mjs +3 -0
- package/dist/grounding-context.d.mts +9 -0
- package/dist/grounding-context.d.mts.map +1 -0
- package/dist/grounding-context.mjs +19 -0
- package/dist/grounding-context.mjs.map +1 -0
- package/dist/grounding-embed.d.mts +102 -0
- package/dist/grounding-embed.d.mts.map +1 -0
- package/dist/grounding-embed.mjs +417 -0
- package/dist/grounding-embed.mjs.map +1 -0
- package/dist/grounding-hallucination.d.mts +44 -0
- package/dist/grounding-hallucination.d.mts.map +1 -0
- package/dist/grounding-hallucination.mjs +115 -0
- package/dist/grounding-hallucination.mjs.map +1 -0
- package/dist/grounding-proof-map.d.mts +9 -0
- package/dist/grounding-proof-map.d.mts.map +1 -0
- package/dist/grounding-proof-map.mjs +26 -0
- package/dist/grounding-proof-map.mjs.map +1 -0
- package/dist/grounding-rag.d.mts +10 -0
- package/dist/grounding-rag.d.mts.map +1 -0
- package/dist/grounding-rag.mjs +27 -0
- package/dist/grounding-rag.mjs.map +1 -0
- package/dist/grounding-verification.d.mts +48 -0
- package/dist/grounding-verification.d.mts.map +1 -0
- package/dist/grounding-verification.mjs +224 -0
- package/dist/grounding-verification.mjs.map +1 -0
- package/dist/grounding.d.mts +24 -0
- package/dist/grounding.d.mts.map +1 -0
- package/dist/grounding.mjs +77 -0
- package/dist/grounding.mjs.map +1 -0
- package/dist/hitl-active-learning.d.mts +41 -0
- package/dist/hitl-active-learning.d.mts.map +1 -0
- package/dist/hitl-active-learning.mjs +178 -0
- package/dist/hitl-active-learning.mjs.map +1 -0
- package/dist/hitl-annotation.d.mts +74 -0
- package/dist/hitl-annotation.d.mts.map +1 -0
- package/dist/hitl-annotation.mjs +170 -0
- package/dist/hitl-annotation.mjs.map +1 -0
- package/dist/hitl-approval.d.mts +2 -0
- package/dist/hitl-approval.mjs +3 -0
- package/dist/hitl-feedback.d.mts +59 -0
- package/dist/hitl-feedback.d.mts.map +1 -0
- package/dist/hitl-feedback.mjs +137 -0
- package/dist/hitl-feedback.mjs.map +1 -0
- package/dist/hitl-review.d.mts +2 -0
- package/dist/hitl-review.mjs +3 -0
- package/dist/hitl.d.mts +14 -0
- package/dist/hitl.d.mts.map +1 -0
- package/dist/hitl.mjs +22 -0
- package/dist/hitl.mjs.map +1 -0
- package/dist/index-B17HT-VL.d.mts +285 -0
- package/dist/index-B17HT-VL.d.mts.map +1 -0
- package/dist/index-BDwgsK9B.d.mts +101 -0
- package/dist/index-BDwgsK9B.d.mts.map +1 -0
- package/dist/index-BGgMn_Ev.d.mts +2615 -0
- package/dist/index-BGgMn_Ev.d.mts.map +1 -0
- package/dist/index-DOqe5r9G.d.mts +318 -0
- package/dist/index-DOqe5r9G.d.mts.map +1 -0
- package/dist/index-DotINT7o.d.mts +1004 -0
- package/dist/index-DotINT7o.d.mts.map +1 -0
- package/dist/index-URlW7aD1.d.mts +67 -0
- package/dist/index-URlW7aD1.d.mts.map +1 -0
- package/dist/index.d.mts +64 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +46 -0
- package/dist/index.mjs.map +1 -0
- package/dist/integrations-blob-storage.d.mts +25 -0
- package/dist/integrations-blob-storage.d.mts.map +1 -0
- package/dist/integrations-blob-storage.mjs +3 -0
- package/dist/integrations-notifications.d.mts +2 -0
- package/dist/integrations-notifications.mjs +3 -0
- package/dist/integrations-rate-limit.d.mts +27 -0
- package/dist/integrations-rate-limit.d.mts.map +1 -0
- package/dist/integrations-rate-limit.mjs +30 -0
- package/dist/integrations-rate-limit.mjs.map +1 -0
- package/dist/integrations-redis.d.mts +3 -0
- package/dist/integrations-redis.mjs +3 -0
- package/dist/integrations-stream.d.mts +14 -0
- package/dist/integrations-stream.d.mts.map +1 -0
- package/dist/integrations-stream.mjs +3 -0
- package/dist/integrations.d.mts +7 -0
- package/dist/integrations.mjs +7 -0
- package/dist/log-adapter-BLegSZtz.d.mts +16 -0
- package/dist/log-adapter-BLegSZtz.d.mts.map +1 -0
- package/dist/log-adapter-PPe_2Pwv.mjs +28 -0
- package/dist/log-adapter-PPe_2Pwv.mjs.map +1 -0
- package/dist/loop-BOYEtr2g.mjs +520 -0
- package/dist/loop-BOYEtr2g.mjs.map +1 -0
- package/dist/loop-C-tBBOqi.d.mts +219 -0
- package/dist/loop-C-tBBOqi.d.mts.map +1 -0
- package/dist/middleware-5wQ9bANW.mjs +306 -0
- package/dist/middleware-5wQ9bANW.mjs.map +1 -0
- package/dist/middleware-C1apSrj0.mjs +613 -0
- package/dist/middleware-C1apSrj0.mjs.map +1 -0
- package/dist/middleware-C7k0uItW.d.mts +9 -0
- package/dist/middleware-C7k0uItW.d.mts.map +1 -0
- package/dist/middleware-CZQCTHfl.mjs +366 -0
- package/dist/middleware-CZQCTHfl.mjs.map +1 -0
- package/dist/models.d.mts +11 -0
- package/dist/models.d.mts.map +1 -0
- package/dist/models.mjs +32 -0
- package/dist/models.mjs.map +1 -0
- package/dist/observability-analytics.d.mts +107 -0
- package/dist/observability-analytics.d.mts.map +1 -0
- package/dist/observability-analytics.mjs +409 -0
- package/dist/observability-analytics.mjs.map +1 -0
- package/dist/observability-cost.d.mts +10 -0
- package/dist/observability-cost.d.mts.map +1 -0
- package/dist/observability-cost.mjs +15 -0
- package/dist/observability-cost.mjs.map +1 -0
- package/dist/observability-telemetry.d.mts +111 -0
- package/dist/observability-telemetry.d.mts.map +1 -0
- package/dist/observability-telemetry.mjs +343 -0
- package/dist/observability-telemetry.mjs.map +1 -0
- package/dist/observability-tracing.d.mts +10 -0
- package/dist/observability-tracing.d.mts.map +1 -0
- package/dist/observability-tracing.mjs +17 -0
- package/dist/observability-tracing.mjs.map +1 -0
- package/dist/observability.d.mts +15 -0
- package/dist/observability.d.mts.map +1 -0
- package/dist/observability.mjs +17 -0
- package/dist/observability.mjs.map +1 -0
- package/dist/optimizer-DhXXpci6.mjs +97 -0
- package/dist/optimizer-DhXXpci6.mjs.map +1 -0
- package/dist/output-multimodal.d.mts +9 -0
- package/dist/output-multimodal.d.mts.map +1 -0
- package/dist/output-multimodal.mjs +18 -0
- package/dist/output-multimodal.mjs.map +1 -0
- package/dist/output.d.mts +11 -0
- package/dist/output.d.mts.map +1 -0
- package/dist/output.mjs +40 -0
- package/dist/output.mjs.map +1 -0
- package/dist/pii-filter-3AxmYSiu.d.mts +23 -0
- package/dist/pii-filter-3AxmYSiu.d.mts.map +1 -0
- package/dist/pipelines.d.mts +448 -0
- package/dist/pipelines.d.mts.map +1 -0
- package/dist/pipelines.mjs +1534 -0
- package/dist/pipelines.mjs.map +1 -0
- package/dist/prompt-injection-DQXchzsV.d.mts +8 -0
- package/dist/prompt-injection-DQXchzsV.d.mts.map +1 -0
- package/dist/prompt-injection-RpoLPwSa.mjs +52 -0
- package/dist/prompt-injection-RpoLPwSa.mjs.map +1 -0
- package/dist/prompts.d.mts +192 -0
- package/dist/prompts.d.mts.map +1 -0
- package/dist/prompts.mjs +732 -0
- package/dist/prompts.mjs.map +1 -0
- package/dist/protocol-DfBiEsnl.d.mts +112 -0
- package/dist/protocol-DfBiEsnl.d.mts.map +1 -0
- package/dist/quota-manager-0iPMkQWN.d.mts +62 -0
- package/dist/quota-manager-0iPMkQWN.d.mts.map +1 -0
- package/dist/quota-manager-D_N7FuQ2.mjs +180 -0
- package/dist/quota-manager-D_N7FuQ2.mjs.map +1 -0
- package/dist/redaction-utils-DcQwsiNh.mjs +438 -0
- package/dist/redaction-utils-DcQwsiNh.mjs.map +1 -0
- package/dist/redis-CpsSrF8K.mjs +102 -0
- package/dist/redis-CpsSrF8K.mjs.map +1 -0
- package/dist/redis-CwguYFGh.d.mts +33 -0
- package/dist/redis-CwguYFGh.d.mts.map +1 -0
- package/dist/registry-CsD3iTIx.mjs +190 -0
- package/dist/registry-CsD3iTIx.mjs.map +1 -0
- package/dist/registry-DVPWzkXR.d.mts +36 -0
- package/dist/registry-DVPWzkXR.d.mts.map +1 -0
- package/dist/reranking-BpWYhYzl.d.mts +72 -0
- package/dist/reranking-BpWYhYzl.d.mts.map +1 -0
- package/dist/reranking-Ck8aKZW7.mjs +331 -0
- package/dist/reranking-Ck8aKZW7.mjs.map +1 -0
- package/dist/resumable-adapter-CO1HtsgJ.mjs +21 -0
- package/dist/resumable-adapter-CO1HtsgJ.mjs.map +1 -0
- package/dist/review-trigger-DmAsiQlM.d.mts +24 -0
- package/dist/review-trigger-DmAsiQlM.d.mts.map +1 -0
- package/dist/review-trigger-DwXfpww9.mjs +112 -0
- package/dist/review-trigger-DwXfpww9.mjs.map +1 -0
- package/dist/safe-context-BynhkTKR.d.mts +54 -0
- package/dist/safe-context-BynhkTKR.d.mts.map +1 -0
- package/dist/safe-context-C5A3Wv3b.mjs +143 -0
- package/dist/safe-context-C5A3Wv3b.mjs.map +1 -0
- package/dist/schema-Bu2noOZ4.mjs +27 -0
- package/dist/schema-Bu2noOZ4.mjs.map +1 -0
- package/dist/schema-CwFvuCnA.mjs +97 -0
- package/dist/schema-CwFvuCnA.mjs.map +1 -0
- package/dist/schema-Wz-1-ro9.d.mts +37 -0
- package/dist/schema-Wz-1-ro9.d.mts.map +1 -0
- package/dist/schemas-CxQtxIga.mjs +62 -0
- package/dist/schemas-CxQtxIga.mjs.map +1 -0
- package/dist/schemas-DBOhxgW7.d.mts +32 -0
- package/dist/schemas-DBOhxgW7.d.mts.map +1 -0
- package/dist/schemas-Dp_OCqBt.d.mts +63 -0
- package/dist/schemas-Dp_OCqBt.d.mts.map +1 -0
- package/dist/schemas-SwCsnT0z.mjs +83 -0
- package/dist/schemas-SwCsnT0z.mjs.map +1 -0
- package/dist/sdk-errors.d.mts +2 -0
- package/dist/sdk-errors.mjs +3 -0
- package/dist/sdk-experimental.d.mts +59 -0
- package/dist/sdk-experimental.d.mts.map +1 -0
- package/dist/sdk-experimental.mjs +193 -0
- package/dist/sdk-experimental.mjs.map +1 -0
- package/dist/sdk-stop-conditions.d.mts +3 -0
- package/dist/sdk-stop-conditions.mjs +3 -0
- package/dist/sdk.d.mts +15 -0
- package/dist/sdk.d.mts.map +1 -0
- package/dist/sdk.mjs +50 -0
- package/dist/sdk.mjs.map +1 -0
- package/dist/security-guardrails.d.mts +3 -0
- package/dist/security-guardrails.mjs +3 -0
- package/dist/security-injection.d.mts +2 -0
- package/dist/security-injection.mjs +3 -0
- package/dist/security.d.mts +12 -0
- package/dist/security.d.mts.map +1 -0
- package/dist/security.mjs +18 -0
- package/dist/security.mjs.map +1 -0
- package/dist/server.d.mts +420 -0
- package/dist/server.d.mts.map +1 -0
- package/dist/server.mjs +2225 -0
- package/dist/server.mjs.map +1 -0
- package/dist/shared.d.mts +2 -0
- package/dist/shared.mjs +3 -0
- package/dist/streaming-control.d.mts +2 -0
- package/dist/streaming-control.mjs +4 -0
- package/dist/streaming-core.d.mts +4 -0
- package/dist/streaming-core.mjs +3 -0
- package/dist/streaming-infra-resilience.d.mts +120 -0
- package/dist/streaming-infra-resilience.d.mts.map +1 -0
- package/dist/streaming-infra-resilience.mjs +358 -0
- package/dist/streaming-infra-resilience.mjs.map +1 -0
- package/dist/streaming-infra-transport.d.mts +57 -0
- package/dist/streaming-infra-transport.d.mts.map +1 -0
- package/dist/streaming-infra-transport.mjs +488 -0
- package/dist/streaming-infra-transport.mjs.map +1 -0
- package/dist/streaming-infra.d.mts +5 -0
- package/dist/streaming-infra.mjs +5 -0
- package/dist/streaming.d.mts +17 -0
- package/dist/streaming.d.mts.map +1 -0
- package/dist/streaming.mjs +71 -0
- package/dist/streaming.mjs.map +1 -0
- package/dist/telemetry-2eKMojIb.mjs +1046 -0
- package/dist/telemetry-2eKMojIb.mjs.map +1 -0
- package/dist/telemetry-C2t03dwD.d.mts +59 -0
- package/dist/telemetry-C2t03dwD.d.mts.map +1 -0
- package/dist/tool-Btbththq.d.mts +253 -0
- package/dist/tool-Btbththq.d.mts.map +1 -0
- package/dist/tool-JSf8JXZ8.mjs +1150 -0
- package/dist/tool-JSf8JXZ8.mjs.map +1 -0
- package/dist/tool-safety-CZO8a4D4.d.mts +60 -0
- package/dist/tool-safety-CZO8a4D4.d.mts.map +1 -0
- package/dist/tool-safety-DXtYDXod.mjs +319 -0
- package/dist/tool-safety-DXtYDXod.mjs.map +1 -0
- package/dist/tools-BuS2Uv0q.mjs +1708 -0
- package/dist/tools-BuS2Uv0q.mjs.map +1 -0
- package/dist/tools-approval.d.mts +99 -0
- package/dist/tools-approval.d.mts.map +1 -0
- package/dist/tools-approval.mjs +395 -0
- package/dist/tools-approval.mjs.map +1 -0
- package/dist/tools-compliance.d.mts +67 -0
- package/dist/tools-compliance.d.mts.map +1 -0
- package/dist/tools-compliance.mjs +330 -0
- package/dist/tools-compliance.mjs.map +1 -0
- package/dist/tools-computer.d.mts +25 -0
- package/dist/tools-computer.d.mts.map +1 -0
- package/dist/tools-computer.mjs +64 -0
- package/dist/tools-computer.mjs.map +1 -0
- package/dist/tools-core.d.mts +3 -0
- package/dist/tools-core.mjs +3 -0
- package/dist/tools-mcp.d.mts +3 -0
- package/dist/tools-mcp.mjs +5 -0
- package/dist/tools-superpowers.d.mts +2 -0
- package/dist/tools-superpowers.mjs +3 -0
- package/dist/tools.d.mts +401 -0
- package/dist/tools.d.mts.map +1 -0
- package/dist/tools.mjs +1921 -0
- package/dist/tools.mjs.map +1 -0
- package/dist/transport-selector-D-Ib05X1.mjs +1936 -0
- package/dist/transport-selector-D-Ib05X1.mjs.map +1 -0
- package/dist/triage-agent-BEsXg5sw.d.mts +63 -0
- package/dist/triage-agent-BEsXg5sw.d.mts.map +1 -0
- package/dist/triage-agent-CBsfX-HW.mjs +167 -0
- package/dist/triage-agent-CBsfX-HW.mjs.map +1 -0
- package/dist/types-BPnq3GQo.d.mts +23 -0
- package/dist/types-BPnq3GQo.d.mts.map +1 -0
- package/dist/types-BjWgimpY.d.mts +16 -0
- package/dist/types-BjWgimpY.d.mts.map +1 -0
- package/dist/types-BxD-5btB.d.mts +41 -0
- package/dist/types-BxD-5btB.d.mts.map +1 -0
- package/dist/types-By-r93bE.d.mts +36 -0
- package/dist/types-By-r93bE.d.mts.map +1 -0
- package/dist/types-CLBWFRZN.d.mts +69 -0
- package/dist/types-CLBWFRZN.d.mts.map +1 -0
- package/dist/types-CQ0HFd0u.d.mts +62 -0
- package/dist/types-CQ0HFd0u.d.mts.map +1 -0
- package/dist/types-D3zJb59_.d.mts +47 -0
- package/dist/types-D3zJb59_.d.mts.map +1 -0
- package/dist/types-DJnugQX0.d.mts +80 -0
- package/dist/types-DJnugQX0.d.mts.map +1 -0
- package/dist/types-DbUfMCnT.d.mts +70 -0
- package/dist/types-DbUfMCnT.d.mts.map +1 -0
- package/dist/upstash-adapter-D96Caq2O.mjs +22 -0
- package/dist/upstash-adapter-D96Caq2O.mjs.map +1 -0
- package/dist/upstash-adapter-DD4433dx.d.mts +8 -0
- package/dist/upstash-adapter-DD4433dx.d.mts.map +1 -0
- package/dist/utils-BlYhcD6M.mjs +319 -0
- package/dist/utils-BlYhcD6M.mjs.map +1 -0
- package/dist/utils-DpJGOb3y.d.mts +120 -0
- package/dist/utils-DpJGOb3y.d.mts.map +1 -0
- package/dist/vercel-blob-adapter-CkOXLT2D.mjs +25 -0
- package/dist/vercel-blob-adapter-CkOXLT2D.mjs.map +1 -0
- package/dist/xai-CbV_dCnP.mjs +1600 -0
- package/dist/xai-CbV_dCnP.mjs.map +1 -0
- package/package.json +479 -0
- package/src/agents/base/factory.ts +382 -0
- package/src/agents/base/index.ts +8 -0
- package/src/agents/base/schemas.ts +117 -0
- package/src/agents/base/types.ts +192 -0
- package/src/agents/control-flow/index.ts +683 -0
- package/src/agents/coordinator/coordinator-agent.ts +381 -0
- package/src/agents/coordinator/index.ts +6 -0
- package/src/agents/default-agent.ts +211 -0
- package/src/agents/evaluator-optimizer/README.md +612 -0
- package/src/agents/evaluator-optimizer/evaluator-optimizer.example.ts +437 -0
- package/src/agents/evaluator-optimizer/evaluator.ts +282 -0
- package/src/agents/evaluator-optimizer/index.test.ts +416 -0
- package/src/agents/evaluator-optimizer/index.ts +519 -0
- package/src/agents/evaluator-optimizer/optimizer.ts +322 -0
- package/src/agents/evaluator-optimizer/schema.ts +302 -0
- package/src/agents/evaluator-optimizer/utils.ts +42 -0
- package/src/agents/experimental/index.ts +1095 -0
- package/src/agents/experimental/types.ts +212 -0
- package/src/agents/fallback/index.ts +18 -0
- package/src/agents/fallback/recovery/circuit-breaker.ts +166 -0
- package/src/agents/fallback/strategies/model-fallback.ts +192 -0
- package/src/agents/fallback/types.ts +87 -0
- package/src/agents/governance-agent.ts +446 -0
- package/src/agents/index.ts +79 -0
- package/src/agents/multi/coordination/index.ts +6 -0
- package/src/agents/multi/coordination/message-bus.ts +144 -0
- package/src/agents/multi/index.ts +6 -0
- package/src/agents/multi/state/index.ts +162 -0
- package/src/agents/multi/supervisor/index.ts +7 -0
- package/src/agents/multi/supervisor/supervisor.ts +254 -0
- package/src/agents/multi/swarm/aggregation.ts +466 -0
- package/src/agents/multi/swarm/communication.ts +388 -0
- package/src/agents/multi/swarm/coordination.ts +380 -0
- package/src/agents/multi/swarm/index.ts +73 -0
- package/src/agents/multi/swarm/swarm-executor.ts +479 -0
- package/src/agents/multi/types.ts +181 -0
- package/src/agents/observability/index.ts +914 -0
- package/src/agents/orchestrator.ts +218 -0
- package/src/agents/patterns/README.md +512 -0
- package/src/agents/patterns/evaluator-optimizer-pattern.example.ts +455 -0
- package/src/agents/patterns/evaluator-optimizer-pattern.ts +653 -0
- package/src/agents/patterns/index.ts +26 -0
- package/src/agents/persistence/index.ts +726 -0
- package/src/agents/tools/index.ts +291 -0
- package/src/agents/tools/mcp.ts +188 -0
- package/src/agents/triage/index.ts +6 -0
- package/src/agents/triage/triage-agent.ts +280 -0
- package/src/agents/workflows/index.ts +6 -0
- package/src/agents/workflows/interfaces.ts +36 -0
- package/src/agents/workflows/schema.ts +20 -0
- package/src/caching/adapters/index.ts +7 -0
- package/src/caching/adapters/memory.ts +77 -0
- package/src/caching/adapters/redis.ts +60 -0
- package/src/caching/index.ts +17 -0
- package/src/caching/middleware.ts +452 -0
- package/src/caching/strategies/index.ts +1008 -0
- package/src/caching/types.ts +47 -0
- package/src/catalog.ts +921 -0
- package/src/client/chat-usage.ts +53 -0
- package/src/client/hooks.ts +343 -0
- package/src/client/index.ts +36 -0
- package/src/client/message-utils.ts +29 -0
- package/src/client/use-generative-ui.ts +174 -0
- package/src/client/utils.ts +66 -0
- package/src/generative-ui/catalog.ts +653 -0
- package/src/generative-ui/index.ts +82 -0
- package/src/generative-ui/registry.ts +273 -0
- package/src/generative-ui/stream.ts +324 -0
- package/src/generative-ui/types.ts +376 -0
- package/src/governance/audit/audit-logger.ts +239 -0
- package/src/governance/audit/audit-schema.ts +82 -0
- package/src/governance/audit/index.ts +6 -0
- package/src/governance/compliance/abac/policy-engine.ts +175 -0
- package/src/governance/compliance/abac/types.ts +40 -0
- package/src/governance/compliance/approval/compliance-approval-queue.ts +217 -0
- package/src/governance/compliance/index.ts +16 -0
- package/src/governance/compliance/schemas.ts +68 -0
- package/src/governance/compliance/types.ts +143 -0
- package/src/governance/compliance/validators/phi-detector.ts +145 -0
- package/src/governance/compliance/validators/redaction-utils.ts +176 -0
- package/src/governance/compliance/validators/safe-harbor.ts +135 -0
- package/src/governance/entitlements/index.ts +585 -0
- package/src/governance/entitlements/middleware.ts +651 -0
- package/src/governance/entitlements/rate-limiter.ts +711 -0
- package/src/governance/index.ts +32 -0
- package/src/governance/policies/guardrails.ts +1121 -0
- package/src/governance/policies/index.ts +42 -0
- package/src/governance/policies/loop-controls.ts +136 -0
- package/src/governance/policies/telemetry.ts +63 -0
- package/src/governance/tenancy/index.ts +30 -0
- package/src/governance/tenancy/isolation/context.ts +92 -0
- package/src/governance/tenancy/isolation/index.ts +13 -0
- package/src/governance/tenancy/quotas/index.ts +11 -0
- package/src/governance/tenancy/quotas/quota-manager.ts +180 -0
- package/src/governance/tenancy/types.ts +66 -0
- package/src/governance/types.ts +16 -0
- package/src/governance/versioning/index.ts +573 -0
- package/src/grounding/attribution/index.ts +424 -0
- package/src/grounding/citation/citation-generator.ts +174 -0
- package/src/grounding/citation/index.ts +12 -0
- package/src/grounding/context/index.ts +32 -0
- package/src/grounding/context/safe-context.ts +116 -0
- package/src/grounding/context/types.ts +62 -0
- package/src/grounding/context-engineering/error-handling.ts +359 -0
- package/src/grounding/context-engineering/index.ts +23 -0
- package/src/grounding/context-engineering/memory.ts +559 -0
- package/src/grounding/context-engineering/tool-masking.ts +338 -0
- package/src/grounding/embed/index.ts +704 -0
- package/src/grounding/embed/reranking.ts +604 -0
- package/src/grounding/hallucination/index.ts +223 -0
- package/src/grounding/index.ts +82 -0
- package/src/grounding/proof-map/applyPatch.ts +172 -0
- package/src/grounding/proof-map/index.ts +41 -0
- package/src/grounding/proof-map/loop.ts +275 -0
- package/src/grounding/proof-map/schema.ts +217 -0
- package/src/grounding/rag/__tests__/pipeline.test.ts +274 -0
- package/src/grounding/rag/__tests__/tool.test.ts +202 -0
- package/src/grounding/rag/__tests__/trace.test.ts +229 -0
- package/src/grounding/rag/circuit-breaker.ts +152 -0
- package/src/grounding/rag/index.ts +64 -0
- package/src/grounding/rag/pipeline.ts +602 -0
- package/src/grounding/rag/tool.ts +281 -0
- package/src/grounding/rag/trace.ts +503 -0
- package/src/grounding/rag/types.ts +284 -0
- package/src/grounding/retrieval/in-memory-store.ts +107 -0
- package/src/grounding/sources/index.ts +943 -0
- package/src/grounding/tests/applyPatch.test.ts +194 -0
- package/src/grounding/tests/loop.test.ts +141 -0
- package/src/grounding/tests/schema.test.ts +160 -0
- package/src/grounding/types.ts +100 -0
- package/src/grounding/verification/index.ts +419 -0
- package/src/hitl/active-learning/index.ts +332 -0
- package/src/hitl/annotation/index.ts +362 -0
- package/src/hitl/approval/approval-queue.ts +132 -0
- package/src/hitl/approval/index.ts +5 -0
- package/src/hitl/feedback/index.ts +284 -0
- package/src/hitl/index.ts +69 -0
- package/src/hitl/review/index.ts +6 -0
- package/src/hitl/review/review-trigger.ts +162 -0
- package/src/hitl/types.ts +126 -0
- package/src/index.ts +125 -0
- package/src/integrations/blob-storage/index.ts +7 -0
- package/src/integrations/blob-storage/types.ts +28 -0
- package/src/integrations/blob-storage/vercel-blob-adapter.ts +35 -0
- package/src/integrations/index.ts +15 -0
- package/src/integrations/notifications/index.ts +7 -0
- package/src/integrations/notifications/log-adapter.ts +30 -0
- package/src/integrations/notifications/types.ts +27 -0
- package/src/integrations/rate-limit/index.ts +7 -0
- package/src/integrations/rate-limit/types.ts +26 -0
- package/src/integrations/rate-limit/upstash-adapter.ts +45 -0
- package/src/integrations/redis/index.ts +7 -0
- package/src/integrations/redis/types.ts +67 -0
- package/src/integrations/redis/upstash-adapter.ts +18 -0
- package/src/integrations/stream/index.ts +7 -0
- package/src/integrations/stream/resumable-adapter.ts +20 -0
- package/src/integrations/stream/types.ts +21 -0
- package/src/internal/__tests__/hallucination.test.ts +162 -0
- package/src/internal/__tests__/models.test.ts +104 -0
- package/src/internal/__tests__/sdk-errors.test.ts +201 -0
- package/src/internal/__tests__/stop-conditions.test.ts +210 -0
- package/src/internal/shared/ai-types.ts +942 -0
- package/src/internal/testing/evaluators.ts +575 -0
- package/src/internal/testing/index.ts +960 -0
- package/src/internal/ui/data-parts.ts +511 -0
- package/src/internal/ui/type-guards.ts +344 -0
- package/src/internal/ui-factories/__tests__/ui-factories.test.ts +548 -0
- package/src/internal/ui-factories/artifact-factory.ts +667 -0
- package/src/internal/ui-factories/index.ts +82 -0
- package/src/internal/ui-factories/shimmer-manager.ts +220 -0
- package/src/internal/ui-factories/status-helpers.ts +149 -0
- package/src/internal/ui-factories/tool-renderer.ts +167 -0
- package/src/internal/ui-factories/types.ts +235 -0
- package/src/models/capabilities.ts +88 -0
- package/src/models/index.ts +16 -0
- package/src/models/provider-factory.ts +229 -0
- package/src/models/providers/anthropic.ts +539 -0
- package/src/models/providers/google.ts +354 -0
- package/src/models/providers/index.ts +21 -0
- package/src/models/providers/openai.ts +346 -0
- package/src/models/providers/perplexity.ts +276 -0
- package/src/models/providers/shared.ts +90 -0
- package/src/models/providers/xai.ts +269 -0
- package/src/models/registry.ts +208 -0
- package/src/models/routing/index.ts +45 -0
- package/src/models/routing/intent-router.ts +143 -0
- package/src/models/routing/model-router.ts +300 -0
- package/src/models/routing/types.ts +106 -0
- package/src/models/types.ts +23 -0
- package/src/observability/analytics/index.ts +593 -0
- package/src/observability/cost/index.ts +16 -0
- package/src/observability/cost/tracking/budget-guard.ts +110 -0
- package/src/observability/cost/tracking/usage-tracker.ts +120 -0
- package/src/observability/cost/types.ts +85 -0
- package/src/observability/index.ts +17 -0
- package/src/observability/telemetry/index.ts +508 -0
- package/src/observability/tracing/index.ts +30 -0
- package/src/observability/tracing/otel/ai-instrumentation.ts +193 -0
- package/src/observability/tracing/otel/exporters/console.ts +58 -0
- package/src/observability/tracing/otel/exporters/index.ts +6 -0
- package/src/observability/tracing/provenance.ts +769 -0
- package/src/observability/tracing/types.ts +92 -0
- package/src/output/__tests__/output.test.ts +737 -0
- package/src/output/element-stream.ts +678 -0
- package/src/output/errors.ts +108 -0
- package/src/output/factories.ts +392 -0
- package/src/output/index.ts +98 -0
- package/src/output/multimodal/EXPORTS.md +306 -0
- package/src/output/multimodal/IMPLEMENTATION_SUMMARY.md +421 -0
- package/src/output/multimodal/README.md +349 -0
- package/src/output/multimodal/SETUP_GUIDE.md +472 -0
- package/src/output/multimodal/audio.ts +650 -0
- package/src/output/multimodal/image.ts +22 -0
- package/src/output/multimodal/index.ts +32 -0
- package/src/output/multimodal/providers.example.ts +375 -0
- package/src/output/validator.ts +495 -0
- package/src/pipelines/adapters/trace-storage-blob.ts +458 -0
- package/src/pipelines/adapters/trace-storage-memory.ts +319 -0
- package/src/pipelines/defaults.ts +109 -0
- package/src/pipelines/index.ts +24 -0
- package/src/pipelines/message-transforms.ts +107 -0
- package/src/pipelines/multi-step-wrapper.ts +433 -0
- package/src/pipelines/pipeline-presets.ts +339 -0
- package/src/pipelines/step-executor.ts +257 -0
- package/src/pipelines/storage-factory.ts +85 -0
- package/src/pipelines/trace-storage-interface.ts +216 -0
- package/src/pipelines/types.ts +255 -0
- package/src/pipelines/validation.ts +323 -0
- package/src/prompts/index.ts +271 -0
- package/src/prompts/model-variants.ts +410 -0
- package/src/prompts/templates.ts +327 -0
- package/src/sdk/errors/base.ts +296 -0
- package/src/sdk/errors/index.ts +31 -0
- package/src/sdk/errors/utils.ts +148 -0
- package/src/sdk/experimental/index.ts +286 -0
- package/src/sdk/index.ts +25 -0
- package/src/sdk/middleware/ai-middleware.ts +95 -0
- package/src/sdk/middleware/cache.ts +154 -0
- package/src/sdk/middleware/circuit-breaker.ts +388 -0
- package/src/sdk/middleware/compose.ts +81 -0
- package/src/sdk/middleware/deduplication.ts +307 -0
- package/src/sdk/middleware/index.ts +660 -0
- package/src/sdk/middleware/model-middleware.ts +200 -0
- package/src/sdk/stop-conditions/conditions.ts +209 -0
- package/src/sdk/stop-conditions/index.ts +35 -0
- package/src/sdk/stop-conditions/types.ts +59 -0
- package/src/security/guardrails/index.ts +6 -0
- package/src/security/guardrails/middleware.ts +465 -0
- package/src/security/guardrails/pii-filter.ts +396 -0
- package/src/security/index.ts +33 -0
- package/src/security/injection/index.ts +5 -0
- package/src/security/injection/prompt-injection.ts +64 -0
- package/src/security/types.ts +85 -0
- package/src/server/cache/crypto.ts +47 -0
- package/src/server/cache/performance.ts +79 -0
- package/src/server/error-handler.ts +93 -0
- package/src/server/errors.ts +73 -0
- package/src/server/helpers.ts +944 -0
- package/src/server/http.ts +156 -0
- package/src/server/index.ts +12 -0
- package/src/server/messages/__tests__/messages.test.ts +720 -0
- package/src/server/messages/converter.ts +245 -0
- package/src/server/messages/data-parts.ts +338 -0
- package/src/server/messages/extraction.ts +328 -0
- package/src/server/messages/index.ts +126 -0
- package/src/server/messages/types.ts +355 -0
- package/src/server/messages/window.ts +450 -0
- package/src/server/rate-limit/env.ts +8 -0
- package/src/server/rate-limit/rate-limit.ts +165 -0
- package/src/server/routes/HEALTH_CHECK.md +502 -0
- package/src/server/routes/IMPLEMENTATION_SUMMARY.md +432 -0
- package/src/server/routes/QUICK_START.md +327 -0
- package/src/server/routes/README.md +357 -0
- package/src/server/routes/__tests__/routes.test.ts +628 -0
- package/src/server/routes/agent-route.ts +224 -0
- package/src/server/routes/agent-routes.ts +191 -0
- package/src/server/routes/embed-config.ts +181 -0
- package/src/server/routes/health-check.example.ts +507 -0
- package/src/server/routes/health-check.test.ts +533 -0
- package/src/server/routes/health-check.ts +639 -0
- package/src/server/routes/health-check.types.ts +217 -0
- package/src/server/routes/index.ts +32 -0
- package/src/server/routes/types.ts +274 -0
- package/src/shared/__tests__/schemas.test.ts +317 -0
- package/src/shared/ai-runtime.ts +139 -0
- package/src/shared/ai-types.ts +133 -0
- package/src/shared/index.ts +30 -0
- package/src/shared/sdk-runtime.ts +198 -0
- package/src/shared/sdk-types.ts +301 -0
- package/src/streaming/control/__tests__/streaming-control.test.ts +708 -0
- package/src/streaming/control/budget-guard.ts +264 -0
- package/src/streaming/control/controller.ts +255 -0
- package/src/streaming/control/index.ts +105 -0
- package/src/streaming/control/smoothing.ts +201 -0
- package/src/streaming/control/step-limit.ts +215 -0
- package/src/streaming/control/types.ts +234 -0
- package/src/streaming/core/auto-resume.ts +276 -0
- package/src/streaming/core/index.ts +85 -0
- package/src/streaming/core/multi-step.ts +471 -0
- package/src/streaming/core/protocol.ts +194 -0
- package/src/streaming/core/types.ts +182 -0
- package/src/streaming/index.ts +97 -0
- package/src/streaming/infra/backpressure/buffer.ts +210 -0
- package/src/streaming/infra/backpressure/index.ts +6 -0
- package/src/streaming/infra/index.ts +75 -0
- package/src/streaming/infra/multiplexing/index.ts +311 -0
- package/src/streaming/infra/resilience/index.ts +684 -0
- package/src/streaming/infra/transform/index.ts +15 -0
- package/src/streaming/infra/transform/stream-transforms.ts +166 -0
- package/src/streaming/infra/transport/index.ts +774 -0
- package/src/streaming/infra/types.ts +118 -0
- package/src/streaming/infra-extra/types.ts +118 -0
- package/src/tools/advanced/caching.ts +299 -0
- package/src/tools/advanced/generator.ts +267 -0
- package/src/tools/advanced/hitl.ts +251 -0
- package/src/tools/advanced/index.ts +9 -0
- package/src/tools/advanced/llm-tool.ts +208 -0
- package/src/tools/approval/FILES.md +449 -0
- package/src/tools/approval/IMPLEMENTATION_SUMMARY.md +567 -0
- package/src/tools/approval/QUICK_START.md +362 -0
- package/src/tools/approval/README.md +514 -0
- package/src/tools/approval/advanced-approval-queue.ts +7 -0
- package/src/tools/approval/approval.example.ts +571 -0
- package/src/tools/approval/in-memory-queue.ts +405 -0
- package/src/tools/approval/index.ts +737 -0
- package/src/tools/approval/middleware.ts +590 -0
- package/src/tools/approval/queue-factory.ts +162 -0
- package/src/tools/approval/redis-queue.ts +327 -0
- package/src/tools/approval/testing.ts +493 -0
- package/src/tools/approval/types.ts +221 -0
- package/src/tools/approval/with-approval.ts +366 -0
- package/src/tools/artifacts/artifact-tools.ts +273 -0
- package/src/tools/artifacts/index.ts +6 -0
- package/src/tools/compliance/compliance-wrapper.ts +789 -0
- package/src/tools/compliance/create-compliant-stream.ts +226 -0
- package/src/tools/compliance/index.ts +8 -0
- package/src/tools/compliance/phi-redaction.ts +406 -0
- package/src/tools/compliance/tool-wrapper.ts +306 -0
- package/src/tools/computer/index.ts +99 -0
- package/src/tools/computer/types.ts +41 -0
- package/src/tools/core/abort.ts +202 -0
- package/src/tools/core/factory.ts +197 -0
- package/src/tools/core/index.ts +8 -0
- package/src/tools/core/tool-safety.ts +112 -0
- package/src/tools/generic/index.ts +9 -0
- package/src/tools/generic/json-schema-tool.ts +301 -0
- package/src/tools/generic/tiptap-context.ts +619 -0
- package/src/tools/generic/web-search-tool.ts +82 -0
- package/src/tools/generic/web-search.ts +142 -0
- package/src/tools/index.ts +36 -0
- package/src/tools/mcp/ai-sdk-error-integration.ts +401 -0
- package/src/tools/mcp/client.ts +988 -0
- package/src/tools/mcp/connection-manager.ts +380 -0
- package/src/tools/mcp/connection-pool.ts +408 -0
- package/src/tools/mcp/edge-runtime.ts +318 -0
- package/src/tools/mcp/environment.ts +310 -0
- package/src/tools/mcp/index.ts +20 -0
- package/src/tools/mcp/next-pattern.ts +401 -0
- package/src/tools/mcp/stream-lifecycle-integration.ts +617 -0
- package/src/tools/mcp/tool-cache.ts +359 -0
- package/src/tools/mcp/transport-selector.ts +492 -0
- package/src/tools/mcp/transports.ts +99 -0
- package/src/tools/simple-factory.ts +55 -0
- package/src/tools/superpowers/index.ts +122 -0
- package/src/tools/superpowers/prompts/index.ts +533 -0
- package/src/tools/superpowers/schemas/index.ts +701 -0
- package/src/tools/superpowers/tools/index.ts +721 -0
- package/src/tools/validation-wrapper.ts +97 -0
|
@@ -0,0 +1,960 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Testing & Evaluation Module
|
|
3
|
+
*
|
|
4
|
+
* AI testing and evaluation patterns:
|
|
5
|
+
* - Mock providers and tools
|
|
6
|
+
* - LLM-as-judge evaluation
|
|
7
|
+
* - Automated test harness
|
|
8
|
+
* - Regression testing
|
|
9
|
+
*
|
|
10
|
+
* @module testing
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import { type z } from 'zod/v4';
|
|
14
|
+
|
|
15
|
+
// -----------------------------------------------------------------------------
|
|
16
|
+
// Types
|
|
17
|
+
// -----------------------------------------------------------------------------
|
|
18
|
+
|
|
19
|
+
/** Mock response configuration */
|
|
20
|
+
export interface MockResponse {
|
|
21
|
+
readonly text?: string;
|
|
22
|
+
readonly object?: unknown;
|
|
23
|
+
readonly toolCalls?: MockToolCall[];
|
|
24
|
+
readonly error?: Error;
|
|
25
|
+
readonly delay?: number;
|
|
26
|
+
readonly usage?: { promptTokens: number; completionTokens: number };
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/** Mock tool call */
|
|
30
|
+
export interface MockToolCall {
|
|
31
|
+
readonly toolName: string;
|
|
32
|
+
readonly args: Record<string, unknown>;
|
|
33
|
+
readonly result?: unknown;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/** Evaluation result */
|
|
37
|
+
export interface EvalResult {
|
|
38
|
+
readonly id: string;
|
|
39
|
+
readonly input: string;
|
|
40
|
+
readonly output: string;
|
|
41
|
+
readonly expected?: string;
|
|
42
|
+
readonly scores: Record<string, number>;
|
|
43
|
+
readonly passed: boolean;
|
|
44
|
+
readonly feedback?: string;
|
|
45
|
+
readonly metadata?: Record<string, unknown>;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/** Evaluation criteria */
|
|
49
|
+
export interface EvalCriteria {
|
|
50
|
+
readonly name: string;
|
|
51
|
+
readonly description: string;
|
|
52
|
+
readonly weight?: number;
|
|
53
|
+
evaluate: (input: string, output: string, expected?: string) => Promise<EvalScore>;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/** Evaluation score */
|
|
57
|
+
export interface EvalScore {
|
|
58
|
+
readonly score: number; // 0-1
|
|
59
|
+
readonly reason?: string;
|
|
60
|
+
readonly details?: Record<string, unknown>;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/** Test case */
|
|
64
|
+
export interface TestCase {
|
|
65
|
+
readonly id: string;
|
|
66
|
+
readonly name: string;
|
|
67
|
+
readonly input: string;
|
|
68
|
+
readonly expected?: string;
|
|
69
|
+
readonly metadata?: Record<string, unknown>;
|
|
70
|
+
validate?: (output: string) => boolean;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/** Test suite */
|
|
74
|
+
export interface TestSuite {
|
|
75
|
+
readonly name: string;
|
|
76
|
+
readonly description?: string;
|
|
77
|
+
readonly cases: TestCase[];
|
|
78
|
+
readonly criteria: EvalCriteria[];
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/** Test run result */
|
|
82
|
+
export interface TestRunResult {
|
|
83
|
+
readonly suiteId: string;
|
|
84
|
+
readonly timestamp: number;
|
|
85
|
+
readonly duration: number;
|
|
86
|
+
readonly results: EvalResult[];
|
|
87
|
+
readonly summary: TestSummary;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/** Test summary */
|
|
91
|
+
export interface TestSummary {
|
|
92
|
+
readonly total: number;
|
|
93
|
+
readonly passed: number;
|
|
94
|
+
readonly failed: number;
|
|
95
|
+
readonly avgScores: Record<string, number>;
|
|
96
|
+
readonly passRate: number;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
// -----------------------------------------------------------------------------
|
|
100
|
+
// Mock Provider
|
|
101
|
+
// -----------------------------------------------------------------------------
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Creates a mock AI provider for testing.
|
|
105
|
+
*
|
|
106
|
+
* @example
|
|
107
|
+
* ```typescript
|
|
108
|
+
* const mock = createMockProvider({
|
|
109
|
+
* responses: [
|
|
110
|
+
* { text: 'Hello, how can I help?' },
|
|
111
|
+
* { text: 'The answer is 42.' }
|
|
112
|
+
* ]
|
|
113
|
+
* });
|
|
114
|
+
*
|
|
115
|
+
* // Use in tests
|
|
116
|
+
* const result = await generateText({ model: mock, prompt: 'Hi' });
|
|
117
|
+
* expect(result.text).toBe('Hello, how can I help?');
|
|
118
|
+
* ```
|
|
119
|
+
*/
|
|
120
|
+
export function createMockProvider(options?: {
|
|
121
|
+
responses?: MockResponse[];
|
|
122
|
+
defaultResponse?: MockResponse;
|
|
123
|
+
onGenerate?: (prompt: string) => MockResponse | Promise<MockResponse>;
|
|
124
|
+
}): MockProvider {
|
|
125
|
+
const { responses = [], defaultResponse, onGenerate } = options ?? {};
|
|
126
|
+
let callIndex = 0;
|
|
127
|
+
const callHistory: { prompt: string; response: MockResponse }[] = [];
|
|
128
|
+
|
|
129
|
+
async function generate(prompt: string): Promise<MockResponse> {
|
|
130
|
+
let response: MockResponse;
|
|
131
|
+
|
|
132
|
+
if (onGenerate) {
|
|
133
|
+
response = await onGenerate(prompt);
|
|
134
|
+
} else if (callIndex < responses.length) {
|
|
135
|
+
const queued = responses[callIndex];
|
|
136
|
+
if (!queued) {
|
|
137
|
+
throw new Error(`Mock response missing at index ${callIndex}`);
|
|
138
|
+
}
|
|
139
|
+
response = queued;
|
|
140
|
+
} else if (defaultResponse) {
|
|
141
|
+
response = defaultResponse;
|
|
142
|
+
} else {
|
|
143
|
+
response = { text: `Mock response ${callIndex + 1}` };
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
callIndex++;
|
|
147
|
+
callHistory.push({ prompt, response });
|
|
148
|
+
|
|
149
|
+
if (response.delay) {
|
|
150
|
+
await new Promise(resolve => setTimeout(resolve, response.delay));
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
if (response.error) {
|
|
154
|
+
throw response.error;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
return response;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
function reset(): void {
|
|
161
|
+
callIndex = 0;
|
|
162
|
+
callHistory.length = 0;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
function getCalls(): { prompt: string; response: MockResponse }[] {
|
|
166
|
+
return [...callHistory];
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
function getCallCount(): number {
|
|
170
|
+
return callHistory.length;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
return {
|
|
174
|
+
generate,
|
|
175
|
+
reset,
|
|
176
|
+
getCalls,
|
|
177
|
+
getCallCount,
|
|
178
|
+
modelId: 'mock-provider',
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
export interface MockProvider {
|
|
183
|
+
generate: (prompt: string) => Promise<MockResponse>;
|
|
184
|
+
reset: () => void;
|
|
185
|
+
getCalls: () => { prompt: string; response: MockResponse }[];
|
|
186
|
+
getCallCount: () => number;
|
|
187
|
+
readonly modelId: string;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
// -----------------------------------------------------------------------------
|
|
191
|
+
// Mock Tools
|
|
192
|
+
// -----------------------------------------------------------------------------
|
|
193
|
+
|
|
194
|
+
/**
|
|
195
|
+
* Creates a mock tool for testing.
|
|
196
|
+
*
|
|
197
|
+
* @example
|
|
198
|
+
* ```typescript
|
|
199
|
+
* const mockSearch = createMockTool({
|
|
200
|
+
* name: 'search',
|
|
201
|
+
* results: [
|
|
202
|
+
* { query: 'weather', result: { temp: 72, condition: 'sunny' } }
|
|
203
|
+
* ]
|
|
204
|
+
* });
|
|
205
|
+
* ```
|
|
206
|
+
*/
|
|
207
|
+
export function createMockTool<TInput extends z.ZodType, TOutput>(options: {
|
|
208
|
+
name: string;
|
|
209
|
+
description?: string;
|
|
210
|
+
inputSchema: TInput;
|
|
211
|
+
results?: { args: Partial<z.infer<TInput>>; result: TOutput }[];
|
|
212
|
+
defaultResult?: TOutput;
|
|
213
|
+
onExecute?: (args: z.infer<TInput>) => TOutput | Promise<TOutput>;
|
|
214
|
+
}): MockTool<TInput, TOutput> {
|
|
215
|
+
const { name, description, inputSchema, results = [], defaultResult, onExecute } = options;
|
|
216
|
+
const callHistory: { args: z.infer<TInput>; result: TOutput }[] = [];
|
|
217
|
+
|
|
218
|
+
async function execute(args: z.infer<TInput>): Promise<TOutput> {
|
|
219
|
+
// Validate input
|
|
220
|
+
const parsed = inputSchema.safeParse(args);
|
|
221
|
+
if (!parsed.success) {
|
|
222
|
+
throw new Error(`Invalid tool input: ${JSON.stringify(parsed.error)}`);
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
let result: TOutput;
|
|
226
|
+
|
|
227
|
+
if (onExecute) {
|
|
228
|
+
result = await onExecute(args);
|
|
229
|
+
} else {
|
|
230
|
+
// Find matching result
|
|
231
|
+
const match = results.find(r =>
|
|
232
|
+
Object.entries(r.args).every(
|
|
233
|
+
([key, value]) => (args as Record<string, unknown>)[key] === value,
|
|
234
|
+
),
|
|
235
|
+
);
|
|
236
|
+
|
|
237
|
+
if (match) {
|
|
238
|
+
const { result: matchedResult } = match;
|
|
239
|
+
result = matchedResult;
|
|
240
|
+
} else if (defaultResult !== undefined) {
|
|
241
|
+
result = defaultResult;
|
|
242
|
+
} else {
|
|
243
|
+
throw new Error(`No mock result found for args: ${JSON.stringify(args)}`);
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
callHistory.push({ args, result });
|
|
248
|
+
return result;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
function reset(): void {
|
|
252
|
+
callHistory.length = 0;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
function getCalls(): { args: z.infer<TInput>; result: TOutput }[] {
|
|
256
|
+
return [...callHistory];
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
return {
|
|
260
|
+
name,
|
|
261
|
+
description: description ?? `Mock tool: ${name}`,
|
|
262
|
+
inputSchema,
|
|
263
|
+
execute,
|
|
264
|
+
reset,
|
|
265
|
+
getCalls,
|
|
266
|
+
};
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
export interface MockTool<TInput extends z.ZodType, TOutput> {
|
|
270
|
+
readonly name: string;
|
|
271
|
+
readonly description: string;
|
|
272
|
+
readonly inputSchema: TInput;
|
|
273
|
+
execute: (args: z.infer<TInput>) => Promise<TOutput>;
|
|
274
|
+
reset: () => void;
|
|
275
|
+
getCalls: () => { args: z.infer<TInput>; result: TOutput }[];
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
// -----------------------------------------------------------------------------
|
|
279
|
+
// Built-in Evaluation Criteria
|
|
280
|
+
// -----------------------------------------------------------------------------
|
|
281
|
+
|
|
282
|
+
/**
|
|
283
|
+
* Creates exact match evaluation criteria.
|
|
284
|
+
*/
|
|
285
|
+
export function exactMatch(): EvalCriteria {
|
|
286
|
+
return {
|
|
287
|
+
name: 'exact_match',
|
|
288
|
+
description: 'Checks if output exactly matches expected',
|
|
289
|
+
evaluate: async (_, output, expected) => {
|
|
290
|
+
if (!expected) {
|
|
291
|
+
return { score: 1, reason: 'No expected value provided' };
|
|
292
|
+
}
|
|
293
|
+
const matches = output.trim() === expected.trim();
|
|
294
|
+
return {
|
|
295
|
+
score: matches ? 1 : 0,
|
|
296
|
+
reason: matches ? 'Exact match' : 'Does not match expected output',
|
|
297
|
+
};
|
|
298
|
+
},
|
|
299
|
+
};
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
/**
|
|
303
|
+
* Creates contains evaluation criteria.
|
|
304
|
+
*/
|
|
305
|
+
export function contains(substring: string | string[]): EvalCriteria {
|
|
306
|
+
const substrings = Array.isArray(substring) ? substring : [substring];
|
|
307
|
+
|
|
308
|
+
return {
|
|
309
|
+
name: 'contains',
|
|
310
|
+
description: `Checks if output contains: ${substrings.join(', ')}`,
|
|
311
|
+
evaluate: async (_, output) => {
|
|
312
|
+
const found = substrings.filter(s => output.includes(s));
|
|
313
|
+
const score = found.length / substrings.length;
|
|
314
|
+
return {
|
|
315
|
+
score,
|
|
316
|
+
reason:
|
|
317
|
+
score === 1
|
|
318
|
+
? 'All substrings found'
|
|
319
|
+
: `Found ${found.length}/${substrings.length} substrings`,
|
|
320
|
+
details: { found, missing: substrings.filter(s => !output.includes(s)) },
|
|
321
|
+
};
|
|
322
|
+
},
|
|
323
|
+
};
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
/**
|
|
327
|
+
* Creates regex match evaluation criteria.
|
|
328
|
+
*/
|
|
329
|
+
export function regexMatch(pattern: RegExp): EvalCriteria {
|
|
330
|
+
return {
|
|
331
|
+
name: 'regex_match',
|
|
332
|
+
description: `Matches pattern: ${pattern.toString()}`,
|
|
333
|
+
evaluate: async (_, output) => {
|
|
334
|
+
const matches = pattern.test(output);
|
|
335
|
+
return {
|
|
336
|
+
score: matches ? 1 : 0,
|
|
337
|
+
reason: matches ? 'Pattern matched' : 'Pattern did not match',
|
|
338
|
+
};
|
|
339
|
+
},
|
|
340
|
+
};
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
/**
|
|
344
|
+
* Creates length constraint evaluation criteria.
|
|
345
|
+
*/
|
|
346
|
+
export function lengthConstraint(options: {
|
|
347
|
+
min?: number;
|
|
348
|
+
max?: number;
|
|
349
|
+
unit?: 'chars' | 'words' | 'sentences';
|
|
350
|
+
}): EvalCriteria {
|
|
351
|
+
const { min = 0, max = Infinity, unit = 'chars' } = options;
|
|
352
|
+
|
|
353
|
+
return {
|
|
354
|
+
name: 'length_constraint',
|
|
355
|
+
description: `Length between ${min}-${max} ${unit}`,
|
|
356
|
+
evaluate: async (_, output) => {
|
|
357
|
+
let length: number;
|
|
358
|
+
|
|
359
|
+
switch (unit) {
|
|
360
|
+
case 'words': {
|
|
361
|
+
const { length: wordCount } = output.split(/\s+/).filter(Boolean);
|
|
362
|
+
length = wordCount;
|
|
363
|
+
break;
|
|
364
|
+
}
|
|
365
|
+
case 'sentences': {
|
|
366
|
+
const { length: sentenceCount } = output.split(/[.!?]+/).filter(Boolean);
|
|
367
|
+
length = sentenceCount;
|
|
368
|
+
break;
|
|
369
|
+
}
|
|
370
|
+
case 'chars': {
|
|
371
|
+
const { length: charCount } = output;
|
|
372
|
+
length = charCount;
|
|
373
|
+
break;
|
|
374
|
+
}
|
|
375
|
+
default: {
|
|
376
|
+
const { length: charCount } = output;
|
|
377
|
+
length = charCount;
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
const inRange = length >= min && length <= max;
|
|
382
|
+
return {
|
|
383
|
+
score: inRange ? 1 : 0,
|
|
384
|
+
reason: inRange
|
|
385
|
+
? `Length ${length} is within range`
|
|
386
|
+
: `Length ${length} is outside range [${min}, ${max}]`,
|
|
387
|
+
details: { length, min, max, unit },
|
|
388
|
+
};
|
|
389
|
+
},
|
|
390
|
+
};
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
/**
|
|
394
|
+
* Creates JSON validity evaluation criteria.
|
|
395
|
+
*/
|
|
396
|
+
export function validJson<T extends z.ZodType>(schema?: T): EvalCriteria {
|
|
397
|
+
return {
|
|
398
|
+
name: 'valid_json',
|
|
399
|
+
description: schema ? 'Validates JSON against schema' : 'Checks if output is valid JSON',
|
|
400
|
+
evaluate: async (_, output) => {
|
|
401
|
+
try {
|
|
402
|
+
const parsed = JSON.parse(output);
|
|
403
|
+
|
|
404
|
+
if (schema) {
|
|
405
|
+
const result = schema.safeParse(parsed);
|
|
406
|
+
return {
|
|
407
|
+
score: result.success ? 1 : 0,
|
|
408
|
+
reason: result.success
|
|
409
|
+
? 'Valid JSON matching schema'
|
|
410
|
+
: `Schema validation failed: ${JSON.stringify(result.error)}`,
|
|
411
|
+
};
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
return { score: 1, reason: 'Valid JSON' };
|
|
415
|
+
} catch (e) {
|
|
416
|
+
return {
|
|
417
|
+
score: 0,
|
|
418
|
+
reason: `Invalid JSON: ${e instanceof Error ? e.message : String(e)}`,
|
|
419
|
+
};
|
|
420
|
+
}
|
|
421
|
+
},
|
|
422
|
+
};
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
// -----------------------------------------------------------------------------
|
|
426
|
+
// LLM-as-Judge
|
|
427
|
+
// -----------------------------------------------------------------------------
|
|
428
|
+
|
|
429
|
+
/**
|
|
430
|
+
* Creates an LLM-as-judge evaluation criteria.
|
|
431
|
+
*
|
|
432
|
+
* @example
|
|
433
|
+
* ```typescript
|
|
434
|
+
* const relevance = llmJudge({
|
|
435
|
+
* name: 'relevance',
|
|
436
|
+
* prompt: 'Rate how relevant the response is to the question (0-10)',
|
|
437
|
+
* generate: (prompt) => generateText({ model, prompt }),
|
|
438
|
+
* parseScore: (response) => parseInt(response) / 10
|
|
439
|
+
* });
|
|
440
|
+
* ```
|
|
441
|
+
*/
|
|
442
|
+
export function llmJudge(options: {
|
|
443
|
+
name: string;
|
|
444
|
+
description?: string;
|
|
445
|
+
prompt: string | ((input: string, output: string, expected?: string) => string);
|
|
446
|
+
generate: (prompt: string) => Promise<string>;
|
|
447
|
+
parseScore: (response: string) => number;
|
|
448
|
+
}): EvalCriteria {
|
|
449
|
+
const { name, description, prompt: promptTemplate, generate, parseScore } = options;
|
|
450
|
+
|
|
451
|
+
return {
|
|
452
|
+
name,
|
|
453
|
+
description: description ?? `LLM judge: ${name}`,
|
|
454
|
+
evaluate: async (input, output, expected) => {
|
|
455
|
+
const prompt =
|
|
456
|
+
typeof promptTemplate === 'function'
|
|
457
|
+
? promptTemplate(input, output, expected)
|
|
458
|
+
: `${promptTemplate}
|
|
459
|
+
|
|
460
|
+
Input: ${input}
|
|
461
|
+
Output: ${output}
|
|
462
|
+
${expected ? `Expected: ${expected}` : ''}
|
|
463
|
+
|
|
464
|
+
Evaluation:`;
|
|
465
|
+
|
|
466
|
+
try {
|
|
467
|
+
const response = await generate(prompt);
|
|
468
|
+
const score = Math.max(0, Math.min(1, parseScore(response)));
|
|
469
|
+
|
|
470
|
+
return {
|
|
471
|
+
score,
|
|
472
|
+
reason: response.slice(0, 200), // First 200 chars as reason
|
|
473
|
+
details: { fullResponse: response },
|
|
474
|
+
};
|
|
475
|
+
} catch (e) {
|
|
476
|
+
return {
|
|
477
|
+
score: 0,
|
|
478
|
+
reason: `Judge error: ${e instanceof Error ? e.message : String(e)}`,
|
|
479
|
+
};
|
|
480
|
+
}
|
|
481
|
+
},
|
|
482
|
+
};
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
// -----------------------------------------------------------------------------
|
|
486
|
+
// Test Runner
|
|
487
|
+
// -----------------------------------------------------------------------------
|
|
488
|
+
|
|
489
|
+
/**
|
|
490
|
+
* Creates a test runner for evaluating AI outputs.
|
|
491
|
+
*
|
|
492
|
+
* @example
|
|
493
|
+
* ```typescript
|
|
494
|
+
* const runner = createTestRunner({
|
|
495
|
+
* generate: (input) => generateText({ model, prompt: input }),
|
|
496
|
+
* parallel: 5
|
|
497
|
+
* });
|
|
498
|
+
*
|
|
499
|
+
* const suite: TestSuite = {
|
|
500
|
+
* name: 'QA Tests',
|
|
501
|
+
* cases: [
|
|
502
|
+
* { id: '1', name: 'Capital', input: 'What is the capital of France?', expected: 'Paris' }
|
|
503
|
+
* ],
|
|
504
|
+
* criteria: [exactMatch(), contains('Paris')]
|
|
505
|
+
* };
|
|
506
|
+
*
|
|
507
|
+
* const results = await runner.run(suite);
|
|
508
|
+
* console.log(`Pass rate: ${results.summary.passRate}%`);
|
|
509
|
+
* ```
|
|
510
|
+
*/
|
|
511
|
+
export function createTestRunner(options: {
|
|
512
|
+
generate: (input: string) => Promise<string>;
|
|
513
|
+
parallel?: number;
|
|
514
|
+
passThreshold?: number;
|
|
515
|
+
onProgress?: (completed: number, total: number) => void;
|
|
516
|
+
}): TestRunner {
|
|
517
|
+
const { generate, parallel = 1, passThreshold = 0.7, onProgress } = options;
|
|
518
|
+
|
|
519
|
+
async function run(suite: TestSuite): Promise<TestRunResult> {
|
|
520
|
+
const startTime = Date.now();
|
|
521
|
+
const results: EvalResult[] = [];
|
|
522
|
+
|
|
523
|
+
// Run tests in parallel batches
|
|
524
|
+
for (let i = 0; i < suite.cases.length; i += parallel) {
|
|
525
|
+
const batch = suite.cases.slice(i, i + parallel);
|
|
526
|
+
|
|
527
|
+
const batchResults = await Promise.all(
|
|
528
|
+
batch.map(async testCase => {
|
|
529
|
+
try {
|
|
530
|
+
const output = await generate(testCase.input);
|
|
531
|
+
return evaluateCase(testCase, output, suite.criteria);
|
|
532
|
+
} catch (e) {
|
|
533
|
+
return createErrorResult(testCase, e);
|
|
534
|
+
}
|
|
535
|
+
}),
|
|
536
|
+
);
|
|
537
|
+
|
|
538
|
+
results.push(...batchResults);
|
|
539
|
+
onProgress?.(results.length, suite.cases.length);
|
|
540
|
+
}
|
|
541
|
+
|
|
542
|
+
const summary = computeSummary(results, suite.criteria);
|
|
543
|
+
|
|
544
|
+
return {
|
|
545
|
+
suiteId: suite.name,
|
|
546
|
+
timestamp: startTime,
|
|
547
|
+
duration: Date.now() - startTime,
|
|
548
|
+
results,
|
|
549
|
+
summary,
|
|
550
|
+
};
|
|
551
|
+
}
|
|
552
|
+
|
|
553
|
+
async function evaluateCase(
|
|
554
|
+
testCase: TestCase,
|
|
555
|
+
output: string,
|
|
556
|
+
criteria: EvalCriteria[],
|
|
557
|
+
): Promise<EvalResult> {
|
|
558
|
+
const scores: Record<string, number> = {};
|
|
559
|
+
const feedbackParts: string[] = [];
|
|
560
|
+
|
|
561
|
+
let totalWeight = 0;
|
|
562
|
+
let weightedSum = 0;
|
|
563
|
+
|
|
564
|
+
for (const criterion of criteria) {
|
|
565
|
+
const score = await criterion.evaluate(testCase.input, output, testCase.expected);
|
|
566
|
+
scores[criterion.name] = score.score;
|
|
567
|
+
|
|
568
|
+
const weight = criterion.weight ?? 1;
|
|
569
|
+
totalWeight += weight;
|
|
570
|
+
weightedSum += score.score * weight;
|
|
571
|
+
|
|
572
|
+
if (score.reason) {
|
|
573
|
+
feedbackParts.push(`${criterion.name}: ${score.reason}`);
|
|
574
|
+
}
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
const avgScore = totalWeight > 0 ? weightedSum / totalWeight : 0;
|
|
578
|
+
const customValid = testCase.validate ? testCase.validate(output) : true;
|
|
579
|
+
|
|
580
|
+
return {
|
|
581
|
+
id: testCase.id,
|
|
582
|
+
input: testCase.input,
|
|
583
|
+
output,
|
|
584
|
+
expected: testCase.expected,
|
|
585
|
+
scores,
|
|
586
|
+
passed: avgScore >= passThreshold && customValid,
|
|
587
|
+
feedback: feedbackParts.join('\n'),
|
|
588
|
+
metadata: testCase.metadata,
|
|
589
|
+
};
|
|
590
|
+
}
|
|
591
|
+
|
|
592
|
+
function createErrorResult(testCase: TestCase, error: unknown): EvalResult {
|
|
593
|
+
return {
|
|
594
|
+
id: testCase.id,
|
|
595
|
+
input: testCase.input,
|
|
596
|
+
output: '',
|
|
597
|
+
expected: testCase.expected,
|
|
598
|
+
scores: {},
|
|
599
|
+
passed: false,
|
|
600
|
+
feedback: `Error: ${error instanceof Error ? error.message : String(error)}`,
|
|
601
|
+
metadata: testCase.metadata,
|
|
602
|
+
};
|
|
603
|
+
}
|
|
604
|
+
|
|
605
|
+
function computeSummary(results: EvalResult[], criteria: EvalCriteria[]): TestSummary {
|
|
606
|
+
const passed = results.filter(r => r.passed).length;
|
|
607
|
+
const avgScores: Record<string, number> = {};
|
|
608
|
+
|
|
609
|
+
for (const criterion of criteria) {
|
|
610
|
+
const scores = results
|
|
611
|
+
.map(r => r.scores[criterion.name])
|
|
612
|
+
.filter((s): s is number => s !== undefined);
|
|
613
|
+
|
|
614
|
+
avgScores[criterion.name] =
|
|
615
|
+
scores.length > 0 ? scores.reduce((a, b) => a + b, 0) / scores.length : 0;
|
|
616
|
+
}
|
|
617
|
+
|
|
618
|
+
return {
|
|
619
|
+
total: results.length,
|
|
620
|
+
passed,
|
|
621
|
+
failed: results.length - passed,
|
|
622
|
+
avgScores,
|
|
623
|
+
passRate: results.length > 0 ? (passed / results.length) * 100 : 0,
|
|
624
|
+
};
|
|
625
|
+
}
|
|
626
|
+
|
|
627
|
+
async function runSingle(
|
|
628
|
+
input: string,
|
|
629
|
+
criteria: EvalCriteria[],
|
|
630
|
+
expected?: string,
|
|
631
|
+
): Promise<EvalResult> {
|
|
632
|
+
const output = await generate(input);
|
|
633
|
+
return evaluateCase({ id: 'single', name: 'Single test', input, expected }, output, criteria);
|
|
634
|
+
}
|
|
635
|
+
|
|
636
|
+
return {
|
|
637
|
+
run,
|
|
638
|
+
runSingle,
|
|
639
|
+
};
|
|
640
|
+
}
|
|
641
|
+
|
|
642
|
+
export interface TestRunner {
|
|
643
|
+
run: (suite: TestSuite) => Promise<TestRunResult>;
|
|
644
|
+
runSingle: (input: string, criteria: EvalCriteria[], expected?: string) => Promise<EvalResult>;
|
|
645
|
+
}
|
|
646
|
+
|
|
647
|
+
// -----------------------------------------------------------------------------
|
|
648
|
+
// Assertion Helpers
|
|
649
|
+
// -----------------------------------------------------------------------------
|
|
650
|
+
|
|
651
|
+
/**
|
|
652
|
+
* Assertion helpers for test frameworks.
|
|
653
|
+
*/
|
|
654
|
+
export const assertions = {
|
|
655
|
+
/**
|
|
656
|
+
* Asserts that the eval result passed.
|
|
657
|
+
*/
|
|
658
|
+
assertPassed(result: EvalResult, message?: string): void {
|
|
659
|
+
if (!result.passed) {
|
|
660
|
+
throw new Error(
|
|
661
|
+
message ??
|
|
662
|
+
`Evaluation failed. Feedback: ${result.feedback}\nScores: ${JSON.stringify(result.scores)}`,
|
|
663
|
+
);
|
|
664
|
+
}
|
|
665
|
+
},
|
|
666
|
+
|
|
667
|
+
/**
|
|
668
|
+
* Asserts that a specific criterion score is above threshold.
|
|
669
|
+
*/
|
|
670
|
+
assertScore(result: EvalResult, criterion: string, minScore: number, message?: string): void {
|
|
671
|
+
const score = result.scores[criterion];
|
|
672
|
+
if (score === undefined) {
|
|
673
|
+
throw new Error(message ?? `Criterion "${criterion}" not found in scores`);
|
|
674
|
+
}
|
|
675
|
+
if (score < minScore) {
|
|
676
|
+
throw new Error(
|
|
677
|
+
message ?? `Score for "${criterion}" (${score}) is below threshold (${minScore})`,
|
|
678
|
+
);
|
|
679
|
+
}
|
|
680
|
+
},
|
|
681
|
+
|
|
682
|
+
/**
|
|
683
|
+
* Asserts that pass rate is above threshold.
|
|
684
|
+
*/
|
|
685
|
+
assertPassRate(result: TestRunResult, minRate: number, message?: string): void {
|
|
686
|
+
if (result.summary.passRate < minRate) {
|
|
687
|
+
throw new Error(
|
|
688
|
+
message ??
|
|
689
|
+
`Pass rate ${result.summary.passRate.toFixed(1)}% is below threshold ${minRate}%`,
|
|
690
|
+
);
|
|
691
|
+
}
|
|
692
|
+
},
|
|
693
|
+
};
|
|
694
|
+
|
|
695
|
+
// -----------------------------------------------------------------------------
|
|
696
|
+
// Tool Sequence Assertions
|
|
697
|
+
// -----------------------------------------------------------------------------
|
|
698
|
+
|
|
699
|
+
/** Tool call record for sequence assertions */
|
|
700
|
+
export interface ToolSequenceRecord {
|
|
701
|
+
toolName: string;
|
|
702
|
+
toolCallId?: string;
|
|
703
|
+
args?: Record<string, unknown>;
|
|
704
|
+
result?: unknown;
|
|
705
|
+
timestamp?: number;
|
|
706
|
+
}
|
|
707
|
+
|
|
708
|
+
/**
|
|
709
|
+
* Tool sequence assertion helpers for agent testing.
|
|
710
|
+
*
|
|
711
|
+
* @example
|
|
712
|
+
* ```typescript
|
|
713
|
+
* const calls = agent.getToolCalls();
|
|
714
|
+
*
|
|
715
|
+
* // Assert exact sequence
|
|
716
|
+
* toolSequence.assertSequence(calls, ['search', 'browse', 'summarize']);
|
|
717
|
+
*
|
|
718
|
+
* // Assert tool was called
|
|
719
|
+
* toolSequence.assertCalled(calls, 'search');
|
|
720
|
+
*
|
|
721
|
+
* // Assert tool was called with specific args
|
|
722
|
+
* toolSequence.assertCalledWith(calls, 'search', { query: 'AI news' });
|
|
723
|
+
*
|
|
724
|
+
* // Assert call count
|
|
725
|
+
* toolSequence.assertCallCount(calls, 'search', 2);
|
|
726
|
+
* ```
|
|
727
|
+
*/
|
|
728
|
+
export const toolSequence = {
|
|
729
|
+
/**
|
|
730
|
+
* Assert that tools were called in a specific order.
|
|
731
|
+
*/
|
|
732
|
+
assertSequence(
|
|
733
|
+
calls: ToolSequenceRecord[],
|
|
734
|
+
expected: string[],
|
|
735
|
+
options?: { strict?: boolean },
|
|
736
|
+
): void {
|
|
737
|
+
const { strict = false } = options ?? {};
|
|
738
|
+
const actualNames = calls.map(c => c.toolName);
|
|
739
|
+
|
|
740
|
+
if (strict) {
|
|
741
|
+
// Exact sequence match
|
|
742
|
+
if (actualNames.length !== expected.length) {
|
|
743
|
+
throw new Error(
|
|
744
|
+
`Tool sequence length mismatch. Expected ${expected.length} calls, got ${actualNames.length}.\n` +
|
|
745
|
+
`Expected: ${expected.join(' -> ')}\n` +
|
|
746
|
+
`Actual: ${actualNames.join(' -> ')}`,
|
|
747
|
+
);
|
|
748
|
+
}
|
|
749
|
+
|
|
750
|
+
for (let i = 0; i < expected.length; i++) {
|
|
751
|
+
if (actualNames[i] !== expected[i]) {
|
|
752
|
+
throw new Error(
|
|
753
|
+
`Tool sequence mismatch at position ${i}.\n` +
|
|
754
|
+
`Expected: ${expected[i]}\n` +
|
|
755
|
+
`Actual: ${actualNames[i]}\n` +
|
|
756
|
+
`Full sequence: ${actualNames.join(' -> ')}`,
|
|
757
|
+
);
|
|
758
|
+
}
|
|
759
|
+
}
|
|
760
|
+
} else {
|
|
761
|
+
// Subsequence match (tools appear in order, but other tools may be in between)
|
|
762
|
+
let expectedIndex = 0;
|
|
763
|
+
for (const actualName of actualNames) {
|
|
764
|
+
if (actualName === expected[expectedIndex]) {
|
|
765
|
+
expectedIndex++;
|
|
766
|
+
if (expectedIndex === expected.length) break;
|
|
767
|
+
}
|
|
768
|
+
}
|
|
769
|
+
|
|
770
|
+
if (expectedIndex !== expected.length) {
|
|
771
|
+
throw new Error(
|
|
772
|
+
`Tool sequence not found.\n` +
|
|
773
|
+
`Expected subsequence: ${expected.join(' -> ')}\n` +
|
|
774
|
+
`Actual sequence: ${actualNames.join(' -> ')}\n` +
|
|
775
|
+
`Matched up to: ${expected.slice(0, expectedIndex).join(' -> ')}`,
|
|
776
|
+
);
|
|
777
|
+
}
|
|
778
|
+
}
|
|
779
|
+
},
|
|
780
|
+
|
|
781
|
+
/**
|
|
782
|
+
* Assert that a tool was called at least once.
|
|
783
|
+
*/
|
|
784
|
+
assertCalled(calls: ToolSequenceRecord[], toolName: string): void {
|
|
785
|
+
const found = calls.some(c => c.toolName === toolName);
|
|
786
|
+
if (!found) {
|
|
787
|
+
const availableTools = [...new Set(calls.map(c => c.toolName))].join(', ');
|
|
788
|
+
throw new Error(
|
|
789
|
+
`Tool "${toolName}" was not called.\n` + `Tools called: ${availableTools || 'none'}`,
|
|
790
|
+
);
|
|
791
|
+
}
|
|
792
|
+
},
|
|
793
|
+
|
|
794
|
+
/**
|
|
795
|
+
* Assert that a tool was NOT called.
|
|
796
|
+
*/
|
|
797
|
+
assertNotCalled(calls: ToolSequenceRecord[], toolName: string): void {
|
|
798
|
+
const found = calls.some(c => c.toolName === toolName);
|
|
799
|
+
if (found) {
|
|
800
|
+
throw new Error(`Tool "${toolName}" should not have been called but was.`);
|
|
801
|
+
}
|
|
802
|
+
},
|
|
803
|
+
|
|
804
|
+
/**
|
|
805
|
+
* Assert that a tool was called with specific arguments.
|
|
806
|
+
*/
|
|
807
|
+
assertCalledWith(
|
|
808
|
+
calls: ToolSequenceRecord[],
|
|
809
|
+
toolName: string,
|
|
810
|
+
expectedArgs: Record<string, unknown>,
|
|
811
|
+
): void {
|
|
812
|
+
const matchingCalls = calls.filter(c => c.toolName === toolName);
|
|
813
|
+
|
|
814
|
+
if (matchingCalls.length === 0) {
|
|
815
|
+
throw new Error(`Tool "${toolName}" was not called.`);
|
|
816
|
+
}
|
|
817
|
+
|
|
818
|
+
const found = matchingCalls.some(call => {
|
|
819
|
+
if (!call.args) return false;
|
|
820
|
+
return Object.entries(expectedArgs).every(
|
|
821
|
+
([key, value]) => JSON.stringify(call.args?.[key]) === JSON.stringify(value),
|
|
822
|
+
);
|
|
823
|
+
});
|
|
824
|
+
|
|
825
|
+
if (!found) {
|
|
826
|
+
const actualArgs = matchingCalls.map(c => JSON.stringify(c.args)).join('\n ');
|
|
827
|
+
throw new Error(
|
|
828
|
+
`Tool "${toolName}" was not called with expected args.\n` +
|
|
829
|
+
`Expected: ${JSON.stringify(expectedArgs)}\n` +
|
|
830
|
+
`Actual calls:\n ${actualArgs}`,
|
|
831
|
+
);
|
|
832
|
+
}
|
|
833
|
+
},
|
|
834
|
+
|
|
835
|
+
/**
|
|
836
|
+
* Assert tool was called a specific number of times.
|
|
837
|
+
*/
|
|
838
|
+
assertCallCount(calls: ToolSequenceRecord[], toolName: string, expected: number): void {
|
|
839
|
+
const count = calls.filter(c => c.toolName === toolName).length;
|
|
840
|
+
if (count !== expected) {
|
|
841
|
+
throw new Error(`Tool "${toolName}" was called ${count} times, expected ${expected}.`);
|
|
842
|
+
}
|
|
843
|
+
},
|
|
844
|
+
|
|
845
|
+
/**
|
|
846
|
+
* Assert tool was called at least N times.
|
|
847
|
+
*/
|
|
848
|
+
assertMinCalls(calls: ToolSequenceRecord[], toolName: string, min: number): void {
|
|
849
|
+
const count = calls.filter(c => c.toolName === toolName).length;
|
|
850
|
+
if (count < min) {
|
|
851
|
+
throw new Error(`Tool "${toolName}" was called ${count} times, expected at least ${min}.`);
|
|
852
|
+
}
|
|
853
|
+
},
|
|
854
|
+
|
|
855
|
+
/**
|
|
856
|
+
* Assert tool was called at most N times.
|
|
857
|
+
*/
|
|
858
|
+
assertMaxCalls(calls: ToolSequenceRecord[], toolName: string, max: number): void {
|
|
859
|
+
const count = calls.filter(c => c.toolName === toolName).length;
|
|
860
|
+
if (count > max) {
|
|
861
|
+
throw new Error(`Tool "${toolName}" was called ${count} times, expected at most ${max}.`);
|
|
862
|
+
}
|
|
863
|
+
},
|
|
864
|
+
|
|
865
|
+
/**
|
|
866
|
+
* Assert a tool was called before another tool.
|
|
867
|
+
*/
|
|
868
|
+
assertCalledBefore(calls: ToolSequenceRecord[], firstTool: string, secondTool: string): void {
|
|
869
|
+
const firstIndex = calls.findIndex(c => c.toolName === firstTool);
|
|
870
|
+
const secondIndex = calls.findIndex(c => c.toolName === secondTool);
|
|
871
|
+
|
|
872
|
+
if (firstIndex === -1) {
|
|
873
|
+
throw new Error(`Tool "${firstTool}" was not called.`);
|
|
874
|
+
}
|
|
875
|
+
if (secondIndex === -1) {
|
|
876
|
+
throw new Error(`Tool "${secondTool}" was not called.`);
|
|
877
|
+
}
|
|
878
|
+
if (firstIndex >= secondIndex) {
|
|
879
|
+
throw new Error(
|
|
880
|
+
`Tool "${firstTool}" was not called before "${secondTool}".\n` +
|
|
881
|
+
`"${firstTool}" at index ${firstIndex}, "${secondTool}" at index ${secondIndex}.`,
|
|
882
|
+
);
|
|
883
|
+
}
|
|
884
|
+
},
|
|
885
|
+
|
|
886
|
+
/**
|
|
887
|
+
* Assert a tool returned a specific result.
|
|
888
|
+
*/
|
|
889
|
+
assertResult(
|
|
890
|
+
calls: ToolSequenceRecord[],
|
|
891
|
+
toolName: string,
|
|
892
|
+
expectedResult: unknown,
|
|
893
|
+
options?: { callIndex?: number },
|
|
894
|
+
): void {
|
|
895
|
+
const { callIndex } = options ?? {};
|
|
896
|
+
const matchingCalls = calls.filter(c => c.toolName === toolName);
|
|
897
|
+
|
|
898
|
+
if (matchingCalls.length === 0) {
|
|
899
|
+
throw new Error(`Tool "${toolName}" was not called.`);
|
|
900
|
+
}
|
|
901
|
+
|
|
902
|
+
const call = callIndex !== undefined ? matchingCalls[callIndex] : matchingCalls[0];
|
|
903
|
+
|
|
904
|
+
if (!call) {
|
|
905
|
+
throw new Error(`Tool "${toolName}" call at index ${callIndex} not found.`);
|
|
906
|
+
}
|
|
907
|
+
|
|
908
|
+
const actualJson = JSON.stringify(call.result);
|
|
909
|
+
const expectedJson = JSON.stringify(expectedResult);
|
|
910
|
+
|
|
911
|
+
if (actualJson !== expectedJson) {
|
|
912
|
+
throw new Error(
|
|
913
|
+
`Tool "${toolName}" result mismatch.\n` +
|
|
914
|
+
`Expected: ${expectedJson}\n` +
|
|
915
|
+
`Actual: ${actualJson}`,
|
|
916
|
+
);
|
|
917
|
+
}
|
|
918
|
+
},
|
|
919
|
+
|
|
920
|
+
/**
|
|
921
|
+
* Get all calls for a specific tool.
|
|
922
|
+
*/
|
|
923
|
+
getCallsFor(calls: ToolSequenceRecord[], toolName: string): ToolSequenceRecord[] {
|
|
924
|
+
return calls.filter(c => c.toolName === toolName);
|
|
925
|
+
},
|
|
926
|
+
|
|
927
|
+
/**
|
|
928
|
+
* Get the last call for a specific tool.
|
|
929
|
+
*/
|
|
930
|
+
getLastCall(calls: ToolSequenceRecord[], toolName: string): ToolSequenceRecord | undefined {
|
|
931
|
+
const matching = calls.filter(c => c.toolName === toolName);
|
|
932
|
+
return matching[matching.length - 1];
|
|
933
|
+
},
|
|
934
|
+
|
|
935
|
+
/**
|
|
936
|
+
* Create a summary of tool calls.
|
|
937
|
+
*/
|
|
938
|
+
summarize(calls: ToolSequenceRecord[]): {
|
|
939
|
+
totalCalls: number;
|
|
940
|
+
uniqueTools: string[];
|
|
941
|
+
callCounts: Record<string, number>;
|
|
942
|
+
sequence: string[];
|
|
943
|
+
} {
|
|
944
|
+
const callCounts: Record<string, number> = {};
|
|
945
|
+
for (const call of calls) {
|
|
946
|
+
callCounts[call.toolName] = (callCounts[call.toolName] ?? 0) + 1;
|
|
947
|
+
}
|
|
948
|
+
|
|
949
|
+
return {
|
|
950
|
+
totalCalls: calls.length,
|
|
951
|
+
uniqueTools: [...new Set(calls.map(c => c.toolName))],
|
|
952
|
+
callCounts,
|
|
953
|
+
sequence: calls.map(c => c.toolName),
|
|
954
|
+
};
|
|
955
|
+
},
|
|
956
|
+
};
|
|
957
|
+
|
|
958
|
+
// Evaluators available via direct import
|
|
959
|
+
// import { createLLMJudge, EvaluationCriteria } from '@od-oneapp/ai-platform/testing/evaluators';
|
|
960
|
+
// Note: Requires SDK v6 compatibility fixes
|