@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,235 @@
|
|
|
1
|
+
import { Message } from "../conversation-message.type.mjs";
|
|
2
|
+
import { AgentResult } from "../result/agent-result.type.mjs";
|
|
3
|
+
import { StreamContract } from "../stream/stream.contract.mjs";
|
|
4
|
+
import { AgentContract } from "../agent/agent.contract.mjs";
|
|
5
|
+
import { WorkflowResult } from "../result/workflow-result.type.mjs";
|
|
6
|
+
import { WorkflowInstance, WorkflowRunOptions } from "../workflow/workflow.contract.mjs";
|
|
7
|
+
import { IterationSnapshot } from "./iteration-snapshot.type.mjs";
|
|
8
|
+
import { SupervisorIntentValue } from "./intent-entry.type.mjs";
|
|
9
|
+
import { SupervisorExecuteOptions } from "./supervisor-execute-options.type.mjs";
|
|
10
|
+
import { SupervisorContract } from "./supervisor.contract.mjs";
|
|
11
|
+
import { ClassifierSnapshot } from "./classifier-context.type.mjs";
|
|
12
|
+
import { SupervisorResult } from "../result/supervisor-result.type.mjs";
|
|
13
|
+
import { AgentExecuteOptions } from "../agent/agent-options.type.mjs";
|
|
14
|
+
|
|
15
|
+
//#region ../../@warlock.js/ai/src/contracts/supervisor/dispatch-context.type.d.ts
|
|
16
|
+
/**
|
|
17
|
+
* Runner exposed on `DispatchContext.intents` for each registered
|
|
18
|
+
* intent. Two methods, mirroring the canonical execute / stream
|
|
19
|
+
* surface every executable primitive exposes:
|
|
20
|
+
*
|
|
21
|
+
* - `.execute(input?)` runs the named intent and returns its resolved
|
|
22
|
+
* output value (existing — Phase 3.3).
|
|
23
|
+
* - `.stream(input?)` runs the named intent in streaming mode and
|
|
24
|
+
* returns a `StreamContract` the caller can iterate or
|
|
25
|
+
* `await .result` on (Phase 6 / decisions §36). Stream events
|
|
26
|
+
* bubble up as `supervisor.agent.streaming` under the calling
|
|
27
|
+
* callback's intent name when the supervisor itself is being
|
|
28
|
+
* streamed.
|
|
29
|
+
*
|
|
30
|
+
* Without `input` → the dispatched primitive sees the calling
|
|
31
|
+
* callback's own `ctx.input`. With `input` → the override is
|
|
32
|
+
* forwarded.
|
|
33
|
+
*
|
|
34
|
+
* Throws `SupervisorFailedError` (`SUPERVISOR_DISPATCH_CYCLE`) when
|
|
35
|
+
* invoking would close a per-branch call cycle. Cycle detection is
|
|
36
|
+
* scoped per fan-out branch — sibling branches dispatching the same
|
|
37
|
+
* intent in parallel is NOT a cycle.
|
|
38
|
+
*
|
|
39
|
+
* Replaces the Phase-3.3 `ctx.dispatch.byName(name, input?)` helper
|
|
40
|
+
* with property-access + per-key autocomplete (Q5/Q6).
|
|
41
|
+
*/
|
|
42
|
+
type IntentRunner = {
|
|
43
|
+
execute: (input?: unknown) => Promise<unknown>;
|
|
44
|
+
stream: (input?: unknown) => StreamContract<SupervisableResult>;
|
|
45
|
+
};
|
|
46
|
+
/**
|
|
47
|
+
* Discriminated union of executable primitives that `ctx.run`
|
|
48
|
+
* accepts (Phase 6 / decisions §36). Tools are deliberately
|
|
49
|
+
* excluded — they have a different lifecycle and compose via
|
|
50
|
+
* `agent.tools[]`, not via supervised inline dispatch.
|
|
51
|
+
*/
|
|
52
|
+
type SupervisableExecutable = AgentContract<unknown> | WorkflowInstance<unknown, unknown> | SupervisorContract<unknown>;
|
|
53
|
+
/**
|
|
54
|
+
* Subset of `SupervisableExecutable` that exposes a native
|
|
55
|
+
* `.stream()` method. Workflows currently expose streaming only
|
|
56
|
+
* through `workflow.step.streaming` events on `.execute()`; their
|
|
57
|
+
* inline streaming via `ctx.stream` is deferred to a future phase.
|
|
58
|
+
* Workflows still work through `ctx.run` — their step-streaming
|
|
59
|
+
* events bubble through the supervisor's existing top-level forward
|
|
60
|
+
* chain.
|
|
61
|
+
*/
|
|
62
|
+
type StreamableExecutable = AgentContract<unknown> | SupervisorContract<unknown>;
|
|
63
|
+
/**
|
|
64
|
+
* Result envelope returned by `ctx.run(executable, ...)` — discriminated
|
|
65
|
+
* by the executable's kind. Callbacks typically know which one they
|
|
66
|
+
* passed and TS narrows accordingly.
|
|
67
|
+
*/
|
|
68
|
+
type SupervisableResult = AgentResult<unknown> | WorkflowResult<unknown> | SupervisorResult<unknown>;
|
|
69
|
+
/**
|
|
70
|
+
* Per-call options to `ctx.run` / `ctx.stream`. Each kind's native
|
|
71
|
+
* options pass through; the supervisor auto-merges `signal`,
|
|
72
|
+
* `toolCtx`, and `history` defaults under the option payload before
|
|
73
|
+
* forwarding. Per-call value REPLACES the auto-default — standard
|
|
74
|
+
* Warlock convention.
|
|
75
|
+
*/
|
|
76
|
+
type SupervisableExecuteOptions = AgentExecuteOptions<unknown> | WorkflowRunOptions | SupervisorExecuteOptions;
|
|
77
|
+
/**
|
|
78
|
+
* Map of registered intents keyed by their name in the supervisor's
|
|
79
|
+
* `intents` config. Generic-typed against the supplied `intents`
|
|
80
|
+
* object so `ctx.intents.<TAB>` autocompletes against the literal
|
|
81
|
+
* keys the user supplied.
|
|
82
|
+
*/
|
|
83
|
+
type IntentRunnerMap<TIntents extends Record<string, SupervisorIntentValue>> = { [K in keyof TIntents]: IntentRunner };
|
|
84
|
+
/**
|
|
85
|
+
* Context passed to callback intents and to per-intent
|
|
86
|
+
* `input(ctx)` / `output(ctx)` resolvers in entries (callback or
|
|
87
|
+
* agent/workflow alike, where the resolver opts into the dispatch
|
|
88
|
+
* shape rather than the legacy `RouteContext`).
|
|
89
|
+
*
|
|
90
|
+
* Sibling of `RouteContext` — same conceptual context, but carries
|
|
91
|
+
* dispatch-specific fields (`intent`, `result`, `intents`) that
|
|
92
|
+
* don't make sense pre-routing.
|
|
93
|
+
*
|
|
94
|
+
* Generic over `TIntents` for autocomplete on `ctx.intents.X`. Most
|
|
95
|
+
* users never write the generic explicitly — it's inferable from
|
|
96
|
+
* the `SupervisorConfig<TOutput, TIntents>` argument.
|
|
97
|
+
*
|
|
98
|
+
* @example
|
|
99
|
+
* intents: {
|
|
100
|
+
* refund: async (ctx) => {
|
|
101
|
+
* if (typeof ctx.input === "object" && (ctx.input as { amount: number }).amount > 1_000) {
|
|
102
|
+
* await ctx.intents.auditLog.execute();
|
|
103
|
+
* }
|
|
104
|
+
* return await callRefundAPI(ctx.input);
|
|
105
|
+
* },
|
|
106
|
+
* }
|
|
107
|
+
*/
|
|
108
|
+
type DispatchContext<TState = Record<string, unknown>, TIntents extends Record<string, SupervisorIntentValue> = Record<string, SupervisorIntentValue>> = {
|
|
109
|
+
/** Zero-indexed iteration number — turn 0 is the first run. */iteration: number; /** This dispatch's intent name (the key from the `intents` map). */
|
|
110
|
+
intent: string;
|
|
111
|
+
/**
|
|
112
|
+
* Resolved input for this intent. Either the supervisor's
|
|
113
|
+
* original `execute(input)` value or the result of the entry's
|
|
114
|
+
* `input(ctx)` resolver when one was supplied.
|
|
115
|
+
*/
|
|
116
|
+
input: unknown;
|
|
117
|
+
/**
|
|
118
|
+
* Per-execute typed accumulator. Built up across iterations as
|
|
119
|
+
* each intent contributes a slice via shallow-merge. Read-only
|
|
120
|
+
* from inside callbacks (Q3 — write via return value, not direct
|
|
121
|
+
* mutation). On the supervisor's clean termination, this is the
|
|
122
|
+
* value validated against `config.output` and returned as
|
|
123
|
+
* `result.data`.
|
|
124
|
+
*
|
|
125
|
+
* Defaults to `{}` when `config.state` is not declared. JSON-safe
|
|
126
|
+
* only — no functions / Maps / Sets / class instances (Q16) so
|
|
127
|
+
* snapshot resume works.
|
|
128
|
+
*/
|
|
129
|
+
state: TState;
|
|
130
|
+
/**
|
|
131
|
+
* Current iteration's snapshot-in-progress — sibling branches
|
|
132
|
+
* that have already settled this iteration. Empty for the first
|
|
133
|
+
* branch dispatched in any iteration.
|
|
134
|
+
*/
|
|
135
|
+
result: IterationSnapshot["result"];
|
|
136
|
+
/**
|
|
137
|
+
* Every completed iteration's snapshot, in chronological order.
|
|
138
|
+
* On turn 0 this is empty.
|
|
139
|
+
*
|
|
140
|
+
* Renamed from `history` (Q2) — the iteration trace is not
|
|
141
|
+
* conversation history; conversation memory is external to the
|
|
142
|
+
* supervisor (Q3).
|
|
143
|
+
*/
|
|
144
|
+
iterations: IterationSnapshot[]; /** Cancellation signal — propagated from the `execute()` caller. */
|
|
145
|
+
signal: AbortSignal;
|
|
146
|
+
/**
|
|
147
|
+
* Registered intents accessible by key. Each entry is an
|
|
148
|
+
* `IntentRunner` exposing `.execute(input?)`. Property access on
|
|
149
|
+
* a typed map replaces the Phase-3.3 `ctx.dispatch.byName` string
|
|
150
|
+
* lookup — autocomplete + no typo crashes.
|
|
151
|
+
*/
|
|
152
|
+
intents: IntentRunnerMap<TIntents>;
|
|
153
|
+
/**
|
|
154
|
+
* Read-only request-scoped bag supplied via
|
|
155
|
+
* `execute(input, { context })`. Shallow-copied + frozen at intake
|
|
156
|
+
* so callbacks can't mutate the caller's object. Defaults to a
|
|
157
|
+
* frozen `{}` when no context was passed. NOT persisted in
|
|
158
|
+
* snapshots — re-supply on `resume()`.
|
|
159
|
+
*/
|
|
160
|
+
context: Readonly<Record<string, unknown>>;
|
|
161
|
+
/**
|
|
162
|
+
* Prior conversation messages supplied via
|
|
163
|
+
* `execute(input, { history })`. Read-only — passed by reference, not
|
|
164
|
+
* copied. Defaults to an empty array when no history was supplied.
|
|
165
|
+
* NOT persisted in snapshots — re-supply on `resume()`.
|
|
166
|
+
*/
|
|
167
|
+
history: ReadonlyArray<Message>;
|
|
168
|
+
/**
|
|
169
|
+
* Resolved natural-language objective from `SupervisorConfig.goal`.
|
|
170
|
+
* `undefined` when the supervisor was configured without one.
|
|
171
|
+
* Read-only.
|
|
172
|
+
*/
|
|
173
|
+
goal?: string;
|
|
174
|
+
/**
|
|
175
|
+
* Run an inline / un-registered executable under the supervisor's
|
|
176
|
+
* supervision (Phase 6 / decisions §36). The framework auto-merges
|
|
177
|
+
* `signal`, `toolCtx`, `history`, and report-nesting under the
|
|
178
|
+
* calling callback's intent name. Per-call `options` REPLACE
|
|
179
|
+
* auto-defaults (standard Warlock convention).
|
|
180
|
+
*
|
|
181
|
+
* Use when you need to compose an agent / workflow / supervisor
|
|
182
|
+
* inline that isn't in the `intents` map — e.g. an agent
|
|
183
|
+
* dynamically built from per-call config, or a delegate supervisor
|
|
184
|
+
* pulled from a registry.
|
|
185
|
+
*
|
|
186
|
+
* Returns the executable's full result envelope (`{ data, error,
|
|
187
|
+
* usage, report }`). Calls `.execute()` internally; for streaming,
|
|
188
|
+
* use `ctx.stream` instead.
|
|
189
|
+
*
|
|
190
|
+
* Cycle detection by executable `name` matches `ctx.intents.X.execute()`.
|
|
191
|
+
*
|
|
192
|
+
* @example
|
|
193
|
+
* intents: {
|
|
194
|
+
* classifyInline: async ctx => {
|
|
195
|
+
* const { data } = await ctx.run(classifierAgent, ctx.input);
|
|
196
|
+
* return { category: data.label };
|
|
197
|
+
* },
|
|
198
|
+
* }
|
|
199
|
+
*/
|
|
200
|
+
run: (executable: SupervisableExecutable, input: unknown, options?: SupervisableExecuteOptions) => Promise<SupervisableResult>;
|
|
201
|
+
/**
|
|
202
|
+
* Stream an inline / un-registered executable under the
|
|
203
|
+
* supervisor's supervision (Phase 6 / decisions §36). Same auto-
|
|
204
|
+
* merge as `ctx.run` plus stream-event bubbling: deltas surface as
|
|
205
|
+
* `supervisor.agent.streaming { iteration, intent: "<callback name>",
|
|
206
|
+
* delta }` when the supervisor itself is being streamed.
|
|
207
|
+
*
|
|
208
|
+
* Returns the executable's own `StreamContract` — iterate with
|
|
209
|
+
* `for await`, `await .result`, or both. The framework attaches
|
|
210
|
+
* subscriptions transparently; the dev's existing usage of the
|
|
211
|
+
* returned stream is unchanged.
|
|
212
|
+
*
|
|
213
|
+
* @example
|
|
214
|
+
* intents: {
|
|
215
|
+
* chatInline: async ctx => {
|
|
216
|
+
* const { result } = ctx.stream(someAgent, enrich(ctx.input));
|
|
217
|
+
* const final = await result;
|
|
218
|
+
* return { reply: final.text };
|
|
219
|
+
* },
|
|
220
|
+
* }
|
|
221
|
+
*/
|
|
222
|
+
stream: (executable: StreamableExecutable, input: unknown, options?: SupervisableExecuteOptions) => StreamContract<SupervisableResult>;
|
|
223
|
+
/**
|
|
224
|
+
* Forensic record of iter-0 classifier run (Phase 7 / decisions §37).
|
|
225
|
+
* Present when `SupervisorConfig.classifier` was configured AND
|
|
226
|
+
* iter 0 has completed; `undefined` otherwise. Callbacks can
|
|
227
|
+
* read `ctx.classifier?.intent` / `.reasoning` / `.confidence` to
|
|
228
|
+
* inspect the classification trail without round-tripping through
|
|
229
|
+
* state.
|
|
230
|
+
*/
|
|
231
|
+
classifier?: Readonly<ClassifierSnapshot>;
|
|
232
|
+
};
|
|
233
|
+
//#endregion
|
|
234
|
+
export { DispatchContext, IntentRunner, IntentRunnerMap, StreamableExecutable, SupervisableExecutable, SupervisableExecuteOptions, SupervisableResult };
|
|
235
|
+
//# sourceMappingURL=dispatch-context.type.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dispatch-context.type.d.mts","names":[],"sources":["../../../../../../../@warlock.js/ai/src/contracts/supervisor/dispatch-context.type.ts"],"mappings":";;;;;;;;;;;;;;;;;AAwCA;;;;;;;;;;;;;;;;AAEgE;AAShE;;;;;;;KAXY,YAAA;EACV,OAAA,GAAU,KAAA,eAAoB,OAAA;EAC9B,MAAA,GAAS,KAAA,eAAoB,cAAA,CAAe,kBAAA;AAAA;;AAYxB;AAWtB;;;;KAdY,sBAAA,GACR,aAAA,YACA,gBAAA,qBACA,kBAAA;AAoBJ;;;;;;;;;AAAA,KATY,oBAAA,GACR,aAAA,YACA,kBAAkB;;;AAUF;AASpB;;KAZY,kBAAA,GACR,WAAA,YACA,cAAA,YACA,gBAAA;;;;;;;;KASQ,0BAAA,GACR,mBAAA,YACA,kBAAA,GACA,wBAAA;;AAAwB;AAQ5B;;;;KAAY,eAAA,kBAAiC,MAAA,SAAe,qBAAA,mBAC9C,QAAA,GAAW,YAAA;;;;;;;;;;AAAY;AA2BrC;;;;;;;;;;;;;;KAAY,eAAA,UACD,MAAA,oCACQ,MAAA,SAAe,qBAAA,IAAyB,MAAA,SAAe,qBAAA;EAwD/D,+DArDT,SAAA,UA4DS;EA1DT,MAAA;EA8FY;;;;;EAxFZ,KAAA;EAmHK;;;;;;;;;;;;EAtGL,KAAA,EAAO,MAAA;EAnBP;;;;;EAyBA,MAAA,EAAQ,iBAAA;EASR;;;;;;;;EAAA,UAAA,EAAY,iBAAA,IAiBM;EAflB,MAAA,EAAQ,WAAA;EAsBC;;;;;;EAfT,OAAA,EAAS,eAAA,CAAgB,QAAA;EAmDb;;;;;;;EA3CZ,OAAA,EAAS,QAAA,CAAS,MAAA;EAqEN;;;;;;EA9DZ,OAAA,EAAS,aAAA,CAAc,OAAA;EAwEiB;AAAA;;;;EAlExC,IAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;EA2BA,GAAA,GACE,UAAA,EAAY,sBAAA,EACZ,KAAA,WACA,OAAA,GAAU,0BAAA,KACP,OAAA,CAAQ,kBAAA;;;;;;;;;;;;;;;;;;;;;;EAsBb,MAAA,GACE,UAAA,EAAY,oBAAA,EACZ,KAAA,WACA,OAAA,GAAU,0BAAA,KACP,cAAA,CAAe,kBAAA;;;;;;;;;EASpB,UAAA,GAAa,QAAA,CAAS,kBAAA;AAAA"}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { Message } from "../conversation-message.type.mjs";
|
|
2
|
+
import { AIError } from "../../errors/ai-error.mjs";
|
|
3
|
+
import { Usage } from "../result/usage.type.mjs";
|
|
4
|
+
import { IterationSnapshot } from "./iteration-snapshot.type.mjs";
|
|
5
|
+
import { SupervisorInput } from "./supervisor-input.type.mjs";
|
|
6
|
+
import { ClassifierSnapshot } from "./classifier-context.type.mjs";
|
|
7
|
+
|
|
8
|
+
//#region ../../@warlock.js/ai/src/contracts/supervisor/evaluate-context.type.d.ts
|
|
9
|
+
/**
|
|
10
|
+
* Per-branch summary passed to `evaluate` via
|
|
11
|
+
* `EvaluateContext.result[intent]`. Carries exactly what `evaluate`
|
|
12
|
+
* needs to judge the turn — the transformed output, timing, token
|
|
13
|
+
* usage, and any per-branch error that didn't abort the sibling
|
|
14
|
+
* dispatches.
|
|
15
|
+
*
|
|
16
|
+
* Distinct from `AgentBranchSnapshot` because it's the `evaluate`
|
|
17
|
+
* contract, not the persistence contract — snapshots mirror the same
|
|
18
|
+
* fields plus canonical timestamps and a frozen shape.
|
|
19
|
+
*/
|
|
20
|
+
type EvaluateBranchResult = {
|
|
21
|
+
/** Output after the per-agent `output` transformer (if any). */output: unknown; /** The resolved input string sent to the agent this iteration. */
|
|
22
|
+
input: string;
|
|
23
|
+
usage: Usage;
|
|
24
|
+
durationMs: number;
|
|
25
|
+
/**
|
|
26
|
+
* Per-branch typed error. Set only when this specific branch
|
|
27
|
+
* failed; sibling branches and the evaluate pass still run.
|
|
28
|
+
*/
|
|
29
|
+
error?: AIError;
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* Context passed to a supervisor's `evaluate` callback. Fires
|
|
33
|
+
* retrospectively after the iteration's agent(s) have settled —
|
|
34
|
+
* never before dispatch — so `result` is populated.
|
|
35
|
+
*
|
|
36
|
+
* `result` is a `Record` keyed by intent name (not an array) — see
|
|
37
|
+
* design §10 for why: it keeps consumer code uniform whether one
|
|
38
|
+
* agent or three ran, matches the `intents` config shape, and
|
|
39
|
+
* expresses "didn't run this iteration" cleanly as key absence.
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* evaluate: (ctx) => {
|
|
43
|
+
* if (ctx.result.resolver?.output) { return { satisfied: true }; }
|
|
44
|
+
* if (!ctx.result.research) { return { reassignTo: "research" }; }
|
|
45
|
+
* return undefined;
|
|
46
|
+
* }
|
|
47
|
+
*/
|
|
48
|
+
type EvaluateContext<TState = Record<string, unknown>> = {
|
|
49
|
+
iteration: number; /** The supervisor's original `execute(input)` value. */
|
|
50
|
+
input: SupervisorInput;
|
|
51
|
+
/**
|
|
52
|
+
* Per-execute typed accumulator AFTER this iteration's intents
|
|
53
|
+
* have merged their outputs. State-driven termination logic
|
|
54
|
+
* (`return ctx.state.reply ? { satisfied: true } : undefined`)
|
|
55
|
+
* lives here.
|
|
56
|
+
*/
|
|
57
|
+
state: TState;
|
|
58
|
+
/**
|
|
59
|
+
* Outputs from this iteration's dispatched agents, keyed by intent
|
|
60
|
+
* name. Absent key = didn't run this iteration. Always an object —
|
|
61
|
+
* even single-agent iterations produce a one-key record.
|
|
62
|
+
*/
|
|
63
|
+
result: Record<string, EvaluateBranchResult>;
|
|
64
|
+
/**
|
|
65
|
+
* Prior iterations' snapshots, in chronological order.
|
|
66
|
+
*
|
|
67
|
+
* Renamed from `history` (Q2).
|
|
68
|
+
*/
|
|
69
|
+
iterations: IterationSnapshot[];
|
|
70
|
+
/**
|
|
71
|
+
* Read-only request-scoped bag supplied via
|
|
72
|
+
* `execute(input, { context })`. Shallow-copied + frozen at intake
|
|
73
|
+
* so callbacks can't mutate the caller's object. Defaults to a
|
|
74
|
+
* frozen `{}` when no context was passed. NOT persisted in
|
|
75
|
+
* snapshots — re-supply on `resume()`.
|
|
76
|
+
*/
|
|
77
|
+
context: Readonly<Record<string, unknown>>;
|
|
78
|
+
/**
|
|
79
|
+
* Prior conversation messages supplied via
|
|
80
|
+
* `execute(input, { history })`. Read-only — passed by reference, not
|
|
81
|
+
* copied. Defaults to an empty array when no history was supplied.
|
|
82
|
+
* NOT persisted in snapshots — re-supply on `resume()`.
|
|
83
|
+
*/
|
|
84
|
+
history: ReadonlyArray<Message>;
|
|
85
|
+
/**
|
|
86
|
+
* Resolved natural-language objective from `SupervisorConfig.goal`.
|
|
87
|
+
* `undefined` when the supervisor was configured without one.
|
|
88
|
+
* Read-only. Especially useful for goal-aware satisfaction checks:
|
|
89
|
+
* `evaluate` can compare `ctx.state` against `ctx.goal` semantics
|
|
90
|
+
* without hardcoded strings.
|
|
91
|
+
*/
|
|
92
|
+
goal?: string;
|
|
93
|
+
/**
|
|
94
|
+
* Forensic record of iter-0 classifier run (Phase 7 / decisions §37).
|
|
95
|
+
* Present when `SupervisorConfig.classifier` was configured AND
|
|
96
|
+
* iter 0 has completed (classifier mode supervisors only). Lets
|
|
97
|
+
* `evaluate` factor the classification trail into satisfaction
|
|
98
|
+
* checks without re-reading from state.
|
|
99
|
+
*/
|
|
100
|
+
classifier?: Readonly<ClassifierSnapshot>;
|
|
101
|
+
};
|
|
102
|
+
/**
|
|
103
|
+
* Verdict returned by `evaluate`. Fields may be combined:
|
|
104
|
+
*
|
|
105
|
+
* - `undefined` — trust the router/route; continue to the next
|
|
106
|
+
* iteration unchanged.
|
|
107
|
+
* - `{ satisfied: true }` — terminate the run successfully.
|
|
108
|
+
* - `{ reassignTo: string | string[] }` — override the next
|
|
109
|
+
* iteration's dispatch decision. Supports fan-out via array form.
|
|
110
|
+
* - `{ feedback: string }` — inject reviewer feedback into the next
|
|
111
|
+
* iteration's composed input.
|
|
112
|
+
*
|
|
113
|
+
* Combining works exactly as expected: `{ reassignTo: "critic",
|
|
114
|
+
* feedback: "focus on factual errors" }` forces a critic dispatch
|
|
115
|
+
* with the feedback threaded into its input.
|
|
116
|
+
*/
|
|
117
|
+
type EvaluateResult = undefined | {
|
|
118
|
+
satisfied?: boolean;
|
|
119
|
+
reassignTo?: string | string[];
|
|
120
|
+
feedback?: string;
|
|
121
|
+
};
|
|
122
|
+
//#endregion
|
|
123
|
+
export { EvaluateBranchResult, EvaluateContext, EvaluateResult };
|
|
124
|
+
//# sourceMappingURL=evaluate-context.type.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"evaluate-context.type.d.mts","names":[],"sources":["../../../../../../../@warlock.js/ai/src/contracts/supervisor/evaluate-context.type.ts"],"mappings":";;;;;;;;;;AAkBA;;;;;;;;;KAAY,oBAAA;EAWF,gEATR,MAAA,WASe;EAPf,KAAA;EACA,KAAA,EAAO,KAAA;EACP,UAAA;EAyBmC;;;;EApBnC,KAAA,GAAQ,OAAO;AAAA;;;;;;;;;;;;;;;;;;KAoBL,eAAA,UAAyB,MAAA;EACnC,SAAA,UAqBY;EAnBZ,KAAA,EAAO,eAAA;EA2BE;;;;;;EApBT,KAAA,EAAO,MAAA;EA2CM;;;AAA2B;AAkB1C;EAvDE,MAAA,EAAQ,MAAA,SAAe,oBAAA;;;;;;EAMvB,UAAA,EAAY,iBAAA;EAsDA;;;;;;;EA9CZ,OAAA,EAAS,QAAA,CAAS,MAAA;;;;;;;EAOlB,OAAA,EAAS,aAAA,CAAc,OAAA;;;;;;;;EAQvB,IAAA;;;;;;;;EAQA,UAAA,GAAa,QAAA,CAAS,kBAAA;AAAA;;;;;;;;;;;;;;;;KAkBZ,cAAA;EAGN,SAAA;EACA,UAAA;EACA,QAAA;AAAA"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { END, EndSentinel } from "../end.type.mjs";
|
|
2
|
+
import { Next } from "./next.type.mjs";
|
|
3
|
+
import { AckSnapshot, AgentBranchSnapshot, DecisionSource, IterationDecision, IterationSnapshot } from "./iteration-snapshot.type.mjs";
|
|
4
|
+
import { SupervisorInput } from "./supervisor-input.type.mjs";
|
|
5
|
+
import { EvaluateBranchResult, EvaluateContext, EvaluateResult } from "./evaluate-context.type.mjs";
|
|
6
|
+
import { RouteContext } from "./route-context.type.mjs";
|
|
7
|
+
import { AckCallback, AckConfig, AckEntry, AckRunEntry } from "./ack-entry.type.mjs";
|
|
8
|
+
import { DispatchRawResult, IntentCallback, IntentEntry, IntentRunEntry, SupervisorIntentValue } from "./intent-entry.type.mjs";
|
|
9
|
+
import { RouterEntry } from "./router-entry.type.mjs";
|
|
10
|
+
import { SupervisorConfig, SupervisorEventHandler, SupervisorEventHandlers } from "./supervisor-config.type.mjs";
|
|
11
|
+
import { SupervisorExecuteOptions, SupervisorResumeOptions } from "./supervisor-execute-options.type.mjs";
|
|
12
|
+
import { SupervisorStreamEvent } from "./supervisor-stream-event.type.mjs";
|
|
13
|
+
import { SupervisorAsToolOptions, SupervisorContract } from "./supervisor.contract.mjs";
|
|
14
|
+
import { DispatchContext, IntentRunner, IntentRunnerMap } from "./dispatch-context.type.mjs";
|
|
15
|
+
import { ClassifierAgentEntry, ClassifierCallback, ClassifierConfig, ClassifierContext, ClassifierOutput, ClassifierRefineContext, ClassifierRefineResult, ClassifierRunEntry, ClassifierSnapshot } from "./classifier-context.type.mjs";
|
|
16
|
+
import { SupervisorSnapshot, SupervisorSnapshotStatus } from "./supervisor-snapshot.type.mjs";
|
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
import { Message } from "../conversation-message.type.mjs";
|
|
2
|
+
import { AgentResult } from "../result/agent-result.type.mjs";
|
|
3
|
+
import { AgentContract } from "../agent/agent.contract.mjs";
|
|
4
|
+
import { EndSentinel } from "../end.type.mjs";
|
|
5
|
+
import { WorkflowResult } from "../result/workflow-result.type.mjs";
|
|
6
|
+
import { WorkflowInstance } from "../workflow/workflow.contract.mjs";
|
|
7
|
+
import { RouteContext } from "./route-context.type.mjs";
|
|
8
|
+
import { DispatchContext } from "./dispatch-context.type.mjs";
|
|
9
|
+
import { StandardSchemaV1 } from "@standard-schema/spec";
|
|
10
|
+
|
|
11
|
+
//#region ../../@warlock.js/ai/src/contracts/supervisor/intent-entry.type.d.ts
|
|
12
|
+
/**
|
|
13
|
+
* Raw result produced by a dispatched unit — either an agent or a
|
|
14
|
+
* workflow — before any per-intent strip-merge runs.
|
|
15
|
+
*
|
|
16
|
+
* Exposed as a named alias so consumers reading
|
|
17
|
+
* `IterationSnapshot.result[intent].output` know the shape.
|
|
18
|
+
*/
|
|
19
|
+
type DispatchRawResult = AgentResult<unknown> | WorkflowResult<unknown>;
|
|
20
|
+
/**
|
|
21
|
+
* Object form of an entry in a supervisor's `intents` map (agent
|
|
22
|
+
* variant). Use when you need to override the unit's `description`,
|
|
23
|
+
* customize the per-dispatch input string, declare a state slice via
|
|
24
|
+
* an `output` schema, or supply per-dispatch placeholder values for
|
|
25
|
+
* the agent's systemPrompt template.
|
|
26
|
+
*
|
|
27
|
+
* Every field other than `agent` is optional — the shorthand form
|
|
28
|
+
* (`intents: { triage: triageAgent }`) simply omits all of them.
|
|
29
|
+
*
|
|
30
|
+
* Phase 3.4 (Stage 4b) — `output` shifted from a transformer
|
|
31
|
+
* `(raw) => unknown` to a `StandardSchemaV1` schema (Q11/Q13). The
|
|
32
|
+
* schema declares the slice this intent contributes to supervisor
|
|
33
|
+
* state; agent output is strip-merged against it. `placeholders`
|
|
34
|
+
* is new — feeds into `agent.execute(input, { placeholders })`.
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* intents: {
|
|
38
|
+
* classify: {
|
|
39
|
+
* agent: classifierAgent,
|
|
40
|
+
* description: "First-pass classifier",
|
|
41
|
+
* placeholders: (ctx) => ({ message: ctx.input }),
|
|
42
|
+
* output: v.object({ classification: v.enum(["billing", "shipping"]) }),
|
|
43
|
+
* },
|
|
44
|
+
* }
|
|
45
|
+
*/
|
|
46
|
+
type IntentEntry = {
|
|
47
|
+
/** The underlying dispatchable unit — an agent or a workflow. */agent: AgentContract<unknown> | WorkflowInstance<unknown, unknown>;
|
|
48
|
+
/**
|
|
49
|
+
* Overrides the unit's own `description` when the router agent's
|
|
50
|
+
* per-turn context is assembled. Required fallback when the
|
|
51
|
+
* underlying agent/workflow doesn't carry one.
|
|
52
|
+
*/
|
|
53
|
+
description?: string;
|
|
54
|
+
/**
|
|
55
|
+
* Per-intent input composer — escape hatch for the rare case where
|
|
56
|
+
* the agent's user message itself must vary per intent. Runs after
|
|
57
|
+
* routing decides this intent should dispatch. Without it, the
|
|
58
|
+
* agent receives the supervisor's `ctx.input` unchanged.
|
|
59
|
+
*/
|
|
60
|
+
input?: (ctx: RouteContext) => string;
|
|
61
|
+
/**
|
|
62
|
+
* Per-dispatch placeholder values for the agent's `systemPrompt`
|
|
63
|
+
* template. Receives the upcoming `DispatchContext` so the
|
|
64
|
+
* computation can read `ctx.state`, `ctx.iterations`, etc. Result
|
|
65
|
+
* is forwarded as `agent.execute(input, { placeholders })` —
|
|
66
|
+
* filling in `{{key}}` references in the agent's systemPrompt.
|
|
67
|
+
*
|
|
68
|
+
* Phase 3.4 — replaces the dropped `composeAgentInput` mechanism
|
|
69
|
+
* for threading prior-iteration context into agents. Use this for
|
|
70
|
+
* "what should the agent know about state right now?" rather than
|
|
71
|
+
* for "what's the agent's user message?" (that's `input`).
|
|
72
|
+
*/
|
|
73
|
+
placeholders?: (ctx: DispatchContext) => Record<string, unknown>;
|
|
74
|
+
/**
|
|
75
|
+
* Schema declaring the slice this intent contributes to supervisor
|
|
76
|
+
* state. Agent output is strip-merged against it: only validated
|
|
77
|
+
* keys land on `IterationSnapshot.result[intent].output` AND merge
|
|
78
|
+
* into supervisor `state`.
|
|
79
|
+
*
|
|
80
|
+
* Without `output`: the agent's full `data` (or `text` fallback)
|
|
81
|
+
* passes through to the snapshot but is NOT auto-merged into
|
|
82
|
+
* state — explicit opt-in keeps state clean.
|
|
83
|
+
*
|
|
84
|
+
* Validation failure surfaces as a per-branch error on the
|
|
85
|
+
* iteration snapshot; sibling branches still run.
|
|
86
|
+
*/
|
|
87
|
+
output?: StandardSchemaV1<unknown>;
|
|
88
|
+
/**
|
|
89
|
+
* Per-intent successor directive (Phase 3.4 Stage 4d / Q24).
|
|
90
|
+
* After this intent runs and its slice merges into state, the
|
|
91
|
+
* supervisor calls `next(ctx)`:
|
|
92
|
+
*
|
|
93
|
+
* - Returns intent name (or array) → next iteration dispatches
|
|
94
|
+
* that. **No router LLM call.**
|
|
95
|
+
* - Returns `END` → terminate. **No router call, no evaluate.**
|
|
96
|
+
* - Returns `undefined` → fall back to router/route as today.
|
|
97
|
+
*
|
|
98
|
+
* Precedence: `evaluate` outranks `next`; `next` outranks
|
|
99
|
+
* router/route. Fan-out: each branch's `next` is collected after
|
|
100
|
+
* all branches settle; the union of unique intents drives the
|
|
101
|
+
* next iteration; any `END` terminates; silent branches abstain.
|
|
102
|
+
*/
|
|
103
|
+
next?: (ctx: DispatchContext) => string | string[] | EndSentinel | undefined;
|
|
104
|
+
/**
|
|
105
|
+
* Custom history slicer for this intent's agent/workflow. When
|
|
106
|
+
* supplied, REPLACES the default slice (full history clipped by
|
|
107
|
+
* `SupervisorConfig.historyWindow.agents` if set).
|
|
108
|
+
*
|
|
109
|
+
* Precedence: entry `history` callback > `historyWindow.agents` >
|
|
110
|
+
* full history. Return `[]` to send no history at all (handy for
|
|
111
|
+
* pure-retrieval RAG agents that just need the current input).
|
|
112
|
+
*
|
|
113
|
+
* @example
|
|
114
|
+
* intents: {
|
|
115
|
+
* sales: {
|
|
116
|
+
* agent: salesAgent,
|
|
117
|
+
* history: (ctx) => ctx.history.slice(-15),
|
|
118
|
+
* },
|
|
119
|
+
* rag: { agent: ragAgent, history: () => [] },
|
|
120
|
+
* }
|
|
121
|
+
*/
|
|
122
|
+
history?: (ctx: RouteContext) => Message[] | ReadonlyArray<Message>;
|
|
123
|
+
/**
|
|
124
|
+
* Dispatch mode (Phase 5 / decisions §34).
|
|
125
|
+
*
|
|
126
|
+
* - `"structured"` (default) — agent runs with the per-intent
|
|
127
|
+
* `output` schema (or a free-form completion if `output` is
|
|
128
|
+
* absent). Existing behavior; every prior intent keeps it.
|
|
129
|
+
* - `"stream"` — agent runs **without** structured-output coercion.
|
|
130
|
+
* Raw text deltas forward as `supervisor.agent.streaming` events;
|
|
131
|
+
* the assembled prose lands on `state[streamTo]` at completion.
|
|
132
|
+
*
|
|
133
|
+
* Stream mode is mutually exclusive with `output` at the intent
|
|
134
|
+
* level — a stream-mode intent declares its state contribution via
|
|
135
|
+
* `streamTo`, not via a schema. The factory throws
|
|
136
|
+
* `SUPERVISOR_INTENT_STREAM_AND_OUTPUT` if both are set, and
|
|
137
|
+
* `SUPERVISOR_INTENT_STREAM_TO_REQUIRED` if `mode === "stream"` and
|
|
138
|
+
* `streamTo` is missing.
|
|
139
|
+
*
|
|
140
|
+
* **Workflow entries do NOT support stream mode in v1** — workflows
|
|
141
|
+
* have no guaranteed single-LLM-text terminal contract. The factory
|
|
142
|
+
* throws if `mode: "stream"` is set on a workflow entry.
|
|
143
|
+
*/
|
|
144
|
+
mode?: "structured" | "stream";
|
|
145
|
+
/**
|
|
146
|
+
* State key the assembled stream-mode prose writes into. Required
|
|
147
|
+
* when `mode === "stream"`; ignored otherwise. The supervisor
|
|
148
|
+
* builds `{ [streamTo]: assembledText }` as the branch's output
|
|
149
|
+
* slice and merges it into `state` like any other slice.
|
|
150
|
+
*/
|
|
151
|
+
streamTo?: string;
|
|
152
|
+
};
|
|
153
|
+
/**
|
|
154
|
+
* Callback dispatch shorthand — an intent handled by dev code rather
|
|
155
|
+
* than by an agent or workflow. Same shape as `ai.step({ run })`.
|
|
156
|
+
*
|
|
157
|
+
* Receives a {@link DispatchContext} and returns a value (sync or
|
|
158
|
+
* async). The return value shallow-merges into supervisor state.
|
|
159
|
+
* The framework wraps the return value in a synthesized leaf report
|
|
160
|
+
* (`type: "callback"`, zero usage, real timing). Throws propagate
|
|
161
|
+
* as `SupervisorFailedError` with `cause` set.
|
|
162
|
+
*
|
|
163
|
+
* @example
|
|
164
|
+
* intents: {
|
|
165
|
+
* refund: async (ctx) => {
|
|
166
|
+
* const id = await callRefundAPI(ctx.input);
|
|
167
|
+
* return { refundId: id }; // shallow-merged into ctx.state
|
|
168
|
+
* },
|
|
169
|
+
* }
|
|
170
|
+
*/
|
|
171
|
+
type IntentCallback = (ctx: DispatchContext) => unknown | Promise<unknown>;
|
|
172
|
+
/**
|
|
173
|
+
* Object form of a callback intent — preferred when you need a
|
|
174
|
+
* `description` (required under a router) or want per-intent
|
|
175
|
+
* `input` / `output` shapes.
|
|
176
|
+
*
|
|
177
|
+
* Mirrors `ai.step({ run, description, ... })` so users moving
|
|
178
|
+
* between workflow and supervisor see the same vocabulary.
|
|
179
|
+
*
|
|
180
|
+
* Phase 3.4 (Stage 4b) — `output` shifted from a transformer to
|
|
181
|
+
* a `StandardSchemaV1`. Without it, the callback's full return
|
|
182
|
+
* shallow-merges into state. With it, the return is strip-merged
|
|
183
|
+
* to declared keys only.
|
|
184
|
+
*
|
|
185
|
+
* @example
|
|
186
|
+
* intents: {
|
|
187
|
+
* cancel: {
|
|
188
|
+
* run: async (ctx) => ({ cancelledId: await cancelOrder(ctx.input) }),
|
|
189
|
+
* description: "Cancel an order on explicit customer request",
|
|
190
|
+
* output: v.object({ cancelledId: v.string() }),
|
|
191
|
+
* },
|
|
192
|
+
* }
|
|
193
|
+
*/
|
|
194
|
+
type IntentRunEntry = {
|
|
195
|
+
/** The dispatch callback. Receives a {@link DispatchContext}. */run: IntentCallback;
|
|
196
|
+
/**
|
|
197
|
+
* Required when the supervisor is configured with a `router` —
|
|
198
|
+
* otherwise the router LLM has no signal for picking this intent.
|
|
199
|
+
* Optional in deterministic-route mode.
|
|
200
|
+
*/
|
|
201
|
+
description?: string;
|
|
202
|
+
/**
|
|
203
|
+
* Per-intent input resolver. Receives a {@link DispatchContext}
|
|
204
|
+
* (the callback's eventual context) and returns the value passed
|
|
205
|
+
* as `ctx.input`. Defaults to the supervisor's input string.
|
|
206
|
+
*/
|
|
207
|
+
input?: (ctx: DispatchContext) => unknown;
|
|
208
|
+
/**
|
|
209
|
+
* Per-dispatch placeholder values. Same role as on `IntentEntry` —
|
|
210
|
+
* available on callback entries for symmetry, though callbacks
|
|
211
|
+
* usually don't have a systemPrompt template to fill.
|
|
212
|
+
*/
|
|
213
|
+
placeholders?: (ctx: DispatchContext) => Record<string, unknown>;
|
|
214
|
+
/**
|
|
215
|
+
* Schema declaring the slice this callback contributes to
|
|
216
|
+
* supervisor state. Without it, the full return value
|
|
217
|
+
* shallow-merges. With it, return is strip-merged to declared keys.
|
|
218
|
+
*/
|
|
219
|
+
output?: StandardSchemaV1<unknown>;
|
|
220
|
+
/**
|
|
221
|
+
* Per-intent successor directive (Phase 3.4 Stage 4d / Q24). See
|
|
222
|
+
* `IntentEntry.next` — same semantics, available on callback
|
|
223
|
+
* intents too.
|
|
224
|
+
*/
|
|
225
|
+
next?: (ctx: DispatchContext) => string | string[] | EndSentinel | undefined;
|
|
226
|
+
};
|
|
227
|
+
/**
|
|
228
|
+
* The accepted shapes for a value in the supervisor's
|
|
229
|
+
* `intents: Record<string, …>` config:
|
|
230
|
+
*
|
|
231
|
+
* - `AgentContract` — shorthand; description inferred from the agent.
|
|
232
|
+
* - `WorkflowInstance` — shorthand; description inferred from the
|
|
233
|
+
* workflow (must be present).
|
|
234
|
+
* - `IntentCallback` — bare async/sync function shorthand, dispatched
|
|
235
|
+
* as dev code. Description-less; allowed only in deterministic
|
|
236
|
+
* `route` mode. Under a router, upgrade to `IntentRunEntry`.
|
|
237
|
+
* - `IntentEntry` — full object form for an agent/workflow with
|
|
238
|
+
* optional overrides.
|
|
239
|
+
* - `IntentRunEntry` — full object form for a callback intent.
|
|
240
|
+
*
|
|
241
|
+
* The runtime resolver discriminates by checking, in order:
|
|
242
|
+
* `function → "run" in value → "agent" in value → instanceof`.
|
|
243
|
+
* Mixed dispatch fields (e.g. `{ agent, run }`) throw at construction.
|
|
244
|
+
*
|
|
245
|
+
* Every key must ultimately resolve to a non-empty description when
|
|
246
|
+
* the supervisor is configured with a `router` — the factory throws
|
|
247
|
+
* `SupervisorFailedError` (`SUPERVISOR_INTENT_DESCRIPTION_REQUIRED`)
|
|
248
|
+
* if any router-routed intent lacks one. Deterministic-route callers
|
|
249
|
+
* skip the check.
|
|
250
|
+
*/
|
|
251
|
+
type SupervisorIntentValue = AgentContract<unknown> | WorkflowInstance<unknown, unknown> | IntentCallback | IntentEntry | IntentRunEntry;
|
|
252
|
+
//#endregion
|
|
253
|
+
export { DispatchRawResult, IntentCallback, IntentEntry, IntentRunEntry, SupervisorIntentValue };
|
|
254
|
+
//# sourceMappingURL=intent-entry.type.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"intent-entry.type.d.mts","names":[],"sources":["../../../../../../../@warlock.js/ai/src/contracts/supervisor/intent-entry.type.ts"],"mappings":";;;;;;;;;;;;;AAiBA;;;;AAAqE;KAAzD,iBAAA,GAAoB,WAAA,YAAuB,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;KA4BzD,WAAA;EA0CV,iEAxCA,KAAA,EAAO,aAAA,YAAyB,gBAAA;EAwDhC;;;;;EAlDA,WAAA;EAqEW;;;;;;EA9DX,KAAA,IAAS,GAAA,EAAK,YAAA;EA2FN;AAqBV;;;;;;;;AAAwE;AAwBxE;;EA3HE,YAAA,IAAgB,GAAA,EAAK,eAAA,KAAoB,MAAA;EA6HpC;;;;;;;;;;;;;EA/GL,MAAA,GAAS,gBAAA;EA2HA;;;;;;;;;;;;AAkBuD;AA2BlE;;EAxJE,IAAA,IAAQ,GAAA,EAAK,eAAA,yBAAwC,WAAA;EAyJnD;;;;;;;;;;;;;AAIc;;;;;EA1IhB,OAAA,IAAW,GAAA,EAAK,YAAA,KAAiB,OAAA,KAAY,aAAA,CAAc,OAAA;;;;;;;;;;;;;;;;;;;;;;EAsB3D,IAAA;;;;;;;EAOA,QAAA;AAAA;;;;;;;;;;;;;;;;;;;KAqBU,cAAA,IAAkB,GAAA,EAAK,eAAA,eAA8B,OAAO;;;;;;;;;;;;;;;;;;;;;;;KAwB5D,cAAA;mEAEV,GAAA,EAAK,cAAA;;;;;;EAML,WAAA;;;;;;EAMA,KAAA,IAAS,GAAA,EAAK,eAAA;;;;;;EAMd,YAAA,IAAgB,GAAA,EAAK,eAAA,KAAoB,MAAA;;;;;;EAMzC,MAAA,GAAS,gBAAA;;;;;;EAMT,IAAA,IAAQ,GAAA,EAAK,eAAA,yBAAwC,WAAA;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;KA2B3C,qBAAA,GACR,aAAA,YACA,gBAAA,qBACA,cAAA,GACA,WAAA,GACA,cAAA"}
|