@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,117 @@
|
|
|
1
|
+
import { AIError } from "../../errors/ai-error.mjs";
|
|
2
|
+
import { Usage } from "../result/usage.type.mjs";
|
|
3
|
+
import { Next } from "./next.type.mjs";
|
|
4
|
+
import { EvaluateResult } from "./evaluate-context.type.mjs";
|
|
5
|
+
|
|
6
|
+
//#region ../../@warlock.js/ai/src/contracts/supervisor/iteration-snapshot.type.d.ts
|
|
7
|
+
/**
|
|
8
|
+
* Per-branch snapshot captured during dispatch — one per intent that
|
|
9
|
+
* ran in the iteration. The persistence-grade record of what each
|
|
10
|
+
* agent did, kept frozen (`Readonly`) so consumers can safely pass
|
|
11
|
+
* snapshots across async boundaries without defensive cloning.
|
|
12
|
+
*
|
|
13
|
+
* Keyed into `IterationSnapshot.result` by the intent name (the key
|
|
14
|
+
* from the supervisor's `intents` config). Absent key = the intent
|
|
15
|
+
* didn't dispatch this iteration.
|
|
16
|
+
*/
|
|
17
|
+
type AgentBranchSnapshot = Readonly<{
|
|
18
|
+
/** The `intents` map key that identified this dispatch. */intent: string; /** Resolved input string the agent/workflow received. */
|
|
19
|
+
input: string; /** Output after the per-agent `output` transformer (if any). */
|
|
20
|
+
output: unknown;
|
|
21
|
+
usage: Usage;
|
|
22
|
+
startedAt: string;
|
|
23
|
+
endedAt: string;
|
|
24
|
+
duration: number; /** Typed error if this branch failed — siblings still ran. */
|
|
25
|
+
error?: AIError;
|
|
26
|
+
}>;
|
|
27
|
+
/**
|
|
28
|
+
* Forensic record of the receptionist (`ackAgent`) run. Set on
|
|
29
|
+
* `SupervisorReport.ack` only when an ack agent was configured AND the
|
|
30
|
+
* run started fresh (resumes don't re-fire ack). Mirrors
|
|
31
|
+
* `AgentBranchSnapshot` shape minus the per-iteration `intent` field —
|
|
32
|
+
* ack is not an iterating intent, it's a one-shot kickoff.
|
|
33
|
+
*/
|
|
34
|
+
type AckSnapshot = Readonly<{
|
|
35
|
+
input: string; /** Ack output after schema validation (if `ackAgent.output` declared). */
|
|
36
|
+
output: unknown;
|
|
37
|
+
usage: Usage;
|
|
38
|
+
startedAt: string;
|
|
39
|
+
endedAt: string;
|
|
40
|
+
duration: number;
|
|
41
|
+
/**
|
|
42
|
+
* Set when the ack agent failed. Run continues regardless — the
|
|
43
|
+
* receptionist tripping doesn't stop the specialist from doing the
|
|
44
|
+
* actual job.
|
|
45
|
+
*/
|
|
46
|
+
error?: AIError;
|
|
47
|
+
}>;
|
|
48
|
+
/**
|
|
49
|
+
* Origin of a dispatch decision, recorded for debugging and drift
|
|
50
|
+
* analysis. `initialAgent` fires only on turn 0 when the supervisor
|
|
51
|
+
* was configured to skip the router on the first iteration.
|
|
52
|
+
*/
|
|
53
|
+
type DecisionSource = "route" | "router" | "initialAgent" | "classifier";
|
|
54
|
+
/**
|
|
55
|
+
* Dispatch decision record — everything a reader needs to answer the
|
|
56
|
+
* question "why did this iteration run these agents?" without
|
|
57
|
+
* replaying the router agent.
|
|
58
|
+
*/
|
|
59
|
+
type IterationDecision = Readonly<{
|
|
60
|
+
source: DecisionSource; /** The raw routing value — string, string[], or END sentinel. */
|
|
61
|
+
next: Next;
|
|
62
|
+
/**
|
|
63
|
+
* Router agents may include a `reasoning` field alongside `next`
|
|
64
|
+
* in their output schema; when present it's preserved here.
|
|
65
|
+
*/
|
|
66
|
+
reasoning?: string; /** Wall-clock time spent deciding (router call or callback). */
|
|
67
|
+
durationMs: number;
|
|
68
|
+
}>;
|
|
69
|
+
/**
|
|
70
|
+
* One full iteration's forensic record, written after the iteration
|
|
71
|
+
* settles (agents returned, evaluate ran, state updated). The
|
|
72
|
+
* `snapshots[]` array on `SupervisorReport` is the primary debug
|
|
73
|
+
* artifact — users debugging routing bugs ask "why did it pick X on
|
|
74
|
+
* turn 3?" and the answer is here.
|
|
75
|
+
*
|
|
76
|
+
* See design §10 for why `result` is a `Record` keyed by intent and
|
|
77
|
+
* not an array — load-bearing design call, don't normalize.
|
|
78
|
+
*/
|
|
79
|
+
type IterationSnapshot = Readonly<{
|
|
80
|
+
/** Zero-indexed iteration number. */iteration: number;
|
|
81
|
+
/**
|
|
82
|
+
* Per-branch dispatch records keyed by intent. Empty object only
|
|
83
|
+
* when the iteration terminated before dispatching (e.g. the very
|
|
84
|
+
* first decision returned `END`).
|
|
85
|
+
*/
|
|
86
|
+
result: Record<string, AgentBranchSnapshot>;
|
|
87
|
+
decision: IterationDecision; /** Present only if `evaluate` ran this iteration. */
|
|
88
|
+
evaluateVerdict?: EvaluateResult;
|
|
89
|
+
/**
|
|
90
|
+
* Supervisor state at the end of this iteration (after every
|
|
91
|
+
* branch's strip-merge). Snapshot persistence stores this so
|
|
92
|
+
* `resume()` can rehydrate state without replaying intents.
|
|
93
|
+
*
|
|
94
|
+
* Phase 3.4 (Stage 4b) — added as part of the state model
|
|
95
|
+
* rollout.
|
|
96
|
+
*/
|
|
97
|
+
state: Record<string, unknown>;
|
|
98
|
+
/**
|
|
99
|
+
* Raw `ctx.artifacts` bag captured at this iteration's merge point
|
|
100
|
+
* — BEFORE `finalizeArtifacts` (or auto-spread) reshaped it into
|
|
101
|
+
* state (Phase 8 / decisions §38). Pre-merge view; lets observers
|
|
102
|
+
* inspect what the tools contributed before any transformation.
|
|
103
|
+
*
|
|
104
|
+
* Empty `{}` when no tool wrote artifacts this iteration. Frozen
|
|
105
|
+
* (read-only). Reconstructable into a flat aggregate by consumers
|
|
106
|
+
* who want a run-level view: `snapshots.map(s => s.artifacts)`.
|
|
107
|
+
*/
|
|
108
|
+
artifacts: Readonly<Record<string, unknown>>;
|
|
109
|
+
startedAt: string;
|
|
110
|
+
endedAt: string;
|
|
111
|
+
duration: number; /** Sum of router + every branch + evaluate (if evaluate is an agent). */
|
|
112
|
+
usage: Usage; /** Iteration-level fatal error, if one terminated the loop here. */
|
|
113
|
+
error?: AIError;
|
|
114
|
+
}>;
|
|
115
|
+
//#endregion
|
|
116
|
+
export { AckSnapshot, AgentBranchSnapshot, DecisionSource, IterationDecision, IterationSnapshot };
|
|
117
|
+
//# sourceMappingURL=iteration-snapshot.type.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"iteration-snapshot.type.d.mts","names":[],"sources":["../../../../../../../@warlock.js/ai/src/contracts/supervisor/iteration-snapshot.type.ts"],"mappings":";;;;;;;;AAeA;;;;;;;;KAAY,mBAAA,GAAsB,QAAA;EAEhC,2DAAA,MAAA,UAIA;EAFA,KAAA,UAGO;EADP,MAAA;EACA,KAAA,EAAO,KAAA;EACP,SAAA;EACA,OAAA;EACA,QAAA,UAEe;EAAf,KAAA,GAAQ,OAAA;AAAA;;;;;;;;KAUE,WAAA,GAAc,QAAA;EACxB,KAAA,UAEA;EAAA,MAAA;EACA,KAAA,EAAO,KAAA;EACP,SAAA;EACA,OAAA;EACA,QAAA;EAMA;;;AAAe;AAQjB;EARE,KAAA,GAAQ,OAAA;AAAA;;AAQgB;AAO1B;;;KAPY,cAAA;;;;;;KAOA,iBAAA,GAAoB,QAAA;EAC9B,MAAA,EAAQ,cAAA,EAER;EAAA,IAAA,EAAM,IAAA;EAKN;;;AAEU;EAFV,SAAA,WAe2B;EAb3B,UAAA;AAAA;;;;;;;;;;;KAaU,iBAAA,GAAoB,QAAA;EAAA,qCAE9B,SAAA;EAMA;;;;;EAAA,MAAA,EAAQ,MAAA,SAAe,mBAAA;EACvB,QAAA,EAAU,iBAAA,EAWV;EATA,eAAA,GAAkB,cAAA;EAoBlB;;;;;;;;EAXA,KAAA,EAAO,MAAA;EAkBC;;AAAO;;;;;;;;EAPf,SAAA,EAAW,QAAA,CAAS,MAAA;EACpB,SAAA;EACA,OAAA;EACA,QAAA;EAEA,KAAA,EAAO,KAAA;EAEP,KAAA,GAAQ,OAAA;AAAA"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { EndSentinel } from "../end.type.mjs";
|
|
2
|
+
|
|
3
|
+
//#region ../../@warlock.js/ai/src/contracts/supervisor/next.type.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* The legal return shape of a supervisor's dispatch decision — what
|
|
6
|
+
* both `route` callbacks and router agents produce for `next`:
|
|
7
|
+
*
|
|
8
|
+
* - `string` — single agent key; supervisor dispatches that one agent.
|
|
9
|
+
* - `string[]` — fan-out; supervisor dispatches all listed keys in
|
|
10
|
+
* parallel via `Promise.all`.
|
|
11
|
+
* - `EndSentinel` — the framework-global `END` constant; terminates.
|
|
12
|
+
*
|
|
13
|
+
* Shape decides dispatch; there is no separate "strategy" enum.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* import { END, type Next } from "@warlock.js/ai";
|
|
17
|
+
*
|
|
18
|
+
* const single: Next = "triage";
|
|
19
|
+
* const fanOut: Next = ["orderLookup", "billingLookup"];
|
|
20
|
+
* const stop: Next = END;
|
|
21
|
+
*/
|
|
22
|
+
type Next = string | string[] | EndSentinel;
|
|
23
|
+
//#endregion
|
|
24
|
+
export { Next };
|
|
25
|
+
//# sourceMappingURL=next.type.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"next.type.d.mts","names":[],"sources":["../../../../../../../@warlock.js/ai/src/contracts/supervisor/next.type.ts"],"mappings":";;;;;AAoBA;;;;AAAkD;;;;;;;;;;;;KAAtC,IAAA,uBAA2B,WAAW"}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { Message } from "../conversation-message.type.mjs";
|
|
2
|
+
import { IterationSnapshot } from "./iteration-snapshot.type.mjs";
|
|
3
|
+
import { SupervisorInput } from "./supervisor-input.type.mjs";
|
|
4
|
+
import { EvaluateResult } from "./evaluate-context.type.mjs";
|
|
5
|
+
import { ClassifierSnapshot } from "./classifier-context.type.mjs";
|
|
6
|
+
|
|
7
|
+
//#region ../../@warlock.js/ai/src/contracts/supervisor/route-context.type.d.ts
|
|
8
|
+
/**
|
|
9
|
+
* Context passed to a supervisor's `route` callback (deterministic
|
|
10
|
+
* dispatch mode) and also exposed to router-agent input composers
|
|
11
|
+
* and per-agent `input` transformers.
|
|
12
|
+
*
|
|
13
|
+
* The context is read-only from the callback's perspective —
|
|
14
|
+
* mutating it is a bug; consumers that need derived state should
|
|
15
|
+
* build it in the callback body.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* route: (ctx) => {
|
|
19
|
+
* if (ctx.iteration >= 5) { return END; }
|
|
20
|
+
* if (ctx.state.draft && !ctx.state.critique) { return "critic"; }
|
|
21
|
+
* return "writer";
|
|
22
|
+
* }
|
|
23
|
+
*/
|
|
24
|
+
type RouteContext<TState = Record<string, unknown>> = {
|
|
25
|
+
/** Zero-indexed iteration number — turn 0 is the first run. */iteration: number;
|
|
26
|
+
/**
|
|
27
|
+
* The supervisor's original `execute(input)` value. Either a raw
|
|
28
|
+
* string or a structured `Record<string, unknown>` payload — see
|
|
29
|
+
* `SupervisorInput`.
|
|
30
|
+
*/
|
|
31
|
+
input: SupervisorInput;
|
|
32
|
+
/**
|
|
33
|
+
* Per-execute typed accumulator. Updated after each iteration's
|
|
34
|
+
* intents merge their outputs. Read-only from the route callback;
|
|
35
|
+
* built up by intents themselves.
|
|
36
|
+
*/
|
|
37
|
+
state: TState;
|
|
38
|
+
/**
|
|
39
|
+
* Every completed iteration's snapshot, in chronological order.
|
|
40
|
+
* On turn 0 this is empty.
|
|
41
|
+
*
|
|
42
|
+
* Renamed from `history` (Q2).
|
|
43
|
+
*/
|
|
44
|
+
iterations: IterationSnapshot[];
|
|
45
|
+
/**
|
|
46
|
+
* Reviewer feedback string produced by `evaluate.feedback` at the
|
|
47
|
+
* end of the previous iteration. Visible to router/route only
|
|
48
|
+
* (Q18 — feedback is router-targeted; not auto-injected into agent
|
|
49
|
+
* placeholders). Absent on turn 0 and turns where evaluate didn't
|
|
50
|
+
* return a feedback string.
|
|
51
|
+
*/
|
|
52
|
+
feedback?: string;
|
|
53
|
+
/**
|
|
54
|
+
* Full previous-iteration evaluate verdict (raw). Available to
|
|
55
|
+
* route callbacks that want the full shape (e.g. inspect
|
|
56
|
+
* `reassignTo` in addition to `feedback`).
|
|
57
|
+
*/
|
|
58
|
+
evaluateFeedback?: EvaluateResult;
|
|
59
|
+
/**
|
|
60
|
+
* Read-only request-scoped bag supplied via
|
|
61
|
+
* `execute(input, { context })`. Shallow-copied + frozen at intake
|
|
62
|
+
* so callbacks can't mutate the caller's object. Defaults to a
|
|
63
|
+
* frozen `{}` when no context was passed. NOT persisted in
|
|
64
|
+
* snapshots — re-supply on `resume()`.
|
|
65
|
+
*/
|
|
66
|
+
context: Readonly<Record<string, unknown>>;
|
|
67
|
+
/**
|
|
68
|
+
* Prior conversation messages supplied via
|
|
69
|
+
* `execute(input, { history })`. Read-only — passed by reference, not
|
|
70
|
+
* copied. Defaults to an empty array when no history was supplied.
|
|
71
|
+
* NOT persisted in snapshots — re-supply on `resume()`.
|
|
72
|
+
*/
|
|
73
|
+
history: ReadonlyArray<Message>;
|
|
74
|
+
/**
|
|
75
|
+
* Resolved natural-language objective from `SupervisorConfig.goal`.
|
|
76
|
+
* `undefined` when the supervisor was configured without one.
|
|
77
|
+
* Read-only.
|
|
78
|
+
*/
|
|
79
|
+
goal?: string;
|
|
80
|
+
/**
|
|
81
|
+
* Forensic record of iter-0 classifier run (Phase 7 / decisions §37).
|
|
82
|
+
* Present only when `SupervisorConfig.classifier` was configured
|
|
83
|
+
* AND iter 0 has completed; `undefined` for iter-0 routing
|
|
84
|
+
* decisions (classifier hasn't run yet) and for supervisors that
|
|
85
|
+
* don't use classifier mode.
|
|
86
|
+
*/
|
|
87
|
+
classifier?: Readonly<ClassifierSnapshot>;
|
|
88
|
+
};
|
|
89
|
+
//#endregion
|
|
90
|
+
export { RouteContext };
|
|
91
|
+
//# sourceMappingURL=route-context.type.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"route-context.type.d.mts","names":[],"sources":["../../../../../../../@warlock.js/ai/src/contracts/supervisor/route-context.type.ts"],"mappings":";;;;;;;;;AAsBA;;;;;;;;;;;;;;KAAY,YAAA,UAAsB,MAAA;EAgEX,+DA9DrB,SAAA;EAFgC;;;;;EAQhC,KAAA,EAAO,eAAA;EAaP;;;;;EAPA,KAAA,EAAO,MAAA;EA6BE;;;;;;EAtBT,UAAA,EAAY,iBAAA;EA2CC;;;AAA2B;;;;EAnCxC,QAAA;;;;;;EAMA,gBAAA,GAAmB,cAAA;;;;;;;;EAQnB,OAAA,EAAS,QAAA,CAAS,MAAA;;;;;;;EAOlB,OAAA,EAAS,aAAA,CAAc,OAAA;;;;;;EAMvB,IAAA;;;;;;;;EAQA,UAAA,GAAa,QAAA,CAAS,kBAAA;AAAA"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { Message } from "../conversation-message.type.mjs";
|
|
2
|
+
import { AgentContract } from "../agent/agent.contract.mjs";
|
|
3
|
+
import { RouteContext } from "./route-context.type.mjs";
|
|
4
|
+
|
|
5
|
+
//#region ../../@warlock.js/ai/src/contracts/supervisor/router-entry.type.d.ts
|
|
6
|
+
/**
|
|
7
|
+
* Object form for `SupervisorConfig.router` — symmetric with
|
|
8
|
+
* `IntentEntry`, but a strict subset:
|
|
9
|
+
*
|
|
10
|
+
* - `agent` — the routing LLM agent. Required.
|
|
11
|
+
* - `placeholders` — values fed into the router agent's
|
|
12
|
+
* `systemPrompt` template. Lets dev surface state-aware context
|
|
13
|
+
* ("user is a VIP", "iteration budget remaining") into the routing
|
|
14
|
+
* prompt without forcing it through the user-message scaffolding.
|
|
15
|
+
* - `input` — full override for the per-turn user message the router
|
|
16
|
+
* agent receives. By default the supervisor builds a structured
|
|
17
|
+
* message (intents list + state + feedback + original input).
|
|
18
|
+
* Returning a string here REPLACES that scaffolding entirely —
|
|
19
|
+
* you take responsibility for surfacing whatever the router needs
|
|
20
|
+
* to make its decision.
|
|
21
|
+
*
|
|
22
|
+
* Deliberately omits:
|
|
23
|
+
* - `description` — the router isn't an intent, has no peer to
|
|
24
|
+
* describe itself to.
|
|
25
|
+
* - `output` — the framework owns the canonical `{ next, reasoning }`
|
|
26
|
+
* schema; overriding it would silently break dispatch resolution.
|
|
27
|
+
* - `next` — the router IS the dispatcher; a `next` directive on
|
|
28
|
+
* the router itself is meaningless.
|
|
29
|
+
*
|
|
30
|
+
* Shorthand: passing a bare `AgentContract` to `router` is equivalent
|
|
31
|
+
* to `{ agent }` — same as `IntentEntry`'s shorthand on `intents`.
|
|
32
|
+
*/
|
|
33
|
+
type RouterEntry<TState = Record<string, unknown>> = {
|
|
34
|
+
/** The router agent — must declare an output that includes `next`. */agent: AgentContract<unknown>;
|
|
35
|
+
/**
|
|
36
|
+
* Per-turn template values fed into the router agent's
|
|
37
|
+
* `systemPrompt`. Receives the same `RouteContext` the route
|
|
38
|
+
* callback would.
|
|
39
|
+
*/
|
|
40
|
+
placeholders?: (ctx: RouteContext<TState>) => Record<string, unknown>;
|
|
41
|
+
/**
|
|
42
|
+
* Replaces the supervisor's default per-turn user message.
|
|
43
|
+
* Returning a string short-circuits the built-in scaffolding —
|
|
44
|
+
* the router sees only what you produce.
|
|
45
|
+
*/
|
|
46
|
+
input?: (ctx: RouteContext<TState>) => string;
|
|
47
|
+
/**
|
|
48
|
+
* Custom history slicer for the router agent. When supplied, REPLACES
|
|
49
|
+
* the default slice (full history clipped by
|
|
50
|
+
* `SupervisorConfig.historyWindow.router` if set) — return whatever
|
|
51
|
+
* subset/transformation the router should see.
|
|
52
|
+
*
|
|
53
|
+
* Precedence: `history` callback > `historyWindow.router` > full
|
|
54
|
+
* history. Return `[]` to send no history at all.
|
|
55
|
+
*
|
|
56
|
+
* @example
|
|
57
|
+
* router: {
|
|
58
|
+
* agent: routerAgent,
|
|
59
|
+
* // last 3 user turns only — keep router prompt small
|
|
60
|
+
* history: (ctx) => ctx.history.filter(m => m.role === "user").slice(-3),
|
|
61
|
+
* }
|
|
62
|
+
*/
|
|
63
|
+
history?: (ctx: RouteContext<TState>) => Message[] | ReadonlyArray<Message>;
|
|
64
|
+
};
|
|
65
|
+
//#endregion
|
|
66
|
+
export { RouterEntry };
|
|
67
|
+
//# sourceMappingURL=router-entry.type.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"router-entry.type.d.mts","names":[],"sources":["../../../../../../../@warlock.js/ai/src/contracts/supervisor/router-entry.type.ts"],"mappings":";;;;;;;AA+BA;;;;;;;;;;;;;;;;;;;;;;;;;KAAY,WAAA,UAAqB,MAAA;EAc/B,sEAZA,KAAA,EAAO,aAAA;EAYoB;;;;;EAN3B,YAAA,IAAgB,GAAA,EAAK,YAAA,CAAa,MAAA,MAAY,MAAA;EAuBL;;;;AAAiC;EAjB1E,KAAA,IAAS,GAAA,EAAK,YAAA,CAAa,MAAA;;;;;;;;;;;;;;;;;EAiB3B,OAAA,IAAW,GAAA,EAAK,YAAA,CAAa,MAAA,MAAY,OAAA,KAAY,aAAA,CAAc,OAAA;AAAA"}
|
|
@@ -0,0 +1,356 @@
|
|
|
1
|
+
import { Message } from "../conversation-message.type.mjs";
|
|
2
|
+
import { AgentContract } from "../agent/agent.contract.mjs";
|
|
3
|
+
import { SystemPromptContract } from "../system-prompt.contract.mjs";
|
|
4
|
+
import { Next } from "./next.type.mjs";
|
|
5
|
+
import { EvaluateContext, EvaluateResult } from "./evaluate-context.type.mjs";
|
|
6
|
+
import { RouteContext } from "./route-context.type.mjs";
|
|
7
|
+
import { AckConfig } from "./ack-entry.type.mjs";
|
|
8
|
+
import { SupervisorIntentValue } from "./intent-entry.type.mjs";
|
|
9
|
+
import { RouterEntry } from "./router-entry.type.mjs";
|
|
10
|
+
import { ClassifierConfig } from "./classifier-context.type.mjs";
|
|
11
|
+
import { SupervisorEventMap } from "../events/event-map.type.mjs";
|
|
12
|
+
import { StandardSchemaV1 } from "@standard-schema/spec";
|
|
13
|
+
import { CacheDriver } from "@warlock.js/cache";
|
|
14
|
+
|
|
15
|
+
//#region ../../@warlock.js/ai/src/contracts/supervisor/supervisor-config.type.d.ts
|
|
16
|
+
/**
|
|
17
|
+
* Handler function for a single supervisor event. Receives the
|
|
18
|
+
* event's typed payload; return value is ignored.
|
|
19
|
+
*/
|
|
20
|
+
type SupervisorEventHandler<K extends keyof SupervisorEventMap> = (payload: SupervisorEventMap[K]) => void;
|
|
21
|
+
type SupervisorEventHandlers = Partial<{ [K in keyof SupervisorEventMap]: SupervisorEventHandler<K> }>;
|
|
22
|
+
/**
|
|
23
|
+
* Full factory config for `ai.supervisor(config)`.
|
|
24
|
+
*
|
|
25
|
+
* Two dispatch modes are exposed as mutually-exclusive top-level
|
|
26
|
+
* fields: `route` (deterministic callback) XOR `router` (LLM-driven
|
|
27
|
+
* agent). The factory throws `SupervisorFailedError` at author time
|
|
28
|
+
* when both or neither is present. `evaluate` pairs with both `route`
|
|
29
|
+
* and `router` (Phase 3.4 Q9 — the earlier router-only restriction
|
|
30
|
+
* was lifted).
|
|
31
|
+
*
|
|
32
|
+
* `intents` is a `Record<string, …>` — keys are intent names the
|
|
33
|
+
* router/route emits. Values are shorthand `AgentContract` /
|
|
34
|
+
* `WorkflowInstance` or the full `IntentEntry` object form. (Phase
|
|
35
|
+
* 3.3 stage 3b extends the union with callback dispatch.)
|
|
36
|
+
*
|
|
37
|
+
* `output` is a Standard Schema; when provided, supervisor validates
|
|
38
|
+
* the final value before populating `result.data`. On failure the
|
|
39
|
+
* error surfaces via `result.error` (never thrown).
|
|
40
|
+
*
|
|
41
|
+
* Phase 3.4 (Stage 4c) — `combine` removed. Fan-out branches now
|
|
42
|
+
* shallow-merge into supervisor `state` via per-intent `output`
|
|
43
|
+
* schemas (Q11/Q15). Use a callback-orchestrator intent for custom
|
|
44
|
+
* merging (max, sum, deep merge): dispatch siblings via
|
|
45
|
+
* `ctx.intents.X.execute()` and assemble the result yourself.
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* const supervisor = ai.supervisor<{ response: string; refund: boolean }>({
|
|
49
|
+
* name: "customer-support",
|
|
50
|
+
* systemPrompt: ai.systemPrompt().persona("You coordinate a support team."),
|
|
51
|
+
* router: routerAgent,
|
|
52
|
+
* intents: { triage, orderLookup, billingLookup, resolver },
|
|
53
|
+
* evaluate: (ctx) =>
|
|
54
|
+
* ctx.state.response ? { satisfied: true } : undefined,
|
|
55
|
+
* maxIterations: 6,
|
|
56
|
+
* output: v.object({ response: v.string(), refund: v.boolean() }),
|
|
57
|
+
* snapshotStore: cache.driver("redis", { client }),
|
|
58
|
+
* });
|
|
59
|
+
*/
|
|
60
|
+
type SupervisorConfig<TOutput = unknown, TState = TOutput, TIntents extends Record<string, SupervisorIntentValue> = Record<string, SupervisorIntentValue>, TArtifacts = Record<string, unknown>> = {
|
|
61
|
+
/** Stable identifier — used in logs, events, snapshots, signature. */name: string;
|
|
62
|
+
/**
|
|
63
|
+
* Dev-curated version string mirrored onto every report node this
|
|
64
|
+
* supervisor produces. Free-form — semver, date, hash. Bump when
|
|
65
|
+
* routing logic, intent set, or evaluate criteria change in a way
|
|
66
|
+
* worth distinguishing in trip archives. The framework neither
|
|
67
|
+
* parses nor compares it; signature drift detection remains
|
|
68
|
+
* independent.
|
|
69
|
+
*/
|
|
70
|
+
version?: string;
|
|
71
|
+
/**
|
|
72
|
+
* Prepended to the router agent's own system prompt (router mode
|
|
73
|
+
* only). Does not touch child agents' system prompts — they stay
|
|
74
|
+
* independent, reusable units.
|
|
75
|
+
*/
|
|
76
|
+
systemPrompt?: SystemPromptContract | string;
|
|
77
|
+
/**
|
|
78
|
+
* Natural-language statement of what "done" looks like for this
|
|
79
|
+
* supervisor — the high-level objective every iteration is
|
|
80
|
+
* working toward. First-class concept rather than buried in
|
|
81
|
+
* `systemPrompt` so:
|
|
82
|
+
*
|
|
83
|
+
* - The router agent's per-turn user message includes it explicitly,
|
|
84
|
+
* so routing decisions are objective-aware without manual prompt
|
|
85
|
+
* stuffing.
|
|
86
|
+
* - `route` / `evaluate` / dispatch callbacks receive it on
|
|
87
|
+
* `ctx.goal` (read-only) for state-driven satisfaction checks
|
|
88
|
+
* without hardcoded strings.
|
|
89
|
+
* - Dispatched agents can reference it via the `{{goal}}`
|
|
90
|
+
* placeholder on their own systemPrompt templates without the
|
|
91
|
+
* supervisor wiring it through `entry.placeholders` manually.
|
|
92
|
+
*
|
|
93
|
+
* Accepts a plain `string` or a `SystemPromptContract` (for
|
|
94
|
+
* placeholder-rendered goals); resolved to text at construction.
|
|
95
|
+
*
|
|
96
|
+
* NOT persisted in snapshots — re-resolved from the config on
|
|
97
|
+
* `resume()`.
|
|
98
|
+
*
|
|
99
|
+
* @example
|
|
100
|
+
* ai.supervisor({
|
|
101
|
+
* name: "ac-recommender",
|
|
102
|
+
* goal: "Recommend an AC unit. Must include BTU calculation, " +
|
|
103
|
+
* "matching catalog product, and city-specific install notes.",
|
|
104
|
+
* router: routerAgent,
|
|
105
|
+
* intents: { ... },
|
|
106
|
+
* evaluate: (ctx) => {
|
|
107
|
+
* if (ctx.state.recommendation && ctx.state.btu && ctx.state.installNotes) {
|
|
108
|
+
* return { satisfied: true };
|
|
109
|
+
* }
|
|
110
|
+
* return undefined;
|
|
111
|
+
* },
|
|
112
|
+
* });
|
|
113
|
+
*/
|
|
114
|
+
goal?: string | SystemPromptContract;
|
|
115
|
+
/**
|
|
116
|
+
* Factory-level default conversation history — the prior turns the
|
|
117
|
+
* supervisor (router + every dispatched agent + ack) sees on each
|
|
118
|
+
* `execute()` call when the caller does NOT supply per-call history.
|
|
119
|
+
*
|
|
120
|
+
* **Precedence:** `execute(input, { history })` (per-call) overrides
|
|
121
|
+
* this entirely when supplied. When neither is set, history is `[]`.
|
|
122
|
+
*
|
|
123
|
+
* Use this for "background" priming messages every run should see —
|
|
124
|
+
* onboarding context, persona warm-up, baseline tenant info. For
|
|
125
|
+
* actual chat-driver scenarios where each turn carries fresh prior
|
|
126
|
+
* turns, pass `history` per-call via `execute()` instead.
|
|
127
|
+
*
|
|
128
|
+
* Subject to the same `historyWindow` slicing + per-entry `history`
|
|
129
|
+
* callbacks as per-call history once resolved.
|
|
130
|
+
*
|
|
131
|
+
* NOT persisted in snapshots — `resume()` re-resolves it from the
|
|
132
|
+
* config (or per-call `history` on the resume options).
|
|
133
|
+
*/
|
|
134
|
+
history?: Message[];
|
|
135
|
+
/**
|
|
136
|
+
* LLM-driven dispatch. Accepts either a bare `AgentContract`
|
|
137
|
+
* (shorthand) or a `RouterEntry` object — `{ agent, placeholders?,
|
|
138
|
+
* input? }` — symmetric with `IntentEntry`. The framework injects
|
|
139
|
+
* the canonical `{ next, reasoning }` output schema; do not declare
|
|
140
|
+
* a custom `output` for the router agent. Mutually exclusive with
|
|
141
|
+
* `route`.
|
|
142
|
+
*/
|
|
143
|
+
router?: AgentContract<unknown> | RouterEntry<TState>;
|
|
144
|
+
/**
|
|
145
|
+
* Deterministic dispatch. Runs once per iteration to pick the next
|
|
146
|
+
* intent(s) or terminate. Mutually exclusive with `router`.
|
|
147
|
+
*/
|
|
148
|
+
route?: (ctx: RouteContext<TState>) => Next | Promise<Next>;
|
|
149
|
+
/**
|
|
150
|
+
* Dispatchable units keyed by intent name. Shorthand accepts any
|
|
151
|
+
* `AgentContract` or `WorkflowInstance`; full form is `IntentEntry`
|
|
152
|
+
* with optional overrides for `description`, `input`, `output`.
|
|
153
|
+
* Callback dispatch (`run` shorthand / `IntentRunEntry`) is wired
|
|
154
|
+
* into the union in Phase 3.3.
|
|
155
|
+
*
|
|
156
|
+
* Typed as the literal `TIntents` shape so `ctx.intents.<TAB>`
|
|
157
|
+
* autocompletes against the actual keys the user supplied (Q6).
|
|
158
|
+
*/
|
|
159
|
+
intents: TIntents;
|
|
160
|
+
/**
|
|
161
|
+
* Retrospective verdict callback. Fires after the iteration's
|
|
162
|
+
* intents settle and their outputs have merged into state — never
|
|
163
|
+
* before dispatch. Pairs with both `router` AND `route` modes
|
|
164
|
+
* (Phase 3.4 Q9 — restriction lifted; state-driven termination is
|
|
165
|
+
* useful in either dispatch mode).
|
|
166
|
+
*
|
|
167
|
+
* Receives `ctx.state` (post-merge) so verdicts can be state-aware.
|
|
168
|
+
*/
|
|
169
|
+
evaluate?: (ctx: EvaluateContext<TState>) => EvaluateResult | Promise<EvaluateResult>;
|
|
170
|
+
/**
|
|
171
|
+
* Initial seed for the per-execute state accumulator. Defaults to
|
|
172
|
+
* `{}`. Each intent contributes a slice via shallow-merge across
|
|
173
|
+
* iterations; the final shape is validated against `output` at
|
|
174
|
+
* termination.
|
|
175
|
+
*
|
|
176
|
+
* `TState` defaults to `TOutput` — for the common case where state
|
|
177
|
+
* IS the output shape, you only declare the schema once. Override
|
|
178
|
+
* `TState` (second generic) when the working accumulator carries
|
|
179
|
+
* intermediate fields that don't survive validation.
|
|
180
|
+
*
|
|
181
|
+
* Must be JSON-serializable (Q16) — no functions / Maps / Sets /
|
|
182
|
+
* class instances. Snapshot resume rehydrates `state` from the
|
|
183
|
+
* last persisted iteration.
|
|
184
|
+
*/
|
|
185
|
+
state?: TState;
|
|
186
|
+
/**
|
|
187
|
+
* Hard cap on iteration count. Hitting the cap terminates the run
|
|
188
|
+
* with `MaxIterationsError` on `result.error`. Default: `10`.
|
|
189
|
+
*/
|
|
190
|
+
maxIterations?: number;
|
|
191
|
+
/**
|
|
192
|
+
* When set, turn 0 dispatches this intent directly and skips the
|
|
193
|
+
* first router/route call. Must be a key in `intents`.
|
|
194
|
+
*/
|
|
195
|
+
initialAgent?: string;
|
|
196
|
+
/**
|
|
197
|
+
* Final-state schema. On clean termination the supervisor's
|
|
198
|
+
* accumulated `state` is validated against this; success populates
|
|
199
|
+
* `result.data`, failure surfaces `SchemaValidationError` on
|
|
200
|
+
* `result.error`.
|
|
201
|
+
*
|
|
202
|
+
* Phase 3.4 (Stage 4b) — semantics shifted from "validates the
|
|
203
|
+
* terminal iteration's value" to "validates the accumulated
|
|
204
|
+
* state." Same field name; broader role.
|
|
205
|
+
*/
|
|
206
|
+
output?: StandardSchemaV1<TOutput>;
|
|
207
|
+
/**
|
|
208
|
+
* Optional durable store enabling `supervisor.resume(runId)`.
|
|
209
|
+
* Snapshots are written after every iteration settles plus once
|
|
210
|
+
* more at final completion / cancel / fail. Accepts any
|
|
211
|
+
* `@warlock.js/cache` driver — `MemoryCacheDriver` for dev/tests,
|
|
212
|
+
* `RedisCacheDriver` / `PgCacheDriver` for production.
|
|
213
|
+
*
|
|
214
|
+
* Falls back to `ai.config({ defaultStore })` when omitted. When
|
|
215
|
+
* neither is set, `resume()` throws and snapshot writes silently
|
|
216
|
+
* skip (current behavior preserved).
|
|
217
|
+
*/
|
|
218
|
+
snapshotStore?: CacheDriver<any, any>;
|
|
219
|
+
/**
|
|
220
|
+
* Definition-level event handlers — tier 1 of the 3-tier model.
|
|
221
|
+
* Fire on every run of this supervisor, before instance and
|
|
222
|
+
* per-call handlers.
|
|
223
|
+
*/
|
|
224
|
+
on?: SupervisorEventHandlers;
|
|
225
|
+
/**
|
|
226
|
+
* Optional receptionist — fires in parallel with phase A on
|
|
227
|
+
* iteration 0 only. Streams a brief acknowledgment to the user the
|
|
228
|
+
* moment its first token lands so the UI doesn't show a blank
|
|
229
|
+
* screen while a slow router or specialist works.
|
|
230
|
+
*
|
|
231
|
+
* Three accepted shapes (order of conciseness):
|
|
232
|
+
* - `AckEntry` — `{ agent, placeholders?, input?, output? }` (LLM)
|
|
233
|
+
* - `AckRunEntry` — `{ run, output? }` (pure-code callback)
|
|
234
|
+
* - `AckCallback` — bare `(ctx) => slice` (shorthand)
|
|
235
|
+
*
|
|
236
|
+
* Loses gracefully — if ack hasn't settled by the time the run is
|
|
237
|
+
* otherwise ready to finalize, the slice drops with a warning log
|
|
238
|
+
* and the run completes regardless. See `AckConfig` for full
|
|
239
|
+
* runtime semantics.
|
|
240
|
+
*/
|
|
241
|
+
ack?: AckConfig<TState>;
|
|
242
|
+
/**
|
|
243
|
+
* One-shot iter-0 prelude that classifies the input and dispatches
|
|
244
|
+
* the chosen intent (Phase 7 / decisions §37). Composes with
|
|
245
|
+
* `router` / `route` — when both are configured, classifier drives
|
|
246
|
+
* iter 0 and router/route picks up at iter 1+. When classifier is
|
|
247
|
+
* configured alone (no router, no route), the supervisor terminates
|
|
248
|
+
* after iter 0's branch settles.
|
|
249
|
+
*
|
|
250
|
+
* Accepts the same value-shape union as `intents` and `router`:
|
|
251
|
+
* bare `AgentContract` shorthand, bare callback shorthand, or full
|
|
252
|
+
* object form (`{ agent, placeholders?, input?, history?, refine? }`
|
|
253
|
+
* or `{ run, refine? }`).
|
|
254
|
+
*
|
|
255
|
+
* Output schema is locked at the framework level —
|
|
256
|
+
* `{ intent, reasoning?, confidence? }`. Devs may extend with
|
|
257
|
+
* additional fields by declaring a richer typed schema on their
|
|
258
|
+
* classifier agent; the extra fields strip-merge into supervisor
|
|
259
|
+
* state per the supervisor's `output` schema.
|
|
260
|
+
*
|
|
261
|
+
* **Mutually exclusive with `initialAgent`** — both answer "what
|
|
262
|
+
* runs first?" and coexistence is meaningless. Factory throws
|
|
263
|
+
* `SupervisorFailedError` when both are set.
|
|
264
|
+
*
|
|
265
|
+
* @example
|
|
266
|
+
* classifier: {
|
|
267
|
+
* agent: classifyAgent,
|
|
268
|
+
* refine: async ctx => {
|
|
269
|
+
* // Override on weak-confidence signal:
|
|
270
|
+
* if ((ctx.result.data.confidence ?? 1) < 0.7) {
|
|
271
|
+
* return { intent: "fallback" };
|
|
272
|
+
* }
|
|
273
|
+
* // Halt on policy violation:
|
|
274
|
+
* if (isToxic(ctx.input)) {
|
|
275
|
+
* return END;
|
|
276
|
+
* }
|
|
277
|
+
* },
|
|
278
|
+
* }
|
|
279
|
+
*/
|
|
280
|
+
classifier?: ClassifierConfig<TState>;
|
|
281
|
+
/**
|
|
282
|
+
* Global default windows applied to the prior conversation history
|
|
283
|
+
* supplied via `execute(input, { history })` — keeps the **last N**
|
|
284
|
+
* messages (most recent, chronological) per role.
|
|
285
|
+
*
|
|
286
|
+
* - `router` — slice for the routing LLM. Recommended small (3–5)
|
|
287
|
+
* since the router only needs recent intent signal. Default:
|
|
288
|
+
* unbounded.
|
|
289
|
+
* - `agents` — slice for every dispatched agent/workflow. Default:
|
|
290
|
+
* unbounded.
|
|
291
|
+
* - `ack` — slice for the receptionist. Default: `0` — receptionists
|
|
292
|
+
* are template-y and rarely need scroll-back; full history wastes
|
|
293
|
+
* tokens on a path explicitly chosen for speed. Override per-call
|
|
294
|
+
* via the entry `history` callback when needed.
|
|
295
|
+
*
|
|
296
|
+
* Precedence (per role): entry-level `history` callback >
|
|
297
|
+
* `historyWindow.<role>` > full history (or empty for ack).
|
|
298
|
+
*
|
|
299
|
+
* @example
|
|
300
|
+
* historyWindow: { router: 5, agents: 10 }
|
|
301
|
+
*/
|
|
302
|
+
historyWindow?: {
|
|
303
|
+
router?: number;
|
|
304
|
+
agents?: number;
|
|
305
|
+
ack?: number;
|
|
306
|
+
};
|
|
307
|
+
/**
|
|
308
|
+
* Schema for the artifacts bag tools may write into via
|
|
309
|
+
* `ctx.artifacts` (Phase 5 / decisions §35). Declared once on the
|
|
310
|
+
* supervisor; threaded into every tool registered to the
|
|
311
|
+
* supervisor's agents so `ctx.artifacts.*` autocompletes against
|
|
312
|
+
* `TArtifacts`.
|
|
313
|
+
*
|
|
314
|
+
* The bag starts empty at every iteration boundary, accumulates
|
|
315
|
+
* across all tool calls in that iteration, validates against this
|
|
316
|
+
* schema (when set), then merges into supervisor `state` via
|
|
317
|
+
* `finalizeArtifacts` if supplied — otherwise via auto-spread.
|
|
318
|
+
*
|
|
319
|
+
* Validation failure aborts the run with
|
|
320
|
+
* `SchemaValidationError` carrying the offending iteration on
|
|
321
|
+
* `result.error`.
|
|
322
|
+
*
|
|
323
|
+
* @example
|
|
324
|
+
* artifactsSchema: v.object({
|
|
325
|
+
* blocks: v.array(blockSchema).optional(),
|
|
326
|
+
* citations: v.array(citationSchema).optional(),
|
|
327
|
+
* }),
|
|
328
|
+
*/
|
|
329
|
+
artifactsSchema?: StandardSchemaV1<TArtifacts>;
|
|
330
|
+
/**
|
|
331
|
+
* Per-iteration merger for the artifacts bag (Phase 5 /
|
|
332
|
+
* decisions §35). When omitted the framework auto-spreads:
|
|
333
|
+
* `state = { ...state, ...artifacts }`. Replace semantics —
|
|
334
|
+
* artifact values overwrite same-keyed state values.
|
|
335
|
+
*
|
|
336
|
+
* Supply this callback for concat / dedupe / transform / cross-
|
|
337
|
+
* iteration accumulation. Typical pattern: blocks should
|
|
338
|
+
* accumulate across iterations rather than replace, so the
|
|
339
|
+
* callback concatenates `state.blocks ?? []` with
|
|
340
|
+
* `artifacts.blocks ?? []`.
|
|
341
|
+
*
|
|
342
|
+
* Called once per iteration with the post-branch-merge state and
|
|
343
|
+
* the iteration's accumulated artifacts. The bag resets to `{}`
|
|
344
|
+
* for the next iteration regardless of what the callback does.
|
|
345
|
+
*
|
|
346
|
+
* @example
|
|
347
|
+
* finalizeArtifacts: (state, artifacts) => ({
|
|
348
|
+
* ...state,
|
|
349
|
+
* blocks: [...(state.blocks ?? []), ...(artifacts.blocks ?? [])],
|
|
350
|
+
* }),
|
|
351
|
+
*/
|
|
352
|
+
finalizeArtifacts?: (state: TState, artifacts: TArtifacts) => TState;
|
|
353
|
+
};
|
|
354
|
+
//#endregion
|
|
355
|
+
export { SupervisorConfig, SupervisorEventHandler, SupervisorEventHandlers };
|
|
356
|
+
//# sourceMappingURL=supervisor-config.type.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"supervisor-config.type.d.mts","names":[],"sources":["../../../../../../../@warlock.js/ai/src/contracts/supervisor/supervisor-config.type.ts"],"mappings":";;;;;;;;;;;;;;;;;AAkBA;;KAAY,sBAAA,iBAAuC,kBAAA,KACjD,OAAA,EAAS,kBAAA,CAAmB,CAAA;AAAA,KAGlB,uBAAA,GAA0B,OAAA,eACxB,kBAAA,GAAqB,sBAAA,CAAuB,CAAA;;;;;;;;;AAJ1B;AAGhC;;;;;;;;;;;;;;;AAC2D;AAyC3D;;;;;;;;;;;;;KAAY,gBAAA,6BAED,OAAA,mBACQ,MAAA,SAAe,qBAAA,IAAyB,MAAA,SAAe,qBAAA,gBAC3D,MAAA;EA0FqB,sEAvFlC,IAAA;EA6Fc;;;;;;;;EAnFd,OAAA;EA0G8D;;;;;EAnG9D,YAAA,GAAe,oBAAA;EAkLC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA3IhB,IAAA,YAAgB,oBAAA;EAqC8B;;;;;;;;;;;;;;;;;;;EAhB9C,OAAA,GAAU,OAAA;EAoGV;;;;;;;;EA1FA,MAAA,GAAS,aAAA,YAAyB,WAAA,CAAY,MAAA;EA2K5C;;;;EArKF,KAAA,IAAS,GAAA,EAAK,YAAA,CAAa,MAAA,MAAY,IAAA,GAAO,OAAA,CAAQ,IAAA;EAgMnB;;;;;;;;AAwBiC;;EA5MpE,OAAA,EAAS,QAAA;;;;;;;;;;EAWT,QAAA,IAAY,GAAA,EAAK,eAAA,CAAgB,MAAA,MAAY,cAAA,GAAiB,OAAA,CAAQ,cAAA;;;;;;;;;;;;;;;;EAiBtE,KAAA,GAAQ,MAAA;;;;;EAMR,aAAA;;;;;EAMA,YAAA;;;;;;;;;;;EAYA,MAAA,GAAS,gBAAA,CAAiB,OAAA;;;;;;;;;;;;EAa1B,aAAA,GAAgB,WAAA;;;;;;EAOhB,EAAA,GAAK,uBAAA;;;;;;;;;;;;;;;;;EAkBL,GAAA,GAAM,SAAA,CAAU,MAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAwChB,UAAA,GAAa,gBAAA,CAAiB,MAAA;;;;;;;;;;;;;;;;;;;;;;EAsB9B,aAAA;IACE,MAAA;IACA,MAAA;IACA,GAAA;EAAA;;;;;;;;;;;;;;;;;;;;;;;EAyBF,eAAA,GAAkB,gBAAA,CAAiB,UAAA;;;;;;;;;;;;;;;;;;;;;;;EAwBnC,iBAAA,IAAqB,KAAA,EAAO,MAAA,EAAQ,SAAA,EAAW,UAAA,KAAe,MAAA;AAAA"}
|