@warlock.js/ai 4.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +72 -0
- package/cjs/index.cjs +8625 -0
- package/cjs/index.cjs.map +1 -0
- package/esm/agent/agent-config.type.d.mts +160 -0
- package/esm/agent/agent-config.type.d.mts.map +1 -0
- package/esm/agent/agent-input-builder.mjs +111 -0
- package/esm/agent/agent-input-builder.mjs.map +1 -0
- package/esm/agent/agent-log-event.mjs +101 -0
- package/esm/agent/agent-log-event.mjs.map +1 -0
- package/esm/agent/agent-stream.d.mts +47 -0
- package/esm/agent/agent-stream.d.mts.map +1 -0
- package/esm/agent/agent-stream.mjs +82 -0
- package/esm/agent/agent-stream.mjs.map +1 -0
- package/esm/agent/agent-to-stream-event.mjs +86 -0
- package/esm/agent/agent-to-stream-event.mjs.map +1 -0
- package/esm/agent/agent.d.mts +38 -0
- package/esm/agent/agent.d.mts.map +1 -0
- package/esm/agent/agent.mjs +974 -0
- package/esm/agent/agent.mjs.map +1 -0
- package/esm/agent/index.d.mts +3 -0
- package/esm/agent/index.mjs +4 -0
- package/esm/agent/json-stream-guard.mjs +400 -0
- package/esm/agent/json-stream-guard.mjs.map +1 -0
- package/esm/ai.d.mts +64 -0
- package/esm/ai.d.mts.map +1 -0
- package/esm/ai.mjs +65 -0
- package/esm/ai.mjs.map +1 -0
- package/esm/config.d.mts +79 -0
- package/esm/config.d.mts.map +1 -0
- package/esm/config.mjs +43 -0
- package/esm/config.mjs.map +1 -0
- package/esm/contracts/agent/agent-options.type.d.mts +132 -0
- package/esm/contracts/agent/agent-options.type.d.mts.map +1 -0
- package/esm/contracts/agent/agent.contract.d.mts +92 -0
- package/esm/contracts/agent/agent.contract.d.mts.map +1 -0
- package/esm/contracts/agent/index.d.mts +2 -0
- package/esm/contracts/attachment.type.d.mts +100 -0
- package/esm/contracts/attachment.type.d.mts.map +1 -0
- package/esm/contracts/content-part.type.d.mts +55 -0
- package/esm/contracts/content-part.type.d.mts.map +1 -0
- package/esm/contracts/conversation-message.type.d.mts +51 -0
- package/esm/contracts/conversation-message.type.d.mts.map +1 -0
- package/esm/contracts/embedder.contract.d.mts +69 -0
- package/esm/contracts/embedder.contract.d.mts.map +1 -0
- package/esm/contracts/end.type.d.mts +53 -0
- package/esm/contracts/end.type.d.mts.map +1 -0
- package/esm/contracts/end.type.mjs +47 -0
- package/esm/contracts/end.type.mjs.map +1 -0
- package/esm/contracts/events/agent-events.type.d.mts +71 -0
- package/esm/contracts/events/agent-events.type.d.mts.map +1 -0
- package/esm/contracts/events/complete-event.type.d.mts +33 -0
- package/esm/contracts/events/complete-event.type.d.mts.map +1 -0
- package/esm/contracts/events/event-identity.type.d.mts +30 -0
- package/esm/contracts/events/event-identity.type.d.mts.map +1 -0
- package/esm/contracts/events/event-map.type.d.mts +80 -0
- package/esm/contracts/events/event-map.type.d.mts.map +1 -0
- package/esm/contracts/events/index.d.mts +7 -0
- package/esm/contracts/events/supervisor-events.type.d.mts +162 -0
- package/esm/contracts/events/supervisor-events.type.d.mts.map +1 -0
- package/esm/contracts/events/usage-event.type.d.mts +39 -0
- package/esm/contracts/events/usage-event.type.d.mts.map +1 -0
- package/esm/contracts/events/workflow-events.type.d.mts +51 -0
- package/esm/contracts/events/workflow-events.type.d.mts.map +1 -0
- package/esm/contracts/executable.contract.d.mts +25 -0
- package/esm/contracts/executable.contract.d.mts.map +1 -0
- package/esm/contracts/finish-reason.type.d.mts +17 -0
- package/esm/contracts/finish-reason.type.d.mts.map +1 -0
- package/esm/contracts/index.d.mts +63 -0
- package/esm/contracts/middleware/index.d.mts +3 -0
- package/esm/contracts/middleware/middleware-context.type.d.mts +99 -0
- package/esm/contracts/middleware/middleware-context.type.d.mts.map +1 -0
- package/esm/contracts/middleware/middleware-state.type.d.mts +34 -0
- package/esm/contracts/middleware/middleware-state.type.d.mts.map +1 -0
- package/esm/contracts/middleware/middleware.contract.d.mts +140 -0
- package/esm/contracts/middleware/middleware.contract.d.mts.map +1 -0
- package/esm/contracts/model-tool-call-request.type.d.mts +58 -0
- package/esm/contracts/model-tool-call-request.type.d.mts.map +1 -0
- package/esm/contracts/model.contract.d.mts +164 -0
- package/esm/contracts/model.contract.d.mts.map +1 -0
- package/esm/contracts/placeholders.type.d.mts +23 -0
- package/esm/contracts/placeholders.type.d.mts.map +1 -0
- package/esm/contracts/result/agent-result.type.d.mts +33 -0
- package/esm/contracts/result/agent-result.type.d.mts.map +1 -0
- package/esm/contracts/result/attempt-entry.type.d.mts +40 -0
- package/esm/contracts/result/attempt-entry.type.d.mts.map +1 -0
- package/esm/contracts/result/base-report.type.d.mts +137 -0
- package/esm/contracts/result/base-report.type.d.mts.map +1 -0
- package/esm/contracts/result/base-report.type.mjs +17 -0
- package/esm/contracts/result/base-report.type.mjs.map +1 -0
- package/esm/contracts/result/base-result.type.d.mts +26 -0
- package/esm/contracts/result/base-result.type.d.mts.map +1 -0
- package/esm/contracts/result/execute-result.type.d.mts +40 -0
- package/esm/contracts/result/execute-result.type.d.mts.map +1 -0
- package/esm/contracts/result/execution-report.type.d.mts +50 -0
- package/esm/contracts/result/execution-report.type.d.mts.map +1 -0
- package/esm/contracts/result/index.d.mts +14 -0
- package/esm/contracts/result/llm-trip.type.d.mts +36 -0
- package/esm/contracts/result/llm-trip.type.d.mts.map +1 -0
- package/esm/contracts/result/model-pricing.type.d.mts +51 -0
- package/esm/contracts/result/model-pricing.type.d.mts.map +1 -0
- package/esm/contracts/result/session-send-result.type.d.mts +29 -0
- package/esm/contracts/result/session-send-result.type.d.mts.map +1 -0
- package/esm/contracts/result/step-result.type.d.mts +43 -0
- package/esm/contracts/result/step-result.type.d.mts.map +1 -0
- package/esm/contracts/result/supervisor-result.type.d.mts +86 -0
- package/esm/contracts/result/supervisor-result.type.d.mts.map +1 -0
- package/esm/contracts/result/tool-call.type.d.mts +44 -0
- package/esm/contracts/result/tool-call.type.d.mts.map +1 -0
- package/esm/contracts/result/usage.type.d.mts +57 -0
- package/esm/contracts/result/usage.type.d.mts.map +1 -0
- package/esm/contracts/result/workflow-result.type.d.mts +45 -0
- package/esm/contracts/result/workflow-result.type.d.mts.map +1 -0
- package/esm/contracts/sdk-adapter.contract.d.mts +77 -0
- package/esm/contracts/sdk-adapter.contract.d.mts.map +1 -0
- package/esm/contracts/stream/stream-event.type.d.mts +68 -0
- package/esm/contracts/stream/stream-event.type.d.mts.map +1 -0
- package/esm/contracts/stream/stream.contract.d.mts +61 -0
- package/esm/contracts/stream/stream.contract.d.mts.map +1 -0
- package/esm/contracts/streaming-tool-guard-config.type.d.mts +78 -0
- package/esm/contracts/streaming-tool-guard-config.type.d.mts.map +1 -0
- package/esm/contracts/supervisor/ack-entry.type.d.mts +97 -0
- package/esm/contracts/supervisor/ack-entry.type.d.mts.map +1 -0
- package/esm/contracts/supervisor/classifier-context.type.d.mts +189 -0
- package/esm/contracts/supervisor/classifier-context.type.d.mts.map +1 -0
- package/esm/contracts/supervisor/dispatch-context.type.d.mts +235 -0
- package/esm/contracts/supervisor/dispatch-context.type.d.mts.map +1 -0
- package/esm/contracts/supervisor/evaluate-context.type.d.mts +124 -0
- package/esm/contracts/supervisor/evaluate-context.type.d.mts.map +1 -0
- package/esm/contracts/supervisor/index.d.mts +16 -0
- package/esm/contracts/supervisor/intent-entry.type.d.mts +254 -0
- package/esm/contracts/supervisor/intent-entry.type.d.mts.map +1 -0
- package/esm/contracts/supervisor/iteration-snapshot.type.d.mts +117 -0
- package/esm/contracts/supervisor/iteration-snapshot.type.d.mts.map +1 -0
- package/esm/contracts/supervisor/next.type.d.mts +25 -0
- package/esm/contracts/supervisor/next.type.d.mts.map +1 -0
- package/esm/contracts/supervisor/route-context.type.d.mts +91 -0
- package/esm/contracts/supervisor/route-context.type.d.mts.map +1 -0
- package/esm/contracts/supervisor/router-entry.type.d.mts +67 -0
- package/esm/contracts/supervisor/router-entry.type.d.mts.map +1 -0
- package/esm/contracts/supervisor/supervisor-config.type.d.mts +356 -0
- package/esm/contracts/supervisor/supervisor-config.type.d.mts.map +1 -0
- package/esm/contracts/supervisor/supervisor-execute-options.type.d.mts +90 -0
- package/esm/contracts/supervisor/supervisor-execute-options.type.d.mts.map +1 -0
- package/esm/contracts/supervisor/supervisor-input.type.d.mts +24 -0
- package/esm/contracts/supervisor/supervisor-input.type.d.mts.map +1 -0
- package/esm/contracts/supervisor/supervisor-snapshot.type.d.mts +49 -0
- package/esm/contracts/supervisor/supervisor-snapshot.type.d.mts.map +1 -0
- package/esm/contracts/supervisor/supervisor-stream-event.type.d.mts +16 -0
- package/esm/contracts/supervisor/supervisor-stream-event.type.d.mts.map +1 -0
- package/esm/contracts/supervisor/supervisor.contract.d.mts +126 -0
- package/esm/contracts/supervisor/supervisor.contract.d.mts.map +1 -0
- package/esm/contracts/system-prompt.contract.d.mts +118 -0
- package/esm/contracts/system-prompt.contract.d.mts.map +1 -0
- package/esm/contracts/tool.contract.d.mts +161 -0
- package/esm/contracts/tool.contract.d.mts.map +1 -0
- package/esm/contracts/workflow/index.d.mts +6 -0
- package/esm/contracts/workflow/next-step-result.type.d.mts +17 -0
- package/esm/contracts/workflow/next-step-result.type.d.mts.map +1 -0
- package/esm/contracts/workflow/retry-config.type.d.mts +19 -0
- package/esm/contracts/workflow/retry-config.type.d.mts.map +1 -0
- package/esm/contracts/workflow/step.contract.d.mts +189 -0
- package/esm/contracts/workflow/step.contract.d.mts.map +1 -0
- package/esm/contracts/workflow/workflow-context.type.d.mts +45 -0
- package/esm/contracts/workflow/workflow-context.type.d.mts.map +1 -0
- package/esm/contracts/workflow/workflow-snapshot.type.d.mts +24 -0
- package/esm/contracts/workflow/workflow-snapshot.type.d.mts.map +1 -0
- package/esm/contracts/workflow/workflow.contract.d.mts +142 -0
- package/esm/contracts/workflow/workflow.contract.d.mts.map +1 -0
- package/esm/errors/agent-cancelled-error.d.mts +49 -0
- package/esm/errors/agent-cancelled-error.d.mts.map +1 -0
- package/esm/errors/agent-cancelled-error.mjs +43 -0
- package/esm/errors/agent-cancelled-error.mjs.map +1 -0
- package/esm/errors/agent-execution-error.d.mts +32 -0
- package/esm/errors/agent-execution-error.d.mts.map +1 -0
- package/esm/errors/agent-execution-error.mjs +35 -0
- package/esm/errors/agent-execution-error.mjs.map +1 -0
- package/esm/errors/agent-max-trips-error.d.mts +45 -0
- package/esm/errors/agent-max-trips-error.d.mts.map +1 -0
- package/esm/errors/agent-max-trips-error.mjs +41 -0
- package/esm/errors/agent-max-trips-error.mjs.map +1 -0
- package/esm/errors/ai-error.d.mts +94 -0
- package/esm/errors/ai-error.d.mts.map +1 -0
- package/esm/errors/ai-error.mjs +68 -0
- package/esm/errors/ai-error.mjs.map +1 -0
- package/esm/errors/budget-exceeded-error.d.mts +41 -0
- package/esm/errors/budget-exceeded-error.d.mts.map +1 -0
- package/esm/errors/budget-exceeded-error.mjs +31 -0
- package/esm/errors/budget-exceeded-error.mjs.map +1 -0
- package/esm/errors/content-filter-error.d.mts +33 -0
- package/esm/errors/content-filter-error.d.mts.map +1 -0
- package/esm/errors/content-filter-error.mjs +28 -0
- package/esm/errors/content-filter-error.mjs.map +1 -0
- package/esm/errors/context-length-exceeded-error.d.mts +38 -0
- package/esm/errors/context-length-exceeded-error.d.mts.map +1 -0
- package/esm/errors/context-length-exceeded-error.mjs +31 -0
- package/esm/errors/context-length-exceeded-error.mjs.map +1 -0
- package/esm/errors/error-category.type.d.mts +30 -0
- package/esm/errors/error-category.type.d.mts.map +1 -0
- package/esm/errors/error-code.type.d.mts +19 -0
- package/esm/errors/error-code.type.d.mts.map +1 -0
- package/esm/errors/guardrail-violation-error.d.mts +55 -0
- package/esm/errors/guardrail-violation-error.d.mts.map +1 -0
- package/esm/errors/guardrail-violation-error.mjs +41 -0
- package/esm/errors/guardrail-violation-error.mjs.map +1 -0
- package/esm/errors/index.d.mts +29 -0
- package/esm/errors/index.mjs +29 -0
- package/esm/errors/invalid-request-error.d.mts +27 -0
- package/esm/errors/invalid-request-error.d.mts.map +1 -0
- package/esm/errors/invalid-request-error.mjs +31 -0
- package/esm/errors/invalid-request-error.mjs.map +1 -0
- package/esm/errors/max-iterations-error.d.mts +31 -0
- package/esm/errors/max-iterations-error.d.mts.map +1 -0
- package/esm/errors/max-iterations-error.mjs +32 -0
- package/esm/errors/max-iterations-error.mjs.map +1 -0
- package/esm/errors/max-steps-exceeded-error.d.mts +20 -0
- package/esm/errors/max-steps-exceeded-error.d.mts.map +1 -0
- package/esm/errors/max-steps-exceeded-error.mjs +21 -0
- package/esm/errors/max-steps-exceeded-error.mjs.map +1 -0
- package/esm/errors/provider-auth-error.d.mts +22 -0
- package/esm/errors/provider-auth-error.d.mts.map +1 -0
- package/esm/errors/provider-auth-error.mjs +26 -0
- package/esm/errors/provider-auth-error.mjs.map +1 -0
- package/esm/errors/provider-error.d.mts +38 -0
- package/esm/errors/provider-error.d.mts.map +1 -0
- package/esm/errors/provider-error.mjs +42 -0
- package/esm/errors/provider-error.mjs.map +1 -0
- package/esm/errors/provider-rate-limit-error.d.mts +34 -0
- package/esm/errors/provider-rate-limit-error.d.mts.map +1 -0
- package/esm/errors/provider-rate-limit-error.mjs +31 -0
- package/esm/errors/provider-rate-limit-error.mjs.map +1 -0
- package/esm/errors/provider-timeout-error.d.mts +22 -0
- package/esm/errors/provider-timeout-error.d.mts.map +1 -0
- package/esm/errors/provider-timeout-error.mjs +26 -0
- package/esm/errors/provider-timeout-error.mjs.map +1 -0
- package/esm/errors/quota-exceeded-error.d.mts +36 -0
- package/esm/errors/quota-exceeded-error.d.mts.map +1 -0
- package/esm/errors/quota-exceeded-error.mjs +40 -0
- package/esm/errors/quota-exceeded-error.mjs.map +1 -0
- package/esm/errors/routing-error.d.mts +23 -0
- package/esm/errors/routing-error.d.mts.map +1 -0
- package/esm/errors/routing-error.mjs +23 -0
- package/esm/errors/routing-error.mjs.map +1 -0
- package/esm/errors/schema-validation-error.d.mts +40 -0
- package/esm/errors/schema-validation-error.d.mts.map +1 -0
- package/esm/errors/schema-validation-error.mjs +37 -0
- package/esm/errors/schema-validation-error.mjs.map +1 -0
- package/esm/errors/step-failed-error.d.mts +20 -0
- package/esm/errors/step-failed-error.d.mts.map +1 -0
- package/esm/errors/step-failed-error.mjs +19 -0
- package/esm/errors/step-failed-error.mjs.map +1 -0
- package/esm/errors/supervisor-cancelled-error.d.mts +29 -0
- package/esm/errors/supervisor-cancelled-error.d.mts.map +1 -0
- package/esm/errors/supervisor-cancelled-error.mjs +29 -0
- package/esm/errors/supervisor-cancelled-error.mjs.map +1 -0
- package/esm/errors/supervisor-drift-error.d.mts +31 -0
- package/esm/errors/supervisor-drift-error.d.mts.map +1 -0
- package/esm/errors/supervisor-drift-error.mjs +30 -0
- package/esm/errors/supervisor-drift-error.mjs.map +1 -0
- package/esm/errors/supervisor-failed-error.d.mts +40 -0
- package/esm/errors/supervisor-failed-error.d.mts.map +1 -0
- package/esm/errors/supervisor-failed-error.mjs +43 -0
- package/esm/errors/supervisor-failed-error.mjs.map +1 -0
- package/esm/errors/supervisor-routing-error.d.mts +44 -0
- package/esm/errors/supervisor-routing-error.d.mts.map +1 -0
- package/esm/errors/supervisor-routing-error.mjs +39 -0
- package/esm/errors/supervisor-routing-error.mjs.map +1 -0
- package/esm/errors/tool-execution-error.d.mts +35 -0
- package/esm/errors/tool-execution-error.d.mts.map +1 -0
- package/esm/errors/tool-execution-error.mjs +32 -0
- package/esm/errors/tool-execution-error.mjs.map +1 -0
- package/esm/errors/workflow-cancelled-error.d.mts +23 -0
- package/esm/errors/workflow-cancelled-error.d.mts.map +1 -0
- package/esm/errors/workflow-cancelled-error.mjs +23 -0
- package/esm/errors/workflow-cancelled-error.mjs.map +1 -0
- package/esm/errors/workflow-drift-error.d.mts +25 -0
- package/esm/errors/workflow-drift-error.d.mts.map +1 -0
- package/esm/errors/workflow-drift-error.mjs +24 -0
- package/esm/errors/workflow-drift-error.mjs.map +1 -0
- package/esm/errors/workflow-error.d.mts +15 -0
- package/esm/errors/workflow-error.d.mts.map +1 -0
- package/esm/errors/workflow-error.mjs +18 -0
- package/esm/errors/workflow-error.mjs.map +1 -0
- package/esm/index.d.mts +137 -0
- package/esm/index.mjs +81 -0
- package/esm/middleware/builtins/budget.d.mts +103 -0
- package/esm/middleware/builtins/budget.d.mts.map +1 -0
- package/esm/middleware/builtins/budget.mjs +100 -0
- package/esm/middleware/builtins/budget.mjs.map +1 -0
- package/esm/middleware/builtins/guardrail.d.mts +92 -0
- package/esm/middleware/builtins/guardrail.d.mts.map +1 -0
- package/esm/middleware/builtins/guardrail.mjs +76 -0
- package/esm/middleware/builtins/guardrail.mjs.map +1 -0
- package/esm/middleware/builtins/semantic-cache.d.mts +106 -0
- package/esm/middleware/builtins/semantic-cache.d.mts.map +1 -0
- package/esm/middleware/builtins/semantic-cache.mjs +149 -0
- package/esm/middleware/builtins/semantic-cache.mjs.map +1 -0
- package/esm/middleware/helpers/compose.d.mts +42 -0
- package/esm/middleware/helpers/compose.d.mts.map +1 -0
- package/esm/middleware/helpers/compose.mjs +52 -0
- package/esm/middleware/helpers/compose.mjs.map +1 -0
- package/esm/middleware/helpers/for-tool.d.mts +55 -0
- package/esm/middleware/helpers/for-tool.d.mts.map +1 -0
- package/esm/middleware/helpers/for-tool.mjs +80 -0
- package/esm/middleware/helpers/for-tool.mjs.map +1 -0
- package/esm/middleware/helpers/index.d.mts +2 -0
- package/esm/middleware/index.d.mts +8 -0
- package/esm/middleware/index.mjs +10 -0
- package/esm/middleware/pipeline.d.mts +70 -0
- package/esm/middleware/pipeline.d.mts.map +1 -0
- package/esm/middleware/pipeline.mjs +100 -0
- package/esm/middleware/pipeline.mjs.map +1 -0
- package/esm/middleware/utils/extract-user-text.d.mts +33 -0
- package/esm/middleware/utils/extract-user-text.d.mts.map +1 -0
- package/esm/middleware/utils/extract-user-text.mjs +40 -0
- package/esm/middleware/utils/extract-user-text.mjs.map +1 -0
- package/esm/middleware/utils/index.d.mts +2 -0
- package/esm/middleware/utils/namespaced-state.d.mts +60 -0
- package/esm/middleware/utils/namespaced-state.d.mts.map +1 -0
- package/esm/middleware/utils/namespaced-state.mjs +60 -0
- package/esm/middleware/utils/namespaced-state.mjs.map +1 -0
- package/esm/mock/index.d.mts +4 -0
- package/esm/mock/index.mjs +5 -0
- package/esm/mock/mock-agent.d.mts +41 -0
- package/esm/mock/mock-agent.d.mts.map +1 -0
- package/esm/mock/mock-agent.mjs +39 -0
- package/esm/mock/mock-agent.mjs.map +1 -0
- package/esm/mock/mock-config.type.d.mts +31 -0
- package/esm/mock/mock-config.type.d.mts.map +1 -0
- package/esm/mock/mock-model.d.mts +94 -0
- package/esm/mock/mock-model.d.mts.map +1 -0
- package/esm/mock/mock-model.mjs +150 -0
- package/esm/mock/mock-model.mjs.map +1 -0
- package/esm/mock/mock-sdk.d.mts +25 -0
- package/esm/mock/mock-sdk.d.mts.map +1 -0
- package/esm/mock/mock-sdk.mjs +37 -0
- package/esm/mock/mock-sdk.mjs.map +1 -0
- package/esm/supervisor/as-tool.d.mts +45 -0
- package/esm/supervisor/as-tool.d.mts.map +1 -0
- package/esm/supervisor/as-tool.mjs +80 -0
- package/esm/supervisor/as-tool.mjs.map +1 -0
- package/esm/supervisor/cancellation.d.mts +12 -0
- package/esm/supervisor/cancellation.d.mts.map +1 -0
- package/esm/supervisor/cancellation.mjs +22 -0
- package/esm/supervisor/cancellation.mjs.map +1 -0
- package/esm/supervisor/decide.mjs +272 -0
- package/esm/supervisor/decide.mjs.map +1 -0
- package/esm/supervisor/emitter.d.mts +27 -0
- package/esm/supervisor/emitter.d.mts.map +1 -0
- package/esm/supervisor/emitter.mjs +47 -0
- package/esm/supervisor/emitter.mjs.map +1 -0
- package/esm/supervisor/entries.d.mts +141 -0
- package/esm/supervisor/entries.d.mts.map +1 -0
- package/esm/supervisor/entries.mjs +206 -0
- package/esm/supervisor/entries.mjs.map +1 -0
- package/esm/supervisor/execution.d.mts +637 -0
- package/esm/supervisor/execution.d.mts.map +1 -0
- package/esm/supervisor/execution.mjs +1868 -0
- package/esm/supervisor/execution.mjs.map +1 -0
- package/esm/supervisor/index.d.mts +11 -0
- package/esm/supervisor/index.mjs +12 -0
- package/esm/supervisor/router-prompt.d.mts +56 -0
- package/esm/supervisor/router-prompt.d.mts.map +1 -0
- package/esm/supervisor/router-prompt.mjs +52 -0
- package/esm/supervisor/router-prompt.mjs.map +1 -0
- package/esm/supervisor/signature.d.mts +28 -0
- package/esm/supervisor/signature.d.mts.map +1 -0
- package/esm/supervisor/signature.mjs +89 -0
- package/esm/supervisor/signature.mjs.map +1 -0
- package/esm/supervisor/snapshot.d.mts +54 -0
- package/esm/supervisor/snapshot.d.mts.map +1 -0
- package/esm/supervisor/snapshot.mjs +77 -0
- package/esm/supervisor/snapshot.mjs.map +1 -0
- package/esm/supervisor/supervisor-stream.d.mts +29 -0
- package/esm/supervisor/supervisor-stream.d.mts.map +1 -0
- package/esm/supervisor/supervisor-stream.mjs +89 -0
- package/esm/supervisor/supervisor-stream.mjs.map +1 -0
- package/esm/supervisor/supervisor.d.mts +27 -0
- package/esm/supervisor/supervisor.d.mts.map +1 -0
- package/esm/supervisor/supervisor.mjs +138 -0
- package/esm/supervisor/supervisor.mjs.map +1 -0
- package/esm/system-prompt/instruction.d.mts +52 -0
- package/esm/system-prompt/instruction.d.mts.map +1 -0
- package/esm/system-prompt/instruction.mjs +57 -0
- package/esm/system-prompt/instruction.mjs.map +1 -0
- package/esm/system-prompt/persona.d.mts +52 -0
- package/esm/system-prompt/persona.d.mts.map +1 -0
- package/esm/system-prompt/persona.mjs +57 -0
- package/esm/system-prompt/persona.mjs.map +1 -0
- package/esm/system-prompt/render-placeholders.d.mts +31 -0
- package/esm/system-prompt/render-placeholders.d.mts.map +1 -0
- package/esm/system-prompt/render-placeholders.mjs +58 -0
- package/esm/system-prompt/render-placeholders.mjs.map +1 -0
- package/esm/system-prompt/system-prompt.d.mts +117 -0
- package/esm/system-prompt/system-prompt.d.mts.map +1 -0
- package/esm/system-prompt/system-prompt.mjs +137 -0
- package/esm/system-prompt/system-prompt.mjs.map +1 -0
- package/esm/tool/index.d.mts +1 -0
- package/esm/tool/index.mjs +3 -0
- package/esm/tool/tool.d.mts +64 -0
- package/esm/tool/tool.d.mts.map +1 -0
- package/esm/tool/tool.mjs +184 -0
- package/esm/tool/tool.mjs.map +1 -0
- package/esm/utils/compute-cost.d.mts +58 -0
- package/esm/utils/compute-cost.d.mts.map +1 -0
- package/esm/utils/compute-cost.mjs +87 -0
- package/esm/utils/compute-cost.mjs.map +1 -0
- package/esm/utils/extract-json-payload.d.mts +33 -0
- package/esm/utils/extract-json-payload.d.mts.map +1 -0
- package/esm/utils/extract-json-payload.mjs +39 -0
- package/esm/utils/extract-json-payload.mjs.map +1 -0
- package/esm/utils/generate-run-id.d.mts +20 -0
- package/esm/utils/generate-run-id.d.mts.map +1 -0
- package/esm/utils/generate-run-id.mjs +23 -0
- package/esm/utils/generate-run-id.mjs.map +1 -0
- package/esm/utils/index.d.mts +9 -0
- package/esm/utils/index.mjs +11 -0
- package/esm/utils/json-schema.d.mts +57 -0
- package/esm/utils/json-schema.d.mts.map +1 -0
- package/esm/utils/json-schema.mjs +89 -0
- package/esm/utils/json-schema.mjs.map +1 -0
- package/esm/utils/prepare-attachment-part.d.mts +36 -0
- package/esm/utils/prepare-attachment-part.d.mts.map +1 -0
- package/esm/utils/prepare-attachment-part.mjs +140 -0
- package/esm/utils/prepare-attachment-part.mjs.map +1 -0
- package/esm/utils/resolve-attachment.d.mts +33 -0
- package/esm/utils/resolve-attachment.d.mts.map +1 -0
- package/esm/utils/resolve-attachment.mjs +73 -0
- package/esm/utils/resolve-attachment.mjs.map +1 -0
- package/esm/utils/safe-json-parse.d.mts +14 -0
- package/esm/utils/safe-json-parse.d.mts.map +1 -0
- package/esm/utils/safe-json-parse.mjs +22 -0
- package/esm/utils/safe-json-parse.mjs.map +1 -0
- package/esm/utils/stamp-report-lineage.d.mts +61 -0
- package/esm/utils/stamp-report-lineage.d.mts.map +1 -0
- package/esm/utils/stamp-report-lineage.mjs +47 -0
- package/esm/utils/stamp-report-lineage.mjs.map +1 -0
- package/esm/utils/token-count.d.mts +15 -0
- package/esm/utils/token-count.d.mts.map +1 -0
- package/esm/utils/token-count.mjs +18 -0
- package/esm/utils/token-count.mjs.map +1 -0
- package/esm/workflow/as-tool.mjs +55 -0
- package/esm/workflow/as-tool.mjs.map +1 -0
- package/esm/workflow/cancellation.mjs +44 -0
- package/esm/workflow/cancellation.mjs.map +1 -0
- package/esm/workflow/emitter.mjs +40 -0
- package/esm/workflow/emitter.mjs.map +1 -0
- package/esm/workflow/engine.mjs +362 -0
- package/esm/workflow/engine.mjs.map +1 -0
- package/esm/workflow/index.d.mts +3 -0
- package/esm/workflow/index.mjs +5 -0
- package/esm/workflow/retry.mjs +32 -0
- package/esm/workflow/retry.mjs.map +1 -0
- package/esm/workflow/router.mjs +56 -0
- package/esm/workflow/router.mjs.map +1 -0
- package/esm/workflow/run-scoped-emitter.mjs +32 -0
- package/esm/workflow/run-scoped-emitter.mjs.map +1 -0
- package/esm/workflow/signature.d.mts +7 -0
- package/esm/workflow/signature.d.mts.map +1 -0
- package/esm/workflow/signature.mjs +34 -0
- package/esm/workflow/signature.mjs.map +1 -0
- package/esm/workflow/snapshot.mjs +71 -0
- package/esm/workflow/snapshot.mjs.map +1 -0
- package/esm/workflow/state.mjs +37 -0
- package/esm/workflow/state.mjs.map +1 -0
- package/esm/workflow/step-runner.mjs +371 -0
- package/esm/workflow/step-runner.mjs.map +1 -0
- package/esm/workflow/step.d.mts +19 -0
- package/esm/workflow/step.d.mts.map +1 -0
- package/esm/workflow/step.mjs +37 -0
- package/esm/workflow/step.mjs.map +1 -0
- package/esm/workflow/workflow.d.mts +12 -0
- package/esm/workflow/workflow.d.mts.map +1 -0
- package/esm/workflow/workflow.mjs +116 -0
- package/esm/workflow/workflow.mjs.map +1 -0
- package/llms-full.txt +2293 -0
- package/llms.txt +20 -0
- package/package.json +37 -0
- package/skills/README.md +53 -0
- package/skills/ai-basics/SKILL.md +95 -0
- package/skills/attach-ai-middleware/SKILL.md +184 -0
- package/skills/define-ai-tool/SKILL.md +186 -0
- package/skills/embed-text/SKILL.md +105 -0
- package/skills/handle-ai-errors/SKILL.md +194 -0
- package/skills/log-ai-calls/SKILL.md +141 -0
- package/skills/persist-ai-data/SKILL.md +207 -0
- package/skills/pick-ai-provider/SKILL.md +164 -0
- package/skills/run-ai-agent/SKILL.md +267 -0
- package/skills/run-ai-workflow/SKILL.md +258 -0
- package/skills/run-supervisor/SKILL.md +309 -0
- package/skills/write-system-prompt/SKILL.md +129 -0
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { AIError } from "./ai-error.mjs";
|
|
2
|
+
|
|
3
|
+
//#region ../../@warlock.js/ai/src/errors/tool-execution-error.ts
|
|
4
|
+
/**
|
|
5
|
+
* A registered tool's `execute()` threw during dispatch — the tool
|
|
6
|
+
* code itself failed (not its input schema). The model's request was
|
|
7
|
+
* valid; the implementation crashed.
|
|
8
|
+
*
|
|
9
|
+
* Carries `toolName` so consumers can branch on which tool failed
|
|
10
|
+
* without regex-parsing the message, and `tripIndex` to correlate
|
|
11
|
+
* with the `LLMTrip` entry in `result.report.trips`.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* if (result.error instanceof ToolExecutionError) {
|
|
15
|
+
* metrics.increment("tool.failure", { tool: result.error.toolName });
|
|
16
|
+
* }
|
|
17
|
+
*/
|
|
18
|
+
var ToolExecutionError = class extends AIError {
|
|
19
|
+
static {
|
|
20
|
+
this.defaultCategory = "tool";
|
|
21
|
+
}
|
|
22
|
+
constructor(message, options) {
|
|
23
|
+
super("TOOL_EXEC_FAILED", message, options);
|
|
24
|
+
this.name = "ToolExecutionError";
|
|
25
|
+
this.toolName = options.toolName;
|
|
26
|
+
this.tripIndex = options.tripIndex;
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
//#endregion
|
|
31
|
+
export { ToolExecutionError };
|
|
32
|
+
//# sourceMappingURL=tool-execution-error.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool-execution-error.mjs","names":[],"sources":["../../../../../../@warlock.js/ai/src/errors/tool-execution-error.ts"],"sourcesContent":["import { AIError, type AIErrorOptions } from \"./ai-error\";\nimport type { ErrorCategory } from \"./error-category.type\";\n\n/**\n * Payload passed to `ToolExecutionError` — identifies which tool\n * failed and, when applicable, which trip it was dispatched from.\n */\nexport type ToolExecutionErrorOptions = AIErrorOptions & {\n toolName: string;\n tripIndex?: number;\n};\n\n/**\n * A registered tool's `execute()` threw during dispatch — the tool\n * code itself failed (not its input schema). The model's request was\n * valid; the implementation crashed.\n *\n * Carries `toolName` so consumers can branch on which tool failed\n * without regex-parsing the message, and `tripIndex` to correlate\n * with the `LLMTrip` entry in `result.report.trips`.\n *\n * @example\n * if (result.error instanceof ToolExecutionError) {\n * metrics.increment(\"tool.failure\", { tool: result.error.toolName });\n * }\n */\nexport class ToolExecutionError extends AIError {\n public static readonly defaultCategory: ErrorCategory = \"tool\";\n\n public readonly toolName: string;\n public readonly tripIndex?: number;\n\n public constructor(message: string, options: ToolExecutionErrorOptions) {\n super(\"TOOL_EXEC_FAILED\", message, options);\n this.name = \"ToolExecutionError\";\n this.toolName = options.toolName;\n this.tripIndex = options.tripIndex;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AA0BA,IAAa,qBAAb,cAAwC,QAAQ;;yBACU;;CAKxD,AAAO,YAAY,SAAiB,SAAoC;EACtE,MAAM,oBAAoB,SAAS,OAAO;EAC1C,KAAK,OAAO;EACZ,KAAK,WAAW,QAAQ;EACxB,KAAK,YAAY,QAAQ;CAC3B;AACF"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { ErrorCategory } from "./error-category.type.mjs";
|
|
2
|
+
import { AIErrorOptions } from "./ai-error.mjs";
|
|
3
|
+
import { WorkflowError } from "./workflow-error.mjs";
|
|
4
|
+
|
|
5
|
+
//#region ../../@warlock.js/ai/src/errors/workflow-cancelled-error.d.ts
|
|
6
|
+
type WorkflowCancelledErrorOptions = AIErrorOptions & {
|
|
7
|
+
cancelledAt: string;
|
|
8
|
+
reason?: string;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Workflow was cancelled via `AbortSignal` before it could finish.
|
|
12
|
+
* `cancelledAt` is ISO timestamp at abort; `reason` carries the
|
|
13
|
+
* `controller.abort(reason)` payload when provided.
|
|
14
|
+
*/
|
|
15
|
+
declare class WorkflowCancelledError extends WorkflowError {
|
|
16
|
+
static readonly defaultCategory: ErrorCategory;
|
|
17
|
+
readonly cancelledAt: string;
|
|
18
|
+
readonly reason?: string;
|
|
19
|
+
constructor(message: string, options: WorkflowCancelledErrorOptions);
|
|
20
|
+
}
|
|
21
|
+
//#endregion
|
|
22
|
+
export { WorkflowCancelledError, WorkflowCancelledErrorOptions };
|
|
23
|
+
//# sourceMappingURL=workflow-cancelled-error.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workflow-cancelled-error.d.mts","names":[],"sources":["../../../../../../@warlock.js/ai/src/errors/workflow-cancelled-error.ts"],"mappings":";;;;;KAIY,6BAAA,GAAgC,cAAc;EACxD,WAAA;EACA,MAAA;AAAA;;;;;;cAQW,sBAAA,SAA+B,aAAA;EAAA,gBACnB,eAAA,EAAiB,aAAA;EAAA,SAExB,WAAA;EAAA,SACA,MAAA;cAEG,OAAA,UAAiB,OAAA,EAAS,6BAAA;AAAA"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { WorkflowError } from "./workflow-error.mjs";
|
|
2
|
+
|
|
3
|
+
//#region ../../@warlock.js/ai/src/errors/workflow-cancelled-error.ts
|
|
4
|
+
/**
|
|
5
|
+
* Workflow was cancelled via `AbortSignal` before it could finish.
|
|
6
|
+
* `cancelledAt` is ISO timestamp at abort; `reason` carries the
|
|
7
|
+
* `controller.abort(reason)` payload when provided.
|
|
8
|
+
*/
|
|
9
|
+
var WorkflowCancelledError = class extends WorkflowError {
|
|
10
|
+
static {
|
|
11
|
+
this.defaultCategory = "cancelled";
|
|
12
|
+
}
|
|
13
|
+
constructor(message, options) {
|
|
14
|
+
super(message, options, "WORKFLOW_CANCELLED");
|
|
15
|
+
this.name = "WorkflowCancelledError";
|
|
16
|
+
this.cancelledAt = options.cancelledAt;
|
|
17
|
+
this.reason = options.reason;
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
//#endregion
|
|
22
|
+
export { WorkflowCancelledError };
|
|
23
|
+
//# sourceMappingURL=workflow-cancelled-error.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workflow-cancelled-error.mjs","names":[],"sources":["../../../../../../@warlock.js/ai/src/errors/workflow-cancelled-error.ts"],"sourcesContent":["import type { AIErrorOptions } from \"./ai-error\";\nimport type { ErrorCategory } from \"./error-category.type\";\nimport { WorkflowError } from \"./workflow-error\";\n\nexport type WorkflowCancelledErrorOptions = AIErrorOptions & {\n cancelledAt: string;\n reason?: string;\n};\n\n/**\n * Workflow was cancelled via `AbortSignal` before it could finish.\n * `cancelledAt` is ISO timestamp at abort; `reason` carries the\n * `controller.abort(reason)` payload when provided.\n */\nexport class WorkflowCancelledError extends WorkflowError {\n public static readonly defaultCategory: ErrorCategory = \"cancelled\";\n\n public readonly cancelledAt: string;\n public readonly reason?: string;\n\n public constructor(message: string, options: WorkflowCancelledErrorOptions) {\n super(message, options, \"WORKFLOW_CANCELLED\");\n this.name = \"WorkflowCancelledError\";\n this.cancelledAt = options.cancelledAt;\n this.reason = options.reason;\n }\n}\n"],"mappings":";;;;;;;;AAcA,IAAa,yBAAb,cAA4C,cAAc;;yBACA;;CAKxD,AAAO,YAAY,SAAiB,SAAwC;EAC1E,MAAM,SAAS,SAAS,oBAAoB;EAC5C,KAAK,OAAO;EACZ,KAAK,cAAc,QAAQ;EAC3B,KAAK,SAAS,QAAQ;CACxB;AACF"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { ErrorCategory } from "./error-category.type.mjs";
|
|
2
|
+
import { AIErrorOptions } from "./ai-error.mjs";
|
|
3
|
+
import { WorkflowError } from "./workflow-error.mjs";
|
|
4
|
+
|
|
5
|
+
//#region ../../@warlock.js/ai/src/errors/workflow-drift-error.d.ts
|
|
6
|
+
type WorkflowDriftErrorOptions = AIErrorOptions & {
|
|
7
|
+
savedSignature: string;
|
|
8
|
+
currentSignature: string;
|
|
9
|
+
runId: string;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* `workflow.resume(runId)` found a snapshot whose structural signature
|
|
13
|
+
* doesn't match the current workflow definition. Thrown without
|
|
14
|
+
* executing anything. User must discard, force, or migrate manually.
|
|
15
|
+
*/
|
|
16
|
+
declare class WorkflowDriftError extends WorkflowError {
|
|
17
|
+
static readonly defaultCategory: ErrorCategory;
|
|
18
|
+
readonly savedSignature: string;
|
|
19
|
+
readonly currentSignature: string;
|
|
20
|
+
readonly runId: string;
|
|
21
|
+
constructor(message: string, options: WorkflowDriftErrorOptions);
|
|
22
|
+
}
|
|
23
|
+
//#endregion
|
|
24
|
+
export { WorkflowDriftError, WorkflowDriftErrorOptions };
|
|
25
|
+
//# sourceMappingURL=workflow-drift-error.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workflow-drift-error.d.mts","names":[],"sources":["../../../../../../@warlock.js/ai/src/errors/workflow-drift-error.ts"],"mappings":";;;;;KAIY,yBAAA,GAA4B,cAAc;EACpD,cAAA;EACA,gBAAA;EACA,KAAA;AAAA;;;;;;cAQW,kBAAA,SAA2B,aAAA;EAAA,gBACf,eAAA,EAAiB,aAAA;EAAA,SAExB,cAAA;EAAA,SACA,gBAAA;EAAA,SACA,KAAA;cAEG,OAAA,UAAiB,OAAA,EAAS,yBAAA;AAAA"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { WorkflowError } from "./workflow-error.mjs";
|
|
2
|
+
|
|
3
|
+
//#region ../../@warlock.js/ai/src/errors/workflow-drift-error.ts
|
|
4
|
+
/**
|
|
5
|
+
* `workflow.resume(runId)` found a snapshot whose structural signature
|
|
6
|
+
* doesn't match the current workflow definition. Thrown without
|
|
7
|
+
* executing anything. User must discard, force, or migrate manually.
|
|
8
|
+
*/
|
|
9
|
+
var WorkflowDriftError = class extends WorkflowError {
|
|
10
|
+
static {
|
|
11
|
+
this.defaultCategory = "drift";
|
|
12
|
+
}
|
|
13
|
+
constructor(message, options) {
|
|
14
|
+
super(message, options, "WORKFLOW_DRIFT");
|
|
15
|
+
this.name = "WorkflowDriftError";
|
|
16
|
+
this.savedSignature = options.savedSignature;
|
|
17
|
+
this.currentSignature = options.currentSignature;
|
|
18
|
+
this.runId = options.runId;
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
//#endregion
|
|
23
|
+
export { WorkflowDriftError };
|
|
24
|
+
//# sourceMappingURL=workflow-drift-error.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workflow-drift-error.mjs","names":[],"sources":["../../../../../../@warlock.js/ai/src/errors/workflow-drift-error.ts"],"sourcesContent":["import type { AIErrorOptions } from \"./ai-error\";\nimport type { ErrorCategory } from \"./error-category.type\";\nimport { WorkflowError } from \"./workflow-error\";\n\nexport type WorkflowDriftErrorOptions = AIErrorOptions & {\n savedSignature: string;\n currentSignature: string;\n runId: string;\n};\n\n/**\n * `workflow.resume(runId)` found a snapshot whose structural signature\n * doesn't match the current workflow definition. Thrown without\n * executing anything. User must discard, force, or migrate manually.\n */\nexport class WorkflowDriftError extends WorkflowError {\n public static readonly defaultCategory: ErrorCategory = \"drift\";\n\n public readonly savedSignature: string;\n public readonly currentSignature: string;\n public readonly runId: string;\n\n public constructor(message: string, options: WorkflowDriftErrorOptions) {\n super(message, options, \"WORKFLOW_DRIFT\");\n this.name = \"WorkflowDriftError\";\n this.savedSignature = options.savedSignature;\n this.currentSignature = options.currentSignature;\n this.runId = options.runId;\n }\n}\n"],"mappings":";;;;;;;;AAeA,IAAa,qBAAb,cAAwC,cAAc;;yBACI;;CAMxD,AAAO,YAAY,SAAiB,SAAoC;EACtE,MAAM,SAAS,SAAS,gBAAgB;EACxC,KAAK,OAAO;EACZ,KAAK,iBAAiB,QAAQ;EAC9B,KAAK,mBAAmB,QAAQ;EAChC,KAAK,QAAQ,QAAQ;CACvB;AACF"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { AIErrorCode } from "./error-code.type.mjs";
|
|
2
|
+
import { AIError, AIErrorOptions } from "./ai-error.mjs";
|
|
3
|
+
|
|
4
|
+
//#region ../../@warlock.js/ai/src/errors/workflow-error.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* Base class for all workflow-specific failures. Subclasses carry
|
|
7
|
+
* precise codes; this base catches everything `workflow.execute()`
|
|
8
|
+
* can produce beyond agent/tool/provider errors.
|
|
9
|
+
*/
|
|
10
|
+
declare class WorkflowError extends AIError {
|
|
11
|
+
constructor(message: string, options?: AIErrorOptions, code?: AIErrorCode);
|
|
12
|
+
}
|
|
13
|
+
//#endregion
|
|
14
|
+
export { WorkflowError };
|
|
15
|
+
//# sourceMappingURL=workflow-error.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workflow-error.d.mts","names":[],"sources":["../../../../../../@warlock.js/ai/src/errors/workflow-error.ts"],"mappings":";;;;;;AAQA;;;cAAa,aAAA,SAAsB,OAAA;cAE/B,OAAA,UACA,OAAA,GAAU,cAAA,EACV,IAAA,GAAM,WAAA;AAAA"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { AIError } from "./ai-error.mjs";
|
|
2
|
+
|
|
3
|
+
//#region ../../@warlock.js/ai/src/errors/workflow-error.ts
|
|
4
|
+
/**
|
|
5
|
+
* Base class for all workflow-specific failures. Subclasses carry
|
|
6
|
+
* precise codes; this base catches everything `workflow.execute()`
|
|
7
|
+
* can produce beyond agent/tool/provider errors.
|
|
8
|
+
*/
|
|
9
|
+
var WorkflowError = class extends AIError {
|
|
10
|
+
constructor(message, options, code = "WORKFLOW_ERROR") {
|
|
11
|
+
super(code, message, options);
|
|
12
|
+
this.name = "WorkflowError";
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
//#endregion
|
|
17
|
+
export { WorkflowError };
|
|
18
|
+
//# sourceMappingURL=workflow-error.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workflow-error.mjs","names":[],"sources":["../../../../../../@warlock.js/ai/src/errors/workflow-error.ts"],"sourcesContent":["import { AIError, type AIErrorOptions } from \"./ai-error\";\nimport type { AIErrorCode } from \"./error-code.type\";\n\n/**\n * Base class for all workflow-specific failures. Subclasses carry\n * precise codes; this base catches everything `workflow.execute()`\n * can produce beyond agent/tool/provider errors.\n */\nexport class WorkflowError extends AIError {\n public constructor(\n message: string,\n options?: AIErrorOptions,\n code: AIErrorCode = \"WORKFLOW_ERROR\",\n ) {\n super(code, message, options);\n this.name = \"WorkflowError\";\n }\n}\n"],"mappings":";;;;;;;;AAQA,IAAa,gBAAb,cAAmC,QAAQ;CACzC,AAAO,YACL,SACA,SACA,OAAoB,kBACpB;EACA,MAAM,MAAM,SAAS,OAAO;EAC5B,KAAK,OAAO;CACd;AACF"}
|
package/esm/index.d.mts
ADDED
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import { Attachment, AttachmentSource, ResolvedAttachment, StorageFileShape } from "./contracts/attachment.type.mjs";
|
|
2
|
+
import { ContentPart, ImageSource } from "./contracts/content-part.type.mjs";
|
|
3
|
+
import { ModelToolCallRequest } from "./contracts/model-tool-call-request.type.mjs";
|
|
4
|
+
import { Message } from "./contracts/conversation-message.type.mjs";
|
|
5
|
+
import { ErrorCategory } from "./errors/error-category.type.mjs";
|
|
6
|
+
import { AIErrorCode } from "./errors/error-code.type.mjs";
|
|
7
|
+
import { AIError, AIErrorOptions } from "./errors/ai-error.mjs";
|
|
8
|
+
import { ModelPricing } from "./contracts/result/model-pricing.type.mjs";
|
|
9
|
+
import { Usage } from "./contracts/result/usage.type.mjs";
|
|
10
|
+
import { BaseResult } from "./contracts/result/base-result.type.mjs";
|
|
11
|
+
import { AttemptEntry } from "./contracts/result/attempt-entry.type.mjs";
|
|
12
|
+
import { BaseReport, REPORT_SCHEMA_VERSION, ReportStatus, ReportType } from "./contracts/result/base-report.type.mjs";
|
|
13
|
+
import { FinishReason } from "./contracts/finish-reason.type.mjs";
|
|
14
|
+
import { ToolCall } from "./contracts/result/tool-call.type.mjs";
|
|
15
|
+
import { LLMTrip } from "./contracts/result/llm-trip.type.mjs";
|
|
16
|
+
import { AgentReport, ExecutionReport, ExecutionStatus } from "./contracts/result/execution-report.type.mjs";
|
|
17
|
+
import { AgentResult } from "./contracts/result/agent-result.type.mjs";
|
|
18
|
+
import { AgentCompletedPayload, AgentErrorPayload, AgentStartingPayload, AgentStreamingPayload, AgentToolCalledPayload, AgentToolCallingFailedPayload, AgentToolCallingPayload, AgentTripCompletedPayload, AgentTripStartedPayload, ToolEventMeta } from "./contracts/events/agent-events.type.mjs";
|
|
19
|
+
import { EventIdentity, WithoutIdentity } from "./contracts/events/event-identity.type.mjs";
|
|
20
|
+
import { ExecuteResult } from "./contracts/result/execute-result.type.mjs";
|
|
21
|
+
import { ExecutableContract } from "./contracts/executable.contract.mjs";
|
|
22
|
+
import { StreamEvent, StreamEventBody } from "./contracts/stream/stream-event.type.mjs";
|
|
23
|
+
import { StreamContract } from "./contracts/stream/stream.contract.mjs";
|
|
24
|
+
import { AgentContract, AgentEventHandler } from "./contracts/agent/agent.contract.mjs";
|
|
25
|
+
import { END, EndSentinel } from "./contracts/end.type.mjs";
|
|
26
|
+
import { StepSnapshot } from "./contracts/result/step-result.type.mjs";
|
|
27
|
+
import { WorkflowReport, WorkflowResult } from "./contracts/result/workflow-result.type.mjs";
|
|
28
|
+
import { ToolConfig, ToolContext, ToolMeta, ToolMode } from "./contracts/tool.contract.mjs";
|
|
29
|
+
import { AgentExecutionError } from "./errors/agent-execution-error.mjs";
|
|
30
|
+
import { AgentCancelledError, AgentCancelledErrorOptions } from "./errors/agent-cancelled-error.mjs";
|
|
31
|
+
import { AgentMaxTripsError, AgentMaxTripsErrorOptions } from "./errors/agent-max-trips-error.mjs";
|
|
32
|
+
import { BudgetExceededError, BudgetExceededErrorOptions, BudgetUnit } from "./errors/budget-exceeded-error.mjs";
|
|
33
|
+
import { ProviderError } from "./errors/provider-error.mjs";
|
|
34
|
+
import { ContentFilterError, ContentFilterErrorOptions } from "./errors/content-filter-error.mjs";
|
|
35
|
+
import { ContextLengthExceededError, ContextLengthExceededErrorOptions } from "./errors/context-length-exceeded-error.mjs";
|
|
36
|
+
import { GuardrailPhase, GuardrailViolationError, GuardrailViolationErrorOptions } from "./errors/guardrail-violation-error.mjs";
|
|
37
|
+
import { InvalidRequestError } from "./errors/invalid-request-error.mjs";
|
|
38
|
+
import { SupervisorFailedError } from "./errors/supervisor-failed-error.mjs";
|
|
39
|
+
import { MaxIterationsError, MaxIterationsErrorOptions } from "./errors/max-iterations-error.mjs";
|
|
40
|
+
import { WorkflowError } from "./errors/workflow-error.mjs";
|
|
41
|
+
import { MaxStepsExceededError, MaxStepsExceededErrorOptions } from "./errors/max-steps-exceeded-error.mjs";
|
|
42
|
+
import { ProviderAuthError } from "./errors/provider-auth-error.mjs";
|
|
43
|
+
import { ProviderRateLimitError, ProviderRateLimitErrorOptions } from "./errors/provider-rate-limit-error.mjs";
|
|
44
|
+
import { ProviderTimeoutError } from "./errors/provider-timeout-error.mjs";
|
|
45
|
+
import { QuotaExceededError } from "./errors/quota-exceeded-error.mjs";
|
|
46
|
+
import { RoutingError, RoutingErrorOptions } from "./errors/routing-error.mjs";
|
|
47
|
+
import { SchemaValidationError, SchemaValidationErrorOptions } from "./errors/schema-validation-error.mjs";
|
|
48
|
+
import { StepFailedError, StepFailedErrorOptions } from "./errors/step-failed-error.mjs";
|
|
49
|
+
import { SupervisorCancelledError, SupervisorCancelledErrorOptions } from "./errors/supervisor-cancelled-error.mjs";
|
|
50
|
+
import { SupervisorDriftError, SupervisorDriftErrorOptions } from "./errors/supervisor-drift-error.mjs";
|
|
51
|
+
import { SupervisorRoutingError, SupervisorRoutingErrorOptions } from "./errors/supervisor-routing-error.mjs";
|
|
52
|
+
import { ToolExecutionError, ToolExecutionErrorOptions } from "./errors/tool-execution-error.mjs";
|
|
53
|
+
import { WorkflowCancelledError, WorkflowCancelledErrorOptions } from "./errors/workflow-cancelled-error.mjs";
|
|
54
|
+
import { WorkflowDriftError, WorkflowDriftErrorOptions } from "./errors/workflow-drift-error.mjs";
|
|
55
|
+
import { ToolContract, ToolInvokeResult, tool } from "./tool/tool.mjs";
|
|
56
|
+
import { NextStepResult } from "./contracts/workflow/next-step-result.type.mjs";
|
|
57
|
+
import { RetryBackoff, RetryConfig } from "./contracts/workflow/retry-config.type.mjs";
|
|
58
|
+
import { WorkflowContext } from "./contracts/workflow/workflow-context.type.mjs";
|
|
59
|
+
import { StepAgentInput, StepDefinition, StepLocalEvents, StepOutputSpec } from "./contracts/workflow/step.contract.mjs";
|
|
60
|
+
import { WorkflowDefinition, WorkflowEventHandler, WorkflowEventHandlers, WorkflowExecuteOptions, WorkflowInstance, WorkflowResumeOptions, WorkflowRunOptions } from "./contracts/workflow/workflow.contract.mjs";
|
|
61
|
+
import { Placeholders } from "./contracts/placeholders.type.mjs";
|
|
62
|
+
import { InstructionContract, PersonaContract, SystemPromptBlockContract, SystemPromptContract } from "./contracts/system-prompt.contract.mjs";
|
|
63
|
+
import { Next } from "./contracts/supervisor/next.type.mjs";
|
|
64
|
+
import { AckSnapshot, AgentBranchSnapshot, DecisionSource, IterationDecision, IterationSnapshot } from "./contracts/supervisor/iteration-snapshot.type.mjs";
|
|
65
|
+
import { SupervisorInput } from "./contracts/supervisor/supervisor-input.type.mjs";
|
|
66
|
+
import { EvaluateBranchResult, EvaluateContext, EvaluateResult } from "./contracts/supervisor/evaluate-context.type.mjs";
|
|
67
|
+
import { RouteContext } from "./contracts/supervisor/route-context.type.mjs";
|
|
68
|
+
import { AckCallback, AckConfig, AckEntry, AckRunEntry } from "./contracts/supervisor/ack-entry.type.mjs";
|
|
69
|
+
import { DispatchRawResult, IntentCallback, IntentEntry, IntentRunEntry, SupervisorIntentValue } from "./contracts/supervisor/intent-entry.type.mjs";
|
|
70
|
+
import { RouterEntry } from "./contracts/supervisor/router-entry.type.mjs";
|
|
71
|
+
import { SupervisorConfig, SupervisorEventHandler, SupervisorEventHandlers } from "./contracts/supervisor/supervisor-config.type.mjs";
|
|
72
|
+
import { SupervisorExecuteOptions, SupervisorResumeOptions } from "./contracts/supervisor/supervisor-execute-options.type.mjs";
|
|
73
|
+
import { SupervisorStreamEvent } from "./contracts/supervisor/supervisor-stream-event.type.mjs";
|
|
74
|
+
import { SupervisorAsToolOptions, SupervisorContract } from "./contracts/supervisor/supervisor.contract.mjs";
|
|
75
|
+
import { DispatchContext, IntentRunner, IntentRunnerMap } from "./contracts/supervisor/dispatch-context.type.mjs";
|
|
76
|
+
import { ClassifierAgentEntry, ClassifierCallback, ClassifierConfig, ClassifierContext, ClassifierOutput, ClassifierRefineContext, ClassifierRefineResult, ClassifierRunEntry, ClassifierSnapshot } from "./contracts/supervisor/classifier-context.type.mjs";
|
|
77
|
+
import { SupervisorReport, SupervisorResult, SupervisorTerminatedBy } from "./contracts/result/supervisor-result.type.mjs";
|
|
78
|
+
import { SessionSendResult } from "./contracts/result/session-send-result.type.mjs";
|
|
79
|
+
import { SupervisorSnapshot, SupervisorSnapshotStatus } from "./contracts/supervisor/supervisor-snapshot.type.mjs";
|
|
80
|
+
import { SupervisorAgentCompletedPayload, SupervisorAgentFailedPayload, SupervisorAgentStartingPayload, SupervisorAgentStreamingPayload, SupervisorCancelledPayload, SupervisorCompletedPayload, SupervisorErrorPayload, SupervisorEvaluateVerdictPayload, SupervisorIterationCompletedPayload, SupervisorIterationStartingPayload, SupervisorRouterDecidedPayload, SupervisorRouterDecidingPayload, SupervisorStartingPayload } from "./contracts/events/supervisor-events.type.mjs";
|
|
81
|
+
import { WorkflowCancelledPayload, WorkflowCompletedPayload, WorkflowErrorPayload, WorkflowLoopWarningPayload, WorkflowStartingPayload, WorkflowStepCompletedPayload, WorkflowStepFailedPayload, WorkflowStepRetryingPayload, WorkflowStepSkippedPayload, WorkflowStepStartingPayload, WorkflowStepStreamingPayload } from "./contracts/events/workflow-events.type.mjs";
|
|
82
|
+
import { AgentEventMap, SupervisorEventMap, WorkflowEventMap } from "./contracts/events/event-map.type.mjs";
|
|
83
|
+
import { StreamingToolGuardConfig } from "./contracts/streaming-tool-guard-config.type.mjs";
|
|
84
|
+
import { AgentExecuteOptions } from "./contracts/agent/agent-options.type.mjs";
|
|
85
|
+
import { EmbedderConfig, EmbedderContract, EmbeddingBatchResult, EmbeddingResult, EmbeddingUsage } from "./contracts/embedder.contract.mjs";
|
|
86
|
+
import { MiddlewareState } from "./contracts/middleware/middleware-state.type.mjs";
|
|
87
|
+
import { MiddlewareAgentRef, MiddlewareExecuteContext, MiddlewareModelRef, MiddlewareToolContext, MiddlewareTripContext } from "./contracts/middleware/middleware-context.type.mjs";
|
|
88
|
+
import { ModelCallOptions, ModelCapabilities, ModelContract, ModelResponse, ModelStreamChunk } from "./contracts/model.contract.mjs";
|
|
89
|
+
import { AgentMiddleware, AgentMiddlewareExecuteHooks, AgentMiddlewareToolHooks, AgentMiddlewareTripHooks } from "./contracts/middleware/middleware.contract.mjs";
|
|
90
|
+
import { ModelConfig, SDKAdapterContract } from "./contracts/sdk-adapter.contract.mjs";
|
|
91
|
+
import { WorkflowSnapshot } from "./contracts/workflow/workflow-snapshot.type.mjs";
|
|
92
|
+
import { CompleteEvent } from "./contracts/events/complete-event.type.mjs";
|
|
93
|
+
import { UsageEvent } from "./contracts/events/usage-event.type.mjs";
|
|
94
|
+
import { AgentConfig } from "./agent/agent-config.type.mjs";
|
|
95
|
+
import { agent } from "./agent/agent.mjs";
|
|
96
|
+
import { StreamController, createAgentStream } from "./agent/agent-stream.mjs";
|
|
97
|
+
import { AIConfig, getAIConfig, resolveDefaultStore, setAIConfig } from "./config.mjs";
|
|
98
|
+
import { BudgetOptions, BudgetPricing, budget } from "./middleware/builtins/budget.mjs";
|
|
99
|
+
import { GuardrailCheck, GuardrailCheckResult, GuardrailOptions, guardrail } from "./middleware/builtins/guardrail.mjs";
|
|
100
|
+
import { SemanticCacheOptions, semanticCache } from "./middleware/builtins/semantic-cache.mjs";
|
|
101
|
+
import { composeMiddleware } from "./middleware/helpers/compose.mjs";
|
|
102
|
+
import { forTool } from "./middleware/helpers/for-tool.mjs";
|
|
103
|
+
import { supervisor } from "./supervisor/supervisor.mjs";
|
|
104
|
+
import { Instruction, instruction } from "./system-prompt/instruction.mjs";
|
|
105
|
+
import { Persona, persona } from "./system-prompt/persona.mjs";
|
|
106
|
+
import { SystemPrompt, systemPrompt } from "./system-prompt/system-prompt.mjs";
|
|
107
|
+
import { step } from "./workflow/step.mjs";
|
|
108
|
+
import { workflow } from "./workflow/workflow.mjs";
|
|
109
|
+
import { ai } from "./ai.mjs";
|
|
110
|
+
import { MiddlewareContextByLevel, MiddlewareLevel, runPipeline } from "./middleware/pipeline.mjs";
|
|
111
|
+
import { extractUserText } from "./middleware/utils/extract-user-text.mjs";
|
|
112
|
+
import { NamespacedStateAccessor, namespacedState } from "./middleware/utils/namespaced-state.mjs";
|
|
113
|
+
import { MockModelResponse, MockSDKConfig } from "./mock/mock-config.type.mjs";
|
|
114
|
+
import { mockAgent } from "./mock/mock-agent.mjs";
|
|
115
|
+
import { MockModel } from "./mock/mock-model.mjs";
|
|
116
|
+
import { MockSDK } from "./mock/mock-sdk.mjs";
|
|
117
|
+
import { asTool } from "./supervisor/as-tool.mjs";
|
|
118
|
+
import { createCancelledError } from "./supervisor/cancellation.mjs";
|
|
119
|
+
import { SupervisorEmitter } from "./supervisor/emitter.mjs";
|
|
120
|
+
import { ResolvedIntentEntry, resolveIntentEntries } from "./supervisor/entries.mjs";
|
|
121
|
+
import { SupervisorStreamController, createSupervisorStream } from "./supervisor/supervisor-stream.mjs";
|
|
122
|
+
import { SupervisorExecution } from "./supervisor/execution.mjs";
|
|
123
|
+
import { buildRouterContextMessage } from "./supervisor/router-prompt.mjs";
|
|
124
|
+
import { computeSignature as computeSignature$1 } from "./supervisor/signature.mjs";
|
|
125
|
+
import { loadSnapshotForResume, persistSupervisorSnapshot, snapshotKey } from "./supervisor/snapshot.mjs";
|
|
126
|
+
import { renderPlaceholders } from "./system-prompt/render-placeholders.mjs";
|
|
127
|
+
import { accumulateCost, computeCost } from "./utils/compute-cost.mjs";
|
|
128
|
+
import { extractJsonPayload } from "./utils/extract-json-payload.mjs";
|
|
129
|
+
import { generateRunId } from "./utils/generate-run-id.mjs";
|
|
130
|
+
import { extractJsonSchema } from "./utils/json-schema.mjs";
|
|
131
|
+
import { prepareAttachmentPart } from "./utils/prepare-attachment-part.mjs";
|
|
132
|
+
import { resolveAttachment } from "./utils/resolve-attachment.mjs";
|
|
133
|
+
import { safeJsonParse } from "./utils/safe-json-parse.mjs";
|
|
134
|
+
import { LineageStamp, stampReportLineage } from "./utils/stamp-report-lineage.mjs";
|
|
135
|
+
import { approximateTokenCount } from "./utils/token-count.mjs";
|
|
136
|
+
import { computeSignature } from "./workflow/signature.mjs";
|
|
137
|
+
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 AgentMiddlewareToolHooks, type AgentMiddlewareTripHooks, type AgentReport, type AgentResult, type AgentStartingPayload, type AgentStreamingPayload, type AgentToolCalledPayload, type AgentToolCallingFailedPayload, type AgentToolCallingPayload, type AgentTripCompletedPayload, type AgentTripStartedPayload, Attachment, AttachmentSource, type AttemptEntry, type BaseReport, type BaseResult, BudgetExceededError, type BudgetExceededErrorOptions, type BudgetOptions, type BudgetPricing, type BudgetUnit, type ClassifierAgentEntry, type ClassifierCallback, type ClassifierConfig, type ClassifierContext, type ClassifierOutput, type ClassifierRefineContext, type ClassifierRefineResult, type ClassifierRunEntry, type ClassifierSnapshot, type CompleteEvent, ContentFilterError, type ContentFilterErrorOptions, ContentPart, ContextLengthExceededError, type ContextLengthExceededErrorOptions, type DecisionSource, type DispatchContext, type DispatchRawResult, END, EmbedderConfig, EmbedderContract, EmbeddingBatchResult, EmbeddingResult, EmbeddingUsage, EndSentinel, type ErrorCategory, type EvaluateBranchResult, type EvaluateContext, type EvaluateResult, type EventIdentity, ExecutableContract, type ExecuteResult, type ExecutionReport, type ExecutionStatus, 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, MaxIterationsError, type MaxIterationsErrorOptions, MaxStepsExceededError, type MaxStepsExceededErrorOptions, Message, type MiddlewareAgentRef, type MiddlewareContextByLevel, type MiddlewareExecuteContext, type MiddlewareLevel, type MiddlewareModelRef, type MiddlewareState, type MiddlewareToolContext, type MiddlewareTripContext, MockModel, type MockModelResponse, MockSDK, type MockSDKConfig, ModelCallOptions, ModelCapabilities, ModelConfig, ModelContract, type ModelPricing, ModelResponse, ModelStreamChunk, ModelToolCallRequest, type NamespacedStateAccessor, type Next, type NextStepResult, Persona, PersonaContract, Placeholders, ProviderAuthError, ProviderError, ProviderRateLimitError, type ProviderRateLimitErrorOptions, ProviderTimeoutError, QuotaExceededError, REPORT_SCHEMA_VERSION, type ReportStatus, type ReportType, ResolvedAttachment, type ResolvedIntentEntry, type RetryBackoff, type RetryConfig, type RouteContext, type RouterEntry, RoutingError, type RoutingErrorOptions, SDKAdapterContract, SchemaValidationError, type SchemaValidationErrorOptions, type SemanticCacheOptions, type SessionSendResult, type StepAgentInput, type StepDefinition, StepFailedError, type StepFailedErrorOptions, type StepLocalEvents, type StepOutputSpec, type StepSnapshot, StorageFileShape, type StreamContract, type StreamController, type StreamEvent, type StreamEventBody, StreamingToolGuardConfig, 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 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, budget, buildRouterContextMessage, composeMiddleware, computeCost, computeSignature, computeSignature$1 as computeSupervisorSignature, createAgentStream, createCancelledError as createSupervisorCancelledError, createSupervisorStream, extractJsonPayload, extractJsonSchema, extractUserText, forTool, generateRunId, getAIConfig, guardrail, instruction, loadSnapshotForResume as loadSupervisorSnapshotForResume, mockAgent, namespacedState, persistSupervisorSnapshot, persona, prepareAttachmentPart, renderPlaceholders, resolveAttachment, resolveDefaultStore, resolveIntentEntries, runPipeline, safeJsonParse, semanticCache, setAIConfig, stampReportLineage, step, supervisor, asTool as supervisorAsTool, snapshotKey as supervisorSnapshotKey, systemPrompt, tool, workflow };
|
package/esm/index.mjs
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { AIError } from "./errors/ai-error.mjs";
|
|
2
|
+
import { AgentExecutionError } from "./errors/agent-execution-error.mjs";
|
|
3
|
+
import { AgentCancelledError } from "./errors/agent-cancelled-error.mjs";
|
|
4
|
+
import { AgentMaxTripsError } from "./errors/agent-max-trips-error.mjs";
|
|
5
|
+
import { BudgetExceededError } from "./errors/budget-exceeded-error.mjs";
|
|
6
|
+
import { ProviderError } from "./errors/provider-error.mjs";
|
|
7
|
+
import { ContentFilterError } from "./errors/content-filter-error.mjs";
|
|
8
|
+
import { ContextLengthExceededError } from "./errors/context-length-exceeded-error.mjs";
|
|
9
|
+
import { GuardrailViolationError } from "./errors/guardrail-violation-error.mjs";
|
|
10
|
+
import { InvalidRequestError } from "./errors/invalid-request-error.mjs";
|
|
11
|
+
import { SupervisorFailedError } from "./errors/supervisor-failed-error.mjs";
|
|
12
|
+
import { MaxIterationsError } from "./errors/max-iterations-error.mjs";
|
|
13
|
+
import { WorkflowError } from "./errors/workflow-error.mjs";
|
|
14
|
+
import { MaxStepsExceededError } from "./errors/max-steps-exceeded-error.mjs";
|
|
15
|
+
import { ProviderAuthError } from "./errors/provider-auth-error.mjs";
|
|
16
|
+
import { ProviderRateLimitError } from "./errors/provider-rate-limit-error.mjs";
|
|
17
|
+
import { ProviderTimeoutError } from "./errors/provider-timeout-error.mjs";
|
|
18
|
+
import { QuotaExceededError } from "./errors/quota-exceeded-error.mjs";
|
|
19
|
+
import { RoutingError } from "./errors/routing-error.mjs";
|
|
20
|
+
import { SchemaValidationError } from "./errors/schema-validation-error.mjs";
|
|
21
|
+
import { StepFailedError } from "./errors/step-failed-error.mjs";
|
|
22
|
+
import { SupervisorCancelledError } from "./errors/supervisor-cancelled-error.mjs";
|
|
23
|
+
import { SupervisorDriftError } from "./errors/supervisor-drift-error.mjs";
|
|
24
|
+
import { SupervisorRoutingError } from "./errors/supervisor-routing-error.mjs";
|
|
25
|
+
import { ToolExecutionError } from "./errors/tool-execution-error.mjs";
|
|
26
|
+
import { WorkflowCancelledError } from "./errors/workflow-cancelled-error.mjs";
|
|
27
|
+
import { WorkflowDriftError } from "./errors/workflow-drift-error.mjs";
|
|
28
|
+
import "./errors/index.mjs";
|
|
29
|
+
import { extractUserText } from "./middleware/utils/extract-user-text.mjs";
|
|
30
|
+
import { namespacedState } from "./middleware/utils/namespaced-state.mjs";
|
|
31
|
+
import { budget } from "./middleware/builtins/budget.mjs";
|
|
32
|
+
import { guardrail } from "./middleware/builtins/guardrail.mjs";
|
|
33
|
+
import { getAIConfig, resolveDefaultStore, setAIConfig } from "./config.mjs";
|
|
34
|
+
import { semanticCache } from "./middleware/builtins/semantic-cache.mjs";
|
|
35
|
+
import { composeMiddleware } from "./middleware/helpers/compose.mjs";
|
|
36
|
+
import { forTool } from "./middleware/helpers/for-tool.mjs";
|
|
37
|
+
import { runPipeline } from "./middleware/pipeline.mjs";
|
|
38
|
+
import "./middleware/index.mjs";
|
|
39
|
+
import { accumulateCost, computeCost } from "./utils/compute-cost.mjs";
|
|
40
|
+
import { extractJsonPayload } from "./utils/extract-json-payload.mjs";
|
|
41
|
+
import { generateRunId } from "./utils/generate-run-id.mjs";
|
|
42
|
+
import { extractJsonSchema } from "./utils/json-schema.mjs";
|
|
43
|
+
import { resolveAttachment } from "./utils/resolve-attachment.mjs";
|
|
44
|
+
import { prepareAttachmentPart } from "./utils/prepare-attachment-part.mjs";
|
|
45
|
+
import { safeJsonParse } from "./utils/safe-json-parse.mjs";
|
|
46
|
+
import { REPORT_SCHEMA_VERSION } from "./contracts/result/base-report.type.mjs";
|
|
47
|
+
import { stampReportLineage } from "./utils/stamp-report-lineage.mjs";
|
|
48
|
+
import { approximateTokenCount } from "./utils/token-count.mjs";
|
|
49
|
+
import "./utils/index.mjs";
|
|
50
|
+
import { createAgentStream } from "./agent/agent-stream.mjs";
|
|
51
|
+
import { agent } from "./agent/agent.mjs";
|
|
52
|
+
import "./agent/index.mjs";
|
|
53
|
+
import { tool } from "./tool/tool.mjs";
|
|
54
|
+
import { asTool } from "./supervisor/as-tool.mjs";
|
|
55
|
+
import { SupervisorEmitter } from "./supervisor/emitter.mjs";
|
|
56
|
+
import { resolveIntentEntries } from "./supervisor/entries.mjs";
|
|
57
|
+
import { END } from "./contracts/end.type.mjs";
|
|
58
|
+
import { createCancelledError } from "./supervisor/cancellation.mjs";
|
|
59
|
+
import { buildRouterContextMessage } from "./supervisor/router-prompt.mjs";
|
|
60
|
+
import { loadSnapshotForResume, persistSupervisorSnapshot, snapshotKey } from "./supervisor/snapshot.mjs";
|
|
61
|
+
import { SupervisorExecution } from "./supervisor/execution.mjs";
|
|
62
|
+
import { computeSignature as computeSignature$1 } from "./supervisor/signature.mjs";
|
|
63
|
+
import { createSupervisorStream } from "./supervisor/supervisor-stream.mjs";
|
|
64
|
+
import { supervisor } from "./supervisor/supervisor.mjs";
|
|
65
|
+
import { renderPlaceholders } from "./system-prompt/render-placeholders.mjs";
|
|
66
|
+
import { Instruction, instruction } from "./system-prompt/instruction.mjs";
|
|
67
|
+
import { Persona, persona } from "./system-prompt/persona.mjs";
|
|
68
|
+
import { SystemPrompt, systemPrompt } from "./system-prompt/system-prompt.mjs";
|
|
69
|
+
import { step } from "./workflow/step.mjs";
|
|
70
|
+
import { computeSignature } from "./workflow/signature.mjs";
|
|
71
|
+
import { workflow } from "./workflow/workflow.mjs";
|
|
72
|
+
import { ai } from "./ai.mjs";
|
|
73
|
+
import { MockModel } from "./mock/mock-model.mjs";
|
|
74
|
+
import { MockSDK } from "./mock/mock-sdk.mjs";
|
|
75
|
+
import { mockAgent } from "./mock/mock-agent.mjs";
|
|
76
|
+
import "./mock/index.mjs";
|
|
77
|
+
import "./supervisor/index.mjs";
|
|
78
|
+
import "./tool/index.mjs";
|
|
79
|
+
import "./workflow/index.mjs";
|
|
80
|
+
|
|
81
|
+
export { AIError, AgentCancelledError, AgentExecutionError, AgentMaxTripsError, BudgetExceededError, ContentFilterError, ContextLengthExceededError, END, GuardrailViolationError, Instruction, InvalidRequestError, MaxIterationsError, MaxStepsExceededError, MockModel, MockSDK, Persona, 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, budget, buildRouterContextMessage, composeMiddleware, computeCost, computeSignature, computeSignature$1 as computeSupervisorSignature, createAgentStream, createCancelledError as createSupervisorCancelledError, createSupervisorStream, extractJsonPayload, extractJsonSchema, extractUserText, forTool, generateRunId, getAIConfig, guardrail, instruction, loadSnapshotForResume as loadSupervisorSnapshotForResume, mockAgent, namespacedState, persistSupervisorSnapshot, persona, prepareAttachmentPart, renderPlaceholders, resolveAttachment, resolveDefaultStore, resolveIntentEntries, runPipeline, safeJsonParse, semanticCache, setAIConfig, stampReportLineage, step, supervisor, asTool as supervisorAsTool, snapshotKey as supervisorSnapshotKey, systemPrompt, tool, workflow };
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { AgentMiddleware } from "../../contracts/middleware/middleware.contract.mjs";
|
|
2
|
+
//#region ../../@warlock.js/ai/src/middleware/builtins/budget.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* Per-model pricing used to compute USD cost from token counts.
|
|
5
|
+
* Caller-supplied — no bundled table. Keys are model names (the
|
|
6
|
+
* `ModelContract.name` value); values are input / output token
|
|
7
|
+
* prices expressed as **USD per 1K tokens** to match every major
|
|
8
|
+
* provider's published pricing sheet.
|
|
9
|
+
*/
|
|
10
|
+
type BudgetPricing = Record<string, {
|
|
11
|
+
/** USD per 1,000 input tokens. */inputPer1K: number; /** USD per 1,000 output tokens. */
|
|
12
|
+
outputPer1K: number;
|
|
13
|
+
}>;
|
|
14
|
+
/**
|
|
15
|
+
* Configuration for `budget()`. At least one of `maxTokens` or
|
|
16
|
+
* `maxCostUSD` must be supplied — a budget with no cap is a no-op.
|
|
17
|
+
*/
|
|
18
|
+
type BudgetOptions = {
|
|
19
|
+
/**
|
|
20
|
+
* Hard cap on cumulative total tokens (input + output, summed
|
|
21
|
+
* across every trip of the run). Inclusive — exceeding triggers
|
|
22
|
+
* the configured `onExceeded`.
|
|
23
|
+
*/
|
|
24
|
+
maxTokens?: number;
|
|
25
|
+
/**
|
|
26
|
+
* Hard cap on cumulative USD cost. Requires `pricing` for the
|
|
27
|
+
* agent's configured model — without a pricing entry the USD check
|
|
28
|
+
* silently skips (tokens-only enforcement still applies).
|
|
29
|
+
*/
|
|
30
|
+
maxCostUSD?: number;
|
|
31
|
+
/**
|
|
32
|
+
* Per-model pricing table used to compute USD cost. Only consulted
|
|
33
|
+
* when `maxCostUSD` is set. Model names must match the running
|
|
34
|
+
* agent's `ModelContract.name` exactly.
|
|
35
|
+
*/
|
|
36
|
+
pricing?: BudgetPricing;
|
|
37
|
+
/**
|
|
38
|
+
* Behavior when a cap is breached. `"abort"` throws
|
|
39
|
+
* `BudgetExceededError` — surfaces on `result.error`, stops the
|
|
40
|
+
* run at the next trip boundary. `"warn"` logs a warning and
|
|
41
|
+
* lets the run continue (useful for observability-first rollouts
|
|
42
|
+
* before flipping the switch to abort). Default `"abort"`.
|
|
43
|
+
*/
|
|
44
|
+
onExceeded?: "abort" | "warn";
|
|
45
|
+
/**
|
|
46
|
+
* Override the middleware name. Useful when two budgets coexist
|
|
47
|
+
* (e.g. a per-request cap plus a session-wide cap via different
|
|
48
|
+
* instances). Default `"budget"`.
|
|
49
|
+
*/
|
|
50
|
+
name?: string;
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* Enforced token and / or USD budget for an agent run.
|
|
54
|
+
*
|
|
55
|
+
* **Role.** Guards against runaway tool loops, misconfigured
|
|
56
|
+
* prompts, and unexpected provider price swings by capping
|
|
57
|
+
* cumulative usage across every LLM trip of a single execution.
|
|
58
|
+
* Aborts the run with a typed `BudgetExceededError` the moment a cap
|
|
59
|
+
* is breached, rather than letting the damage grow trip by trip.
|
|
60
|
+
*
|
|
61
|
+
* **Scope.** Per-execution. A fresh counter is created at
|
|
62
|
+
* `execute.before` and lives in the middleware state bag until the
|
|
63
|
+
* run ends. Two concurrent `agent.execute()` calls on the same
|
|
64
|
+
* agent therefore enforce the cap independently.
|
|
65
|
+
*
|
|
66
|
+
* **Token accounting.** After each successful trip, the middleware
|
|
67
|
+
* adds `response.usage.total` to its running total and checks
|
|
68
|
+
* against `maxTokens`. Synthetic trips (cache hits) contribute
|
|
69
|
+
* `usage.total` as returned by the cache — cache middleware is
|
|
70
|
+
* expected to surface zero usage on a hit, which naturally excludes
|
|
71
|
+
* those trips from the budget.
|
|
72
|
+
*
|
|
73
|
+
* **USD accounting.** When `maxCostUSD` + `pricing[modelName]` are
|
|
74
|
+
* both present, the middleware converts per-trip input / output
|
|
75
|
+
* tokens to USD and accumulates. Missing pricing silently degrades
|
|
76
|
+
* to tokens-only — explicit rather than guessing.
|
|
77
|
+
*
|
|
78
|
+
* **Warn mode.** `onExceeded: "warn"` logs a single warning the first
|
|
79
|
+
* time a cap is breached and lets the run continue. Useful for
|
|
80
|
+
* measuring real-world traffic against a proposed cap before flipping
|
|
81
|
+
* to `"abort"` in production.
|
|
82
|
+
*
|
|
83
|
+
* @example
|
|
84
|
+
* const budgetMiddleware = budget({ maxTokens: 50_000 });
|
|
85
|
+
*
|
|
86
|
+
* const myAgent = agent({
|
|
87
|
+
* model,
|
|
88
|
+
* middleware: [budgetMiddleware],
|
|
89
|
+
* });
|
|
90
|
+
*
|
|
91
|
+
* @example
|
|
92
|
+
* // With USD cap and custom pricing
|
|
93
|
+
* const guard = budget({
|
|
94
|
+
* maxCostUSD: 0.5,
|
|
95
|
+
* pricing: {
|
|
96
|
+
* "gpt-4o": { inputPer1K: 0.005, outputPer1K: 0.015 },
|
|
97
|
+
* },
|
|
98
|
+
* });
|
|
99
|
+
*/
|
|
100
|
+
declare function budget(options: BudgetOptions): AgentMiddleware;
|
|
101
|
+
//#endregion
|
|
102
|
+
export { BudgetOptions, BudgetPricing, budget };
|
|
103
|
+
//# sourceMappingURL=budget.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"budget.d.mts","names":[],"sources":["../../../../../../../@warlock.js/ai/src/middleware/builtins/budget.ts"],"mappings":";;;;;AAWA;;;;KAAY,aAAA,GAAgB,MAAM;EAI9B,kCAAA,UAAA,UAEW;EAAX,WAAA;AAAA;;;;;KAQQ,aAAA;EAkBV;;;;;EAZA,SAAA;EA+Fc;;;;;EAzFd,UAAA;EAyF8C;;AAAe;;;EAnF7D,OAAA,GAAU,aAAa;;;;;;;;EAQvB,UAAA;;;;;;EAMA,IAAA;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAqEc,MAAA,CAAO,OAAA,EAAS,aAAA,GAAgB,eAAe"}
|