@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,1334 @@
|
|
|
1
|
+
//#region src/grounding/retrieval/in-memory-store.ts
|
|
2
|
+
/**
|
|
3
|
+
* Simple in-memory vector store using cosine similarity
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* ```ts
|
|
7
|
+
* const store = new InMemoryVectorStore(embedFn);
|
|
8
|
+
*
|
|
9
|
+
* await store.add([
|
|
10
|
+
* { id: "1", content: "AI is transforming industries" },
|
|
11
|
+
* { id: "2", content: "Machine learning requires data" },
|
|
12
|
+
* ]);
|
|
13
|
+
*
|
|
14
|
+
* const results = await store.search("artificial intelligence", 5);
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
var InMemoryVectorStore = class {
|
|
18
|
+
documents = /* @__PURE__ */ new Map();
|
|
19
|
+
embeddings = /* @__PURE__ */ new Map();
|
|
20
|
+
constructor(embedFn, options = {}) {
|
|
21
|
+
this.embedFn = embedFn;
|
|
22
|
+
this.options = options;
|
|
23
|
+
}
|
|
24
|
+
async add(sources) {
|
|
25
|
+
for (const source of sources) {
|
|
26
|
+
this.documents.set(source.id, source);
|
|
27
|
+
const embedding = await this.embedFn(source.content);
|
|
28
|
+
this.embeddings.set(source.id, embedding);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
async search(query, limit = 10) {
|
|
32
|
+
const queryEmbedding = await this.embedFn(query);
|
|
33
|
+
const scores = [];
|
|
34
|
+
for (const [id, embedding] of this.embeddings) {
|
|
35
|
+
const score = cosineSimilarity(queryEmbedding, embedding);
|
|
36
|
+
scores.push({
|
|
37
|
+
id,
|
|
38
|
+
score
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
scores.sort((a, b) => b.score - a.score);
|
|
42
|
+
return scores.slice(0, limit).flatMap(({ id, score }) => {
|
|
43
|
+
const document = this.documents.get(id);
|
|
44
|
+
if (!document) return [];
|
|
45
|
+
return [{
|
|
46
|
+
...document,
|
|
47
|
+
score
|
|
48
|
+
}];
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
async delete(ids) {
|
|
52
|
+
for (const id of ids) {
|
|
53
|
+
this.documents.delete(id);
|
|
54
|
+
this.embeddings.delete(id);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Get document count
|
|
59
|
+
*/
|
|
60
|
+
size() {
|
|
61
|
+
return this.documents.size;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Clear all documents
|
|
65
|
+
*/
|
|
66
|
+
clear() {
|
|
67
|
+
this.documents.clear();
|
|
68
|
+
this.embeddings.clear();
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
/**
|
|
72
|
+
* Calculate cosine similarity between two vectors
|
|
73
|
+
*/
|
|
74
|
+
function cosineSimilarity(a, b) {
|
|
75
|
+
if (a.length !== b.length) throw new Error("Vectors must have the same length");
|
|
76
|
+
let dotProduct = 0;
|
|
77
|
+
let normA = 0;
|
|
78
|
+
let normB = 0;
|
|
79
|
+
for (let i = 0; i < a.length; i++) {
|
|
80
|
+
const aValue = a[i] ?? 0;
|
|
81
|
+
const bValue = b[i] ?? 0;
|
|
82
|
+
dotProduct += aValue * bValue;
|
|
83
|
+
normA += aValue * aValue;
|
|
84
|
+
normB += bValue * bValue;
|
|
85
|
+
}
|
|
86
|
+
const magnitude = Math.sqrt(normA) * Math.sqrt(normB);
|
|
87
|
+
if (magnitude === 0) return 0;
|
|
88
|
+
return dotProduct / magnitude;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
//#endregion
|
|
92
|
+
//#region src/grounding/sources/index.ts
|
|
93
|
+
/**
|
|
94
|
+
* Creates a source registry for managing grounding sources.
|
|
95
|
+
*
|
|
96
|
+
* @example
|
|
97
|
+
* ```typescript
|
|
98
|
+
* const registry = createSourceRegistry({ maxSources: 1000 });
|
|
99
|
+
*
|
|
100
|
+
* registry.add({
|
|
101
|
+
* id: 'wiki-1',
|
|
102
|
+
* content: 'Climate change refers to...',
|
|
103
|
+
* url: 'https://example.com/climate',
|
|
104
|
+
* score: 0.85
|
|
105
|
+
* });
|
|
106
|
+
*
|
|
107
|
+
* const source = registry.get('wiki-1');
|
|
108
|
+
* console.log(source?.useCount); // 0
|
|
109
|
+
*
|
|
110
|
+
* registry.recordUsage('wiki-1');
|
|
111
|
+
* console.log(registry.get('wiki-1')?.useCount); // 1
|
|
112
|
+
* ```
|
|
113
|
+
*/
|
|
114
|
+
function createSourceRegistry(config = {}) {
|
|
115
|
+
const { maxSources = 1e4, autoDeduplicate = false, deduplicationStrategy = "id" } = config;
|
|
116
|
+
const sources = /* @__PURE__ */ new Map();
|
|
117
|
+
function add(source) {
|
|
118
|
+
if (sources.size >= maxSources) {
|
|
119
|
+
const oldestId = sources.keys().next().value;
|
|
120
|
+
if (oldestId) sources.delete(oldestId);
|
|
121
|
+
}
|
|
122
|
+
if (autoDeduplicate) {
|
|
123
|
+
if (checkDuplicate(source, Array.from(sources.values()), deduplicationStrategy)) return;
|
|
124
|
+
}
|
|
125
|
+
const enhanced = {
|
|
126
|
+
...source,
|
|
127
|
+
addedAt: /* @__PURE__ */ new Date(),
|
|
128
|
+
lastAccessedAt: /* @__PURE__ */ new Date(),
|
|
129
|
+
useCount: 0,
|
|
130
|
+
sourceType: inferSourceType(source)
|
|
131
|
+
};
|
|
132
|
+
sources.set(source.id, enhanced);
|
|
133
|
+
}
|
|
134
|
+
function addMany(newSources) {
|
|
135
|
+
for (const source of newSources) add(source);
|
|
136
|
+
}
|
|
137
|
+
function get(id) {
|
|
138
|
+
const source = sources.get(id);
|
|
139
|
+
if (source) source.lastAccessedAt = /* @__PURE__ */ new Date();
|
|
140
|
+
return source;
|
|
141
|
+
}
|
|
142
|
+
function getAll() {
|
|
143
|
+
return Array.from(sources.values());
|
|
144
|
+
}
|
|
145
|
+
function remove(id) {
|
|
146
|
+
return sources.delete(id);
|
|
147
|
+
}
|
|
148
|
+
function clear() {
|
|
149
|
+
sources.clear();
|
|
150
|
+
}
|
|
151
|
+
function has(id) {
|
|
152
|
+
return sources.has(id);
|
|
153
|
+
}
|
|
154
|
+
function size() {
|
|
155
|
+
return sources.size;
|
|
156
|
+
}
|
|
157
|
+
function search(query, limit = 10) {
|
|
158
|
+
const results = [];
|
|
159
|
+
for (const source of sources.values()) {
|
|
160
|
+
const similarity = computeTextSimilarity(query, source.content);
|
|
161
|
+
if (similarity > .1) results.push({
|
|
162
|
+
source,
|
|
163
|
+
similarity
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
return results.sort((a, b) => b.similarity - a.similarity).slice(0, limit).map((r) => r.source);
|
|
167
|
+
}
|
|
168
|
+
function recordUsage(id) {
|
|
169
|
+
const source = sources.get(id);
|
|
170
|
+
if (source) {
|
|
171
|
+
source.useCount = (source.useCount ?? 0) + 1;
|
|
172
|
+
source.lastAccessedAt = /* @__PURE__ */ new Date();
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
return {
|
|
176
|
+
add,
|
|
177
|
+
addMany,
|
|
178
|
+
get,
|
|
179
|
+
getAll,
|
|
180
|
+
remove,
|
|
181
|
+
clear,
|
|
182
|
+
has,
|
|
183
|
+
size,
|
|
184
|
+
search,
|
|
185
|
+
recordUsage
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Validate a single grounding source.
|
|
190
|
+
*
|
|
191
|
+
* @example
|
|
192
|
+
* ```typescript
|
|
193
|
+
* const result = validateSource(source, { requireUrl: true, minContentLength: 50 });
|
|
194
|
+
* if (!result.valid) {
|
|
195
|
+
* console.error('Validation errors:', result.errors);
|
|
196
|
+
* }
|
|
197
|
+
* ```
|
|
198
|
+
*/
|
|
199
|
+
function validateSource(source, options = {}) {
|
|
200
|
+
const { requireUrl = false, requireTitle = false, minContentLength = 1, maxContentLength = 1e5, requireScore = false } = options;
|
|
201
|
+
const errors = [];
|
|
202
|
+
const warnings = [];
|
|
203
|
+
if (!source.id || typeof source.id !== "string") errors.push("Source must have a valid string id");
|
|
204
|
+
if (!source.content || typeof source.content !== "string") errors.push("Source must have valid string content");
|
|
205
|
+
else {
|
|
206
|
+
if (source.content.length < minContentLength) errors.push(`Content must be at least ${minContentLength} characters`);
|
|
207
|
+
if (source.content.length > maxContentLength) errors.push(`Content must not exceed ${maxContentLength} characters`);
|
|
208
|
+
}
|
|
209
|
+
if (requireUrl && !source.url) errors.push("URL is required");
|
|
210
|
+
if (requireTitle && !source.title) errors.push("Title is required");
|
|
211
|
+
if (requireScore && (source.score === void 0 || source.score === null)) errors.push("Score is required");
|
|
212
|
+
if (source.score !== void 0 && (source.score < 0 || source.score > 1)) warnings.push("score should be between 0 and 1");
|
|
213
|
+
if (source.url && !isValidUrl(source.url)) warnings.push("URL appears to be invalid");
|
|
214
|
+
return {
|
|
215
|
+
valid: errors.length === 0,
|
|
216
|
+
sourceId: source.id ?? "unknown",
|
|
217
|
+
errors,
|
|
218
|
+
warnings
|
|
219
|
+
};
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* Validate multiple sources.
|
|
223
|
+
*
|
|
224
|
+
* @example
|
|
225
|
+
* ```typescript
|
|
226
|
+
* const { valid, invalid, results } = validateSources(sources);
|
|
227
|
+
* console.log(`${valid.length} valid, ${invalid.length} invalid`);
|
|
228
|
+
* ```
|
|
229
|
+
*/
|
|
230
|
+
function validateSources(sources, options = {}) {
|
|
231
|
+
const results = sources.map((s) => validateSource(s, options));
|
|
232
|
+
const valid = [];
|
|
233
|
+
const invalid = [];
|
|
234
|
+
for (let i = 0; i < sources.length; i++) {
|
|
235
|
+
const result = results[i];
|
|
236
|
+
const source = sources[i];
|
|
237
|
+
if (!result || !source) continue;
|
|
238
|
+
if (result.valid) valid.push(source);
|
|
239
|
+
else invalid.push(source);
|
|
240
|
+
}
|
|
241
|
+
return {
|
|
242
|
+
valid,
|
|
243
|
+
invalid,
|
|
244
|
+
results
|
|
245
|
+
};
|
|
246
|
+
}
|
|
247
|
+
/**
|
|
248
|
+
* Remove duplicate sources based on the specified strategy.
|
|
249
|
+
*
|
|
250
|
+
* @example
|
|
251
|
+
* ```typescript
|
|
252
|
+
* // By ID (exact match)
|
|
253
|
+
* const unique = deduplicateSources(sources, { strategy: 'id' });
|
|
254
|
+
*
|
|
255
|
+
* // By content similarity
|
|
256
|
+
* const unique = deduplicateSources(sources, {
|
|
257
|
+
* strategy: 'content',
|
|
258
|
+
* similarityThreshold: 0.9,
|
|
259
|
+
* keepStrategy: 'highest-score'
|
|
260
|
+
* });
|
|
261
|
+
* ```
|
|
262
|
+
*/
|
|
263
|
+
function deduplicateSources(sources, options = {}) {
|
|
264
|
+
const { strategy = "id", similarityThreshold = .9, keepStrategy = "first" } = options;
|
|
265
|
+
if (sources.length === 0) return [];
|
|
266
|
+
switch (strategy) {
|
|
267
|
+
case "id": return deduplicateById(sources, keepStrategy);
|
|
268
|
+
case "url": return deduplicateByUrl(sources, keepStrategy);
|
|
269
|
+
case "content": return deduplicateByContent(sources, similarityThreshold, keepStrategy);
|
|
270
|
+
case "hybrid": return deduplicateByContent(deduplicateByUrl(sources, keepStrategy), similarityThreshold, keepStrategy);
|
|
271
|
+
default: return sources;
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
function deduplicateById(sources, keepStrategy) {
|
|
275
|
+
const seen = /* @__PURE__ */ new Map();
|
|
276
|
+
for (const source of sources) {
|
|
277
|
+
const existing = seen.get(source.id);
|
|
278
|
+
if (!existing) seen.set(source.id, source);
|
|
279
|
+
else if (keepStrategy === "highest-score") {
|
|
280
|
+
if ((source.score ?? 0) > (existing.score ?? 0)) seen.set(source.id, source);
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
return Array.from(seen.values());
|
|
284
|
+
}
|
|
285
|
+
function deduplicateByUrl(sources, keepStrategy) {
|
|
286
|
+
const seen = /* @__PURE__ */ new Map();
|
|
287
|
+
const noUrl = [];
|
|
288
|
+
for (const source of sources) {
|
|
289
|
+
if (!source.url) {
|
|
290
|
+
noUrl.push(source);
|
|
291
|
+
continue;
|
|
292
|
+
}
|
|
293
|
+
const normalizedUrl = normalizeUrl(source.url);
|
|
294
|
+
const existing = seen.get(normalizedUrl);
|
|
295
|
+
if (!existing) seen.set(normalizedUrl, source);
|
|
296
|
+
else if (keepStrategy === "highest-score") {
|
|
297
|
+
if ((source.score ?? 0) > (existing.score ?? 0)) seen.set(normalizedUrl, source);
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
return [...Array.from(seen.values()), ...noUrl];
|
|
301
|
+
}
|
|
302
|
+
function deduplicateByContent(sources, threshold, keepStrategy) {
|
|
303
|
+
const result = [];
|
|
304
|
+
for (const source of sources) {
|
|
305
|
+
let isDuplicate = false;
|
|
306
|
+
let duplicateIndex = -1;
|
|
307
|
+
for (let i = 0; i < result.length; i++) {
|
|
308
|
+
const existing = result[i];
|
|
309
|
+
if (!existing) continue;
|
|
310
|
+
if (computeTextSimilarity(source.content, existing.content) >= threshold) {
|
|
311
|
+
isDuplicate = true;
|
|
312
|
+
duplicateIndex = i;
|
|
313
|
+
break;
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
if (!isDuplicate) result.push(source);
|
|
317
|
+
else if (keepStrategy === "highest-score" && duplicateIndex >= 0) {
|
|
318
|
+
const current = result[duplicateIndex];
|
|
319
|
+
if (current && (source.score ?? 0) > (current.score ?? 0)) result[duplicateIndex] = source;
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
return result;
|
|
323
|
+
}
|
|
324
|
+
/**
|
|
325
|
+
* Merge duplicate sources, combining their metadata.
|
|
326
|
+
*
|
|
327
|
+
* @example
|
|
328
|
+
* ```typescript
|
|
329
|
+
* const merged = mergeSources(sources, { strategy: 'url' });
|
|
330
|
+
* ```
|
|
331
|
+
*/
|
|
332
|
+
function mergeSources(sources, options = {}) {
|
|
333
|
+
const { strategy = "id" } = options;
|
|
334
|
+
const groups = /* @__PURE__ */ new Map();
|
|
335
|
+
for (const source of sources) {
|
|
336
|
+
let key;
|
|
337
|
+
switch (strategy) {
|
|
338
|
+
case "url":
|
|
339
|
+
key = source.url ? normalizeUrl(source.url) : source.id;
|
|
340
|
+
break;
|
|
341
|
+
case "content":
|
|
342
|
+
key = hashContent(source.content);
|
|
343
|
+
break;
|
|
344
|
+
case "hybrid":
|
|
345
|
+
key = `${source.url ? normalizeUrl(source.url) : source.id}:${hashContent(source.content)}`;
|
|
346
|
+
break;
|
|
347
|
+
default: key = source.id;
|
|
348
|
+
}
|
|
349
|
+
const group = groups.get(key) ?? [];
|
|
350
|
+
group.push(source);
|
|
351
|
+
groups.set(key, group);
|
|
352
|
+
}
|
|
353
|
+
return Array.from(groups.values()).filter((group) => group.length > 0).map((group) => {
|
|
354
|
+
const first = group[0];
|
|
355
|
+
if (group.length === 1) return first;
|
|
356
|
+
return group.reduce((acc, s) => {
|
|
357
|
+
return {
|
|
358
|
+
...acc,
|
|
359
|
+
score: Math.max(acc.score ?? 0, s.score ?? 0),
|
|
360
|
+
metadata: {
|
|
361
|
+
...acc.metadata,
|
|
362
|
+
...s.metadata
|
|
363
|
+
}
|
|
364
|
+
};
|
|
365
|
+
}, first);
|
|
366
|
+
});
|
|
367
|
+
}
|
|
368
|
+
/**
|
|
369
|
+
* Filter sources by relevance score.
|
|
370
|
+
*
|
|
371
|
+
* @example
|
|
372
|
+
* ```typescript
|
|
373
|
+
* const topSources = filterByScore(sources, { minScore: 0.7, limit: 5 });
|
|
374
|
+
* ```
|
|
375
|
+
*/
|
|
376
|
+
function filterByScore(sources, options = {}) {
|
|
377
|
+
const { minScore = 0, maxScore = 1, limit } = options;
|
|
378
|
+
let filtered = sources.filter((s) => {
|
|
379
|
+
const score = s.score ?? 0;
|
|
380
|
+
return score >= minScore && score <= maxScore;
|
|
381
|
+
});
|
|
382
|
+
filtered.sort((a, b) => (b.score ?? 0) - (a.score ?? 0));
|
|
383
|
+
if (limit && limit > 0) filtered = filtered.slice(0, limit);
|
|
384
|
+
return filtered;
|
|
385
|
+
}
|
|
386
|
+
/**
|
|
387
|
+
* Filter sources by metadata fields.
|
|
388
|
+
*
|
|
389
|
+
* @example
|
|
390
|
+
* ```typescript
|
|
391
|
+
* const filtered = filterByMetadata(sources, {
|
|
392
|
+
* requiredFields: ['author', 'date'],
|
|
393
|
+
* matchValues: { category: 'science' }
|
|
394
|
+
* });
|
|
395
|
+
* ```
|
|
396
|
+
*/
|
|
397
|
+
function filterByMetadata(sources, options = {}) {
|
|
398
|
+
const { requiredFields = [], matchValues = {} } = options;
|
|
399
|
+
return sources.filter((source) => {
|
|
400
|
+
const metadata = source.metadata ?? {};
|
|
401
|
+
for (const field of requiredFields) if (!(field in metadata)) return false;
|
|
402
|
+
for (const [key, value] of Object.entries(matchValues)) if (metadata[key] !== value) return false;
|
|
403
|
+
return true;
|
|
404
|
+
});
|
|
405
|
+
}
|
|
406
|
+
/**
|
|
407
|
+
* Select top N sources, optionally with diversity.
|
|
408
|
+
*
|
|
409
|
+
* @example
|
|
410
|
+
* ```typescript
|
|
411
|
+
* const top = selectTopSources(sources, 5, { diversify: true });
|
|
412
|
+
* ```
|
|
413
|
+
*/
|
|
414
|
+
function selectTopSources(sources, limit, options = {}) {
|
|
415
|
+
const { diversify = false, diversityThreshold = .7 } = options;
|
|
416
|
+
const sorted = [...sources].sort((a, b) => (b.score ?? 0) - (a.score ?? 0));
|
|
417
|
+
if (!diversify) return sorted.slice(0, limit);
|
|
418
|
+
const selected = [];
|
|
419
|
+
for (const candidate of sorted) {
|
|
420
|
+
if (selected.length >= limit) break;
|
|
421
|
+
if (!selected.some((s) => computeTextSimilarity(candidate.content, s.content) > diversityThreshold)) selected.push(candidate);
|
|
422
|
+
}
|
|
423
|
+
return selected;
|
|
424
|
+
}
|
|
425
|
+
/**
|
|
426
|
+
* Group sources by a metadata field or custom function.
|
|
427
|
+
*
|
|
428
|
+
* @example
|
|
429
|
+
* ```typescript
|
|
430
|
+
* const byCategory = groupSources(sources, s => s.metadata?.category ?? 'other');
|
|
431
|
+
* ```
|
|
432
|
+
*/
|
|
433
|
+
function groupSources(sources, keyFn) {
|
|
434
|
+
const groups = /* @__PURE__ */ new Map();
|
|
435
|
+
for (const source of sources) {
|
|
436
|
+
const key = keyFn(source);
|
|
437
|
+
const group = groups.get(key) ?? [];
|
|
438
|
+
group.push(source);
|
|
439
|
+
groups.set(key, group);
|
|
440
|
+
}
|
|
441
|
+
return groups;
|
|
442
|
+
}
|
|
443
|
+
/**
|
|
444
|
+
* Format sources as a bibliography string.
|
|
445
|
+
*
|
|
446
|
+
* @example
|
|
447
|
+
* ```typescript
|
|
448
|
+
* const bib = formatAsBibliography(sources, { style: 'apa' });
|
|
449
|
+
* console.log(bib);
|
|
450
|
+
* // [1] Author. Title. URL
|
|
451
|
+
* // [2] Author. Title. URL
|
|
452
|
+
* ```
|
|
453
|
+
*/
|
|
454
|
+
function formatAsBibliography(sources, options = {}) {
|
|
455
|
+
const { style = "numbered" } = options;
|
|
456
|
+
return sources.map((source, index) => {
|
|
457
|
+
const title = source.title ?? "Untitled";
|
|
458
|
+
const url = source.url ?? "";
|
|
459
|
+
switch (style) {
|
|
460
|
+
case "apa": return `${source.metadata?.author ?? "Unknown"} (${source.metadata?.year ?? "n.d."}). ${title}. ${url}`;
|
|
461
|
+
case "simple": return `${title}${url ? ` - ${url}` : ""}`;
|
|
462
|
+
default: {
|
|
463
|
+
const author = source.metadata?.author;
|
|
464
|
+
const authorPrefix = typeof author === "string" && author.trim().length > 0 ? `${author.trim()}. ` : "";
|
|
465
|
+
return `[${index + 1}] ${authorPrefix}${title}${url ? `. ${url}` : ""}`;
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
}).join("\n");
|
|
469
|
+
}
|
|
470
|
+
/**
|
|
471
|
+
* Format sources as inline citations.
|
|
472
|
+
*
|
|
473
|
+
* @example
|
|
474
|
+
* ```typescript
|
|
475
|
+
* const citations = formatAsInlineCitations(sources);
|
|
476
|
+
* // Returns: "[1], [2], [3]"
|
|
477
|
+
* ```
|
|
478
|
+
*/
|
|
479
|
+
function formatAsInlineCitations(sources, options = {}) {
|
|
480
|
+
const { separator = ", ", format = "numbered" } = options;
|
|
481
|
+
return sources.map((source, index) => {
|
|
482
|
+
switch (format) {
|
|
483
|
+
case "id": return `[${source.id}]`;
|
|
484
|
+
case "title": return `[${source.title ?? source.id}]`;
|
|
485
|
+
default: return `[${index + 1}]`;
|
|
486
|
+
}
|
|
487
|
+
}).join(separator);
|
|
488
|
+
}
|
|
489
|
+
/**
|
|
490
|
+
* Convert sources to context string for LLM prompts.
|
|
491
|
+
*
|
|
492
|
+
* @example
|
|
493
|
+
* ```typescript
|
|
494
|
+
* const context = sourcesToContext(sources, { includeMetadata: true });
|
|
495
|
+
* ```
|
|
496
|
+
*/
|
|
497
|
+
function sourcesToContext(sources, options = {}) {
|
|
498
|
+
const { includeMetadata = false, includeScore = false, maxLength = 5e4, separator = "\n\n---\n\n" } = options;
|
|
499
|
+
let totalLength = 0;
|
|
500
|
+
const parts = [];
|
|
501
|
+
for (const source of sources) {
|
|
502
|
+
let part = "";
|
|
503
|
+
if (source.title) part += `# ${source.title}\n`;
|
|
504
|
+
if (includeScore && source.score !== void 0) part += `Relevance: ${(source.score * 100).toFixed(0)}%\n`;
|
|
505
|
+
if (source.url) part += `Source: ${source.url}\n`;
|
|
506
|
+
if (includeMetadata && source.metadata) {
|
|
507
|
+
const meta = Object.entries(source.metadata).map(([k, v]) => `${k}: ${v}`).join(", ");
|
|
508
|
+
part += `Metadata: ${meta}\n`;
|
|
509
|
+
}
|
|
510
|
+
part += `\n${source.content}`;
|
|
511
|
+
if (totalLength + part.length > maxLength) {
|
|
512
|
+
const remaining = maxLength - totalLength;
|
|
513
|
+
if (remaining > 100) parts.push(`${part.slice(0, remaining)}...`);
|
|
514
|
+
break;
|
|
515
|
+
}
|
|
516
|
+
parts.push(part);
|
|
517
|
+
totalLength += part.length + separator.length;
|
|
518
|
+
}
|
|
519
|
+
return parts.join(separator);
|
|
520
|
+
}
|
|
521
|
+
function computeTextSimilarity(text1, text2) {
|
|
522
|
+
const words1 = new Set(tokenize(text1));
|
|
523
|
+
const words2 = new Set(tokenize(text2));
|
|
524
|
+
if (words1.size === 0 || words2.size === 0) return 0;
|
|
525
|
+
let intersection = 0;
|
|
526
|
+
for (const word of words1) if (words2.has(word)) intersection++;
|
|
527
|
+
const union = words1.size + words2.size - intersection;
|
|
528
|
+
return union > 0 ? intersection / union : 0;
|
|
529
|
+
}
|
|
530
|
+
function tokenize(text) {
|
|
531
|
+
return text.toLowerCase().replace(/[^\w\s]/g, " ").split(/\s+/).filter((w) => w.length > 2);
|
|
532
|
+
}
|
|
533
|
+
function isValidUrl(url) {
|
|
534
|
+
try {
|
|
535
|
+
new URL(url);
|
|
536
|
+
return true;
|
|
537
|
+
} catch {
|
|
538
|
+
return false;
|
|
539
|
+
}
|
|
540
|
+
}
|
|
541
|
+
function normalizeUrl(url) {
|
|
542
|
+
try {
|
|
543
|
+
const parsed = new URL(url);
|
|
544
|
+
return `${parsed.protocol}//${parsed.host.toLowerCase()}${parsed.pathname.replace(/\/$/, "")}`;
|
|
545
|
+
} catch {
|
|
546
|
+
return url.toLowerCase();
|
|
547
|
+
}
|
|
548
|
+
}
|
|
549
|
+
function hashContent(content) {
|
|
550
|
+
let hash = 5381;
|
|
551
|
+
for (let i = 0; i < content.length; i++) {
|
|
552
|
+
const code = content.charCodeAt(i);
|
|
553
|
+
hash = hash * 33 ^ code;
|
|
554
|
+
}
|
|
555
|
+
return `content-${hash >>> 0}`;
|
|
556
|
+
}
|
|
557
|
+
function inferSourceType(source) {
|
|
558
|
+
if (!source.url) return "unknown";
|
|
559
|
+
const url = source.url.toLowerCase();
|
|
560
|
+
if (url.includes("api.") || url.includes("/api/")) return "api";
|
|
561
|
+
if (url.includes(".pdf") || url.includes("/doc")) return "document";
|
|
562
|
+
if (url.includes("database") || url.includes("db.")) return "database";
|
|
563
|
+
if (url.startsWith("http")) return "webpage";
|
|
564
|
+
return "unknown";
|
|
565
|
+
}
|
|
566
|
+
function checkDuplicate(source, existing, strategy) {
|
|
567
|
+
switch (strategy) {
|
|
568
|
+
case "id": return existing.some((e) => e.id === source.id);
|
|
569
|
+
case "url":
|
|
570
|
+
if (!source.url) return false;
|
|
571
|
+
const normalizedUrl = normalizeUrl(source.url);
|
|
572
|
+
return existing.some((e) => e.url && normalizeUrl(e.url) === normalizedUrl);
|
|
573
|
+
case "content": return existing.some((e) => computeTextSimilarity(source.content, e.content) > .9);
|
|
574
|
+
case "hybrid": {
|
|
575
|
+
const idMatch = existing.some((e) => e.id === source.id);
|
|
576
|
+
const sourceUrl = source.url;
|
|
577
|
+
const urlMatch = sourceUrl ? existing.some((e) => e.url && normalizeUrl(e.url) === normalizeUrl(sourceUrl)) : false;
|
|
578
|
+
const contentMatch = existing.some((e) => computeTextSimilarity(source.content, e.content) > .9);
|
|
579
|
+
return idMatch || urlMatch || contentMatch;
|
|
580
|
+
}
|
|
581
|
+
default: return false;
|
|
582
|
+
}
|
|
583
|
+
}
|
|
584
|
+
|
|
585
|
+
//#endregion
|
|
586
|
+
//#region src/grounding/context-engineering/tool-masking.ts
|
|
587
|
+
/**
|
|
588
|
+
* Creates a tool masker with rules.
|
|
589
|
+
*
|
|
590
|
+
* @param rules - Masking rules
|
|
591
|
+
* @returns Tool masker function
|
|
592
|
+
*
|
|
593
|
+
* @example
|
|
594
|
+
* ```ts
|
|
595
|
+
* const maskTools = createToolMasker([
|
|
596
|
+
* {
|
|
597
|
+
* name: 'hide-admin-tools',
|
|
598
|
+
* toolPatterns: ['admin*', 'delete*'],
|
|
599
|
+
* condition: (ctx) => !ctx.roles?.includes('admin'),
|
|
600
|
+
* action: 'hide',
|
|
601
|
+
* },
|
|
602
|
+
* {
|
|
603
|
+
* name: 'limit-iterations',
|
|
604
|
+
* toolPatterns: ['*'],
|
|
605
|
+
* condition: (ctx) => (ctx.iteration ?? 0) > 5,
|
|
606
|
+
* action: 'disable',
|
|
607
|
+
* },
|
|
608
|
+
* ]);
|
|
609
|
+
*
|
|
610
|
+
* const result = maskTools(allTools, { userId: 'user-1', roles: ['user'] });
|
|
611
|
+
* ```
|
|
612
|
+
*/
|
|
613
|
+
function createToolMasker(rules) {
|
|
614
|
+
return function maskTools(tools, context) {
|
|
615
|
+
const result = {
|
|
616
|
+
tools: { ...tools },
|
|
617
|
+
activeTools: Object.keys(tools),
|
|
618
|
+
hidden: [],
|
|
619
|
+
disabled: [],
|
|
620
|
+
requiresApproval: [],
|
|
621
|
+
appliedRules: []
|
|
622
|
+
};
|
|
623
|
+
outer: for (const toolName of Object.keys(tools)) for (const rule of rules) {
|
|
624
|
+
if (!matchesPattern(toolName, rule.toolPatterns)) continue;
|
|
625
|
+
if (!rule.condition(context)) continue;
|
|
626
|
+
result.appliedRules.push(`${rule.name}:${toolName}`);
|
|
627
|
+
switch (rule.action) {
|
|
628
|
+
case "hide":
|
|
629
|
+
delete result.tools[toolName];
|
|
630
|
+
result.activeTools = result.activeTools.filter((t) => t !== toolName);
|
|
631
|
+
result.hidden.push(toolName);
|
|
632
|
+
continue outer;
|
|
633
|
+
case "disable":
|
|
634
|
+
result.activeTools = result.activeTools.filter((t) => t !== toolName);
|
|
635
|
+
result.disabled.push(toolName);
|
|
636
|
+
break;
|
|
637
|
+
case "require-approval":
|
|
638
|
+
result.requiresApproval.push(toolName);
|
|
639
|
+
break;
|
|
640
|
+
}
|
|
641
|
+
}
|
|
642
|
+
return result;
|
|
643
|
+
};
|
|
644
|
+
}
|
|
645
|
+
/**
|
|
646
|
+
* Checks if a tool name matches any of the patterns.
|
|
647
|
+
*/
|
|
648
|
+
function matchesPattern(toolName, patterns) {
|
|
649
|
+
return patterns.some((pattern) => {
|
|
650
|
+
if (pattern === "*") return true;
|
|
651
|
+
if (pattern.endsWith("*")) return toolName.startsWith(pattern.slice(0, -1));
|
|
652
|
+
if (pattern.startsWith("*")) return toolName.endsWith(pattern.slice(1));
|
|
653
|
+
return toolName === pattern;
|
|
654
|
+
});
|
|
655
|
+
}
|
|
656
|
+
/**
|
|
657
|
+
* Pre-built masking rules.
|
|
658
|
+
*/
|
|
659
|
+
const MaskingRules = {
|
|
660
|
+
limitIterations: (maxIterations, toolPatterns = ["*"]) => ({
|
|
661
|
+
name: "limit-iterations",
|
|
662
|
+
toolPatterns,
|
|
663
|
+
condition: (ctx) => (ctx.iteration ?? 0) >= maxIterations,
|
|
664
|
+
action: "hide"
|
|
665
|
+
}),
|
|
666
|
+
requireRole: (role, toolPatterns) => ({
|
|
667
|
+
name: `require-role-${role}`,
|
|
668
|
+
toolPatterns,
|
|
669
|
+
condition: (ctx) => !ctx.roles?.includes(role),
|
|
670
|
+
action: "hide"
|
|
671
|
+
}),
|
|
672
|
+
preventRepeated: (toolPatterns, maxCalls = 1) => ({
|
|
673
|
+
name: "prevent-repeated",
|
|
674
|
+
toolPatterns,
|
|
675
|
+
condition: (ctx) => {
|
|
676
|
+
const calls = ctx.previousToolCalls ?? [];
|
|
677
|
+
for (const pattern of toolPatterns) if (calls.filter((c) => matchesPattern(c, [pattern])).length >= maxCalls) return true;
|
|
678
|
+
return false;
|
|
679
|
+
},
|
|
680
|
+
action: "hide"
|
|
681
|
+
}),
|
|
682
|
+
requireApproval: (toolPatterns) => ({
|
|
683
|
+
name: "require-approval",
|
|
684
|
+
toolPatterns,
|
|
685
|
+
condition: () => true,
|
|
686
|
+
action: "require-approval"
|
|
687
|
+
})
|
|
688
|
+
};
|
|
689
|
+
/**
|
|
690
|
+
* Creates progressive tool disclosure.
|
|
691
|
+
* Reveals tools based on conversation progress.
|
|
692
|
+
*
|
|
693
|
+
* @param stages - Tool revelation stages
|
|
694
|
+
* @returns Tool masker
|
|
695
|
+
*/
|
|
696
|
+
function createProgressiveDisclosure(stages) {
|
|
697
|
+
const sortedStages = [...stages].sort((a, b) => a.turn - b.turn);
|
|
698
|
+
return (tools, context) => {
|
|
699
|
+
const currentTurn = context.turn ?? 0;
|
|
700
|
+
const availableTools = /* @__PURE__ */ new Set();
|
|
701
|
+
for (const stage of sortedStages) if (stage.turn <= currentTurn) stage.tools.forEach((t) => availableTools.add(t));
|
|
702
|
+
const result = {
|
|
703
|
+
tools: {},
|
|
704
|
+
activeTools: [],
|
|
705
|
+
hidden: [],
|
|
706
|
+
disabled: [],
|
|
707
|
+
requiresApproval: [],
|
|
708
|
+
appliedRules: []
|
|
709
|
+
};
|
|
710
|
+
for (const [name, tool] of Object.entries(tools)) if (availableTools.has(name) || availableTools.has("*")) {
|
|
711
|
+
result.tools[name] = tool;
|
|
712
|
+
result.activeTools.push(name);
|
|
713
|
+
} else {
|
|
714
|
+
result.hidden.push(name);
|
|
715
|
+
result.appliedRules.push(`progressive:${name}`);
|
|
716
|
+
}
|
|
717
|
+
return result;
|
|
718
|
+
};
|
|
719
|
+
}
|
|
720
|
+
/**
|
|
721
|
+
* Creates an activeTools selector for SDK v6.
|
|
722
|
+
* Instead of filtering the tools object, use activeTools parameter.
|
|
723
|
+
*
|
|
724
|
+
* @example
|
|
725
|
+
* ```typescript
|
|
726
|
+
* const selector = createActiveToolsSelector(allTools, [
|
|
727
|
+
* MaskingRules.requireRole('admin', ['delete*', 'admin*']),
|
|
728
|
+
* MaskingRules.limitIterations(5),
|
|
729
|
+
* ]);
|
|
730
|
+
*
|
|
731
|
+
* // Use with generateText
|
|
732
|
+
* const result = await generateText({
|
|
733
|
+
* model,
|
|
734
|
+
* tools: allTools, // Pass ALL tools
|
|
735
|
+
* activeTools: selector(context), // But only activate some
|
|
736
|
+
* prompt: 'Do something',
|
|
737
|
+
* });
|
|
738
|
+
* ```
|
|
739
|
+
*/
|
|
740
|
+
function createActiveToolsSelector(tools, rules) {
|
|
741
|
+
const masker = createToolMasker(rules);
|
|
742
|
+
return (context) => {
|
|
743
|
+
return masker(tools, context).activeTools;
|
|
744
|
+
};
|
|
745
|
+
}
|
|
746
|
+
/**
|
|
747
|
+
* Simple phase-based tool activation.
|
|
748
|
+
* Different tools are active in different phases of execution.
|
|
749
|
+
*
|
|
750
|
+
* @example
|
|
751
|
+
* ```typescript
|
|
752
|
+
* const activator = createPhasedToolActivation({
|
|
753
|
+
* planning: ['search', 'browse'],
|
|
754
|
+
* execution: ['code', 'file_write', 'run_command'],
|
|
755
|
+
* review: ['code_review', 'test'],
|
|
756
|
+
* });
|
|
757
|
+
*
|
|
758
|
+
* const result = await generateText({
|
|
759
|
+
* model,
|
|
760
|
+
* tools: allTools,
|
|
761
|
+
* activeTools: activator('planning'),
|
|
762
|
+
* prompt: 'Research the topic',
|
|
763
|
+
* });
|
|
764
|
+
* ```
|
|
765
|
+
*/
|
|
766
|
+
function createPhasedToolActivation(phases) {
|
|
767
|
+
return (phase) => phases[phase] ?? [];
|
|
768
|
+
}
|
|
769
|
+
/**
|
|
770
|
+
* Context-aware tool activation based on user input analysis.
|
|
771
|
+
*
|
|
772
|
+
* @example
|
|
773
|
+
* ```typescript
|
|
774
|
+
* const activator = createContextualToolActivation([
|
|
775
|
+
* { keywords: ['search', 'find', 'look up'], tools: ['web_search', 'browse'] },
|
|
776
|
+
* { keywords: ['code', 'write', 'implement'], tools: ['code_edit', 'file_write'] },
|
|
777
|
+
* { keywords: ['run', 'execute', 'test'], tools: ['run_command', 'test'] },
|
|
778
|
+
* ]);
|
|
779
|
+
*
|
|
780
|
+
* const activeTools = activator(userQuery);
|
|
781
|
+
* ```
|
|
782
|
+
*/
|
|
783
|
+
function createContextualToolActivation(rules, defaultTools = []) {
|
|
784
|
+
return (input) => {
|
|
785
|
+
const lowerInput = input.toLowerCase();
|
|
786
|
+
const matchedTools = new Set(defaultTools);
|
|
787
|
+
for (const rule of rules) if (rule.keywords.some((kw) => lowerInput.includes(kw.toLowerCase()))) rule.tools.forEach((t) => matchedTools.add(t));
|
|
788
|
+
return Array.from(matchedTools);
|
|
789
|
+
};
|
|
790
|
+
}
|
|
791
|
+
|
|
792
|
+
//#endregion
|
|
793
|
+
//#region src/grounding/context-engineering/memory.ts
|
|
794
|
+
/**
|
|
795
|
+
* In-memory store implementation.
|
|
796
|
+
*/
|
|
797
|
+
var InMemoryStore = class {
|
|
798
|
+
store = /* @__PURE__ */ new Map();
|
|
799
|
+
maxEntries;
|
|
800
|
+
accessOrder = [];
|
|
801
|
+
constructor(options) {
|
|
802
|
+
this.maxEntries = options?.maxEntries;
|
|
803
|
+
}
|
|
804
|
+
async get(key) {
|
|
805
|
+
const entry = this.store.get(key);
|
|
806
|
+
if (entry && this.maxEntries) {
|
|
807
|
+
const index = this.accessOrder.indexOf(key);
|
|
808
|
+
if (index >= 0) this.accessOrder.splice(index, 1);
|
|
809
|
+
this.accessOrder.push(key);
|
|
810
|
+
}
|
|
811
|
+
return entry;
|
|
812
|
+
}
|
|
813
|
+
async set(key, entry) {
|
|
814
|
+
if (this.maxEntries) {
|
|
815
|
+
const index = this.accessOrder.indexOf(key);
|
|
816
|
+
if (index >= 0) this.accessOrder.splice(index, 1);
|
|
817
|
+
this.accessOrder.push(key);
|
|
818
|
+
}
|
|
819
|
+
this.store.set(key, entry);
|
|
820
|
+
if (this.maxEntries && this.store.size > this.maxEntries) {
|
|
821
|
+
const oldest = this.accessOrder.shift();
|
|
822
|
+
if (oldest) this.store.delete(oldest);
|
|
823
|
+
}
|
|
824
|
+
}
|
|
825
|
+
async delete(key) {
|
|
826
|
+
const deleted = this.store.delete(key);
|
|
827
|
+
if (deleted && this.maxEntries) {
|
|
828
|
+
const index = this.accessOrder.indexOf(key);
|
|
829
|
+
if (index >= 0) this.accessOrder.splice(index, 1);
|
|
830
|
+
}
|
|
831
|
+
return deleted;
|
|
832
|
+
}
|
|
833
|
+
async keys() {
|
|
834
|
+
return Array.from(this.store.keys());
|
|
835
|
+
}
|
|
836
|
+
async clear() {
|
|
837
|
+
this.store.clear();
|
|
838
|
+
this.accessOrder = [];
|
|
839
|
+
}
|
|
840
|
+
};
|
|
841
|
+
/**
|
|
842
|
+
* Creates a memory manager for conversation state.
|
|
843
|
+
*
|
|
844
|
+
* @param config - Memory manager configuration
|
|
845
|
+
* @returns Memory manager
|
|
846
|
+
*
|
|
847
|
+
* @example
|
|
848
|
+
* ```ts
|
|
849
|
+
* const memory = createMemoryManager({
|
|
850
|
+
* store: new InMemoryStore(),
|
|
851
|
+
* maxMessages: 100,
|
|
852
|
+
* enableSummarization: true,
|
|
853
|
+
* summarize: async (messages) => {
|
|
854
|
+
* // Use LLM to summarize
|
|
855
|
+
* return 'Summary of conversation...';
|
|
856
|
+
* },
|
|
857
|
+
* });
|
|
858
|
+
*
|
|
859
|
+
* await memory.addMessage('session-1', { role: 'user', content: 'Hello' });
|
|
860
|
+
* const context = await memory.getContext('session-1', 10);
|
|
861
|
+
* ```
|
|
862
|
+
*/
|
|
863
|
+
function createMemoryManager(config) {
|
|
864
|
+
const { store, maxMessages = 100, maxTokens, enableSummarization = false, summarize } = config;
|
|
865
|
+
return {
|
|
866
|
+
async getOrCreate(key) {
|
|
867
|
+
const existing = await store.get(key);
|
|
868
|
+
if (existing) return existing;
|
|
869
|
+
const entry = {
|
|
870
|
+
id: key,
|
|
871
|
+
messages: [],
|
|
872
|
+
createdAt: Date.now(),
|
|
873
|
+
updatedAt: Date.now()
|
|
874
|
+
};
|
|
875
|
+
await store.set(key, entry);
|
|
876
|
+
return entry;
|
|
877
|
+
},
|
|
878
|
+
async addMessage(key, message) {
|
|
879
|
+
const entry = await this.getOrCreate(key);
|
|
880
|
+
entry.messages.push({
|
|
881
|
+
...message,
|
|
882
|
+
timestamp: message.timestamp ?? Date.now()
|
|
883
|
+
});
|
|
884
|
+
entry.updatedAt = Date.now();
|
|
885
|
+
if (entry.messages.length > maxMessages) {
|
|
886
|
+
const excess = entry.messages.splice(0, entry.messages.length - maxMessages);
|
|
887
|
+
if (enableSummarization && summarize && excess.length > 0) {
|
|
888
|
+
const newSummary = await summarize(excess);
|
|
889
|
+
entry.summary = entry.summary ? `${entry.summary}\n\n${newSummary}` : newSummary;
|
|
890
|
+
}
|
|
891
|
+
}
|
|
892
|
+
await store.set(key, entry);
|
|
893
|
+
},
|
|
894
|
+
async getContext(key, recentCount = 10) {
|
|
895
|
+
const entry = await store.get(key);
|
|
896
|
+
if (!entry) return { messages: [] };
|
|
897
|
+
return {
|
|
898
|
+
summary: entry.summary,
|
|
899
|
+
messages: entry.messages.slice(-recentCount)
|
|
900
|
+
};
|
|
901
|
+
},
|
|
902
|
+
async getMessages(key) {
|
|
903
|
+
return (await store.get(key))?.messages ?? [];
|
|
904
|
+
},
|
|
905
|
+
async clear(key) {
|
|
906
|
+
await store.delete(key);
|
|
907
|
+
},
|
|
908
|
+
async updateMetadata(key, metadata) {
|
|
909
|
+
const entry = await this.getOrCreate(key);
|
|
910
|
+
entry.metadata = {
|
|
911
|
+
...entry.metadata,
|
|
912
|
+
...metadata
|
|
913
|
+
};
|
|
914
|
+
entry.updatedAt = Date.now();
|
|
915
|
+
await store.set(key, entry);
|
|
916
|
+
},
|
|
917
|
+
async search(key, query) {
|
|
918
|
+
const entry = await store.get(key);
|
|
919
|
+
if (!entry) return [];
|
|
920
|
+
const lowerQuery = query.toLowerCase();
|
|
921
|
+
return entry.messages.filter((m) => m.content.toLowerCase().includes(lowerQuery));
|
|
922
|
+
}
|
|
923
|
+
};
|
|
924
|
+
}
|
|
925
|
+
/**
|
|
926
|
+
* Sliding window context builder.
|
|
927
|
+
* Keeps recent messages within token/message limits.
|
|
928
|
+
*
|
|
929
|
+
* @deprecated Use createKVCachePreservingContext for better performance.
|
|
930
|
+
* This version breaks KV-cache by removing messages from the start.
|
|
931
|
+
*/
|
|
932
|
+
function createSlidingWindowContext(config) {
|
|
933
|
+
const { maxMessages = 20, maxTokens = 4e3, estimateTokens = (text) => Math.ceil(text.length / 4) } = config;
|
|
934
|
+
return function buildContext(messages) {
|
|
935
|
+
const result = [];
|
|
936
|
+
let tokenCount = 0;
|
|
937
|
+
for (let i = messages.length - 1; i >= 0; i--) {
|
|
938
|
+
const msg = messages[i];
|
|
939
|
+
if (!msg) continue;
|
|
940
|
+
const tokens = estimateTokens(msg.content);
|
|
941
|
+
if (result.length >= maxMessages) break;
|
|
942
|
+
if (tokenCount + tokens > maxTokens) break;
|
|
943
|
+
result.unshift(msg);
|
|
944
|
+
tokenCount += tokens;
|
|
945
|
+
}
|
|
946
|
+
return result;
|
|
947
|
+
};
|
|
948
|
+
}
|
|
949
|
+
/**
|
|
950
|
+
* KV-cache preserving context builder.
|
|
951
|
+
*
|
|
952
|
+
* SDK v6 pattern: Always keep system prompt at the very start to maximize
|
|
953
|
+
* KV-cache hits. When trimming, remove messages from the middle, not the start.
|
|
954
|
+
*
|
|
955
|
+
* This is critical for performance with Claude and other models that support
|
|
956
|
+
* prompt caching - the cache key is based on the prefix of the prompt.
|
|
957
|
+
*
|
|
958
|
+
* @example
|
|
959
|
+
* ```typescript
|
|
960
|
+
* const buildContext = createKVCachePreservingContext({
|
|
961
|
+
* maxTokens: 100000,
|
|
962
|
+
* systemPrompt: 'You are a helpful assistant...',
|
|
963
|
+
* });
|
|
964
|
+
*
|
|
965
|
+
* // Messages are trimmed from middle, keeping system prompt at start
|
|
966
|
+
* const contextMessages = buildContext(allMessages);
|
|
967
|
+
* ```
|
|
968
|
+
*/
|
|
969
|
+
function createKVCachePreservingContext(config) {
|
|
970
|
+
const { maxTokens = 1e5, maxMessages = 100, systemPrompt, estimateTokens = (text) => Math.ceil(text.length / 4), messagePriority } = config;
|
|
971
|
+
const defaultPriority = (message, index, total) => {
|
|
972
|
+
if (index < 2) return 100;
|
|
973
|
+
if (index >= total - 5) return 90 - (total - 1 - index);
|
|
974
|
+
return 50 - (total - 1 - index) * .5;
|
|
975
|
+
};
|
|
976
|
+
const getPriority = messagePriority ?? defaultPriority;
|
|
977
|
+
return function buildContext(messages) {
|
|
978
|
+
const systemTokens = systemPrompt ? estimateTokens(systemPrompt) : 0;
|
|
979
|
+
const availableMessages = maxMessages;
|
|
980
|
+
const sorted = [...messages.map((msg, index) => ({
|
|
981
|
+
message: msg,
|
|
982
|
+
tokens: estimateTokens(msg.content),
|
|
983
|
+
priority: getPriority(msg, index, messages.length),
|
|
984
|
+
originalIndex: index
|
|
985
|
+
}))].sort((a, b) => b.priority - a.priority);
|
|
986
|
+
const selected = [];
|
|
987
|
+
let totalTokens = systemTokens;
|
|
988
|
+
for (const item of sorted) {
|
|
989
|
+
if (selected.length >= availableMessages) break;
|
|
990
|
+
if (totalTokens + item.tokens > maxTokens) continue;
|
|
991
|
+
selected.push(item);
|
|
992
|
+
totalTokens += item.tokens;
|
|
993
|
+
}
|
|
994
|
+
selected.sort((a, b) => a.originalIndex - b.originalIndex);
|
|
995
|
+
return {
|
|
996
|
+
systemPrompt,
|
|
997
|
+
messages: selected.map((s) => s.message),
|
|
998
|
+
trimmedCount: messages.length - selected.length,
|
|
999
|
+
totalTokens
|
|
1000
|
+
};
|
|
1001
|
+
};
|
|
1002
|
+
}
|
|
1003
|
+
/**
|
|
1004
|
+
* Immutable context builder that only appends.
|
|
1005
|
+
* Never removes messages from the start, maximizing KV-cache hits.
|
|
1006
|
+
*
|
|
1007
|
+
* When context gets too long, returns a signal to summarize and reset.
|
|
1008
|
+
*
|
|
1009
|
+
* @example
|
|
1010
|
+
* ```typescript
|
|
1011
|
+
* const contextBuilder = createImmutableContextBuilder({
|
|
1012
|
+
* systemPrompt: 'You are helpful...',
|
|
1013
|
+
* maxTokens: 100000,
|
|
1014
|
+
* compactionThreshold: 80000, // Start warning at 80%
|
|
1015
|
+
* });
|
|
1016
|
+
*
|
|
1017
|
+
* const context = contextBuilder.append(newMessage);
|
|
1018
|
+
* if (context.shouldCompact) {
|
|
1019
|
+
* // Summarize and start fresh context
|
|
1020
|
+
* const summary = await summarize(context.messages);
|
|
1021
|
+
* contextBuilder.reset(summary);
|
|
1022
|
+
* }
|
|
1023
|
+
* ```
|
|
1024
|
+
*/
|
|
1025
|
+
function createImmutableContextBuilder(config) {
|
|
1026
|
+
const { systemPrompt, maxTokens = 1e5, compactionThreshold = maxTokens * .8, estimateTokens = (text) => Math.ceil(text.length / 4) } = config;
|
|
1027
|
+
const systemTokens = systemPrompt ? estimateTokens(systemPrompt) : 0;
|
|
1028
|
+
let messages = [];
|
|
1029
|
+
let totalTokens = systemTokens;
|
|
1030
|
+
return {
|
|
1031
|
+
append(message) {
|
|
1032
|
+
const msgTokens = estimateTokens(message.content);
|
|
1033
|
+
totalTokens += msgTokens;
|
|
1034
|
+
messages.push(message);
|
|
1035
|
+
return {
|
|
1036
|
+
systemPrompt,
|
|
1037
|
+
messages: [...messages],
|
|
1038
|
+
totalTokens,
|
|
1039
|
+
shouldCompact: totalTokens >= compactionThreshold,
|
|
1040
|
+
isFull: totalTokens >= maxTokens
|
|
1041
|
+
};
|
|
1042
|
+
},
|
|
1043
|
+
getContext() {
|
|
1044
|
+
return {
|
|
1045
|
+
systemPrompt,
|
|
1046
|
+
messages: [...messages],
|
|
1047
|
+
totalTokens
|
|
1048
|
+
};
|
|
1049
|
+
},
|
|
1050
|
+
reset(summary) {
|
|
1051
|
+
messages = [];
|
|
1052
|
+
totalTokens = systemTokens;
|
|
1053
|
+
if (summary) {
|
|
1054
|
+
const summaryMessage = {
|
|
1055
|
+
role: "system",
|
|
1056
|
+
content: `Previous conversation summary:\n${summary}`,
|
|
1057
|
+
timestamp: Date.now()
|
|
1058
|
+
};
|
|
1059
|
+
messages.push(summaryMessage);
|
|
1060
|
+
totalTokens += estimateTokens(summaryMessage.content);
|
|
1061
|
+
}
|
|
1062
|
+
},
|
|
1063
|
+
get tokenCount() {
|
|
1064
|
+
return totalTokens;
|
|
1065
|
+
},
|
|
1066
|
+
get messageCount() {
|
|
1067
|
+
return messages.length;
|
|
1068
|
+
}
|
|
1069
|
+
};
|
|
1070
|
+
}
|
|
1071
|
+
/**
|
|
1072
|
+
* Creates a compacting memory that summarizes old messages.
|
|
1073
|
+
*/
|
|
1074
|
+
function createCompactingMemory(config) {
|
|
1075
|
+
const { store, summarize, compactThreshold = 50, keepRecent = 10, maxMessages, maxTokens, enableSummarization } = config;
|
|
1076
|
+
return {
|
|
1077
|
+
...createMemoryManager({
|
|
1078
|
+
store,
|
|
1079
|
+
maxMessages,
|
|
1080
|
+
maxTokens,
|
|
1081
|
+
enableSummarization,
|
|
1082
|
+
summarize
|
|
1083
|
+
}),
|
|
1084
|
+
async compact(key) {
|
|
1085
|
+
const entry = await store.get(key);
|
|
1086
|
+
if (!entry || entry.messages.length < compactThreshold) return;
|
|
1087
|
+
const toKeep = entry.messages.slice(-keepRecent);
|
|
1088
|
+
const toSummarize = entry.messages.slice(0, -keepRecent);
|
|
1089
|
+
if (toSummarize.length === 0) return;
|
|
1090
|
+
const newSummary = await summarize(toSummarize);
|
|
1091
|
+
entry.messages = toKeep;
|
|
1092
|
+
entry.summary = entry.summary ? `${entry.summary}\n\n${newSummary}` : newSummary;
|
|
1093
|
+
entry.updatedAt = Date.now();
|
|
1094
|
+
await store.set(key, entry);
|
|
1095
|
+
}
|
|
1096
|
+
};
|
|
1097
|
+
}
|
|
1098
|
+
|
|
1099
|
+
//#endregion
|
|
1100
|
+
//#region src/grounding/context-engineering/error-handling.ts
|
|
1101
|
+
/**
|
|
1102
|
+
* AI error with typed classification.
|
|
1103
|
+
*/
|
|
1104
|
+
var AIError = class extends Error {
|
|
1105
|
+
type;
|
|
1106
|
+
retryable;
|
|
1107
|
+
retryAfter;
|
|
1108
|
+
details;
|
|
1109
|
+
constructor(message, type, options) {
|
|
1110
|
+
super(message, { cause: options?.cause });
|
|
1111
|
+
this.name = "AIError";
|
|
1112
|
+
this.type = type;
|
|
1113
|
+
this.retryable = options?.retryable ?? isRetryableByDefault(type);
|
|
1114
|
+
this.retryAfter = options?.retryAfter;
|
|
1115
|
+
this.details = options?.details;
|
|
1116
|
+
}
|
|
1117
|
+
};
|
|
1118
|
+
/**
|
|
1119
|
+
* Determines if an error type is retryable by default.
|
|
1120
|
+
*/
|
|
1121
|
+
function isRetryableByDefault(type) {
|
|
1122
|
+
switch (type) {
|
|
1123
|
+
case "rate-limit":
|
|
1124
|
+
case "timeout":
|
|
1125
|
+
case "api-error": return true;
|
|
1126
|
+
case "context-length":
|
|
1127
|
+
case "content-filter":
|
|
1128
|
+
case "tool-error":
|
|
1129
|
+
case "validation":
|
|
1130
|
+
case "unknown": return false;
|
|
1131
|
+
}
|
|
1132
|
+
}
|
|
1133
|
+
/**
|
|
1134
|
+
* Classifies an error into an AIError type.
|
|
1135
|
+
*/
|
|
1136
|
+
function classifyError(error) {
|
|
1137
|
+
if (error instanceof AIError) return error;
|
|
1138
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
1139
|
+
const cause = error instanceof Error ? error : void 0;
|
|
1140
|
+
if (message.includes("rate limit") || message.includes("429") || message.includes("too many requests")) return new AIError(message, "rate-limit", {
|
|
1141
|
+
retryable: true,
|
|
1142
|
+
retryAfter: extractRetryAfter(message),
|
|
1143
|
+
cause
|
|
1144
|
+
});
|
|
1145
|
+
if (message.includes("context length") || message.includes("maximum context") || message.includes("token limit") || message.includes("too long")) return new AIError(message, "context-length", {
|
|
1146
|
+
retryable: false,
|
|
1147
|
+
cause
|
|
1148
|
+
});
|
|
1149
|
+
if (message.includes("content filter") || message.includes("content policy") || message.includes("safety")) return new AIError(message, "content-filter", {
|
|
1150
|
+
retryable: false,
|
|
1151
|
+
cause
|
|
1152
|
+
});
|
|
1153
|
+
if (message.includes("timeout") || message.includes("timed out") || message.includes("ETIMEDOUT")) return new AIError(message, "timeout", {
|
|
1154
|
+
retryable: true,
|
|
1155
|
+
cause
|
|
1156
|
+
});
|
|
1157
|
+
if (message.includes("500") || message.includes("502") || message.includes("503") || message.includes("API error")) return new AIError(message, "api-error", {
|
|
1158
|
+
retryable: true,
|
|
1159
|
+
cause
|
|
1160
|
+
});
|
|
1161
|
+
return new AIError(message, "unknown", { cause });
|
|
1162
|
+
}
|
|
1163
|
+
/**
|
|
1164
|
+
* Extracts retry-after value from error message.
|
|
1165
|
+
*/
|
|
1166
|
+
function extractRetryAfter(message) {
|
|
1167
|
+
const match = message.match(/retry.+?(\d+)\s*(s|seconds?|ms|milliseconds?)/i);
|
|
1168
|
+
if (match?.[1] && match[2]) {
|
|
1169
|
+
const value = parseInt(match[1], 10);
|
|
1170
|
+
return match[2].toLowerCase().startsWith("ms") ? value : value * 1e3;
|
|
1171
|
+
}
|
|
1172
|
+
}
|
|
1173
|
+
/**
|
|
1174
|
+
* Creates an error recovery handler.
|
|
1175
|
+
*
|
|
1176
|
+
* @param strategies - Recovery strategies in priority order
|
|
1177
|
+
* @returns Recovery handler
|
|
1178
|
+
*
|
|
1179
|
+
* @example
|
|
1180
|
+
* ```ts
|
|
1181
|
+
* const recover = createErrorRecovery([
|
|
1182
|
+
* {
|
|
1183
|
+
* errorTypes: ['rate-limit'],
|
|
1184
|
+
* action: { type: 'retry', backoff: 'exponential', baseDelay: 1000 },
|
|
1185
|
+
* maxRetries: 3,
|
|
1186
|
+
* },
|
|
1187
|
+
* {
|
|
1188
|
+
* errorTypes: ['context-length'],
|
|
1189
|
+
* action: { type: 'reduce-context', factor: 0.5 },
|
|
1190
|
+
* },
|
|
1191
|
+
* {
|
|
1192
|
+
* errorTypes: ['content-filter'],
|
|
1193
|
+
* action: { type: 'fail', message: 'Content blocked by safety filters' },
|
|
1194
|
+
* },
|
|
1195
|
+
* ]);
|
|
1196
|
+
*
|
|
1197
|
+
* try {
|
|
1198
|
+
* await generateText(...);
|
|
1199
|
+
* } catch (e) {
|
|
1200
|
+
* const result = await recover(e, { attempt: 1 });
|
|
1201
|
+
* if (result.continueExecution) {
|
|
1202
|
+
* // Retry with modified params
|
|
1203
|
+
* }
|
|
1204
|
+
* }
|
|
1205
|
+
* ```
|
|
1206
|
+
*/
|
|
1207
|
+
function createErrorRecovery(strategies) {
|
|
1208
|
+
const retryCounters = /* @__PURE__ */ new Map();
|
|
1209
|
+
return async function recover(error, context) {
|
|
1210
|
+
const aiError = classifyError(error);
|
|
1211
|
+
const strategy = strategies.find((s) => s.errorTypes.includes(aiError.type));
|
|
1212
|
+
if (!strategy) return {
|
|
1213
|
+
success: false,
|
|
1214
|
+
action: "none",
|
|
1215
|
+
continueExecution: false,
|
|
1216
|
+
error: aiError
|
|
1217
|
+
};
|
|
1218
|
+
const currentRetries = retryCounters.get(aiError.type) ?? 0;
|
|
1219
|
+
if (strategy.maxRetries !== void 0 && currentRetries >= strategy.maxRetries) return {
|
|
1220
|
+
success: false,
|
|
1221
|
+
action: "max-retries-exceeded",
|
|
1222
|
+
continueExecution: false,
|
|
1223
|
+
error: aiError
|
|
1224
|
+
};
|
|
1225
|
+
switch (strategy.action.type) {
|
|
1226
|
+
case "retry": {
|
|
1227
|
+
retryCounters.set(aiError.type, currentRetries + 1);
|
|
1228
|
+
const delay = calculateDelay(strategy.action, context.attempt);
|
|
1229
|
+
if (aiError.retryAfter) await sleep(aiError.retryAfter);
|
|
1230
|
+
else await sleep(delay);
|
|
1231
|
+
return {
|
|
1232
|
+
success: true,
|
|
1233
|
+
action: "retry",
|
|
1234
|
+
continueExecution: true
|
|
1235
|
+
};
|
|
1236
|
+
}
|
|
1237
|
+
case "reduce-context": {
|
|
1238
|
+
const factor = strategy.action.factor ?? .5;
|
|
1239
|
+
return {
|
|
1240
|
+
success: true,
|
|
1241
|
+
action: "reduce-context",
|
|
1242
|
+
continueExecution: true,
|
|
1243
|
+
modifiedParams: { maxMessages: Math.floor((context.maxMessages ?? 20) * factor) }
|
|
1244
|
+
};
|
|
1245
|
+
}
|
|
1246
|
+
case "switch-model": return {
|
|
1247
|
+
success: true,
|
|
1248
|
+
action: "switch-model",
|
|
1249
|
+
continueExecution: true,
|
|
1250
|
+
modifiedParams: { model: strategy.action.fallbackModel }
|
|
1251
|
+
};
|
|
1252
|
+
case "fail": return {
|
|
1253
|
+
success: false,
|
|
1254
|
+
action: "fail",
|
|
1255
|
+
continueExecution: false,
|
|
1256
|
+
error: new AIError(strategy.action.message ?? aiError.message, aiError.type)
|
|
1257
|
+
};
|
|
1258
|
+
case "custom": return strategy.action.handler(aiError);
|
|
1259
|
+
}
|
|
1260
|
+
};
|
|
1261
|
+
}
|
|
1262
|
+
/**
|
|
1263
|
+
* Calculates delay based on backoff strategy.
|
|
1264
|
+
*/
|
|
1265
|
+
function calculateDelay(action, attempt) {
|
|
1266
|
+
const baseDelay = action.baseDelay ?? 1e3;
|
|
1267
|
+
const backoff = action.backoff ?? "fixed";
|
|
1268
|
+
switch (backoff) {
|
|
1269
|
+
case "exponential": return baseDelay * Math.pow(2, attempt - 1);
|
|
1270
|
+
case "linear": return baseDelay * attempt;
|
|
1271
|
+
case "fixed": return baseDelay;
|
|
1272
|
+
default: {
|
|
1273
|
+
const exhaustiveCheck = backoff;
|
|
1274
|
+
throw new Error(`Unknown backoff strategy: ${exhaustiveCheck}`);
|
|
1275
|
+
}
|
|
1276
|
+
}
|
|
1277
|
+
}
|
|
1278
|
+
/**
|
|
1279
|
+
* Sleep helper.
|
|
1280
|
+
*/
|
|
1281
|
+
function sleep(ms) {
|
|
1282
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
1283
|
+
}
|
|
1284
|
+
/**
|
|
1285
|
+
* Default recovery strategies.
|
|
1286
|
+
*/
|
|
1287
|
+
const DefaultRecoveryStrategies = [
|
|
1288
|
+
{
|
|
1289
|
+
errorTypes: ["rate-limit"],
|
|
1290
|
+
action: {
|
|
1291
|
+
type: "retry",
|
|
1292
|
+
backoff: "exponential",
|
|
1293
|
+
baseDelay: 1e3
|
|
1294
|
+
},
|
|
1295
|
+
maxRetries: 5
|
|
1296
|
+
},
|
|
1297
|
+
{
|
|
1298
|
+
errorTypes: ["timeout"],
|
|
1299
|
+
action: {
|
|
1300
|
+
type: "retry",
|
|
1301
|
+
backoff: "exponential",
|
|
1302
|
+
baseDelay: 2e3
|
|
1303
|
+
},
|
|
1304
|
+
maxRetries: 3
|
|
1305
|
+
},
|
|
1306
|
+
{
|
|
1307
|
+
errorTypes: ["api-error"],
|
|
1308
|
+
action: {
|
|
1309
|
+
type: "retry",
|
|
1310
|
+
backoff: "exponential",
|
|
1311
|
+
baseDelay: 1e3
|
|
1312
|
+
},
|
|
1313
|
+
maxRetries: 3
|
|
1314
|
+
},
|
|
1315
|
+
{
|
|
1316
|
+
errorTypes: ["context-length"],
|
|
1317
|
+
action: {
|
|
1318
|
+
type: "reduce-context",
|
|
1319
|
+
factor: .5
|
|
1320
|
+
},
|
|
1321
|
+
maxRetries: 2
|
|
1322
|
+
},
|
|
1323
|
+
{
|
|
1324
|
+
errorTypes: ["content-filter"],
|
|
1325
|
+
action: {
|
|
1326
|
+
type: "fail",
|
|
1327
|
+
message: "Content was blocked by safety filters"
|
|
1328
|
+
}
|
|
1329
|
+
}
|
|
1330
|
+
];
|
|
1331
|
+
|
|
1332
|
+
//#endregion
|
|
1333
|
+
export { groupSources as C, validateSource as D, sourcesToContext as E, validateSources as O, formatAsInlineCitations as S, selectTopSources as T, createSourceRegistry as _, InMemoryStore as a, filterByScore as b, createKVCachePreservingContext as c, MaskingRules as d, createActiveToolsSelector as f, createToolMasker as g, createProgressiveDisclosure as h, createErrorRecovery as i, InMemoryVectorStore as k, createMemoryManager as l, createPhasedToolActivation as m, DefaultRecoveryStrategies as n, createCompactingMemory as o, createContextualToolActivation as p, classifyError as r, createImmutableContextBuilder as s, AIError as t, createSlidingWindowContext as u, deduplicateSources as v, mergeSources as w, formatAsBibliography as x, filterByMetadata as y };
|
|
1334
|
+
//# sourceMappingURL=error-handling-DNVkm6RY.mjs.map
|