@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,26 @@
|
|
|
1
|
+
import { AIError } from "../../errors/ai-error.mjs";
|
|
2
|
+
import { Usage } from "./usage.type.mjs";
|
|
3
|
+
|
|
4
|
+
//#region ../../@warlock.js/ai/src/contracts/result/base-result.type.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* Minimal shape every execution result satisfies. Used as the upper
|
|
7
|
+
* bound on `ExecutableContract`'s `TResult` generic so the contract
|
|
8
|
+
* can promise the fields every caller needs regardless of which
|
|
9
|
+
* primitive ran.
|
|
10
|
+
*
|
|
11
|
+
* Timing metadata now lives on each primitive's `report` field (see
|
|
12
|
+
* `ExecutionReport`); `duration` was removed from this base to avoid
|
|
13
|
+
* two sources of truth.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* function summarize(result: BaseResult) {
|
|
17
|
+
* console.log(`${result.usage.total} tokens, ${result.error ? "failed" : "ok"}`);
|
|
18
|
+
* }
|
|
19
|
+
*/
|
|
20
|
+
type BaseResult = {
|
|
21
|
+
/** Typed AI error if the execution failed, undefined on success. */error?: AIError; /** Aggregated token usage across the execution. */
|
|
22
|
+
usage: Usage;
|
|
23
|
+
};
|
|
24
|
+
//#endregion
|
|
25
|
+
export { BaseResult };
|
|
26
|
+
//# sourceMappingURL=base-result.type.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base-result.type.d.mts","names":[],"sources":["../../../../../../../@warlock.js/ai/src/contracts/result/base-result.type.ts"],"mappings":";;;;;;AAkBA;;;;;;;;;AAIc;;;;KAJF,UAAA;sEAEV,KAAA,GAAQ,OAAA;EAER,KAAA,EAAO,KAAK;AAAA"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { AIError } from "../../errors/ai-error.mjs";
|
|
2
|
+
import { Usage } from "./usage.type.mjs";
|
|
3
|
+
import { BaseReport } from "./base-report.type.mjs";
|
|
4
|
+
|
|
5
|
+
//#region ../../@warlock.js/ai/src/contracts/result/execute-result.type.d.ts
|
|
6
|
+
/**
|
|
7
|
+
* Unified result envelope returned by every executable primitive —
|
|
8
|
+
* `tool.invoke()`, `agent.execute()`, `workflow.execute()`,
|
|
9
|
+
* `supervisor.execute()`. Per-primitive result types
|
|
10
|
+
* (`AgentResult`, `WorkflowResult`, `SupervisorResult`,
|
|
11
|
+
* `ToolInvokeResult`) all satisfy this shape and add their own
|
|
12
|
+
* discriminator / domain-specific fields.
|
|
13
|
+
*
|
|
14
|
+
* `usage` and `report` are **required** on every invocation, including
|
|
15
|
+
* leaf tools — the framework synthesizes a trivial report for tools
|
|
16
|
+
* (type `"tool"`, empty children, zero usage, real timing) so
|
|
17
|
+
* consumers never have to nil-check the presence of a report.
|
|
18
|
+
*
|
|
19
|
+
* Recursion happens inside `report.children[]` — parent walks the
|
|
20
|
+
* report tree top-down to see every child executable that ran.
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* const { data, usage, report, error } = await executable.execute(input);
|
|
24
|
+
*
|
|
25
|
+
* if (error) {
|
|
26
|
+
* logger.error(error.code, { runId: report.runId, duration: report.duration });
|
|
27
|
+
* return;
|
|
28
|
+
* }
|
|
29
|
+
*
|
|
30
|
+
* console.log(`spent ${usage.total} tokens across ${report.children.length} children`);
|
|
31
|
+
*/
|
|
32
|
+
type ExecuteResult<TData = unknown> = {
|
|
33
|
+
/** Typed output if the execution succeeded. */data?: TData; /** Typed AI error if the execution failed, undefined on success. */
|
|
34
|
+
error?: AIError; /** Rolled-up usage (own + sum of children). Always present. */
|
|
35
|
+
usage: Usage; /** Recursive execution report — `report.children[]` carries nested executables. */
|
|
36
|
+
report: BaseReport;
|
|
37
|
+
};
|
|
38
|
+
//#endregion
|
|
39
|
+
export { ExecuteResult };
|
|
40
|
+
//# sourceMappingURL=execute-result.type.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"execute-result.type.d.mts","names":[],"sources":["../../../../../../../@warlock.js/ai/src/contracts/result/execute-result.type.ts"],"mappings":";;;;;;;AA8BA;;;;;;;;;;;;;;;;;;;AAQoB;;;;;KARR,aAAA;iDAEV,IAAA,GAAO,KAAA;EAEP,KAAA,GAAQ,OAAA;EAER,KAAA,EAAO,KAAA;EAEP,MAAA,EAAQ,UAAA;AAAA"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { BaseReport, ReportStatus } from "./base-report.type.mjs";
|
|
2
|
+
import { LLMTrip } from "./llm-trip.type.mjs";
|
|
3
|
+
|
|
4
|
+
//#region ../../@warlock.js/ai/src/contracts/result/execution-report.type.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* Terminal status alias retained for backwards-compatibility with
|
|
7
|
+
* existing imports. Use {@link ReportStatus} directly for new code —
|
|
8
|
+
* both point at the same unified union across every primitive.
|
|
9
|
+
*/
|
|
10
|
+
type ExecutionStatus = ReportStatus;
|
|
11
|
+
/**
|
|
12
|
+
* Alias kept for callers referencing the pre-3.1 shared timing block.
|
|
13
|
+
* Structurally a {@link BaseReport} — use that for new code.
|
|
14
|
+
*/
|
|
15
|
+
type ExecutionReport = BaseReport;
|
|
16
|
+
/**
|
|
17
|
+
* Agent-specific execution report — {@link BaseReport} plus the LLM
|
|
18
|
+
* trip history for a single `agent.execute()` call.
|
|
19
|
+
*
|
|
20
|
+
* Tool dispatches that previously lived under `toolCalls[]` are now
|
|
21
|
+
* reported as child `BaseReport` nodes on
|
|
22
|
+
* {@link BaseReport.children} — filter by `type === "tool"` to isolate
|
|
23
|
+
* leaf tool calls, or walk the full tree to see every nested
|
|
24
|
+
* executable. Trips stay here because they describe the agent's
|
|
25
|
+
* **internal** turn structure (LLM round-trips), not child executions.
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* const { report } = await agent.execute("hi");
|
|
29
|
+
* console.log(report.status, report.duration, report.trips.length);
|
|
30
|
+
*
|
|
31
|
+
* const toolCalls = report.children.filter((c) => c.type === "tool");
|
|
32
|
+
* const nestedAgents = report.children.filter((c) => c.type === "agent");
|
|
33
|
+
*/
|
|
34
|
+
type AgentReport = BaseReport & {
|
|
35
|
+
/**
|
|
36
|
+
* Identity of the model the agent ran against. Captured from the
|
|
37
|
+
* `ModelContract` at result-build time so consumers can attribute
|
|
38
|
+
* cost, latency, and behavior to the right upstream — especially
|
|
39
|
+
* useful when the same provider package fronts multiple labels
|
|
40
|
+
* (e.g. `openai` vs `openrouter` vs `azure` via the OpenAI adapter).
|
|
41
|
+
*/
|
|
42
|
+
model: {
|
|
43
|
+
name: string;
|
|
44
|
+
provider: string;
|
|
45
|
+
}; /** Every LLM round-trip that happened during execution. */
|
|
46
|
+
trips: LLMTrip[];
|
|
47
|
+
};
|
|
48
|
+
//#endregion
|
|
49
|
+
export { AgentReport, ExecutionReport, ExecutionStatus };
|
|
50
|
+
//# sourceMappingURL=execution-report.type.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"execution-report.type.d.mts","names":[],"sources":["../../../../../../../@warlock.js/ai/src/contracts/result/execution-report.type.ts"],"mappings":";;;;;;AAQA;;;KAAY,eAAA,GAAkB,YAAY;AAAA;AAM1C;;;AAN0C,KAM9B,eAAA,GAAkB,UAAU;AAAA;AAoBxC;;;;;;;;;;;AAUgB;;;;;;AA9BwB,KAoB5B,WAAA,GAAc,UAAA;;;;;;;;EAQxB,KAAA;IAAS,IAAA;IAAc,QAAA;EAAA;EAEvB,KAAA,EAAO,OAAO;AAAA"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ModelPricing } from "./model-pricing.type.mjs";
|
|
2
|
+
import { Usage } from "./usage.type.mjs";
|
|
3
|
+
import { BaseResult } from "./base-result.type.mjs";
|
|
4
|
+
import { AttemptEntry } from "./attempt-entry.type.mjs";
|
|
5
|
+
import { BaseReport, REPORT_SCHEMA_VERSION, ReportStatus, ReportType } from "./base-report.type.mjs";
|
|
6
|
+
import { ToolCall } from "./tool-call.type.mjs";
|
|
7
|
+
import { LLMTrip } from "./llm-trip.type.mjs";
|
|
8
|
+
import { AgentReport, ExecutionReport, ExecutionStatus } from "./execution-report.type.mjs";
|
|
9
|
+
import { AgentResult } from "./agent-result.type.mjs";
|
|
10
|
+
import { ExecuteResult } from "./execute-result.type.mjs";
|
|
11
|
+
import { StepSnapshot } from "./step-result.type.mjs";
|
|
12
|
+
import { WorkflowReport, WorkflowResult } from "./workflow-result.type.mjs";
|
|
13
|
+
import { SupervisorReport, SupervisorResult, SupervisorTerminatedBy } from "./supervisor-result.type.mjs";
|
|
14
|
+
import { SessionSendResult } from "./session-send-result.type.mjs";
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { AIError } from "../../errors/ai-error.mjs";
|
|
2
|
+
import { Usage } from "./usage.type.mjs";
|
|
3
|
+
import { FinishReason } from "../finish-reason.type.mjs";
|
|
4
|
+
import { ToolCall } from "./tool-call.type.mjs";
|
|
5
|
+
|
|
6
|
+
//#region ../../@warlock.js/ai/src/contracts/result/llm-trip.type.d.ts
|
|
7
|
+
/**
|
|
8
|
+
* A single LLM round-trip within an agent execution.
|
|
9
|
+
* An agent may make multiple trips when tools are called.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* const trip: LLMTrip = {
|
|
13
|
+
* index: 0,
|
|
14
|
+
* input: "Search for the latest AI news",
|
|
15
|
+
* output: "I'll search for that...",
|
|
16
|
+
* finishReason: "tool_calls",
|
|
17
|
+
* duration: 850,
|
|
18
|
+
* usage: { input: 120, output: 45, total: 165 },
|
|
19
|
+
* toolCalls: [{ tripIndex: 0, name: "searchWeb", input: {...}, duration: 300 }],
|
|
20
|
+
* };
|
|
21
|
+
*/
|
|
22
|
+
type LLMTrip = {
|
|
23
|
+
/** 0-indexed position of this trip in the execution sequence */index: number; /** The prompt/input sent to the LLM for this trip */
|
|
24
|
+
input: string; /** The raw text output from the LLM */
|
|
25
|
+
output: string; /** Why the LLM stopped generating */
|
|
26
|
+
finishReason: FinishReason; /** ISO-8601 timestamp when this trip's model call started */
|
|
27
|
+
startedAt: string; /** ISO-8601 timestamp when this trip finished (post tool dispatch) */
|
|
28
|
+
endedAt: string; /** Duration of this trip in milliseconds */
|
|
29
|
+
duration: number; /** Token usage for this trip */
|
|
30
|
+
usage: Usage; /** Tool calls made during this trip, if any */
|
|
31
|
+
toolCalls?: ToolCall[]; /** Typed AI error that occurred during this trip, if any */
|
|
32
|
+
error?: AIError;
|
|
33
|
+
};
|
|
34
|
+
//#endregion
|
|
35
|
+
export { LLMTrip };
|
|
36
|
+
//# sourceMappingURL=llm-trip.type.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"llm-trip.type.d.mts","names":[],"sources":["../../../../../../../@warlock.js/ai/src/contracts/result/llm-trip.type.ts"],"mappings":";;;;;;;;AAoBA;;;;;;;;;;;;;KAAY,OAAA;EAUV,gEARA,KAAA,UAYA;EAVA,KAAA,UAYO;EAVP,MAAA,UAYY;EAVZ,YAAA,EAAc,YAAA,EAYN;EAVR,SAAA,UAUe;EARf,OAAA;EAEA,QAAA;EAEA,KAAA,EAAO,KAAA;EAEP,SAAA,GAAY,QAAA;EAEZ,KAAA,GAAQ,OAAA;AAAA"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
//#region ../../@warlock.js/ai/src/contracts/result/model-pricing.type.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Per-million-token USD pricing for a model. All values are in USD per
|
|
4
|
+
* 1,000,000 tokens — the industry-standard unit. Used by the framework
|
|
5
|
+
* to compute `Usage.costUSD` at emit time, so stored reports carry
|
|
6
|
+
* historical cost (not re-derived against today's pricing).
|
|
7
|
+
*
|
|
8
|
+
* **Optionality.** Every field except `input` / `output` is optional.
|
|
9
|
+
* `cachedInput` / `cachedOutput` are populated only when the provider
|
|
10
|
+
* actually meters them (OpenAI prompt-cache hits, Anthropic cache
|
|
11
|
+
* reads / writes). Leave undefined for adapters that don't report a
|
|
12
|
+
* cache channel — cost falls back to full-rate pricing for those
|
|
13
|
+
* tokens.
|
|
14
|
+
*
|
|
15
|
+
* **Where it lives.** Two declaration sites, both optional:
|
|
16
|
+
*
|
|
17
|
+
* 1. `SDK.pricing` — a registry keyed by model name. One source of
|
|
18
|
+
* truth per provider; matches how providers publish pricing tables.
|
|
19
|
+
* 2. `model({ pricing })` — per-model override at instantiation. Wins
|
|
20
|
+
* over the SDK-level entry. Critical for multi-tenant projects
|
|
21
|
+
* where pricing is contract-specific or runtime-resolved.
|
|
22
|
+
*
|
|
23
|
+
* Resolution order: per-model > SDK registry > undefined (no cost
|
|
24
|
+
* computed).
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* const pricing: ModelPricing = {
|
|
28
|
+
* input: 0.15,
|
|
29
|
+
* output: 0.6,
|
|
30
|
+
* cachedInput: 0.075,
|
|
31
|
+
* };
|
|
32
|
+
*/
|
|
33
|
+
type ModelPricing = {
|
|
34
|
+
/** USD per 1M input tokens. */input: number; /** USD per 1M output tokens. */
|
|
35
|
+
output: number;
|
|
36
|
+
/**
|
|
37
|
+
* USD per 1M input tokens served from the provider's prompt cache.
|
|
38
|
+
* Typically a fraction of `input`. Falls back to `input` when
|
|
39
|
+
* undefined.
|
|
40
|
+
*/
|
|
41
|
+
cachedInput?: number;
|
|
42
|
+
/**
|
|
43
|
+
* USD per 1M tokens written to the provider's prompt cache.
|
|
44
|
+
* Anthropic charges a small premium on cache-write tokens; OpenAI
|
|
45
|
+
* does not. Falls back to `output` when undefined.
|
|
46
|
+
*/
|
|
47
|
+
cachedOutput?: number;
|
|
48
|
+
};
|
|
49
|
+
//#endregion
|
|
50
|
+
export { ModelPricing };
|
|
51
|
+
//# sourceMappingURL=model-pricing.type.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"model-pricing.type.d.mts","names":[],"sources":["../../../../../../../@warlock.js/ai/src/contracts/result/model-pricing.type.ts"],"mappings":";;AA+BA;;;;;;;;;AAgBc;;;;;;;;;;;;;;;;;;;;;KAhBF,YAAA;iCAEV,KAAA;EAEA,MAAA;;;;;;EAMA,WAAA;;;;;;EAMA,YAAA;AAAA"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { AIError } from "../../errors/ai-error.mjs";
|
|
2
|
+
import { Usage } from "./usage.type.mjs";
|
|
3
|
+
import { AgentResult } from "./agent-result.type.mjs";
|
|
4
|
+
import { WorkflowResult } from "./workflow-result.type.mjs";
|
|
5
|
+
import { SupervisorResult } from "./supervisor-result.type.mjs";
|
|
6
|
+
|
|
7
|
+
//#region ../../@warlock.js/ai/src/contracts/result/session-send-result.type.d.ts
|
|
8
|
+
/**
|
|
9
|
+
* Result returned by SessionContract.send().
|
|
10
|
+
* Narrows executionResult by checking the `type` discriminant.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* const result = await session.send("Analyze this dataset");
|
|
14
|
+
* if (result.executionResult.type === "agent") {
|
|
15
|
+
* console.log(result.executionResult.report.trips.length, "trips");
|
|
16
|
+
* } else if (result.executionResult.type === "workflow") {
|
|
17
|
+
* console.log(Object.keys(result.executionResult.steps), "steps ran");
|
|
18
|
+
* }
|
|
19
|
+
*/
|
|
20
|
+
type SessionSendResult = {
|
|
21
|
+
/** Final text response to display to the user */response: string; /** Whether the session is complete (no more turns expected) */
|
|
22
|
+
done: boolean; /** Typed AI error if the session turn failed */
|
|
23
|
+
error?: AIError; /** Full execution result — narrow by `.executionResult.type` */
|
|
24
|
+
executionResult: AgentResult<unknown> | SupervisorResult<unknown> | WorkflowResult<unknown>; /** Aggregated token usage for this turn */
|
|
25
|
+
usage: Usage;
|
|
26
|
+
};
|
|
27
|
+
//#endregion
|
|
28
|
+
export { SessionSendResult };
|
|
29
|
+
//# sourceMappingURL=session-send-result.type.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session-send-result.type.d.mts","names":[],"sources":["../../../../../../../@warlock.js/ai/src/contracts/result/session-send-result.type.ts"],"mappings":";;;;;;;;;AAkBA;;;;;;;;;;KAAY,iBAAA;EAIV,iDAFA,QAAA,UAIQ;EAFR,IAAA,WAKI;EAHJ,KAAA,GAAQ,OAAA,EAKJ;EAHJ,eAAA,EACI,WAAA,YACA,gBAAA,YACA,cAAA,WAEG;EAAP,KAAA,EAAO,KAAA;AAAA"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { AIError } from "../../errors/ai-error.mjs";
|
|
2
|
+
import { Usage } from "./usage.type.mjs";
|
|
3
|
+
import { AttemptEntry } from "./attempt-entry.type.mjs";
|
|
4
|
+
import { AgentReport } from "./execution-report.type.mjs";
|
|
5
|
+
import { AgentResult } from "./agent-result.type.mjs";
|
|
6
|
+
|
|
7
|
+
//#region ../../@warlock.js/ai/src/contracts/result/step-result.type.d.ts
|
|
8
|
+
/**
|
|
9
|
+
* Frozen snapshot of a completed workflow step, stored under
|
|
10
|
+
* `WorkflowReport.steps[name]` and `ctx.steps[name]`.
|
|
11
|
+
*
|
|
12
|
+
* For agent-backed steps, three forensic fields are surfaced at the
|
|
13
|
+
* top level for easy inspection:
|
|
14
|
+
*
|
|
15
|
+
* - `agentReport` — trips, tool calls, status, timing for the agent
|
|
16
|
+
* call that produced this step's output. Mirrors
|
|
17
|
+
* `executionResult.report` but is directly reachable without
|
|
18
|
+
* narrowing the union.
|
|
19
|
+
* - `agentUsage` — token counts for this step in isolation. Sum of
|
|
20
|
+
* all `steps[*].agentUsage` equals the workflow-level `usage`.
|
|
21
|
+
* - `executionResult` — the full `AgentResult` (or custom `run`
|
|
22
|
+
* return value). Use this when you need `data` / `text` / `error`
|
|
23
|
+
* alongside the report.
|
|
24
|
+
*/
|
|
25
|
+
type StepSnapshot = Readonly<{
|
|
26
|
+
output: unknown;
|
|
27
|
+
skipped: boolean;
|
|
28
|
+
status: "completed" | "skipped" | "failed";
|
|
29
|
+
startedAt: string;
|
|
30
|
+
endedAt: string;
|
|
31
|
+
duration: number;
|
|
32
|
+
attempts: number;
|
|
33
|
+
attemptHistory: AttemptEntry[];
|
|
34
|
+
error?: AIError;
|
|
35
|
+
state: Readonly<Record<string, unknown>>; /** Full agent result when the step ran an agent; absent for `run` / skipped / parallel steps. */
|
|
36
|
+
executionResult?: AgentResult<unknown>; /** Shortcut: `executionResult.report` when present. */
|
|
37
|
+
agentReport?: AgentReport; /** Shortcut: `executionResult.usage` when present. */
|
|
38
|
+
agentUsage?: Usage; /** Nested children for parallel steps. */
|
|
39
|
+
steps?: Record<string, StepSnapshot>;
|
|
40
|
+
}>;
|
|
41
|
+
//#endregion
|
|
42
|
+
export { StepSnapshot };
|
|
43
|
+
//# sourceMappingURL=step-result.type.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"step-result.type.d.mts","names":[],"sources":["../../../../../../../@warlock.js/ai/src/contracts/result/step-result.type.ts"],"mappings":";;;;;;;;AAyBA;;;;;;;;;;;;;;;;KAAY,YAAA,GAAe,QAAA;EACzB,MAAA;EACA,OAAA;EACA,MAAA;EACA,SAAA;EACA,OAAA;EACA,QAAA;EACA,QAAA;EACA,cAAA,EAAgB,YAAA;EAChB,KAAA,GAAQ,OAAA;EACR,KAAA,EAAO,QAAA,CAAS,MAAA,oBAAhB;EAEA,eAAA,GAAkB,WAAA,WAFF;EAIhB,WAAA,GAAc,WAAA,EAFI;EAIlB,UAAA,GAAa,KAAA,EAFC;EAId,KAAA,GAAQ,MAAA,SAAe,YAAA;AAAA"}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { BaseResult } from "./base-result.type.mjs";
|
|
2
|
+
import { BaseReport } from "./base-report.type.mjs";
|
|
3
|
+
import { AckSnapshot, IterationSnapshot } from "../supervisor/iteration-snapshot.type.mjs";
|
|
4
|
+
import { ClassifierSnapshot } from "../supervisor/classifier-context.type.mjs";
|
|
5
|
+
|
|
6
|
+
//#region ../../@warlock.js/ai/src/contracts/result/supervisor-result.type.d.ts
|
|
7
|
+
/**
|
|
8
|
+
* How the supervisor decided to stop iterating. Recorded so log and
|
|
9
|
+
* dashboard queries can slice "ended because router said END" from
|
|
10
|
+
* "ran out of iterations" from "user aborted" without re-reading the
|
|
11
|
+
* error object.
|
|
12
|
+
*/
|
|
13
|
+
type SupervisorTerminatedBy = "router" | "route" | "classifier" | "evaluate" | "max-iterations" | "cancelled" | "error";
|
|
14
|
+
/**
|
|
15
|
+
* Supervisor-specific execution report. Extends {@link BaseReport}
|
|
16
|
+
* with supervisor-only fields — iteration count, termination reason,
|
|
17
|
+
* per-iteration snapshots — while sharing the canonical timing,
|
|
18
|
+
* status, usage, and recursive `children[]` block with every other
|
|
19
|
+
* primitive.
|
|
20
|
+
*
|
|
21
|
+
* `snapshots` remains the primary iteration-granularity debug artifact
|
|
22
|
+
* — every routing decision, every dispatch, every evaluate verdict.
|
|
23
|
+
* The cross-cutting view of "which executables ran underneath" lives
|
|
24
|
+
* on {@link BaseReport.children}, which duplicates nothing: it's the
|
|
25
|
+
* reports of the child agents/workflows dispatched across iterations.
|
|
26
|
+
*/
|
|
27
|
+
type SupervisorReport = BaseReport & {
|
|
28
|
+
supervisorName: string; /** Structural fingerprint — same value exposed on the instance. */
|
|
29
|
+
signature: string;
|
|
30
|
+
terminatedBy: SupervisorTerminatedBy; /** How many iterations ran (including the terminal one). */
|
|
31
|
+
iterations: number; /** ISO-8601 timestamp when a cancellation was observed, if any. */
|
|
32
|
+
cancelledAt?: string;
|
|
33
|
+
snapshots: IterationSnapshot[];
|
|
34
|
+
/**
|
|
35
|
+
* Receptionist (`ackAgent`) forensic record. Present only when an
|
|
36
|
+
* ack agent was configured AND the run started fresh (resumes don't
|
|
37
|
+
* re-fire ack). The ack agent's full report node also lives under
|
|
38
|
+
* `children[]` like any other dispatched agent.
|
|
39
|
+
*/
|
|
40
|
+
ack?: AckSnapshot;
|
|
41
|
+
/**
|
|
42
|
+
* Classifier (Phase 7 / decisions §37) forensic record. Present
|
|
43
|
+
* only when `SupervisorConfig.classifier` was configured AND the
|
|
44
|
+
* run started fresh (resumes don't re-fire classifier). Sibling of
|
|
45
|
+
* `ack` — full forensic detail regardless of what strip-merged
|
|
46
|
+
* into state. Distinct from the children list — classifier runs
|
|
47
|
+
* are not also pushed onto `children[]`.
|
|
48
|
+
*/
|
|
49
|
+
classifier?: ClassifierSnapshot;
|
|
50
|
+
};
|
|
51
|
+
/**
|
|
52
|
+
* Result returned by `supervisor.execute()` and resolved by
|
|
53
|
+
* `stream.result`. Canonical destructure —
|
|
54
|
+
* `const { data, report, usage, error } = await supervisor.execute(...)` —
|
|
55
|
+
* mirrors agent and workflow so nested composition feels uniform.
|
|
56
|
+
*
|
|
57
|
+
* `data` populates only on successful completion of a supervisor
|
|
58
|
+
* configured with `output`. On failure or cancellation it is
|
|
59
|
+
* `undefined`; `error` carries the typed cause and `report.status`
|
|
60
|
+
* narrows further.
|
|
61
|
+
*
|
|
62
|
+
* `usage` is rolled up from every child executable this supervisor
|
|
63
|
+
* ran (router agent, dispatched agents/workflows, evaluate agent) —
|
|
64
|
+
* see {@link BaseReport} rollup semantics.
|
|
65
|
+
*
|
|
66
|
+
* @example
|
|
67
|
+
* const { data, report, usage, error } = await supervisor.execute(input);
|
|
68
|
+
*
|
|
69
|
+
* if (error) {
|
|
70
|
+
* logger.error(error.code, {
|
|
71
|
+
* terminatedBy: report.terminatedBy,
|
|
72
|
+
* iterations: report.iterations,
|
|
73
|
+
* });
|
|
74
|
+
* return;
|
|
75
|
+
* }
|
|
76
|
+
*
|
|
77
|
+
* return { answer: data, cost: usage.total, turns: report.iterations };
|
|
78
|
+
*/
|
|
79
|
+
type SupervisorResult<TOutput = unknown> = BaseResult & {
|
|
80
|
+
/** Discriminant for narrowing `SessionSendResult.executionResult`. */type: "supervisor";
|
|
81
|
+
data?: TOutput;
|
|
82
|
+
report: SupervisorReport;
|
|
83
|
+
};
|
|
84
|
+
//#endregion
|
|
85
|
+
export { SupervisorReport, SupervisorResult, SupervisorTerminatedBy };
|
|
86
|
+
//# sourceMappingURL=supervisor-result.type.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"supervisor-result.type.d.mts","names":[],"sources":["../../../../../../../@warlock.js/ai/src/contracts/result/supervisor-result.type.ts"],"mappings":";;;;;;;;AAWA;;;;KAAY,sBAAA;AAsBZ;;;;;;;;;;;;;AAAA,KAAY,gBAAA,GAAmB,UAAA;EAC7B,cAAA,UAKA;EAHA,SAAA;EACA,YAAA,EAAc,sBAAA,EAKH;EAHX,UAAA,UAUM;EARN,WAAA;EACA,SAAA,EAAW,iBAAA;EAgBoB;AAAA;AA+BjC;;;;EAxCE,GAAA,GAAM,WAAA;EA4CE;;;;;;;;EAnCR,UAAA,GAAa,kBAAA;AAAA;;AAmCW;;;;;;;;;;;;;;;;;;;;;;;;;;;KAJd,gBAAA,sBAAsC,UAAA;wEAEhD,IAAA;EACA,IAAA,GAAO,OAAA;EACP,MAAA,EAAQ,gBAAA;AAAA"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { AIError } from "../../errors/ai-error.mjs";
|
|
2
|
+
import { BaseReport } from "./base-report.type.mjs";
|
|
3
|
+
|
|
4
|
+
//#region ../../@warlock.js/ai/src/contracts/result/tool-call.type.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* Forensic record of a single leaf-tool dispatch inside an agent's
|
|
7
|
+
* execution. Structurally a {@link BaseReport} (`type: "tool"`) with
|
|
8
|
+
* agent-level enrichments — the originating LLM trip index, the raw
|
|
9
|
+
* input the model emitted, the concrete output returned, and the
|
|
10
|
+
* typed error if any.
|
|
11
|
+
*
|
|
12
|
+
* Because `ToolCall` is a `BaseReport`, it drops directly into
|
|
13
|
+
* `AgentReport.children[]` alongside nested agent/workflow/supervisor
|
|
14
|
+
* reports, keeping the recursive tree uniform. It also powers the
|
|
15
|
+
* live `agent.tool.called` event + stream payloads so subscribers see
|
|
16
|
+
* the same shape during execution as they read post-hoc.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* const toolCalls = agentReport.children.filter(
|
|
20
|
+
* (c): c is ToolCall => c.type === "tool",
|
|
21
|
+
* );
|
|
22
|
+
* for (const call of toolCalls) {
|
|
23
|
+
* console.log(call.name, call.tripIndex, call.input, call.output);
|
|
24
|
+
* }
|
|
25
|
+
*/
|
|
26
|
+
type ToolCall = BaseReport & {
|
|
27
|
+
/** Discriminator already fixed on BaseReport, narrowed to "tool" here. */type: "tool"; /** Which LLM trip triggered this tool call (0-indexed). */
|
|
28
|
+
tripIndex: number; /** Input passed to the tool (validated args from the model's request). */
|
|
29
|
+
input: unknown; /** Output returned by the tool (undefined if an error occurred). */
|
|
30
|
+
output?: unknown; /** Typed AI error thrown during dispatch (validation or execute), if any. */
|
|
31
|
+
error?: AIError;
|
|
32
|
+
/**
|
|
33
|
+
* Provenance marker copied from the originating
|
|
34
|
+
* `ModelToolCallRequest.recoveredFrom`. Present only when this
|
|
35
|
+
* dispatch came from the streaming tool-call guard recovering a
|
|
36
|
+
* leaked JSON envelope from the text channel; absent for real
|
|
37
|
+
* provider tool-calls. Telemetry consumers branch on this to compute
|
|
38
|
+
* per-model leak rate.
|
|
39
|
+
*/
|
|
40
|
+
recoveredFrom?: "stream-text";
|
|
41
|
+
};
|
|
42
|
+
//#endregion
|
|
43
|
+
export { ToolCall };
|
|
44
|
+
//# sourceMappingURL=tool-call.type.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool-call.type.d.mts","names":[],"sources":["../../../../../../../@warlock.js/ai/src/contracts/result/tool-call.type.ts"],"mappings":";;;;;;AAwBA;;;;;;;;;;;;;AAmBe;;;;;;KAnBH,QAAA,GAAW,UAAA;4EAErB,IAAA;EAEA,SAAA;EAEA,KAAA;EAEA,MAAA;EAEA,KAAA,GAAQ,OAAO;;;;;;;;;EASf,aAAA;AAAA"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { ModelPricing } from "./model-pricing.type.mjs";
|
|
2
|
+
|
|
3
|
+
//#region ../../@warlock.js/ai/src/contracts/result/usage.type.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Token usage statistics for a single LLM call or aggregated across trips.
|
|
6
|
+
*
|
|
7
|
+
* `cachedTokens` is optional and represents the subset of `input` that
|
|
8
|
+
* was served from the provider's prompt cache (OpenAI's
|
|
9
|
+
* `prompt_tokens_details.cached_tokens`, Anthropic's
|
|
10
|
+
* `cache_read_input_tokens`). Cache-hit tokens are usually billed at
|
|
11
|
+
* a fraction of the full input rate — separate accounting lets cost
|
|
12
|
+
* code price them correctly. Defaults to 0 / undefined when the
|
|
13
|
+
* provider doesn't report it.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* const usage: Usage = {
|
|
17
|
+
* input: 150,
|
|
18
|
+
* output: 320,
|
|
19
|
+
* total: 470,
|
|
20
|
+
* cachedTokens: 120,
|
|
21
|
+
* cost: { input: 0.0000045, output: 0.000192, cachedInput: 0.000009 },
|
|
22
|
+
* };
|
|
23
|
+
*/
|
|
24
|
+
type Usage = {
|
|
25
|
+
/** Number of input/prompt tokens consumed (includes cachedTokens). */input: number; /** Number of output/completion tokens generated. */
|
|
26
|
+
output: number; /** Total tokens (input + output). */
|
|
27
|
+
total: number;
|
|
28
|
+
/**
|
|
29
|
+
* Subset of `input` served from the provider's prompt cache. Billed
|
|
30
|
+
* at a discounted rate when cost is computed downstream. Optional —
|
|
31
|
+
* providers that don't report cache hits leave this undefined.
|
|
32
|
+
*/
|
|
33
|
+
cachedTokens?: number;
|
|
34
|
+
/**
|
|
35
|
+
* Cost breakdown in USD, computed at emit time from `tokens × pricing[model]`
|
|
36
|
+
* when the model adapter declared a `ModelPricing`. Same shape as
|
|
37
|
+
* `ModelPricing` (input / output / cachedInput / cachedOutput) so
|
|
38
|
+
* dashboards can tell HOW the total was reached — what share was
|
|
39
|
+
* input vs output, how much the prompt cache saved — instead of
|
|
40
|
+
* looking at one opaque number.
|
|
41
|
+
*
|
|
42
|
+
* Captured as a historical fact so stored reports remain accurate
|
|
43
|
+
* even after the pricing table changes upstream.
|
|
44
|
+
*
|
|
45
|
+
* `undefined` when no pricing is available (legacy adapters, unknown
|
|
46
|
+
* model names, intentionally unpriced free-tier runs). Aggregators
|
|
47
|
+
* merge defined fields and leave undefined ones untouched, so an
|
|
48
|
+
* unpriced child cannot erase priced siblings.
|
|
49
|
+
*
|
|
50
|
+
* For a single scalar total, sum the populated fields:
|
|
51
|
+
* `(cost.input ?? 0) + (cost.output ?? 0) + (cost.cachedInput ?? 0) + (cost.cachedOutput ?? 0)`.
|
|
52
|
+
*/
|
|
53
|
+
cost?: ModelPricing;
|
|
54
|
+
};
|
|
55
|
+
//#endregion
|
|
56
|
+
export { Usage };
|
|
57
|
+
//# sourceMappingURL=usage.type.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usage.type.d.mts","names":[],"sources":["../../../../../../../@warlock.js/ai/src/contracts/result/usage.type.ts"],"mappings":";;;;;AAsBA;;;;;;;;;;;AAgCqB;;;;;;;KAhCT,KAAA;wEAEV,KAAA;EAEA,MAAA;EAEA,KAAA;;;;;;EAMA,YAAA;;;;;;;;;;;;;;;;;;;;EAoBA,IAAA,GAAO,YAAY;AAAA"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { AIError } from "../../errors/ai-error.mjs";
|
|
2
|
+
import { BaseResult } from "./base-result.type.mjs";
|
|
3
|
+
import { BaseReport } from "./base-report.type.mjs";
|
|
4
|
+
import { StepSnapshot } from "./step-result.type.mjs";
|
|
5
|
+
|
|
6
|
+
//#region ../../@warlock.js/ai/src/contracts/result/workflow-result.type.d.ts
|
|
7
|
+
/**
|
|
8
|
+
* Workflow-specific execution report — {@link BaseReport} plus
|
|
9
|
+
* per-step snapshots and the final frozen `ctx.state`.
|
|
10
|
+
*
|
|
11
|
+
* `report.children[]` carries every executable (tool, agent,
|
|
12
|
+
* sub-workflow, supervisor) any step invoked, in invocation order.
|
|
13
|
+
* `report.steps` remains the authoritative record of workflow
|
|
14
|
+
* structure — one entry per defined step — while `children` gives
|
|
15
|
+
* the cross-cutting tree view shared with other primitives.
|
|
16
|
+
*/
|
|
17
|
+
type WorkflowReport = BaseReport & {
|
|
18
|
+
workflowName: string; /** Structural fingerprint — same value exposed on the workflow instance. */
|
|
19
|
+
signature: string; /** ISO-8601 timestamp when cancellation was observed, if any. */
|
|
20
|
+
cancelledAt?: string; /** Per-step snapshots keyed by step name. */
|
|
21
|
+
steps: Record<string, StepSnapshot>; /** Frozen final `ctx.state` at the moment the workflow terminated. */
|
|
22
|
+
state: Readonly<Record<string, unknown>>;
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Result returned by `workflow.execute()` / `workflow.resume()`.
|
|
26
|
+
*
|
|
27
|
+
* Canonical destructuring (mirrors `AgentResult` and
|
|
28
|
+
* `SupervisorResult`):
|
|
29
|
+
*
|
|
30
|
+
* `const { data, report, usage, error } = await workflow.execute(...)`
|
|
31
|
+
*
|
|
32
|
+
* `data` is populated only when the workflow was defined with an
|
|
33
|
+
* `output: { extract, schema? }` spec and completed successfully. On
|
|
34
|
+
* failure or cancellation it is `undefined`; read `error` and
|
|
35
|
+
* `report.status` instead.
|
|
36
|
+
*/
|
|
37
|
+
type WorkflowResult<TOutput = unknown> = BaseResult & {
|
|
38
|
+
type: "workflow";
|
|
39
|
+
data?: TOutput;
|
|
40
|
+
report: WorkflowReport;
|
|
41
|
+
error?: AIError;
|
|
42
|
+
};
|
|
43
|
+
//#endregion
|
|
44
|
+
export { WorkflowReport, WorkflowResult };
|
|
45
|
+
//# sourceMappingURL=workflow-result.type.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workflow-result.type.d.mts","names":[],"sources":["../../../../../../../@warlock.js/ai/src/contracts/result/workflow-result.type.ts"],"mappings":";;;;;;;;AAeA;;;;;;;;KAAY,cAAA,GAAiB,UAAA;EAC3B,YAAA,UAD2B;EAG3B,SAAA;EAEA,WAAA,WAEA;EAAA,KAAA,EAAO,MAAA,SAAe,YAAA,GAAA;EAEtB,KAAA,EAAO,QAAA,CAAS,MAAA;AAAA;;;AAAM;AAgBxB;;;;;;;;;;KAAY,cAAA,sBAAoC,UAAA;EAC9C,IAAA;EACA,IAAA,GAAO,OAAA;EACP,MAAA,EAAQ,cAAA;EACR,KAAA,GAAQ,OAAA;AAAA"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { ModelPricing } from "./result/model-pricing.type.mjs";
|
|
2
|
+
import { EmbedderConfig, EmbedderContract } from "./embedder.contract.mjs";
|
|
3
|
+
import { ModelContract } from "./model.contract.mjs";
|
|
4
|
+
|
|
5
|
+
//#region ../../@warlock.js/ai/src/contracts/sdk-adapter.contract.d.ts
|
|
6
|
+
/**
|
|
7
|
+
* Configuration passed to SDKAdapterContract.model() to create a model instance.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* const model = ai.openai.model({ name: "gpt-4o", temperature: 0.7 });
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* // Per-model pricing override (multi-tenant projects where the
|
|
14
|
+
* // rate is contract-specific or runtime-resolved):
|
|
15
|
+
* openai.model({
|
|
16
|
+
* name: "gpt-4o",
|
|
17
|
+
* pricing: { input: 2.5, output: 10 },
|
|
18
|
+
* });
|
|
19
|
+
*/
|
|
20
|
+
type ModelConfig = {
|
|
21
|
+
/** Model identifier (e.g. "gpt-4o", "claude-3-5-sonnet-20241022") */name: string; /** Sampling temperature (0–2). Higher = more creative, lower = more focused */
|
|
22
|
+
temperature?: number; /** Maximum tokens to generate in the response */
|
|
23
|
+
maxTokens?: number;
|
|
24
|
+
/**
|
|
25
|
+
* Per-model USD pricing override. Wins over any SDK-level pricing
|
|
26
|
+
* registry — useful in multi-tenant projects where the rate is
|
|
27
|
+
* contract-specific or runtime-resolved. When omitted, the adapter
|
|
28
|
+
* falls back to its SDK-level registry (if any); when neither is
|
|
29
|
+
* configured, `Usage.cost` stays `undefined` (honest absence, not
|
|
30
|
+
* false zero).
|
|
31
|
+
*/
|
|
32
|
+
pricing?: ModelPricing; /** Additional provider-specific configuration */
|
|
33
|
+
[key: string]: unknown;
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* What every SDK adapter factory returns.
|
|
37
|
+
* Becomes `ai.[sdkName]` on the AI namespace (e.g. `ai.openai`, `ai.anthropic`).
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* // OpenAI adapter registered as ai.openai
|
|
41
|
+
* const model = ai.openai.model({ name: "gpt-4o" });
|
|
42
|
+
* const tokens = await ai.openai.count("Hello world", "gpt-4o");
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* // Mock adapter for tests
|
|
46
|
+
* const mock = MockSDK();
|
|
47
|
+
* const model = mock.model({ name: "mock-model" });
|
|
48
|
+
*/
|
|
49
|
+
interface SDKAdapterContract {
|
|
50
|
+
/**
|
|
51
|
+
* Create a model instance with the given configuration.
|
|
52
|
+
* The returned ModelContract is passed to agents, tools, and other primitives.
|
|
53
|
+
*/
|
|
54
|
+
model(config: ModelConfig): ModelContract;
|
|
55
|
+
/**
|
|
56
|
+
* Count the number of tokens in the given text.
|
|
57
|
+
* Implementation is deferred to each adapter package.
|
|
58
|
+
*
|
|
59
|
+
* @param text - The text to tokenize and count
|
|
60
|
+
* @param model - Optional model name; affects tokenizer selection for some providers
|
|
61
|
+
* @returns Promise resolving to the token count
|
|
62
|
+
*/
|
|
63
|
+
count(text: string, model?: string): Promise<number>;
|
|
64
|
+
/**
|
|
65
|
+
* Create an embedder bound to this SDK's client. Optional — not every
|
|
66
|
+
* provider supports embeddings (e.g. a hypothetical Anthropic adapter
|
|
67
|
+
* today). Consumers should check for presence before calling.
|
|
68
|
+
*
|
|
69
|
+
* @example
|
|
70
|
+
* const embedder = openai.embedder({ name: "text-embedding-3-small" });
|
|
71
|
+
* const { vector } = await embedder.embed("Hello world");
|
|
72
|
+
*/
|
|
73
|
+
embedder?(config: EmbedderConfig): EmbedderContract;
|
|
74
|
+
}
|
|
75
|
+
//#endregion
|
|
76
|
+
export { ModelConfig, SDKAdapterContract };
|
|
77
|
+
//# sourceMappingURL=sdk-adapter.contract.d.mts.map
|