@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,501 @@
|
|
|
1
|
+
import { logWarn } from "@od-oneapp/shared/logs";
|
|
2
|
+
|
|
3
|
+
//#region src/streaming/control/step-limit.ts
|
|
4
|
+
/**
|
|
5
|
+
* Creates a step counter for tracking agent execution steps.
|
|
6
|
+
*
|
|
7
|
+
* @param config - Step limit configuration.
|
|
8
|
+
* @returns StepCounter instance for tracking and controlling steps.
|
|
9
|
+
*
|
|
10
|
+
* @remarks
|
|
11
|
+
* The step counter tracks how many steps an agent has executed and
|
|
12
|
+
* provides methods to check whether execution should stop or warn.
|
|
13
|
+
*
|
|
14
|
+
* Strategies:
|
|
15
|
+
* - 'stop': shouldStop() returns true when limit is reached
|
|
16
|
+
* - 'warn': shouldWarn() returns true, shouldStop() returns false
|
|
17
|
+
* - 'continue': Both return false (only onLimitReached is called)
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```ts
|
|
21
|
+
* const counter = createStepCounter({
|
|
22
|
+
* maxSteps: 5,
|
|
23
|
+
* strategy: 'warn',
|
|
24
|
+
* onLimitReached: (count) => {
|
|
25
|
+
* sendTelemetry({ event: 'step_limit_reached', count });
|
|
26
|
+
* }
|
|
27
|
+
* });
|
|
28
|
+
*
|
|
29
|
+
* // In agent loop
|
|
30
|
+
* while (hasMoreWork) {
|
|
31
|
+
* counter.increment();
|
|
32
|
+
*
|
|
33
|
+
* if (counter.shouldWarn()) {
|
|
34
|
+
* console.warn('Step limit approaching');
|
|
35
|
+
* }
|
|
36
|
+
*
|
|
37
|
+
* if (counter.shouldStop()) {
|
|
38
|
+
* break;
|
|
39
|
+
* }
|
|
40
|
+
*
|
|
41
|
+
* await executeStep();
|
|
42
|
+
* }
|
|
43
|
+
* ```
|
|
44
|
+
*/
|
|
45
|
+
function createStepCounter(config) {
|
|
46
|
+
let count = 0;
|
|
47
|
+
const { maxSteps, onLimitReached, strategy = "stop" } = config;
|
|
48
|
+
let limitReachedCalled = false;
|
|
49
|
+
return {
|
|
50
|
+
increment() {
|
|
51
|
+
count += 1;
|
|
52
|
+
if (count >= maxSteps && !limitReachedCalled) {
|
|
53
|
+
limitReachedCalled = true;
|
|
54
|
+
onLimitReached?.(count);
|
|
55
|
+
}
|
|
56
|
+
return count;
|
|
57
|
+
},
|
|
58
|
+
getCount() {
|
|
59
|
+
return count;
|
|
60
|
+
},
|
|
61
|
+
shouldStop() {
|
|
62
|
+
if (strategy !== "stop") return false;
|
|
63
|
+
return count >= maxSteps;
|
|
64
|
+
},
|
|
65
|
+
shouldWarn() {
|
|
66
|
+
if (strategy !== "warn") return false;
|
|
67
|
+
return count >= maxSteps;
|
|
68
|
+
},
|
|
69
|
+
reset() {
|
|
70
|
+
count = 0;
|
|
71
|
+
limitReachedCalled = false;
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Creates a stopWhen condition function for AI SDK.
|
|
77
|
+
* Returns true when the step count reaches the limit.
|
|
78
|
+
*
|
|
79
|
+
* @param maxSteps - Maximum number of steps before stopping.
|
|
80
|
+
* @returns Function that takes step count and returns whether to stop.
|
|
81
|
+
*
|
|
82
|
+
* @remarks
|
|
83
|
+
* This function returns a predicate that can be used with AI SDK's
|
|
84
|
+
* stopWhen configuration to automatically stop agent loops.
|
|
85
|
+
*
|
|
86
|
+
* @example
|
|
87
|
+
* ```ts
|
|
88
|
+
* import { generateText } from 'ai';
|
|
89
|
+
*
|
|
90
|
+
* const result = await generateText({
|
|
91
|
+
* model: myModel,
|
|
92
|
+
* prompt: 'Complete this task',
|
|
93
|
+
* maxSteps: 10,
|
|
94
|
+
* stopWhen: createStepLimitCondition(10)
|
|
95
|
+
* });
|
|
96
|
+
* ```
|
|
97
|
+
*/
|
|
98
|
+
function createStepLimitCondition(maxSteps) {
|
|
99
|
+
return (state) => {
|
|
100
|
+
return state.steps >= maxSteps;
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Creates a step limiter that wraps an async function with step counting.
|
|
105
|
+
*
|
|
106
|
+
* @param config - Step limit configuration.
|
|
107
|
+
* @param fn - Async function to wrap with step limiting.
|
|
108
|
+
* @returns Wrapped function that increments counter before each call.
|
|
109
|
+
*
|
|
110
|
+
* @example
|
|
111
|
+
* ```ts
|
|
112
|
+
* const executeStep = async () => {
|
|
113
|
+
* // ... perform step logic
|
|
114
|
+
* };
|
|
115
|
+
*
|
|
116
|
+
* const limitedExecuteStep = withStepLimit(
|
|
117
|
+
* { maxSteps: 5, strategy: 'stop' },
|
|
118
|
+
* executeStep
|
|
119
|
+
* );
|
|
120
|
+
*
|
|
121
|
+
* // Will throw after 5 calls when strategy is 'stop'
|
|
122
|
+
* await limitedExecuteStep();
|
|
123
|
+
* ```
|
|
124
|
+
*/
|
|
125
|
+
function withStepLimit(config, fn) {
|
|
126
|
+
const counter = createStepCounter(config);
|
|
127
|
+
return async (...args) => {
|
|
128
|
+
if (counter.shouldStop()) throw new StepLimitExceededError(counter.getCount(), config.maxSteps);
|
|
129
|
+
counter.increment();
|
|
130
|
+
return fn(...args);
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Error thrown when step limit is exceeded with 'stop' strategy.
|
|
135
|
+
*/
|
|
136
|
+
var StepLimitExceededError = class extends Error {
|
|
137
|
+
/** Current step count when error was thrown. */
|
|
138
|
+
stepCount;
|
|
139
|
+
/** Maximum steps that were configured. */
|
|
140
|
+
maxSteps;
|
|
141
|
+
constructor(stepCount, maxSteps) {
|
|
142
|
+
super(`Step limit exceeded: ${stepCount}/${maxSteps} steps`);
|
|
143
|
+
this.name = "StepLimitExceededError";
|
|
144
|
+
this.stepCount = stepCount;
|
|
145
|
+
this.maxSteps = maxSteps;
|
|
146
|
+
}
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
//#endregion
|
|
150
|
+
//#region src/streaming/control/smoothing.ts
|
|
151
|
+
/** Default delay in milliseconds between chunks. */
|
|
152
|
+
const DEFAULT_DELAY_MS = 10;
|
|
153
|
+
/** Default chunking strategy. */
|
|
154
|
+
const DEFAULT_CHUNKING = "word";
|
|
155
|
+
/**
|
|
156
|
+
* Creates a smooth stream transform configuration for AI SDK.
|
|
157
|
+
*
|
|
158
|
+
* @param config - Optional smooth stream configuration.
|
|
159
|
+
* @returns Transform configuration compatible with AI SDK's smoothStream.
|
|
160
|
+
*
|
|
161
|
+
* @remarks
|
|
162
|
+
* Stream smoothing helps create a more natural reading experience by:
|
|
163
|
+
* - Adding small delays between chunks to simulate typing
|
|
164
|
+
* - Chunking text at natural boundaries (words, lines, sentences)
|
|
165
|
+
* - Preventing overwhelming the UI with rapid updates
|
|
166
|
+
*
|
|
167
|
+
* Chunking strategies:
|
|
168
|
+
* - 'word': Emit at word boundaries (recommended for most cases)
|
|
169
|
+
* - 'line': Emit at line breaks
|
|
170
|
+
* - 'sentence': Emit at sentence boundaries
|
|
171
|
+
*
|
|
172
|
+
* @example
|
|
173
|
+
* ```ts
|
|
174
|
+
* // Default configuration (10ms delay, word chunking)
|
|
175
|
+
* const defaultTransform = createSmoothStreamTransform();
|
|
176
|
+
*
|
|
177
|
+
* // Custom configuration
|
|
178
|
+
* const customTransform = createSmoothStreamTransform({
|
|
179
|
+
* delayInMs: 30,
|
|
180
|
+
* chunking: 'sentence'
|
|
181
|
+
* });
|
|
182
|
+
* ```
|
|
183
|
+
*/
|
|
184
|
+
function createSmoothStreamTransform(config) {
|
|
185
|
+
const chunking = config?.chunking ?? DEFAULT_CHUNKING;
|
|
186
|
+
return {
|
|
187
|
+
delayInMs: config?.delayInMs ?? DEFAULT_DELAY_MS,
|
|
188
|
+
chunking
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Regex patterns for different chunking strategies.
|
|
193
|
+
* Used to split text into chunks at natural boundaries.
|
|
194
|
+
* @internal
|
|
195
|
+
*/
|
|
196
|
+
const CHUNKING_PATTERNS = {
|
|
197
|
+
word: /\s+/,
|
|
198
|
+
line: /\n/,
|
|
199
|
+
sentence: /(?<=[.!?])\s+/
|
|
200
|
+
};
|
|
201
|
+
/**
|
|
202
|
+
* Splits text into chunks based on the configured strategy.
|
|
203
|
+
*
|
|
204
|
+
* @param text - Text to split into chunks.
|
|
205
|
+
* @param chunking - Chunking strategy to use.
|
|
206
|
+
* @param minChunkSize - Minimum chunk size before emitting.
|
|
207
|
+
* @returns Array of text chunks.
|
|
208
|
+
*
|
|
209
|
+
* @example
|
|
210
|
+
* ```ts
|
|
211
|
+
* const chunks = splitIntoChunks('Hello world. How are you?', 'sentence');
|
|
212
|
+
* // chunks = ['Hello world. ', 'How are you?']
|
|
213
|
+
* ```
|
|
214
|
+
*/
|
|
215
|
+
function splitIntoChunks(text, chunking = "word", minChunkSize = 1) {
|
|
216
|
+
const pattern = CHUNKING_PATTERNS[chunking];
|
|
217
|
+
const parts = text.split(pattern);
|
|
218
|
+
if (minChunkSize <= 1) return parts.filter(Boolean);
|
|
219
|
+
const chunks = [];
|
|
220
|
+
let buffer = "";
|
|
221
|
+
for (const part of parts) {
|
|
222
|
+
buffer += part;
|
|
223
|
+
if (buffer.length >= minChunkSize) {
|
|
224
|
+
chunks.push(buffer);
|
|
225
|
+
buffer = "";
|
|
226
|
+
} else if (chunking !== "word") buffer += chunking === "line" ? "\n" : " ";
|
|
227
|
+
else buffer += " ";
|
|
228
|
+
}
|
|
229
|
+
if (buffer.trim()) chunks.push(buffer.trim());
|
|
230
|
+
return chunks;
|
|
231
|
+
}
|
|
232
|
+
/**
|
|
233
|
+
* Creates an async generator that yields text chunks with delays.
|
|
234
|
+
*
|
|
235
|
+
* @param text - Text to stream.
|
|
236
|
+
* @param config - Smooth stream configuration.
|
|
237
|
+
* @yields Text chunks with configured delays.
|
|
238
|
+
*
|
|
239
|
+
* @example
|
|
240
|
+
* ```ts
|
|
241
|
+
* for await (const chunk of smoothTextGenerator('Hello world!', { delayInMs: 50 })) {
|
|
242
|
+
* process.stdout.write(chunk);
|
|
243
|
+
* }
|
|
244
|
+
* ```
|
|
245
|
+
*/
|
|
246
|
+
async function* smoothTextGenerator(text, config) {
|
|
247
|
+
const delay = config?.delayInMs ?? DEFAULT_DELAY_MS;
|
|
248
|
+
const chunks = splitIntoChunks(text, config?.chunking ?? DEFAULT_CHUNKING, config?.minChunkSize ?? 1);
|
|
249
|
+
for (const chunk of chunks) {
|
|
250
|
+
yield chunk;
|
|
251
|
+
if (delay > 0) await new Promise((resolve) => setTimeout(resolve, delay));
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
/**
|
|
255
|
+
* Wraps an async iterable to add smooth streaming delays.
|
|
256
|
+
*
|
|
257
|
+
* @param source - Source async iterable of text chunks.
|
|
258
|
+
* @param config - Smooth stream configuration.
|
|
259
|
+
* @yields Text chunks with configured delays.
|
|
260
|
+
*
|
|
261
|
+
* @example
|
|
262
|
+
* ```ts
|
|
263
|
+
* const source = getStreamFromModel();
|
|
264
|
+
* const smoothed = withSmoothStream(source, { delayInMs: 20 });
|
|
265
|
+
*
|
|
266
|
+
* for await (const chunk of smoothed) {
|
|
267
|
+
* // Chunks arrive with smooth delays
|
|
268
|
+
* }
|
|
269
|
+
* ```
|
|
270
|
+
*/
|
|
271
|
+
async function* withSmoothStream(source, config) {
|
|
272
|
+
const delay = config?.delayInMs ?? DEFAULT_DELAY_MS;
|
|
273
|
+
for await (const chunk of source) {
|
|
274
|
+
yield chunk;
|
|
275
|
+
if (delay > 0) await new Promise((resolve) => setTimeout(resolve, delay));
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
//#endregion
|
|
280
|
+
//#region src/streaming/control/controller.ts
|
|
281
|
+
/**
|
|
282
|
+
* @fileoverview Stream controller for fluent composition.
|
|
283
|
+
* @module @od-oneapp/ai-platform/streaming-control
|
|
284
|
+
*
|
|
285
|
+
* Provides a fluent API for composing streaming control configurations:
|
|
286
|
+
* - Budget guards for token and cost limits
|
|
287
|
+
* - Step limits for agent loop control
|
|
288
|
+
* - Stream smoothing for improved UX
|
|
289
|
+
*
|
|
290
|
+
* @example
|
|
291
|
+
* ```ts
|
|
292
|
+
* import { createStreamController } from '@od-oneapp/ai-platform/streaming-control';
|
|
293
|
+
*
|
|
294
|
+
* const controller = createStreamController()
|
|
295
|
+
* .withBudgetGuard({
|
|
296
|
+
* maxTokens: 100_000,
|
|
297
|
+
* maxCost: 10.00,
|
|
298
|
+
* onBudgetExceeded: (usage, limit) => {
|
|
299
|
+
* console.error(`Budget exceeded: ${limit.type}`);
|
|
300
|
+
* }
|
|
301
|
+
* })
|
|
302
|
+
* .withStepLimit({
|
|
303
|
+
* maxSteps: 10,
|
|
304
|
+
* strategy: 'stop',
|
|
305
|
+
* onLimitReached: (count) => {
|
|
306
|
+
* console.log(`Reached ${count} steps`);
|
|
307
|
+
* }
|
|
308
|
+
* })
|
|
309
|
+
* .withSmoothStream({
|
|
310
|
+
* delayInMs: 20,
|
|
311
|
+
* chunking: 'word'
|
|
312
|
+
* });
|
|
313
|
+
*
|
|
314
|
+
* const config = controller.getConfig();
|
|
315
|
+
* ```
|
|
316
|
+
*/
|
|
317
|
+
/**
|
|
318
|
+
* Internal implementation of StreamController.
|
|
319
|
+
* @internal
|
|
320
|
+
*/
|
|
321
|
+
var StreamControllerImpl = class StreamControllerImpl {
|
|
322
|
+
config;
|
|
323
|
+
constructor(initialConfig = {}) {
|
|
324
|
+
this.config = { ...initialConfig };
|
|
325
|
+
}
|
|
326
|
+
/**
|
|
327
|
+
* Adds budget guard configuration.
|
|
328
|
+
* Merges with existing budget guard config if present.
|
|
329
|
+
*/
|
|
330
|
+
withBudgetGuard(budgetConfig) {
|
|
331
|
+
return new StreamControllerImpl({
|
|
332
|
+
...this.config,
|
|
333
|
+
budgetGuard: {
|
|
334
|
+
...this.config.budgetGuard,
|
|
335
|
+
...budgetConfig,
|
|
336
|
+
costTable: {
|
|
337
|
+
...this.config.budgetGuard?.costTable,
|
|
338
|
+
...budgetConfig.costTable
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
});
|
|
342
|
+
}
|
|
343
|
+
/**
|
|
344
|
+
* Adds step limit configuration.
|
|
345
|
+
* Replaces existing step limit config if present.
|
|
346
|
+
*/
|
|
347
|
+
withStepLimit(stepConfig) {
|
|
348
|
+
return new StreamControllerImpl({
|
|
349
|
+
...this.config,
|
|
350
|
+
stepLimit: stepConfig
|
|
351
|
+
});
|
|
352
|
+
}
|
|
353
|
+
/**
|
|
354
|
+
* Adds smooth stream configuration.
|
|
355
|
+
* Merges with existing smooth stream config if present.
|
|
356
|
+
*/
|
|
357
|
+
withSmoothStream(smoothConfig) {
|
|
358
|
+
return new StreamControllerImpl({
|
|
359
|
+
...this.config,
|
|
360
|
+
smoothStream: {
|
|
361
|
+
...this.config.smoothStream,
|
|
362
|
+
...smoothConfig
|
|
363
|
+
}
|
|
364
|
+
});
|
|
365
|
+
}
|
|
366
|
+
/**
|
|
367
|
+
* Gets the combined configuration.
|
|
368
|
+
*/
|
|
369
|
+
getConfig() {
|
|
370
|
+
return { ...this.config };
|
|
371
|
+
}
|
|
372
|
+
};
|
|
373
|
+
/**
|
|
374
|
+
* Creates a new stream controller for fluent composition.
|
|
375
|
+
*
|
|
376
|
+
* @param initialConfig - Optional initial configuration.
|
|
377
|
+
* @returns StreamController instance for chaining.
|
|
378
|
+
*
|
|
379
|
+
* @remarks
|
|
380
|
+
* The stream controller provides a fluent API for building
|
|
381
|
+
* streaming control configurations. Each method returns a new
|
|
382
|
+
* controller instance, making the configuration immutable.
|
|
383
|
+
*
|
|
384
|
+
* @example
|
|
385
|
+
* ```ts
|
|
386
|
+
* // Basic usage
|
|
387
|
+
* const controller = createStreamController()
|
|
388
|
+
* .withBudgetGuard({ maxTokens: 50_000 })
|
|
389
|
+
* .withStepLimit({ maxSteps: 5 });
|
|
390
|
+
*
|
|
391
|
+
* // With initial config
|
|
392
|
+
* const controller2 = createStreamController({
|
|
393
|
+
* smoothStream: { delayInMs: 10 }
|
|
394
|
+
* }).withBudgetGuard({ maxCost: 5.00 });
|
|
395
|
+
*
|
|
396
|
+
* // Get final config
|
|
397
|
+
* const config = controller.getConfig();
|
|
398
|
+
* // config = {
|
|
399
|
+
* // budgetGuard: { maxTokens: 50_000 },
|
|
400
|
+
* // stepLimit: { maxSteps: 5 }
|
|
401
|
+
* // }
|
|
402
|
+
* ```
|
|
403
|
+
*/
|
|
404
|
+
function createStreamController(initialConfig) {
|
|
405
|
+
return new StreamControllerImpl(initialConfig);
|
|
406
|
+
}
|
|
407
|
+
/**
|
|
408
|
+
* Merges multiple stream controller configs into one.
|
|
409
|
+
*
|
|
410
|
+
* @param configs - Array of configs to merge.
|
|
411
|
+
* @returns Merged StreamControllerConfig.
|
|
412
|
+
*
|
|
413
|
+
* @example
|
|
414
|
+
* ```ts
|
|
415
|
+
* const budgetConfig = createStreamController()
|
|
416
|
+
* .withBudgetGuard({ maxTokens: 100_000 })
|
|
417
|
+
* .getConfig();
|
|
418
|
+
*
|
|
419
|
+
* const stepConfig = createStreamController()
|
|
420
|
+
* .withStepLimit({ maxSteps: 10 })
|
|
421
|
+
* .getConfig();
|
|
422
|
+
*
|
|
423
|
+
* const merged = mergeStreamConfigs([budgetConfig, stepConfig]);
|
|
424
|
+
* ```
|
|
425
|
+
*/
|
|
426
|
+
function mergeStreamConfigs(configs) {
|
|
427
|
+
let result = createStreamController();
|
|
428
|
+
for (const config of configs) {
|
|
429
|
+
if (config.budgetGuard) result = result.withBudgetGuard(config.budgetGuard);
|
|
430
|
+
if (config.stepLimit) result = result.withStepLimit(config.stepLimit);
|
|
431
|
+
if (config.smoothStream) result = result.withSmoothStream(config.smoothStream);
|
|
432
|
+
}
|
|
433
|
+
return result.getConfig();
|
|
434
|
+
}
|
|
435
|
+
/**
|
|
436
|
+
* Creates a preset configuration for development/testing.
|
|
437
|
+
* Higher limits and verbose callbacks.
|
|
438
|
+
*
|
|
439
|
+
* @returns StreamController with development presets.
|
|
440
|
+
*
|
|
441
|
+
* @example
|
|
442
|
+
* ```ts
|
|
443
|
+
* const devController = createDevStreamController();
|
|
444
|
+
* const config = devController.getConfig();
|
|
445
|
+
* ```
|
|
446
|
+
*/
|
|
447
|
+
function createDevStreamController() {
|
|
448
|
+
return createStreamController().withBudgetGuard({
|
|
449
|
+
maxTokens: 5e5,
|
|
450
|
+
maxCost: 50,
|
|
451
|
+
onBudgetExceeded: (usage, limit) => {
|
|
452
|
+
logWarn("[DEV] Budget exceeded", {
|
|
453
|
+
usage,
|
|
454
|
+
limit
|
|
455
|
+
});
|
|
456
|
+
}
|
|
457
|
+
}).withStepLimit({
|
|
458
|
+
maxSteps: 20,
|
|
459
|
+
strategy: "warn",
|
|
460
|
+
onLimitReached: (count) => {
|
|
461
|
+
logWarn("[DEV] Step limit reached", { count });
|
|
462
|
+
}
|
|
463
|
+
}).withSmoothStream({
|
|
464
|
+
delayInMs: 5,
|
|
465
|
+
chunking: "word"
|
|
466
|
+
});
|
|
467
|
+
}
|
|
468
|
+
/**
|
|
469
|
+
* Creates a preset configuration for production.
|
|
470
|
+
* Conservative limits and minimal overhead.
|
|
471
|
+
*
|
|
472
|
+
* @param options - Production configuration options.
|
|
473
|
+
* @returns StreamController with production presets.
|
|
474
|
+
*
|
|
475
|
+
* @example
|
|
476
|
+
* ```ts
|
|
477
|
+
* const prodController = createProdStreamController({
|
|
478
|
+
* maxTokens: 100_000,
|
|
479
|
+
* maxCost: 10.00,
|
|
480
|
+
* maxSteps: 10
|
|
481
|
+
* });
|
|
482
|
+
* ```
|
|
483
|
+
*/
|
|
484
|
+
function createProdStreamController(options) {
|
|
485
|
+
return createStreamController().withBudgetGuard({
|
|
486
|
+
maxTokens: options?.maxTokens ?? 1e5,
|
|
487
|
+
maxCost: options?.maxCost ?? 10,
|
|
488
|
+
onBudgetExceeded: options?.onBudgetExceeded
|
|
489
|
+
}).withStepLimit({
|
|
490
|
+
maxSteps: options?.maxSteps ?? 10,
|
|
491
|
+
strategy: "stop",
|
|
492
|
+
onLimitReached: options?.onStepLimitReached
|
|
493
|
+
}).withSmoothStream({
|
|
494
|
+
delayInMs: 10,
|
|
495
|
+
chunking: "word"
|
|
496
|
+
});
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
//#endregion
|
|
500
|
+
export { createSmoothStreamTransform as a, withSmoothStream as c, createStepLimitCondition as d, withStepLimit as f, mergeStreamConfigs as i, StepLimitExceededError as l, createProdStreamController as n, smoothTextGenerator as o, createStreamController as r, splitIntoChunks as s, createDevStreamController as t, createStepCounter as u };
|
|
501
|
+
//# sourceMappingURL=controller-BOy3-xbC.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"controller-BOy3-xbC.mjs","names":[],"sources":["../src/streaming/control/step-limit.ts","../src/streaming/control/smoothing.ts","../src/streaming/control/controller.ts"],"sourcesContent":["/**\n * @fileoverview Step limit utilities for agent loop control.\n * @module @od-oneapp/ai-platform/streaming-control\n *\n * Provides functions for controlling agent execution steps:\n * - Step counter with configurable strategies\n * - Stop condition generators for AI SDK integration\n *\n * @example\n * ```ts\n * import { createStepCounter, createStepLimitCondition } from '@od-oneapp/ai-platform/streaming-control';\n *\n * const counter = createStepCounter({\n * maxSteps: 10,\n * strategy: 'stop',\n * onLimitReached: (count) => console.log(`Reached ${count} steps`)\n * });\n *\n * counter.increment();\n * if (counter.shouldStop()) {\n * // Stop agent execution\n * }\n * ```\n */\n\nimport { type StepCounter, type StepLimitConfig } from './types';\n\n/**\n * Creates a step counter for tracking agent execution steps.\n *\n * @param config - Step limit configuration.\n * @returns StepCounter instance for tracking and controlling steps.\n *\n * @remarks\n * The step counter tracks how many steps an agent has executed and\n * provides methods to check whether execution should stop or warn.\n *\n * Strategies:\n * - 'stop': shouldStop() returns true when limit is reached\n * - 'warn': shouldWarn() returns true, shouldStop() returns false\n * - 'continue': Both return false (only onLimitReached is called)\n *\n * @example\n * ```ts\n * const counter = createStepCounter({\n * maxSteps: 5,\n * strategy: 'warn',\n * onLimitReached: (count) => {\n * sendTelemetry({ event: 'step_limit_reached', count });\n * }\n * });\n *\n * // In agent loop\n * while (hasMoreWork) {\n * counter.increment();\n *\n * if (counter.shouldWarn()) {\n * console.warn('Step limit approaching');\n * }\n *\n * if (counter.shouldStop()) {\n * break;\n * }\n *\n * await executeStep();\n * }\n * ```\n */\nexport function createStepCounter(config: StepLimitConfig): StepCounter {\n let count = 0;\n const { maxSteps, onLimitReached, strategy = 'stop' } = config;\n let limitReachedCalled = false;\n\n return {\n /**\n * Increments the step counter.\n * Calls onLimitReached when limit is first reached.\n * @returns The new step count.\n */\n increment(): number {\n count += 1;\n\n if (count >= maxSteps && !limitReachedCalled) {\n limitReachedCalled = true;\n onLimitReached?.(count);\n }\n\n return count;\n },\n\n /**\n * Gets the current step count.\n * @returns Current number of steps executed.\n */\n getCount(): number {\n return count;\n },\n\n /**\n * Checks if agent should stop based on strategy.\n * @returns true if strategy is 'stop' and limit is reached.\n */\n shouldStop(): boolean {\n if (strategy !== 'stop') {\n return false;\n }\n return count >= maxSteps;\n },\n\n /**\n * Checks if a warning should be emitted.\n * @returns true if strategy is 'warn' and limit is reached.\n */\n shouldWarn(): boolean {\n if (strategy !== 'warn') {\n return false;\n }\n return count >= maxSteps;\n },\n\n /**\n * Resets the counter to zero.\n */\n reset(): void {\n count = 0;\n limitReachedCalled = false;\n },\n };\n}\n\n/**\n * Creates a stopWhen condition function for AI SDK.\n * Returns true when the step count reaches the limit.\n *\n * @param maxSteps - Maximum number of steps before stopping.\n * @returns Function that takes step count and returns whether to stop.\n *\n * @remarks\n * This function returns a predicate that can be used with AI SDK's\n * stopWhen configuration to automatically stop agent loops.\n *\n * @example\n * ```ts\n * import { generateText } from 'ai';\n *\n * const result = await generateText({\n * model: myModel,\n * prompt: 'Complete this task',\n * maxSteps: 10,\n * stopWhen: createStepLimitCondition(10)\n * });\n * ```\n */\nexport function createStepLimitCondition(maxSteps: number): (state: { steps: number }) => boolean {\n return (state: { steps: number }): boolean => {\n return state.steps >= maxSteps;\n };\n}\n\n/**\n * Creates a step limiter that wraps an async function with step counting.\n *\n * @param config - Step limit configuration.\n * @param fn - Async function to wrap with step limiting.\n * @returns Wrapped function that increments counter before each call.\n *\n * @example\n * ```ts\n * const executeStep = async () => {\n * // ... perform step logic\n * };\n *\n * const limitedExecuteStep = withStepLimit(\n * { maxSteps: 5, strategy: 'stop' },\n * executeStep\n * );\n *\n * // Will throw after 5 calls when strategy is 'stop'\n * await limitedExecuteStep();\n * ```\n */\nexport function withStepLimit<TArgs extends unknown[], TResult>(\n config: StepLimitConfig,\n fn: (...args: TArgs) => Promise<TResult>,\n): (...args: TArgs) => Promise<TResult> {\n const counter = createStepCounter(config);\n\n return async (...args: TArgs): Promise<TResult> => {\n // Check if we've already reached the limit before executing\n if (counter.shouldStop()) {\n throw new StepLimitExceededError(counter.getCount(), config.maxSteps);\n }\n\n counter.increment();\n\n return fn(...args);\n };\n}\n\n/**\n * Error thrown when step limit is exceeded with 'stop' strategy.\n */\nexport class StepLimitExceededError extends Error {\n /** Current step count when error was thrown. */\n readonly stepCount: number;\n /** Maximum steps that were configured. */\n readonly maxSteps: number;\n\n constructor(stepCount: number, maxSteps: number) {\n super(`Step limit exceeded: ${stepCount}/${maxSteps} steps`);\n this.name = 'StepLimitExceededError';\n this.stepCount = stepCount;\n this.maxSteps = maxSteps;\n }\n}\n","/**\n * @fileoverview Stream smoothing utilities for improved UX.\n * @module @od-oneapp/ai-platform/streaming-control\n *\n * Provides utilities for smoothing streaming responses:\n * - Transform configuration for AI SDK's smoothStream option\n * - Chunking strategies (word, line, sentence)\n * - Configurable delay between chunks\n *\n * @example\n * ```ts\n * import { createSmoothStreamTransform } from '@od-oneapp/ai-platform/streaming-control';\n * import { streamText, smoothStream } from 'ai';\n *\n * const transform = createSmoothStreamTransform({\n * delayInMs: 20,\n * chunking: 'word'\n * });\n *\n * const result = await streamText({\n * model: myModel,\n * prompt: 'Hello',\n * experimental_transform: smoothStream(transform)\n * });\n * ```\n */\n\nimport { type SmoothStreamConfig, type SmoothStreamTransform } from './types';\n\n/** Default delay in milliseconds between chunks. */\nconst DEFAULT_DELAY_MS = 10;\n\n/** Default chunking strategy. */\nconst DEFAULT_CHUNKING = 'word' as const;\n\n/**\n * Creates a smooth stream transform configuration for AI SDK.\n *\n * @param config - Optional smooth stream configuration.\n * @returns Transform configuration compatible with AI SDK's smoothStream.\n *\n * @remarks\n * Stream smoothing helps create a more natural reading experience by:\n * - Adding small delays between chunks to simulate typing\n * - Chunking text at natural boundaries (words, lines, sentences)\n * - Preventing overwhelming the UI with rapid updates\n *\n * Chunking strategies:\n * - 'word': Emit at word boundaries (recommended for most cases)\n * - 'line': Emit at line breaks\n * - 'sentence': Emit at sentence boundaries\n *\n * @example\n * ```ts\n * // Default configuration (10ms delay, word chunking)\n * const defaultTransform = createSmoothStreamTransform();\n *\n * // Custom configuration\n * const customTransform = createSmoothStreamTransform({\n * delayInMs: 30,\n * chunking: 'sentence'\n * });\n * ```\n */\nexport function createSmoothStreamTransform(config?: SmoothStreamConfig): SmoothStreamTransform {\n const chunking: 'word' | 'line' | 'sentence' = config?.chunking ?? DEFAULT_CHUNKING;\n return {\n delayInMs: config?.delayInMs ?? DEFAULT_DELAY_MS,\n chunking,\n };\n}\n\n/**\n * Regex patterns for different chunking strategies.\n * Used to split text into chunks at natural boundaries.\n * @internal\n */\nconst CHUNKING_PATTERNS: Record<NonNullable<SmoothStreamConfig['chunking']>, RegExp> = {\n word: /\\s+/,\n line: /\\n/,\n sentence: /(?<=[.!?])\\s+/,\n};\n\n/**\n * Splits text into chunks based on the configured strategy.\n *\n * @param text - Text to split into chunks.\n * @param chunking - Chunking strategy to use.\n * @param minChunkSize - Minimum chunk size before emitting.\n * @returns Array of text chunks.\n *\n * @example\n * ```ts\n * const chunks = splitIntoChunks('Hello world. How are you?', 'sentence');\n * // chunks = ['Hello world. ', 'How are you?']\n * ```\n */\nexport function splitIntoChunks(\n text: string,\n chunking: NonNullable<SmoothStreamConfig['chunking']> = 'word',\n minChunkSize = 1,\n): string[] {\n const pattern = CHUNKING_PATTERNS[chunking];\n const parts = text.split(pattern);\n\n if (minChunkSize <= 1) {\n return parts.filter(Boolean);\n }\n\n // Combine small chunks to meet minimum size\n const chunks: string[] = [];\n let buffer = '';\n\n for (const part of parts) {\n buffer += part;\n\n if (buffer.length >= minChunkSize) {\n chunks.push(buffer);\n buffer = '';\n } else {\n // Add back the delimiter for non-word chunking\n if (chunking !== 'word') {\n buffer += chunking === 'line' ? '\\n' : ' ';\n } else {\n buffer += ' ';\n }\n }\n }\n\n // Push any remaining buffer\n if (buffer.trim()) {\n chunks.push(buffer.trim());\n }\n\n return chunks;\n}\n\n/**\n * Creates an async generator that yields text chunks with delays.\n *\n * @param text - Text to stream.\n * @param config - Smooth stream configuration.\n * @yields Text chunks with configured delays.\n *\n * @example\n * ```ts\n * for await (const chunk of smoothTextGenerator('Hello world!', { delayInMs: 50 })) {\n * process.stdout.write(chunk);\n * }\n * ```\n */\nexport async function* smoothTextGenerator(\n text: string,\n config?: SmoothStreamConfig,\n): AsyncGenerator<string> {\n const delay = config?.delayInMs ?? DEFAULT_DELAY_MS;\n const chunking = config?.chunking ?? DEFAULT_CHUNKING;\n const minChunkSize = config?.minChunkSize ?? 1;\n\n const chunks = splitIntoChunks(text, chunking, minChunkSize);\n\n for (const chunk of chunks) {\n yield chunk;\n\n if (delay > 0) {\n await new Promise(resolve => setTimeout(resolve, delay));\n }\n }\n}\n\n/**\n * Wraps an async iterable to add smooth streaming delays.\n *\n * @param source - Source async iterable of text chunks.\n * @param config - Smooth stream configuration.\n * @yields Text chunks with configured delays.\n *\n * @example\n * ```ts\n * const source = getStreamFromModel();\n * const smoothed = withSmoothStream(source, { delayInMs: 20 });\n *\n * for await (const chunk of smoothed) {\n * // Chunks arrive with smooth delays\n * }\n * ```\n */\nexport async function* withSmoothStream(\n source: AsyncIterable<string>,\n config?: SmoothStreamConfig,\n): AsyncGenerator<string> {\n const delay = config?.delayInMs ?? DEFAULT_DELAY_MS;\n\n for await (const chunk of source) {\n yield chunk;\n\n if (delay > 0) {\n await new Promise(resolve => setTimeout(resolve, delay));\n }\n }\n}\n","/**\n * @fileoverview Stream controller for fluent composition.\n * @module @od-oneapp/ai-platform/streaming-control\n *\n * Provides a fluent API for composing streaming control configurations:\n * - Budget guards for token and cost limits\n * - Step limits for agent loop control\n * - Stream smoothing for improved UX\n *\n * @example\n * ```ts\n * import { createStreamController } from '@od-oneapp/ai-platform/streaming-control';\n *\n * const controller = createStreamController()\n * .withBudgetGuard({\n * maxTokens: 100_000,\n * maxCost: 10.00,\n * onBudgetExceeded: (usage, limit) => {\n * console.error(`Budget exceeded: ${limit.type}`);\n * }\n * })\n * .withStepLimit({\n * maxSteps: 10,\n * strategy: 'stop',\n * onLimitReached: (count) => {\n * console.log(`Reached ${count} steps`);\n * }\n * })\n * .withSmoothStream({\n * delayInMs: 20,\n * chunking: 'word'\n * });\n *\n * const config = controller.getConfig();\n * ```\n */\n\nimport { logWarn } from '@repo/shared/logs';\n\nimport {\n type BudgetGuardConfig,\n type SmoothStreamConfig,\n type StepLimitConfig,\n type StreamController,\n type StreamControllerConfig,\n} from './types';\n\n/**\n * Internal implementation of StreamController.\n * @internal\n */\nclass StreamControllerImpl implements StreamController {\n private config: StreamControllerConfig;\n\n constructor(initialConfig: StreamControllerConfig = {}) {\n this.config = { ...initialConfig };\n }\n\n /**\n * Adds budget guard configuration.\n * Merges with existing budget guard config if present.\n */\n withBudgetGuard(budgetConfig: BudgetGuardConfig): StreamController {\n return new StreamControllerImpl({\n ...this.config,\n budgetGuard: {\n ...this.config.budgetGuard,\n ...budgetConfig,\n // Merge cost tables if both exist\n costTable: {\n ...this.config.budgetGuard?.costTable,\n ...budgetConfig.costTable,\n },\n },\n });\n }\n\n /**\n * Adds step limit configuration.\n * Replaces existing step limit config if present.\n */\n withStepLimit(stepConfig: StepLimitConfig): StreamController {\n return new StreamControllerImpl({\n ...this.config,\n stepLimit: stepConfig,\n });\n }\n\n /**\n * Adds smooth stream configuration.\n * Merges with existing smooth stream config if present.\n */\n withSmoothStream(smoothConfig: SmoothStreamConfig): StreamController {\n return new StreamControllerImpl({\n ...this.config,\n smoothStream: {\n ...this.config.smoothStream,\n ...smoothConfig,\n },\n });\n }\n\n /**\n * Gets the combined configuration.\n */\n getConfig(): StreamControllerConfig {\n return { ...this.config };\n }\n}\n\n/**\n * Creates a new stream controller for fluent composition.\n *\n * @param initialConfig - Optional initial configuration.\n * @returns StreamController instance for chaining.\n *\n * @remarks\n * The stream controller provides a fluent API for building\n * streaming control configurations. Each method returns a new\n * controller instance, making the configuration immutable.\n *\n * @example\n * ```ts\n * // Basic usage\n * const controller = createStreamController()\n * .withBudgetGuard({ maxTokens: 50_000 })\n * .withStepLimit({ maxSteps: 5 });\n *\n * // With initial config\n * const controller2 = createStreamController({\n * smoothStream: { delayInMs: 10 }\n * }).withBudgetGuard({ maxCost: 5.00 });\n *\n * // Get final config\n * const config = controller.getConfig();\n * // config = {\n * // budgetGuard: { maxTokens: 50_000 },\n * // stepLimit: { maxSteps: 5 }\n * // }\n * ```\n */\nexport function createStreamController(initialConfig?: StreamControllerConfig): StreamController {\n return new StreamControllerImpl(initialConfig);\n}\n\n/**\n * Merges multiple stream controller configs into one.\n *\n * @param configs - Array of configs to merge.\n * @returns Merged StreamControllerConfig.\n *\n * @example\n * ```ts\n * const budgetConfig = createStreamController()\n * .withBudgetGuard({ maxTokens: 100_000 })\n * .getConfig();\n *\n * const stepConfig = createStreamController()\n * .withStepLimit({ maxSteps: 10 })\n * .getConfig();\n *\n * const merged = mergeStreamConfigs([budgetConfig, stepConfig]);\n * ```\n */\nexport function mergeStreamConfigs(configs: StreamControllerConfig[]): StreamControllerConfig {\n let result = createStreamController();\n\n for (const config of configs) {\n if (config.budgetGuard) {\n result = result.withBudgetGuard(config.budgetGuard);\n }\n if (config.stepLimit) {\n result = result.withStepLimit(config.stepLimit);\n }\n if (config.smoothStream) {\n result = result.withSmoothStream(config.smoothStream);\n }\n }\n\n return result.getConfig();\n}\n\n/**\n * Creates a preset configuration for development/testing.\n * Higher limits and verbose callbacks.\n *\n * @returns StreamController with development presets.\n *\n * @example\n * ```ts\n * const devController = createDevStreamController();\n * const config = devController.getConfig();\n * ```\n */\nexport function createDevStreamController(): StreamController {\n return createStreamController()\n .withBudgetGuard({\n maxTokens: 500_000,\n maxCost: 50.0,\n onBudgetExceeded: (usage, limit) => {\n logWarn('[DEV] Budget exceeded', { usage, limit });\n },\n })\n .withStepLimit({\n maxSteps: 20,\n strategy: 'warn',\n onLimitReached: count => {\n logWarn('[DEV] Step limit reached', { count });\n },\n })\n .withSmoothStream({\n delayInMs: 5,\n chunking: 'word',\n });\n}\n\n/**\n * Creates a preset configuration for production.\n * Conservative limits and minimal overhead.\n *\n * @param options - Production configuration options.\n * @returns StreamController with production presets.\n *\n * @example\n * ```ts\n * const prodController = createProdStreamController({\n * maxTokens: 100_000,\n * maxCost: 10.00,\n * maxSteps: 10\n * });\n * ```\n */\nexport function createProdStreamController(options?: {\n maxTokens?: number;\n maxCost?: number;\n maxSteps?: number;\n onBudgetExceeded?: BudgetGuardConfig['onBudgetExceeded'];\n onStepLimitReached?: StepLimitConfig['onLimitReached'];\n}): StreamController {\n return createStreamController()\n .withBudgetGuard({\n maxTokens: options?.maxTokens ?? 100_000,\n maxCost: options?.maxCost ?? 10.0,\n onBudgetExceeded: options?.onBudgetExceeded,\n })\n .withStepLimit({\n maxSteps: options?.maxSteps ?? 10,\n strategy: 'stop',\n onLimitReached: options?.onStepLimitReached,\n })\n .withSmoothStream({\n delayInMs: 10,\n chunking: 'word',\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoEA,SAAgB,kBAAkB,QAAsC;CACtE,IAAI,QAAQ;CACZ,MAAM,EAAE,UAAU,gBAAgB,WAAW,WAAW;CACxD,IAAI,qBAAqB;AAEzB,QAAO;EAML,YAAoB;AAClB,YAAS;AAET,OAAI,SAAS,YAAY,CAAC,oBAAoB;AAC5C,yBAAqB;AACrB,qBAAiB,MAAM;;AAGzB,UAAO;;EAOT,WAAmB;AACjB,UAAO;;EAOT,aAAsB;AACpB,OAAI,aAAa,OACf,QAAO;AAET,UAAO,SAAS;;EAOlB,aAAsB;AACpB,OAAI,aAAa,OACf,QAAO;AAET,UAAO,SAAS;;EAMlB,QAAc;AACZ,WAAQ;AACR,wBAAqB;;EAExB;;;;;;;;;;;;;;;;;;;;;;;;;AA0BH,SAAgB,yBAAyB,UAAyD;AAChG,SAAQ,UAAsC;AAC5C,SAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;AA0B1B,SAAgB,cACd,QACA,IACsC;CACtC,MAAM,UAAU,kBAAkB,OAAO;AAEzC,QAAO,OAAO,GAAG,SAAkC;AAEjD,MAAI,QAAQ,YAAY,CACtB,OAAM,IAAI,uBAAuB,QAAQ,UAAU,EAAE,OAAO,SAAS;AAGvE,UAAQ,WAAW;AAEnB,SAAO,GAAG,GAAG,KAAK;;;;;;AAOtB,IAAa,yBAAb,cAA4C,MAAM;;CAEhD,AAAS;;CAET,AAAS;CAET,YAAY,WAAmB,UAAkB;AAC/C,QAAM,wBAAwB,UAAU,GAAG,SAAS,QAAQ;AAC5D,OAAK,OAAO;AACZ,OAAK,YAAY;AACjB,OAAK,WAAW;;;;;;;ACtLpB,MAAM,mBAAmB;;AAGzB,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+BzB,SAAgB,4BAA4B,QAAoD;CAC9F,MAAM,WAAyC,QAAQ,YAAY;AACnE,QAAO;EACL,WAAW,QAAQ,aAAa;EAChC;EACD;;;;;;;AAQH,MAAM,oBAAiF;CACrF,MAAM;CACN,MAAM;CACN,UAAU;CACX;;;;;;;;;;;;;;;AAgBD,SAAgB,gBACd,MACA,WAAwD,QACxD,eAAe,GACL;CACV,MAAM,UAAU,kBAAkB;CAClC,MAAM,QAAQ,KAAK,MAAM,QAAQ;AAEjC,KAAI,gBAAgB,EAClB,QAAO,MAAM,OAAO,QAAQ;CAI9B,MAAM,SAAmB,EAAE;CAC3B,IAAI,SAAS;AAEb,MAAK,MAAM,QAAQ,OAAO;AACxB,YAAU;AAEV,MAAI,OAAO,UAAU,cAAc;AACjC,UAAO,KAAK,OAAO;AACnB,YAAS;aAGL,aAAa,OACf,WAAU,aAAa,SAAS,OAAO;MAEvC,WAAU;;AAMhB,KAAI,OAAO,MAAM,CACf,QAAO,KAAK,OAAO,MAAM,CAAC;AAG5B,QAAO;;;;;;;;;;;;;;;;AAiBT,gBAAuB,oBACrB,MACA,QACwB;CACxB,MAAM,QAAQ,QAAQ,aAAa;CAInC,MAAM,SAAS,gBAAgB,MAHd,QAAQ,YAAY,kBAChB,QAAQ,gBAAgB,EAEe;AAE5D,MAAK,MAAM,SAAS,QAAQ;AAC1B,QAAM;AAEN,MAAI,QAAQ,EACV,OAAM,IAAI,SAAQ,YAAW,WAAW,SAAS,MAAM,CAAC;;;;;;;;;;;;;;;;;;;;AAsB9D,gBAAuB,iBACrB,QACA,QACwB;CACxB,MAAM,QAAQ,QAAQ,aAAa;AAEnC,YAAW,MAAM,SAAS,QAAQ;AAChC,QAAM;AAEN,MAAI,QAAQ,EACV,OAAM,IAAI,SAAQ,YAAW,WAAW,SAAS,MAAM,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AClJ9D,IAAM,uBAAN,MAAM,qBAAiD;CACrD,AAAQ;CAER,YAAY,gBAAwC,EAAE,EAAE;AACtD,OAAK,SAAS,EAAE,GAAG,eAAe;;;;;;CAOpC,gBAAgB,cAAmD;AACjE,SAAO,IAAI,qBAAqB;GAC9B,GAAG,KAAK;GACR,aAAa;IACX,GAAG,KAAK,OAAO;IACf,GAAG;IAEH,WAAW;KACT,GAAG,KAAK,OAAO,aAAa;KAC5B,GAAG,aAAa;KACjB;IACF;GACF,CAAC;;;;;;CAOJ,cAAc,YAA+C;AAC3D,SAAO,IAAI,qBAAqB;GAC9B,GAAG,KAAK;GACR,WAAW;GACZ,CAAC;;;;;;CAOJ,iBAAiB,cAAoD;AACnE,SAAO,IAAI,qBAAqB;GAC9B,GAAG,KAAK;GACR,cAAc;IACZ,GAAG,KAAK,OAAO;IACf,GAAG;IACJ;GACF,CAAC;;;;;CAMJ,YAAoC;AAClC,SAAO,EAAE,GAAG,KAAK,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmC7B,SAAgB,uBAAuB,eAA0D;AAC/F,QAAO,IAAI,qBAAqB,cAAc;;;;;;;;;;;;;;;;;;;;;AAsBhD,SAAgB,mBAAmB,SAA2D;CAC5F,IAAI,SAAS,wBAAwB;AAErC,MAAK,MAAM,UAAU,SAAS;AAC5B,MAAI,OAAO,YACT,UAAS,OAAO,gBAAgB,OAAO,YAAY;AAErD,MAAI,OAAO,UACT,UAAS,OAAO,cAAc,OAAO,UAAU;AAEjD,MAAI,OAAO,aACT,UAAS,OAAO,iBAAiB,OAAO,aAAa;;AAIzD,QAAO,OAAO,WAAW;;;;;;;;;;;;;;AAe3B,SAAgB,4BAA8C;AAC5D,QAAO,wBAAwB,CAC5B,gBAAgB;EACf,WAAW;EACX,SAAS;EACT,mBAAmB,OAAO,UAAU;AAClC,WAAQ,yBAAyB;IAAE;IAAO;IAAO,CAAC;;EAErD,CAAC,CACD,cAAc;EACb,UAAU;EACV,UAAU;EACV,iBAAgB,UAAS;AACvB,WAAQ,4BAA4B,EAAE,OAAO,CAAC;;EAEjD,CAAC,CACD,iBAAiB;EAChB,WAAW;EACX,UAAU;EACX,CAAC;;;;;;;;;;;;;;;;;;AAmBN,SAAgB,2BAA2B,SAMtB;AACnB,QAAO,wBAAwB,CAC5B,gBAAgB;EACf,WAAW,SAAS,aAAa;EACjC,SAAS,SAAS,WAAW;EAC7B,kBAAkB,SAAS;EAC5B,CAAC,CACD,cAAc;EACb,UAAU,SAAS,YAAY;EAC/B,UAAU;EACV,gBAAgB,SAAS;EAC1B,CAAC,CACD,iBAAiB;EAChB,WAAW;EACX,UAAU;EACX,CAAC"}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
//#region src/streaming/control/types.d.ts
|
|
2
|
+
interface TokenUsage {
|
|
3
|
+
readonly promptTokens: number;
|
|
4
|
+
readonly completionTokens: number;
|
|
5
|
+
readonly totalTokens: number;
|
|
6
|
+
}
|
|
7
|
+
interface BudgetLimit {
|
|
8
|
+
readonly type: 'tokens' | 'cost';
|
|
9
|
+
readonly limit: number;
|
|
10
|
+
readonly actual: number;
|
|
11
|
+
}
|
|
12
|
+
interface CostEntry {
|
|
13
|
+
readonly input: number;
|
|
14
|
+
readonly output: number;
|
|
15
|
+
}
|
|
16
|
+
interface BudgetGuardConfig {
|
|
17
|
+
readonly maxTokens?: number;
|
|
18
|
+
readonly maxCost?: number;
|
|
19
|
+
readonly costTable?: Record<string, CostEntry>;
|
|
20
|
+
readonly onBudgetExceeded?: (usage: TokenUsage, limit: BudgetLimit) => void;
|
|
21
|
+
}
|
|
22
|
+
interface StepLimitConfig {
|
|
23
|
+
readonly maxSteps: number;
|
|
24
|
+
readonly onLimitReached?: (stepCount: number) => void;
|
|
25
|
+
readonly strategy?: 'stop' | 'warn' | 'continue';
|
|
26
|
+
}
|
|
27
|
+
interface SmoothStreamConfig {
|
|
28
|
+
readonly delayInMs?: number;
|
|
29
|
+
readonly chunking?: 'word' | 'line' | 'sentence';
|
|
30
|
+
readonly minChunkSize?: number;
|
|
31
|
+
}
|
|
32
|
+
interface StreamControllerConfig {
|
|
33
|
+
readonly budgetGuard?: BudgetGuardConfig;
|
|
34
|
+
readonly stepLimit?: StepLimitConfig;
|
|
35
|
+
readonly smoothStream?: SmoothStreamConfig;
|
|
36
|
+
}
|
|
37
|
+
interface StreamController {
|
|
38
|
+
withBudgetGuard(config: BudgetGuardConfig): StreamController;
|
|
39
|
+
withStepLimit(config: StepLimitConfig): StreamController;
|
|
40
|
+
withSmoothStream(config: SmoothStreamConfig): StreamController;
|
|
41
|
+
getConfig(): StreamControllerConfig;
|
|
42
|
+
}
|
|
43
|
+
interface BudgetCheckResult {
|
|
44
|
+
readonly exceeded: boolean;
|
|
45
|
+
readonly limit?: BudgetLimit;
|
|
46
|
+
}
|
|
47
|
+
interface StepCounter {
|
|
48
|
+
increment(): number;
|
|
49
|
+
getCount(): number;
|
|
50
|
+
shouldStop(): boolean;
|
|
51
|
+
shouldWarn(): boolean;
|
|
52
|
+
reset(): void;
|
|
53
|
+
}
|
|
54
|
+
interface SmoothStreamTransform {
|
|
55
|
+
readonly delayInMs: number;
|
|
56
|
+
readonly chunking: 'word' | 'line' | 'sentence';
|
|
57
|
+
}
|
|
58
|
+
//#endregion
|
|
59
|
+
//#region src/streaming/control/budget-guard.d.ts
|
|
60
|
+
declare const DEFAULT_COST_TABLE: Record<string, CostEntry>;
|
|
61
|
+
declare function calculateCost(usage: TokenUsage, modelId: string, costTable?: Record<string, CostEntry>): number;
|
|
62
|
+
declare function createBudgetChecker(config: BudgetGuardConfig): (usage: TokenUsage, modelId: string) => BudgetCheckResult;
|
|
63
|
+
interface OnFinishResult {
|
|
64
|
+
usage?: {
|
|
65
|
+
promptTokens: number;
|
|
66
|
+
completionTokens: number;
|
|
67
|
+
totalTokens?: number;
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
declare function createBudgetGuardedOnFinish(config: BudgetGuardConfig, modelId: string): (result: OnFinishResult) => void;
|
|
71
|
+
declare function estimateCost(estimatedPromptTokens: number, estimatedCompletionTokens: number, modelId: string, costTable?: Record<string, CostEntry>): number;
|
|
72
|
+
//#endregion
|
|
73
|
+
//#region src/streaming/control/step-limit.d.ts
|
|
74
|
+
declare function createStepCounter(config: StepLimitConfig): StepCounter;
|
|
75
|
+
declare function createStepLimitCondition(maxSteps: number): (state: {
|
|
76
|
+
steps: number;
|
|
77
|
+
}) => boolean;
|
|
78
|
+
declare function withStepLimit<TArgs extends unknown[], TResult>(config: StepLimitConfig, fn: (...args: TArgs) => Promise<TResult>): (...args: TArgs) => Promise<TResult>;
|
|
79
|
+
declare class StepLimitExceededError extends Error {
|
|
80
|
+
readonly stepCount: number;
|
|
81
|
+
readonly maxSteps: number;
|
|
82
|
+
constructor(stepCount: number, maxSteps: number);
|
|
83
|
+
}
|
|
84
|
+
//#endregion
|
|
85
|
+
//#region src/streaming/control/smoothing.d.ts
|
|
86
|
+
declare function createSmoothStreamTransform(config?: SmoothStreamConfig): SmoothStreamTransform;
|
|
87
|
+
declare function splitIntoChunks(text: string, chunking?: NonNullable<SmoothStreamConfig['chunking']>, minChunkSize?: number): string[];
|
|
88
|
+
declare function smoothTextGenerator(text: string, config?: SmoothStreamConfig): AsyncGenerator<string>;
|
|
89
|
+
declare function withSmoothStream(source: AsyncIterable<string>, config?: SmoothStreamConfig): AsyncGenerator<string>;
|
|
90
|
+
//#endregion
|
|
91
|
+
//#region src/streaming/control/controller.d.ts
|
|
92
|
+
declare function createStreamController(initialConfig?: StreamControllerConfig): StreamController;
|
|
93
|
+
declare function mergeStreamConfigs(configs: StreamControllerConfig[]): StreamControllerConfig;
|
|
94
|
+
declare function createDevStreamController(): StreamController;
|
|
95
|
+
declare function createProdStreamController(options?: {
|
|
96
|
+
maxTokens?: number;
|
|
97
|
+
maxCost?: number;
|
|
98
|
+
maxSteps?: number;
|
|
99
|
+
onBudgetExceeded?: BudgetGuardConfig['onBudgetExceeded'];
|
|
100
|
+
onStepLimitReached?: StepLimitConfig['onLimitReached'];
|
|
101
|
+
}): StreamController;
|
|
102
|
+
//#endregion
|
|
103
|
+
export { SmoothStreamConfig as C, StreamController as D, StepLimitConfig as E, StreamControllerConfig as O, CostEntry as S, StepCounter as T, createBudgetGuardedOnFinish as _, createSmoothStreamTransform as a, BudgetGuardConfig as b, withSmoothStream as c, createStepLimitCondition as d, withStepLimit as f, createBudgetChecker as g, calculateCost as h, mergeStreamConfigs as i, TokenUsage as k, StepLimitExceededError as l, OnFinishResult as m, createProdStreamController as n, smoothTextGenerator as o, DEFAULT_COST_TABLE as p, createStreamController as r, splitIntoChunks as s, createDevStreamController as t, createStepCounter as u, estimateCost as v, SmoothStreamTransform as w, BudgetLimit as x, BudgetCheckResult as y };
|
|
104
|
+
//# sourceMappingURL=controller-Y0NGosbJ.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"controller-Y0NGosbJ.d.mts","names":[],"sources":["../src/streaming/control/types.ts","../src/streaming/control/budget-guard.ts","../src/streaming/control/step-limit.ts","../src/streaming/control/smoothing.ts","../src/streaming/control/controller.ts"],"mappings":"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"}
|