@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,446 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Governance Agent
|
|
3
|
+
*
|
|
4
|
+
* Implements the "Governance Track" agent strategy using the Ralph Wiggum autonomous retry loop.
|
|
5
|
+
* This agent prioritizes RELIABILITY and COMPLIANCE over raw speed.
|
|
6
|
+
*
|
|
7
|
+
* Features:
|
|
8
|
+
* - Autonomous Retry Loop (keeps trying until completion signal)
|
|
9
|
+
* - "Principal Skinner" Governance (fine-grained token budgets per iteration)
|
|
10
|
+
* - Audit Signals (loop.approval_required, loop.budget_exceeded)
|
|
11
|
+
* - Feedback Loops (feeds errors back into context)
|
|
12
|
+
*
|
|
13
|
+
* @module @od-oneapp/ai-platform/agents/governance-agent
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
import { randomUUID } from 'node:crypto';
|
|
17
|
+
|
|
18
|
+
import { complianceSignalSchema } from '../governance/compliance/schemas';
|
|
19
|
+
import { generateText } from '../shared';
|
|
20
|
+
|
|
21
|
+
import type { ComplianceSignal, RiskLevel } from '../governance/compliance/schemas';
|
|
22
|
+
import type { SDKLanguageModelV3, SDKTool } from '../shared';
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Configuration for Governance Agent (Principal Skinner) rules.
|
|
28
|
+
*/
|
|
29
|
+
export interface GovernanceRules {
|
|
30
|
+
/** Maximum tokens per iteration to limit output length. */
|
|
31
|
+
maxTokensPerIteration: number;
|
|
32
|
+
/** Tool names that are blocked from execution. */
|
|
33
|
+
blockedTools: string[];
|
|
34
|
+
/**
|
|
35
|
+
* Tool names that emit an approval signal when executed.
|
|
36
|
+
* NOTE: This is currently a notification/audit mechanism, NOT a blocking gate.
|
|
37
|
+
* Tools will execute and a 'loop.approval_required' signal is emitted for audit purposes.
|
|
38
|
+
*/
|
|
39
|
+
requireApproval: string[];
|
|
40
|
+
/** Maximum total tokens across all iterations. */
|
|
41
|
+
maxTotalTokens?: number;
|
|
42
|
+
/** Timeout in milliseconds for each iteration. */
|
|
43
|
+
iterationTimeoutMs?: number;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Single iteration result.
|
|
48
|
+
*/
|
|
49
|
+
export interface GovernanceIteration {
|
|
50
|
+
/** Iteration index (1-based). */
|
|
51
|
+
index: number;
|
|
52
|
+
/** Status of the iteration. */
|
|
53
|
+
status: 'running' | 'success' | 'error' | 'timeout';
|
|
54
|
+
/** Output text from the iteration. */
|
|
55
|
+
output?: string;
|
|
56
|
+
/** Error message if iteration failed. */
|
|
57
|
+
error?: string;
|
|
58
|
+
/** Token usage for this iteration. */
|
|
59
|
+
tokenUsage: { input: number; output: number };
|
|
60
|
+
/** Duration in milliseconds. */
|
|
61
|
+
durationMs: number;
|
|
62
|
+
/** Tool calls made during this iteration. */
|
|
63
|
+
toolCalls?: Array<{ name: string; args: unknown }>;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Final result of the Governance Agent execution.
|
|
68
|
+
*/
|
|
69
|
+
export interface GovernanceResult {
|
|
70
|
+
/** Whether the loop completed successfully. */
|
|
71
|
+
success: boolean;
|
|
72
|
+
/** Total number of iterations executed. */
|
|
73
|
+
iterations: number;
|
|
74
|
+
/** All iteration results. */
|
|
75
|
+
iterationHistory: GovernanceIteration[];
|
|
76
|
+
/** Final output if successful. */
|
|
77
|
+
finalOutput?: string;
|
|
78
|
+
/** Error message if failed. */
|
|
79
|
+
error?: string;
|
|
80
|
+
/** Total token usage. */
|
|
81
|
+
totalTokens: { input: number; output: number };
|
|
82
|
+
/** Total duration in milliseconds. */
|
|
83
|
+
totalDurationMs: number;
|
|
84
|
+
/** Compliance signals generated. */
|
|
85
|
+
signals: ComplianceSignal[];
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Options for configuring the Governance Agent.
|
|
90
|
+
*/
|
|
91
|
+
export interface GovernanceAgentOptions {
|
|
92
|
+
/** Task prompt to retry until completion. */
|
|
93
|
+
task: string;
|
|
94
|
+
/** Completion signal to detect success (e.g., "DONE", "COMPLETE", "FINISHED"). */
|
|
95
|
+
completionSignal: string;
|
|
96
|
+
/** Maximum iterations before force exit. Default: 10. */
|
|
97
|
+
maxIterations?: number;
|
|
98
|
+
/** Whether to feed errors back into context. Default: true. */
|
|
99
|
+
feedbackErrors?: boolean;
|
|
100
|
+
/** Delay between iterations in milliseconds. Default: 0. */
|
|
101
|
+
iterationDelay?: number;
|
|
102
|
+
/** Principal Skinner governance rules. */
|
|
103
|
+
governance: GovernanceRules;
|
|
104
|
+
/** Language model to use. */
|
|
105
|
+
model: SDKLanguageModelV3;
|
|
106
|
+
/** Tools available to the agent. */
|
|
107
|
+
tools?: Record<string, SDKTool>;
|
|
108
|
+
/** Callback for each iteration. */
|
|
109
|
+
onIteration?: (iteration: GovernanceIteration) => void;
|
|
110
|
+
/** Callback for compliance signals. */
|
|
111
|
+
onSignal?: (signal: ComplianceSignal) => void;
|
|
112
|
+
/** Optional system prompt to prepend. */
|
|
113
|
+
systemPrompt?: string;
|
|
114
|
+
/** Run ID for audit logging. */
|
|
115
|
+
runId?: string;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Creates a delay promise.
|
|
120
|
+
* @internal
|
|
121
|
+
*/
|
|
122
|
+
const sleep = (ms: number): Promise<void> => new Promise(resolve => setTimeout(resolve, ms));
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Filters tools based on blocked list.
|
|
126
|
+
* @internal
|
|
127
|
+
*/
|
|
128
|
+
const filterTools = (
|
|
129
|
+
tools: Record<string, SDKTool> | undefined,
|
|
130
|
+
blockedTools: string[],
|
|
131
|
+
): Record<string, SDKTool> | undefined => {
|
|
132
|
+
if (!tools) return undefined;
|
|
133
|
+
|
|
134
|
+
const filtered: Record<string, SDKTool> = {};
|
|
135
|
+
for (const [name, tool] of Object.entries(tools)) {
|
|
136
|
+
if (!blockedTools.includes(name)) {
|
|
137
|
+
filtered[name] = tool;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
return Object.keys(filtered).length > 0 ? filtered : undefined;
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Checks if output contains completion signal.
|
|
145
|
+
* Uses word boundary matching to avoid false positives.
|
|
146
|
+
* @internal
|
|
147
|
+
*/
|
|
148
|
+
const detectCompletion = (output: string, signal: string): boolean => {
|
|
149
|
+
const escapedSignal = signal.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
150
|
+
const regex = new RegExp(`\\b${escapedSignal}\\b`, 'i');
|
|
151
|
+
return regex.test(output);
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* Creates a compliance signal.
|
|
156
|
+
* @internal
|
|
157
|
+
*/
|
|
158
|
+
const createSignal = (
|
|
159
|
+
type: ComplianceSignal['type'],
|
|
160
|
+
message: string,
|
|
161
|
+
runId: string,
|
|
162
|
+
riskLevel?: RiskLevel,
|
|
163
|
+
metadata?: Record<string, unknown>,
|
|
164
|
+
): ComplianceSignal => {
|
|
165
|
+
return complianceSignalSchema.parse({
|
|
166
|
+
id: randomUUID(),
|
|
167
|
+
type,
|
|
168
|
+
message,
|
|
169
|
+
runId,
|
|
170
|
+
riskLevel,
|
|
171
|
+
timestamp: new Date().toISOString(),
|
|
172
|
+
metadata,
|
|
173
|
+
});
|
|
174
|
+
};
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* Executes the Governance Loop.
|
|
178
|
+
* @internal
|
|
179
|
+
*/
|
|
180
|
+
async function executeGovernanceLoop(options: GovernanceAgentOptions): Promise<GovernanceResult> {
|
|
181
|
+
const {
|
|
182
|
+
task,
|
|
183
|
+
completionSignal,
|
|
184
|
+
maxIterations = 10,
|
|
185
|
+
feedbackErrors = true,
|
|
186
|
+
iterationDelay = 0,
|
|
187
|
+
governance,
|
|
188
|
+
model,
|
|
189
|
+
tools,
|
|
190
|
+
onIteration,
|
|
191
|
+
onSignal,
|
|
192
|
+
systemPrompt,
|
|
193
|
+
runId = randomUUID(),
|
|
194
|
+
} = options;
|
|
195
|
+
|
|
196
|
+
const signals: ComplianceSignal[] = [];
|
|
197
|
+
const iterationHistory: GovernanceIteration[] = [];
|
|
198
|
+
let iteration = 0;
|
|
199
|
+
const context = task;
|
|
200
|
+
let lastError: string | undefined;
|
|
201
|
+
let totalInputTokens = 0;
|
|
202
|
+
let totalOutputTokens = 0;
|
|
203
|
+
const startTime = Date.now();
|
|
204
|
+
|
|
205
|
+
const allowedTools = filterTools(tools, governance.blockedTools);
|
|
206
|
+
|
|
207
|
+
const startSignal = createSignal(
|
|
208
|
+
'loop.started',
|
|
209
|
+
`Governance Agent started: ${task.slice(0, 50)}...`,
|
|
210
|
+
runId,
|
|
211
|
+
'low',
|
|
212
|
+
{ maxIterations, completionSignal },
|
|
213
|
+
);
|
|
214
|
+
signals.push(startSignal);
|
|
215
|
+
onSignal?.(startSignal);
|
|
216
|
+
|
|
217
|
+
while (iteration < maxIterations) {
|
|
218
|
+
iteration++;
|
|
219
|
+
const iterationStart = Date.now();
|
|
220
|
+
|
|
221
|
+
if (
|
|
222
|
+
governance.maxTotalTokens &&
|
|
223
|
+
totalInputTokens + totalOutputTokens >= governance.maxTotalTokens
|
|
224
|
+
) {
|
|
225
|
+
const budgetSignal = createSignal(
|
|
226
|
+
'loop.budget_exceeded',
|
|
227
|
+
`Total token budget exhausted after ${iteration - 1} iterations`,
|
|
228
|
+
runId,
|
|
229
|
+
'medium',
|
|
230
|
+
{ totalInputTokens, totalOutputTokens },
|
|
231
|
+
);
|
|
232
|
+
signals.push(budgetSignal);
|
|
233
|
+
onSignal?.(budgetSignal);
|
|
234
|
+
|
|
235
|
+
return {
|
|
236
|
+
success: false,
|
|
237
|
+
iterations: iteration - 1,
|
|
238
|
+
iterationHistory,
|
|
239
|
+
error: `Token budget exceeded (${totalInputTokens + totalOutputTokens} / ${governance.maxTotalTokens})`,
|
|
240
|
+
totalTokens: { input: totalInputTokens, output: totalOutputTokens },
|
|
241
|
+
totalDurationMs: Date.now() - startTime,
|
|
242
|
+
signals,
|
|
243
|
+
};
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
const prompt =
|
|
247
|
+
feedbackErrors && lastError
|
|
248
|
+
? `${context}\n\n[Previous attempt failed with error: ${lastError}]\n\nPlease try again and address the error.`
|
|
249
|
+
: context;
|
|
250
|
+
|
|
251
|
+
try {
|
|
252
|
+
const result = await generateText({
|
|
253
|
+
model,
|
|
254
|
+
prompt,
|
|
255
|
+
system: systemPrompt,
|
|
256
|
+
tools: allowedTools,
|
|
257
|
+
maxOutputTokens: governance.maxTokensPerIteration,
|
|
258
|
+
abortSignal: governance.iterationTimeoutMs
|
|
259
|
+
? AbortSignal.timeout(governance.iterationTimeoutMs)
|
|
260
|
+
: undefined,
|
|
261
|
+
});
|
|
262
|
+
|
|
263
|
+
const iterationDuration = Date.now() - iterationStart;
|
|
264
|
+
const inputTokens = result.usage?.inputTokens ?? 0;
|
|
265
|
+
const outputTokens = result.usage?.outputTokens ?? 0;
|
|
266
|
+
totalInputTokens += inputTokens;
|
|
267
|
+
totalOutputTokens += outputTokens;
|
|
268
|
+
|
|
269
|
+
const toolCalls = result.toolCalls?.map(tc => ({
|
|
270
|
+
name: tc.toolName,
|
|
271
|
+
args: (tc as { input?: unknown; args?: unknown }).input ?? (tc as { args?: unknown }).args,
|
|
272
|
+
}));
|
|
273
|
+
|
|
274
|
+
if (toolCalls) {
|
|
275
|
+
const approvalRequired = toolCalls.filter(tc =>
|
|
276
|
+
governance.requireApproval.includes(tc.name),
|
|
277
|
+
);
|
|
278
|
+
if (approvalRequired.length > 0) {
|
|
279
|
+
const approvalSignal = createSignal(
|
|
280
|
+
'loop.approval_required',
|
|
281
|
+
`Audit: Tools executed that require approval: ${approvalRequired.map(t => t.name).join(', ')}`,
|
|
282
|
+
runId,
|
|
283
|
+
'medium',
|
|
284
|
+
{ tools: approvalRequired, note: 'Post-execution audit signal' },
|
|
285
|
+
);
|
|
286
|
+
signals.push(approvalSignal);
|
|
287
|
+
onSignal?.(approvalSignal);
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
const iterationResult: GovernanceIteration = {
|
|
292
|
+
index: iteration,
|
|
293
|
+
status: 'running',
|
|
294
|
+
output: result.text,
|
|
295
|
+
tokenUsage: { input: inputTokens, output: outputTokens },
|
|
296
|
+
durationMs: iterationDuration,
|
|
297
|
+
toolCalls,
|
|
298
|
+
};
|
|
299
|
+
|
|
300
|
+
if (detectCompletion(result.text, completionSignal)) {
|
|
301
|
+
iterationResult.status = 'success';
|
|
302
|
+
iterationHistory.push(iterationResult);
|
|
303
|
+
onIteration?.(iterationResult);
|
|
304
|
+
|
|
305
|
+
const successSignal = createSignal(
|
|
306
|
+
'loop.completed',
|
|
307
|
+
`Governance Agent completed successfully after ${iteration} iterations`,
|
|
308
|
+
runId,
|
|
309
|
+
'low',
|
|
310
|
+
{ iterations: iteration, totalTokens: totalInputTokens + totalOutputTokens },
|
|
311
|
+
);
|
|
312
|
+
signals.push(successSignal);
|
|
313
|
+
onSignal?.(successSignal);
|
|
314
|
+
|
|
315
|
+
return {
|
|
316
|
+
success: true,
|
|
317
|
+
iterations: iteration,
|
|
318
|
+
iterationHistory,
|
|
319
|
+
finalOutput: result.text,
|
|
320
|
+
totalTokens: { input: totalInputTokens, output: totalOutputTokens },
|
|
321
|
+
totalDurationMs: Date.now() - startTime,
|
|
322
|
+
signals,
|
|
323
|
+
};
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
iterationHistory.push(iterationResult);
|
|
327
|
+
onIteration?.(iterationResult);
|
|
328
|
+
lastError = undefined;
|
|
329
|
+
|
|
330
|
+
if (iterationDelay > 0 && iteration < maxIterations) {
|
|
331
|
+
await sleep(iterationDelay);
|
|
332
|
+
}
|
|
333
|
+
} catch (error) {
|
|
334
|
+
// Error handling consistent with previous implementation
|
|
335
|
+
const iterationDuration = Date.now() - iterationStart;
|
|
336
|
+
lastError = error instanceof Error ? error.message : String(error);
|
|
337
|
+
const isTimeout = error instanceof Error && error.name === 'TimeoutError';
|
|
338
|
+
|
|
339
|
+
const iterationResult: GovernanceIteration = {
|
|
340
|
+
index: iteration,
|
|
341
|
+
status: isTimeout ? 'timeout' : 'error',
|
|
342
|
+
error: lastError,
|
|
343
|
+
tokenUsage: { input: 0, output: 0 },
|
|
344
|
+
durationMs: iterationDuration,
|
|
345
|
+
};
|
|
346
|
+
|
|
347
|
+
iterationHistory.push(iterationResult);
|
|
348
|
+
onIteration?.(iterationResult);
|
|
349
|
+
|
|
350
|
+
const errorSignal = createSignal(
|
|
351
|
+
isTimeout ? 'loop.timeout' : 'loop.error',
|
|
352
|
+
`Iteration ${iteration} ${isTimeout ? 'timed out' : 'failed'}: ${lastError}`,
|
|
353
|
+
runId,
|
|
354
|
+
'medium',
|
|
355
|
+
{ iteration, error: lastError },
|
|
356
|
+
);
|
|
357
|
+
signals.push(errorSignal);
|
|
358
|
+
onSignal?.(errorSignal);
|
|
359
|
+
|
|
360
|
+
if (!feedbackErrors) {
|
|
361
|
+
return {
|
|
362
|
+
success: false,
|
|
363
|
+
iterations: iteration,
|
|
364
|
+
iterationHistory,
|
|
365
|
+
error: `Iteration ${iteration} failed: ${lastError}`,
|
|
366
|
+
totalTokens: { input: totalInputTokens, output: totalOutputTokens },
|
|
367
|
+
totalDurationMs: Date.now() - startTime,
|
|
368
|
+
signals,
|
|
369
|
+
};
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
const exhaustedSignal = createSignal(
|
|
375
|
+
'loop.exhausted',
|
|
376
|
+
`Max iterations (${maxIterations}) reached without completion signal`,
|
|
377
|
+
runId,
|
|
378
|
+
'high',
|
|
379
|
+
{ iterations: maxIterations, completionSignal },
|
|
380
|
+
);
|
|
381
|
+
signals.push(exhaustedSignal);
|
|
382
|
+
onSignal?.(exhaustedSignal);
|
|
383
|
+
|
|
384
|
+
return {
|
|
385
|
+
success: false,
|
|
386
|
+
iterations: iteration,
|
|
387
|
+
iterationHistory,
|
|
388
|
+
error: `Max iterations (${maxIterations}) reached without completion signal "${completionSignal}"`,
|
|
389
|
+
totalTokens: { input: totalInputTokens, output: totalOutputTokens },
|
|
390
|
+
totalDurationMs: Date.now() - startTime,
|
|
391
|
+
signals,
|
|
392
|
+
};
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
/**
|
|
396
|
+
* Governance Agent class.
|
|
397
|
+
* Wraps the autonomous retry loop in an interface compatible with StandardAgent.
|
|
398
|
+
*/
|
|
399
|
+
export class GovernanceAgent {
|
|
400
|
+
private options: GovernanceAgentOptions;
|
|
401
|
+
|
|
402
|
+
constructor(options: GovernanceAgentOptions) {
|
|
403
|
+
this.options = options;
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
/**
|
|
407
|
+
* Generates a response using the governance retry loop.
|
|
408
|
+
* Maps the result to a format compatible with StandardAgent results where possible,
|
|
409
|
+
* or returns the specific GovernanceResult.
|
|
410
|
+
*/
|
|
411
|
+
async generate(): Promise<GovernanceResult> {
|
|
412
|
+
return executeGovernanceLoop(this.options);
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
/**
|
|
416
|
+
* Creates a new instance with merged options.
|
|
417
|
+
*/
|
|
418
|
+
static create(options: GovernanceAgentOptions): GovernanceAgent {
|
|
419
|
+
return new GovernanceAgent(options);
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
/**
|
|
424
|
+
* Factory for creating a Governance Agent with defaults.
|
|
425
|
+
*/
|
|
426
|
+
export function createGovernanceAgent(options: GovernanceAgentOptions): GovernanceAgent {
|
|
427
|
+
return new GovernanceAgent(options);
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
/**
|
|
431
|
+
* Default governance rules.
|
|
432
|
+
*/
|
|
433
|
+
export const DEFAULT_GOVERNANCE_RULES: GovernanceRules = {
|
|
434
|
+
maxTokensPerIteration: 4096,
|
|
435
|
+
blockedTools: ['deleteFile', 'formatDisk', 'dropTable', 'truncateTable', 'deleteDatabase'],
|
|
436
|
+
requireApproval: ['executeShell', 'runCommand', 'modifyPermissions', 'deployProduction'],
|
|
437
|
+
maxTotalTokens: 100_000,
|
|
438
|
+
iterationTimeoutMs: 60_000,
|
|
439
|
+
};
|
|
440
|
+
|
|
441
|
+
// Re-export types and legacy function for backward compatibility
|
|
442
|
+
export const ralphLoop = executeGovernanceLoop;
|
|
443
|
+
export type RalphLoopResult = GovernanceResult;
|
|
444
|
+
export type RalphLoopOptions = GovernanceAgentOptions;
|
|
445
|
+
export type RalphGovernance = GovernanceRules;
|
|
446
|
+
export const DEFAULT_RALPH_GOVERNANCE = DEFAULT_GOVERNANCE_RULES;
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview AI Agents Module
|
|
3
|
+
* @module @od-oneapp/ai-platform/agents
|
|
4
|
+
*
|
|
5
|
+
* Submodule overview:
|
|
6
|
+
* - base — Core agent types (BaseAgentState, AgentConfig, StopConditions)
|
|
7
|
+
* - triage — Intent-based routing to specialized agents
|
|
8
|
+
* - coordinator — Multi-step task planning and execution
|
|
9
|
+
* - experimental — AI SDK v6 agent with prepareStep hook and phased tools
|
|
10
|
+
* - evaluatorOptimizer — Typed evaluator/optimizer feedback loops
|
|
11
|
+
* - patterns — Lightweight pattern-based evaluator/optimizer (PatternEvaluatorOptimizer)
|
|
12
|
+
* - persistence — Checkpoint/restore with versioned state (CheckpointState)
|
|
13
|
+
* - controlFlow — Execution controllers, stop/continue conditions (ExecutionMetrics)
|
|
14
|
+
* - multi — Multi-agent swarm coordination (SwarmAgentState)
|
|
15
|
+
* - fallback — Model fallback and retry strategies
|
|
16
|
+
* - workflows — Workflow definition and execution
|
|
17
|
+
* - observability — Agent-level telemetry
|
|
18
|
+
*
|
|
19
|
+
* Note: tools/approval/ and tools/compliance/ are now re-exported from tools/index.ts.
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
// Convenience exports for primary agent constructors
|
|
23
|
+
export {
|
|
24
|
+
createTriageAgent,
|
|
25
|
+
createKeywordTriage,
|
|
26
|
+
type TriageAgentConfig,
|
|
27
|
+
type TriageResult,
|
|
28
|
+
} from './triage/triage-agent';
|
|
29
|
+
export {
|
|
30
|
+
createCoordinatorAgent,
|
|
31
|
+
type CoordinatorConfig,
|
|
32
|
+
type ExecutionPlan,
|
|
33
|
+
type Task,
|
|
34
|
+
type TaskResult,
|
|
35
|
+
} from './coordinator/coordinator-agent';
|
|
36
|
+
|
|
37
|
+
// Standard Agent (Experimental_Agent track)
|
|
38
|
+
export {
|
|
39
|
+
StandardAgent,
|
|
40
|
+
createDefaultAgent,
|
|
41
|
+
createDefaultAgentConfig,
|
|
42
|
+
type CreateAgentOptions,
|
|
43
|
+
type DefaultAgent,
|
|
44
|
+
type DefaultAgentOutput,
|
|
45
|
+
} from './default-agent';
|
|
46
|
+
|
|
47
|
+
// Governance Agent (Ralph Loop track)
|
|
48
|
+
export {
|
|
49
|
+
GovernanceAgent,
|
|
50
|
+
createGovernanceAgent,
|
|
51
|
+
DEFAULT_GOVERNANCE_RULES,
|
|
52
|
+
ralphLoop,
|
|
53
|
+
DEFAULT_RALPH_GOVERNANCE,
|
|
54
|
+
type GovernanceRules,
|
|
55
|
+
type GovernanceIteration,
|
|
56
|
+
type GovernanceResult,
|
|
57
|
+
type GovernanceAgentOptions,
|
|
58
|
+
type RalphLoopResult,
|
|
59
|
+
type RalphLoopOptions,
|
|
60
|
+
type RalphGovernance,
|
|
61
|
+
} from './governance-agent';
|
|
62
|
+
|
|
63
|
+
// Platform Orchestrator (risk-aware routing)
|
|
64
|
+
export { PlatformOrchestrator, type OrchestratorOptions, type PlatformAgent } from './orchestrator';
|
|
65
|
+
|
|
66
|
+
// Namespaced exports to avoid conflicts across agent modules
|
|
67
|
+
export * as base from "./base";
|
|
68
|
+
export * as triage from "./triage";
|
|
69
|
+
export * as coordinator from "./coordinator";
|
|
70
|
+
export * as experimental from "./experimental";
|
|
71
|
+
export * as persistence from "./persistence";
|
|
72
|
+
export * as observability from "./observability";
|
|
73
|
+
export * as controlFlow from "./control-flow";
|
|
74
|
+
export * as fallback from "./fallback";
|
|
75
|
+
export * as workflows from "./workflows";
|
|
76
|
+
export * as evaluatorOptimizer from "./evaluator-optimizer";
|
|
77
|
+
export * as multi from "./multi";
|
|
78
|
+
export * as swarm from "./multi/swarm";
|
|
79
|
+
export * as patterns from "./patterns";
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* In-memory message bus for agent coordination
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { randomUUID } from 'node:crypto';
|
|
6
|
+
|
|
7
|
+
import { logError } from '@repo/shared/logs';
|
|
8
|
+
|
|
9
|
+
import type { AgentMessage, MessageBus, MessageHandler, Unsubscribe } from '../types';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* In-memory message bus implementation
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```ts
|
|
16
|
+
* const bus = new InMemoryMessageBus();
|
|
17
|
+
*
|
|
18
|
+
* // Subscribe to messages
|
|
19
|
+
* bus.subscribe("agent-1", async (msg) => {
|
|
20
|
+
* console.log("Received:", msg.payload);
|
|
21
|
+
* });
|
|
22
|
+
*
|
|
23
|
+
* // Send a message
|
|
24
|
+
* await bus.send({
|
|
25
|
+
* id: randomUUID(),
|
|
26
|
+
* from: "coordinator",
|
|
27
|
+
* to: "agent-1",
|
|
28
|
+
* type: "command",
|
|
29
|
+
* payload: { action: "process" },
|
|
30
|
+
* timestamp: new Date().toISOString(),
|
|
31
|
+
* });
|
|
32
|
+
*
|
|
33
|
+
* // Request/response pattern
|
|
34
|
+
* const result = await bus.request<{ query: string }, { answer: string }>(
|
|
35
|
+
* "coordinator", // from
|
|
36
|
+
* "agent-1", // to
|
|
37
|
+
* { query: "What is 2+2?" },
|
|
38
|
+
* 5000
|
|
39
|
+
* );
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
export class InMemoryMessageBus implements MessageBus {
|
|
43
|
+
private handlers = new Map<string, MessageHandler[]>();
|
|
44
|
+
private topicHandlers = new Map<string, MessageHandler[]>();
|
|
45
|
+
private pending = new Map<
|
|
46
|
+
string,
|
|
47
|
+
{ resolve: (value: unknown) => void; reject: (error: Error) => void }
|
|
48
|
+
>();
|
|
49
|
+
|
|
50
|
+
async send(message: AgentMessage): Promise<void> {
|
|
51
|
+
const targets = Array.isArray(message.to) ? message.to : [message.to];
|
|
52
|
+
|
|
53
|
+
for (const target of targets) {
|
|
54
|
+
const handlers = this.handlers.get(target) || [];
|
|
55
|
+
for (const handler of handlers) {
|
|
56
|
+
try {
|
|
57
|
+
await handler(message);
|
|
58
|
+
} catch (error) {
|
|
59
|
+
logError(`Handler error for target ${target}`, {
|
|
60
|
+
error: error instanceof Error ? error : new Error(String(error)),
|
|
61
|
+
});
|
|
62
|
+
// Continue to next handler
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// Handle responses for pending requests
|
|
68
|
+
if (message.type === 'response' && message.correlationId) {
|
|
69
|
+
const pending = this.pending.get(message.correlationId);
|
|
70
|
+
if (pending) {
|
|
71
|
+
this.pending.delete(message.correlationId);
|
|
72
|
+
pending.resolve(message.payload);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
async broadcast(topic: string, message: AgentMessage): Promise<void> {
|
|
78
|
+
const handlers = this.topicHandlers.get(topic) || [];
|
|
79
|
+
for (const handler of handlers) {
|
|
80
|
+
await handler(message);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
subscribe(agentId: string, handler: MessageHandler): Unsubscribe {
|
|
85
|
+
const handlers = this.handlers.get(agentId) || [];
|
|
86
|
+
handlers.push(handler);
|
|
87
|
+
this.handlers.set(agentId, handlers);
|
|
88
|
+
|
|
89
|
+
return () => {
|
|
90
|
+
const idx = handlers.indexOf(handler);
|
|
91
|
+
if (idx >= 0) handlers.splice(idx, 1);
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
subscribeTopic(topic: string, handler: MessageHandler): Unsubscribe {
|
|
96
|
+
const handlers = this.topicHandlers.get(topic) || [];
|
|
97
|
+
handlers.push(handler);
|
|
98
|
+
this.topicHandlers.set(topic, handlers);
|
|
99
|
+
|
|
100
|
+
return () => {
|
|
101
|
+
const idx = handlers.indexOf(handler);
|
|
102
|
+
if (idx >= 0) handlers.splice(idx, 1);
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
async request<T, R>(from: string, to: string, payload: T, timeout = 30000): Promise<R> {
|
|
107
|
+
const correlationId = randomUUID();
|
|
108
|
+
const message: AgentMessage<T> = {
|
|
109
|
+
id: randomUUID(),
|
|
110
|
+
from,
|
|
111
|
+
to,
|
|
112
|
+
type: 'request',
|
|
113
|
+
payload,
|
|
114
|
+
correlationId,
|
|
115
|
+
timestamp: new Date().toISOString(),
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
return new Promise((resolve, reject) => {
|
|
119
|
+
const timer = setTimeout(() => {
|
|
120
|
+
this.pending.delete(correlationId);
|
|
121
|
+
reject(new Error(`Request timeout: ${to}`));
|
|
122
|
+
}, timeout);
|
|
123
|
+
|
|
124
|
+
this.pending.set(correlationId, {
|
|
125
|
+
resolve: response => {
|
|
126
|
+
clearTimeout(timer);
|
|
127
|
+
resolve(response as R);
|
|
128
|
+
},
|
|
129
|
+
reject: error => {
|
|
130
|
+
clearTimeout(timer);
|
|
131
|
+
reject(error);
|
|
132
|
+
},
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
void (async () => {
|
|
136
|
+
try {
|
|
137
|
+
await this.send(message);
|
|
138
|
+
} catch (error) {
|
|
139
|
+
reject(error as Error);
|
|
140
|
+
}
|
|
141
|
+
})();
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
}
|