@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,90 @@
|
|
|
1
|
+
import { Message } from "../conversation-message.type.mjs";
|
|
2
|
+
import { SupervisorEventHandlers } from "./supervisor-config.type.mjs";
|
|
3
|
+
|
|
4
|
+
//#region ../../@warlock.js/ai/src/contracts/supervisor/supervisor-execute-options.type.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* Per-call options for `supervisor.execute()`. Everything here is
|
|
7
|
+
* scoped to a single run — factory-level knobs live on
|
|
8
|
+
* `SupervisorConfig`.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* const controller = new AbortController();
|
|
12
|
+
* const result = await supervisor.execute("order #123 late", {
|
|
13
|
+
* runId: "support-2026-04-23-123",
|
|
14
|
+
* signal: controller.signal,
|
|
15
|
+
* on: {
|
|
16
|
+
* "supervisor.router.decided": ({ next }) => console.log("->", next),
|
|
17
|
+
* },
|
|
18
|
+
* });
|
|
19
|
+
*/
|
|
20
|
+
type SupervisorExecuteOptions = {
|
|
21
|
+
/**
|
|
22
|
+
* Caller-chosen run identifier — reused as the cache key when
|
|
23
|
+
* `store` is configured. Auto-generated (`sup_<rand>`) when omitted.
|
|
24
|
+
*/
|
|
25
|
+
runId?: string;
|
|
26
|
+
/**
|
|
27
|
+
* Cancellation handle. Between-iteration cancellation is
|
|
28
|
+
* guaranteed; mid-iteration aborts are propagated into every
|
|
29
|
+
* in-flight child `execute()` (agents, workflows, router).
|
|
30
|
+
*/
|
|
31
|
+
signal?: AbortSignal;
|
|
32
|
+
/**
|
|
33
|
+
* Per-execution event handlers — tier 3 of the 3-tier model.
|
|
34
|
+
* Fire last, after definition-level and instance-level listeners.
|
|
35
|
+
*/
|
|
36
|
+
on?: SupervisorEventHandlers;
|
|
37
|
+
/**
|
|
38
|
+
* Read-only request-scoped bag, surfaced on every `ctx.context`
|
|
39
|
+
* inside `route` / `evaluate` / intent callbacks / router-entry
|
|
40
|
+
* `placeholders` + `input` / per-intent `placeholders` + `input` +
|
|
41
|
+
* `next`. Use it to thread per-request data — `userId`, `traceId`,
|
|
42
|
+
* locale, DB clients, feature flags — without forcing supervisors
|
|
43
|
+
* to be re-instantiated per request.
|
|
44
|
+
*
|
|
45
|
+
* Shallow-copied + frozen at intake, so callbacks can't mutate the
|
|
46
|
+
* caller's object. NOT persisted in snapshots; re-supply on
|
|
47
|
+
* `resume(runId, { context })`.
|
|
48
|
+
*/
|
|
49
|
+
context?: Record<string, unknown>;
|
|
50
|
+
/**
|
|
51
|
+
* Prior conversation messages — read-only context threaded into
|
|
52
|
+
* `route` / `evaluate` / dispatch callbacks via `ctx.history`, and
|
|
53
|
+
* forwarded verbatim to every dispatched agent (and the receptionist
|
|
54
|
+
* `ack` agent, when configured) as `agent.execute(input, { history })`.
|
|
55
|
+
*
|
|
56
|
+
* Mirrors `AgentExecuteOptions.history` so a supervisor can be slotted
|
|
57
|
+
* into a chat pipeline as a drop-in replacement for a single agent
|
|
58
|
+
* without the caller juggling history across primitives.
|
|
59
|
+
*
|
|
60
|
+
* NOT persisted in snapshots — re-supply on `resume(runId, { history })`
|
|
61
|
+
* if the resumed run still needs prior conversation context.
|
|
62
|
+
*/
|
|
63
|
+
history?: Message[];
|
|
64
|
+
/**
|
|
65
|
+
* Opaque caller-supplied identifier that groups multiple `execute()`
|
|
66
|
+
* calls into one conceptual user session / request. Mirrored onto
|
|
67
|
+
* every report node this run produces so flat dashboard queries
|
|
68
|
+
* don't need to walk the tree.
|
|
69
|
+
*
|
|
70
|
+
* Auto-propagated to every dispatched intent, the router, the
|
|
71
|
+
* receptionist `ack`, and any nested composite invoked through
|
|
72
|
+
* `asTool`. Execution state stays isolated; only observability
|
|
73
|
+
* identity is shared.
|
|
74
|
+
*/
|
|
75
|
+
sessionId?: string;
|
|
76
|
+
};
|
|
77
|
+
/**
|
|
78
|
+
* Options accepted by `supervisor.resume(runId, options?)`.
|
|
79
|
+
*
|
|
80
|
+
* `force: true` bypasses the signature drift check — use only when
|
|
81
|
+
* you have verified that the definition change is safe for the
|
|
82
|
+
* in-flight snapshot. `SupervisorDriftError` is otherwise thrown
|
|
83
|
+
* without executing anything.
|
|
84
|
+
*/
|
|
85
|
+
type SupervisorResumeOptions = SupervisorExecuteOptions & {
|
|
86
|
+
force?: boolean;
|
|
87
|
+
};
|
|
88
|
+
//#endregion
|
|
89
|
+
export { SupervisorExecuteOptions, SupervisorResumeOptions };
|
|
90
|
+
//# sourceMappingURL=supervisor-execute-options.type.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"supervisor-execute-options.type.d.mts","names":[],"sources":["../../../../../../../@warlock.js/ai/src/contracts/supervisor/supervisor-execute-options.type.ts"],"mappings":";;;;;;AAkBA;;;;;;;;;;;;;KAAY,wBAAA;EA6BV;;;;EAxBA,KAAA;EAkDS;AAAA;AAWX;;;EAvDE,MAAA,GAAS,WAAA;EAwDJ;;;;EAnDL,EAAA,GAAK,uBAAA;;;;;;;;;;;;;EAaL,OAAA,GAAU,MAAA;;;;;;;;;;;;;;EAcV,OAAA,GAAU,OAAA;;;;;;;;;;;;EAYV,SAAA;AAAA;;;;;;;;;KAWU,uBAAA,GAA0B,wBAAwB;EAC5D,KAAK;AAAA"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
//#region ../../@warlock.js/ai/src/contracts/supervisor/supervisor-input.type.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Accepted input shape for `supervisor.execute(input)` and the
|
|
4
|
+
* matching field on every supervisor context (`RouteContext`,
|
|
5
|
+
* `EvaluateContext`, `IterationSnapshot`).
|
|
6
|
+
*
|
|
7
|
+
* Two shapes carry every realistic case without bloating the factory
|
|
8
|
+
* with a fourth generic:
|
|
9
|
+
*
|
|
10
|
+
* - `string` — raw user message, the most common case.
|
|
11
|
+
* - `Record<string, unknown>` — structured payload (e.g. `{ orderId,
|
|
12
|
+
* reason, customerId }`) when the supervisor needs more than a
|
|
13
|
+
* sentence to start its work.
|
|
14
|
+
*
|
|
15
|
+
* Callers wanting stronger static typing can wrap the supervisor in
|
|
16
|
+
* their own typed function — the runtime accepts both shapes
|
|
17
|
+
* uniformly. Object inputs are JSON-stringified when forwarded to a
|
|
18
|
+
* child agent without an explicit `entry.input(ctx)` override; supply
|
|
19
|
+
* the override when the agent should see anything other than `JSON.stringify(input)`.
|
|
20
|
+
*/
|
|
21
|
+
type SupervisorInput = string | Record<string, unknown>;
|
|
22
|
+
//#endregion
|
|
23
|
+
export { SupervisorInput };
|
|
24
|
+
//# sourceMappingURL=supervisor-input.type.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"supervisor-input.type.d.mts","names":[],"sources":["../../../../../../../@warlock.js/ai/src/contracts/supervisor/supervisor-input.type.ts"],"mappings":";;AAmBA;;;;AAA6C;;;;;;;;;;;;;;KAAjC,eAAA,YAA2B,MAAM"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { IterationSnapshot } from "./iteration-snapshot.type.mjs";
|
|
2
|
+
import { SupervisorInput } from "./supervisor-input.type.mjs";
|
|
3
|
+
|
|
4
|
+
//#region ../../@warlock.js/ai/src/contracts/supervisor/supervisor-snapshot.type.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* Lifecycle status of a supervisor run, recorded on the persisted
|
|
7
|
+
* snapshot so resume can decide whether a run is still in flight.
|
|
8
|
+
*
|
|
9
|
+
* - `"running"` — the iteration loop is active; a resume is
|
|
10
|
+
* legitimate if the process crashed.
|
|
11
|
+
* - `"completed"` — the supervisor terminated successfully; resume
|
|
12
|
+
* is a no-op and returns the final state.
|
|
13
|
+
* - `"cancelled"` — aborted via `AbortSignal`; resume is allowed
|
|
14
|
+
* (the caller decides whether to retry).
|
|
15
|
+
* - `"failed"` — terminated with an error; resume after the fix.
|
|
16
|
+
*/
|
|
17
|
+
type SupervisorSnapshotStatus = "running" | "completed" | "cancelled" | "failed";
|
|
18
|
+
/**
|
|
19
|
+
* Persisted shape written to the configured `KVStore` after every
|
|
20
|
+
* iteration settles. Exists so `supervisor.resume(runId)` can
|
|
21
|
+
* re-hydrate the history + iteration counter and continue from the
|
|
22
|
+
* next turn.
|
|
23
|
+
*
|
|
24
|
+
* `signature` is a structural fingerprint covering the agent keys,
|
|
25
|
+
* their resolved descriptions, the router's identity (if any), and
|
|
26
|
+
* whether `route` was configured. `resume()` compares this against
|
|
27
|
+
* the current supervisor's signature; mismatch throws
|
|
28
|
+
* `SupervisorDriftError` (bypassable with `{ force: true }`).
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* const snapshot: SupervisorSnapshot = await store.get(`supervisor:${runId}`);
|
|
32
|
+
* if (snapshot?.status === "running") {
|
|
33
|
+
* await supervisor.resume(runId);
|
|
34
|
+
* }
|
|
35
|
+
*/
|
|
36
|
+
type SupervisorSnapshot = {
|
|
37
|
+
runId: string;
|
|
38
|
+
supervisorName: string;
|
|
39
|
+
signature: string; /** The original `execute(input)` value — needed on resume. */
|
|
40
|
+
input: SupervisorInput; /** Index of the last *completed* iteration; -1 before any settle. */
|
|
41
|
+
iteration: number;
|
|
42
|
+
snapshots: IterationSnapshot[];
|
|
43
|
+
status: SupervisorSnapshotStatus;
|
|
44
|
+
startedAt: string;
|
|
45
|
+
savedAt: string;
|
|
46
|
+
};
|
|
47
|
+
//#endregion
|
|
48
|
+
export { SupervisorSnapshot, SupervisorSnapshotStatus };
|
|
49
|
+
//# sourceMappingURL=supervisor-snapshot.type.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"supervisor-snapshot.type.d.mts","names":[],"sources":["../../../../../../../@warlock.js/ai/src/contracts/supervisor/supervisor-snapshot.type.ts"],"mappings":";;;;;;;AAcA;;;;AAAoC;AAwBpC;;;;KAxBY,wBAAA;;;;;;;;;;;;;;;;;AAmCH;;KAXG,kBAAA;EACV,KAAA;EACA,cAAA;EACA,SAAA;EAEA,KAAA,EAL4B,eAAA;EAO5B,SAAA;EACA,SAAA,EAAW,iBAAA;EACX,MAAA,EAAQ,wBAAA;EACR,SAAA;EACA,OAAA;AAAA"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { SupervisorEventMap } from "../events/event-map.type.mjs";
|
|
2
|
+
|
|
3
|
+
//#region ../../@warlock.js/ai/src/contracts/supervisor/supervisor-stream-event.type.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Discriminated union of every event consumers see when iterating
|
|
6
|
+
* `supervisor.stream()`. Mirrors `SupervisorEventMap` keys one-for-one
|
|
7
|
+
* with payloads widened by adding the `type` discriminator, so
|
|
8
|
+
* `for await` consumers can narrow via `event.type === "supervisor.xyz"`
|
|
9
|
+
* the same way agent-stream consumers narrow on `"agent.xyz"`.
|
|
10
|
+
*/
|
|
11
|
+
type SupervisorStreamEvent = { [K in keyof SupervisorEventMap]: {
|
|
12
|
+
type: K;
|
|
13
|
+
} & SupervisorEventMap[K] }[keyof SupervisorEventMap];
|
|
14
|
+
//#endregion
|
|
15
|
+
export { SupervisorStreamEvent };
|
|
16
|
+
//# sourceMappingURL=supervisor-stream-event.type.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"supervisor-stream-event.type.d.mts","names":[],"sources":["../../../../../../../@warlock.js/ai/src/contracts/supervisor/supervisor-stream-event.type.ts"],"mappings":";;;;;AASA;;;;;KAAY,qBAAA,iBACE,kBAAA;EAAuB,IAAA,EAAM,CAAA;AAAA,IAAM,kBAAA,CAAmB,CAAA,UAC5D,kBAAA"}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { ExecutableContract } from "../executable.contract.mjs";
|
|
2
|
+
import { StreamContract } from "../stream/stream.contract.mjs";
|
|
3
|
+
import { ToolContract } from "../../tool/tool.mjs";
|
|
4
|
+
import { SupervisorInput } from "./supervisor-input.type.mjs";
|
|
5
|
+
import { SupervisorEventHandler } from "./supervisor-config.type.mjs";
|
|
6
|
+
import { SupervisorExecuteOptions, SupervisorResumeOptions } from "./supervisor-execute-options.type.mjs";
|
|
7
|
+
import { SupervisorStreamEvent } from "./supervisor-stream-event.type.mjs";
|
|
8
|
+
import { SupervisorResult } from "../result/supervisor-result.type.mjs";
|
|
9
|
+
import { SupervisorEventMap } from "../events/event-map.type.mjs";
|
|
10
|
+
import { StandardSchemaV1 } from "@standard-schema/spec";
|
|
11
|
+
|
|
12
|
+
//#region ../../@warlock.js/ai/src/contracts/supervisor/supervisor.contract.d.ts
|
|
13
|
+
/**
|
|
14
|
+
* Options accepted by `supervisor.asTool()`, mirroring
|
|
15
|
+
* `workflow.asTool()` / `agent.asTool()`. Exposes the supervisor as
|
|
16
|
+
* a tool an outer agent can invoke inside its tool-call loop.
|
|
17
|
+
*
|
|
18
|
+
* `inputSchema` types the tool's `input` payload — the supervisor
|
|
19
|
+
* receives the result of coercing the payload into a string (via
|
|
20
|
+
* the same `stringifyInput` helper the other primitives use) as its
|
|
21
|
+
* `execute(input)` argument.
|
|
22
|
+
*/
|
|
23
|
+
type SupervisorAsToolOptions<TToolInput> = {
|
|
24
|
+
name?: string;
|
|
25
|
+
description?: string;
|
|
26
|
+
inputSchema: StandardSchemaV1<TToolInput>;
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* Runtime handle returned by `ai.supervisor(config)`. Third
|
|
30
|
+
* implementer of `ExecutableContract` alongside `AgentContract` and
|
|
31
|
+
* `WorkflowInstance`, so orchestrators and nested supervisors can
|
|
32
|
+
* dispatch any primitive through the same uniform surface.
|
|
33
|
+
*
|
|
34
|
+
* Implements the 3-tier event subscription model (definition →
|
|
35
|
+
* instance → per-call), with events fired in that order on every
|
|
36
|
+
* emission. See `SupervisorEventMap` for the full surface.
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* const support = ai.supervisor({
|
|
40
|
+
* name: "customer-support",
|
|
41
|
+
* router: routerAgent,
|
|
42
|
+
* intents: { triage, resolver },
|
|
43
|
+
* output: z.object({ response: z.string() }),
|
|
44
|
+
* });
|
|
45
|
+
*
|
|
46
|
+
* // Fire-and-forget — await the typed result
|
|
47
|
+
* const { data, report, usage, error } = await support.execute(ticket);
|
|
48
|
+
*
|
|
49
|
+
* // Or stream every lifecycle event in real time
|
|
50
|
+
* const stream = support.stream(ticket);
|
|
51
|
+
* stream.on({
|
|
52
|
+
* "supervisor.router.decided": ({ next }) => console.log("→", next),
|
|
53
|
+
* "supervisor.agent.streaming": ({ intent, delta }) =>
|
|
54
|
+
* process.stdout.write(`[${intent}] ${delta}`),
|
|
55
|
+
* });
|
|
56
|
+
* const result = await stream.result;
|
|
57
|
+
*
|
|
58
|
+
* // Resume a crashed run from the persisted snapshot
|
|
59
|
+
* const recovered = await support.resume("support-run-42");
|
|
60
|
+
*
|
|
61
|
+
* // Expose the supervisor as a tool for an outer agent
|
|
62
|
+
* const tool = support.asTool({
|
|
63
|
+
* name: "handle_support_ticket",
|
|
64
|
+
* description: "Processes a customer support ticket end-to-end.",
|
|
65
|
+
* inputSchema: z.object({ ticket: z.string() }),
|
|
66
|
+
* });
|
|
67
|
+
*/
|
|
68
|
+
interface SupervisorContract<TOutput = unknown> extends ExecutableContract<SupervisorInput, SupervisorExecuteOptions, SupervisorResult<TOutput>> {
|
|
69
|
+
/** Stable identifier — mirrors the config's `name`. */
|
|
70
|
+
readonly name: string;
|
|
71
|
+
/**
|
|
72
|
+
* Structural fingerprint of the supervisor definition — agent
|
|
73
|
+
* keys + their resolved descriptions + router identity (if set) +
|
|
74
|
+
* whether `route` was configured. Persisted on every snapshot so
|
|
75
|
+
* `resume()` can detect drift.
|
|
76
|
+
*/
|
|
77
|
+
readonly signature: string;
|
|
78
|
+
/**
|
|
79
|
+
* Run the supervisor end-to-end. Returns the uniform `{ data,
|
|
80
|
+
* report, usage, error }` shape. Never throws on runtime failure —
|
|
81
|
+
* errors surface via `result.error`. Authoring-time misconfig
|
|
82
|
+
* throws at factory call, not here.
|
|
83
|
+
*/
|
|
84
|
+
execute(input: SupervisorInput, options?: SupervisorExecuteOptions): Promise<SupervisorResult<TOutput>>;
|
|
85
|
+
/**
|
|
86
|
+
* Stream every lifecycle event in real time. Returns a
|
|
87
|
+
* `StreamContract` whose `result` resolves to the same value
|
|
88
|
+
* `execute()` would produce. Child agent streaming bubbles up as
|
|
89
|
+
* `supervisor.agent.streaming` — UI consumers can render per-
|
|
90
|
+
* agent tokens with zero extra wiring.
|
|
91
|
+
*/
|
|
92
|
+
stream(input: SupervisorInput, options?: SupervisorExecuteOptions): StreamContract<SupervisorResult<TOutput>, SupervisorStreamEvent>;
|
|
93
|
+
/**
|
|
94
|
+
* Resume a supervisor run from its persisted snapshot. Requires
|
|
95
|
+
* `store` to have been configured on the supervisor. Throws
|
|
96
|
+
* `SupervisorDriftError` when the current definition's signature
|
|
97
|
+
* doesn't match the snapshot's, unless `{ force: true }` is set.
|
|
98
|
+
*
|
|
99
|
+
* Idempotency across side-effectful agents is the caller's
|
|
100
|
+
* responsibility — same contract as `workflow.resume()`.
|
|
101
|
+
*/
|
|
102
|
+
resume(runId: string, options?: SupervisorResumeOptions): Promise<SupervisorResult<TOutput>>;
|
|
103
|
+
/**
|
|
104
|
+
* Subscribe an instance-level handler — tier 2 of the 3-tier
|
|
105
|
+
* model. Fires on every run of this supervisor instance, between
|
|
106
|
+
* definition-level and per-call handlers. Returns an unsubscribe
|
|
107
|
+
* function equivalent to `off(event, handler)`.
|
|
108
|
+
*/
|
|
109
|
+
on<K extends keyof SupervisorEventMap>(event: K, handler: SupervisorEventHandler<K>): () => void;
|
|
110
|
+
/**
|
|
111
|
+
* Remove a previously-subscribed instance-level handler. No-op
|
|
112
|
+
* when the handler was never registered or already removed.
|
|
113
|
+
*/
|
|
114
|
+
off<K extends keyof SupervisorEventMap>(event: K, handler: SupervisorEventHandler<K>): void;
|
|
115
|
+
/**
|
|
116
|
+
* Wrap this supervisor as a `ToolContract` so an outer agent can
|
|
117
|
+
* invoke it inside its tool-call loop. The tool calls
|
|
118
|
+
* `supervisor.execute(input)` internally; supervisor failures
|
|
119
|
+
* surface as `ToolExecutionError` with `cause` set to the original
|
|
120
|
+
* typed error.
|
|
121
|
+
*/
|
|
122
|
+
asTool<TToolInput = string>(options: SupervisorAsToolOptions<TToolInput>): ToolContract<TToolInput, TOutput>;
|
|
123
|
+
}
|
|
124
|
+
//#endregion
|
|
125
|
+
export { SupervisorAsToolOptions, SupervisorContract };
|
|
126
|
+
//# sourceMappingURL=supervisor.contract.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"supervisor.contract.d.mts","names":[],"sources":["../../../../../../../@warlock.js/ai/src/contracts/supervisor/supervisor.contract.ts"],"mappings":";;;;;;;;;;;;;;AAwBA;;;;;;;;KAAY,uBAAA;EACV,IAAA;EACA,WAAA;EACA,WAAA,EAAa,gBAAgB,CAAC,UAAA;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UA2Cf,kBAAA,4BAA8C,kBAAA,CAC7D,eAAA,EACA,wBAAA,EACA,gBAAA,CAAiB,OAAA;EAAjB;EAAA,SAGS,IAAA;EAAA;;;;;;EAAA,SAQA,SAAA;EAWN;;;;;;EAHH,OAAA,CACE,KAAA,EAAO,eAAA,EACP,OAAA,GAAU,wBAAA,GACT,OAAA,CAAQ,gBAAA,CAAiB,OAAA;EAW1B;;;;;;;EAFF,MAAA,CACE,KAAA,EAAO,eAAA,EACP,OAAA,GAAU,wBAAA,GACT,cAAA,CAAe,gBAAA,CAAiB,OAAA,GAAU,qBAAA;EAWvB;;;;;;;;;EAAtB,MAAA,CAAO,KAAA,UAAe,OAAA,GAAU,uBAAA,GAA0B,OAAA,CAAQ,gBAAA,CAAiB,OAAA;EAQF;;;;;;EAAjF,EAAA,iBAAmB,kBAAA,EAAoB,KAAA,EAAO,CAAA,EAAG,OAAA,EAAS,sBAAA,CAAuB,CAAA;EAMtB;;;;EAA3D,GAAA,iBAAoB,kBAAA,EAAoB,KAAA,EAAO,CAAA,EAAG,OAAA,EAAS,sBAAA,CAAuB,CAAA;EAUvE;;;;;;;EADX,MAAA,sBACE,OAAA,EAAS,uBAAA,CAAwB,UAAA,IAChC,YAAA,CAAa,UAAA,EAAY,OAAA;AAAA"}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { Placeholders } from "./placeholders.type.mjs";
|
|
2
|
+
|
|
3
|
+
//#region ../../@warlock.js/ai/src/contracts/system-prompt.contract.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Base contract shared by every block that can appear inside a
|
|
6
|
+
* `SystemPromptContract` — currently persona and instruction, with room for
|
|
7
|
+
* future block kinds (examples, guardrails, etc.) without breaking changes.
|
|
8
|
+
*
|
|
9
|
+
* Blocks are discriminated by a string `type` tag — not `instanceof` — so
|
|
10
|
+
* runtime checks remain robust across duplicate package copies, bundler
|
|
11
|
+
* scopes, and user-supplied implementations that don't extend our classes.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* // Narrow via the discriminator
|
|
15
|
+
* if (block.type === "persona") {
|
|
16
|
+
* // block is PersonaContract
|
|
17
|
+
* }
|
|
18
|
+
*/
|
|
19
|
+
interface SystemPromptBlockContract {
|
|
20
|
+
/** Discriminator for the concrete block kind. */
|
|
21
|
+
readonly type: string;
|
|
22
|
+
/** Raw template text, before placeholder resolution. */
|
|
23
|
+
readonly text: string;
|
|
24
|
+
/** Render the block with placeholders substituted in. */
|
|
25
|
+
resolve(placeholders?: Placeholders): string;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Contract for a persona block — the "who the agent is" layer of a system
|
|
29
|
+
* prompt. A persona owns a single template string and resolves its own
|
|
30
|
+
* placeholders, so the same `Persona` instance can be reused across many
|
|
31
|
+
* `SystemPrompt`s or agents without recomputation.
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* const alex: PersonaContract = ai.persona("You are Alex, a TypeScript expert.");
|
|
35
|
+
* alex.resolve(); // "You are Alex, a TypeScript expert."
|
|
36
|
+
*/
|
|
37
|
+
interface PersonaContract extends SystemPromptBlockContract {
|
|
38
|
+
readonly type: "persona";
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Contract for a single instruction block — one directive in a layered
|
|
42
|
+
* system prompt. Each instruction owns its own template string and resolves
|
|
43
|
+
* its placeholders independently, so the same `Instruction` instance can be
|
|
44
|
+
* reused across different `SystemPrompt`s with different placeholder maps.
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* const replyInLanguage: InstructionContract =
|
|
48
|
+
* ai.instruction("Respond in {{language|English}}.");
|
|
49
|
+
*
|
|
50
|
+
* replyInLanguage.resolve({ language: "Arabic" });
|
|
51
|
+
* // "Respond in Arabic."
|
|
52
|
+
*/
|
|
53
|
+
interface InstructionContract extends SystemPromptBlockContract {
|
|
54
|
+
readonly type: "instruction";
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Immutable builder for composing a layered system prompt out of persona and
|
|
58
|
+
* instruction blocks. Every mutating method returns a fresh builder — the
|
|
59
|
+
* original is never mutated, so base prompts can be forked into specialized
|
|
60
|
+
* variants without side effects.
|
|
61
|
+
*
|
|
62
|
+
* Blocks are stored in a single ordered list and rendered in insertion order.
|
|
63
|
+
* The array-form factory (`systemPrompt([...])`) gives you full control over
|
|
64
|
+
* placement; the chainable form defaults to persona-first by prepending new
|
|
65
|
+
* personas (or replacing an existing one in place).
|
|
66
|
+
*
|
|
67
|
+
* Both `persona()` and `instruction()` accept either a raw string (auto-
|
|
68
|
+
* wrapped into a `Persona` / `Instruction`) or a pre-built contract
|
|
69
|
+
* instance. Passing instances lets the same block be reused across many
|
|
70
|
+
* prompts with each prompt supplying its own placeholder map at resolve time.
|
|
71
|
+
*
|
|
72
|
+
* @example
|
|
73
|
+
* // Chainable form
|
|
74
|
+
* const alex = ai.persona("You are Alex, a TypeScript expert.");
|
|
75
|
+
* const replyIn = ai.instruction("Respond in {{language|English}}.");
|
|
76
|
+
*
|
|
77
|
+
* const prompt = ai.systemPrompt()
|
|
78
|
+
* .persona(alex)
|
|
79
|
+
* .instruction(replyIn)
|
|
80
|
+
* .instruction("Always include working code examples.");
|
|
81
|
+
*
|
|
82
|
+
* @example
|
|
83
|
+
* // Array form — insertion order is preserved exactly
|
|
84
|
+
* const prompt = ai.systemPrompt([
|
|
85
|
+
* ai.persona("You are Alex, a TypeScript expert."),
|
|
86
|
+
* ai.instruction("Respond in {{language|English}}."),
|
|
87
|
+
* ai.instruction("Always include working code examples."),
|
|
88
|
+
* ]);
|
|
89
|
+
*
|
|
90
|
+
* const arabic = prompt.resolve({ language: "Arabic" });
|
|
91
|
+
*/
|
|
92
|
+
interface SystemPromptContract {
|
|
93
|
+
/** All blocks in render order. Read-only snapshot — use `persona()` / `instruction()` to derive a new builder. */
|
|
94
|
+
readonly blocks: readonly SystemPromptBlockContract[];
|
|
95
|
+
/**
|
|
96
|
+
* Set (or replace) the persona block. Returns a new builder. If a persona
|
|
97
|
+
* already exists it's replaced in place (preserving its position);
|
|
98
|
+
* otherwise the new persona is prepended. Only one persona per prompt.
|
|
99
|
+
*/
|
|
100
|
+
persona(persona: PersonaContract | string): SystemPromptContract;
|
|
101
|
+
/**
|
|
102
|
+
* Append an instruction block. Returns a new builder. Multiple calls
|
|
103
|
+
* accumulate — instructions render in the order they were added.
|
|
104
|
+
*/
|
|
105
|
+
instruction(instruction: InstructionContract | string): SystemPromptContract;
|
|
106
|
+
/**
|
|
107
|
+
* Resolve all placeholders across every block, producing the final system
|
|
108
|
+
* prompt string. Blocks render in insertion order, separated by a blank line.
|
|
109
|
+
*
|
|
110
|
+
* Supports `{{key}}`, `{{nested.key}}`, and `{{key|default}}` syntax.
|
|
111
|
+
*
|
|
112
|
+
* @param placeholders - Values to inject into `{{mustache}}` slots.
|
|
113
|
+
*/
|
|
114
|
+
resolve(placeholders?: Placeholders): string;
|
|
115
|
+
}
|
|
116
|
+
//#endregion
|
|
117
|
+
export { InstructionContract, PersonaContract, SystemPromptBlockContract, SystemPromptContract };
|
|
118
|
+
//# sourceMappingURL=system-prompt.contract.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"system-prompt.contract.d.mts","names":[],"sources":["../../../../../../@warlock.js/ai/src/contracts/system-prompt.contract.ts"],"mappings":";;;;;AAiBA;;;;;;;;;;AAQqC;AAarC;;UArBiB,yBAAA;EAqBwB;EAAA,SAnB9B,IAAA;EAoCM;EAAA,SAjCN,IAAA;;EAGT,OAAA,CAAQ,YAAA,GAAe,YAAY;AAAA;AAsErC;;;;;;;;;;AAAA,UAzDiB,eAAA,SAAwB,yBAAyB;EAAA,SACvD,IAAI;AAAA;;;;;;;;;;;;;AAiFsB;UAjEpB,mBAAA,SAA4B,yBAAyB;EAAA,SAC3D,IAAI;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UAuCE,oBAAA;;WAEN,MAAA,WAAiB,yBAAA;;;;;;EAO1B,OAAA,CAAQ,OAAA,EAAS,eAAA,YAA2B,oBAAA;;;;;EAM5C,WAAA,CAAY,WAAA,EAAa,mBAAA,YAA+B,oBAAA;;;;;;;;;EAUxD,OAAA,CAAQ,YAAA,GAAe,YAAA;AAAA"}
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import { StandardSchemaV1 } from "@standard-schema/spec";
|
|
2
|
+
|
|
3
|
+
//#region ../../@warlock.js/ai/src/contracts/tool.contract.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Optional metadata attached to a tool for documentation and tooling.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* const meta: ToolMeta = { category: "search", version: "1.0" };
|
|
9
|
+
*/
|
|
10
|
+
type ToolMeta = Record<"label" | "actionLabel" | (string & {}), unknown>;
|
|
11
|
+
/**
|
|
12
|
+
* Discriminated mode controlling whether the tool's result feeds back
|
|
13
|
+
* to the model.
|
|
14
|
+
*
|
|
15
|
+
* - **`feedback`** (default) — standard tool behavior. The model emits
|
|
16
|
+
* a tool call, the agent dispatches the tool, the result is appended
|
|
17
|
+
* to the conversation as a `role: "tool"` message, and the agent
|
|
18
|
+
* makes another LLM trip so the model can read the result and
|
|
19
|
+
* respond. Use for tools whose output the model needs to narrate
|
|
20
|
+
* (search, lookup, classification with a reply that depends on it).
|
|
21
|
+
*
|
|
22
|
+
* - **`silent`** — fire-and-forget mechanics. The tool's *result* is
|
|
23
|
+
* not fed back to the model. When every tool call in a single
|
|
24
|
+
* generation is `silent`, the agent loop terminates after dispatch:
|
|
25
|
+
* the prose the model streamed alongside the tool call IS the final
|
|
26
|
+
* reply. Use for pure side-effect tools where the model already
|
|
27
|
+
* knows what to say before the tool runs (state mutations, locale
|
|
28
|
+
* pinning, topic classification updates, telemetry pings).
|
|
29
|
+
*
|
|
30
|
+
* **What "silent" applies to.** Strictly the LLM-feedback channel.
|
|
31
|
+
* The tool itself runs to completion through middleware (logging,
|
|
32
|
+
* cost tracking, telemetry) like any other — only the model-feedback
|
|
33
|
+
* leg is closed.
|
|
34
|
+
*
|
|
35
|
+
* **Constraints for silent tools.** Should be cheap, idempotent, and
|
|
36
|
+
* side-effect-only. No slow ops, no expensive network calls — the
|
|
37
|
+
* customer is waiting on the prose stream that already finished, but
|
|
38
|
+
* the request is still open until the silent tool resolves.
|
|
39
|
+
*
|
|
40
|
+
* **Mixed-mode trips.** If a single generation contains both
|
|
41
|
+
* `feedback` and `silent` tool calls, the loop continues — the
|
|
42
|
+
* feedback tool's result still needs to round-trip. The "all silent
|
|
43
|
+
* → terminate" rule only kicks in when EVERY tool call is silent.
|
|
44
|
+
*/
|
|
45
|
+
type ToolMode = "feedback" | "silent";
|
|
46
|
+
/**
|
|
47
|
+
* Per-call context threaded into a tool handler as the optional second
|
|
48
|
+
* argument (Phase 5 / decisions §35).
|
|
49
|
+
*
|
|
50
|
+
* **Role.** Carry system-only data that should NOT round-trip through
|
|
51
|
+
* the LLM. The tool's `return` value is what the agent sees;
|
|
52
|
+
* `ctx.artifacts` is what the system captures. Strict separation of
|
|
53
|
+
* channels — neither leaks into the other.
|
|
54
|
+
*
|
|
55
|
+
* **Lifecycle.** When dispatched under a supervisor, the bag starts
|
|
56
|
+
* empty at every iteration boundary, accumulates across all tool
|
|
57
|
+
* calls in that iteration, and merges into supervisor state via
|
|
58
|
+
* `artifactsSchema` / `finalizeArtifacts` at iteration end. When the
|
|
59
|
+
* tool runs standalone (`tool.invoke(input)` without a ctx), a
|
|
60
|
+
* degraded `{ artifacts: {} }` is supplied — mutations are harmless
|
|
61
|
+
* no-ops.
|
|
62
|
+
*
|
|
63
|
+
* @example
|
|
64
|
+
* ai.tool({
|
|
65
|
+
* name: "search_catalog",
|
|
66
|
+
* input: v.object({ query: v.string() }),
|
|
67
|
+
* execute: async (input, ctx) => {
|
|
68
|
+
* const items = await searchItems(input.query);
|
|
69
|
+
*
|
|
70
|
+
* // Side-channel: blocks land in supervisor state, not the LLM.
|
|
71
|
+
* ctx.artifacts.blocks ??= [];
|
|
72
|
+
* ctx.artifacts.blocks.push({ type: "items", itemIds: items.map(i => i.id) });
|
|
73
|
+
*
|
|
74
|
+
* // Return value: what the agent sees and reasons over.
|
|
75
|
+
* return { total: items.length };
|
|
76
|
+
* },
|
|
77
|
+
* });
|
|
78
|
+
*/
|
|
79
|
+
type ToolContext<TArtifacts = Record<string, unknown>> = {
|
|
80
|
+
/**
|
|
81
|
+
* Mutable bag for system-only data. Writes here never reach the
|
|
82
|
+
* LLM. Shape is typed by the registering supervisor's
|
|
83
|
+
* `artifactsSchema` when present; defaults to
|
|
84
|
+
* `Record<string, unknown>` for tools used outside a supervisor.
|
|
85
|
+
*/
|
|
86
|
+
artifacts: TArtifacts; /** Same signal threaded through dispatch — for cancellation-aware tools. */
|
|
87
|
+
signal?: AbortSignal;
|
|
88
|
+
};
|
|
89
|
+
/**
|
|
90
|
+
* Contract that every tool must implement.
|
|
91
|
+
* Tools are callable functions exposed to the LLM during agent execution.
|
|
92
|
+
*
|
|
93
|
+
* @example
|
|
94
|
+
* import { z } from "zod"; // or any Standard Schema compatible library
|
|
95
|
+
*
|
|
96
|
+
* const searchTool: ToolConfig<{ query: string }, { results: string[] }> = {
|
|
97
|
+
* name: "searchWeb",
|
|
98
|
+
* description: "Search the web for current information",
|
|
99
|
+
* input: z.object({ query: z.string() }),
|
|
100
|
+
* execute: async ({ query }) => ({ results: ["result1", "result2"] }),
|
|
101
|
+
* };
|
|
102
|
+
*/
|
|
103
|
+
interface ToolConfig<TInput = unknown, TOutput = unknown> {
|
|
104
|
+
/** Unique tool name exposed to the LLM */
|
|
105
|
+
name: string;
|
|
106
|
+
/** Human-readable description of what the tool does */
|
|
107
|
+
description: string;
|
|
108
|
+
/**
|
|
109
|
+
* Dev-curated version string mirrored onto every report node this
|
|
110
|
+
* tool produces. Free-form — semver, date, hash. Bump when the
|
|
111
|
+
* tool's behavior changes in a way that matters for stored
|
|
112
|
+
* trip-archive queries (schema rev, new API endpoint, semantic
|
|
113
|
+
* change). The framework neither parses nor compares it.
|
|
114
|
+
*/
|
|
115
|
+
version?: string;
|
|
116
|
+
/**
|
|
117
|
+
* Present-progressive UI string surfaced on `agent.tool.calling` /
|
|
118
|
+
* `agent.tool.called` events for streaming UX (e.g.
|
|
119
|
+
* `"Searching the catalog"`). Distinct from `description`, which
|
|
120
|
+
* the LLM reads — `action` is for humans/UI.
|
|
121
|
+
*
|
|
122
|
+
* Two forms:
|
|
123
|
+
* - **string** — static, used as-is.
|
|
124
|
+
* - **function** — receives the validated input and returns a
|
|
125
|
+
* string, so callers can include input data
|
|
126
|
+
* (`(input) => \`Searching for "${input.query}"\``).
|
|
127
|
+
*
|
|
128
|
+
* Resolved at the framework boundary; consumers receive a
|
|
129
|
+
* pre-resolved string in `ToolEventMeta.action`.
|
|
130
|
+
*/
|
|
131
|
+
action?: string | ((input: TInput) => string);
|
|
132
|
+
/** Optional metadata for documentation or tooling */
|
|
133
|
+
meta?: ToolMeta;
|
|
134
|
+
/**
|
|
135
|
+
* Result-feedback mode. Defaults to `"feedback"` (standard
|
|
136
|
+
* round-trip behavior) when unset. See {@link ToolMode} for the
|
|
137
|
+
* full contract on `"silent"` semantics, constraints, and the
|
|
138
|
+
* mixed-mode rule.
|
|
139
|
+
*/
|
|
140
|
+
mode?: ToolMode;
|
|
141
|
+
/**
|
|
142
|
+
* Standard Schema-compatible input schema.
|
|
143
|
+
* Any schema library implementing @standard-schema/spec works here
|
|
144
|
+
* (e.g. Zod, Valibot, ArkType, warlock's seal).
|
|
145
|
+
*/
|
|
146
|
+
input?: StandardSchemaV1<TInput>;
|
|
147
|
+
/**
|
|
148
|
+
* Execute the tool with validated input.
|
|
149
|
+
* Called by the agent runtime after the LLM requests this tool.
|
|
150
|
+
*
|
|
151
|
+
* The optional second `ctx` parameter (Phase 5 / decisions §35)
|
|
152
|
+
* carries a `ToolContext` with a mutable `artifacts` bag for
|
|
153
|
+
* system-only side data. Tools written with the single-arg
|
|
154
|
+
* signature continue to work unchanged — the framework supplies a
|
|
155
|
+
* degraded ctx when one isn't threaded through.
|
|
156
|
+
*/
|
|
157
|
+
execute(input: TInput, ctx?: ToolContext): Promise<TOutput>;
|
|
158
|
+
}
|
|
159
|
+
//#endregion
|
|
160
|
+
export { ToolConfig, ToolContext, ToolMeta, ToolMode };
|
|
161
|
+
//# sourceMappingURL=tool.contract.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool.contract.d.mts","names":[],"sources":["../../../../../../@warlock.js/ai/src/contracts/tool.contract.ts"],"mappings":";;;;;AAQA;;;;KAAY,QAAA,GAAW,MAAM;AAoC7B;;;;AAAoB;AAmCpB;;;;;;;;;;;;;;;AASsB;AAiBtB;;;;;;;;;;;;;AA7DA,KAAY,QAAA;;;;;;;;;;;;;;;;;;;;;;;;AAmHgD;;;;;;;;;;KAhFhD,WAAA,cAAyB,MAAA;;;;;;;EAOnC,SAAA,EAAW,UAAA;EAEX,MAAA,GAAS,WAAA;AAAA;;;;;;;;;;;;;;;UAiBM,UAAA;;EAEf,IAAA;;EAEA,WAAA;;;;;;;;EAQA,OAAA;;;;;;;;;;;;;;;;EAgBA,MAAA,cAAoB,KAAA,EAAO,MAAA;;EAE3B,IAAA,GAAO,QAAA;;;;;;;EAOP,IAAA,GAAO,QAAA;;;;;;EAMP,KAAA,GAAQ,gBAAA,CAAiB,MAAA;;;;;;;;;;;EAWzB,OAAA,CAAQ,KAAA,EAAO,MAAA,EAAQ,GAAA,GAAM,WAAA,GAAc,OAAA,CAAQ,OAAA;AAAA"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { NextStepResult } from "./next-step-result.type.mjs";
|
|
2
|
+
import { RetryBackoff, RetryConfig } from "./retry-config.type.mjs";
|
|
3
|
+
import { WorkflowContext } from "./workflow-context.type.mjs";
|
|
4
|
+
import { StepAgentInput, StepDefinition, StepLocalEvents, StepOutputSpec } from "./step.contract.mjs";
|
|
5
|
+
import { WorkflowDefinition, WorkflowEventHandler, WorkflowEventHandlers, WorkflowExecuteOptions, WorkflowInstance, WorkflowResumeOptions, WorkflowRunOptions } from "./workflow.contract.mjs";
|
|
6
|
+
import { WorkflowSnapshot } from "./workflow-snapshot.type.mjs";
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
//#region ../../@warlock.js/ai/src/contracts/workflow/next-step-result.type.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Return shape for `nextStep` callbacks — controls workflow routing.
|
|
4
|
+
*
|
|
5
|
+
* - `{ goto: string }` — jump to a named step
|
|
6
|
+
* - `{ end: true }` — terminate the workflow successfully
|
|
7
|
+
* - `void` / `undefined` — fall through (next declared step, or next
|
|
8
|
+
* level of routing resolution)
|
|
9
|
+
*/
|
|
10
|
+
type NextStepResult = {
|
|
11
|
+
goto: string;
|
|
12
|
+
} | {
|
|
13
|
+
end: true;
|
|
14
|
+
} | void | undefined;
|
|
15
|
+
//#endregion
|
|
16
|
+
export { NextStepResult };
|
|
17
|
+
//# sourceMappingURL=next-step-result.type.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"next-step-result.type.d.mts","names":[],"sources":["../../../../../../../@warlock.js/ai/src/contracts/workflow/next-step-result.type.ts"],"mappings":";;AAQA;;;;AAES;;;KAFG,cAAA;EACN,IAAA;AAAA;EACA,GAAG;AAAA"}
|