@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,45 @@
|
|
|
1
|
+
import { ErrorCategory } from "./error-category.type.mjs";
|
|
2
|
+
import { AIErrorOptions } from "./ai-error.mjs";
|
|
3
|
+
import { AgentExecutionError } from "./agent-execution-error.mjs";
|
|
4
|
+
|
|
5
|
+
//#region ../../@warlock.js/ai/src/errors/agent-max-trips-error.d.ts
|
|
6
|
+
/**
|
|
7
|
+
* Payload for {@link AgentMaxTripsError}. `maxTrips` is the cap the
|
|
8
|
+
* agent hit — useful for log/metric attribution and for retry-with-
|
|
9
|
+
* higher-cap recovery strategies.
|
|
10
|
+
*/
|
|
11
|
+
type AgentMaxTripsErrorOptions = AIErrorOptions & {
|
|
12
|
+
maxTrips: number;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Runaway-loop hard guard: the agent's trip loop ran `maxTrips` round
|
|
16
|
+
* trips to the model without the model issuing a natural stop. The
|
|
17
|
+
* loop terminates with this typed error on `result.error` and the
|
|
18
|
+
* full trip history preserved in `result.report.trips` so consumers
|
|
19
|
+
* can see where the loop got stuck.
|
|
20
|
+
*
|
|
21
|
+
* **Not retryable by default.** A run that hit the cap usually
|
|
22
|
+
* indicates either a tool the agent can't satisfy (causing infinite
|
|
23
|
+
* re-asks) or a model that won't commit to an answer. Bumping
|
|
24
|
+
* `maxTrips` and retrying without root-causing the underlying issue
|
|
25
|
+
* just burns more tokens.
|
|
26
|
+
*
|
|
27
|
+
* **Why split from `AgentExecutionError`.** The catch-all base wears
|
|
28
|
+
* too many hats — cancellation vs. max-trips vs. generic crashes had
|
|
29
|
+
* to be disambiguated from `context` flags or message regex. Split
|
|
30
|
+
* subclasses let category dispatch (`"max-trips"`) and consumer
|
|
31
|
+
* branching (`instanceof`) work without inference.
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* if (result.error instanceof AgentMaxTripsError) {
|
|
35
|
+
* logger.warn("agent hit trip cap", { max: result.error.maxTrips });
|
|
36
|
+
* }
|
|
37
|
+
*/
|
|
38
|
+
declare class AgentMaxTripsError extends AgentExecutionError {
|
|
39
|
+
static readonly defaultCategory: ErrorCategory;
|
|
40
|
+
readonly maxTrips: number;
|
|
41
|
+
constructor(message: string, options: AgentMaxTripsErrorOptions);
|
|
42
|
+
}
|
|
43
|
+
//#endregion
|
|
44
|
+
export { AgentMaxTripsError, AgentMaxTripsErrorOptions };
|
|
45
|
+
//# sourceMappingURL=agent-max-trips-error.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-max-trips-error.d.mts","names":[],"sources":["../../../../../../@warlock.js/ai/src/errors/agent-max-trips-error.ts"],"mappings":";;;;;;;AASA;;;KAAY,yBAAA,GAA4B,cAAc;EACpD,QAAQ;AAAA;;;;;;;;;;;;;;;;;AAgC8D;;;;;;;;cAL3D,kBAAA,SAA2B,mBAAA;EAAA,gBACf,eAAA,EAAiB,aAAA;EAAA,SAExB,QAAA;cAEG,OAAA,UAAiB,OAAA,EAAS,yBAAA;AAAA"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { AgentExecutionError } from "./agent-execution-error.mjs";
|
|
2
|
+
|
|
3
|
+
//#region ../../@warlock.js/ai/src/errors/agent-max-trips-error.ts
|
|
4
|
+
/**
|
|
5
|
+
* Runaway-loop hard guard: the agent's trip loop ran `maxTrips` round
|
|
6
|
+
* trips to the model without the model issuing a natural stop. The
|
|
7
|
+
* loop terminates with this typed error on `result.error` and the
|
|
8
|
+
* full trip history preserved in `result.report.trips` so consumers
|
|
9
|
+
* can see where the loop got stuck.
|
|
10
|
+
*
|
|
11
|
+
* **Not retryable by default.** A run that hit the cap usually
|
|
12
|
+
* indicates either a tool the agent can't satisfy (causing infinite
|
|
13
|
+
* re-asks) or a model that won't commit to an answer. Bumping
|
|
14
|
+
* `maxTrips` and retrying without root-causing the underlying issue
|
|
15
|
+
* just burns more tokens.
|
|
16
|
+
*
|
|
17
|
+
* **Why split from `AgentExecutionError`.** The catch-all base wears
|
|
18
|
+
* too many hats — cancellation vs. max-trips vs. generic crashes had
|
|
19
|
+
* to be disambiguated from `context` flags or message regex. Split
|
|
20
|
+
* subclasses let category dispatch (`"max-trips"`) and consumer
|
|
21
|
+
* branching (`instanceof`) work without inference.
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* if (result.error instanceof AgentMaxTripsError) {
|
|
25
|
+
* logger.warn("agent hit trip cap", { max: result.error.maxTrips });
|
|
26
|
+
* }
|
|
27
|
+
*/
|
|
28
|
+
var AgentMaxTripsError = class extends AgentExecutionError {
|
|
29
|
+
static {
|
|
30
|
+
this.defaultCategory = "max-trips";
|
|
31
|
+
}
|
|
32
|
+
constructor(message, options) {
|
|
33
|
+
super(message, options, "AGENT_MAX_TRIPS");
|
|
34
|
+
this.name = "AgentMaxTripsError";
|
|
35
|
+
this.maxTrips = options.maxTrips;
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
//#endregion
|
|
40
|
+
export { AgentMaxTripsError };
|
|
41
|
+
//# sourceMappingURL=agent-max-trips-error.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-max-trips-error.mjs","names":[],"sources":["../../../../../../@warlock.js/ai/src/errors/agent-max-trips-error.ts"],"sourcesContent":["import { AgentExecutionError } from \"./agent-execution-error\";\nimport type { AIErrorOptions } from \"./ai-error\";\nimport type { ErrorCategory } from \"./error-category.type\";\n\n/**\n * Payload for {@link AgentMaxTripsError}. `maxTrips` is the cap the\n * agent hit — useful for log/metric attribution and for retry-with-\n * higher-cap recovery strategies.\n */\nexport type AgentMaxTripsErrorOptions = AIErrorOptions & {\n maxTrips: number;\n};\n\n/**\n * Runaway-loop hard guard: the agent's trip loop ran `maxTrips` round\n * trips to the model without the model issuing a natural stop. The\n * loop terminates with this typed error on `result.error` and the\n * full trip history preserved in `result.report.trips` so consumers\n * can see where the loop got stuck.\n *\n * **Not retryable by default.** A run that hit the cap usually\n * indicates either a tool the agent can't satisfy (causing infinite\n * re-asks) or a model that won't commit to an answer. Bumping\n * `maxTrips` and retrying without root-causing the underlying issue\n * just burns more tokens.\n *\n * **Why split from `AgentExecutionError`.** The catch-all base wears\n * too many hats — cancellation vs. max-trips vs. generic crashes had\n * to be disambiguated from `context` flags or message regex. Split\n * subclasses let category dispatch (`\"max-trips\"`) and consumer\n * branching (`instanceof`) work without inference.\n *\n * @example\n * if (result.error instanceof AgentMaxTripsError) {\n * logger.warn(\"agent hit trip cap\", { max: result.error.maxTrips });\n * }\n */\nexport class AgentMaxTripsError extends AgentExecutionError {\n public static readonly defaultCategory: ErrorCategory = \"max-trips\";\n\n public readonly maxTrips: number;\n\n public constructor(message: string, options: AgentMaxTripsErrorOptions) {\n super(message, options, \"AGENT_MAX_TRIPS\");\n this.name = \"AgentMaxTripsError\";\n this.maxTrips = options.maxTrips;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAqCA,IAAa,qBAAb,cAAwC,oBAAoB;;yBACF;;CAIxD,AAAO,YAAY,SAAiB,SAAoC;EACtE,MAAM,SAAS,SAAS,iBAAiB;EACzC,KAAK,OAAO;EACZ,KAAK,WAAW,QAAQ;CAC1B;AACF"}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { ErrorCategory } from "./error-category.type.mjs";
|
|
2
|
+
import { AIErrorCode } from "./error-code.type.mjs";
|
|
3
|
+
|
|
4
|
+
//#region ../../@warlock.js/ai/src/errors/ai-error.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* Optional constructor payload shared by every `AIError` subclass.
|
|
7
|
+
*
|
|
8
|
+
* `cause` carries the original thrown value (SDK error, runtime crash,
|
|
9
|
+
* validation failure) so downstream logging and debuggers can still
|
|
10
|
+
* reach it. `context` is a free-form diagnostic bag for provider-raw
|
|
11
|
+
* metadata (status codes, request ids, response headers) that shouldn't
|
|
12
|
+
* be promoted to typed fields but is useful in logs and telemetry.
|
|
13
|
+
*
|
|
14
|
+
* **No `category` here.** Category is fixed per subclass via the
|
|
15
|
+
* class-level `static defaultCategory`. Subclasses ARE their
|
|
16
|
+
* category — `RateLimitError` is always `"rate-limit"`, never
|
|
17
|
+
* something else at runtime. Direct `new AIError(...)` callers (the
|
|
18
|
+
* one legitimate override case, since the base catch-all has no
|
|
19
|
+
* specific class) receive a separate 4th constructor argument
|
|
20
|
+
* instead, so the override is structurally unreachable from subclass
|
|
21
|
+
* call sites.
|
|
22
|
+
*/
|
|
23
|
+
type AIErrorOptions = {
|
|
24
|
+
cause?: unknown;
|
|
25
|
+
context?: Record<string, unknown>;
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* Base class for every error thrown (or surfaced via `result.error`) by
|
|
29
|
+
* `@warlock.js/ai` and its provider adapter packages.
|
|
30
|
+
*
|
|
31
|
+
* **Role.** The single typed error contract across the AI framework.
|
|
32
|
+
* Every thrown error anywhere in `@warlock.js/ai*` is either an
|
|
33
|
+
* `AIError` itself or one of its subclasses — plain `Error` must never
|
|
34
|
+
* leak out. Consumers branch either on the narrow `error.code` (stable
|
|
35
|
+
* string), on `error.category` (coarse dashboard grouping), or on
|
|
36
|
+
* `instanceof` a specific subclass.
|
|
37
|
+
*
|
|
38
|
+
* **Independence.** Deliberately extends the platform `Error` directly
|
|
39
|
+
* — never `HttpError` from `@warlock.js/core`. The AI framework is a
|
|
40
|
+
* standalone product; coupling its error base to a web framework would
|
|
41
|
+
* force every consumer to pull in the HTTP layer even when they only
|
|
42
|
+
* use AI in a CLI, worker, or test.
|
|
43
|
+
*
|
|
44
|
+
* **Fields.**
|
|
45
|
+
* - `code` — stable machine-readable identifier (see `AIErrorCode`).
|
|
46
|
+
* - `category` — coarse `ErrorCategory` for dashboards / retry policy.
|
|
47
|
+
* Resolved at construction from the subclass's `static defaultCategory`
|
|
48
|
+
* (or, for direct `new AIError(...)` calls, from the explicit 4th
|
|
49
|
+
* constructor argument).
|
|
50
|
+
* - `cause` — optional original thrown value (SDK error, nested error,
|
|
51
|
+
* raw value). Preserves root cause through re-wrapping.
|
|
52
|
+
* - `context` — optional free-form diagnostic bag (status, requestId,
|
|
53
|
+
* headers). Consumers treat it as opaque; logs and telemetry read it.
|
|
54
|
+
*
|
|
55
|
+
* **Category override — direct AIError usage only.** Subclasses ARE
|
|
56
|
+
* their category by type; there's no legitimate runtime override at
|
|
57
|
+
* the subclass level. The 4th constructor argument exists ONLY for
|
|
58
|
+
* direct `new AIError(...)` callers, who would otherwise be stuck with
|
|
59
|
+
* the `"unknown"` default. Subclasses construct via `super(code,
|
|
60
|
+
* message, options)` and physically cannot reach the override slot
|
|
61
|
+
* through their own typed signatures.
|
|
62
|
+
*
|
|
63
|
+
* @example
|
|
64
|
+
* try {
|
|
65
|
+
* await agent.execute("hello");
|
|
66
|
+
* } catch (error) {
|
|
67
|
+
* if (error instanceof AIError) {
|
|
68
|
+
* console.error(`[${error.code}] (${error.category}) ${error.message}`);
|
|
69
|
+
* }
|
|
70
|
+
* }
|
|
71
|
+
*
|
|
72
|
+
* @example
|
|
73
|
+
* // Direct AIError construction with explicit category — escape hatch
|
|
74
|
+
* // for call sites that lack a specific subclass.
|
|
75
|
+
* throw new AIError("UNEXPECTED", "transient glitch", undefined, "provider");
|
|
76
|
+
*/
|
|
77
|
+
declare class AIError extends Error {
|
|
78
|
+
/**
|
|
79
|
+
* Class-level category for every instance of this error type.
|
|
80
|
+
* Subclasses redeclare with their own concrete `ErrorCategory` so
|
|
81
|
+
* `error.category` is correct without per-call wiring. The base
|
|
82
|
+
* class keeps `"unknown"` so untyped direct throws of `AIError`
|
|
83
|
+
* itself remain honest about their lack of dispatch information
|
|
84
|
+
* (and can override via the 4th constructor argument).
|
|
85
|
+
*/
|
|
86
|
+
static readonly defaultCategory: ErrorCategory;
|
|
87
|
+
readonly code: AIErrorCode;
|
|
88
|
+
readonly category: ErrorCategory;
|
|
89
|
+
readonly context?: Record<string, unknown>;
|
|
90
|
+
constructor(code: AIErrorCode, message: string, options?: AIErrorOptions, category?: ErrorCategory);
|
|
91
|
+
}
|
|
92
|
+
//#endregion
|
|
93
|
+
export { AIError, AIErrorOptions };
|
|
94
|
+
//# sourceMappingURL=ai-error.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ai-error.d.mts","names":[],"sources":["../../../../../../@warlock.js/ai/src/errors/ai-error.ts"],"mappings":";;;;;;AAqBA;;;;;;;;AAEkB;AAqDlB;;;;;;;KAvDY,cAAA;EACV,KAAA;EACA,OAAA,GAAU,MAAM;AAAA;;;;;;;;;;;;;;;;;;;;;AAwEU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAnBf,OAAA,SAAgB,KAAA;;;;;;;;;kBASJ,eAAA,EAAiB,aAAA;EAAA,SAExB,IAAA,EAAM,WAAA;EAAA,SACN,QAAA,EAAU,aAAA;EAAA,SACV,OAAA,GAAU,MAAA;cAGxB,IAAA,EAAM,WAAA,EACN,OAAA,UACA,OAAA,GAAU,cAAA,EACV,QAAA,GAAW,aAAA;AAAA"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
//#region ../../@warlock.js/ai/src/errors/ai-error.ts
|
|
2
|
+
/**
|
|
3
|
+
* Base class for every error thrown (or surfaced via `result.error`) by
|
|
4
|
+
* `@warlock.js/ai` and its provider adapter packages.
|
|
5
|
+
*
|
|
6
|
+
* **Role.** The single typed error contract across the AI framework.
|
|
7
|
+
* Every thrown error anywhere in `@warlock.js/ai*` is either an
|
|
8
|
+
* `AIError` itself or one of its subclasses — plain `Error` must never
|
|
9
|
+
* leak out. Consumers branch either on the narrow `error.code` (stable
|
|
10
|
+
* string), on `error.category` (coarse dashboard grouping), or on
|
|
11
|
+
* `instanceof` a specific subclass.
|
|
12
|
+
*
|
|
13
|
+
* **Independence.** Deliberately extends the platform `Error` directly
|
|
14
|
+
* — never `HttpError` from `@warlock.js/core`. The AI framework is a
|
|
15
|
+
* standalone product; coupling its error base to a web framework would
|
|
16
|
+
* force every consumer to pull in the HTTP layer even when they only
|
|
17
|
+
* use AI in a CLI, worker, or test.
|
|
18
|
+
*
|
|
19
|
+
* **Fields.**
|
|
20
|
+
* - `code` — stable machine-readable identifier (see `AIErrorCode`).
|
|
21
|
+
* - `category` — coarse `ErrorCategory` for dashboards / retry policy.
|
|
22
|
+
* Resolved at construction from the subclass's `static defaultCategory`
|
|
23
|
+
* (or, for direct `new AIError(...)` calls, from the explicit 4th
|
|
24
|
+
* constructor argument).
|
|
25
|
+
* - `cause` — optional original thrown value (SDK error, nested error,
|
|
26
|
+
* raw value). Preserves root cause through re-wrapping.
|
|
27
|
+
* - `context` — optional free-form diagnostic bag (status, requestId,
|
|
28
|
+
* headers). Consumers treat it as opaque; logs and telemetry read it.
|
|
29
|
+
*
|
|
30
|
+
* **Category override — direct AIError usage only.** Subclasses ARE
|
|
31
|
+
* their category by type; there's no legitimate runtime override at
|
|
32
|
+
* the subclass level. The 4th constructor argument exists ONLY for
|
|
33
|
+
* direct `new AIError(...)` callers, who would otherwise be stuck with
|
|
34
|
+
* the `"unknown"` default. Subclasses construct via `super(code,
|
|
35
|
+
* message, options)` and physically cannot reach the override slot
|
|
36
|
+
* through their own typed signatures.
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* try {
|
|
40
|
+
* await agent.execute("hello");
|
|
41
|
+
* } catch (error) {
|
|
42
|
+
* if (error instanceof AIError) {
|
|
43
|
+
* console.error(`[${error.code}] (${error.category}) ${error.message}`);
|
|
44
|
+
* }
|
|
45
|
+
* }
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* // Direct AIError construction with explicit category — escape hatch
|
|
49
|
+
* // for call sites that lack a specific subclass.
|
|
50
|
+
* throw new AIError("UNEXPECTED", "transient glitch", undefined, "provider");
|
|
51
|
+
*/
|
|
52
|
+
var AIError = class extends Error {
|
|
53
|
+
static {
|
|
54
|
+
this.defaultCategory = "unknown";
|
|
55
|
+
}
|
|
56
|
+
constructor(code, message, options, category) {
|
|
57
|
+
super(message);
|
|
58
|
+
this.name = "AIError";
|
|
59
|
+
this.code = code;
|
|
60
|
+
this.context = options?.context;
|
|
61
|
+
this.category = category ?? this.constructor.defaultCategory;
|
|
62
|
+
if (options?.cause !== void 0) this.cause = options.cause;
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
//#endregion
|
|
67
|
+
export { AIError };
|
|
68
|
+
//# sourceMappingURL=ai-error.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ai-error.mjs","names":[],"sources":["../../../../../../@warlock.js/ai/src/errors/ai-error.ts"],"sourcesContent":["import type { ErrorCategory } from \"./error-category.type\";\nimport type { AIErrorCode } from \"./error-code.type\";\n\n/**\n * Optional constructor payload shared by every `AIError` subclass.\n *\n * `cause` carries the original thrown value (SDK error, runtime crash,\n * validation failure) so downstream logging and debuggers can still\n * reach it. `context` is a free-form diagnostic bag for provider-raw\n * metadata (status codes, request ids, response headers) that shouldn't\n * be promoted to typed fields but is useful in logs and telemetry.\n *\n * **No `category` here.** Category is fixed per subclass via the\n * class-level `static defaultCategory`. Subclasses ARE their\n * category — `RateLimitError` is always `\"rate-limit\"`, never\n * something else at runtime. Direct `new AIError(...)` callers (the\n * one legitimate override case, since the base catch-all has no\n * specific class) receive a separate 4th constructor argument\n * instead, so the override is structurally unreachable from subclass\n * call sites.\n */\nexport type AIErrorOptions = {\n cause?: unknown;\n context?: Record<string, unknown>;\n};\n\n/**\n * Base class for every error thrown (or surfaced via `result.error`) by\n * `@warlock.js/ai` and its provider adapter packages.\n *\n * **Role.** The single typed error contract across the AI framework.\n * Every thrown error anywhere in `@warlock.js/ai*` is either an\n * `AIError` itself or one of its subclasses — plain `Error` must never\n * leak out. Consumers branch either on the narrow `error.code` (stable\n * string), on `error.category` (coarse dashboard grouping), or on\n * `instanceof` a specific subclass.\n *\n * **Independence.** Deliberately extends the platform `Error` directly\n * — never `HttpError` from `@warlock.js/core`. The AI framework is a\n * standalone product; coupling its error base to a web framework would\n * force every consumer to pull in the HTTP layer even when they only\n * use AI in a CLI, worker, or test.\n *\n * **Fields.**\n * - `code` — stable machine-readable identifier (see `AIErrorCode`).\n * - `category` — coarse `ErrorCategory` for dashboards / retry policy.\n * Resolved at construction from the subclass's `static defaultCategory`\n * (or, for direct `new AIError(...)` calls, from the explicit 4th\n * constructor argument).\n * - `cause` — optional original thrown value (SDK error, nested error,\n * raw value). Preserves root cause through re-wrapping.\n * - `context` — optional free-form diagnostic bag (status, requestId,\n * headers). Consumers treat it as opaque; logs and telemetry read it.\n *\n * **Category override — direct AIError usage only.** Subclasses ARE\n * their category by type; there's no legitimate runtime override at\n * the subclass level. The 4th constructor argument exists ONLY for\n * direct `new AIError(...)` callers, who would otherwise be stuck with\n * the `\"unknown\"` default. Subclasses construct via `super(code,\n * message, options)` and physically cannot reach the override slot\n * through their own typed signatures.\n *\n * @example\n * try {\n * await agent.execute(\"hello\");\n * } catch (error) {\n * if (error instanceof AIError) {\n * console.error(`[${error.code}] (${error.category}) ${error.message}`);\n * }\n * }\n *\n * @example\n * // Direct AIError construction with explicit category — escape hatch\n * // for call sites that lack a specific subclass.\n * throw new AIError(\"UNEXPECTED\", \"transient glitch\", undefined, \"provider\");\n */\nexport class AIError extends Error {\n /**\n * Class-level category for every instance of this error type.\n * Subclasses redeclare with their own concrete `ErrorCategory` so\n * `error.category` is correct without per-call wiring. The base\n * class keeps `\"unknown\"` so untyped direct throws of `AIError`\n * itself remain honest about their lack of dispatch information\n * (and can override via the 4th constructor argument).\n */\n public static readonly defaultCategory: ErrorCategory = \"unknown\";\n\n public readonly code: AIErrorCode;\n public readonly category: ErrorCategory;\n public readonly context?: Record<string, unknown>;\n\n public constructor(\n code: AIErrorCode,\n message: string,\n options?: AIErrorOptions,\n category?: ErrorCategory,\n ) {\n super(message);\n\n this.name = \"AIError\";\n this.code = code;\n this.context = options?.context;\n this.category = category ?? (this.constructor as typeof AIError).defaultCategory;\n\n if (options?.cause !== undefined) {\n (this as { cause?: unknown }).cause = options.cause;\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4EA,IAAa,UAAb,cAA6B,MAAM;;yBASuB;;CAMxD,AAAO,YACL,MACA,SACA,SACA,UACA;EACA,MAAM,OAAO;EAEb,KAAK,OAAO;EACZ,KAAK,OAAO;EACZ,KAAK,UAAU,SAAS;EACxB,KAAK,WAAW,YAAa,KAAK,YAA+B;EAEjE,IAAI,SAAS,UAAU,QACrB,AAAC,KAA6B,QAAQ,QAAQ;CAElD;AACF"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { ErrorCategory } from "./error-category.type.mjs";
|
|
2
|
+
import { AIError, AIErrorOptions } from "./ai-error.mjs";
|
|
3
|
+
|
|
4
|
+
//#region ../../@warlock.js/ai/src/errors/budget-exceeded-error.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* Unit of the budget being enforced. `tokens` for context/output
|
|
7
|
+
* caps, `usd` for monetary caps, `requests` for call-count caps.
|
|
8
|
+
*/
|
|
9
|
+
type BudgetUnit = "tokens" | "usd" | "requests";
|
|
10
|
+
/**
|
|
11
|
+
* Payload for `BudgetExceededError`. All three fields are required so
|
|
12
|
+
* consumers can present the breach numerically without having to
|
|
13
|
+
* reparse the message.
|
|
14
|
+
*/
|
|
15
|
+
type BudgetExceededErrorOptions = AIErrorOptions & {
|
|
16
|
+
limit: number;
|
|
17
|
+
actual: number;
|
|
18
|
+
unit: BudgetUnit;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* A user- or framework-configured budget was exceeded mid-execution.
|
|
22
|
+
*
|
|
23
|
+
* **Not thrown yet.** The class is defined here so v2's budget
|
|
24
|
+
* middleware can throw it without a breaking release of the error
|
|
25
|
+
* hierarchy. Shape is locked: `{ limit, actual, unit }`.
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* if (error instanceof BudgetExceededError && error.unit === "usd") {
|
|
29
|
+
* alertFinance(error.actual, error.limit);
|
|
30
|
+
* }
|
|
31
|
+
*/
|
|
32
|
+
declare class BudgetExceededError extends AIError {
|
|
33
|
+
static readonly defaultCategory: ErrorCategory;
|
|
34
|
+
readonly limit: number;
|
|
35
|
+
readonly actual: number;
|
|
36
|
+
readonly unit: BudgetUnit;
|
|
37
|
+
constructor(message: string, options: BudgetExceededErrorOptions);
|
|
38
|
+
}
|
|
39
|
+
//#endregion
|
|
40
|
+
export { BudgetExceededError, BudgetExceededErrorOptions, BudgetUnit };
|
|
41
|
+
//# sourceMappingURL=budget-exceeded-error.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"budget-exceeded-error.d.mts","names":[],"sources":["../../../../../../@warlock.js/ai/src/errors/budget-exceeded-error.ts"],"mappings":";;;;;;AAOA;;KAAY,UAAA;;AAAU;AAOtB;;;KAAY,0BAAA,GAA6B,cAAA;EACvC,KAAA;EACA,MAAA;EACA,IAAA,EAAM,UAAU;AAAA;;;AAAA;AAelB;;;;;;;;;cAAa,mBAAA,SAA4B,OAAA;EAAA,gBAChB,eAAA,EAAiB,aAAA;EAAA,SAExB,KAAA;EAAA,SACA,MAAA;EAAA,SACA,IAAA,EAAM,UAAA;cAEH,OAAA,UAAiB,OAAA,EAAS,0BAAA;AAAA"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { AIError } from "./ai-error.mjs";
|
|
2
|
+
|
|
3
|
+
//#region ../../@warlock.js/ai/src/errors/budget-exceeded-error.ts
|
|
4
|
+
/**
|
|
5
|
+
* A user- or framework-configured budget was exceeded mid-execution.
|
|
6
|
+
*
|
|
7
|
+
* **Not thrown yet.** The class is defined here so v2's budget
|
|
8
|
+
* middleware can throw it without a breaking release of the error
|
|
9
|
+
* hierarchy. Shape is locked: `{ limit, actual, unit }`.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* if (error instanceof BudgetExceededError && error.unit === "usd") {
|
|
13
|
+
* alertFinance(error.actual, error.limit);
|
|
14
|
+
* }
|
|
15
|
+
*/
|
|
16
|
+
var BudgetExceededError = class extends AIError {
|
|
17
|
+
static {
|
|
18
|
+
this.defaultCategory = "budget";
|
|
19
|
+
}
|
|
20
|
+
constructor(message, options) {
|
|
21
|
+
super("BUDGET_EXCEEDED", message, options);
|
|
22
|
+
this.name = "BudgetExceededError";
|
|
23
|
+
this.limit = options.limit;
|
|
24
|
+
this.actual = options.actual;
|
|
25
|
+
this.unit = options.unit;
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
//#endregion
|
|
30
|
+
export { BudgetExceededError };
|
|
31
|
+
//# sourceMappingURL=budget-exceeded-error.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"budget-exceeded-error.mjs","names":[],"sources":["../../../../../../@warlock.js/ai/src/errors/budget-exceeded-error.ts"],"sourcesContent":["import { AIError, type AIErrorOptions } from \"./ai-error\";\nimport type { ErrorCategory } from \"./error-category.type\";\n\n/**\n * Unit of the budget being enforced. `tokens` for context/output\n * caps, `usd` for monetary caps, `requests` for call-count caps.\n */\nexport type BudgetUnit = \"tokens\" | \"usd\" | \"requests\";\n\n/**\n * Payload for `BudgetExceededError`. All three fields are required so\n * consumers can present the breach numerically without having to\n * reparse the message.\n */\nexport type BudgetExceededErrorOptions = AIErrorOptions & {\n limit: number;\n actual: number;\n unit: BudgetUnit;\n};\n\n/**\n * A user- or framework-configured budget was exceeded mid-execution.\n *\n * **Not thrown yet.** The class is defined here so v2's budget\n * middleware can throw it without a breaking release of the error\n * hierarchy. Shape is locked: `{ limit, actual, unit }`.\n *\n * @example\n * if (error instanceof BudgetExceededError && error.unit === \"usd\") {\n * alertFinance(error.actual, error.limit);\n * }\n */\nexport class BudgetExceededError extends AIError {\n public static readonly defaultCategory: ErrorCategory = \"budget\";\n\n public readonly limit: number;\n public readonly actual: number;\n public readonly unit: BudgetUnit;\n\n public constructor(message: string, options: BudgetExceededErrorOptions) {\n super(\"BUDGET_EXCEEDED\", message, options);\n this.name = \"BudgetExceededError\";\n this.limit = options.limit;\n this.actual = options.actual;\n this.unit = options.unit;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;AAgCA,IAAa,sBAAb,cAAyC,QAAQ;;yBACS;;CAMxD,AAAO,YAAY,SAAiB,SAAqC;EACvE,MAAM,mBAAmB,SAAS,OAAO;EACzC,KAAK,OAAO;EACZ,KAAK,QAAQ,QAAQ;EACrB,KAAK,SAAS,QAAQ;EACtB,KAAK,OAAO,QAAQ;CACtB;AACF"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { ErrorCategory } from "./error-category.type.mjs";
|
|
2
|
+
import { AIErrorOptions } from "./ai-error.mjs";
|
|
3
|
+
import { ProviderError } from "./provider-error.mjs";
|
|
4
|
+
|
|
5
|
+
//#region ../../@warlock.js/ai/src/errors/content-filter-error.d.ts
|
|
6
|
+
/**
|
|
7
|
+
* Payload for `ContentFilterError`. Both fields optional — providers
|
|
8
|
+
* don't consistently disclose the specific filter reason or
|
|
9
|
+
* categories, especially when the block is pre-generation.
|
|
10
|
+
*/
|
|
11
|
+
type ContentFilterErrorOptions = AIErrorOptions & {
|
|
12
|
+
reason?: string;
|
|
13
|
+
categories?: string[];
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Response (or request) was blocked by the provider's safety filter.
|
|
17
|
+
* Not retryable with the same input — reshape the prompt or lean on
|
|
18
|
+
* a less-restrictive model.
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* if (result.error instanceof ContentFilterError) {
|
|
22
|
+
* return respondWithPolicyMessage(result.error.reason);
|
|
23
|
+
* }
|
|
24
|
+
*/
|
|
25
|
+
declare class ContentFilterError extends ProviderError {
|
|
26
|
+
static readonly defaultCategory: ErrorCategory;
|
|
27
|
+
readonly reason?: string;
|
|
28
|
+
readonly categories?: string[];
|
|
29
|
+
constructor(message: string, options?: ContentFilterErrorOptions);
|
|
30
|
+
}
|
|
31
|
+
//#endregion
|
|
32
|
+
export { ContentFilterError, ContentFilterErrorOptions };
|
|
33
|
+
//# sourceMappingURL=content-filter-error.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"content-filter-error.d.mts","names":[],"sources":["../../../../../../@warlock.js/ai/src/errors/content-filter-error.ts"],"mappings":";;;;;;;AASA;;;KAAY,yBAAA,GAA4B,cAAc;EACpD,MAAA;EACA,UAAA;AAAA;;AAAU;AAaZ;;;;;;;;cAAa,kBAAA,SAA2B,aAAA;EAAA,gBACf,eAAA,EAAiB,aAAA;EAAA,SAExB,MAAA;EAAA,SACA,UAAA;cAEG,OAAA,UAAiB,OAAA,GAAU,yBAAA;AAAA"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { ProviderError } from "./provider-error.mjs";
|
|
2
|
+
|
|
3
|
+
//#region ../../@warlock.js/ai/src/errors/content-filter-error.ts
|
|
4
|
+
/**
|
|
5
|
+
* Response (or request) was blocked by the provider's safety filter.
|
|
6
|
+
* Not retryable with the same input — reshape the prompt or lean on
|
|
7
|
+
* a less-restrictive model.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* if (result.error instanceof ContentFilterError) {
|
|
11
|
+
* return respondWithPolicyMessage(result.error.reason);
|
|
12
|
+
* }
|
|
13
|
+
*/
|
|
14
|
+
var ContentFilterError = class extends ProviderError {
|
|
15
|
+
static {
|
|
16
|
+
this.defaultCategory = "content-filter";
|
|
17
|
+
}
|
|
18
|
+
constructor(message, options) {
|
|
19
|
+
super(message, options, "CONTENT_FILTER");
|
|
20
|
+
this.name = "ContentFilterError";
|
|
21
|
+
this.reason = options?.reason;
|
|
22
|
+
this.categories = options?.categories;
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
//#endregion
|
|
27
|
+
export { ContentFilterError };
|
|
28
|
+
//# sourceMappingURL=content-filter-error.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"content-filter-error.mjs","names":[],"sources":["../../../../../../@warlock.js/ai/src/errors/content-filter-error.ts"],"sourcesContent":["import type { AIErrorOptions } from \"./ai-error\";\nimport type { ErrorCategory } from \"./error-category.type\";\nimport { ProviderError } from \"./provider-error\";\n\n/**\n * Payload for `ContentFilterError`. Both fields optional — providers\n * don't consistently disclose the specific filter reason or\n * categories, especially when the block is pre-generation.\n */\nexport type ContentFilterErrorOptions = AIErrorOptions & {\n reason?: string;\n categories?: string[];\n};\n\n/**\n * Response (or request) was blocked by the provider's safety filter.\n * Not retryable with the same input — reshape the prompt or lean on\n * a less-restrictive model.\n *\n * @example\n * if (result.error instanceof ContentFilterError) {\n * return respondWithPolicyMessage(result.error.reason);\n * }\n */\nexport class ContentFilterError extends ProviderError {\n public static readonly defaultCategory: ErrorCategory = \"content-filter\";\n\n public readonly reason?: string;\n public readonly categories?: string[];\n\n public constructor(message: string, options?: ContentFilterErrorOptions) {\n super(message, options, \"CONTENT_FILTER\");\n this.name = \"ContentFilterError\";\n this.reason = options?.reason;\n this.categories = options?.categories;\n }\n}\n"],"mappings":";;;;;;;;;;;;;AAwBA,IAAa,qBAAb,cAAwC,cAAc;;yBACI;;CAKxD,AAAO,YAAY,SAAiB,SAAqC;EACvE,MAAM,SAAS,SAAS,gBAAgB;EACxC,KAAK,OAAO;EACZ,KAAK,SAAS,SAAS;EACvB,KAAK,aAAa,SAAS;CAC7B;AACF"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { ErrorCategory } from "./error-category.type.mjs";
|
|
2
|
+
import { AIErrorOptions } from "./ai-error.mjs";
|
|
3
|
+
import { ProviderError } from "./provider-error.mjs";
|
|
4
|
+
|
|
5
|
+
//#region ../../@warlock.js/ai/src/errors/context-length-exceeded-error.d.ts
|
|
6
|
+
/**
|
|
7
|
+
* Payload for `ContextLengthExceededError`. All fields are optional —
|
|
8
|
+
* providers inconsistently surface exact token counts and the
|
|
9
|
+
* model's limit. When present, they let callers compute a trim
|
|
10
|
+
* target; when absent, the error still categorizes the failure.
|
|
11
|
+
*/
|
|
12
|
+
type ContextLengthExceededErrorOptions = AIErrorOptions & {
|
|
13
|
+
limit?: number;
|
|
14
|
+
actual?: number;
|
|
15
|
+
modelName?: string;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* The request's prompt (messages + tools + schema) exceeded the
|
|
19
|
+
* model's context window. Not retryable without shortening the input.
|
|
20
|
+
*
|
|
21
|
+
* Typically surfaced as OpenAI 400 with `code: "context_length_exceeded"`.
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* if (result.error instanceof ContextLengthExceededError) {
|
|
25
|
+
* messages = truncateOldestTurns(messages);
|
|
26
|
+
* return agent.execute(input, { history: messages });
|
|
27
|
+
* }
|
|
28
|
+
*/
|
|
29
|
+
declare class ContextLengthExceededError extends ProviderError {
|
|
30
|
+
static readonly defaultCategory: ErrorCategory;
|
|
31
|
+
readonly limit?: number;
|
|
32
|
+
readonly actual?: number;
|
|
33
|
+
readonly modelName?: string;
|
|
34
|
+
constructor(message: string, options?: ContextLengthExceededErrorOptions);
|
|
35
|
+
}
|
|
36
|
+
//#endregion
|
|
37
|
+
export { ContextLengthExceededError, ContextLengthExceededErrorOptions };
|
|
38
|
+
//# sourceMappingURL=context-length-exceeded-error.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context-length-exceeded-error.d.mts","names":[],"sources":["../../../../../../@warlock.js/ai/src/errors/context-length-exceeded-error.ts"],"mappings":";;;;;;;AAUA;;;;KAAY,iCAAA,GAAoC,cAAc;EAC5D,KAAA;EACA,MAAA;EACA,SAAA;AAAA;AAAS;AAeX;;;;;;;;;;;AAfW,cAeE,0BAAA,SAAmC,aAAA;EAAA,gBACvB,eAAA,EAAiB,aAAA;EAAA,SAExB,KAAA;EAAA,SACA,MAAA;EAAA,SACA,SAAA;cAGd,OAAA,UACA,OAAA,GAAU,iCAAA;AAAA"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { ProviderError } from "./provider-error.mjs";
|
|
2
|
+
|
|
3
|
+
//#region ../../@warlock.js/ai/src/errors/context-length-exceeded-error.ts
|
|
4
|
+
/**
|
|
5
|
+
* The request's prompt (messages + tools + schema) exceeded the
|
|
6
|
+
* model's context window. Not retryable without shortening the input.
|
|
7
|
+
*
|
|
8
|
+
* Typically surfaced as OpenAI 400 with `code: "context_length_exceeded"`.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* if (result.error instanceof ContextLengthExceededError) {
|
|
12
|
+
* messages = truncateOldestTurns(messages);
|
|
13
|
+
* return agent.execute(input, { history: messages });
|
|
14
|
+
* }
|
|
15
|
+
*/
|
|
16
|
+
var ContextLengthExceededError = class extends ProviderError {
|
|
17
|
+
static {
|
|
18
|
+
this.defaultCategory = "context-length";
|
|
19
|
+
}
|
|
20
|
+
constructor(message, options) {
|
|
21
|
+
super(message, options, "CONTEXT_LENGTH_EXCEEDED");
|
|
22
|
+
this.name = "ContextLengthExceededError";
|
|
23
|
+
this.limit = options?.limit;
|
|
24
|
+
this.actual = options?.actual;
|
|
25
|
+
this.modelName = options?.modelName;
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
//#endregion
|
|
30
|
+
export { ContextLengthExceededError };
|
|
31
|
+
//# sourceMappingURL=context-length-exceeded-error.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context-length-exceeded-error.mjs","names":[],"sources":["../../../../../../@warlock.js/ai/src/errors/context-length-exceeded-error.ts"],"sourcesContent":["import type { AIErrorOptions } from \"./ai-error\";\nimport type { ErrorCategory } from \"./error-category.type\";\nimport { ProviderError } from \"./provider-error\";\n\n/**\n * Payload for `ContextLengthExceededError`. All fields are optional —\n * providers inconsistently surface exact token counts and the\n * model's limit. When present, they let callers compute a trim\n * target; when absent, the error still categorizes the failure.\n */\nexport type ContextLengthExceededErrorOptions = AIErrorOptions & {\n limit?: number;\n actual?: number;\n modelName?: string;\n};\n\n/**\n * The request's prompt (messages + tools + schema) exceeded the\n * model's context window. Not retryable without shortening the input.\n *\n * Typically surfaced as OpenAI 400 with `code: \"context_length_exceeded\"`.\n *\n * @example\n * if (result.error instanceof ContextLengthExceededError) {\n * messages = truncateOldestTurns(messages);\n * return agent.execute(input, { history: messages });\n * }\n */\nexport class ContextLengthExceededError extends ProviderError {\n public static readonly defaultCategory: ErrorCategory = \"context-length\";\n\n public readonly limit?: number;\n public readonly actual?: number;\n public readonly modelName?: string;\n\n public constructor(\n message: string,\n options?: ContextLengthExceededErrorOptions,\n ) {\n super(message, options, \"CONTEXT_LENGTH_EXCEEDED\");\n this.name = \"ContextLengthExceededError\";\n this.limit = options?.limit;\n this.actual = options?.actual;\n this.modelName = options?.modelName;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;AA4BA,IAAa,6BAAb,cAAgD,cAAc;;yBACJ;;CAMxD,AAAO,YACL,SACA,SACA;EACA,MAAM,SAAS,SAAS,yBAAyB;EACjD,KAAK,OAAO;EACZ,KAAK,QAAQ,SAAS;EACtB,KAAK,SAAS,SAAS;EACvB,KAAK,YAAY,SAAS;CAC5B;AACF"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
//#region ../../@warlock.js/ai/src/errors/error-category.type.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Coarse error grouping for dashboards and routing logic. `code` is too
|
|
4
|
+
* granular for "what's failing this week" charts — the category union
|
|
5
|
+
* is the dispatch key that drives:
|
|
6
|
+
*
|
|
7
|
+
* - Panoptic / dashboard aggregations (pie chart of failures by
|
|
8
|
+
* category)
|
|
9
|
+
* - Retry policy (`rate-limit` → retry with backoff; `auth` → don't
|
|
10
|
+
* retry, escalate)
|
|
11
|
+
* - User-facing error mapping (`content-filter` → soft message;
|
|
12
|
+
* `provider` → "we're having issues, try again")
|
|
13
|
+
*
|
|
14
|
+
* Each `AIError` subclass declares its category via a `static
|
|
15
|
+
* defaultCategory` field, so the value is inherent to the error type
|
|
16
|
+
* rather than constructor-supplied — bugs that forget to set a
|
|
17
|
+
* category are caught at class-definition time, not at runtime. Direct
|
|
18
|
+
* `new AIError(...)` usages may pass `category` in options as an
|
|
19
|
+
* escape hatch.
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* if (error.category === "rate-limit") {
|
|
23
|
+
* await sleep(error.context?.retryAfterMs ?? 1000);
|
|
24
|
+
* return retry();
|
|
25
|
+
* }
|
|
26
|
+
*/
|
|
27
|
+
type ErrorCategory = "auth" | "rate-limit" | "timeout" | "validation" | "content-filter" | "provider" | "tool" | "cancelled" | "max-trips" | "max-iterations" | "max-steps" | "schema" | "drift" | "routing" | "guardrail" | "budget" | "quota" | "context-length" | "unknown";
|
|
28
|
+
//#endregion
|
|
29
|
+
export { ErrorCategory };
|
|
30
|
+
//# sourceMappingURL=error-category.type.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error-category.type.d.mts","names":[],"sources":["../../../../../../@warlock.js/ai/src/errors/error-category.type.ts"],"mappings":";;AAyBA;;;;AAAyB;;;;;;;;;;;;;;;;;;;;KAAb,aAAA"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
//#region ../../@warlock.js/ai/src/errors/error-code.type.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Stable machine-readable identifier for every `AIError` subclass.
|
|
4
|
+
*
|
|
5
|
+
* Consumers switch on `error.code` rather than `instanceof` whenever the
|
|
6
|
+
* logic is "what went wrong in terms the user needs to handle" (retryable,
|
|
7
|
+
* wrong API key, too long, etc.). The strings are part of the public API —
|
|
8
|
+
* never rename an existing code; add a new one.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* if (result.error?.code === "PROVIDER_RATE_LIMIT") {
|
|
12
|
+
* await sleep(result.error.retryAfter ?? 1000);
|
|
13
|
+
* return agent.execute(input);
|
|
14
|
+
* }
|
|
15
|
+
*/
|
|
16
|
+
type AIErrorCode = "AGENT_EXEC_FAILED" | "AGENT_CANCELLED" | "AGENT_MAX_TRIPS" | "SCHEMA_VALIDATION_FAILED" | "TOOL_EXEC_FAILED" | "PROVIDER_ERROR" | "PROVIDER_RATE_LIMIT" | "PROVIDER_QUOTA_EXCEEDED" | "PROVIDER_TIMEOUT" | "CONTEXT_LENGTH_EXCEEDED" | "CONTENT_FILTER" | "PROVIDER_INVALID_REQUEST" | "PROVIDER_AUTH" | "BUDGET_EXCEEDED" | "GUARDRAIL_VIOLATION" | "WORKFLOW_ERROR" | "STEP_FAILED" | "WORKFLOW_DRIFT" | "WORKFLOW_CANCELLED" | "WORKFLOW_MAX_STEPS" | "WORKFLOW_INVALID_GOTO" | "SUPERVISOR_FAILED" | "SUPERVISOR_MAX_ITERATIONS" | "SUPERVISOR_INVALID_ROUTE" | "SUPERVISOR_CANCELLED" | "SUPERVISOR_DRIFT" | "SUPERVISOR_INTENT_DESCRIPTION_REQUIRED" | "SUPERVISOR_INTENT_MIXED_DISPATCH" | "SUPERVISOR_INTENT_STREAM_AND_OUTPUT" | "SUPERVISOR_INTENT_STREAM_TO_REQUIRED" | "SUPERVISOR_INTENT_STREAM_ON_WORKFLOW" | "SUPERVISOR_DISPATCH_CYCLE";
|
|
17
|
+
//#endregion
|
|
18
|
+
export { AIErrorCode };
|
|
19
|
+
//# sourceMappingURL=error-code.type.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error-code.type.d.mts","names":[],"sources":["../../../../../../@warlock.js/ai/src/errors/error-code.type.ts"],"mappings":";;AAcA;;;;AAAuB;;;;;;;;;KAAX,WAAA"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { ErrorCategory } from "./error-category.type.mjs";
|
|
2
|
+
import { AIError, AIErrorOptions } from "./ai-error.mjs";
|
|
3
|
+
|
|
4
|
+
//#region ../../@warlock.js/ai/src/errors/guardrail-violation-error.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* Phase at which a guardrail rejected the content — `"input"` when the
|
|
7
|
+
* violation was detected on the outbound prompt (before the model saw
|
|
8
|
+
* it), `"output"` when it was detected on the model's response (before
|
|
9
|
+
* the caller saw it).
|
|
10
|
+
*/
|
|
11
|
+
type GuardrailPhase = "input" | "output";
|
|
12
|
+
/**
|
|
13
|
+
* Payload for `GuardrailViolationError`. `phase` tells the caller
|
|
14
|
+
* whether the prompt or the response tripped the check; `reason` is
|
|
15
|
+
* the free-form explanation the guardrail middleware produced;
|
|
16
|
+
* `guardrail` names the offending middleware so operators can tune a
|
|
17
|
+
* specific rule without hunting through logs.
|
|
18
|
+
*/
|
|
19
|
+
type GuardrailViolationErrorOptions = AIErrorOptions & {
|
|
20
|
+
phase: GuardrailPhase;
|
|
21
|
+
reason: string;
|
|
22
|
+
guardrail?: string;
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* A guardrail middleware rejected the prompt or response mid-execution.
|
|
26
|
+
*
|
|
27
|
+
* **Role.** The typed abort surface for `ai.middleware.guardrail`.
|
|
28
|
+
* Consumers branch on `error.phase` to distinguish "the user asked
|
|
29
|
+
* something disallowed" (`"input"`) from "the model produced something
|
|
30
|
+
* disallowed" (`"output"`) — the two failure modes have very different
|
|
31
|
+
* product responses (block vs. retry, or surface a policy message vs.
|
|
32
|
+
* re-prompt the model).
|
|
33
|
+
*
|
|
34
|
+
* Thrown from inside the middleware pipeline's `trip.before` / `trip.after`
|
|
35
|
+
* hooks; surfaced to the caller via `result.error` like every other
|
|
36
|
+
* `AIError`.
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* if (result.error instanceof GuardrailViolationError) {
|
|
40
|
+
* if (result.error.phase === "input") {
|
|
41
|
+
* return respondWithPolicyMessage(result.error.reason);
|
|
42
|
+
* }
|
|
43
|
+
* return retryWithSanitizedPrompt();
|
|
44
|
+
* }
|
|
45
|
+
*/
|
|
46
|
+
declare class GuardrailViolationError extends AIError {
|
|
47
|
+
static readonly defaultCategory: ErrorCategory;
|
|
48
|
+
readonly phase: GuardrailPhase;
|
|
49
|
+
readonly reason: string;
|
|
50
|
+
readonly guardrail?: string;
|
|
51
|
+
constructor(message: string, options: GuardrailViolationErrorOptions);
|
|
52
|
+
}
|
|
53
|
+
//#endregion
|
|
54
|
+
export { GuardrailPhase, GuardrailViolationError, GuardrailViolationErrorOptions };
|
|
55
|
+
//# sourceMappingURL=guardrail-violation-error.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"guardrail-violation-error.d.mts","names":[],"sources":["../../../../../../@warlock.js/ai/src/errors/guardrail-violation-error.ts"],"mappings":";;;;;;AASA;;;;KAAY,cAAA;AASZ;;;;;;;AAAA,KAAY,8BAAA,GAAiC,cAAA;EAC3C,KAAA,EAAO,cAAc;EACrB,MAAA;EACA,SAAA;AAAA;;;;;;;;;;;;;;;;;;;;;AAgC2E;;cAPhE,uBAAA,SAAgC,OAAA;EAAA,gBACpB,eAAA,EAAiB,aAAA;EAAA,SAExB,KAAA,EAAO,cAAA;EAAA,SACP,MAAA;EAAA,SACA,SAAA;cAEG,OAAA,UAAiB,OAAA,EAAS,8BAAA;AAAA"}
|