@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,19 @@
|
|
|
1
|
+
//#region ../../@warlock.js/ai/src/contracts/workflow/retry-config.type.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Backoff strategy for step retries.
|
|
4
|
+
*
|
|
5
|
+
* - `"none"` — immediate retry, no delay
|
|
6
|
+
* - `"linear"` — attempt N waits `N * 500ms` (capped at 30s)
|
|
7
|
+
* - `"exponential"` — 500ms, 1s, 2s, 4s, ... (capped at 30s)
|
|
8
|
+
* - custom `(attempt) => ms` — full control (attempt is 1-based)
|
|
9
|
+
*/
|
|
10
|
+
type RetryBackoff = "none" | "linear" | "exponential" | ((attempt: number) => number);
|
|
11
|
+
type RetryConfig = {
|
|
12
|
+
/** Total attempts including the first. Default 1 (no retry). */attempts: number; /** Backoff strategy between attempts. Default `"exponential"`. */
|
|
13
|
+
backoff?: RetryBackoff; /** Per-error predicate; return false to skip remaining attempts. */
|
|
14
|
+
retryOn?: (error: unknown, attempt: number) => boolean; /** Hook fired before each retry (not the first attempt). */
|
|
15
|
+
onRetry?: (attempt: number, error: unknown) => void;
|
|
16
|
+
};
|
|
17
|
+
//#endregion
|
|
18
|
+
export { RetryBackoff, RetryConfig };
|
|
19
|
+
//# sourceMappingURL=retry-config.type.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"retry-config.type.d.mts","names":[],"sources":["../../../../../../../@warlock.js/ai/src/contracts/workflow/retry-config.type.ts"],"mappings":";;AAQA;;;;AAIqB;AAErB;;KANY,YAAA,yCAIN,OAAe;AAAA,KAET,WAAA;EAEV,gEAAA,QAAA,UAEU;EAAV,OAAA,GAAU,YAAY,EAEX;EAAX,OAAA,IAAW,KAAA,WAAgB,OAAA,sBAE3B;EAAA,OAAA,IAAW,OAAA,UAAiB,KAAA;AAAA"}
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
import { AIError } from "../../errors/ai-error.mjs";
|
|
2
|
+
import { AgentContract } from "../agent/agent.contract.mjs";
|
|
3
|
+
import { NextStepResult } from "./next-step-result.type.mjs";
|
|
4
|
+
import { RetryConfig } from "./retry-config.type.mjs";
|
|
5
|
+
import { WorkflowContext } from "./workflow-context.type.mjs";
|
|
6
|
+
import { AgentExecuteOptions } from "../agent/agent-options.type.mjs";
|
|
7
|
+
import { StandardSchemaV1 } from "@standard-schema/spec";
|
|
8
|
+
|
|
9
|
+
//#region ../../@warlock.js/ai/src/contracts/workflow/step.contract.d.ts
|
|
10
|
+
/**
|
|
11
|
+
* Step-local event payloads. Fired on per-step `on: { ... }` handlers
|
|
12
|
+
* in addition to the workflow-level `workflow.step.*` events — useful
|
|
13
|
+
* when you want a handler scoped to one step only.
|
|
14
|
+
*/
|
|
15
|
+
type StepLocalEvents = {
|
|
16
|
+
/** Before the step's lifecycle starts (after `skip` evaluates false). */starting: {
|
|
17
|
+
step: string;
|
|
18
|
+
}; /** Fired before every retry attempt (not the first). */
|
|
19
|
+
retrying: {
|
|
20
|
+
step: string;
|
|
21
|
+
attempt: number;
|
|
22
|
+
totalAttempts: number;
|
|
23
|
+
lastError: unknown;
|
|
24
|
+
}; /** Fired once after all retry attempts are exhausted. */
|
|
25
|
+
failed: {
|
|
26
|
+
step: string;
|
|
27
|
+
error: unknown;
|
|
28
|
+
attempts: number;
|
|
29
|
+
}; /** Fired when the step completes successfully. */
|
|
30
|
+
completed: {
|
|
31
|
+
step: string;
|
|
32
|
+
output: unknown;
|
|
33
|
+
duration: number;
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* Input built by `input(ctx)` when the step has an `agent`. Carries
|
|
38
|
+
* the prompt string plus any per-call agent options (history,
|
|
39
|
+
* attachments, placeholders, per-call output schema, etc.).
|
|
40
|
+
*/
|
|
41
|
+
type StepAgentInput = AgentExecuteOptions<unknown> & {
|
|
42
|
+
/** Prompt text passed to `agent.execute(prompt, options)`. */prompt: string;
|
|
43
|
+
};
|
|
44
|
+
/**
|
|
45
|
+
* Output extraction spec. `extract(ctx)` reads from `ctx.agentResult`
|
|
46
|
+
* (for agent steps), the step's `run()` return value, or `ctx.state`
|
|
47
|
+
* and produces the value stored at `step.output` in the snapshot.
|
|
48
|
+
*
|
|
49
|
+
* If `schema` is supplied, the extracted value is validated against it;
|
|
50
|
+
* validation failures throw `SchemaValidationError` and trip the
|
|
51
|
+
* step's retry logic (a retryable failure).
|
|
52
|
+
*/
|
|
53
|
+
type StepOutputSpec<TOutput = unknown, TInput = unknown, TState = Record<string, unknown>, TContext = unknown> = {
|
|
54
|
+
extract: (ctx: WorkflowContext<TInput, TState, TContext>) => TOutput | Promise<TOutput>;
|
|
55
|
+
schema?: StandardSchemaV1<TOutput>;
|
|
56
|
+
};
|
|
57
|
+
/**
|
|
58
|
+
* Static declaration of a single workflow step.
|
|
59
|
+
*
|
|
60
|
+
* **Step kind.** Exactly one of `run`, `agent`, or `parallel` must be
|
|
61
|
+
* set. `input` is required when `agent` is set. The step factory
|
|
62
|
+
* (`ai.step`) throws a `WorkflowError` at authoring time when these
|
|
63
|
+
* invariants are broken.
|
|
64
|
+
*
|
|
65
|
+
* **Lifecycle order (happy path).**
|
|
66
|
+
* ```
|
|
67
|
+
* skip? → before? → (run | agent | parallel) → output?.extract (+ schema) → after?
|
|
68
|
+
* ↓
|
|
69
|
+
* nextStep?
|
|
70
|
+
* ```
|
|
71
|
+
* Retry wraps the middle block (`before → run|agent → output → after`);
|
|
72
|
+
* `skip` / `nextStep` / `onCancel` sit outside the retry loop.
|
|
73
|
+
*/
|
|
74
|
+
type StepDefinition<TInput = unknown, TState = Record<string, unknown>, TContext = unknown> = {
|
|
75
|
+
/**
|
|
76
|
+
* Unique step name. Must be unique within the workflow (including
|
|
77
|
+
* across parallel children). Used as the key in `ctx.steps` and
|
|
78
|
+
* `report.steps`, as the routing target for `{ goto: "..." }`, and
|
|
79
|
+
* as the identifier in every event payload.
|
|
80
|
+
*/
|
|
81
|
+
name: string;
|
|
82
|
+
/**
|
|
83
|
+
* Skip guard. Evaluated BEFORE `before`. Returns `true` to bypass
|
|
84
|
+
* the step entirely — `before` / `run` / `agent` / `output` / `after`
|
|
85
|
+
* are never invoked, the snapshot is marked `{ skipped: true,
|
|
86
|
+
* status: "skipped" }`, and `nextStep` still fires so routing can
|
|
87
|
+
* react to the skip.
|
|
88
|
+
*/
|
|
89
|
+
skip?: (ctx: WorkflowContext<TInput, TState, TContext>) => boolean | Promise<boolean>;
|
|
90
|
+
/**
|
|
91
|
+
* Pre-work hook. Runs inside the retry loop before `run` / `agent`.
|
|
92
|
+
* Mutate `ctx.state` here for setup (fetching prerequisites, setting
|
|
93
|
+
* derived values, validating preconditions). A throw fails the
|
|
94
|
+
* attempt and triggers retry (if configured).
|
|
95
|
+
*/
|
|
96
|
+
before?: (ctx: WorkflowContext<TInput, TState, TContext>) => void | Promise<void>;
|
|
97
|
+
/**
|
|
98
|
+
* Core work for non-agent steps. Receives the context and may return
|
|
99
|
+
* any value; the return value is exposed to `output.extract` via
|
|
100
|
+
* `ctx.agentResult`. Mutually exclusive with `agent` and `parallel`.
|
|
101
|
+
*/
|
|
102
|
+
run?: (ctx: WorkflowContext<TInput, TState, TContext>) => unknown;
|
|
103
|
+
/**
|
|
104
|
+
* Agent to execute for this step. Mutually exclusive with `run` and
|
|
105
|
+
* `parallel`. The agent receives `input(ctx)`'s prompt (and any
|
|
106
|
+
* options from the same call); its `AgentResult` is stored on
|
|
107
|
+
* `ctx.agentResult` for downstream `output.extract` / `after` use
|
|
108
|
+
* and aggregated into `report.steps[name].executionResult`.
|
|
109
|
+
*/
|
|
110
|
+
agent?: AgentContract<unknown>;
|
|
111
|
+
/**
|
|
112
|
+
* Builds the prompt + per-call options for `agent`. Required when
|
|
113
|
+
* `agent` is set. Runs once per retry attempt so the prompt can
|
|
114
|
+
* incorporate fresh context (e.g., loop-back feedback on
|
|
115
|
+
* `ctx.state.qaFeedback`).
|
|
116
|
+
*/
|
|
117
|
+
input?: (ctx: WorkflowContext<TInput, TState, TContext>) => StepAgentInput | Promise<StepAgentInput>;
|
|
118
|
+
/**
|
|
119
|
+
* Output extraction spec. Runs after `run` / `agent`. Without this
|
|
120
|
+
* the step's `output` in the snapshot is `undefined`. A throw (or
|
|
121
|
+
* schema validation failure) fails the attempt and triggers retry.
|
|
122
|
+
*/
|
|
123
|
+
output?: StepOutputSpec<unknown, TInput, TState, TContext>;
|
|
124
|
+
/**
|
|
125
|
+
* Post-work hook. Runs inside the retry loop AFTER `output.extract`.
|
|
126
|
+
* Intended for side effects (save to DB, send notification, fire
|
|
127
|
+
* webhook). A throw fails the attempt and triggers retry — so keep
|
|
128
|
+
* `after` work idempotent.
|
|
129
|
+
*/
|
|
130
|
+
after?: (ctx: WorkflowContext<TInput, TState, TContext>) => void | Promise<void>;
|
|
131
|
+
/**
|
|
132
|
+
* Step-level routing. Runs OUTSIDE the retry loop, once per step
|
|
133
|
+
* completion — but ONLY for `completed` and `skipped` outcomes. A
|
|
134
|
+
* step whose retries are exhausted (`failed`) bypasses `nextStep`
|
|
135
|
+
* and goes through `onFailure` (if defined) or halts the workflow.
|
|
136
|
+
* Return `{ goto, end, void }` — step-level wins over workflow-level;
|
|
137
|
+
* `void` falls through. Errors here are NOT retried: routing is
|
|
138
|
+
* authoritative, so a throw terminates the workflow with
|
|
139
|
+
* `RoutingError`.
|
|
140
|
+
*/
|
|
141
|
+
nextStep?: (ctx: WorkflowContext<TInput, TState, TContext>) => NextStepResult | Promise<NextStepResult>;
|
|
142
|
+
/**
|
|
143
|
+
* Failure-routing hook. Runs OUTSIDE the retry loop, once after all
|
|
144
|
+
* retry attempts are exhausted, before the workflow halts. Return:
|
|
145
|
+
* - `{ goto: "name" }` to redirect to a recovery step (workflow
|
|
146
|
+
* continues; final status becomes `completed` if recovery succeeds)
|
|
147
|
+
* - `{ end: true }` to terminate cleanly without an error
|
|
148
|
+
* - `void` (or omit) to halt the workflow with the original
|
|
149
|
+
* `StepFailedError` — same as if no `onFailure` were defined
|
|
150
|
+
*
|
|
151
|
+
* The step's snapshot retains `status: "failed"` and `error` for
|
|
152
|
+
* forensic trace even when `onFailure` recovers the run. Errors
|
|
153
|
+
* thrown from `onFailure` are NOT retried — they terminate the
|
|
154
|
+
* workflow with `RoutingError` (mirrors `nextStep`).
|
|
155
|
+
*/
|
|
156
|
+
onFailure?: (ctx: WorkflowContext<TInput, TState, TContext>, error: AIError) => NextStepResult | Promise<NextStepResult>;
|
|
157
|
+
/**
|
|
158
|
+
* Cancellation cleanup. Runs best-effort when the workflow is
|
|
159
|
+
* aborted while this step is in-flight. Typical use: release a
|
|
160
|
+
* reservation, flush a partial write, cancel an external job. Errors
|
|
161
|
+
* thrown from `onCancel` are swallowed + logged — never rethrown.
|
|
162
|
+
*/
|
|
163
|
+
onCancel?: (ctx: WorkflowContext<TInput, TState, TContext>) => void | Promise<void>;
|
|
164
|
+
/**
|
|
165
|
+
* Retry configuration. Overrides workflow-level `defaultRetry`.
|
|
166
|
+
* `false` disables retry entirely. See `RetryConfig` for backoff
|
|
167
|
+
* options. Retry wraps `before → run|agent → output → after`;
|
|
168
|
+
* `AbortError` short-circuits the loop.
|
|
169
|
+
*/
|
|
170
|
+
retry?: RetryConfig | false;
|
|
171
|
+
/**
|
|
172
|
+
* Parallel children — run concurrently, share `ctx.state`
|
|
173
|
+
* (last-write-wins). Mutually exclusive with `run` and `agent`.
|
|
174
|
+
* The parent's snapshot is atomic: written only after every child
|
|
175
|
+
* settles. Children are addressable at both `ctx.steps.<child>` and
|
|
176
|
+
* `ctx.steps.<parent>.steps.<child>`.
|
|
177
|
+
*/
|
|
178
|
+
parallel?: StepDefinition<TInput, TState, TContext>[];
|
|
179
|
+
/**
|
|
180
|
+
* Per-step event handlers — fires alongside the workflow-level
|
|
181
|
+
* `workflow.step.*` events. Scope is step-local (no `workflow.`
|
|
182
|
+
* prefix); payload includes the step name for symmetry with the
|
|
183
|
+
* workflow-level events.
|
|
184
|
+
*/
|
|
185
|
+
on?: Partial<{ [K in keyof StepLocalEvents]: (payload: StepLocalEvents[K]) => void }>;
|
|
186
|
+
};
|
|
187
|
+
//#endregion
|
|
188
|
+
export { StepAgentInput, StepDefinition, StepLocalEvents, StepOutputSpec };
|
|
189
|
+
//# sourceMappingURL=step.contract.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"step.contract.d.mts","names":[],"sources":["../../../../../../../@warlock.js/ai/src/contracts/workflow/step.contract.ts"],"mappings":";;;;;;;;;;;;AAaA;;KAAY,eAAA;EAAe,yEAEzB,QAAA;IAAY,IAAA;EAAA,GAGV;EADF,QAAA;IACE,IAAA;IACA,OAAA;IACA,aAAA;IACA,SAAA;EAAA,GAGsC;EAAxC,MAAA;IAAU,IAAA;IAAc,KAAA;IAAgB,QAAA;EAAA,GAEY;EAApD,SAAA;IAAa,IAAA;IAAc,MAAA;IAAiB,QAAA;EAAA;AAAA;;;;;;KAQlC,cAAA,GAAiB,mBAAmB;EAqBvC,8DAnBP,MAAM;AAAA;;;;;;;;;;KAYI,cAAA,+CAGD,MAAA;EAGT,OAAA,GACE,GAAA,EAAK,eAAA,CAAgB,MAAA,EAAQ,MAAA,EAAQ,QAAA,MAClC,OAAA,GAAU,OAAA,CAAQ,OAAA;EACvB,MAAA,GAAS,gBAAA,CAAiB,OAAA;AAAA;;;;;;;;;;;AAAO;AAoBnC;;;;;;KAAY,cAAA,4BAED,MAAA;EAkBI;;;;;;EATb,IAAA;EAwB4B;;;;;;;EAf5B,IAAA,IAAQ,GAAA,EAAK,eAAA,CAAgB,MAAA,EAAQ,MAAA,EAAQ,QAAA,gBAAwB,OAAA;EAgCvD;;;;;;EAxBd,MAAA,IAAU,GAAA,EAAK,eAAA,CAAgB,MAAA,EAAQ,MAAA,EAAQ,QAAA,aAAqB,OAAA;EA+B3D;;;;;EAxBT,GAAA,IAAO,GAAA,EAAK,eAAA,CAAgB,MAAA,EAAQ,MAAA,EAAQ,QAAA;EA4CX;;;;;;;EAnCjC,KAAA,GAAQ,aAAA;EAoDuB;;;;;;EA5C/B,KAAA,IAAS,GAAA,EAAK,eAAA,CAAgB,MAAA,EAAQ,MAAA,EAAQ,QAAA,MAAc,cAAA,GAAiB,OAAA,CAAQ,cAAA;EAsDpD;;;;;EA/CjC,MAAA,GAAS,cAAA,UAAwB,MAAA,EAAQ,MAAA,EAAQ,QAAA;EAgEvB;;;;;;EAxD1B,KAAA,IAAS,GAAA,EAAK,eAAA,CAAgB,MAAA,EAAQ,MAAA,EAAQ,QAAA,aAAqB,OAAA;EAgE9D;;;;;;;;;;EApDL,QAAA,IAAY,GAAA,EAAK,eAAA,CAAgB,MAAA,EAAQ,MAAA,EAAQ,QAAA,MAAc,cAAA,GAAiB,OAAA,CAAQ,cAAA;EA3DnD;;;;;;;;;;;;;;EA2ErC,SAAA,IACE,GAAA,EAAK,eAAA,CAAgB,MAAA,EAAQ,MAAA,EAAQ,QAAA,GACrC,KAAA,EAAO,OAAA,KACJ,cAAA,GAAiB,OAAA,CAAQ,cAAA;EA/Dc;;;;;;EAuE5C,QAAA,IAAY,GAAA,EAAK,eAAA,CAAgB,MAAA,EAAQ,MAAA,EAAQ,QAAA,aAAqB,OAAA;EAtDhC;;;;;;EA8DtC,KAAA,GAAQ,WAAA;EAvDC;;;;;;;EAgET,QAAA,GAAW,cAAA,CAAe,MAAA,EAAQ,MAAA,EAAQ,QAAA;EAxDI;;;;;;EAgE9C,EAAA,GAAK,OAAA,eACS,eAAA,IAAmB,OAAA,EAAS,eAAA,CAAgB,CAAA;AAAA"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { AgentResult } from "../result/agent-result.type.mjs";
|
|
2
|
+
import { StepSnapshot } from "../result/step-result.type.mjs";
|
|
3
|
+
|
|
4
|
+
//#region ../../@warlock.js/ai/src/contracts/workflow/workflow-context.type.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* Context threaded through every step lifecycle phase.
|
|
7
|
+
*
|
|
8
|
+
* Invariants:
|
|
9
|
+
* - `input` is deep-frozen and never changes
|
|
10
|
+
* - `context` is deep-frozen and never changes — request-scoped
|
|
11
|
+
* envelope (tenancy, current user, locale, traceId). Supplied via
|
|
12
|
+
* `execute({ context })` / `resume({ context })`. NOT persisted in
|
|
13
|
+
* snapshots; resume callers must pass it fresh. Defaults to `{}`
|
|
14
|
+
* when the caller omits it, so readers never need a guard.
|
|
15
|
+
* - `steps` is a frozen map of completed step snapshots
|
|
16
|
+
* - `state` is mutable during a step; frozen into `steps[name].state`
|
|
17
|
+
* when the step completes
|
|
18
|
+
* - `agentResult` is framework-owned — set when the current step has
|
|
19
|
+
* an `agent`, reset between steps
|
|
20
|
+
*
|
|
21
|
+
* `input` vs `context` — quick rule: if the field defines *what* to
|
|
22
|
+
* process, it's `input` (durable cause; replayed verbatim on resume).
|
|
23
|
+
* If it defines *who's running it* / *what request scope this is*,
|
|
24
|
+
* it's `context` (per-execution envelope; supplied fresh on resume).
|
|
25
|
+
*/
|
|
26
|
+
type WorkflowContext<TInput = unknown, TState = Record<string, unknown>, TContext = unknown> = {
|
|
27
|
+
readonly input: TInput;
|
|
28
|
+
readonly context: TContext;
|
|
29
|
+
readonly steps: Readonly<Record<string, StepSnapshot>>;
|
|
30
|
+
state: TState;
|
|
31
|
+
readonly agentResult?: AgentResult<unknown>;
|
|
32
|
+
readonly runId: string;
|
|
33
|
+
readonly signal?: AbortSignal;
|
|
34
|
+
/**
|
|
35
|
+
* Workflow start time as a `Date`. Stable across resume — on a
|
|
36
|
+
* resumed run this reflects the *original* start, not the resume
|
|
37
|
+
* moment. Use `Date.now() - ctx.startedAt.getTime()` for elapsed
|
|
38
|
+
* time, or `ctx.startedAt.toISOString()` when you need the string
|
|
39
|
+
* form (matches `report.startedAt`).
|
|
40
|
+
*/
|
|
41
|
+
readonly startedAt: Date;
|
|
42
|
+
};
|
|
43
|
+
//#endregion
|
|
44
|
+
export { WorkflowContext };
|
|
45
|
+
//# sourceMappingURL=workflow-context.type.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workflow-context.type.d.mts","names":[],"sources":["../../../../../../../@warlock.js/ai/src/contracts/workflow/workflow-context.type.ts"],"mappings":";;;;;;AAwBA;;;;;;;;;;;;;;;;;;;KAAY,eAAA,4BAED,MAAA;EAAA,SAGA,KAAA,EAAO,MAAA;EAAA,SACP,OAAA,EAAS,QAAA;EAAA,SACT,KAAA,EAAO,QAAA,CAAS,MAAA,SAAe,YAAA;EACxC,KAAA,EAAO,MAAA;EAAA,SACE,WAAA,GAAc,WAAA;EAAA,SACd,KAAA;EAAA,SACA,MAAA,GAAS,WAAA;EAHlB;;;;;;;EAAA,SAWS,SAAA,EAAW,IAAA;AAAA"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { ExecutionStatus } from "../result/execution-report.type.mjs";
|
|
2
|
+
import { StepSnapshot } from "../result/step-result.type.mjs";
|
|
3
|
+
|
|
4
|
+
//#region ../../@warlock.js/ai/src/contracts/workflow/workflow-snapshot.type.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* Serializable workflow state written to the configured `KVStore`
|
|
7
|
+
* after every step completion.
|
|
8
|
+
*/
|
|
9
|
+
type WorkflowSnapshot = {
|
|
10
|
+
runId: string;
|
|
11
|
+
workflowName: string;
|
|
12
|
+
signature: string;
|
|
13
|
+
version?: string;
|
|
14
|
+
input: unknown;
|
|
15
|
+
state: Record<string, unknown>;
|
|
16
|
+
steps: Record<string, StepSnapshot>; /** Resolved next step name; null when the workflow has ended. */
|
|
17
|
+
next: string | null;
|
|
18
|
+
status: ExecutionStatus | "running";
|
|
19
|
+
startedAt: string;
|
|
20
|
+
savedAt: string;
|
|
21
|
+
};
|
|
22
|
+
//#endregion
|
|
23
|
+
export { WorkflowSnapshot };
|
|
24
|
+
//# sourceMappingURL=workflow-snapshot.type.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workflow-snapshot.type.d.mts","names":[],"sources":["../../../../../../../@warlock.js/ai/src/contracts/workflow/workflow-snapshot.type.ts"],"mappings":";;;;;;AAOA;;KAAY,gBAAA;EACV,KAAA;EACA,YAAA;EACA,SAAA;EACA,OAAA;EACA,KAAA;EACA,KAAA,EAAO,MAAA;EACP,KAAA,EAAO,MAAA,SAAe,YAAA,GALtB;EAOA,IAAA;EACA,MAAA,EAAQ,eAAA;EACR,SAAA;EACA,OAAA;AAAA"}
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import { ExecutableContract } from "../executable.contract.mjs";
|
|
2
|
+
import { WorkflowResult } from "../result/workflow-result.type.mjs";
|
|
3
|
+
import { ToolContract } from "../../tool/tool.mjs";
|
|
4
|
+
import { NextStepResult } from "./next-step-result.type.mjs";
|
|
5
|
+
import { RetryConfig } from "./retry-config.type.mjs";
|
|
6
|
+
import { WorkflowContext } from "./workflow-context.type.mjs";
|
|
7
|
+
import { StepDefinition, StepOutputSpec } from "./step.contract.mjs";
|
|
8
|
+
import { WorkflowEventMap } from "../events/event-map.type.mjs";
|
|
9
|
+
import { StandardSchemaV1 } from "@standard-schema/spec";
|
|
10
|
+
import { CacheDriver } from "@warlock.js/cache";
|
|
11
|
+
|
|
12
|
+
//#region ../../@warlock.js/ai/src/contracts/workflow/workflow.contract.d.ts
|
|
13
|
+
type WorkflowEventHandler<K extends keyof WorkflowEventMap> = (payload: WorkflowEventMap[K]) => void;
|
|
14
|
+
type WorkflowEventHandlers = Partial<{ [K in keyof WorkflowEventMap]: WorkflowEventHandler<K> }>;
|
|
15
|
+
/**
|
|
16
|
+
* Per-run options for `workflow.execute()`. Carries runtime knobs —
|
|
17
|
+
* everything here is per-call, not per-factory.
|
|
18
|
+
*/
|
|
19
|
+
type WorkflowRunOptions<TContext = unknown> = {
|
|
20
|
+
/** Caller-chosen runId. Auto-generated (`wf_<rand>`) when omitted. */runId?: string; /** Cancellation handle — between-step + in-flight agent abort. */
|
|
21
|
+
signal?: AbortSignal; /** Per-execution event handlers (layer 3 of the 3-tier model). */
|
|
22
|
+
on?: WorkflowEventHandlers;
|
|
23
|
+
/**
|
|
24
|
+
* Request-scoped envelope exposed as `ctx.context` to every step.
|
|
25
|
+
* Frozen, never persisted in snapshots — resume callers must
|
|
26
|
+
* supply it fresh. Use for tenancy (`organizationId`), the current
|
|
27
|
+
* user, locale, traceId — anything that scopes the run without
|
|
28
|
+
* being part of the durable input. Defaults to `{}` when omitted.
|
|
29
|
+
*/
|
|
30
|
+
context?: TContext;
|
|
31
|
+
/**
|
|
32
|
+
* Opaque caller-supplied identifier that groups multiple `execute()`
|
|
33
|
+
* calls into one conceptual user session / request. Mirrored onto
|
|
34
|
+
* every report node this run produces — including child steps and
|
|
35
|
+
* agents dispatched by steps — so flat queries don't need to walk
|
|
36
|
+
* the tree.
|
|
37
|
+
*/
|
|
38
|
+
sessionId?: string;
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* Combined-object form accepted by the single-argument overload of
|
|
42
|
+
* `workflow.execute(options)`. Equivalent to `execute(input, options)`
|
|
43
|
+
* with `input` bundled in.
|
|
44
|
+
*/
|
|
45
|
+
type WorkflowExecuteOptions<TInput = unknown, TContext = unknown> = WorkflowRunOptions<TContext> & {
|
|
46
|
+
input: TInput;
|
|
47
|
+
};
|
|
48
|
+
type WorkflowResumeOptions<TContext = unknown> = WorkflowRunOptions<TContext> & {
|
|
49
|
+
/** Bypass signature drift check. Use when you know the workflow
|
|
50
|
+
* definition change is safe for in-flight snapshots. */
|
|
51
|
+
force?: boolean;
|
|
52
|
+
};
|
|
53
|
+
type WorkflowDefinition<TInput = unknown, TOutput = unknown, TState = Record<string, unknown>, TContext = unknown> = {
|
|
54
|
+
name: string;
|
|
55
|
+
/**
|
|
56
|
+
* Short natural-language summary of what the workflow does. Surfaced
|
|
57
|
+
* to `ai.supervisor()`'s router prompt and to `workflow.asTool()` as
|
|
58
|
+
* the default tool description.
|
|
59
|
+
*/
|
|
60
|
+
description?: string;
|
|
61
|
+
version?: string;
|
|
62
|
+
steps: StepDefinition<TInput, TState, TContext>[];
|
|
63
|
+
/**
|
|
64
|
+
* Optional durable store enabling `workflow.resume(runId)`. Accepts
|
|
65
|
+
* any `@warlock.js/cache` driver — `MemoryCacheDriver` for
|
|
66
|
+
* dev/tests, `RedisCacheDriver` / `PgCacheDriver` for production.
|
|
67
|
+
*
|
|
68
|
+
* Falls back to `ai.config({ defaultStore })` when omitted. When
|
|
69
|
+
* neither is set, `resume()` throws and snapshot writes silently
|
|
70
|
+
* skip (current behavior preserved).
|
|
71
|
+
*/
|
|
72
|
+
snapshotStore?: CacheDriver<any, any>;
|
|
73
|
+
/**
|
|
74
|
+
* Default retry applied to every step that doesn't supply its own
|
|
75
|
+
* `retry`. `undefined` (omitted) means "no retry" — resolves to
|
|
76
|
+
* `{ attempts: 1 }` at runtime. `false` also means no retry; use
|
|
77
|
+
* it to be explicit when you want to lock out retries even for
|
|
78
|
+
* steps that set their own `retry`.
|
|
79
|
+
*
|
|
80
|
+
* Resolution precedence: `step.retry` → `defaultRetry` → `{ attempts: 1 }`.
|
|
81
|
+
*/
|
|
82
|
+
defaultRetry?: RetryConfig | false;
|
|
83
|
+
maxSteps?: number;
|
|
84
|
+
loopWarnAfter?: number;
|
|
85
|
+
nextStep?: (stepName: string, ctx: WorkflowContext<TInput, TState, TContext>) => NextStepResult | Promise<NextStepResult>;
|
|
86
|
+
output?: StepOutputSpec<TOutput, TInput, TState, TContext>;
|
|
87
|
+
on?: WorkflowEventHandlers;
|
|
88
|
+
};
|
|
89
|
+
/**
|
|
90
|
+
* Runtime handle returned by `ai.workflow(def)`. Implements the
|
|
91
|
+
* 3-tier event subscription model (factory → instance → per-call)
|
|
92
|
+
* and satisfies `ExecutableContract` so orchestrators / supervisors
|
|
93
|
+
* can invoke any primitive with one uniform signature.
|
|
94
|
+
*/
|
|
95
|
+
interface WorkflowInstance<TInput = unknown, TOutput = unknown, TState = Record<string, unknown>, TContext = unknown> extends ExecutableContract<TInput, WorkflowRunOptions<TContext>, WorkflowResult<TOutput>> {
|
|
96
|
+
readonly name: string;
|
|
97
|
+
readonly description?: string;
|
|
98
|
+
readonly signature: string;
|
|
99
|
+
readonly version?: string;
|
|
100
|
+
/**
|
|
101
|
+
* Run the workflow. Two interchangeable call shapes:
|
|
102
|
+
*
|
|
103
|
+
* ```ts
|
|
104
|
+
* wf.execute(input); // minimal
|
|
105
|
+
* wf.execute(input, { runId, signal, on }); // canonical — mirrors agent.execute
|
|
106
|
+
* wf.execute({ input, runId, signal, on }); // single-object — ergonomic alt
|
|
107
|
+
* ```
|
|
108
|
+
*
|
|
109
|
+
* Runtime picks the combined form when exactly one argument is
|
|
110
|
+
* passed and it is a plain object carrying an `input` property. If
|
|
111
|
+
* your real `input` has a top-level `input` key, prefer the
|
|
112
|
+
* two-arg form to avoid ambiguity.
|
|
113
|
+
*/
|
|
114
|
+
execute(input: TInput, options?: WorkflowRunOptions<TContext>): Promise<WorkflowResult<TOutput>>;
|
|
115
|
+
execute(options: WorkflowExecuteOptions<TInput, TContext>): Promise<WorkflowResult<TOutput>>;
|
|
116
|
+
resume(runId: string, options?: WorkflowResumeOptions<TContext>): Promise<WorkflowResult<TOutput>>;
|
|
117
|
+
on<K extends keyof WorkflowEventMap>(event: K, handler: WorkflowEventHandler<K>): () => void;
|
|
118
|
+
off<K extends keyof WorkflowEventMap>(event: K, handler: WorkflowEventHandler<K>): void;
|
|
119
|
+
/**
|
|
120
|
+
* Wrap this workflow as a `ToolContract` so an agent can invoke it
|
|
121
|
+
* inside its tool-call loop. The tool's `name` mirrors the workflow's
|
|
122
|
+
* `name` (must be set — anonymous workflows throw `WorkflowError`),
|
|
123
|
+
* its `input` is the supplied schema, and its `execute()` runs
|
|
124
|
+
* `workflow.execute(input)`. Workflow errors surface to the agent as
|
|
125
|
+
* `ToolExecutionError` with `cause` set to the original
|
|
126
|
+
* `WorkflowError` subclass.
|
|
127
|
+
*
|
|
128
|
+
* @example
|
|
129
|
+
* const wrapped = wf.asTool({
|
|
130
|
+
* description: "Run support-ticket triage",
|
|
131
|
+
* inputSchema: ticketSchema,
|
|
132
|
+
* });
|
|
133
|
+
* const a = ai.agent({ model, tools: [wrapped] });
|
|
134
|
+
*/
|
|
135
|
+
asTool<TToolInput = TInput>(options: {
|
|
136
|
+
description?: string;
|
|
137
|
+
inputSchema: StandardSchemaV1<TToolInput>;
|
|
138
|
+
}): ToolContract<TToolInput, TOutput>;
|
|
139
|
+
}
|
|
140
|
+
//#endregion
|
|
141
|
+
export { WorkflowDefinition, WorkflowEventHandler, WorkflowEventHandlers, WorkflowExecuteOptions, WorkflowInstance, WorkflowResumeOptions, WorkflowRunOptions };
|
|
142
|
+
//# sourceMappingURL=workflow.contract.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workflow.contract.d.mts","names":[],"sources":["../../../../../../../@warlock.js/ai/src/contracts/workflow/workflow.contract.ts"],"mappings":";;;;;;;;;;;;KAWY,oBAAA,iBAAqC,gBAAA,KAC/C,OAAA,EAAS,gBAAA,CAAiB,CAAA;AAAA,KAGhB,qBAAA,GAAwB,OAAA,eACtB,gBAAA,GAAmB,oBAAA,CAAqB,CAAA;;;;;KAO1C,kBAAA;EAXiB,sEAa3B,KAAA,WAd+C;EAgB/C,MAAA,GAAS,WAAA,EAfiB;EAiB1B,EAAA,GAAK,qBAAA;EAjBuB;AAAA;AAG9B;;;;;EAsBE,OAAA,GAAU,QAAA;EAtBwB;;;;;;;EA8BlC,SAAA;AAAA;AA7BqD;AAOvD;;;;AAPuD,KAqC3C,sBAAA,yCAGR,kBAAA,CAAmB,QAAA;EACrB,KAAA,EAAO,MAAA;AAAA;AAAA,KAGG,qBAAA,uBACV,kBAAkB,CAAC,QAAA;EAtCU;;EAyC3B,KAAA;AAAA;AAAA,KAGQ,kBAAA,+CAGD,MAAA;EAGT,IAAA;EApCA;;;;AAQS;EAkCT,WAAA;EACA,OAAA;EACA,KAAA,EAAO,cAAA,CAAe,MAAA,EAAQ,MAAA,EAAQ,QAAA;EAzBjB;;;;;;;;;EAmCrB,aAAA,GAAgB,WAAA;EAlCT;;AAAM;AAGf;;;;;;EAyCE,YAAA,GAAe,WAAA;EACf,QAAA;EACA,aAAA;EACA,QAAA,IACE,QAAA,UACA,GAAA,EAAK,eAAA,CAAgB,MAAA,EAAQ,MAAA,EAAQ,QAAA,MAClC,cAAA,GAAiB,OAAA,CAAQ,cAAA;EAC9B,MAAA,GAAS,cAAA,CAAe,OAAA,EAAS,MAAA,EAAQ,MAAA,EAAQ,QAAA;EACjD,EAAA,GAAK,qBAAA;AAAA;;;;;;;UASU,gBAAA,+CAGN,MAAA,+CAED,kBAAA,CACR,MAAA,EACA,kBAAA,CAAmB,QAAA,GACnB,cAAA,CAAe,OAAA;EAAA,SAEN,IAAA;EAAA,SACA,WAAA;EAAA,SACA,SAAA;EAAA,SACA,OAAA;EAxBJ;;;;;;;;;;;;;;EAwCL,OAAA,CACE,KAAA,EAAO,MAAA,EACP,OAAA,GAAU,kBAAA,CAAmB,QAAA,IAC5B,OAAA,CAAQ,cAAA,CAAe,OAAA;EAC1B,OAAA,CACE,OAAA,EAAS,sBAAA,CAAuB,MAAA,EAAQ,QAAA,IACvC,OAAA,CAAQ,cAAA,CAAe,OAAA;EAE1B,MAAA,CACE,KAAA,UACA,OAAA,GAAU,qBAAA,CAAsB,QAAA,IAC/B,OAAA,CAAQ,cAAA,CAAe,OAAA;EAE1B,EAAA,iBAAmB,gBAAA,EAAkB,KAAA,EAAO,CAAA,EAAG,OAAA,EAAS,oBAAA,CAAqB,CAAA;EAC7E,GAAA,iBAAoB,gBAAA,EAAkB,KAAA,EAAO,CAAA,EAAG,OAAA,EAAS,oBAAA,CAAqB,CAAA;EAhF9E;;;;;;;;;;;;;;;;EAkGA,MAAA,cAAoB,MAAA,EAAQ,OAAA;IAC1B,WAAA;IACA,WAAA,EAAa,gBAAA,CAAiB,UAAA;EAAA,IAC5B,YAAA,CAAa,UAAA,EAAY,OAAA;AAAA"}
|
|
@@ -0,0 +1,49 @@
|
|
|
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-cancelled-error.d.ts
|
|
6
|
+
/**
|
|
7
|
+
* Payload for {@link AgentCancelledError}. `cancelledAt` is the
|
|
8
|
+
* ISO-8601 timestamp at which the abort was observed; `reason`
|
|
9
|
+
* carries the value the caller supplied to `controller.abort(reason)`
|
|
10
|
+
* when present.
|
|
11
|
+
*/
|
|
12
|
+
type AgentCancelledErrorOptions = AIErrorOptions & {
|
|
13
|
+
cancelledAt?: string;
|
|
14
|
+
reason?: string;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Agent run was cancelled via `AbortSignal` before it could finish.
|
|
18
|
+
* Between-trip cancellation is guaranteed; mid-trip cancellation is
|
|
19
|
+
* best-effort (the signal is threaded into the provider adapter's
|
|
20
|
+
* HTTP client when supported).
|
|
21
|
+
*
|
|
22
|
+
* Surfaced on `result.error` rather than thrown — `agent.execute()`
|
|
23
|
+
* still returns with `report.status = "cancelled"` and partial trip
|
|
24
|
+
* history intact. Consumers branch on the class (not the message) to
|
|
25
|
+
* distinguish caller-initiated stops from other failures.
|
|
26
|
+
*
|
|
27
|
+
* **Why split from `AgentExecutionError`.** Cancellation is a
|
|
28
|
+
* different operational signal from "the agent crashed" — retry
|
|
29
|
+
* policy and dashboards typically want different behavior for each.
|
|
30
|
+
* Keeping cancellation in its own class lets the category
|
|
31
|
+
* (`"cancelled"`) be set declaratively per type instead of inferred
|
|
32
|
+
* from a `context.cancelled === true` flag.
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* const result = await agent.execute(input, { signal });
|
|
36
|
+
* if (result.error instanceof AgentCancelledError) {
|
|
37
|
+
* // caller pulled the plug — don't retry, surface a "stopped" UI
|
|
38
|
+
* return { status: "cancelled" };
|
|
39
|
+
* }
|
|
40
|
+
*/
|
|
41
|
+
declare class AgentCancelledError extends AgentExecutionError {
|
|
42
|
+
static readonly defaultCategory: ErrorCategory;
|
|
43
|
+
readonly cancelledAt?: string;
|
|
44
|
+
readonly reason?: string;
|
|
45
|
+
constructor(message: string, options?: AgentCancelledErrorOptions);
|
|
46
|
+
}
|
|
47
|
+
//#endregion
|
|
48
|
+
export { AgentCancelledError, AgentCancelledErrorOptions };
|
|
49
|
+
//# sourceMappingURL=agent-cancelled-error.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-cancelled-error.d.mts","names":[],"sources":["../../../../../../@warlock.js/ai/src/errors/agent-cancelled-error.ts"],"mappings":";;;;;;;AAUA;;;;KAAY,0BAAA,GAA6B,cAAc;EACrD,WAAA;EACA,MAAA;AAAA;AAAM;AA4BR;;;;;;;;;;;;;;;;;;AAM0E;;;;;;AAlClE,cA4BK,mBAAA,SAA4B,mBAAA;EAAA,gBAChB,eAAA,EAAiB,aAAA;EAAA,SAExB,WAAA;EAAA,SACA,MAAA;cAEG,OAAA,UAAiB,OAAA,GAAU,0BAAA;AAAA"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { AgentExecutionError } from "./agent-execution-error.mjs";
|
|
2
|
+
|
|
3
|
+
//#region ../../@warlock.js/ai/src/errors/agent-cancelled-error.ts
|
|
4
|
+
/**
|
|
5
|
+
* Agent run was cancelled via `AbortSignal` before it could finish.
|
|
6
|
+
* Between-trip cancellation is guaranteed; mid-trip cancellation is
|
|
7
|
+
* best-effort (the signal is threaded into the provider adapter's
|
|
8
|
+
* HTTP client when supported).
|
|
9
|
+
*
|
|
10
|
+
* Surfaced on `result.error` rather than thrown — `agent.execute()`
|
|
11
|
+
* still returns with `report.status = "cancelled"` and partial trip
|
|
12
|
+
* history intact. Consumers branch on the class (not the message) to
|
|
13
|
+
* distinguish caller-initiated stops from other failures.
|
|
14
|
+
*
|
|
15
|
+
* **Why split from `AgentExecutionError`.** Cancellation is a
|
|
16
|
+
* different operational signal from "the agent crashed" — retry
|
|
17
|
+
* policy and dashboards typically want different behavior for each.
|
|
18
|
+
* Keeping cancellation in its own class lets the category
|
|
19
|
+
* (`"cancelled"`) be set declaratively per type instead of inferred
|
|
20
|
+
* from a `context.cancelled === true` flag.
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* const result = await agent.execute(input, { signal });
|
|
24
|
+
* if (result.error instanceof AgentCancelledError) {
|
|
25
|
+
* // caller pulled the plug — don't retry, surface a "stopped" UI
|
|
26
|
+
* return { status: "cancelled" };
|
|
27
|
+
* }
|
|
28
|
+
*/
|
|
29
|
+
var AgentCancelledError = class extends AgentExecutionError {
|
|
30
|
+
static {
|
|
31
|
+
this.defaultCategory = "cancelled";
|
|
32
|
+
}
|
|
33
|
+
constructor(message, options) {
|
|
34
|
+
super(message, options, "AGENT_CANCELLED");
|
|
35
|
+
this.name = "AgentCancelledError";
|
|
36
|
+
this.cancelledAt = options?.cancelledAt;
|
|
37
|
+
this.reason = options?.reason;
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
//#endregion
|
|
42
|
+
export { AgentCancelledError };
|
|
43
|
+
//# sourceMappingURL=agent-cancelled-error.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-cancelled-error.mjs","names":[],"sources":["../../../../../../@warlock.js/ai/src/errors/agent-cancelled-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 AgentCancelledError}. `cancelledAt` is the\n * ISO-8601 timestamp at which the abort was observed; `reason`\n * carries the value the caller supplied to `controller.abort(reason)`\n * when present.\n */\nexport type AgentCancelledErrorOptions = AIErrorOptions & {\n cancelledAt?: string;\n reason?: string;\n};\n\n/**\n * Agent run was cancelled via `AbortSignal` before it could finish.\n * Between-trip cancellation is guaranteed; mid-trip cancellation is\n * best-effort (the signal is threaded into the provider adapter's\n * HTTP client when supported).\n *\n * Surfaced on `result.error` rather than thrown — `agent.execute()`\n * still returns with `report.status = \"cancelled\"` and partial trip\n * history intact. Consumers branch on the class (not the message) to\n * distinguish caller-initiated stops from other failures.\n *\n * **Why split from `AgentExecutionError`.** Cancellation is a\n * different operational signal from \"the agent crashed\" — retry\n * policy and dashboards typically want different behavior for each.\n * Keeping cancellation in its own class lets the category\n * (`\"cancelled\"`) be set declaratively per type instead of inferred\n * from a `context.cancelled === true` flag.\n *\n * @example\n * const result = await agent.execute(input, { signal });\n * if (result.error instanceof AgentCancelledError) {\n * // caller pulled the plug — don't retry, surface a \"stopped\" UI\n * return { status: \"cancelled\" };\n * }\n */\nexport class AgentCancelledError extends AgentExecutionError {\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?: AgentCancelledErrorOptions) {\n super(message, options, \"AGENT_CANCELLED\");\n this.name = \"AgentCancelledError\";\n this.cancelledAt = options?.cancelledAt;\n this.reason = options?.reason;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwCA,IAAa,sBAAb,cAAyC,oBAAoB;;yBACH;;CAKxD,AAAO,YAAY,SAAiB,SAAsC;EACxE,MAAM,SAAS,SAAS,iBAAiB;EACzC,KAAK,OAAO;EACZ,KAAK,cAAc,SAAS;EAC5B,KAAK,SAAS,SAAS;CACzB;AACF"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { AIErrorCode } from "./error-code.type.mjs";
|
|
2
|
+
import { AIError, AIErrorOptions } from "./ai-error.mjs";
|
|
3
|
+
|
|
4
|
+
//#region ../../@warlock.js/ai/src/errors/agent-execution-error.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* Base for agent runtime failures that aren't schema / tool / provider
|
|
7
|
+
* problems — runtime-structural issues inside the trip loop or
|
|
8
|
+
* authoring-time middleware misconfiguration. Two specialized
|
|
9
|
+
* subclasses cover the two non-generic cases:
|
|
10
|
+
*
|
|
11
|
+
* - {@link AgentCancelledError} (`AGENT_CANCELLED`) — caller-driven
|
|
12
|
+
* abort via `AbortSignal`.
|
|
13
|
+
* - {@link AgentMaxTripsError} (`AGENT_MAX_TRIPS`) — trip loop hit
|
|
14
|
+
* the `maxTrips` cap without a natural stop.
|
|
15
|
+
*
|
|
16
|
+
* Use the base class directly for anything else (unregistered tool
|
|
17
|
+
* dispatch, authoring-time middleware validation, surprise
|
|
18
|
+
* exceptions). The subclasses exist so consumers can branch on a
|
|
19
|
+
* dedicated `instanceof` / category without inferring from `context`
|
|
20
|
+
* flags or parsing the message.
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* if (result.error?.code === "AGENT_EXEC_FAILED") {
|
|
24
|
+
* logger.warn("unexpected agent failure", result.error.context);
|
|
25
|
+
* }
|
|
26
|
+
*/
|
|
27
|
+
declare class AgentExecutionError extends AIError {
|
|
28
|
+
constructor(message: string, options?: AIErrorOptions, code?: AIErrorCode);
|
|
29
|
+
}
|
|
30
|
+
//#endregion
|
|
31
|
+
export { AgentExecutionError };
|
|
32
|
+
//# sourceMappingURL=agent-execution-error.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-execution-error.d.mts","names":[],"sources":["../../../../../../@warlock.js/ai/src/errors/agent-execution-error.ts"],"mappings":";;;;;;AAyBA;;;;;;;;;;;;;;;;AAI2C;;;;cAJ9B,mBAAA,SAA4B,OAAA;cAErC,OAAA,UACA,OAAA,GAAU,cAAA,EACV,IAAA,GAAM,WAAA;AAAA"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { AIError } from "./ai-error.mjs";
|
|
2
|
+
|
|
3
|
+
//#region ../../@warlock.js/ai/src/errors/agent-execution-error.ts
|
|
4
|
+
/**
|
|
5
|
+
* Base for agent runtime failures that aren't schema / tool / provider
|
|
6
|
+
* problems — runtime-structural issues inside the trip loop or
|
|
7
|
+
* authoring-time middleware misconfiguration. Two specialized
|
|
8
|
+
* subclasses cover the two non-generic cases:
|
|
9
|
+
*
|
|
10
|
+
* - {@link AgentCancelledError} (`AGENT_CANCELLED`) — caller-driven
|
|
11
|
+
* abort via `AbortSignal`.
|
|
12
|
+
* - {@link AgentMaxTripsError} (`AGENT_MAX_TRIPS`) — trip loop hit
|
|
13
|
+
* the `maxTrips` cap without a natural stop.
|
|
14
|
+
*
|
|
15
|
+
* Use the base class directly for anything else (unregistered tool
|
|
16
|
+
* dispatch, authoring-time middleware validation, surprise
|
|
17
|
+
* exceptions). The subclasses exist so consumers can branch on a
|
|
18
|
+
* dedicated `instanceof` / category without inferring from `context`
|
|
19
|
+
* flags or parsing the message.
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* if (result.error?.code === "AGENT_EXEC_FAILED") {
|
|
23
|
+
* logger.warn("unexpected agent failure", result.error.context);
|
|
24
|
+
* }
|
|
25
|
+
*/
|
|
26
|
+
var AgentExecutionError = class extends AIError {
|
|
27
|
+
constructor(message, options, code = "AGENT_EXEC_FAILED") {
|
|
28
|
+
super(code, message, options);
|
|
29
|
+
this.name = "AgentExecutionError";
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
//#endregion
|
|
34
|
+
export { AgentExecutionError };
|
|
35
|
+
//# sourceMappingURL=agent-execution-error.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-execution-error.mjs","names":[],"sources":["../../../../../../@warlock.js/ai/src/errors/agent-execution-error.ts"],"sourcesContent":["import { AIError, type AIErrorOptions } from \"./ai-error\";\nimport type { AIErrorCode } from \"./error-code.type\";\n\n/**\n * Base for agent runtime failures that aren't schema / tool / provider\n * problems — runtime-structural issues inside the trip loop or\n * authoring-time middleware misconfiguration. Two specialized\n * subclasses cover the two non-generic cases:\n *\n * - {@link AgentCancelledError} (`AGENT_CANCELLED`) — caller-driven\n * abort via `AbortSignal`.\n * - {@link AgentMaxTripsError} (`AGENT_MAX_TRIPS`) — trip loop hit\n * the `maxTrips` cap without a natural stop.\n *\n * Use the base class directly for anything else (unregistered tool\n * dispatch, authoring-time middleware validation, surprise\n * exceptions). The subclasses exist so consumers can branch on a\n * dedicated `instanceof` / category without inferring from `context`\n * flags or parsing the message.\n *\n * @example\n * if (result.error?.code === \"AGENT_EXEC_FAILED\") {\n * logger.warn(\"unexpected agent failure\", result.error.context);\n * }\n */\nexport class AgentExecutionError extends AIError {\n public constructor(\n message: string,\n options?: AIErrorOptions,\n code: AIErrorCode = \"AGENT_EXEC_FAILED\",\n ) {\n super(code, message, options);\n this.name = \"AgentExecutionError\";\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAyBA,IAAa,sBAAb,cAAyC,QAAQ;CAC/C,AAAO,YACL,SACA,SACA,OAAoB,qBACpB;EACA,MAAM,MAAM,SAAS,OAAO;EAC5B,KAAK,OAAO;CACd;AACF"}
|