@warlock.js/ai 4.4.0 → 4.5.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/CHANGELOG.md +52 -55
- package/cjs/index.cjs +221 -14147
- package/cjs/src-C02yzsLs.cjs +22991 -0
- package/cjs/src-C02yzsLs.cjs.map +1 -0
- package/cjs/src-DFibP2FQ.cjs +30 -0
- package/esm/agent/agent-config.type.d.mts +90 -1
- package/esm/agent/agent-config.type.d.mts.map +1 -1
- package/esm/agent/agent-input-builder.mjs +27 -6
- package/esm/agent/agent-input-builder.mjs.map +1 -1
- package/esm/agent/agent.d.mts +40 -1
- package/esm/agent/agent.d.mts.map +1 -1
- package/esm/agent/agent.mjs +203 -30
- package/esm/agent/agent.mjs.map +1 -1
- package/esm/agent/index.d.mts +2 -1
- package/esm/agent/index.mjs +1 -0
- package/esm/agent/judge-config.type.d.mts +33 -0
- package/esm/agent/judge-config.type.d.mts.map +1 -0
- package/esm/agent/judge-config.type.mjs +13 -0
- package/esm/agent/judge-config.type.mjs.map +1 -0
- package/esm/ai-openai/src/embedder.mjs +4 -0
- package/esm/ai-openai/src/index.mjs +4 -0
- package/esm/ai-openai/src/model.mjs +5 -0
- package/esm/ai-openai/src/sdk.mjs +6 -0
- package/esm/ai-openai/src/utils/index.mjs +4 -0
- package/esm/ai-openai/src/utils/to-openai-tools.mjs +3 -0
- package/esm/ai-openai/src/utils/wrap-openai-error.mjs +4 -0
- package/esm/ai.d.mts +119 -53
- package/esm/ai.d.mts.map +1 -1
- package/esm/ai.mjs +43 -8
- package/esm/ai.mjs.map +1 -1
- package/esm/batch/batch.d.mts.map +1 -1
- package/esm/batch/batch.mjs +21 -1
- package/esm/batch/batch.mjs.map +1 -1
- package/esm/batch/batch.type.d.mts +11 -4
- package/esm/batch/batch.type.d.mts.map +1 -1
- package/esm/config.d.mts +39 -3
- package/esm/config.d.mts.map +1 -1
- package/esm/config.mjs +26 -2
- package/esm/config.mjs.map +1 -1
- package/esm/contracts/agent/agent-options.type.d.mts +11 -3
- package/esm/contracts/agent/agent-options.type.d.mts.map +1 -1
- package/esm/contracts/agent/eval.type.d.mts +43 -2
- package/esm/contracts/agent/eval.type.d.mts.map +1 -1
- package/esm/contracts/attachment-policy.type.d.mts +51 -0
- package/esm/contracts/attachment-policy.type.d.mts.map +1 -0
- package/esm/contracts/attachment.type.d.mts +16 -7
- package/esm/contracts/attachment.type.d.mts.map +1 -1
- package/esm/contracts/content-part.type.d.mts +14 -5
- package/esm/contracts/content-part.type.d.mts.map +1 -1
- package/esm/contracts/events/supervisor-events.type.d.mts.map +1 -1
- package/esm/contracts/index.d.mts +6 -4
- package/esm/contracts/model.contract.d.mts +11 -8
- package/esm/contracts/model.contract.d.mts.map +1 -1
- package/esm/contracts/orchestrator/index.d.mts +1 -0
- package/esm/contracts/orchestrator/orchestrator-config.type.d.mts +31 -2
- package/esm/contracts/orchestrator/orchestrator-config.type.d.mts.map +1 -1
- package/esm/contracts/orchestrator/session-lock.contract.d.mts +47 -0
- package/esm/contracts/orchestrator/session-lock.contract.d.mts.map +1 -0
- package/esm/contracts/planner/index.d.mts +1 -1
- package/esm/contracts/planner/planner-config.type.d.mts +31 -0
- package/esm/contracts/planner/planner-config.type.d.mts.map +1 -1
- package/esm/contracts/planner/planner-execute-options.type.d.mts +48 -1
- package/esm/contracts/planner/planner-execute-options.type.d.mts.map +1 -1
- package/esm/contracts/planner/planner-result.type.d.mts +8 -0
- package/esm/contracts/planner/planner-result.type.d.mts.map +1 -1
- package/esm/contracts/planner/planner.contract.d.mts +1 -1
- package/esm/contracts/result/agent-result.type.d.mts +6 -4
- package/esm/contracts/result/agent-result.type.d.mts.map +1 -1
- package/esm/contracts/result/base-report.type.d.mts +21 -3
- package/esm/contracts/result/base-report.type.d.mts.map +1 -1
- package/esm/contracts/result/base-report.type.mjs.map +1 -1
- package/esm/contracts/result/execution-report.type.d.mts +53 -1
- package/esm/contracts/result/execution-report.type.d.mts.map +1 -1
- package/esm/contracts/result/supervisor-result.type.d.mts +14 -2
- package/esm/contracts/result/supervisor-result.type.d.mts.map +1 -1
- package/esm/contracts/result/workflow-result.type.d.mts +2 -1
- package/esm/contracts/result/workflow-result.type.d.mts.map +1 -1
- package/esm/contracts/supervisor/supervisor-config.type.d.mts +29 -0
- package/esm/contracts/supervisor/supervisor-config.type.d.mts.map +1 -1
- package/esm/contracts/system-prompt.contract.d.mts +103 -1
- package/esm/contracts/system-prompt.contract.d.mts.map +1 -1
- package/esm/contracts/team/index.d.mts +1 -0
- package/esm/contracts/team/team-config.type.d.mts +127 -0
- package/esm/contracts/team/team-config.type.d.mts.map +1 -0
- package/esm/contracts/tool.contract.d.mts +4 -2
- package/esm/contracts/tool.contract.d.mts.map +1 -1
- package/esm/contracts/workflow/step.contract.d.mts +30 -5
- package/esm/contracts/workflow/step.contract.d.mts.map +1 -1
- package/esm/contracts/workflow/workflow.contract.d.mts +16 -0
- package/esm/contracts/workflow/workflow.contract.d.mts.map +1 -1
- package/esm/errors/error-code.type.d.mts +1 -1
- package/esm/errors/index.d.mts +1 -0
- package/esm/errors/index.mjs +1 -0
- package/esm/errors/outbound-policy-error.d.mts +27 -0
- package/esm/errors/outbound-policy-error.d.mts.map +1 -0
- package/esm/errors/outbound-policy-error.mjs +32 -0
- package/esm/errors/outbound-policy-error.mjs.map +1 -0
- package/esm/eval/dataset.d.mts +28 -0
- package/esm/eval/dataset.d.mts.map +1 -0
- package/esm/eval/dataset.mjs +112 -0
- package/esm/eval/dataset.mjs.map +1 -0
- package/esm/eval/dataset.type.d.mts +53 -0
- package/esm/eval/dataset.type.d.mts.map +1 -0
- package/esm/eval/eval-runner.d.mts.map +1 -1
- package/esm/eval/eval-runner.mjs +16 -2
- package/esm/eval/eval-runner.mjs.map +1 -1
- package/esm/eval/index.d.mts +20 -1
- package/esm/eval/index.d.mts.map +1 -1
- package/esm/eval/index.mjs +20 -2
- package/esm/eval/index.mjs.map +1 -1
- package/esm/eval/regression.d.mts +30 -0
- package/esm/eval/regression.d.mts.map +1 -0
- package/esm/eval/regression.mjs +51 -0
- package/esm/eval/regression.mjs.map +1 -0
- package/esm/eval/report-json.d.mts +30 -0
- package/esm/eval/report-json.d.mts.map +1 -0
- package/esm/eval/report-json.mjs +33 -0
- package/esm/eval/report-json.mjs.map +1 -0
- package/esm/eval/report-junit.d.mts +22 -0
- package/esm/eval/report-junit.d.mts.map +1 -0
- package/esm/eval/report-junit.mjs +60 -0
- package/esm/eval/report-junit.mjs.map +1 -0
- package/esm/guard/contracts/guard-options.type.d.mts +165 -0
- package/esm/guard/contracts/guard-options.type.d.mts.map +1 -0
- package/esm/guard/contracts/guardrail.contract.d.mts +78 -0
- package/esm/guard/contracts/guardrail.contract.d.mts.map +1 -0
- package/esm/guard/contracts/index.d.mts +4 -0
- package/esm/guard/contracts/openai-client.contract.d.mts +51 -0
- package/esm/guard/contracts/openai-client.contract.d.mts.map +1 -0
- package/esm/guard/contracts/verdict.type.d.mts +76 -0
- package/esm/guard/contracts/verdict.type.d.mts.map +1 -0
- package/esm/guard/detectors/index.d.mts +4 -0
- package/esm/guard/detectors/index.mjs +6 -0
- package/esm/guard/detectors/injection.d.mts +34 -0
- package/esm/guard/detectors/injection.d.mts.map +1 -0
- package/esm/guard/detectors/injection.mjs +254 -0
- package/esm/guard/detectors/injection.mjs.map +1 -0
- package/esm/guard/detectors/moderation.d.mts +32 -0
- package/esm/guard/detectors/moderation.d.mts.map +1 -0
- package/esm/guard/detectors/moderation.mjs +134 -0
- package/esm/guard/detectors/moderation.mjs.map +1 -0
- package/esm/guard/detectors/pii.d.mts +41 -0
- package/esm/guard/detectors/pii.d.mts.map +1 -0
- package/esm/guard/detectors/pii.mjs +199 -0
- package/esm/guard/detectors/pii.mjs.map +1 -0
- package/esm/guard/detectors/topic.d.mts +29 -0
- package/esm/guard/detectors/topic.d.mts.map +1 -0
- package/esm/guard/detectors/topic.mjs +99 -0
- package/esm/guard/detectors/topic.mjs.map +1 -0
- package/esm/guard/errors.d.mts +12 -0
- package/esm/guard/errors.d.mts.map +1 -0
- package/esm/guard/errors.mjs +18 -0
- package/esm/guard/errors.mjs.map +1 -0
- package/esm/guard/guard.d.mts +67 -0
- package/esm/guard/guard.d.mts.map +1 -0
- package/esm/guard/guard.mjs +209 -0
- package/esm/guard/guard.mjs.map +1 -0
- package/esm/guard/guardrail.d.mts +39 -0
- package/esm/guard/guardrail.d.mts.map +1 -0
- package/esm/guard/guardrail.mjs +22 -0
- package/esm/guard/guardrail.mjs.map +1 -0
- package/esm/human/contracts/approval.type.d.mts +154 -0
- package/esm/human/contracts/approval.type.d.mts.map +1 -0
- package/esm/human/contracts/human-approval.type.d.mts +38 -0
- package/esm/human/contracts/human-approval.type.d.mts.map +1 -0
- package/esm/human/contracts/index.d.mts +4 -0
- package/esm/human/contracts/interrupt-store.contract.d.mts +112 -0
- package/esm/human/contracts/interrupt-store.contract.d.mts.map +1 -0
- package/esm/human/contracts/resume.type.d.mts +77 -0
- package/esm/human/contracts/resume.type.d.mts.map +1 -0
- package/esm/human/errors.d.mts +84 -0
- package/esm/human/errors.d.mts.map +1 -0
- package/esm/human/errors.mjs +60 -0
- package/esm/human/errors.mjs.map +1 -0
- package/esm/human/human-approval.d.mts +57 -0
- package/esm/human/human-approval.d.mts.map +1 -0
- package/esm/human/human-approval.mjs +170 -0
- package/esm/human/human-approval.mjs.map +1 -0
- package/esm/human/policy.d.mts +55 -0
- package/esm/human/policy.d.mts.map +1 -0
- package/esm/human/policy.mjs +67 -0
- package/esm/human/policy.mjs.map +1 -0
- package/esm/human/register.mjs +37 -0
- package/esm/human/register.mjs.map +1 -0
- package/esm/human/resume-seed.mjs +53 -0
- package/esm/human/resume-seed.mjs.map +1 -0
- package/esm/human/resume.d.mts +54 -0
- package/esm/human/resume.d.mts.map +1 -0
- package/esm/human/resume.mjs +121 -0
- package/esm/human/resume.mjs.map +1 -0
- package/esm/human/stores/index.mjs +5 -0
- package/esm/human/stores/memory.d.mts +30 -0
- package/esm/human/stores/memory.d.mts.map +1 -0
- package/esm/human/stores/memory.mjs +91 -0
- package/esm/human/stores/memory.mjs.map +1 -0
- package/esm/human/stores/pg.d.mts +59 -0
- package/esm/human/stores/pg.d.mts.map +1 -0
- package/esm/human/stores/pg.mjs +220 -0
- package/esm/human/stores/pg.mjs.map +1 -0
- package/esm/human/stores/redis.d.mts +56 -0
- package/esm/human/stores/redis.d.mts.map +1 -0
- package/esm/human/stores/redis.mjs +201 -0
- package/esm/human/stores/redis.mjs.map +1 -0
- package/esm/index.d.mts +113 -22
- package/esm/index.mjs +82 -11
- package/esm/middleware/builtins/budget.mjs +6 -2
- package/esm/middleware/builtins/budget.mjs.map +1 -1
- package/esm/middleware/utils/extract-user-text.d.mts +8 -1
- package/esm/middleware/utils/extract-user-text.d.mts.map +1 -1
- package/esm/middleware/utils/extract-user-text.mjs +8 -1
- package/esm/middleware/utils/extract-user-text.mjs.map +1 -1
- package/esm/object-stream/index.d.mts +2 -0
- package/esm/object-stream/index.mjs +4 -0
- package/esm/object-stream/parse-partial-json.d.mts +22 -0
- package/esm/object-stream/parse-partial-json.d.mts.map +1 -0
- package/esm/object-stream/parse-partial-json.mjs +78 -0
- package/esm/object-stream/parse-partial-json.mjs.map +1 -0
- package/esm/object-stream/stream-object.d.mts +68 -0
- package/esm/object-stream/stream-object.d.mts.map +1 -0
- package/esm/object-stream/stream-object.mjs +104 -0
- package/esm/object-stream/stream-object.mjs.map +1 -0
- package/esm/observe/index.mjs +4 -0
- package/esm/observe/observer-registry.d.mts +30 -0
- package/esm/observe/observer-registry.d.mts.map +1 -0
- package/esm/observe/observer-registry.mjs +51 -0
- package/esm/observe/observer-registry.mjs.map +1 -0
- package/esm/observe/observer.contract.d.mts +40 -0
- package/esm/observe/observer.contract.d.mts.map +1 -0
- package/esm/observe/resolve-observers.d.mts +40 -0
- package/esm/observe/resolve-observers.d.mts.map +1 -0
- package/esm/observe/resolve-observers.mjs +73 -0
- package/esm/observe/resolve-observers.mjs.map +1 -0
- package/esm/orchestrator/execution.d.mts.map +1 -1
- package/esm/orchestrator/execution.mjs +5 -2
- package/esm/orchestrator/execution.mjs.map +1 -1
- package/esm/orchestrator/index.d.mts +1 -0
- package/esm/orchestrator/index.mjs +1 -0
- package/esm/orchestrator/orchestrator.d.mts.map +1 -1
- package/esm/orchestrator/orchestrator.mjs +39 -6
- package/esm/orchestrator/orchestrator.mjs.map +1 -1
- package/esm/orchestrator/session-lock.d.mts +25 -0
- package/esm/orchestrator/session-lock.d.mts.map +1 -0
- package/esm/orchestrator/session-lock.mjs +83 -0
- package/esm/orchestrator/session-lock.mjs.map +1 -0
- package/esm/planner/dag-scheduler.mjs +97 -0
- package/esm/planner/dag-scheduler.mjs.map +1 -0
- package/esm/planner/plan-prompt.d.mts +1 -1
- package/esm/planner/plan-prompt.d.mts.map +1 -1
- package/esm/planner/plan-prompt.mjs +2 -1
- package/esm/planner/plan-prompt.mjs.map +1 -1
- package/esm/planner/planner-run.d.mts.map +1 -1
- package/esm/planner/planner-run.mjs +300 -29
- package/esm/planner/planner-run.mjs.map +1 -1
- package/esm/planner/planner.mjs +1 -1
- package/esm/planner/planner.mjs.map +1 -1
- package/esm/prompt/errors.d.mts +57 -0
- package/esm/prompt/errors.d.mts.map +1 -0
- package/esm/prompt/errors.mjs +73 -0
- package/esm/prompt/errors.mjs.map +1 -0
- package/esm/prompt/index.d.mts +3 -0
- package/esm/prompt/index.mjs +4 -0
- package/esm/prompt/prompt-langfuse-sync.mjs +104 -0
- package/esm/prompt/prompt-langfuse-sync.mjs.map +1 -0
- package/esm/prompt/prompt-langfuse-sync.type.d.mts +32 -0
- package/esm/prompt/prompt-langfuse-sync.type.d.mts.map +1 -0
- package/esm/prompt/prompt-validate.mjs +170 -0
- package/esm/prompt/prompt-validate.mjs.map +1 -0
- package/esm/prompt/prompt.d.mts +54 -0
- package/esm/prompt/prompt.d.mts.map +1 -0
- package/esm/prompt/prompt.mjs +218 -0
- package/esm/prompt/prompt.mjs.map +1 -0
- package/esm/prompt/prompt.type.d.mts +174 -0
- package/esm/prompt/prompt.type.d.mts.map +1 -0
- package/esm/prompts/index.d.mts +3 -0
- package/esm/prompts/index.mjs +3 -0
- package/esm/prompts/prompts-manager.contract.d.mts +154 -0
- package/esm/prompts/prompts-manager.contract.d.mts.map +1 -0
- package/esm/prompts/prompts-manager.d.mts +38 -0
- package/esm/prompts/prompts-manager.d.mts.map +1 -0
- package/esm/prompts/prompts-manager.mjs +410 -0
- package/esm/prompts/prompts-manager.mjs.map +1 -0
- package/esm/prompts/prompts-manager.type.d.mts +172 -0
- package/esm/prompts/prompts-manager.type.d.mts.map +1 -0
- package/esm/prompts/prompts-validate.mjs +200 -0
- package/esm/prompts/prompts-validate.mjs.map +1 -0
- package/esm/rag/as-tool.mjs +48 -0
- package/esm/rag/as-tool.mjs.map +1 -0
- package/esm/rag/chunk/chunk.d.mts +24 -0
- package/esm/rag/chunk/chunk.d.mts.map +1 -0
- package/esm/rag/chunk/chunk.mjs +44 -0
- package/esm/rag/chunk/chunk.mjs.map +1 -0
- package/esm/rag/chunk/fixed.mjs +32 -0
- package/esm/rag/chunk/fixed.mjs.map +1 -0
- package/esm/rag/chunk/markdown.mjs +75 -0
- package/esm/rag/chunk/markdown.mjs.map +1 -0
- package/esm/rag/chunk/recursive.mjs +132 -0
- package/esm/rag/chunk/recursive.mjs.map +1 -0
- package/esm/rag/chunk/sentence.mjs +73 -0
- package/esm/rag/chunk/sentence.mjs.map +1 -0
- package/esm/rag/contracts/chunk-options.type.d.mts +35 -0
- package/esm/rag/contracts/chunk-options.type.d.mts.map +1 -0
- package/esm/rag/contracts/citation.type.d.mts +35 -0
- package/esm/rag/contracts/citation.type.d.mts.map +1 -0
- package/esm/rag/contracts/index.d.mts +4 -0
- package/esm/rag/contracts/rag-config.type.d.mts +68 -0
- package/esm/rag/contracts/rag-config.type.d.mts.map +1 -0
- package/esm/rag/contracts/rag-document.type.d.mts +21 -0
- package/esm/rag/contracts/rag-document.type.d.mts.map +1 -0
- package/esm/rag/hybrid/bm25.d.mts +23 -0
- package/esm/rag/hybrid/bm25.d.mts.map +1 -0
- package/esm/rag/hybrid/bm25.mjs +51 -0
- package/esm/rag/hybrid/bm25.mjs.map +1 -0
- package/esm/rag/hybrid/hybrid-rank.d.mts +33 -0
- package/esm/rag/hybrid/hybrid-rank.d.mts.map +1 -0
- package/esm/rag/hybrid/hybrid-rank.mjs +29 -0
- package/esm/rag/hybrid/hybrid-rank.mjs.map +1 -0
- package/esm/rag/hybrid/rrf.d.mts +25 -0
- package/esm/rag/hybrid/rrf.d.mts.map +1 -0
- package/esm/rag/hybrid/rrf.mjs +30 -0
- package/esm/rag/hybrid/rrf.mjs.map +1 -0
- package/esm/rag/index.d.mts +15 -0
- package/esm/rag/index.mjs +11 -0
- package/esm/rag/rag.d.mts +38 -0
- package/esm/rag/rag.d.mts.map +1 -0
- package/esm/rag/rag.mjs +126 -0
- package/esm/rag/rag.mjs.map +1 -0
- package/esm/rag/rerank/keyword-reranker.d.mts +32 -0
- package/esm/rag/rerank/keyword-reranker.d.mts.map +1 -0
- package/esm/rag/rerank/keyword-reranker.mjs +58 -0
- package/esm/rag/rerank/keyword-reranker.mjs.map +1 -0
- package/esm/rag/rerank/llm-reranker.d.mts +36 -0
- package/esm/rag/rerank/llm-reranker.d.mts.map +1 -0
- package/esm/rag/rerank/llm-reranker.mjs +85 -0
- package/esm/rag/rerank/llm-reranker.mjs.map +1 -0
- package/esm/rag/rerank/reranker.contract.d.mts +28 -0
- package/esm/rag/rerank/reranker.contract.d.mts.map +1 -0
- package/esm/rag/retrieve.mjs +68 -0
- package/esm/rag/retrieve.mjs.map +1 -0
- package/esm/rag/store/cache-vector-store.d.mts +27 -0
- package/esm/rag/store/cache-vector-store.d.mts.map +1 -0
- package/esm/rag/store/cache-vector-store.mjs +48 -0
- package/esm/rag/store/cache-vector-store.mjs.map +1 -0
- package/esm/rag/store/vector-store.contract.d.mts +38 -0
- package/esm/rag/store/vector-store.contract.d.mts.map +1 -0
- package/esm/rag/transforms/multi-query.d.mts +27 -0
- package/esm/rag/transforms/multi-query.d.mts.map +1 -0
- package/esm/rag/transforms/multi-query.mjs +41 -0
- package/esm/rag/transforms/multi-query.mjs.map +1 -0
- package/esm/security/index.mjs +5 -0
- package/esm/security/outbound-policy.d.mts +46 -0
- package/esm/security/outbound-policy.d.mts.map +1 -0
- package/esm/security/outbound-policy.mjs +187 -0
- package/esm/security/outbound-policy.mjs.map +1 -0
- package/esm/security/outbound-policy.type.d.mts +74 -0
- package/esm/security/outbound-policy.type.d.mts.map +1 -0
- package/esm/security/private-ip.d.mts +15 -0
- package/esm/security/private-ip.d.mts.map +1 -0
- package/esm/security/private-ip.mjs +48 -0
- package/esm/security/private-ip.mjs.map +1 -0
- package/esm/security/redact.d.mts +59 -0
- package/esm/security/redact.d.mts.map +1 -0
- package/esm/security/redact.mjs +122 -0
- package/esm/security/redact.mjs.map +1 -0
- package/esm/serve/serve.d.mts +50 -0
- package/esm/serve/serve.d.mts.map +1 -0
- package/esm/serve/serve.mjs +90 -0
- package/esm/serve/serve.mjs.map +1 -0
- package/esm/serve/sse.d.mts +20 -0
- package/esm/serve/sse.d.mts.map +1 -0
- package/esm/serve/sse.mjs +25 -0
- package/esm/serve/sse.mjs.map +1 -0
- package/esm/serve/stream-to-sse.d.mts +29 -0
- package/esm/serve/stream-to-sse.d.mts.map +1 -0
- package/esm/serve/stream-to-sse.mjs +37 -0
- package/esm/serve/stream-to-sse.mjs.map +1 -0
- package/esm/skills/catalog.d.mts +49 -0
- package/esm/skills/catalog.d.mts.map +1 -0
- package/esm/skills/catalog.mjs +140 -0
- package/esm/skills/catalog.mjs.map +1 -0
- package/esm/skills/contracts/skill-record.type.d.mts +37 -0
- package/esm/skills/contracts/skill-record.type.d.mts.map +1 -0
- package/esm/skills/contracts/skills-config.type.d.mts +108 -0
- package/esm/skills/contracts/skills-config.type.d.mts.map +1 -0
- package/esm/skills/contracts/skills-store.contract.d.mts +28 -0
- package/esm/skills/contracts/skills-store.contract.d.mts.map +1 -0
- package/esm/skills/contracts/skills.contract.d.mts +43 -0
- package/esm/skills/contracts/skills.contract.d.mts.map +1 -0
- package/esm/skills/index.d.mts +16 -0
- package/esm/skills/index.mjs +14 -0
- package/esm/skills/load-skill-tool.d.mts +38 -0
- package/esm/skills/load-skill-tool.d.mts.map +1 -0
- package/esm/skills/load-skill-tool.mjs +65 -0
- package/esm/skills/load-skill-tool.mjs.map +1 -0
- package/esm/skills/review-gate.d.mts +33 -0
- package/esm/skills/review-gate.d.mts.map +1 -0
- package/esm/skills/review-gate.mjs +60 -0
- package/esm/skills/review-gate.mjs.map +1 -0
- package/esm/skills/save-skill-tool.d.mts +39 -0
- package/esm/skills/save-skill-tool.d.mts.map +1 -0
- package/esm/skills/save-skill-tool.mjs +65 -0
- package/esm/skills/save-skill-tool.mjs.map +1 -0
- package/esm/skills/skills.d.mts +33 -0
- package/esm/skills/skills.d.mts.map +1 -0
- package/esm/skills/skills.mjs +109 -0
- package/esm/skills/skills.mjs.map +1 -0
- package/esm/skills/sources/directory-source.d.mts +19 -0
- package/esm/skills/sources/directory-source.d.mts.map +1 -0
- package/esm/skills/sources/directory-source.mjs +108 -0
- package/esm/skills/sources/directory-source.mjs.map +1 -0
- package/esm/skills/sources/index.d.mts +18 -0
- package/esm/skills/sources/index.d.mts.map +1 -0
- package/esm/skills/sources/index.mjs +27 -0
- package/esm/skills/sources/index.mjs.map +1 -0
- package/esm/skills/sources/parse-frontmatter.d.mts +27 -0
- package/esm/skills/sources/parse-frontmatter.d.mts.map +1 -0
- package/esm/skills/sources/parse-frontmatter.mjs +46 -0
- package/esm/skills/sources/parse-frontmatter.mjs.map +1 -0
- package/esm/skills/sources/store-source.d.mts +14 -0
- package/esm/skills/sources/store-source.d.mts.map +1 -0
- package/esm/skills/sources/store-source.mjs +15 -0
- package/esm/skills/sources/store-source.mjs.map +1 -0
- package/esm/skills/sources/url-source.d.mts +29 -0
- package/esm/skills/sources/url-source.d.mts.map +1 -0
- package/esm/skills/sources/url-source.mjs +117 -0
- package/esm/skills/sources/url-source.mjs.map +1 -0
- package/esm/skills/store/mock-skills-store.d.mts +57 -0
- package/esm/skills/store/mock-skills-store.d.mts.map +1 -0
- package/esm/skills/store/mock-skills-store.mjs +100 -0
- package/esm/skills/store/mock-skills-store.mjs.map +1 -0
- package/esm/skills/store/procedural-skill-store.d.mts +30 -0
- package/esm/skills/store/procedural-skill-store.d.mts.map +1 -0
- package/esm/skills/store/procedural-skill-store.mjs +125 -0
- package/esm/skills/store/procedural-skill-store.mjs.map +1 -0
- package/esm/supervisor/as-tool.mjs +2 -2
- package/esm/supervisor/as-tool.mjs.map +1 -1
- package/esm/supervisor/execution.d.mts.map +1 -1
- package/esm/supervisor/execution.mjs +31 -28
- package/esm/supervisor/execution.mjs.map +1 -1
- package/esm/supervisor/supervisor.d.mts.map +1 -1
- package/esm/supervisor/supervisor.mjs +8 -3
- package/esm/supervisor/supervisor.mjs.map +1 -1
- package/esm/system-prompt/index.d.mts +4 -0
- package/esm/system-prompt/system-prompt.d.mts +68 -4
- package/esm/system-prompt/system-prompt.d.mts.map +1 -1
- package/esm/system-prompt/system-prompt.mjs +89 -5
- package/esm/system-prompt/system-prompt.mjs.map +1 -1
- package/esm/team/gates.mjs +48 -0
- package/esm/team/gates.mjs.map +1 -0
- package/esm/team/index.d.mts +1 -0
- package/esm/team/index.mjs +3 -0
- package/esm/team/team.d.mts +42 -0
- package/esm/team/team.d.mts.map +1 -0
- package/esm/team/team.mjs +94 -0
- package/esm/team/team.mjs.map +1 -0
- package/esm/tool/executable-as-tool.d.mts.map +1 -1
- package/esm/tool/executable-as-tool.mjs +2 -2
- package/esm/tool/executable-as-tool.mjs.map +1 -1
- package/esm/tool/tool.d.mts.map +1 -1
- package/esm/tool/tool.mjs +2 -2
- package/esm/tool/tool.mjs.map +1 -1
- package/esm/utils/compute-cost.d.mts +17 -1
- package/esm/utils/compute-cost.d.mts.map +1 -1
- package/esm/utils/compute-cost.mjs +26 -1
- package/esm/utils/compute-cost.mjs.map +1 -1
- package/esm/utils/extract-json-lenient.d.mts +42 -0
- package/esm/utils/extract-json-lenient.d.mts.map +1 -0
- package/esm/utils/extract-json-lenient.mjs +97 -0
- package/esm/utils/extract-json-lenient.mjs.map +1 -0
- package/esm/utils/index.d.mts +4 -2
- package/esm/utils/index.mjs +3 -1
- package/esm/utils/json-schema.d.mts +1 -1
- package/esm/utils/prepare-attachment-part.d.mts +10 -1
- package/esm/utils/prepare-attachment-part.d.mts.map +1 -1
- package/esm/utils/prepare-attachment-part.mjs +103 -11
- package/esm/utils/prepare-attachment-part.mjs.map +1 -1
- package/esm/utils/resolve-attachment.d.mts +4 -3
- package/esm/utils/resolve-attachment.d.mts.map +1 -1
- package/esm/utils/resolve-attachment.mjs +4 -3
- package/esm/utils/resolve-attachment.mjs.map +1 -1
- package/esm/utils/run-context.d.mts +94 -0
- package/esm/utils/run-context.d.mts.map +1 -0
- package/esm/utils/run-context.mjs +98 -0
- package/esm/utils/run-context.mjs.map +1 -0
- package/esm/vcr/cassette-io.mjs +57 -0
- package/esm/vcr/cassette-io.mjs.map +1 -0
- package/esm/vcr/errors.d.mts +42 -0
- package/esm/vcr/errors.d.mts.map +1 -0
- package/esm/vcr/errors.mjs +37 -0
- package/esm/vcr/errors.mjs.map +1 -0
- package/esm/vcr/hash-request.d.mts +28 -0
- package/esm/vcr/hash-request.d.mts.map +1 -0
- package/esm/vcr/hash-request.mjs +118 -0
- package/esm/vcr/hash-request.mjs.map +1 -0
- package/esm/vcr/index.d.mts +4 -0
- package/esm/vcr/index.mjs +5 -0
- package/esm/vcr/vcr.d.mts +32 -0
- package/esm/vcr/vcr.d.mts.map +1 -0
- package/esm/vcr/vcr.mjs +248 -0
- package/esm/vcr/vcr.mjs.map +1 -0
- package/esm/vcr/vcr.type.d.mts +118 -0
- package/esm/vcr/vcr.type.d.mts.map +1 -0
- package/esm/workflow/as-tool.mjs +2 -2
- package/esm/workflow/as-tool.mjs.map +1 -1
- package/esm/workflow/engine.mjs +1 -0
- package/esm/workflow/engine.mjs.map +1 -1
- package/esm/workflow/step-runner.mjs +19 -20
- package/esm/workflow/step-runner.mjs.map +1 -1
- package/esm/workflow/workflow.d.mts.map +1 -1
- package/esm/workflow/workflow.mjs +8 -3
- package/esm/workflow/workflow.mjs.map +1 -1
- package/llms-full.txt +1683 -68
- package/llms.txt +16 -4
- package/package.json +7 -3
- package/skills/README.md +40 -4
- package/skills/ai-dx-helpers/SKILL.md +2 -2
- package/skills/approve-tool-calls/SKILL.md +134 -0
- package/skills/attach-ai-middleware/SKILL.md +1 -1
- package/skills/detect-and-redact-pii/SKILL.md +104 -0
- package/skills/durable-resume/SKILL.md +128 -0
- package/skills/escalate-block-to-human/SKILL.md +85 -0
- package/skills/eval-datasets-and-ci/SKILL.md +117 -0
- package/skills/guard-input-output/SKILL.md +117 -0
- package/skills/manage-prompts/SKILL.md +186 -0
- package/skills/observe-ai-flows/SKILL.md +94 -0
- package/skills/record-replay-llm/SKILL.md +92 -0
- package/skills/run-ai-agent/SKILL.md +26 -1
- package/skills/run-ai-rag/SKILL.md +139 -0
- package/skills/run-ai-team/SKILL.md +107 -0
- package/skills/run-orchestrator/SKILL.md +2 -0
- package/skills/run-planner/SKILL.md +73 -8
- package/skills/run-supervisor/SKILL.md +20 -1
- package/skills/use-runtime-skills/SKILL.md +106 -0
- package/skills/write-system-prompt/SKILL.md +30 -1
- package/cjs/index.cjs.map +0 -1
- package/esm/contracts/result/index.d.mts +0 -15
package/esm/index.d.mts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import { OutboundPolicy, ResolvedOutboundPolicy } from "./security/outbound-policy.type.mjs";
|
|
2
|
+
import { AttachmentPolicy } from "./contracts/attachment-policy.type.mjs";
|
|
1
3
|
import { Attachment, AttachmentSource, ResolvedAttachment, StorageFileShape } from "./contracts/attachment.type.mjs";
|
|
2
|
-
import { ContentPart, ImageSource } from "./contracts/content-part.type.mjs";
|
|
4
|
+
import { BinarySource, ContentPart, ImageSource } from "./contracts/content-part.type.mjs";
|
|
3
5
|
import { ModelToolCallRequest } from "./contracts/model-tool-call-request.type.mjs";
|
|
4
6
|
import { Message } from "./contracts/conversation-message.type.mjs";
|
|
5
7
|
import { ErrorCategory } from "./errors/error-category.type.mjs";
|
|
@@ -13,7 +15,7 @@ import { BaseReport, REPORT_SCHEMA_VERSION, ReportStatus, ReportType } from "./c
|
|
|
13
15
|
import { FinishReason } from "./contracts/finish-reason.type.mjs";
|
|
14
16
|
import { ToolCall } from "./contracts/result/tool-call.type.mjs";
|
|
15
17
|
import { LLMTrip } from "./contracts/result/llm-trip.type.mjs";
|
|
16
|
-
import { AgentReport, ExecutionReport, ExecutionStatus } from "./contracts/result/execution-report.type.mjs";
|
|
18
|
+
import { AgentReport, CapturedMessage, ExecutionReport, ExecutionStatus } from "./contracts/result/execution-report.type.mjs";
|
|
17
19
|
import { AgentResult } from "./contracts/result/agent-result.type.mjs";
|
|
18
20
|
import { AgentCompletedPayload, AgentErrorPayload, AgentStartingPayload, AgentStreamingPayload, AgentToolCalledPayload, AgentToolCallingFailedPayload, AgentToolCallingPayload, AgentTripCompletedPayload, AgentTripStartedPayload, ToolEventMeta } from "./contracts/events/agent-events.type.mjs";
|
|
19
21
|
import { EventIdentity, WithoutIdentity } from "./contracts/events/event-identity.type.mjs";
|
|
@@ -21,6 +23,7 @@ import { ExecuteResult } from "./contracts/result/execute-result.type.mjs";
|
|
|
21
23
|
import { ExecutableContract } from "./contracts/executable.contract.mjs";
|
|
22
24
|
import { StreamEvent, StreamEventBody } from "./contracts/stream/stream-event.type.mjs";
|
|
23
25
|
import { StreamContract } from "./contracts/stream/stream.contract.mjs";
|
|
26
|
+
import { DatasetContract, DatasetEntry, DatasetOptions } from "./eval/dataset.type.mjs";
|
|
24
27
|
import { EvalCase, EvalCaseResult, EvalJudge, EvalOptions, EvalReport, EvalScore, EvalScorer, EvalScorerContext } from "./contracts/agent/eval.type.mjs";
|
|
25
28
|
import { AgentContract, AgentEventHandler } from "./contracts/agent/agent.contract.mjs";
|
|
26
29
|
import { END, EndSentinel } from "./contracts/end.type.mjs";
|
|
@@ -35,7 +38,7 @@ import { BudgetExceededError, BudgetExceededErrorOptions, BudgetUnit } from "./e
|
|
|
35
38
|
import { ProviderError } from "./errors/provider-error.mjs";
|
|
36
39
|
import { ContentFilterError, ContentFilterErrorOptions } from "./errors/content-filter-error.mjs";
|
|
37
40
|
import { ContextLengthExceededError, ContextLengthExceededErrorOptions } from "./errors/context-length-exceeded-error.mjs";
|
|
38
|
-
import {
|
|
41
|
+
import { GuardrailViolationError, GuardrailViolationErrorOptions } from "./errors/guardrail-violation-error.mjs";
|
|
39
42
|
import { InvalidRequestError } from "./errors/invalid-request-error.mjs";
|
|
40
43
|
import { SupervisorFailedError } from "./errors/supervisor-failed-error.mjs";
|
|
41
44
|
import { MaxIterationsError, MaxIterationsErrorOptions } from "./errors/max-iterations-error.mjs";
|
|
@@ -45,6 +48,7 @@ import { OrchestratorFailedError } from "./errors/orchestrator-failed-error.mjs"
|
|
|
45
48
|
import { OrchestratorCancelledError, OrchestratorCancelledErrorOptions } from "./errors/orchestrator-cancelled-error.mjs";
|
|
46
49
|
import { OrchestratorConfigError } from "./errors/orchestrator-config-error.mjs";
|
|
47
50
|
import { OrchestratorDriftError, OrchestratorDriftErrorOptions } from "./errors/orchestrator-drift-error.mjs";
|
|
51
|
+
import { OutboundPolicyError } from "./errors/outbound-policy-error.mjs";
|
|
48
52
|
import { PlannerFailedError } from "./errors/planner-failed-error.mjs";
|
|
49
53
|
import { PlannerCancelledError, PlannerCancelledErrorOptions } from "./errors/planner-cancelled-error.mjs";
|
|
50
54
|
import { PlannerPlanInvalidError } from "./errors/planner-plan-invalid-error.mjs";
|
|
@@ -62,9 +66,11 @@ import { ToolExecutionError, ToolExecutionErrorOptions } from "./errors/tool-exe
|
|
|
62
66
|
import { WorkflowCancelledError, WorkflowCancelledErrorOptions } from "./errors/workflow-cancelled-error.mjs";
|
|
63
67
|
import { WorkflowDriftError, WorkflowDriftErrorOptions } from "./errors/workflow-drift-error.mjs";
|
|
64
68
|
import { ToolContract, ToolInvokeResult, tool } from "./tool/tool.mjs";
|
|
69
|
+
import { Observer } from "./observe/observer.contract.mjs";
|
|
70
|
+
import { FlowObserveOption, resolveObservers } from "./observe/resolve-observers.mjs";
|
|
65
71
|
import { SupervisorInput } from "./contracts/supervisor/supervisor-input.type.mjs";
|
|
66
72
|
import { SupervisorSnapshot, SupervisorSnapshotStatus } from "./contracts/supervisor/supervisor-snapshot.type.mjs";
|
|
67
|
-
import {
|
|
73
|
+
import { SnapshotStore } from "./contracts/orchestrator/snapshot-store.contract.mjs";
|
|
68
74
|
import { NextStepResult } from "./contracts/workflow/next-step-result.type.mjs";
|
|
69
75
|
import { RetryBackoff, RetryConfig } from "./contracts/workflow/retry-config.type.mjs";
|
|
70
76
|
import { WorkflowContext } from "./contracts/workflow/workflow-context.type.mjs";
|
|
@@ -78,7 +84,8 @@ import { MiddlewareState } from "./contracts/middleware/middleware-state.type.mj
|
|
|
78
84
|
import { MiddlewareAgentRef, MiddlewareExecuteContext, MiddlewareModelRef, MiddlewareSupervisorContext, MiddlewareSupervisorRef, MiddlewareToolContext, MiddlewareTripContext } from "./contracts/middleware/middleware-context.type.mjs";
|
|
79
85
|
import { AgentMiddleware, AgentMiddlewareExecuteHooks, AgentMiddlewareSupervisorHooks, AgentMiddlewareToolHooks, AgentMiddlewareTripHooks } from "./contracts/middleware/middleware.contract.mjs";
|
|
80
86
|
import { Placeholders } from "./contracts/placeholders.type.mjs";
|
|
81
|
-
import {
|
|
87
|
+
import { ExportedPrompt, ExportedPromptVersion, ExportedRegistry, PromptDiff, PromptDiffBlock, PromptJudgeCacheLike, PromptTemplateVersion, PromptValidateTarget, PromptValidationResult, PromptsManagerOptions, PromptsValidateOptions } from "./prompts/prompts-manager.type.mjs";
|
|
88
|
+
import { InstructionContract, PersonaContract, SystemPromptBlockContract, SystemPromptContract, SystemPromptMergeOptions, SystemPromptMergeSource, SystemPromptMeta } from "./contracts/system-prompt.contract.mjs";
|
|
82
89
|
import { RouteContext } from "./contracts/supervisor/route-context.type.mjs";
|
|
83
90
|
import { AckCallback, AckConfig, AckEntry, AckRunEntry } from "./contracts/supervisor/ack-entry.type.mjs";
|
|
84
91
|
import { DispatchRawResult, IntentCallback, IntentEntry, IntentRunEntry, SupervisorIntentValue } from "./contracts/supervisor/intent-entry.type.mjs";
|
|
@@ -104,6 +111,7 @@ import { RecallOptions } from "./contracts/memory/recall-options.type.mjs";
|
|
|
104
111
|
import { MemoryContract } from "./contracts/memory/memory.contract.mjs";
|
|
105
112
|
import { EpisodicMemoryConfig, MemoryConfig, ProceduralMemoryConfig, SemanticMemoryConfig } from "./contracts/memory/memory-config.type.mjs";
|
|
106
113
|
import { CheckpointRecord, CheckpointStore } from "./contracts/orchestrator/checkpoint-store.contract.mjs";
|
|
114
|
+
import { SessionLock } from "./contracts/orchestrator/session-lock.contract.mjs";
|
|
107
115
|
import { OrchestratorCommands } from "./contracts/orchestrator/orchestrator-commands.type.mjs";
|
|
108
116
|
import { OrchestratorEvent, OrchestratorEventHandler, OrchestratorEventHandlers, OrchestratorEventMap, OrchestratorEventName } from "./contracts/orchestrator/orchestrator-event.type.mjs";
|
|
109
117
|
import { OrchestratorExecuteOptions, OrchestratorResumeOptions } from "./contracts/orchestrator/orchestrator-execute-options.type.mjs";
|
|
@@ -112,32 +120,59 @@ import { OrchestratorConfig, OrchestratorMemoryConfig, SummarizeCallback, Summar
|
|
|
112
120
|
import { SessionContract } from "./contracts/orchestrator/session.contract.mjs";
|
|
113
121
|
import { PlannerCapability } from "./contracts/planner/planner-capability.type.mjs";
|
|
114
122
|
import { PlannerConfig } from "./contracts/planner/planner-config.type.mjs";
|
|
115
|
-
import { PlannerExecuteOptions } from "./contracts/planner/planner-execute-options.type.mjs";
|
|
116
123
|
import { PlannerPlan, PlannerStep } from "./contracts/planner/planner-plan.type.mjs";
|
|
117
124
|
import { PlannerReport, PlannerReportType, PlannerResult, PlannerStepSnapshot } from "./contracts/planner/planner-result.type.mjs";
|
|
125
|
+
import { PlannerExecuteOptions, PlannerStepDirective } from "./contracts/planner/planner-execute-options.type.mjs";
|
|
118
126
|
import { PlannerContract } from "./contracts/planner/planner.contract.mjs";
|
|
119
127
|
import { ModelConfig, SDKAdapterContract } from "./contracts/sdk-adapter.contract.mjs";
|
|
120
128
|
import { CompleteEvent } from "./contracts/events/complete-event.type.mjs";
|
|
121
129
|
import { UsageEvent } from "./contracts/events/usage-event.type.mjs";
|
|
130
|
+
import { LoadSkillInput, SkillCatalogEntry, SkillRecord } from "./skills/contracts/skill-record.type.mjs";
|
|
131
|
+
import { SkillsStoreContract } from "./skills/contracts/skills-store.contract.mjs";
|
|
132
|
+
import { SkillAnalyticsEvent, SkillInjectMode, SkillReviewGate, SkillSource, SkillsConfig } from "./skills/contracts/skills-config.type.mjs";
|
|
133
|
+
import { SkillsContract } from "./skills/contracts/skills.contract.mjs";
|
|
134
|
+
import { JUDGE_DEFAULT_REPAIR_ATTEMPTS, JudgeConfig } from "./agent/judge-config.type.mjs";
|
|
122
135
|
import { AgentConfig } from "./agent/agent-config.type.mjs";
|
|
123
|
-
import { agent } from "./agent/agent.mjs";
|
|
136
|
+
import { JudgeAgentConfig, agent } from "./agent/agent.mjs";
|
|
124
137
|
import { StreamController, createAgentStream } from "./agent/agent-stream.mjs";
|
|
125
138
|
import { BudgetContract, BudgetContractDimension, BudgetContractFallback, BudgetContractViolation, BudgetContractViolationMode } from "./middleware/builtins/budget-contract.type.mjs";
|
|
126
139
|
import { BudgetFallbackSignal, BudgetOptions, BudgetPricing, budget, readBudgetFallbackSignal } from "./middleware/builtins/budget.mjs";
|
|
127
140
|
import { SpawnSubAgentSpec, spawnSubAgent } from "./agent/spawn-sub-agent.mjs";
|
|
128
|
-
import { SystemPrompt, systemPrompt } from "./system-prompt/system-prompt.mjs";
|
|
129
|
-
import { judge } from "./eval/judge-scorer.mjs";
|
|
130
|
-
import { EvalPredicate, contains, exact, predicate } from "./eval/scorers.mjs";
|
|
131
|
-
import { runEval } from "./eval/eval-runner.mjs";
|
|
132
|
-
import { evalScorers } from "./eval/index.mjs";
|
|
133
141
|
import { BatchItemHandler, BatchItemResult, BatchItemStatus, BatchOptions, BatchReport, BatchResult } from "./batch/batch.type.mjs";
|
|
134
142
|
import { batch } from "./batch/batch.mjs";
|
|
143
|
+
import { ObjectStreamEvent, StreamObjectParams, collectStreamObject, streamObject } from "./object-stream/stream-object.mjs";
|
|
144
|
+
import { parsePartialJson } from "./object-stream/parse-partial-json.mjs";
|
|
145
|
+
import { SSE_DONE, encodeSSE } from "./serve/sse.mjs";
|
|
146
|
+
import { StreamLike, streamToSSE } from "./serve/stream-to-sse.mjs";
|
|
147
|
+
import { ServableExecutable, ServeOptions, serve } from "./serve/serve.mjs";
|
|
135
148
|
import { memory } from "./checkpoint/memory.mjs";
|
|
136
149
|
import { PgCheckpointOptions, pg } from "./checkpoint/pg.mjs";
|
|
137
150
|
import { RedisCheckpointOptions, redis } from "./checkpoint/redis.mjs";
|
|
138
|
-
import { AIConfig, getAIConfig, resolveDefaultCheckpointStore, resolveDefaultSnapshotStore, resolveDefaultStore, setAIConfig } from "./config.mjs";
|
|
139
|
-
import {
|
|
140
|
-
import {
|
|
151
|
+
import { AIConfig, getAIConfig, onConfigApplied, resolveDefaultCheckpointStore, resolveDefaultSnapshotStore, resolveDefaultStore, setAIConfig } from "./config.mjs";
|
|
152
|
+
import { judge } from "./eval/judge-scorer.mjs";
|
|
153
|
+
import { fromJSON, toJSON } from "./eval/report-json.mjs";
|
|
154
|
+
import { toJUnit } from "./eval/report-junit.mjs";
|
|
155
|
+
import { EvalPredicate, contains, exact, predicate } from "./eval/scorers.mjs";
|
|
156
|
+
import { runEval } from "./eval/eval-runner.mjs";
|
|
157
|
+
import { dataset } from "./eval/dataset.mjs";
|
|
158
|
+
import { diff } from "./eval/regression.mjs";
|
|
159
|
+
import { evalScorers } from "./eval/index.mjs";
|
|
160
|
+
import { ApprovalDecision, ApprovalDecisionType, ApprovalHandler, ApprovalRequest, ApprovalRequestContext, InterruptPolicy, PolicyContext } from "./human/contracts/approval.type.mjs";
|
|
161
|
+
import { InterruptStore, PendingInterrupt, PendingInterruptStatus, PgClientLike, RedisClientLike } from "./human/contracts/interrupt-store.contract.mjs";
|
|
162
|
+
import { HumanApprovalOptions } from "./human/contracts/human-approval.type.mjs";
|
|
163
|
+
import { ResumeOptions, ResumeResult } from "./human/contracts/resume.type.mjs";
|
|
164
|
+
import { humanApproval } from "./human/human-approval.mjs";
|
|
165
|
+
import { resume } from "./human/resume.mjs";
|
|
166
|
+
import { memory as memory$1 } from "./human/stores/memory.mjs";
|
|
167
|
+
import { PgInterruptOptions, pg as pg$1 } from "./human/stores/pg.mjs";
|
|
168
|
+
import { RedisInterruptOptions, redis as redis$1 } from "./human/stores/redis.mjs";
|
|
169
|
+
import { GuardrailAction, GuardrailMatch, GuardrailPhase, GuardrailVerdict } from "./guard/contracts/verdict.type.mjs";
|
|
170
|
+
import { GuardrailDetector, GuardrailDetectorContext, SyncGuardrailDetector } from "./guard/contracts/guardrail.contract.mjs";
|
|
171
|
+
import { OpenAiClientLike, OpenAiModerationCreateBody, OpenAiModerationResponse, OpenAiModerationResult } from "./guard/contracts/openai-client.contract.mjs";
|
|
172
|
+
import { GuardOptions, GuardrailBlockEvent, GuardrailEscalation, InjectionDetectorOptions, OpenAiModerationOptions, PiiCategory, PiiDetectorOptions, TopicFilterOptions } from "./guard/contracts/guard-options.type.mjs";
|
|
173
|
+
import { GuardrailFactory, guardrail } from "./guard/guardrail.mjs";
|
|
174
|
+
import { memory as memory$2 } from "./memory/memory.mjs";
|
|
175
|
+
import { GuardrailCheck, GuardrailCheckResult, GuardrailOptions } from "./middleware/builtins/guardrail.mjs";
|
|
141
176
|
import { SemanticCacheOptions, semanticCache } from "./middleware/builtins/semantic-cache.mjs";
|
|
142
177
|
import { composeMiddleware } from "./middleware/helpers/compose.mjs";
|
|
143
178
|
import { forTool } from "./middleware/helpers/for-tool.mjs";
|
|
@@ -156,15 +191,53 @@ import { ResolvedIntentEntry, resolveIntentEntries } from "./supervisor/entries.
|
|
|
156
191
|
import { OrchestratorStreamController, createOrchestratorStream } from "./orchestrator/orchestrator-stream.mjs";
|
|
157
192
|
import { OrchestratorExecution, OrchestratorExecutionParams, runResume, runTurn, streamTurn } from "./orchestrator/execution.mjs";
|
|
158
193
|
import { orchestrator } from "./orchestrator/orchestrator.mjs";
|
|
194
|
+
import { inProcessSessionLock, noopSessionLock } from "./orchestrator/session-lock.mjs";
|
|
159
195
|
import { computeOrchestratorSignature } from "./orchestrator/signature.mjs";
|
|
160
196
|
import { planner } from "./planner/planner.mjs";
|
|
161
197
|
import { planSchema } from "./planner/plan-schema.mjs";
|
|
162
198
|
import { buildPlanSystemPrompt } from "./planner/plan-prompt.mjs";
|
|
163
199
|
import { computeSignature } from "./planner/signature.mjs";
|
|
164
200
|
import { PlannerRunArgs } from "./planner/planner-run.mjs";
|
|
165
|
-
import {
|
|
166
|
-
import {
|
|
167
|
-
import {
|
|
201
|
+
import { PromptsManagerContract, PromptsManagerEntry, PromptsManagerRegisterOptions } from "./prompts/prompts-manager.contract.mjs";
|
|
202
|
+
import { defaultPromptsManager, promptKey, prompts } from "./prompts/prompts-manager.mjs";
|
|
203
|
+
import { Citation, RetrieveOptions, RetrieveResult, RetrievedChunk } from "./rag/contracts/citation.type.mjs";
|
|
204
|
+
import { RagReranker } from "./rag/rerank/reranker.contract.mjs";
|
|
205
|
+
import { Chunk, ChunkOptions, ChunkType } from "./rag/contracts/chunk-options.type.mjs";
|
|
206
|
+
import { RagDocument } from "./rag/contracts/rag-document.type.mjs";
|
|
207
|
+
import { Rag, RagAsToolOptions, RagConfig } from "./rag/contracts/rag-config.type.mjs";
|
|
208
|
+
import { rag } from "./rag/rag.mjs";
|
|
209
|
+
import { chunk } from "./rag/chunk/chunk.mjs";
|
|
210
|
+
import { VectorStore } from "./rag/store/vector-store.contract.mjs";
|
|
211
|
+
import { cacheVectorStore } from "./rag/store/cache-vector-store.mjs";
|
|
212
|
+
import { KeywordRerankerOptions, keywordReranker } from "./rag/rerank/keyword-reranker.mjs";
|
|
213
|
+
import { LlmRerankerOptions, llmReranker } from "./rag/rerank/llm-reranker.mjs";
|
|
214
|
+
import { RankedItem, reciprocalRankFusion } from "./rag/hybrid/rrf.mjs";
|
|
215
|
+
import { LexicalDoc, bm25Rank } from "./rag/hybrid/bm25.mjs";
|
|
216
|
+
import { hybridRank } from "./rag/hybrid/hybrid-rank.mjs";
|
|
217
|
+
import { MultiQueryOptions, multiQuery } from "./rag/transforms/multi-query.mjs";
|
|
218
|
+
import { skills } from "./skills/skills.mjs";
|
|
219
|
+
import { MockSkillsStore } from "./skills/store/mock-skills-store.mjs";
|
|
220
|
+
import { proceduralSkillStore } from "./skills/store/procedural-skill-store.mjs";
|
|
221
|
+
import { LoadSkillResult, LoadSkillToolDeps, loadSkillTool } from "./skills/load-skill-tool.mjs";
|
|
222
|
+
import { SaveSkillInput, SaveSkillResult, SaveSkillToolDeps, saveSkillTool } from "./skills/save-skill-tool.mjs";
|
|
223
|
+
import { ReviewOutcome, runReviewGate } from "./skills/review-gate.mjs";
|
|
224
|
+
import { directorySource } from "./skills/sources/directory-source.mjs";
|
|
225
|
+
import { urlSource } from "./skills/sources/url-source.mjs";
|
|
226
|
+
import { storeSource } from "./skills/sources/store-source.mjs";
|
|
227
|
+
import { ParsedFrontmatter, parseFrontmatter, parseTags } from "./skills/sources/parse-frontmatter.mjs";
|
|
228
|
+
import { resolveSource } from "./skills/sources/index.mjs";
|
|
229
|
+
import { buildCatalog, loadRecord, renderCatalogPrompt, semanticPreselect } from "./skills/catalog.mjs";
|
|
230
|
+
import { SystemPrompt, systemPrompt } from "./system-prompt/system-prompt.mjs";
|
|
231
|
+
import { PromptEntry, PromptLangfuseSyncOptions, PromptRegistryContract, PromptRegistryOptions, PromptResolveOptions, PromptValidateOptions, PromptValidationNote, PromptValidationReport, PromptValidationSeverity, PromptVersion, ResolvedPrompt } from "./prompt/prompt.type.mjs";
|
|
232
|
+
import { prompt } from "./prompt/prompt.mjs";
|
|
233
|
+
import { PromptNotFoundError, PromptValidationError } from "./prompt/errors.mjs";
|
|
234
|
+
import { Cassette, CassetteEntry, VcrMode, VcrModel, VcrOptions } from "./vcr/vcr.type.mjs";
|
|
235
|
+
import { vcr } from "./vcr/vcr.mjs";
|
|
236
|
+
import { VcrCassetteMissError, VcrCassetteMissErrorOptions } from "./vcr/errors.mjs";
|
|
237
|
+
import { DEFAULT_HASH_OPTIONS, hashRequest } from "./vcr/hash-request.mjs";
|
|
238
|
+
import { memory as memory$3 } from "./snapshot/memory.mjs";
|
|
239
|
+
import { PgSnapshotStoreOptions, pg as pg$2 } from "./snapshot/pg.mjs";
|
|
240
|
+
import { RedisSnapshotStoreOptions, redis as redis$2 } from "./snapshot/redis.mjs";
|
|
168
241
|
import { asTool as asTool$1 } from "./supervisor/as-tool.mjs";
|
|
169
242
|
import { createCancelledError } from "./supervisor/cancellation.mjs";
|
|
170
243
|
import { SupervisorEmitter } from "./supervisor/emitter.mjs";
|
|
@@ -176,21 +249,37 @@ import { buildRouterContextMessage } from "./supervisor/router-prompt.mjs";
|
|
|
176
249
|
import { computeSignature as computeSignature$2 } from "./supervisor/signature.mjs";
|
|
177
250
|
import { loadSnapshotForResume, persistSupervisorSnapshot } from "./supervisor/snapshot.mjs";
|
|
178
251
|
import { supervisor } from "./supervisor/supervisor.mjs";
|
|
252
|
+
import { TeamConfig, TeamGate, TeamGateFn, TeamMemberValue } from "./contracts/team/team-config.type.mjs";
|
|
253
|
+
import { team } from "./team/team.mjs";
|
|
179
254
|
import { Instruction, instruction } from "./system-prompt/instruction.mjs";
|
|
180
255
|
import { Persona, persona } from "./system-prompt/persona.mjs";
|
|
181
256
|
import { step } from "./workflow/step.mjs";
|
|
182
257
|
import { workflow } from "./workflow/workflow.mjs";
|
|
183
|
-
import { ai } from "./ai.mjs";
|
|
258
|
+
import { Ai, ai } from "./ai.mjs";
|
|
259
|
+
import { PolicyVerdict, evaluatePolicy } from "./human/policy.mjs";
|
|
260
|
+
import { ApprovalRejectedError, ApprovalRejectedErrorOptions, HumanErrorCode, InterruptSuspendedError, InterruptSuspendedErrorOptions } from "./human/errors.mjs";
|
|
261
|
+
import { FlagRecord, guard } from "./guard/guard.mjs";
|
|
262
|
+
import { injection } from "./guard/detectors/injection.mjs";
|
|
263
|
+
import { pii } from "./guard/detectors/pii.mjs";
|
|
264
|
+
import { topic } from "./guard/detectors/topic.mjs";
|
|
265
|
+
import { moderation } from "./guard/detectors/moderation.mjs";
|
|
266
|
+
import { OPENAI_INSTALL_INSTRUCTIONS } from "./guard/errors.mjs";
|
|
184
267
|
import { MiddlewareContextByLevel, MiddlewareLevel, runPipeline } from "./middleware/pipeline.mjs";
|
|
185
268
|
import { extractUserText } from "./middleware/utils/extract-user-text.mjs";
|
|
186
269
|
import { NamespacedStateAccessor, namespacedState } from "./middleware/utils/namespaced-state.mjs";
|
|
270
|
+
import { getObservers, isObserveAll, registerObserver, setObserveAll } from "./observe/observer-registry.mjs";
|
|
271
|
+
import { assertUrlAllowed, fetchTextWithPolicy, guardedFetch, readTextCapped, resolveOutboundPolicy } from "./security/outbound-policy.mjs";
|
|
272
|
+
import { isPrivateOrReservedIp } from "./security/private-ip.mjs";
|
|
273
|
+
import { DEFAULT_SENSITIVE_KEYS, RedactOptions, RedactedError, SENSITIVE_HEADERS, redact, redactError, redactHeaders, scrubSecrets } from "./security/redact.mjs";
|
|
187
274
|
import { renderPlaceholders } from "./system-prompt/render-placeholders.mjs";
|
|
188
|
-
import { accumulateCost, computeCost } from "./utils/compute-cost.mjs";
|
|
275
|
+
import { accumulateCost, computeCost, mergeUsage } from "./utils/compute-cost.mjs";
|
|
276
|
+
import { extractJsonLenient } from "./utils/extract-json-lenient.mjs";
|
|
189
277
|
import { extractJsonPayload } from "./utils/extract-json-payload.mjs";
|
|
190
278
|
import { generateRunId } from "./utils/generate-run-id.mjs";
|
|
191
|
-
import { extractJsonSchema } from "./utils/json-schema.mjs";
|
|
279
|
+
import { ExtractJsonSchemaOptions, JsonSchemaTarget, extractJsonSchema } from "./utils/json-schema.mjs";
|
|
192
280
|
import { prepareAttachmentPart } from "./utils/prepare-attachment-part.mjs";
|
|
193
281
|
import { resolveAttachment } from "./utils/resolve-attachment.mjs";
|
|
282
|
+
import { RunFrame, captureChildReport, currentRunFrame, withRunFrame, withoutRunFrame } from "./utils/run-context.mjs";
|
|
194
283
|
import { safeJsonParse } from "./utils/safe-json-parse.mjs";
|
|
195
284
|
import { LineageStamp, stampReportLineage } from "./utils/stamp-report-lineage.mjs";
|
|
196
285
|
import { approximateTokenCount } from "./utils/token-count.mjs";
|
|
@@ -198,5 +287,7 @@ import { computeSignature as computeSignature$1 } from "./workflow/signature.mjs
|
|
|
198
287
|
import { MatcherVerdict, matchConverge, matchOutputShape, matchPassStep, matchRouteTo } from "./testing/matcher-logic.mjs";
|
|
199
288
|
import { AiMatchers } from "./testing/matchers.mjs";
|
|
200
289
|
import { registerAiMatchers } from "./testing/register-lazy.mjs";
|
|
201
|
-
export { AIConfig, AIError, type AIErrorCode, type AIErrorOptions, type AckCallback, type AckConfig, type AckEntry, type AckRunEntry, type AckSnapshot, type AgentBranchSnapshot, AgentCancelledError, type AgentCancelledErrorOptions, type AgentCompletedPayload, type AgentConfig, type AgentContract, type AgentErrorPayload, type AgentEventHandler, type AgentEventMap, type AgentExecuteOptions, AgentExecutionError, AgentMaxTripsError, type AgentMaxTripsErrorOptions, type AgentMiddleware, type AgentMiddlewareExecuteHooks, type AgentMiddlewareSupervisorHooks, type AgentMiddlewareToolHooks, type AgentMiddlewareTripHooks, type AgentReport, type AgentResult, type AgentStartingPayload, type AgentStreamingPayload, type AgentToolCalledPayload, type AgentToolCallingFailedPayload, type AgentToolCallingPayload, type AgentToolEntry, type AgentTripCompletedPayload, type AgentTripStartedPayload, type AiMatchers, Attachment, AttachmentSource, type AttemptEntry, type BaseReport, type BaseResult, type BatchItemHandler, type BatchItemResult, type BatchItemStatus, type BatchOptions, type BatchReport, type BatchResult, type BudgetContract, type BudgetContractDimension, type BudgetContractFallback, type BudgetContractViolation, type BudgetContractViolationMode, BudgetExceededError, type BudgetExceededErrorOptions, type BudgetFallbackSignal, type BudgetOptions, type BudgetPricing, type BudgetUnit, type CheckpointRecord, type CheckpointStore, type ClassifierAgentEntry, type ClassifierCallback, type ClassifierConfig, type ClassifierContext, type ClassifierOutput, type ClassifierRefineContext, type ClassifierRefineResult, type ClassifierRunEntry, type ClassifierSnapshot, type CompactionResult, type CompleteEvent, ContentFilterError, type ContentFilterErrorOptions, ContentPart, ContextLengthExceededError, type ContextLengthExceededErrorOptions, type DecisionSource, type DispatchContext, type DispatchRawResult, END, EmbedderConfig, EmbedderContract, EmbeddingBatchResult, EmbeddingResult, EmbeddingUsage, EndSentinel, type EpisodicMemoryConfig, type ErrorCategory, type EvalCase, type EvalCaseResult, type EvalJudge, type EvalOptions, type EvalPredicate, type EvalReport, type EvalScore, type EvalScorer, type EvalScorerContext, type EvaluateBranchResult, type EvaluateContext, type EvaluateResult, type EventIdentity, ExecutableContract, type ExecutableTool, type ExecuteResult, type ExecutionReport, type ExecutionStatus, type FallbackAttempt, type FallbackModelContract, type FallbackModelOptions, type FallbackRetryPredicate, type FanOutOptions, type FanOutUnit, FinishReason, type GuardrailCheck, type GuardrailCheckResult, type GuardrailOptions, type GuardrailPhase, GuardrailViolationError, type GuardrailViolationErrorOptions, ImageSource, Instruction, InstructionContract, type IntentCallback, type IntentEntry, type IntentRunEntry, type IntentRunner, type IntentRunnerMap, InvalidRequestError, type IterationDecision, type IterationSnapshot, type LLMTrip, type LineageStamp, type MatcherVerdict, MaxIterationsError, type MaxIterationsErrorOptions, MaxStepsExceededError, type MaxStepsExceededErrorOptions, type MemoryConfig, type MemoryContract, type MemoryItem, type MemoryTier, Message, type MiddlewareAgentRef, type MiddlewareContextByLevel, type MiddlewareExecuteContext, type MiddlewareLevel, type MiddlewareModelRef, type MiddlewareState, type MiddlewareSupervisorContext, type MiddlewareSupervisorRef, type MiddlewareToolContext, type MiddlewareTripContext, MockModel, type MockModelResponse, type MockRouterDecision, type MockRouterExhaustion, type MockRouterOptions, MockSDK, type MockSDKConfig, ModelCallOptions, ModelCapabilities, ModelConfig, ModelContract, type ModelPricing, ModelResponse, ModelStreamChunk, ModelToolCallRequest, type NamespacedStateAccessor, type Next, type NextStepResult, type OrchestratorAsToolOptions, type OrchestratorAwaitingStatus, OrchestratorCancelledError, type OrchestratorCancelledErrorOptions, type OrchestratorCommandHandlers, type OrchestratorCommands, type OrchestratorConfig, OrchestratorConfigError, type OrchestratorContract, OrchestratorDriftError, type OrchestratorDriftErrorOptions, OrchestratorEmitter, type OrchestratorEvent, type OrchestratorEventHandler, type OrchestratorEventHandlers, type OrchestratorEventMap, type OrchestratorEventName, type OrchestratorExecuteOptions, OrchestratorExecution, type OrchestratorExecutionParams, OrchestratorFailedError, type OrchestratorMemoryConfig, type OrchestratorReport, type OrchestratorReportStatus, type OrchestratorReportType, type OrchestratorResult, type OrchestratorResumeOptions, type OrchestratorSessionScope, type OrchestratorStreamController, Persona, PersonaContract, type PgCheckpointOptions, type PgClientLike, type PgSnapshotStoreOptions, Placeholders, PlannerCancelledError, type PlannerCancelledErrorOptions, type PlannerCapability, type PlannerConfig, type PlannerContract, type PlannerExecuteOptions, PlannerFailedError, type PlannerPlan, PlannerPlanInvalidError, type PlannerReport, type PlannerReportType, type PlannerResult, type PlannerRunArgs, type PlannerStep, type PlannerStepSnapshot, type ProceduralMemoryConfig, ProviderAuthError, ProviderError, ProviderRateLimitError, type ProviderRateLimitErrorOptions, ProviderTimeoutError, QuotaExceededError, REPORT_SCHEMA_VERSION, ReasoningEffort, type RecallOptions, type RecalledMemory, type RedisCheckpointOptions, type RedisClientLike, type RedisSnapshotStoreOptions, type ReportStatus, type ReportType, ResolvedAttachment, type ResolvedIntentEntry, type ResolvedOrchestratorMemory, type RetryBackoff, type RetryConfig, type RouteContext, type RouterConfig, type RouterEntry, type RouterIntents, type RouterOutput, RoutingError, type RoutingErrorOptions, SDKAdapterContract, SchemaValidationError, type SchemaValidationErrorOptions, type SemanticCacheOptions, type SemanticMemoryConfig, type SessionContextOverrides, type SessionContract, type SessionSendResult, type SnapshotStore, type SpawnSubAgentSpec, type StepAgentInput, type StepDefinition, StepFailedError, type StepFailedErrorOptions, type StepLocalEvents, type StepOutputSpec, type StepSnapshot, StorageFileShape, type StreamContract, type StreamController, type StreamEvent, type StreamEventBody, StreamingToolGuardConfig, type SummarizeCallback, type SummarizeConfig, type SupervisorAgentCompletedPayload, type SupervisorAgentFailedPayload, type SupervisorAgentStartingPayload, type SupervisorAgentStreamingPayload, type SupervisorAsToolOptions, SupervisorCancelledError, type SupervisorCancelledErrorOptions, type SupervisorCancelledPayload, type SupervisorCompletedPayload, type SupervisorConfig, type SupervisorContract, SupervisorDriftError, type SupervisorDriftErrorOptions, SupervisorEmitter, type SupervisorErrorPayload, type SupervisorEvaluateVerdictPayload, type SupervisorEventHandler, type SupervisorEventHandlers, type SupervisorEventMap, type SupervisorExecuteOptions, SupervisorExecution, SupervisorFailedError, type SupervisorInput, type SupervisorIntentValue, type SupervisorIterationCompletedPayload, type SupervisorIterationStartingPayload, type SupervisorReport, type SupervisorResult, type SupervisorResumeOptions, type SupervisorRouterDecidedPayload, type SupervisorRouterDecidingPayload, SupervisorRoutingError, type SupervisorRoutingErrorOptions, type SupervisorSnapshot, type SupervisorSnapshotStatus, type SupervisorStartingPayload, type SupervisorStreamController, type SupervisorStreamEvent, type SupervisorTerminatedBy, SystemPrompt, SystemPromptBlockContract, SystemPromptContract, type ToolCall, ToolConfig, ToolContext, type ToolContract, type ToolEventMeta, ToolExecutionError, type ToolExecutionErrorOptions, type ToolInvokeResult, ToolMeta, ToolMode, type TurnSnapshot, type Usage, type UsageEvent, type WithoutIdentity, WorkflowCancelledError, type WorkflowCancelledErrorOptions, type WorkflowCancelledPayload, type WorkflowCompletedPayload, type WorkflowContext, type WorkflowDefinition, WorkflowDriftError, type WorkflowDriftErrorOptions, WorkflowError, type WorkflowErrorPayload, type WorkflowEventHandler, type WorkflowEventHandlers, type WorkflowEventMap, type WorkflowExecuteOptions, type WorkflowInstance, type WorkflowLoopWarningPayload, type WorkflowReport, type WorkflowResult, type WorkflowResumeOptions, type WorkflowRunOptions, type WorkflowSnapshot, type WorkflowStartingPayload, type WorkflowStepCompletedPayload, type WorkflowStepFailedPayload, type WorkflowStepRetryingPayload, type WorkflowStepSkippedPayload, type WorkflowStepStartingPayload, type WorkflowStepStreamingPayload, accumulateCost, agent, ai, approximateTokenCount, batch, budget, buildPlanSystemPrompt, buildRouterContextMessage, memory as checkpointMemory, pg as checkpointPg, redis as checkpointRedis, composeMiddleware, computeCost, computeOrchestratorSignature, computeSignature as computePlannerSignature, computeSignature$1 as computeSignature, computeSignature$2 as computeSupervisorSignature, contains, createAgentStream, createCommandDispatcher as createOrchestratorCommandDispatcher, createOrchestratorStream, createCancelledError as createSupervisorCancelledError, createSupervisorStream, evalScorers, exact, executableToTool, extractJsonPayload, extractJsonSchema, extractUserText, fallbackModel, fanOut, forTool, generateRunId, getAIConfig, guardrail, injectMemories as injectOrchestratorMemories, instruction, isExecutableTool, judge, loadSnapshotForResume as loadSupervisorSnapshotForResume, matchConverge, matchOutputShape, matchPassStep, matchRouteTo, memory$1 as memory, mockAgent, mockRouter, namespacedState, normalizeAgentTools, orchestrator, asTool as orchestratorAsTool, memoryQueryFromInput as orchestratorMemoryQueryFromInput, outcomeTextFromTurn as orchestratorOutcomeTextFromTurn, persistSupervisorSnapshot, persona, planSchema, planner, predicate, prepareAttachmentPart, readBudgetFallbackSignal, recallForTurn as recallOrchestratorMemory, registerAiMatchers, rememberTurnOutcome as rememberOrchestratorTurnOutcome, renderPlaceholders, resolveAttachment, resolveDefaultCheckpointStore, resolveDefaultSnapshotStore, resolveDefaultStore, resolveIntentEntries, resolveOrchestratorMemory, router, runEval, runResume as runOrchestratorResume, runTurn as runOrchestratorTurn, runPipeline, safeJsonParse, semanticCache, setAIConfig, memory$2 as snapshotMemory, pg$1 as snapshotPg, redis$1 as snapshotRedis, spawnSubAgent, stampReportLineage, step, streamTurn as streamOrchestratorTurn, supervisor, asTool$1 as supervisorAsTool, systemPrompt, tool, workflow };
|
|
290
|
+
export { AIConfig, AIError, type AIErrorCode, type AIErrorOptions, type AckCallback, type AckConfig, type AckEntry, type AckRunEntry, type AckSnapshot, type AgentBranchSnapshot, AgentCancelledError, type AgentCancelledErrorOptions, type AgentCompletedPayload, type AgentConfig, type AgentContract, type AgentErrorPayload, type AgentEventHandler, type AgentEventMap, type AgentExecuteOptions, AgentExecutionError, AgentMaxTripsError, type AgentMaxTripsErrorOptions, type AgentMiddleware, type AgentMiddlewareExecuteHooks, type AgentMiddlewareSupervisorHooks, type AgentMiddlewareToolHooks, type AgentMiddlewareTripHooks, type AgentReport, type AgentResult, type AgentStartingPayload, type AgentStreamingPayload, type AgentToolCalledPayload, type AgentToolCallingFailedPayload, type AgentToolCallingPayload, type AgentToolEntry, type AgentTripCompletedPayload, type AgentTripStartedPayload, type Ai, type AiMatchers, type ApprovalDecision, type ApprovalDecisionType, type ApprovalHandler, ApprovalRejectedError, type ApprovalRejectedErrorOptions, type ApprovalRequest, type ApprovalRequestContext, Attachment, AttachmentPolicy, AttachmentSource, type AttemptEntry, type BaseReport, type BaseResult, type BatchItemHandler, type BatchItemResult, type BatchItemStatus, type BatchOptions, type BatchReport, type BatchResult, BinarySource, type BudgetContract, type BudgetContractDimension, type BudgetContractFallback, type BudgetContractViolation, type BudgetContractViolationMode, BudgetExceededError, type BudgetExceededErrorOptions, type BudgetFallbackSignal, type BudgetOptions, type BudgetPricing, type BudgetUnit, type CapturedMessage, type Cassette, type CassetteEntry, type CheckpointRecord, type CheckpointStore, type Chunk, type ChunkOptions, type ChunkType, type Citation, type ClassifierAgentEntry, type ClassifierCallback, type ClassifierConfig, type ClassifierContext, type ClassifierOutput, type ClassifierRefineContext, type ClassifierRefineResult, type ClassifierRunEntry, type ClassifierSnapshot, type CompactionResult, type CompleteEvent, ContentFilterError, type ContentFilterErrorOptions, ContentPart, ContextLengthExceededError, type ContextLengthExceededErrorOptions, DEFAULT_HASH_OPTIONS, DEFAULT_SENSITIVE_KEYS, type DatasetContract, type DatasetEntry, type DatasetOptions, type DecisionSource, type DispatchContext, type DispatchRawResult, END, EmbedderConfig, EmbedderContract, EmbeddingBatchResult, EmbeddingResult, EmbeddingUsage, EndSentinel, type EpisodicMemoryConfig, type ErrorCategory, type EvalCase, type EvalCaseResult, type EvalJudge, type EvalOptions, type EvalPredicate, type EvalReport, type EvalScore, type EvalScorer, type EvalScorerContext, type EvaluateBranchResult, type EvaluateContext, type EvaluateResult, type EventIdentity, ExecutableContract, type ExecutableTool, type ExecuteResult, type ExecutionReport, type ExecutionStatus, type ExportedPrompt, type ExportedPromptVersion, type ExportedRegistry, type ExtractJsonSchemaOptions, type FallbackAttempt, type FallbackModelContract, type FallbackModelOptions, type FallbackRetryPredicate, type FanOutOptions, type FanOutUnit, FinishReason, type FlagRecord, type FlowObserveOption, type GuardOptions, type GuardrailAction, type GuardrailBlockEvent, type GuardrailCheck, type GuardrailCheckResult, type GuardrailDetector, type GuardrailDetectorContext, type GuardrailEscalation, type GuardrailFactory, type GuardrailMatch, type GuardrailOptions, type GuardrailPhase, type GuardrailVerdict, GuardrailViolationError, type GuardrailViolationErrorOptions, type HumanApprovalOptions, type HumanErrorCode, ImageSource, type InjectionDetectorOptions, Instruction, InstructionContract, type IntentCallback, type IntentEntry, type IntentRunEntry, type IntentRunner, type IntentRunnerMap, type InterruptPolicy, type InterruptStore, InterruptSuspendedError, type InterruptSuspendedErrorOptions, InvalidRequestError, type IterationDecision, type IterationSnapshot, JUDGE_DEFAULT_REPAIR_ATTEMPTS, type JsonSchemaTarget, type JudgeAgentConfig, type JudgeConfig, type KeywordRerankerOptions, type LLMTrip, type LexicalDoc, type LineageStamp, type LlmRerankerOptions, type LoadSkillInput, type LoadSkillResult, type LoadSkillToolDeps, type MatcherVerdict, MaxIterationsError, type MaxIterationsErrorOptions, MaxStepsExceededError, type MaxStepsExceededErrorOptions, type MemoryConfig, type MemoryContract, type MemoryItem, type MemoryTier, Message, type MiddlewareAgentRef, type MiddlewareContextByLevel, type MiddlewareExecuteContext, type MiddlewareLevel, type MiddlewareModelRef, type MiddlewareState, type MiddlewareSupervisorContext, type MiddlewareSupervisorRef, type MiddlewareToolContext, type MiddlewareTripContext, MockModel, type MockModelResponse, type MockRouterDecision, type MockRouterExhaustion, type MockRouterOptions, MockSDK, type MockSDKConfig, MockSkillsStore, ModelCallOptions, ModelCapabilities, ModelConfig, ModelContract, type ModelPricing, ModelResponse, ModelStreamChunk, ModelToolCallRequest, type MultiQueryOptions, type NamespacedStateAccessor, type Next, type NextStepResult, OPENAI_INSTALL_INSTRUCTIONS, type ObjectStreamEvent, type Observer, type OpenAiClientLike, type OpenAiModerationCreateBody, type OpenAiModerationOptions, type OpenAiModerationResponse, type OpenAiModerationResult, type OrchestratorAsToolOptions, type OrchestratorAwaitingStatus, OrchestratorCancelledError, type OrchestratorCancelledErrorOptions, type OrchestratorCommandHandlers, type OrchestratorCommands, type OrchestratorConfig, OrchestratorConfigError, type OrchestratorContract, OrchestratorDriftError, type OrchestratorDriftErrorOptions, OrchestratorEmitter, type OrchestratorEvent, type OrchestratorEventHandler, type OrchestratorEventHandlers, type OrchestratorEventMap, type OrchestratorEventName, type OrchestratorExecuteOptions, OrchestratorExecution, type OrchestratorExecutionParams, OrchestratorFailedError, type OrchestratorMemoryConfig, type OrchestratorReport, type OrchestratorReportStatus, type OrchestratorReportType, type OrchestratorResult, type OrchestratorResumeOptions, type OrchestratorSessionScope, type OrchestratorStreamController, type OutboundPolicy, OutboundPolicyError, type ParsedFrontmatter, type PendingInterrupt, type PendingInterruptStatus, Persona, PersonaContract, type PgCheckpointOptions, type PgClientLike, type PgInterruptOptions, type PgSnapshotStoreOptions, type PiiCategory, type PiiDetectorOptions, Placeholders, PlannerCancelledError, type PlannerCancelledErrorOptions, type PlannerCapability, type PlannerConfig, type PlannerContract, type PlannerExecuteOptions, PlannerFailedError, type PlannerPlan, PlannerPlanInvalidError, type PlannerReport, type PlannerReportType, type PlannerResult, type PlannerRunArgs, type PlannerStep, type PlannerStepDirective, type PlannerStepSnapshot, type PolicyContext, type PolicyVerdict, type ProceduralMemoryConfig, type PromptDiff, type PromptDiffBlock, type PromptEntry, type PromptJudgeCacheLike, type PromptLangfuseSyncOptions, PromptNotFoundError, type PromptRegistryContract, type PromptRegistryOptions, type PromptResolveOptions, type PromptTemplateVersion, type PromptValidateOptions, type PromptValidateTarget, PromptValidationError, type PromptValidationNote, type PromptValidationReport, type PromptValidationResult, type PromptValidationSeverity, type PromptVersion, type PromptsManagerContract, type PromptsManagerEntry, type PromptsManagerOptions, type PromptsManagerRegisterOptions, type PromptsValidateOptions, ProviderAuthError, ProviderError, ProviderRateLimitError, type ProviderRateLimitErrorOptions, ProviderTimeoutError, QuotaExceededError, REPORT_SCHEMA_VERSION, type Rag, type RagAsToolOptions, type RagConfig, type RagDocument, type RagReranker, type RankedItem, ReasoningEffort, type RecallOptions, type RecalledMemory, type RedactOptions, type RedactedError, type RedisCheckpointOptions, type RedisClientLike, type RedisInterruptOptions, type RedisSnapshotStoreOptions, type ReportStatus, type ReportType, ResolvedAttachment, type ResolvedIntentEntry, type ResolvedOrchestratorMemory, type ResolvedOutboundPolicy, type ResolvedPrompt, type ResumeOptions, type ResumeResult, type RetrieveOptions, type RetrieveResult, type RetrievedChunk, type RetryBackoff, type RetryConfig, type ReviewOutcome, type RouteContext, type RouterConfig, type RouterEntry, type RouterIntents, type RouterOutput, RoutingError, type RoutingErrorOptions, type RunFrame, SDKAdapterContract, SENSITIVE_HEADERS, SSE_DONE, type SaveSkillInput, type SaveSkillResult, type SaveSkillToolDeps, SchemaValidationError, type SchemaValidationErrorOptions, type SemanticCacheOptions, type SemanticMemoryConfig, type ServableExecutable, type ServeOptions, type SessionContextOverrides, type SessionContract, type SessionLock, type SessionSendResult, type SkillAnalyticsEvent, type SkillCatalogEntry, type SkillInjectMode, type SkillRecord, type SkillReviewGate, type SkillSource, type SkillsConfig, type SkillsContract, type SkillsStoreContract, type SnapshotStore, type SpawnSubAgentSpec, type StepAgentInput, type StepDefinition, StepFailedError, type StepFailedErrorOptions, type StepLocalEvents, type StepOutputSpec, type StepSnapshot, StorageFileShape, type StreamContract, type StreamController, type StreamEvent, type StreamEventBody, type StreamLike, type StreamObjectParams, StreamingToolGuardConfig, type SummarizeCallback, type SummarizeConfig, type SupervisorAgentCompletedPayload, type SupervisorAgentFailedPayload, type SupervisorAgentStartingPayload, type SupervisorAgentStreamingPayload, type SupervisorAsToolOptions, SupervisorCancelledError, type SupervisorCancelledErrorOptions, type SupervisorCancelledPayload, type SupervisorCompletedPayload, type SupervisorConfig, type SupervisorContract, SupervisorDriftError, type SupervisorDriftErrorOptions, SupervisorEmitter, type SupervisorErrorPayload, type SupervisorEvaluateVerdictPayload, type SupervisorEventHandler, type SupervisorEventHandlers, type SupervisorEventMap, type SupervisorExecuteOptions, SupervisorExecution, SupervisorFailedError, type SupervisorInput, type SupervisorIntentValue, type SupervisorIterationCompletedPayload, type SupervisorIterationStartingPayload, type SupervisorReport, type SupervisorResult, type SupervisorResumeOptions, type SupervisorRouterDecidedPayload, type SupervisorRouterDecidingPayload, SupervisorRoutingError, type SupervisorRoutingErrorOptions, type SupervisorSnapshot, type SupervisorSnapshotStatus, type SupervisorStartingPayload, type SupervisorStreamController, type SupervisorStreamEvent, type SupervisorTerminatedBy, type SyncGuardrailDetector, SystemPrompt, SystemPromptBlockContract, SystemPromptContract, SystemPromptMergeOptions, SystemPromptMergeSource, SystemPromptMeta, type TeamConfig, type TeamGate, type TeamGateFn, type TeamMemberValue, type ToolCall, ToolConfig, ToolContext, type ToolContract, type ToolEventMeta, ToolExecutionError, type ToolExecutionErrorOptions, type ToolInvokeResult, ToolMeta, ToolMode, type TopicFilterOptions, type TurnSnapshot, type Usage, type UsageEvent, VcrCassetteMissError, type VcrCassetteMissErrorOptions, type VcrMode, type VcrModel, type VcrOptions, type VectorStore, type WithoutIdentity, WorkflowCancelledError, type WorkflowCancelledErrorOptions, type WorkflowCancelledPayload, type WorkflowCompletedPayload, type WorkflowContext, type WorkflowDefinition, WorkflowDriftError, type WorkflowDriftErrorOptions, WorkflowError, type WorkflowErrorPayload, type WorkflowEventHandler, type WorkflowEventHandlers, type WorkflowEventMap, type WorkflowExecuteOptions, type WorkflowInstance, type WorkflowLoopWarningPayload, type WorkflowReport, type WorkflowResult, type WorkflowResumeOptions, type WorkflowRunOptions, type WorkflowSnapshot, type WorkflowStartingPayload, type WorkflowStepCompletedPayload, type WorkflowStepFailedPayload, type WorkflowStepRetryingPayload, type WorkflowStepSkippedPayload, type WorkflowStepStartingPayload, type WorkflowStepStreamingPayload, accumulateCost, agent, ai, approximateTokenCount, assertUrlAllowed, batch, bm25Rank, budget, buildCatalog, buildPlanSystemPrompt, buildRouterContextMessage, cacheVectorStore, captureChildReport, memory as checkpointMemory, pg as checkpointPg, redis as checkpointRedis, chunk, collectStreamObject, composeMiddleware, computeCost, computeOrchestratorSignature, computeSignature as computePlannerSignature, computeSignature$1 as computeSignature, computeSignature$2 as computeSupervisorSignature, contains, createAgentStream, createCommandDispatcher as createOrchestratorCommandDispatcher, createOrchestratorStream, createCancelledError as createSupervisorCancelledError, createSupervisorStream, currentRunFrame, dataset, defaultPromptsManager, diff, directorySource, encodeSSE, evalScorers, evaluatePolicy, exact, executableToTool, extractJsonLenient, extractJsonPayload, extractJsonSchema, extractUserText, fallbackModel, fanOut, fetchTextWithPolicy, forTool, fromJSON, generateRunId, getAIConfig, getObservers, guard, guardedFetch, guardrail, hashRequest, humanApproval, hybridRank, inProcessSessionLock, injectMemories as injectOrchestratorMemories, injection, instruction, memory$1 as interruptMemory, pg$1 as interruptPg, redis$1 as interruptRedis, isExecutableTool, isObserveAll, isPrivateOrReservedIp, judge, keywordReranker, llmReranker, loadRecord, loadSkillTool, loadSnapshotForResume as loadSupervisorSnapshotForResume, matchConverge, matchOutputShape, matchPassStep, matchRouteTo, memory$2 as memory, mergeUsage, mockAgent, mockRouter, moderation, multiQuery, namespacedState, noopSessionLock, normalizeAgentTools, onConfigApplied, orchestrator, asTool as orchestratorAsTool, memoryQueryFromInput as orchestratorMemoryQueryFromInput, outcomeTextFromTurn as orchestratorOutcomeTextFromTurn, parseFrontmatter, parsePartialJson, parseTags, persistSupervisorSnapshot, persona, pii, planSchema, planner, predicate, prepareAttachmentPart, proceduralSkillStore, prompt, promptKey, prompts, rag, readBudgetFallbackSignal, readTextCapped, recallForTurn as recallOrchestratorMemory, reciprocalRankFusion, redact, redactError, redactHeaders, registerAiMatchers, registerObserver, rememberTurnOutcome as rememberOrchestratorTurnOutcome, renderCatalogPrompt, renderPlaceholders, resolveAttachment, resolveDefaultCheckpointStore, resolveDefaultSnapshotStore, resolveDefaultStore, resolveIntentEntries, resolveObservers, resolveOrchestratorMemory, resolveOutboundPolicy, resolveSource, resume, router, runEval, runResume as runOrchestratorResume, runTurn as runOrchestratorTurn, runPipeline, runReviewGate, safeJsonParse, saveSkillTool, scrubSecrets, semanticCache, semanticPreselect, serve, setAIConfig, setObserveAll, skills, memory$3 as snapshotMemory, pg$2 as snapshotPg, redis$2 as snapshotRedis, spawnSubAgent, stampReportLineage, step, storeSource, streamObject, streamTurn as streamOrchestratorTurn, streamToSSE, supervisor, asTool$1 as supervisorAsTool, systemPrompt, team, toJSON, toJUnit, tool, topic, urlSource, vcr, withRunFrame, withoutRunFrame, workflow };
|
|
291
|
+
import "./ai.mjs";
|
|
292
|
+
import "./config.mjs";
|
|
202
293
|
import "./testing/matchers.mjs";
|
package/esm/index.mjs
CHANGED
|
@@ -16,6 +16,7 @@ import { OrchestratorFailedError } from "./errors/orchestrator-failed-error.mjs"
|
|
|
16
16
|
import { OrchestratorCancelledError } from "./errors/orchestrator-cancelled-error.mjs";
|
|
17
17
|
import { OrchestratorConfigError } from "./errors/orchestrator-config-error.mjs";
|
|
18
18
|
import { OrchestratorDriftError } from "./errors/orchestrator-drift-error.mjs";
|
|
19
|
+
import { OutboundPolicyError } from "./errors/outbound-policy-error.mjs";
|
|
19
20
|
import { PlannerFailedError } from "./errors/planner-failed-error.mjs";
|
|
20
21
|
import { PlannerCancelledError } from "./errors/planner-cancelled-error.mjs";
|
|
21
22
|
import { PlannerPlanInvalidError } from "./errors/planner-plan-invalid-error.mjs";
|
|
@@ -33,43 +34,88 @@ import { ToolExecutionError } from "./errors/tool-execution-error.mjs";
|
|
|
33
34
|
import { WorkflowCancelledError } from "./errors/workflow-cancelled-error.mjs";
|
|
34
35
|
import { WorkflowDriftError } from "./errors/workflow-drift-error.mjs";
|
|
35
36
|
import "./errors/index.mjs";
|
|
36
|
-
import { accumulateCost, computeCost } from "./utils/compute-cost.mjs";
|
|
37
|
+
import { accumulateCost, computeCost, mergeUsage } from "./utils/compute-cost.mjs";
|
|
37
38
|
import { extractJsonPayload } from "./utils/extract-json-payload.mjs";
|
|
39
|
+
import { extractJsonLenient } from "./utils/extract-json-lenient.mjs";
|
|
38
40
|
import { generateRunId } from "./utils/generate-run-id.mjs";
|
|
39
41
|
import { extractJsonSchema } from "./utils/json-schema.mjs";
|
|
42
|
+
import { isPrivateOrReservedIp } from "./security/private-ip.mjs";
|
|
43
|
+
import { assertUrlAllowed, fetchTextWithPolicy, guardedFetch, readTextCapped, resolveOutboundPolicy } from "./security/outbound-policy.mjs";
|
|
40
44
|
import { resolveAttachment } from "./utils/resolve-attachment.mjs";
|
|
41
45
|
import { prepareAttachmentPart } from "./utils/prepare-attachment-part.mjs";
|
|
46
|
+
import { captureChildReport, currentRunFrame, withRunFrame, withoutRunFrame } from "./utils/run-context.mjs";
|
|
42
47
|
import { safeJsonParse } from "./utils/safe-json-parse.mjs";
|
|
43
48
|
import { REPORT_SCHEMA_VERSION } from "./contracts/result/base-report.type.mjs";
|
|
44
49
|
import { stampReportLineage } from "./utils/stamp-report-lineage.mjs";
|
|
45
50
|
import { approximateTokenCount } from "./utils/token-count.mjs";
|
|
46
51
|
import "./utils/index.mjs";
|
|
47
52
|
import { judge } from "./eval/judge-scorer.mjs";
|
|
53
|
+
import { diff } from "./eval/regression.mjs";
|
|
48
54
|
import { runEval } from "./eval/eval-runner.mjs";
|
|
49
55
|
import { extractUserText } from "./middleware/utils/extract-user-text.mjs";
|
|
50
56
|
import { namespacedState } from "./middleware/utils/namespaced-state.mjs";
|
|
51
57
|
import { budget, readBudgetFallbackSignal } from "./middleware/builtins/budget.mjs";
|
|
52
|
-
import {
|
|
53
|
-
import { getAIConfig, resolveDefaultCheckpointStore, resolveDefaultSnapshotStore, resolveDefaultStore, setAIConfig } from "./config.mjs";
|
|
58
|
+
import { getAIConfig, onConfigApplied, resolveDefaultCheckpointStore, resolveDefaultSnapshotStore, resolveDefaultStore, setAIConfig } from "./config.mjs";
|
|
54
59
|
import { semanticCache } from "./middleware/builtins/semantic-cache.mjs";
|
|
55
60
|
import { composeMiddleware } from "./middleware/helpers/compose.mjs";
|
|
56
61
|
import { forTool } from "./middleware/helpers/for-tool.mjs";
|
|
57
62
|
import { runPipeline } from "./middleware/pipeline.mjs";
|
|
58
63
|
import "./middleware/index.mjs";
|
|
64
|
+
import { getObservers, isObserveAll, registerObserver, setObserveAll } from "./observe/observer-registry.mjs";
|
|
65
|
+
import { resolveObservers } from "./observe/resolve-observers.mjs";
|
|
66
|
+
import { buildCatalog, loadRecord, renderCatalogPrompt, semanticPreselect } from "./skills/catalog.mjs";
|
|
59
67
|
import { tool } from "./tool/tool.mjs";
|
|
68
|
+
import { loadSkillTool } from "./skills/load-skill-tool.mjs";
|
|
69
|
+
import { saveSkillTool } from "./skills/save-skill-tool.mjs";
|
|
70
|
+
import { parseFrontmatter, parseTags } from "./skills/sources/parse-frontmatter.mjs";
|
|
71
|
+
import { directorySource } from "./skills/sources/directory-source.mjs";
|
|
72
|
+
import { storeSource } from "./skills/sources/store-source.mjs";
|
|
73
|
+
import { urlSource } from "./skills/sources/url-source.mjs";
|
|
74
|
+
import { resolveSource } from "./skills/sources/index.mjs";
|
|
75
|
+
import { skills } from "./skills/skills.mjs";
|
|
76
|
+
import { MockSkillsStore } from "./skills/store/mock-skills-store.mjs";
|
|
77
|
+
import { memory as memory$2 } from "./memory/memory.mjs";
|
|
78
|
+
import { proceduralSkillStore } from "./skills/store/procedural-skill-store.mjs";
|
|
79
|
+
import { runReviewGate } from "./skills/review-gate.mjs";
|
|
80
|
+
import "./skills/index.mjs";
|
|
60
81
|
import { executableToTool, isExecutableTool, normalizeAgentTools } from "./tool/executable-as-tool.mjs";
|
|
82
|
+
import { JUDGE_DEFAULT_REPAIR_ATTEMPTS } from "./agent/judge-config.type.mjs";
|
|
61
83
|
import { createAgentStream } from "./agent/agent-stream.mjs";
|
|
62
84
|
import { agent } from "./agent/agent.mjs";
|
|
63
85
|
import { spawnSubAgent } from "./agent/spawn-sub-agent.mjs";
|
|
64
86
|
import "./agent/index.mjs";
|
|
65
87
|
import { batch } from "./batch/batch.mjs";
|
|
66
88
|
import "./batch/index.mjs";
|
|
89
|
+
import { parsePartialJson } from "./object-stream/parse-partial-json.mjs";
|
|
90
|
+
import { collectStreamObject, streamObject } from "./object-stream/stream-object.mjs";
|
|
91
|
+
import "./object-stream/index.mjs";
|
|
92
|
+
import { SSE_DONE, encodeSSE } from "./serve/sse.mjs";
|
|
93
|
+
import { streamToSSE } from "./serve/stream-to-sse.mjs";
|
|
94
|
+
import { serve } from "./serve/serve.mjs";
|
|
67
95
|
import { memory } from "./checkpoint/memory.mjs";
|
|
68
96
|
import { pg } from "./checkpoint/pg.mjs";
|
|
69
97
|
import { redis } from "./checkpoint/redis.mjs";
|
|
98
|
+
import { fromJSON, toJSON } from "./eval/report-json.mjs";
|
|
99
|
+
import { toJUnit } from "./eval/report-junit.mjs";
|
|
70
100
|
import { contains, exact, predicate } from "./eval/scorers.mjs";
|
|
101
|
+
import { dataset } from "./eval/dataset.mjs";
|
|
71
102
|
import { evalScorers } from "./eval/index.mjs";
|
|
72
|
-
import {
|
|
103
|
+
import { ApprovalRejectedError, InterruptSuspendedError } from "./human/errors.mjs";
|
|
104
|
+
import { evaluatePolicy } from "./human/policy.mjs";
|
|
105
|
+
import { humanApproval } from "./human/human-approval.mjs";
|
|
106
|
+
import { resume } from "./human/resume.mjs";
|
|
107
|
+
import { memory as memory$1 } from "./human/stores/memory.mjs";
|
|
108
|
+
import { pg as pg$1 } from "./human/stores/pg.mjs";
|
|
109
|
+
import { redis as redis$1 } from "./human/stores/redis.mjs";
|
|
110
|
+
import "./human/stores/index.mjs";
|
|
111
|
+
import { injection } from "./guard/detectors/injection.mjs";
|
|
112
|
+
import { pii } from "./guard/detectors/pii.mjs";
|
|
113
|
+
import { topic } from "./guard/detectors/topic.mjs";
|
|
114
|
+
import { OPENAI_INSTALL_INSTRUCTIONS } from "./guard/errors.mjs";
|
|
115
|
+
import { moderation } from "./guard/detectors/moderation.mjs";
|
|
116
|
+
import "./guard/detectors/index.mjs";
|
|
117
|
+
import { guard } from "./guard/guard.mjs";
|
|
118
|
+
import { guardrail } from "./guard/guardrail.mjs";
|
|
73
119
|
import { MockModel } from "./mock/mock-model.mjs";
|
|
74
120
|
import { MockSDK } from "./mock/mock-sdk.mjs";
|
|
75
121
|
import { mockAgent } from "./mock/mock-agent.mjs";
|
|
@@ -94,6 +140,7 @@ import { createSupervisorStream } from "./supervisor/supervisor-stream.mjs";
|
|
|
94
140
|
import { supervisor } from "./supervisor/supervisor.mjs";
|
|
95
141
|
import { OrchestratorExecution, runResume, runTurn, streamTurn } from "./orchestrator/execution.mjs";
|
|
96
142
|
import { createOrchestratorStream } from "./orchestrator/orchestrator-stream.mjs";
|
|
143
|
+
import { inProcessSessionLock, noopSessionLock } from "./orchestrator/session-lock.mjs";
|
|
97
144
|
import { computeOrchestratorSignature } from "./orchestrator/signature.mjs";
|
|
98
145
|
import { orchestrator } from "./orchestrator/orchestrator.mjs";
|
|
99
146
|
import "./orchestrator/index.mjs";
|
|
@@ -102,24 +149,48 @@ import { planSchema } from "./planner/plan-schema.mjs";
|
|
|
102
149
|
import { computeSignature } from "./planner/signature.mjs";
|
|
103
150
|
import { planner } from "./planner/planner.mjs";
|
|
104
151
|
import "./planner/index.mjs";
|
|
105
|
-
import { memory as memory$2 } from "./snapshot/memory.mjs";
|
|
106
|
-
import { pg as pg$1 } from "./snapshot/pg.mjs";
|
|
107
|
-
import { redis as redis$1 } from "./snapshot/redis.mjs";
|
|
108
|
-
import { fanOut } from "./supervisor/fan-out.mjs";
|
|
109
|
-
import { router } from "./supervisor/router-factory.mjs";
|
|
110
|
-
import "./supervisor/index.mjs";
|
|
111
152
|
import { renderPlaceholders } from "./system-prompt/render-placeholders.mjs";
|
|
112
153
|
import { Instruction, instruction } from "./system-prompt/instruction.mjs";
|
|
113
154
|
import { Persona, persona } from "./system-prompt/persona.mjs";
|
|
114
155
|
import { SystemPrompt, systemPrompt } from "./system-prompt/system-prompt.mjs";
|
|
156
|
+
import { defaultPromptsManager, promptKey, prompts } from "./prompts/prompts-manager.mjs";
|
|
157
|
+
import { chunk } from "./rag/chunk/chunk.mjs";
|
|
158
|
+
import { cacheVectorStore } from "./rag/store/cache-vector-store.mjs";
|
|
159
|
+
import { rag } from "./rag/rag.mjs";
|
|
160
|
+
import { keywordReranker } from "./rag/rerank/keyword-reranker.mjs";
|
|
161
|
+
import { llmReranker } from "./rag/rerank/llm-reranker.mjs";
|
|
162
|
+
import { reciprocalRankFusion } from "./rag/hybrid/rrf.mjs";
|
|
163
|
+
import { bm25Rank } from "./rag/hybrid/bm25.mjs";
|
|
164
|
+
import { hybridRank } from "./rag/hybrid/hybrid-rank.mjs";
|
|
165
|
+
import { multiQuery } from "./rag/transforms/multi-query.mjs";
|
|
166
|
+
import "./rag/index.mjs";
|
|
167
|
+
import { PromptNotFoundError, PromptValidationError } from "./prompt/errors.mjs";
|
|
168
|
+
import { prompt } from "./prompt/prompt.mjs";
|
|
169
|
+
import "./prompt/index.mjs";
|
|
170
|
+
import { DEFAULT_SENSITIVE_KEYS, SENSITIVE_HEADERS, redact, redactError, redactHeaders, scrubSecrets } from "./security/redact.mjs";
|
|
171
|
+
import { VcrCassetteMissError } from "./vcr/errors.mjs";
|
|
172
|
+
import { DEFAULT_HASH_OPTIONS, hashRequest } from "./vcr/hash-request.mjs";
|
|
173
|
+
import { vcr } from "./vcr/vcr.mjs";
|
|
174
|
+
import "./vcr/index.mjs";
|
|
175
|
+
import { memory as memory$3 } from "./snapshot/memory.mjs";
|
|
176
|
+
import { pg as pg$2 } from "./snapshot/pg.mjs";
|
|
177
|
+
import { redis as redis$2 } from "./snapshot/redis.mjs";
|
|
178
|
+
import { fanOut } from "./supervisor/fan-out.mjs";
|
|
179
|
+
import { router } from "./supervisor/router-factory.mjs";
|
|
180
|
+
import "./supervisor/index.mjs";
|
|
181
|
+
import { team } from "./team/team.mjs";
|
|
115
182
|
import { step } from "./workflow/step.mjs";
|
|
116
183
|
import { computeSignature as computeSignature$1 } from "./workflow/signature.mjs";
|
|
117
184
|
import { workflow } from "./workflow/workflow.mjs";
|
|
118
185
|
import { ai } from "./ai.mjs";
|
|
186
|
+
import "./observe/index.mjs";
|
|
187
|
+
import "./prompts/index.mjs";
|
|
188
|
+
import "./security/index.mjs";
|
|
189
|
+
import "./team/index.mjs";
|
|
119
190
|
import "./system-prompt/index.mjs";
|
|
120
191
|
import "./tool/index.mjs";
|
|
121
192
|
import "./workflow/index.mjs";
|
|
122
193
|
import { matchConverge, matchOutputShape, matchPassStep, matchRouteTo } from "./testing/matcher-logic.mjs";
|
|
123
194
|
import { registerAiMatchers } from "./testing/register-lazy.mjs";
|
|
124
195
|
|
|
125
|
-
export { AIError, AgentCancelledError, AgentExecutionError, AgentMaxTripsError, BudgetExceededError, ContentFilterError, ContextLengthExceededError, END, GuardrailViolationError, Instruction, InvalidRequestError, MaxIterationsError, MaxStepsExceededError, MockModel, MockSDK, OrchestratorCancelledError, OrchestratorConfigError, OrchestratorDriftError, OrchestratorEmitter, OrchestratorExecution, OrchestratorFailedError, Persona, PlannerCancelledError, PlannerFailedError, PlannerPlanInvalidError, ProviderAuthError, ProviderError, ProviderRateLimitError, ProviderTimeoutError, QuotaExceededError, REPORT_SCHEMA_VERSION, RoutingError, SchemaValidationError, StepFailedError, SupervisorCancelledError, SupervisorDriftError, SupervisorEmitter, SupervisorExecution, SupervisorFailedError, SupervisorRoutingError, SystemPrompt, ToolExecutionError, WorkflowCancelledError, WorkflowDriftError, WorkflowError, accumulateCost, agent, ai, approximateTokenCount, batch, budget, buildPlanSystemPrompt, buildRouterContextMessage, memory as checkpointMemory, pg as checkpointPg, redis as checkpointRedis, composeMiddleware, computeCost, computeOrchestratorSignature, computeSignature as computePlannerSignature, computeSignature$1 as computeSignature, computeSignature$2 as computeSupervisorSignature, contains, createAgentStream, createCommandDispatcher as createOrchestratorCommandDispatcher, createOrchestratorStream, createCancelledError as createSupervisorCancelledError, createSupervisorStream, evalScorers, exact, executableToTool, extractJsonPayload, extractJsonSchema, extractUserText, fallbackModel, fanOut, forTool, generateRunId, getAIConfig, guardrail, injectMemories as injectOrchestratorMemories, instruction, isExecutableTool, judge, loadSnapshotForResume as loadSupervisorSnapshotForResume, matchConverge, matchOutputShape, matchPassStep, matchRouteTo, memory$
|
|
196
|
+
export { AIError, AgentCancelledError, AgentExecutionError, AgentMaxTripsError, ApprovalRejectedError, BudgetExceededError, ContentFilterError, ContextLengthExceededError, DEFAULT_HASH_OPTIONS, DEFAULT_SENSITIVE_KEYS, END, GuardrailViolationError, Instruction, InterruptSuspendedError, InvalidRequestError, JUDGE_DEFAULT_REPAIR_ATTEMPTS, MaxIterationsError, MaxStepsExceededError, MockModel, MockSDK, MockSkillsStore, OPENAI_INSTALL_INSTRUCTIONS, OrchestratorCancelledError, OrchestratorConfigError, OrchestratorDriftError, OrchestratorEmitter, OrchestratorExecution, OrchestratorFailedError, OutboundPolicyError, Persona, PlannerCancelledError, PlannerFailedError, PlannerPlanInvalidError, PromptNotFoundError, PromptValidationError, ProviderAuthError, ProviderError, ProviderRateLimitError, ProviderTimeoutError, QuotaExceededError, REPORT_SCHEMA_VERSION, RoutingError, SENSITIVE_HEADERS, SSE_DONE, SchemaValidationError, StepFailedError, SupervisorCancelledError, SupervisorDriftError, SupervisorEmitter, SupervisorExecution, SupervisorFailedError, SupervisorRoutingError, SystemPrompt, ToolExecutionError, VcrCassetteMissError, WorkflowCancelledError, WorkflowDriftError, WorkflowError, accumulateCost, agent, ai, approximateTokenCount, assertUrlAllowed, batch, bm25Rank, budget, buildCatalog, buildPlanSystemPrompt, buildRouterContextMessage, cacheVectorStore, captureChildReport, memory as checkpointMemory, pg as checkpointPg, redis as checkpointRedis, chunk, collectStreamObject, composeMiddleware, computeCost, computeOrchestratorSignature, computeSignature as computePlannerSignature, computeSignature$1 as computeSignature, computeSignature$2 as computeSupervisorSignature, contains, createAgentStream, createCommandDispatcher as createOrchestratorCommandDispatcher, createOrchestratorStream, createCancelledError as createSupervisorCancelledError, createSupervisorStream, currentRunFrame, dataset, defaultPromptsManager, diff, directorySource, encodeSSE, evalScorers, evaluatePolicy, exact, executableToTool, extractJsonLenient, extractJsonPayload, extractJsonSchema, extractUserText, fallbackModel, fanOut, fetchTextWithPolicy, forTool, fromJSON, generateRunId, getAIConfig, getObservers, guard, guardedFetch, guardrail, hashRequest, humanApproval, hybridRank, inProcessSessionLock, injectMemories as injectOrchestratorMemories, injection, instruction, memory$1 as interruptMemory, pg$1 as interruptPg, redis$1 as interruptRedis, isExecutableTool, isObserveAll, isPrivateOrReservedIp, judge, keywordReranker, llmReranker, loadRecord, loadSkillTool, loadSnapshotForResume as loadSupervisorSnapshotForResume, matchConverge, matchOutputShape, matchPassStep, matchRouteTo, memory$2 as memory, mergeUsage, mockAgent, mockRouter, moderation, multiQuery, namespacedState, noopSessionLock, normalizeAgentTools, onConfigApplied, orchestrator, asTool as orchestratorAsTool, memoryQueryFromInput as orchestratorMemoryQueryFromInput, outcomeTextFromTurn as orchestratorOutcomeTextFromTurn, parseFrontmatter, parsePartialJson, parseTags, persistSupervisorSnapshot, persona, pii, planSchema, planner, predicate, prepareAttachmentPart, proceduralSkillStore, prompt, promptKey, prompts, rag, readBudgetFallbackSignal, readTextCapped, recallForTurn as recallOrchestratorMemory, reciprocalRankFusion, redact, redactError, redactHeaders, registerAiMatchers, registerObserver, rememberTurnOutcome as rememberOrchestratorTurnOutcome, renderCatalogPrompt, renderPlaceholders, resolveAttachment, resolveDefaultCheckpointStore, resolveDefaultSnapshotStore, resolveDefaultStore, resolveIntentEntries, resolveObservers, resolveOrchestratorMemory, resolveOutboundPolicy, resolveSource, resume, router, runEval, runResume as runOrchestratorResume, runTurn as runOrchestratorTurn, runPipeline, runReviewGate, safeJsonParse, saveSkillTool, scrubSecrets, semanticCache, semanticPreselect, serve, setAIConfig, setObserveAll, skills, memory$3 as snapshotMemory, pg$2 as snapshotPg, redis$2 as snapshotRedis, spawnSubAgent, stampReportLineage, step, storeSource, streamObject, streamTurn as streamOrchestratorTurn, streamToSSE, supervisor, asTool$1 as supervisorAsTool, systemPrompt, team, toJSON, toJUnit, tool, topic, urlSource, vcr, withRunFrame, withoutRunFrame, workflow };
|
|
@@ -144,6 +144,7 @@ function budget(options) {
|
|
|
144
144
|
const hasContractCostCap = typeof contract?.maxCostUSD === "number";
|
|
145
145
|
const hasContractLatencyCap = typeof contract?.maxLatencyMs === "number";
|
|
146
146
|
const contractNeedsCost = hasCostCap || hasContractCostCap;
|
|
147
|
+
const warnedUnpricedModels = /* @__PURE__ */ new Set();
|
|
147
148
|
return {
|
|
148
149
|
name,
|
|
149
150
|
execute: { before(context) {
|
|
@@ -159,11 +160,14 @@ function budget(options) {
|
|
|
159
160
|
const counters = namespacedState(context, name).get();
|
|
160
161
|
if (!counters) return;
|
|
161
162
|
counters.tokens += response.usage.total;
|
|
162
|
-
if (contractNeedsCost
|
|
163
|
-
const pricing = options.pricing[context.model.name];
|
|
163
|
+
if (contractNeedsCost) {
|
|
164
|
+
const pricing = options.pricing?.[context.model.name];
|
|
164
165
|
if (pricing) {
|
|
165
166
|
const tripCost = response.usage.input / 1e3 * pricing.inputPer1K + response.usage.output / 1e3 * pricing.outputPer1K;
|
|
166
167
|
counters.costUSD += tripCost;
|
|
168
|
+
} else if (!warnedUnpricedModels.has(context.model.name)) {
|
|
169
|
+
warnedUnpricedModels.add(context.model.name);
|
|
170
|
+
console.warn(`ai.middleware.budget("${name}"): a USD cost cap is set but no pricing entry matches the running model "${context.model.name}" — the cap cannot be enforced for it. Add a pricing entry for "${context.model.name}" to options.pricing.`);
|
|
167
171
|
}
|
|
168
172
|
}
|
|
169
173
|
if (hasTokenCap && counters.tokens > options.maxTokens) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"budget.mjs","names":[],"sources":["../../../../../../../../@warlock.js/ai/src/middleware/builtins/budget.ts"],"sourcesContent":["import type {\n AgentMiddleware,\n MiddlewareExecuteContext,\n} from \"../../contracts/middleware\";\nimport { BudgetExceededError, type BudgetUnit } from \"../../errors\";\nimport { namespacedState } from \"../utils\";\nimport type {\n BudgetContract,\n BudgetContractDimension,\n BudgetContractViolation,\n} from \"./budget-contract.type\";\n\nexport type {\n BudgetContract,\n BudgetContractDimension,\n BudgetContractFallback,\n BudgetContractViolation,\n BudgetContractViolationMode,\n} from \"./budget-contract.type\";\n\n/**\n * Per-model pricing used to compute USD cost from token counts.\n * Caller-supplied — no bundled table. Keys are model names (the\n * `ModelContract.name` value); values are input / output token\n * prices expressed as **USD per 1K tokens** to match every major\n * provider's published pricing sheet.\n */\nexport type BudgetPricing = Record<\n string,\n {\n /** USD per 1,000 input tokens. */\n inputPer1K: number;\n /** USD per 1,000 output tokens. */\n outputPer1K: number;\n }\n>;\n\n/**\n * Configuration for `budget()`. At least one of `maxTokens` or\n * `maxCostUSD` must be supplied — a budget with no cap is a no-op.\n */\nexport type BudgetOptions = {\n /**\n * Hard cap on cumulative total tokens (input + output, summed\n * across every trip of the run). Inclusive — exceeding triggers\n * the configured `onExceeded`.\n */\n maxTokens?: number;\n /**\n * Hard cap on cumulative USD cost. Requires `pricing` for the\n * agent's configured model — without a pricing entry the USD check\n * silently skips (tokens-only enforcement still applies).\n */\n maxCostUSD?: number;\n /**\n * Per-model pricing table used to compute USD cost. Only consulted\n * when `maxCostUSD` is set. Model names must match the running\n * agent's `ModelContract.name` exactly.\n */\n pricing?: BudgetPricing;\n /**\n * Behavior when a cap is breached. `\"abort\"` throws\n * `BudgetExceededError` — surfaces on `result.error`, stops the\n * run at the next trip boundary. `\"warn\"` logs a warning and\n * lets the run continue (useful for observability-first rollouts\n * before flipping the switch to abort). Default `\"abort\"`.\n */\n onExceeded?: \"abort\" | \"warn\";\n /**\n * Override the middleware name. Useful when two budgets coexist\n * (e.g. a per-request cap plus a session-wide cap via different\n * instances). Default `\"budget\"`.\n */\n name?: string;\n /**\n * Declarative SLO / cost contract enforced on top of (and\n * independently of) the legacy `maxTokens` / `maxCostUSD` caps.\n * Adds a wall-clock `maxLatencyMs` dimension and a per-contract\n * `onViolation` reaction (`\"abort\"` hard-stops, `\"fallback\"` records\n * a signal + fires `fallback` and lets the run continue). Omit to\n * keep the classic budget behavior unchanged.\n *\n * Read a recorded fallback signal back with\n * {@link readBudgetFallbackSignal}.\n */\n contract?: BudgetContract;\n};\n\ntype BudgetCounters = {\n tokens: number;\n costUSD: number;\n warned: boolean;\n /**\n * Wall-clock epoch ms captured at `execute.before`. Used to derive\n * cumulative run latency for the contract's `maxLatencyMs` clause.\n */\n startedAt: number;\n /**\n * Set once a `\"fallback\"` contract clause has fired, so the signal +\n * callback are emitted at most once per run even if later trips keep\n * breaching.\n */\n fallbackFired: boolean;\n};\n\n/**\n * Recorded contract fallback signal, stashed under the `<name>.fallback`\n * state key when a `\"fallback\"` clause trips. A fallback orchestrator\n * reads it via {@link readBudgetFallbackSignal} to decide how to degrade.\n */\nexport type BudgetFallbackSignal = BudgetContractViolation;\n\n/**\n * The `BudgetUnit` to stamp on the thrown error per contract dimension.\n * Latency has no native unit — it borrows `\"requests\"` as the least-wrong\n * operational measure, while the authoritative detail rides on the\n * error's `context.dimension`.\n */\nconst DIMENSION_UNIT: Record<BudgetContractDimension, BudgetUnit> = {\n tokens: \"tokens\",\n cost: \"usd\",\n latency: \"requests\",\n};\n\nfunction breach(\n limit: number,\n actual: number,\n unit: BudgetUnit,\n name: string,\n): never {\n throw new BudgetExceededError(\n `budget \"${name}\" exceeded — ${actual} ${unit} (cap: ${limit})`,\n { limit, actual, unit },\n );\n}\n\nfunction breachContract(\n name: string,\n dimension: BudgetContractDimension,\n limit: number,\n actual: number,\n): never {\n throw new BudgetExceededError(\n `budget \"${name}\" contract exceeded — ${dimension} ${actual} (cap: ${limit})`,\n {\n limit,\n actual,\n unit: DIMENSION_UNIT[dimension],\n context: { dimension, limit, actual, source: \"contract\" },\n },\n );\n}\n\n/**\n * Read the contract fallback signal recorded by a `budget()` middleware\n * running under `contract.onViolation: \"fallback\"`. Returns `undefined`\n * when no clause was breached.\n *\n * **Role.** The middleware cannot itself switch models on a soft breach,\n * so it records a typed {@link BudgetFallbackSignal} in the shared state\n * bag and lets the run continue. A fallback orchestrator (or the\n * `execute.after` hook of an outer middleware) reads it back here and\n * decides how to degrade the next run — cheaper model, cached answer,\n * truncated context.\n *\n * @param state - The middleware state bag (`ctx.state`).\n * @param name - The budget middleware's name. Default `\"budget\"`,\n * matching `BudgetOptions.name`'s default.\n *\n * @example\n * const guard = budget({ contract: { maxCostUSD: 0.05, onViolation: \"fallback\" } });\n *\n * // In an outer middleware's execute.after, after the run:\n * const signal = readBudgetFallbackSignal(ctx.state);\n * if (signal?.dimension === \"cost\") {\n * await rerunOnCheaperModel();\n * }\n */\nexport function readBudgetFallbackSignal(\n state: MiddlewareExecuteContext[\"state\"],\n name = \"budget\",\n): BudgetFallbackSignal | undefined {\n return namespacedState<BudgetFallbackSignal>(\n { state },\n `${name}.fallback`,\n ).get();\n}\n\n/**\n * Enforced token and / or USD budget for an agent run.\n *\n * **Role.** Guards against runaway tool loops, misconfigured\n * prompts, and unexpected provider price swings by capping\n * cumulative usage across every LLM trip of a single execution.\n * Aborts the run with a typed `BudgetExceededError` the moment a cap\n * is breached, rather than letting the damage grow trip by trip.\n *\n * **Scope.** Per-execution. A fresh counter is created at\n * `execute.before` and lives in the middleware state bag until the\n * run ends. Two concurrent `agent.execute()` calls on the same\n * agent therefore enforce the cap independently.\n *\n * **Token accounting.** After each successful trip, the middleware\n * adds `response.usage.total` to its running total and checks\n * against `maxTokens`. Synthetic trips (cache hits) contribute\n * `usage.total` as returned by the cache — cache middleware is\n * expected to surface zero usage on a hit, which naturally excludes\n * those trips from the budget.\n *\n * **USD accounting.** When `maxCostUSD` + `pricing[modelName]` are\n * both present, the middleware converts per-trip input / output\n * tokens to USD and accumulates. Missing pricing silently degrades\n * to tokens-only — explicit rather than guessing.\n *\n * **Warn mode.** `onExceeded: \"warn\"` logs a single warning the first\n * time a cap is breached and lets the run continue. Useful for\n * measuring real-world traffic against a proposed cap before flipping\n * to `\"abort\"` in production.\n *\n * **Contract / SLO mode.** Pass `contract` to enforce a declarative\n * service-level objective — `maxCostUSD`, `maxLatencyMs`, `maxTokens` —\n * on top of the legacy caps, with a single `onViolation` reaction:\n * `\"abort\"` hard-stops with `BudgetExceededError`; `\"fallback\"` records\n * a typed signal (read it via {@link readBudgetFallbackSignal}), fires\n * the optional `fallback` callback, and lets the run continue so an\n * outer layer can degrade gracefully. The contract's clauses are\n * evaluated independently of — and after — the top-level caps; the\n * top-level caps stay fully functional with or without a contract.\n *\n * @example\n * const budgetMiddleware = budget({ maxTokens: 50_000 });\n *\n * const myAgent = agent({\n * model,\n * middleware: [budgetMiddleware],\n * });\n *\n * @example\n * // With USD cap and custom pricing\n * const guard = budget({\n * maxCostUSD: 0.5,\n * pricing: {\n * \"gpt-4o\": { inputPer1K: 0.005, outputPer1K: 0.015 },\n * },\n * });\n *\n * @example\n * // SLO contract — soft-fallback on any breach\n * const sloGuard = budget({\n * pricing: { \"gpt-4o\": { inputPer1K: 0.005, outputPer1K: 0.015 } },\n * contract: {\n * maxCostUSD: 0.05,\n * maxLatencyMs: 8_000,\n * maxTokens: 40_000,\n * onViolation: \"fallback\",\n * fallback: (violation) => routeToCheaperModel(violation.dimension),\n * },\n * });\n */\nexport function budget(options: BudgetOptions): AgentMiddleware {\n const name = options.name ?? \"budget\";\n const onExceeded = options.onExceeded ?? \"abort\";\n const hasTokenCap = typeof options.maxTokens === \"number\";\n const hasCostCap = typeof options.maxCostUSD === \"number\";\n\n const contract = options.contract;\n const contractMode = contract?.onViolation ?? \"abort\";\n const hasContractTokenCap = typeof contract?.maxTokens === \"number\";\n const hasContractCostCap = typeof contract?.maxCostUSD === \"number\";\n const hasContractLatencyCap = typeof contract?.maxLatencyMs === \"number\";\n const contractNeedsCost = hasCostCap || hasContractCostCap;\n\n return {\n name,\n execute: {\n before(context) {\n const counters = namespacedState<BudgetCounters>(context, name);\n counters.set({\n tokens: 0,\n costUSD: 0,\n warned: false,\n startedAt: Date.now(),\n fallbackFired: false,\n });\n },\n },\n trip: {\n async after(context, response) {\n const counters = namespacedState<BudgetCounters>(context, name).get();\n\n if (!counters) {\n return;\n }\n\n counters.tokens += response.usage.total;\n\n if (contractNeedsCost && options.pricing) {\n const pricing = options.pricing[context.model.name];\n\n if (pricing) {\n const tripCost =\n (response.usage.input / 1000) * pricing.inputPer1K +\n (response.usage.output / 1000) * pricing.outputPer1K;\n counters.costUSD += tripCost;\n }\n }\n\n if (hasTokenCap && counters.tokens > options.maxTokens!) {\n if (onExceeded === \"abort\") {\n breach(options.maxTokens!, counters.tokens, \"tokens\", name);\n }\n\n if (!counters.warned) {\n counters.warned = true;\n }\n }\n\n if (hasCostCap && counters.costUSD > options.maxCostUSD!) {\n if (onExceeded === \"abort\") {\n breach(options.maxCostUSD!, counters.costUSD, \"usd\", name);\n }\n\n if (!counters.warned) {\n counters.warned = true;\n }\n }\n\n if (!contract) {\n return;\n }\n\n if (hasContractTokenCap && counters.tokens > contract.maxTokens!) {\n await enforceContract(\n context,\n counters,\n name,\n contractMode,\n contract,\n \"tokens\",\n contract.maxTokens!,\n counters.tokens,\n );\n }\n\n if (hasContractCostCap && counters.costUSD > contract.maxCostUSD!) {\n await enforceContract(\n context,\n counters,\n name,\n contractMode,\n contract,\n \"cost\",\n contract.maxCostUSD!,\n counters.costUSD,\n );\n }\n\n if (hasContractLatencyCap) {\n const elapsedMs = Date.now() - counters.startedAt;\n\n if (elapsedMs > contract.maxLatencyMs!) {\n await enforceContract(\n context,\n counters,\n name,\n contractMode,\n contract,\n \"latency\",\n contract.maxLatencyMs!,\n elapsedMs,\n );\n }\n }\n },\n },\n };\n}\n\n/**\n * Apply the contract's reaction to a single breached clause. `\"abort\"`\n * throws `BudgetExceededError` (stops the run); `\"fallback\"` records the\n * signal once, fires the callback, and returns so the run continues.\n *\n * The callback is invoked at most once per run (guarded by\n * `counters.fallbackFired`) and its rejections are swallowed — a buggy\n * fallback hook must never crash the agent.\n */\nasync function enforceContract(\n context: MiddlewareExecuteContext,\n counters: BudgetCounters,\n name: string,\n mode: NonNullable<BudgetContract[\"onViolation\"]>,\n contract: BudgetContract,\n dimension: BudgetContractDimension,\n limit: number,\n actual: number,\n): Promise<void> {\n if (mode === \"abort\") {\n breachContract(name, dimension, limit, actual);\n }\n\n if (counters.fallbackFired) {\n return;\n }\n\n counters.fallbackFired = true;\n\n const violation: BudgetContractViolation = {\n dimension,\n limit,\n actual,\n mode,\n };\n\n namespacedState<BudgetContractViolation>(context, `${name}.fallback`).set(\n violation,\n );\n\n if (!contract.fallback) {\n return;\n }\n\n try {\n await contract.fallback(violation, context);\n } catch {\n // A fallback callback is a notification hook — its failure must\n // never crash the run. Swallow deliberately.\n }\n}\n"],"mappings":";;;;;;;;;;;AAsHA,MAAM,iBAA8D;CAClE,QAAQ;CACR,MAAM;CACN,SAAS;AACX;AAEA,SAAS,OACP,OACA,QACA,MACA,MACO;CACP,MAAM,IAAI,oBACR,WAAW,KAAK,eAAe,OAAO,GAAG,KAAK,SAAS,MAAM,IAC7D;EAAE;EAAO;EAAQ;CAAK,CACxB;AACF;AAEA,SAAS,eACP,MACA,WACA,OACA,QACO;CACP,MAAM,IAAI,oBACR,WAAW,KAAK,wBAAwB,UAAU,GAAG,OAAO,SAAS,MAAM,IAC3E;EACE;EACA;EACA,MAAM,eAAe;EACrB,SAAS;GAAE;GAAW;GAAO;GAAQ,QAAQ;EAAW;CAC1D,CACF;AACF;;;;;;;;;;;;;;;;;;;;;;;;;;AA2BA,SAAgB,yBACd,OACA,OAAO,UAC2B;CAClC,OAAO,gBACL,EAAE,MAAM,GACR,GAAG,KAAK,UACV,CAAC,CAAC,IAAI;AACR;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyEA,SAAgB,OAAO,SAAyC;CAC9D,MAAM,OAAO,QAAQ,QAAQ;CAC7B,MAAM,aAAa,QAAQ,cAAc;CACzC,MAAM,cAAc,OAAO,QAAQ,cAAc;CACjD,MAAM,aAAa,OAAO,QAAQ,eAAe;CAEjD,MAAM,WAAW,QAAQ;CACzB,MAAM,eAAe,UAAU,eAAe;CAC9C,MAAM,sBAAsB,OAAO,UAAU,cAAc;CAC3D,MAAM,qBAAqB,OAAO,UAAU,eAAe;CAC3D,MAAM,wBAAwB,OAAO,UAAU,iBAAiB;CAChE,MAAM,oBAAoB,cAAc;CAExC,OAAO;EACL;EACA,SAAS,EACP,OAAO,SAAS;GAEd,AADiB,gBAAgC,SAAS,IACnD,CAAC,CAAC,IAAI;IACX,QAAQ;IACR,SAAS;IACT,QAAQ;IACR,WAAW,KAAK,IAAI;IACpB,eAAe;GACjB,CAAC;EACH,EACF;EACA,MAAM,EACJ,MAAM,MAAM,SAAS,UAAU;GAC7B,MAAM,WAAW,gBAAgC,SAAS,IAAI,CAAC,CAAC,IAAI;GAEpE,IAAI,CAAC,UACH;GAGF,SAAS,UAAU,SAAS,MAAM;GAElC,IAAI,qBAAqB,QAAQ,SAAS;IACxC,MAAM,UAAU,QAAQ,QAAQ,QAAQ,MAAM;IAE9C,IAAI,SAAS;KACX,MAAM,WACH,SAAS,MAAM,QAAQ,MAAQ,QAAQ,aACvC,SAAS,MAAM,SAAS,MAAQ,QAAQ;KAC3C,SAAS,WAAW;IACtB;GACF;GAEA,IAAI,eAAe,SAAS,SAAS,QAAQ,WAAY;IACvD,IAAI,eAAe,SACjB,OAAO,QAAQ,WAAY,SAAS,QAAQ,UAAU,IAAI;IAG5D,IAAI,CAAC,SAAS,QACZ,SAAS,SAAS;GAEtB;GAEA,IAAI,cAAc,SAAS,UAAU,QAAQ,YAAa;IACxD,IAAI,eAAe,SACjB,OAAO,QAAQ,YAAa,SAAS,SAAS,OAAO,IAAI;IAG3D,IAAI,CAAC,SAAS,QACZ,SAAS,SAAS;GAEtB;GAEA,IAAI,CAAC,UACH;GAGF,IAAI,uBAAuB,SAAS,SAAS,SAAS,WACpD,MAAM,gBACJ,SACA,UACA,MACA,cACA,UACA,UACA,SAAS,WACT,SAAS,MACX;GAGF,IAAI,sBAAsB,SAAS,UAAU,SAAS,YACpD,MAAM,gBACJ,SACA,UACA,MACA,cACA,UACA,QACA,SAAS,YACT,SAAS,OACX;GAGF,IAAI,uBAAuB;IACzB,MAAM,YAAY,KAAK,IAAI,IAAI,SAAS;IAExC,IAAI,YAAY,SAAS,cACvB,MAAM,gBACJ,SACA,UACA,MACA,cACA,UACA,WACA,SAAS,cACT,SACF;GAEJ;EACF,EACF;CACF;AACF;;;;;;;;;;AAWA,eAAe,gBACb,SACA,UACA,MACA,MACA,UACA,WACA,OACA,QACe;CACf,IAAI,SAAS,SACX,eAAe,MAAM,WAAW,OAAO,MAAM;CAG/C,IAAI,SAAS,eACX;CAGF,SAAS,gBAAgB;CAEzB,MAAM,YAAqC;EACzC;EACA;EACA;EACA;CACF;CAEA,gBAAyC,SAAS,GAAG,KAAK,UAAU,CAAC,CAAC,IACpE,SACF;CAEA,IAAI,CAAC,SAAS,UACZ;CAGF,IAAI;EACF,MAAM,SAAS,SAAS,WAAW,OAAO;CAC5C,QAAQ,CAGR;AACF"}
|
|
1
|
+
{"version":3,"file":"budget.mjs","names":[],"sources":["../../../../../../../../@warlock.js/ai/src/middleware/builtins/budget.ts"],"sourcesContent":["import type {\n AgentMiddleware,\n MiddlewareExecuteContext,\n} from \"../../contracts/middleware\";\nimport { BudgetExceededError, type BudgetUnit } from \"../../errors\";\nimport { namespacedState } from \"../utils\";\nimport type {\n BudgetContract,\n BudgetContractDimension,\n BudgetContractViolation,\n} from \"./budget-contract.type\";\n\nexport type {\n BudgetContract,\n BudgetContractDimension,\n BudgetContractFallback,\n BudgetContractViolation,\n BudgetContractViolationMode,\n} from \"./budget-contract.type\";\n\n/**\n * Per-model pricing used to compute USD cost from token counts.\n * Caller-supplied — no bundled table. Keys are model names (the\n * `ModelContract.name` value); values are input / output token\n * prices expressed as **USD per 1K tokens** to match every major\n * provider's published pricing sheet.\n */\nexport type BudgetPricing = Record<\n string,\n {\n /** USD per 1,000 input tokens. */\n inputPer1K: number;\n /** USD per 1,000 output tokens. */\n outputPer1K: number;\n }\n>;\n\n/**\n * Configuration for `budget()`. At least one of `maxTokens` or\n * `maxCostUSD` must be supplied — a budget with no cap is a no-op.\n */\nexport type BudgetOptions = {\n /**\n * Hard cap on cumulative total tokens (input + output, summed\n * across every trip of the run). Inclusive — exceeding triggers\n * the configured `onExceeded`.\n */\n maxTokens?: number;\n /**\n * Hard cap on cumulative USD cost. Requires `pricing` for the\n * agent's configured model — without a pricing entry the USD check\n * silently skips (tokens-only enforcement still applies).\n */\n maxCostUSD?: number;\n /**\n * Per-model pricing table used to compute USD cost. Only consulted\n * when `maxCostUSD` is set. Model names must match the running\n * agent's `ModelContract.name` exactly.\n */\n pricing?: BudgetPricing;\n /**\n * Behavior when a cap is breached. `\"abort\"` throws\n * `BudgetExceededError` — surfaces on `result.error`, stops the\n * run at the next trip boundary. `\"warn\"` logs a warning and\n * lets the run continue (useful for observability-first rollouts\n * before flipping the switch to abort). Default `\"abort\"`.\n */\n onExceeded?: \"abort\" | \"warn\";\n /**\n * Override the middleware name. Useful when two budgets coexist\n * (e.g. a per-request cap plus a session-wide cap via different\n * instances). Default `\"budget\"`.\n */\n name?: string;\n /**\n * Declarative SLO / cost contract enforced on top of (and\n * independently of) the legacy `maxTokens` / `maxCostUSD` caps.\n * Adds a wall-clock `maxLatencyMs` dimension and a per-contract\n * `onViolation` reaction (`\"abort\"` hard-stops, `\"fallback\"` records\n * a signal + fires `fallback` and lets the run continue). Omit to\n * keep the classic budget behavior unchanged.\n *\n * Read a recorded fallback signal back with\n * {@link readBudgetFallbackSignal}.\n */\n contract?: BudgetContract;\n};\n\ntype BudgetCounters = {\n tokens: number;\n costUSD: number;\n warned: boolean;\n /**\n * Wall-clock epoch ms captured at `execute.before`. Used to derive\n * cumulative run latency for the contract's `maxLatencyMs` clause.\n */\n startedAt: number;\n /**\n * Set once a `\"fallback\"` contract clause has fired, so the signal +\n * callback are emitted at most once per run even if later trips keep\n * breaching.\n */\n fallbackFired: boolean;\n};\n\n/**\n * Recorded contract fallback signal, stashed under the `<name>.fallback`\n * state key when a `\"fallback\"` clause trips. A fallback orchestrator\n * reads it via {@link readBudgetFallbackSignal} to decide how to degrade.\n */\nexport type BudgetFallbackSignal = BudgetContractViolation;\n\n/**\n * The `BudgetUnit` to stamp on the thrown error per contract dimension.\n * Latency has no native unit — it borrows `\"requests\"` as the least-wrong\n * operational measure, while the authoritative detail rides on the\n * error's `context.dimension`.\n */\nconst DIMENSION_UNIT: Record<BudgetContractDimension, BudgetUnit> = {\n tokens: \"tokens\",\n cost: \"usd\",\n latency: \"requests\",\n};\n\nfunction breach(\n limit: number,\n actual: number,\n unit: BudgetUnit,\n name: string,\n): never {\n throw new BudgetExceededError(\n `budget \"${name}\" exceeded — ${actual} ${unit} (cap: ${limit})`,\n { limit, actual, unit },\n );\n}\n\nfunction breachContract(\n name: string,\n dimension: BudgetContractDimension,\n limit: number,\n actual: number,\n): never {\n throw new BudgetExceededError(\n `budget \"${name}\" contract exceeded — ${dimension} ${actual} (cap: ${limit})`,\n {\n limit,\n actual,\n unit: DIMENSION_UNIT[dimension],\n context: { dimension, limit, actual, source: \"contract\" },\n },\n );\n}\n\n/**\n * Read the contract fallback signal recorded by a `budget()` middleware\n * running under `contract.onViolation: \"fallback\"`. Returns `undefined`\n * when no clause was breached.\n *\n * **Role.** The middleware cannot itself switch models on a soft breach,\n * so it records a typed {@link BudgetFallbackSignal} in the shared state\n * bag and lets the run continue. A fallback orchestrator (or the\n * `execute.after` hook of an outer middleware) reads it back here and\n * decides how to degrade the next run — cheaper model, cached answer,\n * truncated context.\n *\n * @param state - The middleware state bag (`ctx.state`).\n * @param name - The budget middleware's name. Default `\"budget\"`,\n * matching `BudgetOptions.name`'s default.\n *\n * @example\n * const guard = budget({ contract: { maxCostUSD: 0.05, onViolation: \"fallback\" } });\n *\n * // In an outer middleware's execute.after, after the run:\n * const signal = readBudgetFallbackSignal(ctx.state);\n * if (signal?.dimension === \"cost\") {\n * await rerunOnCheaperModel();\n * }\n */\nexport function readBudgetFallbackSignal(\n state: MiddlewareExecuteContext[\"state\"],\n name = \"budget\",\n): BudgetFallbackSignal | undefined {\n return namespacedState<BudgetFallbackSignal>(\n { state },\n `${name}.fallback`,\n ).get();\n}\n\n/**\n * Enforced token and / or USD budget for an agent run.\n *\n * **Role.** Guards against runaway tool loops, misconfigured\n * prompts, and unexpected provider price swings by capping\n * cumulative usage across every LLM trip of a single execution.\n * Aborts the run with a typed `BudgetExceededError` the moment a cap\n * is breached, rather than letting the damage grow trip by trip.\n *\n * **Scope.** Per-execution. A fresh counter is created at\n * `execute.before` and lives in the middleware state bag until the\n * run ends. Two concurrent `agent.execute()` calls on the same\n * agent therefore enforce the cap independently.\n *\n * **Token accounting.** After each successful trip, the middleware\n * adds `response.usage.total` to its running total and checks\n * against `maxTokens`. Synthetic trips (cache hits) contribute\n * `usage.total` as returned by the cache — cache middleware is\n * expected to surface zero usage on a hit, which naturally excludes\n * those trips from the budget.\n *\n * **USD accounting.** When `maxCostUSD` + `pricing[modelName]` are\n * both present, the middleware converts per-trip input / output\n * tokens to USD and accumulates. Missing pricing silently degrades\n * to tokens-only — explicit rather than guessing.\n *\n * **Warn mode.** `onExceeded: \"warn\"` logs a single warning the first\n * time a cap is breached and lets the run continue. Useful for\n * measuring real-world traffic against a proposed cap before flipping\n * to `\"abort\"` in production.\n *\n * **Contract / SLO mode.** Pass `contract` to enforce a declarative\n * service-level objective — `maxCostUSD`, `maxLatencyMs`, `maxTokens` —\n * on top of the legacy caps, with a single `onViolation` reaction:\n * `\"abort\"` hard-stops with `BudgetExceededError`; `\"fallback\"` records\n * a typed signal (read it via {@link readBudgetFallbackSignal}), fires\n * the optional `fallback` callback, and lets the run continue so an\n * outer layer can degrade gracefully. The contract's clauses are\n * evaluated independently of — and after — the top-level caps; the\n * top-level caps stay fully functional with or without a contract.\n *\n * @example\n * const budgetMiddleware = budget({ maxTokens: 50_000 });\n *\n * const myAgent = agent({\n * model,\n * middleware: [budgetMiddleware],\n * });\n *\n * @example\n * // With USD cap and custom pricing\n * const guard = budget({\n * maxCostUSD: 0.5,\n * pricing: {\n * \"gpt-4o\": { inputPer1K: 0.005, outputPer1K: 0.015 },\n * },\n * });\n *\n * @example\n * // SLO contract — soft-fallback on any breach\n * const sloGuard = budget({\n * pricing: { \"gpt-4o\": { inputPer1K: 0.005, outputPer1K: 0.015 } },\n * contract: {\n * maxCostUSD: 0.05,\n * maxLatencyMs: 8_000,\n * maxTokens: 40_000,\n * onViolation: \"fallback\",\n * fallback: (violation) => routeToCheaperModel(violation.dimension),\n * },\n * });\n */\nexport function budget(options: BudgetOptions): AgentMiddleware {\n const name = options.name ?? \"budget\";\n const onExceeded = options.onExceeded ?? \"abort\";\n const hasTokenCap = typeof options.maxTokens === \"number\";\n const hasCostCap = typeof options.maxCostUSD === \"number\";\n\n const contract = options.contract;\n const contractMode = contract?.onViolation ?? \"abort\";\n const hasContractTokenCap = typeof contract?.maxTokens === \"number\";\n const hasContractCostCap = typeof contract?.maxCostUSD === \"number\";\n const hasContractLatencyCap = typeof contract?.maxLatencyMs === \"number\";\n const contractNeedsCost = hasCostCap || hasContractCostCap;\n // Warn once per model when a cost cap is configured but the running model\n // has no pricing entry — without this the USD cap silently never enforces\n // (costUSD stays 0), a fail-open the JSDoc on `maxCostUSD` documents.\n const warnedUnpricedModels = new Set<string>();\n\n return {\n name,\n execute: {\n before(context) {\n const counters = namespacedState<BudgetCounters>(context, name);\n counters.set({\n tokens: 0,\n costUSD: 0,\n warned: false,\n startedAt: Date.now(),\n fallbackFired: false,\n });\n },\n },\n trip: {\n async after(context, response) {\n const counters = namespacedState<BudgetCounters>(context, name).get();\n\n if (!counters) {\n return;\n }\n\n counters.tokens += response.usage.total;\n\n if (contractNeedsCost) {\n const pricing = options.pricing?.[context.model.name];\n\n if (pricing) {\n const tripCost =\n (response.usage.input / 1000) * pricing.inputPer1K +\n (response.usage.output / 1000) * pricing.outputPer1K;\n counters.costUSD += tripCost;\n } else if (!warnedUnpricedModels.has(context.model.name)) {\n // A cost cap is set but no pricing matched the running model, so\n // costUSD can never grow and the USD cap silently never fires.\n // Surface the fail-open once per model instead of swallowing it.\n warnedUnpricedModels.add(context.model.name);\n console.warn(\n `ai.middleware.budget(\"${name}\"): a USD cost cap is set but no pricing entry ` +\n `matches the running model \"${context.model.name}\" — the cap cannot be enforced ` +\n `for it. Add a pricing entry for \"${context.model.name}\" to options.pricing.`,\n );\n }\n }\n\n if (hasTokenCap && counters.tokens > options.maxTokens!) {\n if (onExceeded === \"abort\") {\n breach(options.maxTokens!, counters.tokens, \"tokens\", name);\n }\n\n if (!counters.warned) {\n counters.warned = true;\n }\n }\n\n if (hasCostCap && counters.costUSD > options.maxCostUSD!) {\n if (onExceeded === \"abort\") {\n breach(options.maxCostUSD!, counters.costUSD, \"usd\", name);\n }\n\n if (!counters.warned) {\n counters.warned = true;\n }\n }\n\n if (!contract) {\n return;\n }\n\n if (hasContractTokenCap && counters.tokens > contract.maxTokens!) {\n await enforceContract(\n context,\n counters,\n name,\n contractMode,\n contract,\n \"tokens\",\n contract.maxTokens!,\n counters.tokens,\n );\n }\n\n if (hasContractCostCap && counters.costUSD > contract.maxCostUSD!) {\n await enforceContract(\n context,\n counters,\n name,\n contractMode,\n contract,\n \"cost\",\n contract.maxCostUSD!,\n counters.costUSD,\n );\n }\n\n if (hasContractLatencyCap) {\n const elapsedMs = Date.now() - counters.startedAt;\n\n if (elapsedMs > contract.maxLatencyMs!) {\n await enforceContract(\n context,\n counters,\n name,\n contractMode,\n contract,\n \"latency\",\n contract.maxLatencyMs!,\n elapsedMs,\n );\n }\n }\n },\n },\n };\n}\n\n/**\n * Apply the contract's reaction to a single breached clause. `\"abort\"`\n * throws `BudgetExceededError` (stops the run); `\"fallback\"` records the\n * signal once, fires the callback, and returns so the run continues.\n *\n * The callback is invoked at most once per run (guarded by\n * `counters.fallbackFired`) and its rejections are swallowed — a buggy\n * fallback hook must never crash the agent.\n */\nasync function enforceContract(\n context: MiddlewareExecuteContext,\n counters: BudgetCounters,\n name: string,\n mode: NonNullable<BudgetContract[\"onViolation\"]>,\n contract: BudgetContract,\n dimension: BudgetContractDimension,\n limit: number,\n actual: number,\n): Promise<void> {\n if (mode === \"abort\") {\n breachContract(name, dimension, limit, actual);\n }\n\n if (counters.fallbackFired) {\n return;\n }\n\n counters.fallbackFired = true;\n\n const violation: BudgetContractViolation = {\n dimension,\n limit,\n actual,\n mode,\n };\n\n namespacedState<BudgetContractViolation>(context, `${name}.fallback`).set(\n violation,\n );\n\n if (!contract.fallback) {\n return;\n }\n\n try {\n await contract.fallback(violation, context);\n } catch {\n // A fallback callback is a notification hook — its failure must\n // never crash the run. Swallow deliberately.\n }\n}\n"],"mappings":";;;;;;;;;;;AAsHA,MAAM,iBAA8D;CAClE,QAAQ;CACR,MAAM;CACN,SAAS;AACX;AAEA,SAAS,OACP,OACA,QACA,MACA,MACO;CACP,MAAM,IAAI,oBACR,WAAW,KAAK,eAAe,OAAO,GAAG,KAAK,SAAS,MAAM,IAC7D;EAAE;EAAO;EAAQ;CAAK,CACxB;AACF;AAEA,SAAS,eACP,MACA,WACA,OACA,QACO;CACP,MAAM,IAAI,oBACR,WAAW,KAAK,wBAAwB,UAAU,GAAG,OAAO,SAAS,MAAM,IAC3E;EACE;EACA;EACA,MAAM,eAAe;EACrB,SAAS;GAAE;GAAW;GAAO;GAAQ,QAAQ;EAAW;CAC1D,CACF;AACF;;;;;;;;;;;;;;;;;;;;;;;;;;AA2BA,SAAgB,yBACd,OACA,OAAO,UAC2B;CAClC,OAAO,gBACL,EAAE,MAAM,GACR,GAAG,KAAK,UACV,CAAC,CAAC,IAAI;AACR;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyEA,SAAgB,OAAO,SAAyC;CAC9D,MAAM,OAAO,QAAQ,QAAQ;CAC7B,MAAM,aAAa,QAAQ,cAAc;CACzC,MAAM,cAAc,OAAO,QAAQ,cAAc;CACjD,MAAM,aAAa,OAAO,QAAQ,eAAe;CAEjD,MAAM,WAAW,QAAQ;CACzB,MAAM,eAAe,UAAU,eAAe;CAC9C,MAAM,sBAAsB,OAAO,UAAU,cAAc;CAC3D,MAAM,qBAAqB,OAAO,UAAU,eAAe;CAC3D,MAAM,wBAAwB,OAAO,UAAU,iBAAiB;CAChE,MAAM,oBAAoB,cAAc;CAIxC,MAAM,uCAAuB,IAAI,IAAY;CAE7C,OAAO;EACL;EACA,SAAS,EACP,OAAO,SAAS;GAEd,AADiB,gBAAgC,SAAS,IACnD,CAAC,CAAC,IAAI;IACX,QAAQ;IACR,SAAS;IACT,QAAQ;IACR,WAAW,KAAK,IAAI;IACpB,eAAe;GACjB,CAAC;EACH,EACF;EACA,MAAM,EACJ,MAAM,MAAM,SAAS,UAAU;GAC7B,MAAM,WAAW,gBAAgC,SAAS,IAAI,CAAC,CAAC,IAAI;GAEpE,IAAI,CAAC,UACH;GAGF,SAAS,UAAU,SAAS,MAAM;GAElC,IAAI,mBAAmB;IACrB,MAAM,UAAU,QAAQ,UAAU,QAAQ,MAAM;IAEhD,IAAI,SAAS;KACX,MAAM,WACH,SAAS,MAAM,QAAQ,MAAQ,QAAQ,aACvC,SAAS,MAAM,SAAS,MAAQ,QAAQ;KAC3C,SAAS,WAAW;IACtB,OAAO,IAAI,CAAC,qBAAqB,IAAI,QAAQ,MAAM,IAAI,GAAG;KAIxD,qBAAqB,IAAI,QAAQ,MAAM,IAAI;KAC3C,QAAQ,KACN,yBAAyB,KAAK,4EACE,QAAQ,MAAM,KAAK,kEACb,QAAQ,MAAM,KAAK,sBAC3D;IACF;GACF;GAEA,IAAI,eAAe,SAAS,SAAS,QAAQ,WAAY;IACvD,IAAI,eAAe,SACjB,OAAO,QAAQ,WAAY,SAAS,QAAQ,UAAU,IAAI;IAG5D,IAAI,CAAC,SAAS,QACZ,SAAS,SAAS;GAEtB;GAEA,IAAI,cAAc,SAAS,UAAU,QAAQ,YAAa;IACxD,IAAI,eAAe,SACjB,OAAO,QAAQ,YAAa,SAAS,SAAS,OAAO,IAAI;IAG3D,IAAI,CAAC,SAAS,QACZ,SAAS,SAAS;GAEtB;GAEA,IAAI,CAAC,UACH;GAGF,IAAI,uBAAuB,SAAS,SAAS,SAAS,WACpD,MAAM,gBACJ,SACA,UACA,MACA,cACA,UACA,UACA,SAAS,WACT,SAAS,MACX;GAGF,IAAI,sBAAsB,SAAS,UAAU,SAAS,YACpD,MAAM,gBACJ,SACA,UACA,MACA,cACA,UACA,QACA,SAAS,YACT,SAAS,OACX;GAGF,IAAI,uBAAuB;IACzB,MAAM,YAAY,KAAK,IAAI,IAAI,SAAS;IAExC,IAAI,YAAY,SAAS,cACvB,MAAM,gBACJ,SACA,UACA,MACA,cACA,UACA,WACA,SAAS,cACT,SACF;GAEJ;EACF,EACF;CACF;AACF;;;;;;;;;;AAWA,eAAe,gBACb,SACA,UACA,MACA,MACA,UACA,WACA,OACA,QACe;CACf,IAAI,SAAS,SACX,eAAe,MAAM,WAAW,OAAO,MAAM;CAG/C,IAAI,SAAS,eACX;CAGF,SAAS,gBAAgB;CAEzB,MAAM,YAAqC;EACzC;EACA;EACA;EACA;CACF;CAEA,gBAAyC,SAAS,GAAG,KAAK,UAAU,CAAC,CAAC,IACpE,SACF;CAEA,IAAI,CAAC,SAAS,UACZ;CAGF,IAAI;EACF,MAAM,SAAS,SAAS,WAAW,OAAO;CAC5C,QAAQ,CAGR;AACF"}
|