@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
package/esm/ai.d.mts
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { tool } from "./tool/tool.mjs";
|
|
2
|
+
import { agent } from "./agent/agent.mjs";
|
|
3
|
+
import { setAIConfig } from "./config.mjs";
|
|
4
|
+
import { budget } from "./middleware/builtins/budget.mjs";
|
|
5
|
+
import { guardrail } from "./middleware/builtins/guardrail.mjs";
|
|
6
|
+
import { semanticCache } from "./middleware/builtins/semantic-cache.mjs";
|
|
7
|
+
import { composeMiddleware } from "./middleware/helpers/compose.mjs";
|
|
8
|
+
import { forTool } from "./middleware/helpers/for-tool.mjs";
|
|
9
|
+
import { supervisor } from "./supervisor/supervisor.mjs";
|
|
10
|
+
import { instruction } from "./system-prompt/instruction.mjs";
|
|
11
|
+
import { persona } from "./system-prompt/persona.mjs";
|
|
12
|
+
import { systemPrompt } from "./system-prompt/system-prompt.mjs";
|
|
13
|
+
import { step } from "./workflow/step.mjs";
|
|
14
|
+
import { workflow } from "./workflow/workflow.mjs";
|
|
15
|
+
|
|
16
|
+
//#region ../../@warlock.js/ai/src/ai.d.ts
|
|
17
|
+
/**
|
|
18
|
+
* Top-level `ai` namespace — holds built-in factories and user-registered SDK adapters.
|
|
19
|
+
*
|
|
20
|
+
* Factories:
|
|
21
|
+
* - `ai.tool(...)` — wrap an async function with a schema-validated input.
|
|
22
|
+
* - `ai.agent(...)` — build an executable agent from model + tools + prompt.
|
|
23
|
+
* - `ai.systemPrompt(...)` — compose a layered persona + instructions prompt.
|
|
24
|
+
* - `ai.persona(text)` — reusable persona block (can be passed to `systemPrompt`).
|
|
25
|
+
* - `ai.instruction(text)` — reusable instruction block (can be passed to `systemPrompt`).
|
|
26
|
+
* - `ai.openai.model(...)` / `ai.anthropic.model(...)` / ... once the adapter SDK is registered.
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* const alex = ai.persona("You are Alex, a TypeScript expert.");
|
|
30
|
+
* const replyIn = ai.instruction("Respond in {{language|English}}.");
|
|
31
|
+
*
|
|
32
|
+
* const prompt = ai.systemPrompt().persona(alex).instruction(replyIn);
|
|
33
|
+
*
|
|
34
|
+
* const myAgent = ai.agent({
|
|
35
|
+
* model: ai.openai.model({ name: "gpt-4o" }),
|
|
36
|
+
* systemPrompt: prompt,
|
|
37
|
+
* tools: [myTool],
|
|
38
|
+
* });
|
|
39
|
+
*
|
|
40
|
+
* const result = await myAgent.execute("What is the weather in Cairo?", {
|
|
41
|
+
* placeholders: { language: "Arabic" },
|
|
42
|
+
* });
|
|
43
|
+
*/
|
|
44
|
+
declare const ai: {
|
|
45
|
+
config: typeof setAIConfig;
|
|
46
|
+
tool: typeof tool;
|
|
47
|
+
agent: typeof agent;
|
|
48
|
+
systemPrompt: typeof systemPrompt;
|
|
49
|
+
persona: typeof persona;
|
|
50
|
+
instruction: typeof instruction;
|
|
51
|
+
workflow: typeof workflow;
|
|
52
|
+
step: typeof step;
|
|
53
|
+
supervisor: typeof supervisor;
|
|
54
|
+
middleware: {
|
|
55
|
+
budget: typeof budget;
|
|
56
|
+
guardrail: typeof guardrail;
|
|
57
|
+
semanticCache: typeof semanticCache;
|
|
58
|
+
compose: typeof composeMiddleware;
|
|
59
|
+
forTool: typeof forTool;
|
|
60
|
+
};
|
|
61
|
+
};
|
|
62
|
+
//#endregion
|
|
63
|
+
export { ai };
|
|
64
|
+
//# sourceMappingURL=ai.d.mts.map
|
package/esm/ai.d.mts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ai.d.mts","names":[],"sources":["../../../../../@warlock.js/ai/src/ai.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;AAyCA;;;;;;;;;;;;;;;;;;;;;;;cAAa,EAAA"}
|
package/esm/ai.mjs
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { budget } from "./middleware/builtins/budget.mjs";
|
|
2
|
+
import { guardrail } from "./middleware/builtins/guardrail.mjs";
|
|
3
|
+
import { setAIConfig } from "./config.mjs";
|
|
4
|
+
import { semanticCache } from "./middleware/builtins/semantic-cache.mjs";
|
|
5
|
+
import { composeMiddleware } from "./middleware/helpers/compose.mjs";
|
|
6
|
+
import { forTool } from "./middleware/helpers/for-tool.mjs";
|
|
7
|
+
import { agent } from "./agent/agent.mjs";
|
|
8
|
+
import { tool } from "./tool/tool.mjs";
|
|
9
|
+
import { supervisor } from "./supervisor/supervisor.mjs";
|
|
10
|
+
import { instruction } from "./system-prompt/instruction.mjs";
|
|
11
|
+
import { persona } from "./system-prompt/persona.mjs";
|
|
12
|
+
import { systemPrompt } from "./system-prompt/system-prompt.mjs";
|
|
13
|
+
import { step } from "./workflow/step.mjs";
|
|
14
|
+
import { workflow } from "./workflow/workflow.mjs";
|
|
15
|
+
|
|
16
|
+
//#region ../../@warlock.js/ai/src/ai.ts
|
|
17
|
+
/**
|
|
18
|
+
* Top-level `ai` namespace — holds built-in factories and user-registered SDK adapters.
|
|
19
|
+
*
|
|
20
|
+
* Factories:
|
|
21
|
+
* - `ai.tool(...)` — wrap an async function with a schema-validated input.
|
|
22
|
+
* - `ai.agent(...)` — build an executable agent from model + tools + prompt.
|
|
23
|
+
* - `ai.systemPrompt(...)` — compose a layered persona + instructions prompt.
|
|
24
|
+
* - `ai.persona(text)` — reusable persona block (can be passed to `systemPrompt`).
|
|
25
|
+
* - `ai.instruction(text)` — reusable instruction block (can be passed to `systemPrompt`).
|
|
26
|
+
* - `ai.openai.model(...)` / `ai.anthropic.model(...)` / ... once the adapter SDK is registered.
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* const alex = ai.persona("You are Alex, a TypeScript expert.");
|
|
30
|
+
* const replyIn = ai.instruction("Respond in {{language|English}}.");
|
|
31
|
+
*
|
|
32
|
+
* const prompt = ai.systemPrompt().persona(alex).instruction(replyIn);
|
|
33
|
+
*
|
|
34
|
+
* const myAgent = ai.agent({
|
|
35
|
+
* model: ai.openai.model({ name: "gpt-4o" }),
|
|
36
|
+
* systemPrompt: prompt,
|
|
37
|
+
* tools: [myTool],
|
|
38
|
+
* });
|
|
39
|
+
*
|
|
40
|
+
* const result = await myAgent.execute("What is the weather in Cairo?", {
|
|
41
|
+
* placeholders: { language: "Arabic" },
|
|
42
|
+
* });
|
|
43
|
+
*/
|
|
44
|
+
const ai = {
|
|
45
|
+
config: setAIConfig,
|
|
46
|
+
tool,
|
|
47
|
+
agent,
|
|
48
|
+
systemPrompt,
|
|
49
|
+
persona,
|
|
50
|
+
instruction,
|
|
51
|
+
workflow,
|
|
52
|
+
step,
|
|
53
|
+
supervisor,
|
|
54
|
+
middleware: {
|
|
55
|
+
budget,
|
|
56
|
+
guardrail,
|
|
57
|
+
semanticCache,
|
|
58
|
+
compose: composeMiddleware,
|
|
59
|
+
forTool
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
//#endregion
|
|
64
|
+
export { ai };
|
|
65
|
+
//# sourceMappingURL=ai.mjs.map
|
package/esm/ai.mjs.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ai.mjs","names":[],"sources":["../../../../../@warlock.js/ai/src/ai.ts"],"sourcesContent":["import { agent } from \"./agent/agent\";\nimport { setAIConfig } from \"./config\";\nimport { budget } from \"./middleware/builtins/budget\";\nimport { guardrail } from \"./middleware/builtins/guardrail\";\nimport { semanticCache } from \"./middleware/builtins/semantic-cache\";\nimport { composeMiddleware, forTool } from \"./middleware/helpers\";\nimport { supervisor } from \"./supervisor/supervisor\";\nimport { instruction } from \"./system-prompt/instruction\";\nimport { persona } from \"./system-prompt/persona\";\nimport { systemPrompt } from \"./system-prompt/system-prompt\";\nimport { tool } from \"./tool/tool\";\nimport { step } from \"./workflow/step\";\nimport { workflow } from \"./workflow/workflow\";\n\n/**\n * Top-level `ai` namespace — holds built-in factories and user-registered SDK adapters.\n *\n * Factories:\n * - `ai.tool(...)` — wrap an async function with a schema-validated input.\n * - `ai.agent(...)` — build an executable agent from model + tools + prompt.\n * - `ai.systemPrompt(...)` — compose a layered persona + instructions prompt.\n * - `ai.persona(text)` — reusable persona block (can be passed to `systemPrompt`).\n * - `ai.instruction(text)` — reusable instruction block (can be passed to `systemPrompt`).\n * - `ai.openai.model(...)` / `ai.anthropic.model(...)` / ... once the adapter SDK is registered.\n *\n * @example\n * const alex = ai.persona(\"You are Alex, a TypeScript expert.\");\n * const replyIn = ai.instruction(\"Respond in {{language|English}}.\");\n *\n * const prompt = ai.systemPrompt().persona(alex).instruction(replyIn);\n *\n * const myAgent = ai.agent({\n * model: ai.openai.model({ name: \"gpt-4o\" }),\n * systemPrompt: prompt,\n * tools: [myTool],\n * });\n *\n * const result = await myAgent.execute(\"What is the weather in Cairo?\", {\n * placeholders: { language: \"Arabic\" },\n * });\n */\nexport const ai = {\n config: setAIConfig,\n tool,\n agent,\n systemPrompt,\n persona,\n instruction,\n workflow,\n step,\n supervisor,\n middleware: {\n budget,\n guardrail,\n semanticCache,\n compose: composeMiddleware,\n forTool,\n },\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyCA,MAAa,KAAK;CAChB,QAAQ;CACR;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA,YAAY;EACV;EACA;EACA;EACA,SAAS;EACT;CACF;AACF"}
|
package/esm/config.d.mts
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { CacheDriver } from "@warlock.js/cache";
|
|
2
|
+
|
|
3
|
+
//#region ../../@warlock.js/ai/src/config.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Process-wide `@warlock.js/ai` configuration. **Intentionally tiny.**
|
|
6
|
+
* Lives here only for genuinely cross-cutting defaults that would
|
|
7
|
+
* otherwise force users to wire the same value into every consumer.
|
|
8
|
+
*
|
|
9
|
+
* **What lives here.** A field earns a slot only when it satisfies
|
|
10
|
+
* all three:
|
|
11
|
+
* 1. Multiple unrelated consumers need the same value.
|
|
12
|
+
* 2. The value is infrastructure (drivers, clients, pools), not
|
|
13
|
+
* behavior (kill-switches, mode flags).
|
|
14
|
+
* 3. Per-call override doesn't make sense for the use case.
|
|
15
|
+
*
|
|
16
|
+
* **What does NOT live here.** Logger config (use
|
|
17
|
+
* `@warlock.js/logger` directly). Per-primitive feature flags
|
|
18
|
+
* (live on the relevant config type). Anything that's really one
|
|
19
|
+
* consumer's concern (lives on that consumer).
|
|
20
|
+
*
|
|
21
|
+
* Phase 3.2 deliberately removed the previous `configureAI()` bag
|
|
22
|
+
* because it was growing unbounded. Treat new fields here with the
|
|
23
|
+
* same suspicion.
|
|
24
|
+
*/
|
|
25
|
+
type AIConfig = {
|
|
26
|
+
/**
|
|
27
|
+
* Default store used by every consumer that supports persistence
|
|
28
|
+
* but didn't supply its own `store` / `snapshotStore`. Most
|
|
29
|
+
* realistic deployments back resume snapshots, semantic cache, and
|
|
30
|
+
* future memory primitives with the same driver — declaring it
|
|
31
|
+
* once here removes the repetition.
|
|
32
|
+
*
|
|
33
|
+
* Per-declaration overrides (`SupervisorConfig.snapshotStore`,
|
|
34
|
+
* `semanticCache({ store })`) win when supplied. Set this once at
|
|
35
|
+
* app boot, *after* you've constructed your driver.
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* import { cache } from "@warlock.js/cache";
|
|
39
|
+
* import { ai } from "@warlock.js/ai";
|
|
40
|
+
*
|
|
41
|
+
* ai.config({
|
|
42
|
+
* defaultStore: cache.driver("redis", { client: redisClient }),
|
|
43
|
+
* });
|
|
44
|
+
*/
|
|
45
|
+
defaultStore?: CacheDriver<any, any>;
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* Set or extend process-wide AI configuration. Merges over existing
|
|
49
|
+
* values — fields not present in `partial` keep whatever was set
|
|
50
|
+
* before (or stay unset). Call once at app boot, before constructing
|
|
51
|
+
* any agent / supervisor / middleware that should pick up the
|
|
52
|
+
* defaults.
|
|
53
|
+
*
|
|
54
|
+
* Returns the merged config so callers can verify what landed.
|
|
55
|
+
*
|
|
56
|
+
* @example
|
|
57
|
+
* import { cache } from "@warlock.js/cache";
|
|
58
|
+
* import { ai } from "@warlock.js/ai";
|
|
59
|
+
*
|
|
60
|
+
* ai.config({ defaultStore: cache.driver("redis", { client }) });
|
|
61
|
+
*/
|
|
62
|
+
declare function setAIConfig(partial: Partial<AIConfig>): AIConfig;
|
|
63
|
+
/**
|
|
64
|
+
* Read the current AI config snapshot. Returns a shallow copy so
|
|
65
|
+
* callers can't accidentally mutate the source of truth. Used
|
|
66
|
+
* internally by consumers to resolve their `defaultStore` fallback.
|
|
67
|
+
*/
|
|
68
|
+
declare function getAIConfig(): AIConfig;
|
|
69
|
+
/**
|
|
70
|
+
* Resolve the effective store for a consumer that didn't receive an
|
|
71
|
+
* explicit one. Returns the global `defaultStore` if set, otherwise
|
|
72
|
+
* `undefined`. Consumers decide whether `undefined` is fatal (semantic
|
|
73
|
+
* cache: yes, throws) or a no-op (snapshot persistence: yes, just
|
|
74
|
+
* skips).
|
|
75
|
+
*/
|
|
76
|
+
declare function resolveDefaultStore(): CacheDriver<any, any> | undefined;
|
|
77
|
+
//#endregion
|
|
78
|
+
export { AIConfig, getAIConfig, resolveDefaultStore, setAIConfig };
|
|
79
|
+
//# sourceMappingURL=config.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.mts","names":[],"sources":["../../../../../@warlock.js/ai/src/config.ts"],"mappings":";;;;;AAuBA;;;;AAoB4B;AAoB5B;;;;;;;;;;;;;AAAiE;KAxCrD,QAAA;EAkDe;;;AAAY;AAWvC;;;;AAAkD;;;;;;;;;;;EAzChD,YAAA,GAAe,WAAW;AAAA;;;;;;;;;;;;;;;;iBAoBZ,WAAA,CAAY,OAAA,EAAS,OAAA,CAAQ,QAAA,IAAY,QAAA;;;;;;iBAUzC,WAAA,CAAA,GAAe,QAAQ;;;;;;;;iBAWvB,mBAAA,CAAA,GAAuB,WAAW"}
|
package/esm/config.mjs
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
//#region ../../@warlock.js/ai/src/config.ts
|
|
2
|
+
const aiConfig = {};
|
|
3
|
+
/**
|
|
4
|
+
* Set or extend process-wide AI configuration. Merges over existing
|
|
5
|
+
* values — fields not present in `partial` keep whatever was set
|
|
6
|
+
* before (or stay unset). Call once at app boot, before constructing
|
|
7
|
+
* any agent / supervisor / middleware that should pick up the
|
|
8
|
+
* defaults.
|
|
9
|
+
*
|
|
10
|
+
* Returns the merged config so callers can verify what landed.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* import { cache } from "@warlock.js/cache";
|
|
14
|
+
* import { ai } from "@warlock.js/ai";
|
|
15
|
+
*
|
|
16
|
+
* ai.config({ defaultStore: cache.driver("redis", { client }) });
|
|
17
|
+
*/
|
|
18
|
+
function setAIConfig(partial) {
|
|
19
|
+
Object.assign(aiConfig, partial);
|
|
20
|
+
return { ...aiConfig };
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Read the current AI config snapshot. Returns a shallow copy so
|
|
24
|
+
* callers can't accidentally mutate the source of truth. Used
|
|
25
|
+
* internally by consumers to resolve their `defaultStore` fallback.
|
|
26
|
+
*/
|
|
27
|
+
function getAIConfig() {
|
|
28
|
+
return { ...aiConfig };
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Resolve the effective store for a consumer that didn't receive an
|
|
32
|
+
* explicit one. Returns the global `defaultStore` if set, otherwise
|
|
33
|
+
* `undefined`. Consumers decide whether `undefined` is fatal (semantic
|
|
34
|
+
* cache: yes, throws) or a no-op (snapshot persistence: yes, just
|
|
35
|
+
* skips).
|
|
36
|
+
*/
|
|
37
|
+
function resolveDefaultStore() {
|
|
38
|
+
return aiConfig.defaultStore;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
//#endregion
|
|
42
|
+
export { getAIConfig, resolveDefaultStore, setAIConfig };
|
|
43
|
+
//# sourceMappingURL=config.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.mjs","names":[],"sources":["../../../../../@warlock.js/ai/src/config.ts"],"sourcesContent":["import type { CacheDriver } from \"@warlock.js/cache\";\n\n/**\n * Process-wide `@warlock.js/ai` configuration. **Intentionally tiny.**\n * Lives here only for genuinely cross-cutting defaults that would\n * otherwise force users to wire the same value into every consumer.\n *\n * **What lives here.** A field earns a slot only when it satisfies\n * all three:\n * 1. Multiple unrelated consumers need the same value.\n * 2. The value is infrastructure (drivers, clients, pools), not\n * behavior (kill-switches, mode flags).\n * 3. Per-call override doesn't make sense for the use case.\n *\n * **What does NOT live here.** Logger config (use\n * `@warlock.js/logger` directly). Per-primitive feature flags\n * (live on the relevant config type). Anything that's really one\n * consumer's concern (lives on that consumer).\n *\n * Phase 3.2 deliberately removed the previous `configureAI()` bag\n * because it was growing unbounded. Treat new fields here with the\n * same suspicion.\n */\nexport type AIConfig = {\n /**\n * Default store used by every consumer that supports persistence\n * but didn't supply its own `store` / `snapshotStore`. Most\n * realistic deployments back resume snapshots, semantic cache, and\n * future memory primitives with the same driver — declaring it\n * once here removes the repetition.\n *\n * Per-declaration overrides (`SupervisorConfig.snapshotStore`,\n * `semanticCache({ store })`) win when supplied. Set this once at\n * app boot, *after* you've constructed your driver.\n *\n * @example\n * import { cache } from \"@warlock.js/cache\";\n * import { ai } from \"@warlock.js/ai\";\n *\n * ai.config({\n * defaultStore: cache.driver(\"redis\", { client: redisClient }),\n * });\n */\n defaultStore?: CacheDriver<any, any>;\n};\n\nconst aiConfig: AIConfig = {};\n\n/**\n * Set or extend process-wide AI configuration. Merges over existing\n * values — fields not present in `partial` keep whatever was set\n * before (or stay unset). Call once at app boot, before constructing\n * any agent / supervisor / middleware that should pick up the\n * defaults.\n *\n * Returns the merged config so callers can verify what landed.\n *\n * @example\n * import { cache } from \"@warlock.js/cache\";\n * import { ai } from \"@warlock.js/ai\";\n *\n * ai.config({ defaultStore: cache.driver(\"redis\", { client }) });\n */\nexport function setAIConfig(partial: Partial<AIConfig>): AIConfig {\n Object.assign(aiConfig, partial);\n return { ...aiConfig };\n}\n\n/**\n * Read the current AI config snapshot. Returns a shallow copy so\n * callers can't accidentally mutate the source of truth. Used\n * internally by consumers to resolve their `defaultStore` fallback.\n */\nexport function getAIConfig(): AIConfig {\n return { ...aiConfig };\n}\n\n/**\n * Resolve the effective store for a consumer that didn't receive an\n * explicit one. Returns the global `defaultStore` if set, otherwise\n * `undefined`. Consumers decide whether `undefined` is fatal (semantic\n * cache: yes, throws) or a no-op (snapshot persistence: yes, just\n * skips).\n */\nexport function resolveDefaultStore(): CacheDriver<any, any> | undefined {\n return aiConfig.defaultStore;\n}\n"],"mappings":";AA8CA,MAAM,WAAqB,CAAC;;;;;;;;;;;;;;;;AAiB5B,SAAgB,YAAY,SAAsC;CAChE,OAAO,OAAO,UAAU,OAAO;CAC/B,OAAO,EAAE,GAAG,SAAS;AACvB;;;;;;AAOA,SAAgB,cAAwB;CACtC,OAAO,EAAE,GAAG,SAAS;AACvB;;;;;;;;AASA,SAAgB,sBAAyD;CACvE,OAAO,SAAS;AAClB"}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { Attachment } from "../attachment.type.mjs";
|
|
2
|
+
import { Message } from "../conversation-message.type.mjs";
|
|
3
|
+
import { ToolContext } from "../tool.contract.mjs";
|
|
4
|
+
import { Placeholders } from "../placeholders.type.mjs";
|
|
5
|
+
import { SystemPromptContract } from "../system-prompt.contract.mjs";
|
|
6
|
+
import { AgentEventMap } from "../events/event-map.type.mjs";
|
|
7
|
+
import { StreamingToolGuardConfig } from "../streaming-tool-guard-config.type.mjs";
|
|
8
|
+
import { StandardSchemaV1 } from "@standard-schema/spec";
|
|
9
|
+
|
|
10
|
+
//#region ../../@warlock.js/ai/src/contracts/agent/agent-options.type.d.ts
|
|
11
|
+
/**
|
|
12
|
+
* Options passed to AgentContract.execute() to configure a single execution run.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* const result = await agent.execute("Analyze this document", {
|
|
16
|
+
* history: previousMessages,
|
|
17
|
+
* attachments: ["/path/to/doc.pdf"],
|
|
18
|
+
* placeholders: { language: "English" },
|
|
19
|
+
* output: z.object({ summary: z.string(), keyPoints: z.array(z.string()) }),
|
|
20
|
+
* on: {
|
|
21
|
+
* streaming: ({ delta }) => process.stdout.write(delta),
|
|
22
|
+
* completed: ({ result }) => console.log("Done"),
|
|
23
|
+
* },
|
|
24
|
+
* });
|
|
25
|
+
*/
|
|
26
|
+
type AgentExecuteOptions<TOutput = unknown> = {
|
|
27
|
+
/** Prior conversation messages to prepend as context */history?: Message[]; /** Files or URLs to attach to the message */
|
|
28
|
+
attachments?: Attachment[]; /** Values to inject into {{mustache}} placeholders in prompts */
|
|
29
|
+
placeholders?: Placeholders;
|
|
30
|
+
/**
|
|
31
|
+
* Standard Schema for structured output extraction.
|
|
32
|
+
* When provided, the agent will attempt to return typed data in result.data.
|
|
33
|
+
*/
|
|
34
|
+
output?: StandardSchemaV1<TOutput>;
|
|
35
|
+
/**
|
|
36
|
+
* Hand-crafted JSON Schema used to drive native structured-output mode
|
|
37
|
+
* (OpenAI `response_format: json_schema`, etc.) and to embed in the
|
|
38
|
+
* soft system-prompt instruction.
|
|
39
|
+
*
|
|
40
|
+
* Primary use case: libraries whose JSON Schema output isn't
|
|
41
|
+
* automatically extractable by `extractJsonSchema` — notably Zod,
|
|
42
|
+
* which ships `z.toJSONSchema` as a top-level module function rather
|
|
43
|
+
* than a property on the schema. Pass the converter's output here and
|
|
44
|
+
* the agent will use it verbatim, skipping extraction.
|
|
45
|
+
*
|
|
46
|
+
* When both `output` and `responseSchema` are set, `responseSchema`
|
|
47
|
+
* wins — `output` still runs for client-side validation into
|
|
48
|
+
* `result.data`, but the wire-level schema sent to the model is
|
|
49
|
+
* whatever was passed here.
|
|
50
|
+
*
|
|
51
|
+
* @example
|
|
52
|
+
* import { z, toJSONSchema } from "zod";
|
|
53
|
+
* const schema = z.object({ summary: z.string() });
|
|
54
|
+
* await agent.execute(input, {
|
|
55
|
+
* output: schema,
|
|
56
|
+
* responseSchema: toJSONSchema(schema),
|
|
57
|
+
* });
|
|
58
|
+
*/
|
|
59
|
+
responseSchema?: Record<string, unknown>;
|
|
60
|
+
/**
|
|
61
|
+
* Opt-in self-repair when the model's response fails to parse or
|
|
62
|
+
* validate against `output`. When enabled, the agent appends the bad
|
|
63
|
+
* assistant message plus a corrective user message to the conversation
|
|
64
|
+
* and re-invokes the model up to `maxAttempts` times, re-parsing on
|
|
65
|
+
* each attempt. Disabled by default — schema failures normally surface
|
|
66
|
+
* a real prompt/model issue worth seeing rather than silently retrying.
|
|
67
|
+
*
|
|
68
|
+
* Each repair attempt counts as a normal trip and is bounded by the
|
|
69
|
+
* agent's `maxTrips` cap (belt-and-suspenders against runaway loops).
|
|
70
|
+
*
|
|
71
|
+
* Only active when `output` (or `responseSchema`) is set; ignored
|
|
72
|
+
* otherwise.
|
|
73
|
+
*
|
|
74
|
+
* @example
|
|
75
|
+
* await agent.execute(input, {
|
|
76
|
+
* output: schema,
|
|
77
|
+
* repair: { maxAttempts: 1 },
|
|
78
|
+
* });
|
|
79
|
+
*/
|
|
80
|
+
repair?: {
|
|
81
|
+
/** Max number of re-ask attempts after the initial failure. Default 1. */maxAttempts?: number;
|
|
82
|
+
}; /** Override the agent's system prompt for this execution */
|
|
83
|
+
systemPrompt?: SystemPromptContract;
|
|
84
|
+
/**
|
|
85
|
+
* Cancellation handle. When `signal.aborted` becomes true the agent
|
|
86
|
+
* short-circuits at the next trip boundary and returns with
|
|
87
|
+
* `report.status = "cancelled"` + `result.error` set to an
|
|
88
|
+
* `AgentExecutionError` carrying the abort reason. Mid-trip abort
|
|
89
|
+
* is best-effort — it relies on the underlying provider adapter
|
|
90
|
+
* threading `signal` into its HTTP client. The workflow engine
|
|
91
|
+
* passes its own signal through automatically when a step has an
|
|
92
|
+
* `agent`.
|
|
93
|
+
*/
|
|
94
|
+
signal?: AbortSignal; /** Event handlers for observing execution progress */
|
|
95
|
+
on?: Partial<{ [K in keyof AgentEventMap]: (payload: AgentEventMap[K]) => void }>;
|
|
96
|
+
/**
|
|
97
|
+
* Tool context threaded into every `tool.invoke()` call this agent
|
|
98
|
+
* runs (Phase 5 / decisions §35). Tools mutate `ctx.artifacts` to
|
|
99
|
+
* contribute system-only side data; the supervisor that supplied
|
|
100
|
+
* the ctx merges that bag into state at iteration end.
|
|
101
|
+
*
|
|
102
|
+
* Typically set by the supervisor's dispatch loop, not by user
|
|
103
|
+
* code. Standalone callers may omit it — the framework supplies a
|
|
104
|
+
* degraded `{ artifacts: {} }` so single-arg legacy tools keep
|
|
105
|
+
* working unchanged.
|
|
106
|
+
*/
|
|
107
|
+
toolCtx?: ToolContext;
|
|
108
|
+
/**
|
|
109
|
+
* Per-call override for the stream-time tool-call guard. Wins over
|
|
110
|
+
* `AgentConfig.streamingToolGuard` when set. Pass `undefined` to
|
|
111
|
+
* disable for a single call when the agent-level config has the
|
|
112
|
+
* guard enabled (e.g. a one-off "give me a raw JSON config" call
|
|
113
|
+
* where the buffering delay isn't worth it).
|
|
114
|
+
*/
|
|
115
|
+
streamingToolGuard?: StreamingToolGuardConfig;
|
|
116
|
+
/**
|
|
117
|
+
* Opaque caller-supplied identifier that groups multiple `execute()`
|
|
118
|
+
* calls into one conceptual user session / request. Mirrored onto
|
|
119
|
+
* every report node this run produces (and every nested executable
|
|
120
|
+
* it invokes via `asTool` wrappers) so flat queries like "total
|
|
121
|
+
* spend for user X this morning" don't need to walk the tree.
|
|
122
|
+
*
|
|
123
|
+
* Auto-propagated to composite primitives — an inner supervisor
|
|
124
|
+
* dispatched via `asTool` inherits the outer agent's `sessionId`.
|
|
125
|
+
* Execution state (artifacts, snapshots) stays isolated; only the
|
|
126
|
+
* observability identity is shared.
|
|
127
|
+
*/
|
|
128
|
+
sessionId?: string;
|
|
129
|
+
};
|
|
130
|
+
//#endregion
|
|
131
|
+
export { AgentExecuteOptions };
|
|
132
|
+
//# sourceMappingURL=agent-options.type.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-options.type.d.mts","names":[],"sources":["../../../../../../../@warlock.js/ai/src/contracts/agent/agent-options.type.ts"],"mappings":";;;;;;;;;;;;AAwBA;;;;;;;;;;;;;KAAY,mBAAA;EA2EL,wDAzEL,OAAA,GAAU,OAAA,IA+FW;EA7FrB,WAAA,GAAc,UAAA,IA6F+B;EA3F7C,YAAA,GAAe,YAAA;EAJf;;;;EASA,MAAA,GAAS,gBAAA,CAAiB,OAAA;EALX;;;;;;;;;;;;;;;;;;;;;;;;EA8Bf,cAAA,GAAiB,MAAA;EA0ER;;;;;;;;;;;;;;;;;;;;EArDT,MAAA;8EAEE,WAAA;EAAA;EAGF,YAAA,GAAe,oBAAA;;;;;;;;;;;EAWf,MAAA,GAAS,WAAA;EAET,EAAA,GAAK,OAAA,eACS,aAAA,IAAiB,OAAA,EAAS,aAAA,CAAc,CAAA;;;;;;;;;;;;EAatD,OAAA,GAAU,WAAA;;;;;;;;EAQV,kBAAA,GAAqB,wBAAA;;;;;;;;;;;;;EAarB,SAAA;AAAA"}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { AgentResult } from "../result/agent-result.type.mjs";
|
|
2
|
+
import { ExecutableContract } from "../executable.contract.mjs";
|
|
3
|
+
import { StreamContract } from "../stream/stream.contract.mjs";
|
|
4
|
+
import { AgentEventMap } from "../events/event-map.type.mjs";
|
|
5
|
+
import { AgentExecuteOptions } from "./agent-options.type.mjs";
|
|
6
|
+
|
|
7
|
+
//#region ../../@warlock.js/ai/src/contracts/agent/agent.contract.d.ts
|
|
8
|
+
/**
|
|
9
|
+
* Handler function for a single agent event. Takes the event's typed
|
|
10
|
+
* payload; return value is ignored.
|
|
11
|
+
*/
|
|
12
|
+
type AgentEventHandler<K extends keyof AgentEventMap> = (payload: AgentEventMap[K]) => void;
|
|
13
|
+
/**
|
|
14
|
+
* Contract for an AI agent — the core executable primitive.
|
|
15
|
+
*
|
|
16
|
+
* Supports a 3-tier event subscription model. All three layers fire in
|
|
17
|
+
* order on every event: **factory → instance → per-call**. A listener
|
|
18
|
+
* at any level can inspect the same event without the others needing
|
|
19
|
+
* to know.
|
|
20
|
+
*
|
|
21
|
+
* - **Factory-level** — `ai.agent({ on: {...} })`. Fires on every run.
|
|
22
|
+
* - **Instance-level** — `agent.on(event, handler)` / `agent.off(...)`.
|
|
23
|
+
* Imperative additions that persist across every `execute()`/`stream()`
|
|
24
|
+
* call on this instance. `on()` returns an unsubscribe function.
|
|
25
|
+
* - **Per-call** — `agent.execute(input, { on: {...} })` or
|
|
26
|
+
* `agent.stream(input, { on: {...} })`. Scoped to that one run.
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* const myAgent = ai.agent({
|
|
30
|
+
* model,
|
|
31
|
+
* on: { "agent.starting": () => metrics.inc("agent.runs") },
|
|
32
|
+
* });
|
|
33
|
+
*
|
|
34
|
+
* const unsubscribe = myAgent.on("agent.error", ({ error }) => logger.error(error));
|
|
35
|
+
*
|
|
36
|
+
* const result = await myAgent.execute("Summarize this", {
|
|
37
|
+
* output: z.object({ summary: z.string() }),
|
|
38
|
+
* on: { "agent.trip.completed": ({ trip }) => console.log(trip.duration) },
|
|
39
|
+
* });
|
|
40
|
+
*
|
|
41
|
+
* unsubscribe();
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* // Stream tokens as they arrive
|
|
45
|
+
* const stream = myAgent.stream("Write a poem");
|
|
46
|
+
* for await (const event of stream) {
|
|
47
|
+
* if (event.type === "agent.trip.streaming") process.stdout.write(event.delta);
|
|
48
|
+
* }
|
|
49
|
+
* const result = await stream.result;
|
|
50
|
+
*/
|
|
51
|
+
interface AgentContract<TOutput = unknown> extends ExecutableContract<string, AgentExecuteOptions<TOutput>, AgentResult<TOutput>> {
|
|
52
|
+
/**
|
|
53
|
+
* Stable identifier for this agent. Always populated — if the
|
|
54
|
+
* factory caller omitted `name`, a deterministic
|
|
55
|
+
* `anon_<provider>_<model>[_<tool>+...]` fingerprint is synthesized
|
|
56
|
+
* (same config → same name across restarts). Consumers that require
|
|
57
|
+
* a *meaningful* name (workflow step, tool wrapper) should
|
|
58
|
+
* additionally check `isAnonymous`.
|
|
59
|
+
*/
|
|
60
|
+
readonly name: string;
|
|
61
|
+
/**
|
|
62
|
+
* `true` when the agent was constructed without an explicit name.
|
|
63
|
+
* Workflow / tool boundaries reject anonymous agents at author time
|
|
64
|
+
* so signature drift detection and tool routing stay honest.
|
|
65
|
+
*/
|
|
66
|
+
readonly isAnonymous: boolean;
|
|
67
|
+
/**
|
|
68
|
+
* Optional short summary — surfaced to supervisor router prompts and
|
|
69
|
+
* to `asTool()` wrappers. Mirrors whatever was set on
|
|
70
|
+
* `AgentConfig.description` at factory time.
|
|
71
|
+
*/
|
|
72
|
+
readonly description?: string;
|
|
73
|
+
/**
|
|
74
|
+
* Stream execution events in real time.
|
|
75
|
+
* Yields typed StreamEvent values and resolves result when done.
|
|
76
|
+
*/
|
|
77
|
+
stream(input: string, options?: AgentExecuteOptions<TOutput>): StreamContract<AgentResult<TOutput>>;
|
|
78
|
+
/**
|
|
79
|
+
* Subscribe a handler to a single event name for the lifetime of
|
|
80
|
+
* this agent instance. Returns an unsubscribe function; calling it
|
|
81
|
+
* is equivalent to `off(event, handler)`.
|
|
82
|
+
*/
|
|
83
|
+
on<K extends keyof AgentEventMap>(event: K, handler: AgentEventHandler<K>): () => void;
|
|
84
|
+
/**
|
|
85
|
+
* Remove a previously-subscribed handler. No-op when the handler was
|
|
86
|
+
* never registered or was already removed.
|
|
87
|
+
*/
|
|
88
|
+
off<K extends keyof AgentEventMap>(event: K, handler: AgentEventHandler<K>): void;
|
|
89
|
+
}
|
|
90
|
+
//#endregion
|
|
91
|
+
export { AgentContract, AgentEventHandler };
|
|
92
|
+
//# sourceMappingURL=agent.contract.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent.contract.d.mts","names":[],"sources":["../../../../../../../@warlock.js/ai/src/contracts/agent/agent.contract.ts"],"mappings":";;;;;;;;;AAUA;;KAAY,iBAAA,iBAAkC,aAAA,KAC5C,OAAA,EAAS,aAAA,CAAc,CAAA;;;;;;;;;;;;AAAE;AAyC3B;;;;;;;;;;;;;;;;;;;;;;;;;;UAAiB,aAAA,4BAAyC,kBAAA,SAExD,mBAAA,CAAoB,OAAA,GACpB,WAAA,CAAY,OAAA;EAAZ;;;;;;;;EAAA,SAUS,IAAA;EAmBP;;;;;EAAA,SAbO,WAAA;EAqBU;;;;;EAAA,SAfV,WAAA;EAwBT;;;;EAnBA,MAAA,CACE,KAAA,UACA,OAAA,GAAU,mBAAA,CAAoB,OAAA,IAC7B,cAAA,CAAe,WAAA,CAAY,OAAA;EAkBnB;;;;AAAoB;EAX/B,EAAA,iBAAmB,aAAA,EACjB,KAAA,EAAO,CAAA,EACP,OAAA,EAAS,iBAAA,CAAkB,CAAA;;;;;EAO7B,GAAA,iBAAoB,aAAA,EAClB,KAAA,EAAO,CAAA,EACP,OAAA,EAAS,iBAAA,CAAkB,CAAA;AAAA"}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
//#region ../../@warlock.js/ai/src/contracts/attachment.type.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Shape of a StorageFile object from @warlock.js/core.
|
|
4
|
+
* Used to detect storage files in the Attachment union.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* const file: StorageFileShape = {
|
|
8
|
+
* url: "https://cdn.example.com/uploads/doc.pdf",
|
|
9
|
+
* absolutePath: "/var/www/uploads/doc.pdf",
|
|
10
|
+
* };
|
|
11
|
+
*/
|
|
12
|
+
type StorageFileShape = {
|
|
13
|
+
/** Public URL of the file */url?: string; /** Absolute filesystem path to the file */
|
|
14
|
+
absolutePath?: string;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Where the bytes of an attachment originate. The agent's
|
|
18
|
+
* `prepareAttachmentPart` collapses every variant into a `ContentPart`
|
|
19
|
+
* the model adapter can consume.
|
|
20
|
+
*
|
|
21
|
+
* - `string` — local file path or remote URL (auto-detected via the
|
|
22
|
+
* `https?://` prefix).
|
|
23
|
+
* - `StorageFileShape` — a `@warlock.js/core` storage file; URL wins
|
|
24
|
+
* over path when both are present.
|
|
25
|
+
* - `{ base64, mediaType }` — raw inline bytes with an explicit IANA
|
|
26
|
+
* media type, useful for in-memory data that never touched disk.
|
|
27
|
+
*/
|
|
28
|
+
type AttachmentSource = string | StorageFileShape | {
|
|
29
|
+
base64: string;
|
|
30
|
+
mediaType: string;
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* An attachment that can be passed to an agent execution.
|
|
34
|
+
*
|
|
35
|
+
* Two forms:
|
|
36
|
+
*
|
|
37
|
+
* - **Tagged form** (preferred for non-image types and for explicit
|
|
38
|
+
* intent): `{ type: "image" | "text", source }`.
|
|
39
|
+
* - **Shorthand string / StorageFileShape**: the agent infers the
|
|
40
|
+
* media kind from the file extension. Recognized image extensions:
|
|
41
|
+
* `.png`, `.jpg`, `.jpeg`, `.webp`, `.gif`. Recognized text
|
|
42
|
+
* extension: `.txt`. Anything else throws — silent inference for
|
|
43
|
+
* ambiguous inputs causes silent bugs.
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* // Shorthand — extension-inferred image
|
|
47
|
+
* agent.execute("What's in this?", { attachments: ["./photo.png"] });
|
|
48
|
+
*
|
|
49
|
+
* @example
|
|
50
|
+
* // Tagged form — explicit kind
|
|
51
|
+
* agent.execute("Compare", {
|
|
52
|
+
* attachments: [
|
|
53
|
+
* { type: "image", source: "https://cdn.example.com/a.jpg" },
|
|
54
|
+
* { type: "image", source: { base64: "iVBOR...", mediaType: "image/png" } },
|
|
55
|
+
* ],
|
|
56
|
+
* });
|
|
57
|
+
*
|
|
58
|
+
* @example
|
|
59
|
+
* // Text attachment — contents are read and injected as extra text
|
|
60
|
+
* agent.execute("Summarize", { attachments: [{ type: "text", source: "./notes.txt" }] });
|
|
61
|
+
*
|
|
62
|
+
* @example
|
|
63
|
+
* // StorageFileShape from @warlock.js/core (extension-inferred)
|
|
64
|
+
* agent.execute("Describe", { attachments: [storageFile] });
|
|
65
|
+
*/
|
|
66
|
+
type Attachment = string | StorageFileShape | {
|
|
67
|
+
type: "image";
|
|
68
|
+
source: AttachmentSource;
|
|
69
|
+
} | {
|
|
70
|
+
type: "text";
|
|
71
|
+
source: AttachmentSource;
|
|
72
|
+
};
|
|
73
|
+
/**
|
|
74
|
+
* A normalized attachment after source resolution — a tagged value the
|
|
75
|
+
* agent can hand to file-reading code without re-discriminating the
|
|
76
|
+
* input variant.
|
|
77
|
+
*
|
|
78
|
+
* @example
|
|
79
|
+
* const resolved: ResolvedAttachment = { type: "url", value: "https://..." };
|
|
80
|
+
* const resolved2: ResolvedAttachment = { type: "path", value: "/tmp/doc.pdf" };
|
|
81
|
+
* const resolved3: ResolvedAttachment = {
|
|
82
|
+
* type: "base64",
|
|
83
|
+
* value: "iVBORw0...",
|
|
84
|
+
* mediaType: "image/png",
|
|
85
|
+
* };
|
|
86
|
+
*/
|
|
87
|
+
type ResolvedAttachment = {
|
|
88
|
+
type: "url";
|
|
89
|
+
value: string;
|
|
90
|
+
} | {
|
|
91
|
+
type: "path";
|
|
92
|
+
value: string;
|
|
93
|
+
} | {
|
|
94
|
+
type: "base64";
|
|
95
|
+
value: string;
|
|
96
|
+
mediaType: string;
|
|
97
|
+
};
|
|
98
|
+
//#endregion
|
|
99
|
+
export { Attachment, AttachmentSource, ResolvedAttachment, StorageFileShape };
|
|
100
|
+
//# sourceMappingURL=attachment.type.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"attachment.type.d.mts","names":[],"sources":["../../../../../../@warlock.js/ai/src/contracts/attachment.type.ts"],"mappings":";;AAUA;;;;AAIc;AAed;;;;KAnBY,gBAAA;EAsBN,6BApBJ,GAAA,WAoB6B;EAlB7B,YAAY;AAAA;;;;;;;;;;;;;KAeF,gBAAA,YAER,gBAAgB;EACd,MAAA;EAAgB,SAAA;AAAA;AAwDtB;;;;;;;;;;;;AAG8C;;;;;;;;;;;;;;;;;;;;;;AAH9C,KApBY,UAAA,YAER,gBAAA;EACE,IAAA;EAAe,MAAA,EAAQ,gBAAA;AAAA;EACvB,IAAA;EAAc,MAAA,EAAQ,gBAAA;AAAA;;;;;;;;;;;;;;;KAgBhB,kBAAA;EACN,IAAA;EAAa,KAAA;AAAA;EACb,IAAA;EAAc,KAAA;AAAA;EACd,IAAA;EAAgB,KAAA;EAAe,SAAA;AAAA"}
|