@warlock.js/ai 4.2.11 → 4.3.0
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/CHANGELOG.md +61 -1
- package/cjs/index.cjs +10151 -4625
- package/cjs/index.cjs.map +1 -1
- package/cjs/magic-string.es-BtxW4VqG.cjs +1015 -0
- package/cjs/magic-string.es-BtxW4VqG.cjs.map +1 -0
- package/cjs/matcher-logic-SBnzYohQ.cjs +217 -0
- package/cjs/matcher-logic-SBnzYohQ.cjs.map +1 -0
- package/cjs/matchers-BBh3gyB-.cjs +13739 -0
- package/cjs/matchers-BBh3gyB-.cjs.map +1 -0
- package/esm/agent/agent-config.type.d.mts +19 -6
- package/esm/agent/agent-config.type.d.mts.map +1 -1
- package/esm/agent/agent.d.mts.map +1 -1
- package/esm/agent/agent.mjs +17 -6
- package/esm/agent/agent.mjs.map +1 -1
- package/esm/agent/index.d.mts +2 -1
- package/esm/agent/index.mjs +1 -0
- package/esm/agent/spawn-sub-agent.d.mts +87 -0
- package/esm/agent/spawn-sub-agent.d.mts.map +1 -0
- package/esm/agent/spawn-sub-agent.mjs +68 -0
- package/esm/agent/spawn-sub-agent.mjs.map +1 -0
- package/esm/ai.d.mts +58 -3
- package/esm/ai.d.mts.map +1 -1
- package/esm/ai.mjs +58 -3
- package/esm/ai.mjs.map +1 -1
- package/esm/batch/batch.d.mts +43 -0
- package/esm/batch/batch.d.mts.map +1 -0
- package/esm/batch/batch.mjs +179 -0
- package/esm/batch/batch.mjs.map +1 -0
- package/esm/batch/batch.type.d.mts +144 -0
- package/esm/batch/batch.type.d.mts.map +1 -0
- package/esm/batch/index.mjs +3 -0
- package/esm/batch/run-batch-item.mjs +100 -0
- package/esm/batch/run-batch-item.mjs.map +1 -0
- package/esm/batch/run-with-concurrency.mjs +39 -0
- package/esm/batch/run-with-concurrency.mjs.map +1 -0
- package/esm/checkpoint/index.d.mts +3 -0
- package/esm/checkpoint/memory.d.mts +21 -0
- package/esm/checkpoint/memory.d.mts.map +1 -0
- package/esm/checkpoint/memory.mjs +0 -0
- package/esm/checkpoint/memory.mjs.map +1 -0
- package/esm/checkpoint/pg.d.mts +37 -0
- package/esm/checkpoint/pg.d.mts.map +1 -0
- package/esm/checkpoint/pg.mjs +265 -0
- package/esm/checkpoint/pg.mjs.map +1 -0
- package/esm/checkpoint/redis.d.mts +39 -0
- package/esm/checkpoint/redis.d.mts.map +1 -0
- package/esm/checkpoint/redis.mjs +200 -0
- package/esm/checkpoint/redis.mjs.map +1 -0
- package/esm/config.d.mts +61 -14
- package/esm/config.d.mts.map +1 -1
- package/esm/config.mjs +25 -6
- package/esm/config.mjs.map +1 -1
- package/esm/contracts/agent/agent.contract.d.mts +43 -0
- package/esm/contracts/agent/agent.contract.d.mts.map +1 -1
- package/esm/contracts/agent/eval.type.d.mts +143 -0
- package/esm/contracts/agent/eval.type.d.mts.map +1 -0
- package/esm/contracts/agent/index.d.mts +1 -0
- package/esm/contracts/events/supervisor-events.type.d.mts +3 -3
- package/esm/contracts/fallback-model.contract.d.mts +65 -0
- package/esm/contracts/fallback-model.contract.d.mts.map +1 -0
- package/esm/contracts/index.d.mts +32 -12
- package/esm/contracts/memory/index.d.mts +4 -0
- package/esm/contracts/memory/memory-config.type.d.mts +150 -0
- package/esm/contracts/memory/memory-config.type.d.mts.map +1 -0
- package/esm/contracts/memory/memory-item.type.d.mts +64 -0
- package/esm/contracts/memory/memory-item.type.d.mts.map +1 -0
- package/esm/contracts/memory/memory.contract.d.mts +87 -0
- package/esm/contracts/memory/memory.contract.d.mts.map +1 -0
- package/esm/contracts/memory/recall-options.type.d.mts +33 -0
- package/esm/contracts/memory/recall-options.type.d.mts.map +1 -0
- package/esm/contracts/middleware/index.d.mts +2 -2
- package/esm/contracts/middleware/middleware-context.type.d.mts +42 -2
- package/esm/contracts/middleware/middleware-context.type.d.mts.map +1 -1
- package/esm/contracts/middleware/middleware.contract.d.mts +46 -2
- package/esm/contracts/middleware/middleware.contract.d.mts.map +1 -1
- package/esm/contracts/model.contract.d.mts +63 -2
- package/esm/contracts/model.contract.d.mts.map +1 -1
- package/esm/contracts/orchestrator/checkpoint-store.contract.d.mts +91 -0
- package/esm/contracts/orchestrator/checkpoint-store.contract.d.mts.map +1 -0
- package/esm/contracts/orchestrator/index.d.mts +8 -0
- package/esm/contracts/orchestrator/orchestrator-commands.type.d.mts +43 -0
- package/esm/contracts/orchestrator/orchestrator-commands.type.d.mts.map +1 -0
- package/esm/contracts/orchestrator/orchestrator-config.type.d.mts +170 -0
- package/esm/contracts/orchestrator/orchestrator-config.type.d.mts.map +1 -0
- package/esm/contracts/orchestrator/orchestrator-event.type.d.mts +118 -0
- package/esm/contracts/orchestrator/orchestrator-event.type.d.mts.map +1 -0
- package/esm/contracts/orchestrator/orchestrator-execute-options.type.d.mts +44 -0
- package/esm/contracts/orchestrator/orchestrator-execute-options.type.d.mts.map +1 -0
- package/esm/contracts/orchestrator/orchestrator.contract.d.mts +129 -0
- package/esm/contracts/orchestrator/orchestrator.contract.d.mts.map +1 -0
- package/esm/contracts/orchestrator/session.contract.d.mts +26 -0
- package/esm/contracts/orchestrator/session.contract.d.mts.map +1 -0
- package/esm/contracts/orchestrator/snapshot-store.contract.d.mts +89 -0
- package/esm/contracts/orchestrator/snapshot-store.contract.d.mts.map +1 -0
- package/esm/contracts/planner/index.d.mts +6 -0
- package/esm/contracts/planner/planner-capability.type.d.mts +39 -0
- package/esm/contracts/planner/planner-capability.type.d.mts.map +1 -0
- package/esm/contracts/planner/planner-config.type.d.mts +78 -0
- package/esm/contracts/planner/planner-config.type.d.mts.map +1 -0
- package/esm/contracts/planner/planner-execute-options.type.d.mts +43 -0
- package/esm/contracts/planner/planner-execute-options.type.d.mts.map +1 -0
- package/esm/contracts/planner/planner-plan.type.d.mts +48 -0
- package/esm/contracts/planner/planner-plan.type.d.mts.map +1 -0
- package/esm/contracts/planner/planner-result.type.d.mts +82 -0
- package/esm/contracts/planner/planner-result.type.d.mts.map +1 -0
- package/esm/contracts/planner/planner.contract.d.mts +60 -0
- package/esm/contracts/planner/planner.contract.d.mts.map +1 -0
- package/esm/contracts/result/base-report.type.d.mts +7 -2
- package/esm/contracts/result/base-report.type.d.mts.map +1 -1
- package/esm/contracts/result/base-report.type.mjs.map +1 -1
- package/esm/contracts/result/index.d.mts +2 -1
- package/esm/contracts/result/model-pricing.type.d.mts +10 -0
- package/esm/contracts/result/model-pricing.type.d.mts.map +1 -1
- package/esm/contracts/result/orchestrator-result.type.d.mts +139 -0
- package/esm/contracts/result/orchestrator-result.type.d.mts.map +1 -0
- package/esm/contracts/result/session-send-result.type.d.mts +12 -3
- package/esm/contracts/result/session-send-result.type.d.mts.map +1 -1
- package/esm/contracts/result/supervisor-result.type.d.mts +1 -1
- package/esm/contracts/result/usage.type.d.mts +24 -0
- package/esm/contracts/result/usage.type.d.mts.map +1 -1
- package/esm/contracts/sdk-adapter.contract.d.mts +1 -1
- package/esm/contracts/supervisor/dispatch-context.type.d.mts +3 -3
- package/esm/contracts/supervisor/evaluate-context.type.d.mts +1 -1
- package/esm/contracts/supervisor/index.d.mts +5 -5
- package/esm/contracts/supervisor/route-context.type.d.mts +2 -2
- package/esm/contracts/supervisor/supervisor-config.type.d.mts +55 -13
- package/esm/contracts/supervisor/supervisor-config.type.d.mts.map +1 -1
- package/esm/contracts/supervisor/supervisor-snapshot.type.d.mts +1 -1
- package/esm/contracts/supervisor/supervisor.contract.d.mts +9 -2
- package/esm/contracts/supervisor/supervisor.contract.d.mts.map +1 -1
- package/esm/contracts/workflow/index.d.mts +2 -2
- package/esm/contracts/workflow/workflow.contract.d.mts +28 -7
- package/esm/contracts/workflow/workflow.contract.d.mts.map +1 -1
- package/esm/errors/error-code.type.d.mts +1 -1
- package/esm/errors/index.d.mts +7 -0
- package/esm/errors/index.mjs +7 -0
- package/esm/errors/orchestrator-cancelled-error.d.mts +32 -0
- package/esm/errors/orchestrator-cancelled-error.d.mts.map +1 -0
- package/esm/errors/orchestrator-cancelled-error.mjs +31 -0
- package/esm/errors/orchestrator-cancelled-error.mjs.map +1 -0
- package/esm/errors/orchestrator-config-error.d.mts +26 -0
- package/esm/errors/orchestrator-config-error.d.mts.map +1 -0
- package/esm/errors/orchestrator-config-error.mjs +30 -0
- package/esm/errors/orchestrator-config-error.mjs.map +1 -0
- package/esm/errors/orchestrator-drift-error.d.mts +38 -0
- package/esm/errors/orchestrator-drift-error.d.mts.map +1 -0
- package/esm/errors/orchestrator-drift-error.mjs +37 -0
- package/esm/errors/orchestrator-drift-error.mjs.map +1 -0
- package/esm/errors/orchestrator-failed-error.d.mts +33 -0
- package/esm/errors/orchestrator-failed-error.d.mts.map +1 -0
- package/esm/errors/orchestrator-failed-error.mjs +36 -0
- package/esm/errors/orchestrator-failed-error.mjs.map +1 -0
- package/esm/errors/planner-cancelled-error.d.mts +33 -0
- package/esm/errors/planner-cancelled-error.d.mts.map +1 -0
- package/esm/errors/planner-cancelled-error.mjs +29 -0
- package/esm/errors/planner-cancelled-error.mjs.map +1 -0
- package/esm/errors/planner-failed-error.d.mts +40 -0
- package/esm/errors/planner-failed-error.d.mts.map +1 -0
- package/esm/errors/planner-failed-error.mjs +37 -0
- package/esm/errors/planner-failed-error.mjs.map +1 -0
- package/esm/errors/planner-plan-invalid-error.d.mts +21 -0
- package/esm/errors/planner-plan-invalid-error.d.mts.map +1 -0
- package/esm/errors/planner-plan-invalid-error.mjs +25 -0
- package/esm/errors/planner-plan-invalid-error.mjs.map +1 -0
- package/esm/eval/eval-runner.d.mts +17 -0
- package/esm/eval/eval-runner.d.mts.map +1 -0
- package/esm/eval/eval-runner.mjs +121 -0
- package/esm/eval/eval-runner.mjs.map +1 -0
- package/esm/eval/index.d.mts +29 -0
- package/esm/eval/index.d.mts.map +1 -0
- package/esm/eval/index.mjs +30 -0
- package/esm/eval/index.mjs.map +1 -0
- package/esm/eval/judge-scorer.d.mts +21 -0
- package/esm/eval/judge-scorer.d.mts.map +1 -0
- package/esm/eval/judge-scorer.mjs +87 -0
- package/esm/eval/judge-scorer.mjs.map +1 -0
- package/esm/eval/scorers.d.mts +50 -0
- package/esm/eval/scorers.d.mts.map +1 -0
- package/esm/eval/scorers.mjs +101 -0
- package/esm/eval/scorers.mjs.map +1 -0
- package/esm/index.d.mts +95 -30
- package/esm/index.mjs +66 -22
- package/esm/memory/derive-id.mjs +24 -0
- package/esm/memory/derive-id.mjs.map +1 -0
- package/esm/memory/episodic-memory.mjs +106 -0
- package/esm/memory/episodic-memory.mjs.map +1 -0
- package/esm/memory/index.d.mts +5 -0
- package/esm/memory/memory.d.mts +42 -0
- package/esm/memory/memory.d.mts.map +1 -0
- package/esm/memory/memory.mjs +166 -0
- package/esm/memory/memory.mjs.map +1 -0
- package/esm/memory/procedural-memory.mjs +103 -0
- package/esm/memory/procedural-memory.mjs.map +1 -0
- package/esm/memory/semantic-memory.mjs +80 -0
- package/esm/memory/semantic-memory.mjs.map +1 -0
- package/esm/memory/working-memory.mjs +62 -0
- package/esm/memory/working-memory.mjs.map +1 -0
- package/esm/middleware/builtins/budget-contract.type.d.mts +126 -0
- package/esm/middleware/builtins/budget-contract.type.d.mts.map +1 -0
- package/esm/middleware/builtins/budget.d.mts +71 -1
- package/esm/middleware/builtins/budget.d.mts.map +1 -1
- package/esm/middleware/builtins/budget.mjs +119 -4
- package/esm/middleware/builtins/budget.mjs.map +1 -1
- package/esm/middleware/builtins/semantic-cache.d.mts +1 -1
- package/esm/middleware/index.d.mts +2 -1
- package/esm/middleware/index.mjs +1 -1
- package/esm/middleware/pipeline.d.mts +9 -6
- package/esm/middleware/pipeline.d.mts.map +1 -1
- package/esm/middleware/pipeline.mjs.map +1 -1
- package/esm/mock/index.d.mts +1 -0
- package/esm/mock/index.mjs +1 -0
- package/esm/mock/mock-router.d.mts +63 -0
- package/esm/mock/mock-router.d.mts.map +1 -0
- package/esm/mock/mock-router.mjs +58 -0
- package/esm/mock/mock-router.mjs.map +1 -0
- package/esm/model/fallback-model.d.mts +45 -0
- package/esm/model/fallback-model.d.mts.map +1 -0
- package/esm/model/fallback-model.mjs +218 -0
- package/esm/model/fallback-model.mjs.map +1 -0
- package/esm/model/index.d.mts +2 -0
- package/esm/model/index.mjs +3 -0
- package/esm/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.mjs +78 -0
- package/esm/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.mjs.map +1 -0
- package/esm/node_modules/@vitest/expect/dist/index.mjs +1473 -0
- package/esm/node_modules/@vitest/expect/dist/index.mjs.map +1 -0
- package/esm/node_modules/@vitest/pretty-format/dist/index.mjs +888 -0
- package/esm/node_modules/@vitest/pretty-format/dist/index.mjs.map +1 -0
- package/esm/node_modules/@vitest/runner/dist/chunk-artifact.mjs +1533 -0
- package/esm/node_modules/@vitest/runner/dist/chunk-artifact.mjs.map +1 -0
- package/esm/node_modules/@vitest/runner/dist/index.mjs +3 -0
- package/esm/node_modules/@vitest/runner/dist/utils.mjs +3 -0
- package/esm/node_modules/@vitest/snapshot/dist/index.mjs +922 -0
- package/esm/node_modules/@vitest/snapshot/dist/index.mjs.map +1 -0
- package/esm/node_modules/@vitest/spy/dist/index.mjs +386 -0
- package/esm/node_modules/@vitest/spy/dist/index.mjs.map +1 -0
- package/esm/node_modules/@vitest/utils/dist/chunk-pathe.M-eThtNZ.mjs +82 -0
- package/esm/node_modules/@vitest/utils/dist/chunk-pathe.M-eThtNZ.mjs.map +1 -0
- package/esm/node_modules/@vitest/utils/dist/diff.mjs +1357 -0
- package/esm/node_modules/@vitest/utils/dist/diff.mjs.map +1 -0
- package/esm/node_modules/@vitest/utils/dist/display.mjs +559 -0
- package/esm/node_modules/@vitest/utils/dist/display.mjs.map +1 -0
- package/esm/node_modules/@vitest/utils/dist/error.mjs +38 -0
- package/esm/node_modules/@vitest/utils/dist/error.mjs.map +1 -0
- package/esm/node_modules/@vitest/utils/dist/helpers.mjs +181 -0
- package/esm/node_modules/@vitest/utils/dist/helpers.mjs.map +1 -0
- package/esm/node_modules/@vitest/utils/dist/offset.mjs +27 -0
- package/esm/node_modules/@vitest/utils/dist/offset.mjs.map +1 -0
- package/esm/node_modules/@vitest/utils/dist/serialize.mjs +77 -0
- package/esm/node_modules/@vitest/utils/dist/serialize.mjs.map +1 -0
- package/esm/node_modules/@vitest/utils/dist/source-map.mjs +374 -0
- package/esm/node_modules/@vitest/utils/dist/source-map.mjs.map +1 -0
- package/esm/node_modules/@vitest/utils/dist/timers.mjs +37 -0
- package/esm/node_modules/@vitest/utils/dist/timers.mjs.map +1 -0
- package/esm/node_modules/chai/index.mjs +2973 -0
- package/esm/node_modules/chai/index.mjs.map +1 -0
- package/esm/node_modules/magic-string/dist/magic-string.es.mjs +940 -0
- package/esm/node_modules/magic-string/dist/magic-string.es.mjs.map +1 -0
- package/esm/node_modules/tinyrainbow/dist/index.mjs +87 -0
- package/esm/node_modules/tinyrainbow/dist/index.mjs.map +1 -0
- package/esm/node_modules/vitest/dist/chunks/_commonjsHelpers.D26ty3Ew.mjs +6 -0
- package/esm/node_modules/vitest/dist/chunks/_commonjsHelpers.D26ty3Ew.mjs.map +1 -0
- package/esm/node_modules/vitest/dist/chunks/rpc.MzXet3jl.mjs +52 -0
- package/esm/node_modules/vitest/dist/chunks/rpc.MzXet3jl.mjs.map +1 -0
- package/esm/node_modules/vitest/dist/chunks/test.DNmyFkvJ.mjs +2697 -0
- package/esm/node_modules/vitest/dist/chunks/test.DNmyFkvJ.mjs.map +1 -0
- package/esm/node_modules/vitest/dist/chunks/utils.BX5Fg8C4.mjs +45 -0
- package/esm/node_modules/vitest/dist/chunks/utils.BX5Fg8C4.mjs.map +1 -0
- package/esm/orchestrator/as-tool.d.mts +42 -0
- package/esm/orchestrator/as-tool.d.mts.map +1 -0
- package/esm/orchestrator/as-tool.mjs +98 -0
- package/esm/orchestrator/as-tool.mjs.map +1 -0
- package/esm/orchestrator/checkpoint.mjs +75 -0
- package/esm/orchestrator/checkpoint.mjs.map +1 -0
- package/esm/orchestrator/commands.d.mts +38 -0
- package/esm/orchestrator/commands.d.mts.map +1 -0
- package/esm/orchestrator/commands.mjs +34 -0
- package/esm/orchestrator/commands.mjs.map +1 -0
- package/esm/orchestrator/compaction.mjs +206 -0
- package/esm/orchestrator/compaction.mjs.map +1 -0
- package/esm/orchestrator/dispatch.mjs +171 -0
- package/esm/orchestrator/dispatch.mjs.map +1 -0
- package/esm/orchestrator/emitter-port.type.d.mts +31 -0
- package/esm/orchestrator/emitter-port.type.d.mts.map +1 -0
- package/esm/orchestrator/emitter.d.mts +56 -0
- package/esm/orchestrator/emitter.d.mts.map +1 -0
- package/esm/orchestrator/emitter.mjs +85 -0
- package/esm/orchestrator/emitter.mjs.map +1 -0
- package/esm/orchestrator/engine-context.type.d.mts +56 -0
- package/esm/orchestrator/engine-context.type.d.mts.map +1 -0
- package/esm/orchestrator/execution.d.mts +116 -0
- package/esm/orchestrator/execution.d.mts.map +1 -0
- package/esm/orchestrator/execution.mjs +406 -0
- package/esm/orchestrator/execution.mjs.map +1 -0
- package/esm/orchestrator/index.d.mts +8 -0
- package/esm/orchestrator/index.mjs +10 -0
- package/esm/orchestrator/load.mjs +49 -0
- package/esm/orchestrator/load.mjs.map +1 -0
- package/esm/orchestrator/lock.mjs +75 -0
- package/esm/orchestrator/lock.mjs.map +1 -0
- package/esm/orchestrator/memory.d.mts +84 -0
- package/esm/orchestrator/memory.d.mts.map +1 -0
- package/esm/orchestrator/memory.mjs +141 -0
- package/esm/orchestrator/memory.mjs.map +1 -0
- package/esm/orchestrator/orchestrator-stream.d.mts +42 -0
- package/esm/orchestrator/orchestrator-stream.d.mts.map +1 -0
- package/esm/orchestrator/orchestrator-stream.mjs +98 -0
- package/esm/orchestrator/orchestrator-stream.mjs.map +1 -0
- package/esm/orchestrator/orchestrator.d.mts +38 -0
- package/esm/orchestrator/orchestrator.d.mts.map +1 -0
- package/esm/orchestrator/orchestrator.mjs +173 -0
- package/esm/orchestrator/orchestrator.mjs.map +1 -0
- package/esm/orchestrator/resume.mjs +74 -0
- package/esm/orchestrator/resume.mjs.map +1 -0
- package/esm/orchestrator/signature.d.mts +40 -0
- package/esm/orchestrator/signature.d.mts.map +1 -0
- package/esm/orchestrator/signature.mjs +120 -0
- package/esm/orchestrator/signature.mjs.map +1 -0
- package/esm/orchestrator/window.mjs +56 -0
- package/esm/orchestrator/window.mjs.map +1 -0
- package/esm/planner/index.d.mts +5 -0
- package/esm/planner/index.mjs +6 -0
- package/esm/planner/plan-prompt.d.mts +17 -0
- package/esm/planner/plan-prompt.d.mts.map +1 -0
- package/esm/planner/plan-prompt.mjs +30 -0
- package/esm/planner/plan-prompt.mjs.map +1 -0
- package/esm/planner/plan-schema.d.mts +27 -0
- package/esm/planner/plan-schema.d.mts.map +1 -0
- package/esm/planner/plan-schema.mjs +117 -0
- package/esm/planner/plan-schema.mjs.map +1 -0
- package/esm/planner/planner-run.d.mts +23 -0
- package/esm/planner/planner-run.d.mts.map +1 -0
- package/esm/planner/planner-run.mjs +344 -0
- package/esm/planner/planner-run.mjs.map +1 -0
- package/esm/planner/planner.d.mts +37 -0
- package/esm/planner/planner.d.mts.map +1 -0
- package/esm/planner/planner.mjs +120 -0
- package/esm/planner/planner.mjs.map +1 -0
- package/esm/planner/signature.d.mts +18 -0
- package/esm/planner/signature.d.mts.map +1 -0
- package/esm/planner/signature.mjs +27 -0
- package/esm/planner/signature.mjs.map +1 -0
- package/esm/snapshot/index.d.mts +3 -0
- package/esm/snapshot/memory.d.mts +26 -0
- package/esm/snapshot/memory.d.mts.map +1 -0
- package/esm/snapshot/memory.mjs +81 -0
- package/esm/snapshot/memory.mjs.map +1 -0
- package/esm/snapshot/pg.d.mts +41 -0
- package/esm/snapshot/pg.d.mts.map +1 -0
- package/esm/snapshot/pg.mjs +146 -0
- package/esm/snapshot/pg.mjs.map +1 -0
- package/esm/snapshot/redis.d.mts +42 -0
- package/esm/snapshot/redis.d.mts.map +1 -0
- package/esm/snapshot/redis.mjs +101 -0
- package/esm/snapshot/redis.mjs.map +1 -0
- package/esm/supervisor/as-tool.d.mts +0 -6
- package/esm/supervisor/as-tool.d.mts.map +1 -1
- package/esm/supervisor/as-tool.mjs +0 -6
- package/esm/supervisor/as-tool.mjs.map +1 -1
- package/esm/supervisor/execution.d.mts +43 -8
- package/esm/supervisor/execution.d.mts.map +1 -1
- package/esm/supervisor/execution.mjs +66 -16
- package/esm/supervisor/execution.mjs.map +1 -1
- package/esm/supervisor/fan-out.d.mts +65 -0
- package/esm/supervisor/fan-out.d.mts.map +1 -0
- package/esm/supervisor/fan-out.mjs +65 -0
- package/esm/supervisor/fan-out.mjs.map +1 -0
- package/esm/supervisor/index.d.mts +5 -3
- package/esm/supervisor/index.mjs +3 -1
- package/esm/supervisor/router-factory.d.mts +110 -0
- package/esm/supervisor/router-factory.d.mts.map +1 -0
- package/esm/supervisor/router-factory.mjs +141 -0
- package/esm/supervisor/router-factory.mjs.map +1 -0
- package/esm/supervisor/router-prompt.d.mts +1 -1
- package/esm/supervisor/snapshot.d.mts +4 -10
- package/esm/supervisor/snapshot.d.mts.map +1 -1
- package/esm/supervisor/snapshot.mjs +8 -16
- package/esm/supervisor/snapshot.mjs.map +1 -1
- package/esm/supervisor/supervisor.mjs +1 -0
- package/esm/supervisor/supervisor.mjs.map +1 -1
- package/esm/system-prompt/index.mjs +6 -0
- package/esm/system-prompt/system-prompt.d.mts +51 -3
- package/esm/system-prompt/system-prompt.d.mts.map +1 -1
- package/esm/system-prompt/system-prompt.mjs +52 -6
- package/esm/system-prompt/system-prompt.mjs.map +1 -1
- package/esm/testing/matcher-logic.d.mts +76 -0
- package/esm/testing/matcher-logic.d.mts.map +1 -0
- package/esm/testing/matcher-logic.mjs +144 -0
- package/esm/testing/matcher-logic.mjs.map +1 -0
- package/esm/testing/matchers.d.mts +48 -0
- package/esm/testing/matchers.d.mts.map +1 -0
- package/esm/testing/matchers.mjs +37 -0
- package/esm/testing/matchers.mjs.map +1 -0
- package/esm/testing/register-lazy.d.mts +20 -0
- package/esm/testing/register-lazy.d.mts.map +1 -0
- package/esm/testing/register-lazy.mjs +24 -0
- package/esm/testing/register-lazy.mjs.map +1 -0
- package/esm/tool/executable-as-tool.d.mts +87 -0
- package/esm/tool/executable-as-tool.d.mts.map +1 -0
- package/esm/tool/executable-as-tool.mjs +81 -0
- package/esm/tool/executable-as-tool.mjs.map +1 -0
- package/esm/tool/index.d.mts +2 -1
- package/esm/tool/index.mjs +1 -0
- package/esm/workflow/as-tool.mjs +0 -6
- package/esm/workflow/as-tool.mjs.map +1 -1
- package/esm/workflow/engine.mjs +2 -2
- package/esm/workflow/snapshot.mjs +13 -7
- package/esm/workflow/snapshot.mjs.map +1 -1
- package/esm/workflow/step-runner.mjs +1 -1
- package/esm/workflow/workflow.mjs +1 -0
- package/esm/workflow/workflow.mjs.map +1 -1
- package/llms-full.txt +947 -42
- package/llms.txt +13 -8
- package/package.json +3 -3
- package/skills/README.md +25 -5
- package/skills/ai-basics/SKILL.md +18 -7
- package/skills/ai-dx-helpers/SKILL.md +180 -0
- package/skills/attach-ai-middleware/SKILL.md +32 -3
- package/skills/handle-ai-errors/SKILL.md +20 -6
- package/skills/manage-ai-stores/SKILL.md +127 -0
- package/skills/persist-ai-data/SKILL.md +21 -10
- package/skills/pick-ai-provider/SKILL.md +46 -12
- package/skills/run-ai-agent/SKILL.md +51 -2
- package/skills/run-orchestrator/SKILL.md +198 -0
- package/skills/run-planner/SKILL.md +68 -0
- package/skills/run-supervisor/SKILL.md +47 -2
- package/skills/use-ai-memory/SKILL.md +124 -0
- package/skills/write-system-prompt/SKILL.md +14 -1
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { AIError } from "../../errors/ai-error.mjs";
|
|
2
2
|
import { AgentResult } from "../result/agent-result.type.mjs";
|
|
3
|
+
import { SupervisorResult } from "../result/supervisor-result.type.mjs";
|
|
3
4
|
import { ToolInvokeResult } from "../../tool/tool.mjs";
|
|
4
|
-
import { MiddlewareExecuteContext, MiddlewareToolContext, MiddlewareTripContext } from "./middleware-context.type.mjs";
|
|
5
5
|
import { ModelResponse } from "../model.contract.mjs";
|
|
6
|
+
import { MiddlewareExecuteContext, MiddlewareSupervisorContext, MiddlewareToolContext, MiddlewareTripContext } from "./middleware-context.type.mjs";
|
|
6
7
|
|
|
7
8
|
//#region ../@warlock.js/ai/src/contracts/middleware/middleware.contract.d.ts
|
|
8
9
|
/**
|
|
@@ -59,6 +60,38 @@ type AgentMiddlewareToolHooks = {
|
|
|
59
60
|
after?(ctx: MiddlewareToolContext, result: ToolInvokeResult<unknown>): void | ToolInvokeResult<unknown> | Promise<void | ToolInvokeResult<unknown>>;
|
|
60
61
|
onError?(ctx: MiddlewareToolContext, error: AIError): void | ToolInvokeResult<unknown> | Promise<void | ToolInvokeResult<unknown>>;
|
|
61
62
|
};
|
|
63
|
+
/**
|
|
64
|
+
* `supervisor`-level hook map. Wraps the entire `supervisor.execute()`
|
|
65
|
+
* / `.stream()` / `.resume()` run — the supervisor-level peer of
|
|
66
|
+
* `AgentMiddlewareExecuteHooks`. Fires once per run, around the whole
|
|
67
|
+
* iteration loop and final result assembly.
|
|
68
|
+
*
|
|
69
|
+
* - `before` — fires once at the start of the run, before the first
|
|
70
|
+
* routing decision. Throw to abort the whole supervisor run before
|
|
71
|
+
* any iteration executes (cross-run budget pre-check, hard deny on
|
|
72
|
+
* a ctx flag). Return a `SupervisorResult` to short-circuit the run
|
|
73
|
+
* entirely with that result (run-level cache hit, fixture replay).
|
|
74
|
+
* - `after` — fires once at the end of a successful run with the
|
|
75
|
+
* final `SupervisorResult`. Optional return value replaces the
|
|
76
|
+
* result. Does not fire when the run threw before producing a
|
|
77
|
+
* result — use `onError` for that path. (A run that completed with
|
|
78
|
+
* `result.error` populated is still a "successful" return here, the
|
|
79
|
+
* same as agent-level `execute.after`.)
|
|
80
|
+
* - `onError`— fires once when the run threw before a result could be
|
|
81
|
+
* assembled. Optional `SupervisorResult` return recovers: the engine
|
|
82
|
+
* treats it as the real outcome and clears the error. `void` /
|
|
83
|
+
* omitted rethrow.
|
|
84
|
+
*
|
|
85
|
+
* **Type independence.** Like every other level, supervisor hooks are
|
|
86
|
+
* never generic over the supervisor's `TOutput` — a budget or audit
|
|
87
|
+
* middleware must be reusable across every supervisor in the app, so
|
|
88
|
+
* hooks see `SupervisorResult<unknown>`.
|
|
89
|
+
*/
|
|
90
|
+
type AgentMiddlewareSupervisorHooks = {
|
|
91
|
+
before?(ctx: MiddlewareSupervisorContext): void | SupervisorResult<unknown> | Promise<void | SupervisorResult<unknown>>;
|
|
92
|
+
after?(ctx: MiddlewareSupervisorContext, result: SupervisorResult<unknown>): void | SupervisorResult<unknown> | Promise<void | SupervisorResult<unknown>>;
|
|
93
|
+
onError?(ctx: MiddlewareSupervisorContext, error: AIError): void | SupervisorResult<unknown> | Promise<void | SupervisorResult<unknown>>;
|
|
94
|
+
};
|
|
62
95
|
/**
|
|
63
96
|
* Agent-level middleware — a composable interceptor that wraps agent
|
|
64
97
|
* execution at one or more of three granularities: the whole
|
|
@@ -134,7 +167,18 @@ type AgentMiddleware = {
|
|
|
134
167
|
execute?: AgentMiddlewareExecuteHooks;
|
|
135
168
|
trip?: AgentMiddlewareTripHooks;
|
|
136
169
|
tool?: AgentMiddlewareToolHooks;
|
|
170
|
+
/**
|
|
171
|
+
* Optional `supervisor`-level hook map — wraps an entire
|
|
172
|
+
* `supervisor.execute()` run, the supervisor-level peer of
|
|
173
|
+
* `execute`. Only fires when the middleware is registered on a
|
|
174
|
+
* supervisor (`ai.supervisor({ middleware: [...] })`); it is inert on
|
|
175
|
+
* a plain agent, exactly as `execute` / `trip` / `tool` are inert on
|
|
176
|
+
* a supervisor that never reaches the agent pipeline. A single
|
|
177
|
+
* middleware object may declare both `execute` and `supervisor` to
|
|
178
|
+
* cover both authoring surfaces.
|
|
179
|
+
*/
|
|
180
|
+
supervisor?: AgentMiddlewareSupervisorHooks;
|
|
137
181
|
};
|
|
138
182
|
//#endregion
|
|
139
|
-
export { AgentMiddleware, AgentMiddlewareExecuteHooks, AgentMiddlewareToolHooks, AgentMiddlewareTripHooks };
|
|
183
|
+
export { AgentMiddleware, AgentMiddlewareExecuteHooks, AgentMiddlewareSupervisorHooks, AgentMiddlewareToolHooks, AgentMiddlewareTripHooks };
|
|
140
184
|
//# sourceMappingURL=middleware.contract.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"middleware.contract.d.mts","names":[],"sources":["../../../../../../../../@warlock.js/ai/src/contracts/middleware/middleware.contract.ts"],"mappings":";;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"middleware.contract.d.mts","names":[],"sources":["../../../../../../../../@warlock.js/ai/src/contracts/middleware/middleware.contract.ts"],"mappings":";;;;;;;;;;;AAyBA;;;;;;;;;;KAAY,2BAAA;EACV,MAAA,EAAQ,GAAA,EAAK,wBAAA,UAAkC,OAAA;EAC/C,KAAA,EACE,GAAA,EAAK,wBAAA,EACL,MAAA,EAAQ,WAAA,mBACA,WAAA,YAAuB,OAAA,QAAe,WAAA;EAChD,OAAA,EACE,GAAA,EAAK,wBAAA,EACL,KAAA,EAAO,OAAA,UACC,WAAA,YAAuB,OAAA,QAAe,WAAA;AAAA;;;;;;;;;;;;;;KAgBtC,wBAAA;EACV,MAAA,EACE,GAAA,EAAK,qBAAA,UACG,aAAA,GAAgB,OAAA,QAAe,aAAA;EACzC,KAAA,EACE,GAAA,EAAK,qBAAA,EACL,QAAA,EAAU,aAAA,UACF,aAAA,GAAgB,OAAA,QAAe,aAAA;EACzC,OAAA,EACE,GAAA,EAAK,qBAAA,EACL,KAAA,EAAO,OAAA,UACC,aAAA,GAAgB,OAAA,QAAe,aAAA;AAAA;;;;;;AA3BkB;AAgB7D;;;;;;;KA2BY,wBAAA;EACV,MAAA,EACE,GAAA,EAAK,qBAAA,UAGH,gBAAA,YACA,OAAA,QAAe,gBAAA;EACnB,KAAA,EACE,GAAA,EAAK,qBAAA,EACL,MAAA,EAAQ,gBAAA,mBAGN,gBAAA,YACA,OAAA,QAAe,gBAAA;EACnB,OAAA,EACE,GAAA,EAAK,qBAAA,EACL,KAAA,EAAO,OAAA,UAGL,gBAAA,YACA,OAAA,QAAe,gBAAA;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;KA8BT,8BAAA;EACV,MAAA,EACE,GAAA,EAAK,2BAAA,UACG,gBAAA,YAA4B,OAAA,QAAe,gBAAA;EACrD,KAAA,EACE,GAAA,EAAK,2BAAA,EACL,MAAA,EAAQ,gBAAA,mBACA,gBAAA,YAA4B,OAAA,QAAe,gBAAA;EACrD,OAAA,EACE,GAAA,EAAK,2BAAA,EACL,KAAA,EAAO,OAAA,UACC,gBAAA,YAA4B,OAAA,QAAe,gBAAA;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAzClB;AA8BrC;;;;;;;;;;;;;;;;;KAyEY,eAAA;EA9DmC;;;;;EAoE7C,IAAA;EA5EqD;;;;;EAkFrD,GAAA;EACA,OAAA,GAAU,2BAAA;EACV,IAAA,GAAO,wBAAA;EACP,IAAA,GAAO,wBAAA;EAhFP;;;;;;;;;AAGqE;EAwFrE,UAAA,GAAa,8BAAA;AAAA"}
|
|
@@ -39,9 +39,43 @@ type ModelCallOptions = {
|
|
|
39
39
|
* `signal.aborted` flips. Adapters without support may ignore it;
|
|
40
40
|
* the agent still honors the signal at trip boundaries regardless.
|
|
41
41
|
*/
|
|
42
|
-
signal?: AbortSignal;
|
|
42
|
+
signal?: AbortSignal;
|
|
43
|
+
/**
|
|
44
|
+
* Reasoning / thinking-effort control for reasoning-capable models.
|
|
45
|
+
* `effort` maps to OpenAI `reasoning_effort`; `maxTokens` caps the
|
|
46
|
+
* Anthropic extended-thinking budget. Adapters whose
|
|
47
|
+
* `capabilities.reasoning` is absent/false ignore this rather than
|
|
48
|
+
* forwarding unsupported params. Absent = provider default.
|
|
49
|
+
*
|
|
50
|
+
* @example
|
|
51
|
+
* await model.complete(messages, { reasoning: { effort: "high" } });
|
|
52
|
+
*/
|
|
53
|
+
reasoning?: {
|
|
54
|
+
effort?: ReasoningEffort;
|
|
55
|
+
maxTokens?: number;
|
|
56
|
+
};
|
|
57
|
+
/**
|
|
58
|
+
* Vendor-neutral prompt-cache WRITE breakpoint hint. Adapters with
|
|
59
|
+
* `capabilities.promptCaching` translate `breakpoints` into provider
|
|
60
|
+
* cache markers (Anthropic `cache_control`); others ignore it.
|
|
61
|
+
* Read-side accounting (`Usage.cachedTokens`) works without this — it
|
|
62
|
+
* only controls WRITE placement. Absent = provider default (no
|
|
63
|
+
* explicit breakpoints).
|
|
64
|
+
*
|
|
65
|
+
* @example
|
|
66
|
+
* await model.complete(messages, { cacheControl: { breakpoints: 1 } });
|
|
67
|
+
*/
|
|
68
|
+
cacheControl?: {
|
|
69
|
+
breakpoints?: number;
|
|
70
|
+
}; /** Additional provider-specific options */
|
|
43
71
|
[key: string]: unknown;
|
|
44
72
|
};
|
|
73
|
+
/**
|
|
74
|
+
* Reasoning/thinking-effort levels for reasoning-capable models. Maps to
|
|
75
|
+
* the provider-native control (OpenAI `reasoning_effort`); adapters
|
|
76
|
+
* without reasoning support ignore it.
|
|
77
|
+
*/
|
|
78
|
+
type ReasoningEffort = "low" | "medium" | "high";
|
|
45
79
|
/**
|
|
46
80
|
* Declarative feature flags a `ModelContract` may expose so the agent can
|
|
47
81
|
* short-circuit redundant work when the provider already enforces a
|
|
@@ -68,6 +102,33 @@ type ModelCapabilities = {
|
|
|
68
102
|
* dropping them at the wire layer.
|
|
69
103
|
*/
|
|
70
104
|
vision?: boolean;
|
|
105
|
+
/**
|
|
106
|
+
* True when the adapter exposes provider reasoning / extended-thinking
|
|
107
|
+
* and forwards `ModelCallOptions.reasoning`. When false/absent the
|
|
108
|
+
* agent ignores reasoning options rather than sending unsupported
|
|
109
|
+
* params to the provider.
|
|
110
|
+
*/
|
|
111
|
+
reasoning?: boolean;
|
|
112
|
+
/**
|
|
113
|
+
* True when the adapter honors `ModelCallOptions.cacheControl` write
|
|
114
|
+
* breakpoints and reports `Usage.cachedTokens` / `Usage.cacheWriteTokens`.
|
|
115
|
+
* When false/absent the agent skips emitting cache breakpoints.
|
|
116
|
+
*/
|
|
117
|
+
promptCaching?: boolean;
|
|
118
|
+
/**
|
|
119
|
+
* True when the adapter accepts audio `ContentPart` input. When
|
|
120
|
+
* false/absent and the caller passes audio attachments, the agent
|
|
121
|
+
* throws upfront rather than dropping them at the wire layer (mirrors
|
|
122
|
+
* `vision`).
|
|
123
|
+
*/
|
|
124
|
+
audio?: boolean;
|
|
125
|
+
/**
|
|
126
|
+
* True when the adapter accepts PDF / document `ContentPart` input.
|
|
127
|
+
* When false/absent and the caller passes PDF attachments, the agent
|
|
128
|
+
* throws upfront rather than dropping them at the wire layer (mirrors
|
|
129
|
+
* `vision`).
|
|
130
|
+
*/
|
|
131
|
+
pdf?: boolean;
|
|
71
132
|
};
|
|
72
133
|
/**
|
|
73
134
|
* Full response from a non-streaming model call.
|
|
@@ -160,5 +221,5 @@ interface ModelContract {
|
|
|
160
221
|
stream(messages: Message[], options?: ModelCallOptions): AsyncIterable<ModelStreamChunk>;
|
|
161
222
|
}
|
|
162
223
|
//#endregion
|
|
163
|
-
export { ModelCallOptions, ModelCapabilities, ModelContract, ModelResponse, ModelStreamChunk };
|
|
224
|
+
export { ModelCallOptions, ModelCapabilities, ModelContract, ModelResponse, ModelStreamChunk, ReasoningEffort };
|
|
164
225
|
//# sourceMappingURL=model.contract.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model.contract.d.mts","names":[],"sources":["../../../../../../../@warlock.js/ai/src/contracts/model.contract.ts"],"mappings":";;;;;;;;;;AAqBA;;;;;;;;;;;;KAAY,gBAAA;EACV,WAAA;EACA,SAAA,
|
|
1
|
+
{"version":3,"file":"model.contract.d.mts","names":[],"sources":["../../../../../../../@warlock.js/ai/src/contracts/model.contract.ts"],"mappings":";;;;;;;;;;AAqBA;;;;;;;;;;;;KAAY,gBAAA;EACV,WAAA;EACA,SAAA,WAkBA;EAhBA,KAAA,GAAQ,UAAA;EA2BR;;;;;;;;EAlBA,cAAA,GAAiB,MAAA;EA6CP;;;;AAAe;AAY3B;EAlDE,MAAA,GAAS,WAAA;;;;;;;;;;AA4FN;EAjFH,SAAA;IACE,MAAA,GAAS,eAAA;IACT,SAAA;EAAA;EA+FK;;;;;;;;;;;EAlFP,YAAA;IACE,WAAA;EAAA,GA+FwB;EAAA,CA5FzB,GAAA;AAAA;;;;;;KAQS,eAAA;;;;;;;;;;;KAYA,iBAAA;EAuFgD;AAAA;AAgB5D;;;;EAhGE,gBAAA;EA2HmB;;;;;;;EAnHnB,MAAA;EAwHsE;;;;;;EAjHtE,SAAA;EAuGmB;;;;;EAjGnB,aAAA;EAsG2D;;;;;;EA/F3D,KAAA;EAoGyD;;;AAA8B;;;EA7FvF,GAAA;AAAA;;;;;;;;;;;KAaU,aAAA;EACV,OAAA;EACA,YAAA,EAAc,YAAA;EACd,KAAA,EAAO,KAAA;EAEP,SAAA,GAAY,oBAAA;AAAA;;;;;;;;;;KAYF,gBAAA;EACN,IAAA;EAAe,OAAA;AAAA;EAEf,IAAA;EACA,EAAA;EACA,IAAA;EACA,KAAA;;;;;;;EAOA,gBAAA,GAAmB,MAAA;AAAA;EAEnB,IAAA;EAAc,YAAA,EAAc,YAAA;EAAc,KAAA,EAAO,KAAA;AAAA;;;;;;;;;;;;;;;UAgBtC,aAAA;;WAEN,IAAA;;WAEA,QAAA;;;;;;WAMA,YAAA,GAAe,iBAAA;;;;;;;;;;;WAYf,OAAA,GAAU,YAAA;;;;EAKnB,QAAA,CAAS,QAAA,EAAU,OAAA,IAAW,OAAA,GAAU,gBAAA,GAAmB,OAAA,CAAQ,aAAA;;;;EAKnE,MAAA,CAAO,QAAA,EAAU,OAAA,IAAW,OAAA,GAAU,gBAAA,GAAmB,aAAA,CAAc,gBAAA;AAAA"}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
//#region ../@warlock.js/ai/src/contracts/orchestrator/checkpoint-store.contract.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* A single persisted orchestrator session checkpoint. One row is
|
|
4
|
+
* written per settled turn — the primary key is
|
|
5
|
+
* `(orchestrator_name, session_id, turn_index)`, append-only from v1
|
|
6
|
+
* (orchestrator.md §8.2 / §8.6). The latest row (highest
|
|
7
|
+
* `turn_index`) is the live session state.
|
|
8
|
+
*
|
|
9
|
+
* All fields are JSON-serializable. `state` is `unknown` because its
|
|
10
|
+
* shape is the orchestrator's `TState`, validated upstream — the store
|
|
11
|
+
* only round-trips it.
|
|
12
|
+
*
|
|
13
|
+
* Naming follows the on-disk DDL columns verbatim (snake_case) so the
|
|
14
|
+
* record maps 1:1 onto the reference table in orchestrator.md §8.6 and
|
|
15
|
+
* the pg driver can read/write it without a field-rename layer.
|
|
16
|
+
*/
|
|
17
|
+
type CheckpointRecord = {
|
|
18
|
+
/** Orchestrator definition name — first PK segment, partitions sessions across orchestrators. */orchestrator_name: string; /** Caller-owned session identifier — second PK segment. */
|
|
19
|
+
session_id: string; /** Monotonic turn counter — third PK segment; the row with the highest value is live. */
|
|
20
|
+
turn_index: number; /** Post-merge session accumulator. JSON-serializable; shape is the orchestrator's `TState`. */
|
|
21
|
+
state: unknown; /** Summary of the turn's dispatch decision — a single intent, a fan-out list, or `null` on a turn that routed nowhere. */
|
|
22
|
+
last_route: string | string[] | null; /** Structural fingerprint of the orchestrator definition at write time; compared on load for drift detection. */
|
|
23
|
+
signature: string; /** Informational `config.version` tag, or `null` when unset. Metadata only — never drives behavior. */
|
|
24
|
+
version: string | null; /** Exclusive turn index through which compaction has been applied, or `null` when no compaction has landed. */
|
|
25
|
+
summarized_through: number | null; /** ISO timestamp when a compaction lock was taken, or `null` when no lock is held. */
|
|
26
|
+
lock_acquired_at: string | null; /** ISO timestamp when the compaction lock expires, or `null` when no lock is held. */
|
|
27
|
+
lock_expires_at: string | null; /** ISO timestamp written server-side when the row was persisted. */
|
|
28
|
+
saved_at: string;
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* Durable store for orchestrator session state (orchestrator.md §8.2).
|
|
32
|
+
*
|
|
33
|
+
* Owns the checkpoint rows that let `ai.orchestrator()` rehydrate a
|
|
34
|
+
* session across calls: `state`, `turn_index`, drift `signature`,
|
|
35
|
+
* `version`, `last_route`, compaction progress, and lock metadata.
|
|
36
|
+
* Distinct from {@link import("./snapshot-store.contract").SnapshotStore},
|
|
37
|
+
* which persists the per-turn internal supervisor run for
|
|
38
|
+
* `iterate: true` mid-turn resume.
|
|
39
|
+
*
|
|
40
|
+
* Implementations: `ai.checkpoint.{memory,pg,redis}()`. The memory
|
|
41
|
+
* impl ships in v1; pg/redis follow. Schema is never auto-migrated —
|
|
42
|
+
* {@link CheckpointStore.schema} returns a DDL string the dev runs
|
|
43
|
+
* through their own migration tool (§8.5).
|
|
44
|
+
*/
|
|
45
|
+
interface CheckpointStore {
|
|
46
|
+
/**
|
|
47
|
+
* Load the latest checkpoint (highest `turn_index`) for a session,
|
|
48
|
+
* or `undefined` for a brand-new session the store has never seen.
|
|
49
|
+
*/
|
|
50
|
+
load(orchestratorName: string, sessionId: string): Promise<CheckpointRecord | undefined>;
|
|
51
|
+
/**
|
|
52
|
+
* Persist a fresh checkpoint row. Append-only — never overwrites a
|
|
53
|
+
* prior `turn_index`. The key is derived from
|
|
54
|
+
* `(orchestrator_name, session_id, turn_index)` on the record.
|
|
55
|
+
*/
|
|
56
|
+
save(record: CheckpointRecord): Promise<void>;
|
|
57
|
+
/**
|
|
58
|
+
* Delete every checkpoint row for a session, ending it.
|
|
59
|
+
*/
|
|
60
|
+
delete(orchestratorName: string, sessionId: string): Promise<void>;
|
|
61
|
+
/**
|
|
62
|
+
* List the session ids known for an orchestrator, optionally
|
|
63
|
+
* filtered by a session-id prefix. Used by the production boot-drain
|
|
64
|
+
* loop (§9.3). Optional — stores that can't enumerate omit it.
|
|
65
|
+
*/
|
|
66
|
+
list?(orchestratorName: string, prefix?: string): Promise<string[]>;
|
|
67
|
+
/**
|
|
68
|
+
* Drop every row for a session whose `turn_index` is strictly below
|
|
69
|
+
* `keepBeforeTurnIndex`, honoring `keepSnapshots` retention (§4 Phase
|
|
70
|
+
* 6, Q20). Called after each settled turn's save. Optional — stores
|
|
71
|
+
* that prune in their own dialect (or never prune) omit it; the engine
|
|
72
|
+
* skips pruning when it is absent.
|
|
73
|
+
*/
|
|
74
|
+
prune?(orchestratorName: string, sessionId: string, keepBeforeTurnIndex: number): Promise<void>;
|
|
75
|
+
/**
|
|
76
|
+
* Return the DDL string for this store's backing table. The dev runs
|
|
77
|
+
* it through their migration tool; the framework never auto-migrates
|
|
78
|
+
* (§8.5).
|
|
79
|
+
*/
|
|
80
|
+
schema(): string;
|
|
81
|
+
/**
|
|
82
|
+
* Optional idle-TTL knob. Stores that support row expiry honor it;
|
|
83
|
+
* others may no-op.
|
|
84
|
+
*/
|
|
85
|
+
setOptions?(options: {
|
|
86
|
+
ttl?: number;
|
|
87
|
+
}): void;
|
|
88
|
+
}
|
|
89
|
+
//#endregion
|
|
90
|
+
export { CheckpointRecord, CheckpointStore };
|
|
91
|
+
//# sourceMappingURL=checkpoint-store.contract.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"checkpoint-store.contract.d.mts","names":[],"sources":["../../../../../../../../@warlock.js/ai/src/contracts/orchestrator/checkpoint-store.contract.ts"],"mappings":";;AAeA;;;;;;;;;;;;;;KAAY,gBAAA;EAsBF,iGApBR,iBAAA,UAsCe;EApCf,UAAA;EAEA,UAAA,UA0CG;EAxCH,KAAA,WA+CgC;EA7ChC,UAAA,4BAyDkD;EAvDlD,SAAA,UAoEU;EAlEV,OAAA,iBA+BA;EA7BA,kBAAA,iBA+BE;EA7BF,gBAAA,iBA8BW;EA5BX,eAAA,iBAmCa;EAjCb,QAAA;AAAA;;;;;;;;;;;;;;;;UAkBe,eAAA;EAqDH;;AAAyB;;EAhDrC,IAAA,CACE,gBAAA,UACA,SAAA,WACC,OAAA,CAAQ,gBAAA;;;;;;EAOX,IAAA,CAAK,MAAA,EAAQ,gBAAA,GAAmB,OAAA;;;;EAKhC,MAAA,CAAO,gBAAA,UAA0B,SAAA,WAAoB,OAAA;;;;;;EAOrD,IAAA,EAAM,gBAAA,UAA0B,MAAA,YAAkB,OAAA;;;;;;;;EASlD,KAAA,EACE,gBAAA,UACA,SAAA,UACA,mBAAA,WACC,OAAA;;;;;;EAOH,MAAA;;;;;EAMA,UAAA,EAAY,OAAA;IAAW,GAAA;EAAA;AAAA"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { PgClientLike, RedisClientLike, SnapshotStore } from "./snapshot-store.contract.mjs";
|
|
2
|
+
import { CheckpointRecord, CheckpointStore } from "./checkpoint-store.contract.mjs";
|
|
3
|
+
import { OrchestratorCommands } from "./orchestrator-commands.type.mjs";
|
|
4
|
+
import { OrchestratorEvent, OrchestratorEventHandler, OrchestratorEventHandlers, OrchestratorEventMap, OrchestratorEventName } from "./orchestrator-event.type.mjs";
|
|
5
|
+
import { OrchestratorExecuteOptions, OrchestratorResumeOptions } from "./orchestrator-execute-options.type.mjs";
|
|
6
|
+
import { OrchestratorAsToolOptions, OrchestratorContract, OrchestratorSessionScope, SessionContextOverrides } from "./orchestrator.contract.mjs";
|
|
7
|
+
import { OrchestratorConfig, OrchestratorMemoryConfig, SummarizeCallback, SummarizeConfig } from "./orchestrator-config.type.mjs";
|
|
8
|
+
import { SessionContract } from "./session.contract.mjs";
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { Message } from "../conversation-message.type.mjs";
|
|
2
|
+
|
|
3
|
+
//#region ../@warlock.js/ai/src/contracts/orchestrator/orchestrator-commands.type.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Typed command surface for `orchestrator.command(name, args)` (design
|
|
6
|
+
* §11). Each key is a command name; its value declares the command's
|
|
7
|
+
* `args` and `result` shapes so the contract's `command<K>` method is
|
|
8
|
+
* fully typed against the map.
|
|
9
|
+
*
|
|
10
|
+
* v1 ships exactly one built-in command, `compact`. v2 user commands
|
|
11
|
+
* attach via module augmentation of this type — declaring additional
|
|
12
|
+
* keys in a consumer's own `.d.ts` widens the map without a framework
|
|
13
|
+
* release.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* const result = await orchestrator.command("compact", {
|
|
17
|
+
* sessionId,
|
|
18
|
+
* history,
|
|
19
|
+
* });
|
|
20
|
+
* // result: { summary, replacesFromIndex, replacesToIndex }
|
|
21
|
+
*/
|
|
22
|
+
type OrchestratorCommands = {
|
|
23
|
+
/**
|
|
24
|
+
* Force a manual compaction of the supplied session history outside
|
|
25
|
+
* the automatic post-turn trigger. `result` is structurally
|
|
26
|
+
* identical to `CompactionResult` (kept per the literal §11 shape).
|
|
27
|
+
*/
|
|
28
|
+
compact: {
|
|
29
|
+
args: {
|
|
30
|
+
sessionId: string;
|
|
31
|
+
history: Message[];
|
|
32
|
+
signal?: AbortSignal;
|
|
33
|
+
};
|
|
34
|
+
result: {
|
|
35
|
+
summary: Message;
|
|
36
|
+
replacesFromIndex: number;
|
|
37
|
+
replacesToIndex: number;
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
//#endregion
|
|
42
|
+
export { OrchestratorCommands };
|
|
43
|
+
//# sourceMappingURL=orchestrator-commands.type.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"orchestrator-commands.type.d.mts","names":[],"sources":["../../../../../../../../@warlock.js/ai/src/contracts/orchestrator/orchestrator-commands.type.ts"],"mappings":";;;;;AAoBA;;;;;;;;;;;;;;;;KAAY,oBAAA;EASG;;;;AAEM;EALnB,OAAA;IACE,IAAA;MAAQ,SAAA;MAAmB,OAAA,EAAS,OAAA;MAAW,MAAA,GAAS,WAAA;IAAA;IACxD,MAAA;MACE,OAAA,EAAS,OAAA;MACT,iBAAA;MACA,eAAA;IAAA;EAAA;AAAA"}
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import { Message } from "../conversation-message.type.mjs";
|
|
2
|
+
import { AgentContract } from "../agent/agent.contract.mjs";
|
|
3
|
+
import { SnapshotStore } from "./snapshot-store.contract.mjs";
|
|
4
|
+
import { ModelContract } from "../model.contract.mjs";
|
|
5
|
+
import { SystemPromptContract } from "../system-prompt.contract.mjs";
|
|
6
|
+
import { RouteContext } from "../supervisor/route-context.type.mjs";
|
|
7
|
+
import { SupervisorIntentValue } from "../supervisor/intent-entry.type.mjs";
|
|
8
|
+
import { Next } from "../supervisor/next.type.mjs";
|
|
9
|
+
import { RouterEntry } from "../supervisor/router-entry.type.mjs";
|
|
10
|
+
import { EvaluateContext, EvaluateResult } from "../supervisor/evaluate-context.type.mjs";
|
|
11
|
+
import { CompactionResult } from "../result/orchestrator-result.type.mjs";
|
|
12
|
+
import { MemoryTier } from "../memory/memory-item.type.mjs";
|
|
13
|
+
import { MemoryContract } from "../memory/memory.contract.mjs";
|
|
14
|
+
import { CheckpointStore } from "./checkpoint-store.contract.mjs";
|
|
15
|
+
import { OrchestratorEventHandlers } from "./orchestrator-event.type.mjs";
|
|
16
|
+
import { StandardSchemaV1 } from "@standard-schema/spec";
|
|
17
|
+
|
|
18
|
+
//#region ../@warlock.js/ai/src/contracts/orchestrator/orchestrator-config.type.d.ts
|
|
19
|
+
/**
|
|
20
|
+
* Object form of `OrchestratorConfig.summarize` (design §12.4) — the
|
|
21
|
+
* automatic post-turn compaction policy. Fires after `afterTurns`,
|
|
22
|
+
* keeps the most recent `keep` messages, and summarizes the rest with
|
|
23
|
+
* `summarizer`. `onCompact` lets the dev apply the produced summary to
|
|
24
|
+
* their own message store; `lock` bounds how long a turn waits on the
|
|
25
|
+
* compaction lock before failing open.
|
|
26
|
+
*/
|
|
27
|
+
type SummarizeConfig = {
|
|
28
|
+
/** Trigger compaction once the turn count crosses this threshold. */afterTurns?: number; /** Number of most-recent messages to keep verbatim (not summarized). Default 8. */
|
|
29
|
+
keep?: number; /** Model used to produce the summary. Defaults to the orchestrator's own model. */
|
|
30
|
+
summarizer?: ModelContract;
|
|
31
|
+
/**
|
|
32
|
+
* Applies the produced compaction to the dev's message store. When
|
|
33
|
+
* supplied the orchestrator does not surface `result.compaction` for
|
|
34
|
+
* the dev to apply manually.
|
|
35
|
+
*/
|
|
36
|
+
onCompact?: (compaction: CompactionResult, ctx: {
|
|
37
|
+
sessionId: string;
|
|
38
|
+
}) => Promise<void> | void; /** Compaction-lock tuning. `maxWait` caps the per-turn wait in ms. */
|
|
39
|
+
lock?: {
|
|
40
|
+
maxWait?: number;
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* Callback form of `OrchestratorConfig.summarize` (design §12.4). Full
|
|
45
|
+
* control: receives the session history, returns the compaction result
|
|
46
|
+
* directly. Use when the built-in `SummarizeConfig` policy is too
|
|
47
|
+
* coarse.
|
|
48
|
+
*/
|
|
49
|
+
type SummarizeCallback = (history: Message[]) => Promise<CompactionResult> | CompactionResult;
|
|
50
|
+
/**
|
|
51
|
+
* Per-turn memory wiring for `OrchestratorConfig.memory` (memory core
|
|
52
|
+
* M2). The `store` is the {@link MemoryContract} the orchestrator
|
|
53
|
+
* recalls from before each dispatch and remembers into after each turn
|
|
54
|
+
* settles. `recall` tunes the pre-dispatch recall (how many memories,
|
|
55
|
+
* the similarity floor, an optional single-tier restriction); `remember`
|
|
56
|
+
* toggles whether the turn outcome is written back. When `recall.k` is 0
|
|
57
|
+
* the orchestrator skips recall entirely (write-only memory); when
|
|
58
|
+
* `remember` is `false` it recalls but never writes (read-only memory).
|
|
59
|
+
*
|
|
60
|
+
* The recalled memories are injected into the request-scoped `context`
|
|
61
|
+
* bag under the `injectKey` (default `"memories"`) so every route /
|
|
62
|
+
* router / evaluate / dispatch callback reads them at
|
|
63
|
+
* `ctx.context[injectKey]` — memory never mutates the prompt itself, the
|
|
64
|
+
* surfacing point stays explicit (the same contract `MemoryContract`
|
|
65
|
+
* documents).
|
|
66
|
+
*/
|
|
67
|
+
type OrchestratorMemoryConfig = {
|
|
68
|
+
/** The memory store recalled-from before dispatch and remembered-into after. */store: MemoryContract;
|
|
69
|
+
/**
|
|
70
|
+
* Pre-dispatch recall tuning. `k` caps the injected count (0 disables
|
|
71
|
+
* recall — write-only memory); `threshold` raises the semantic
|
|
72
|
+
* similarity floor; `tier` restricts recall to a single tier. Omit for
|
|
73
|
+
* the memory's own configured defaults.
|
|
74
|
+
*/
|
|
75
|
+
recall?: {
|
|
76
|
+
k?: number;
|
|
77
|
+
threshold?: number;
|
|
78
|
+
tier?: MemoryTier;
|
|
79
|
+
};
|
|
80
|
+
/**
|
|
81
|
+
* Write the settled turn outcome back into memory after a clean turn.
|
|
82
|
+
* Default `true`. Set `false` for a read-only memory that recalls but
|
|
83
|
+
* never accumulates. Cancelled / failed turns never remember (they
|
|
84
|
+
* revert — §17), regardless of this flag.
|
|
85
|
+
*/
|
|
86
|
+
remember?: boolean;
|
|
87
|
+
/**
|
|
88
|
+
* Tier the remembered turn outcome lands in. Omit to use the memory's
|
|
89
|
+
* own `defaultTier`. Pass `"semantic"` to durably accumulate turns for
|
|
90
|
+
* later cross-session recall.
|
|
91
|
+
*/
|
|
92
|
+
rememberTier?: MemoryTier;
|
|
93
|
+
/**
|
|
94
|
+
* Key the recalled memories are injected under inside the per-turn
|
|
95
|
+
* `context` bag. Callbacks read them at `ctx.context[injectKey]` as a
|
|
96
|
+
* `RecalledMemory[]`. Default `"memories"`.
|
|
97
|
+
*/
|
|
98
|
+
injectKey?: string;
|
|
99
|
+
};
|
|
100
|
+
/**
|
|
101
|
+
* Factory config for `ai.orchestrator(config)` (design §15.2).
|
|
102
|
+
*
|
|
103
|
+
* The "what runs" fields (`intents`, `route` / `router`, `evaluate`,
|
|
104
|
+
* `state`, `output`, `initialAgent`, `maxIterations`) are the
|
|
105
|
+
* supervisor's surface spread directly — the orchestrator builds the
|
|
106
|
+
* supervisor lazily per turn and delegates to it. The remaining fields
|
|
107
|
+
* are orchestrator-specific: session-scoped history windowing,
|
|
108
|
+
* compaction, snapshot retention, and the two durable stores.
|
|
109
|
+
*
|
|
110
|
+
* `TState` defaults to `TOutput` for the common case where the working
|
|
111
|
+
* session state IS the output shape. `TIntents` captures the literal
|
|
112
|
+
* intent map so `ctx.intents.<TAB>` autocompletes against real keys.
|
|
113
|
+
*
|
|
114
|
+
* @example
|
|
115
|
+
* const supportBot = ai.orchestrator<SessionState>({
|
|
116
|
+
* name: "refund-support",
|
|
117
|
+
* intents: { classify, lookup, process, compose },
|
|
118
|
+
* route: (ctx) => (ctx.iteration === 0 ? "classify" : END),
|
|
119
|
+
* iterate: true,
|
|
120
|
+
* historyWindow: { router: 5, agents: 20 },
|
|
121
|
+
* checkpointStore: ai.checkpoint.pg({ client: pg }),
|
|
122
|
+
* snapshotStore: ai.snapshot.pg({ client: pg }),
|
|
123
|
+
* });
|
|
124
|
+
*/
|
|
125
|
+
type OrchestratorConfig<TOutput, TState = TOutput, TIntents extends Record<string, SupervisorIntentValue> = Record<string, SupervisorIntentValue>> = {
|
|
126
|
+
/** Stable identifier — used in logs, events, checkpoints, signature. */name: string; /** Dev-curated version string. Metadata only (§10.2) — never parsed. */
|
|
127
|
+
version?: string; /** Prepended to the router agent's system prompt (router mode only). */
|
|
128
|
+
systemPrompt?: SystemPromptContract | string; /** Dispatchable units keyed by intent name (supervisor surface). */
|
|
129
|
+
intents: TIntents; /** Deterministic per-turn dispatch. Mutually exclusive with `router`. */
|
|
130
|
+
route?: (ctx: RouteContext<TState>) => Next | Promise<Next>; /** LLM-driven dispatch. Mutually exclusive with `route`. */
|
|
131
|
+
router?: AgentContract<unknown> | RouterEntry<TState>; /** Retrospective per-turn verdict callback. */
|
|
132
|
+
evaluate?: (ctx: EvaluateContext<TState>) => EvaluateResult | Promise<EvaluateResult>; /** Initial seed for the session-state accumulator. */
|
|
133
|
+
state?: TState; /** Final-state schema; validated before populating `result.data`. */
|
|
134
|
+
output?: StandardSchemaV1<TOutput>; /** Dispatch this intent on turn 0, skipping the first route/router call. */
|
|
135
|
+
initialAgent?: string; /** Hard cap on in-turn iterations — only consulted when `iterate: true`. Default 10. */
|
|
136
|
+
maxIterations?: number;
|
|
137
|
+
/**
|
|
138
|
+
* Delegate each turn to a real internal supervisor for in-turn
|
|
139
|
+
* iteration. Default `false` — single dispatch per turn. Requires
|
|
140
|
+
* `snapshotStore` (or `ai.config({ defaultSnapshotStore })`) when set.
|
|
141
|
+
*/
|
|
142
|
+
iterate?: boolean;
|
|
143
|
+
/**
|
|
144
|
+
* Per-role history windowing applied to the dev-supplied history
|
|
145
|
+
* before each turn. A number keeps the last N messages; a callback
|
|
146
|
+
* takes full control of the slice.
|
|
147
|
+
*/
|
|
148
|
+
historyWindow?: {
|
|
149
|
+
router?: number | ((messages: Message[]) => Message[]);
|
|
150
|
+
agents?: number | ((messages: Message[]) => Message[]);
|
|
151
|
+
}; /** Automatic post-turn compaction policy (§12). */
|
|
152
|
+
summarize?: SummarizeConfig | SummarizeCallback; /** Number of turn snapshots to retain per session. Default 100. */
|
|
153
|
+
keepSnapshots?: number | "all"; /** Durable session-state store. Falls back to `ai.config({ defaultCheckpointStore })`. */
|
|
154
|
+
checkpointStore?: CheckpointStore; /** Internal-supervisor snapshot store. Required when `iterate: true`. */
|
|
155
|
+
snapshotStore?: SnapshotStore;
|
|
156
|
+
/**
|
|
157
|
+
* Optional per-turn memory (memory core M2). When set, the
|
|
158
|
+
* orchestrator recalls relevant memories for the turn input and injects
|
|
159
|
+
* them into the dispatch context (`ctx.context[injectKey]`) before
|
|
160
|
+
* routing, then remembers the settled turn outcome afterward. Omit for
|
|
161
|
+
* the existing behavior — orchestrators without memory are unchanged.
|
|
162
|
+
* Accepts a bare {@link MemoryContract} (recall + remember with
|
|
163
|
+
* defaults) or an {@link OrchestratorMemoryConfig} for finer control.
|
|
164
|
+
*/
|
|
165
|
+
memory?: MemoryContract | OrchestratorMemoryConfig; /** Definition-level event handlers — tier 1 of the 3-tier model. */
|
|
166
|
+
on?: OrchestratorEventHandlers;
|
|
167
|
+
};
|
|
168
|
+
//#endregion
|
|
169
|
+
export { OrchestratorConfig, OrchestratorMemoryConfig, SummarizeCallback, SummarizeConfig };
|
|
170
|
+
//# sourceMappingURL=orchestrator-config.type.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"orchestrator-config.type.d.mts","names":[],"sources":["../../../../../../../../@warlock.js/ai/src/contracts/orchestrator/orchestrator-config.type.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;AAyBA;;;;;;KAAY,eAAA;EAeE,qEAbZ,UAAA,WAEA;EAAA,IAAA,WAEa;EAAb,UAAA,GAAa,aAAA;EAOC;;;;;EADd,SAAA,IACE,UAAA,EAAY,gBAAA,EACZ,GAAA;IAAO,SAAA;EAAA,MACJ,OAAA,eAEW;EAAhB,IAAA;IAAS,OAAA;EAAA;AAAA;;;;;;;KASC,iBAAA,IACV,OAAA,EAAS,OAAA,OACN,OAAA,CAAQ,gBAAA,IAAoB,gBAAA;;;;;AAAgB;AAmBjD;;;;;;;;;;;;KAAY,wBAAA;EAYR,gFAVF,KAAA,EAAO,cAAA;EAkBP;;;;;AAYS;EAvBT,MAAA;IACE,CAAA;IACA,SAAA;IACA,IAAA,GAAO,UAAA;EAAA;EAmDQ;;;;;;EA3CjB,QAAA;EA0DuC;;;;;EApDvC,YAAA,GAAe,UAAA;EAyDQ;;;;;EAnDvB,SAAA;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;KA4BU,kBAAA,mBAED,OAAA,mBACQ,MAAA,SAAe,qBAAA,IAAyB,MAAA,SAEvD,qBAAA;EAWF,wEAPA,IAAA,UASA;EAPA,OAAA,WAO2B;EAL3B,YAAA,GAAe,oBAAA,WAKwB;EAFvC,OAAA,EAAS,QAAA,EAE6C;EAAtD,KAAA,IAAS,GAAA,EAAK,YAAA,CAAa,MAAA,MAAY,IAAA,GAAO,OAAA,CAAQ,IAAA,GAE7C;EAAT,MAAA,GAAS,aAAA,YAAyB,WAAA,CAAY,MAAA,GAAA;EAE9C,QAAA,IACE,GAAA,EAAK,eAAA,CAAgB,MAAA,MAClB,cAAA,GAAiB,OAAA,CAAQ,cAAA,GADvB;EAGP,KAAA,GAAQ,MAAA,EAHN;EAKF,MAAA,GAAS,gBAAA,CAAiB,OAAA,GAJJ;EAMtB,YAAA,WAJA;EAMA,aAAA;EAJA;;;;;EAWA,OAAA;EAMA;;;;;EAAA,aAAA;IACE,MAAA,cAAoB,QAAA,EAAU,OAAA,OAAc,OAAA;IAC5C,MAAA,cAAoB,QAAA,EAAU,OAAA,OAAc,OAAA;EAAA,GAG9C;EAAA,SAAA,GAAY,eAAA,GAAkB,iBAAA,EAAA;EAE9B,aAAA,mBAGA;EAAA,eAAA,GAAkB,eAAA,EAElB;EAAA,aAAA,GAAgB,aAAA;EAUhB;;;;;;AAG8B;;;EAH9B,MAAA,GAAS,cAAA,GAAiB,wBAAA;EAG1B,EAAA,GAAK,yBAAA;AAAA"}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { EventIdentity } from "../events/event-identity.type.mjs";
|
|
2
|
+
import { CompactionResult } from "../result/orchestrator-result.type.mjs";
|
|
3
|
+
|
|
4
|
+
//#region ../@warlock.js/ai/src/contracts/orchestrator/orchestrator-event.type.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* Per-turn lifecycle event payloads emitted under the `orchestrator.*`
|
|
7
|
+
* namespace (design §14). Three-tier subscription — definition,
|
|
8
|
+
* instance, per-call — fires in that order on every emission, mirroring
|
|
9
|
+
* the supervisor + workflow model.
|
|
10
|
+
*
|
|
11
|
+
* Child events (`supervisor.*` / `agent.*`) bubble up UNMODIFIED under
|
|
12
|
+
* their own identity (§14.2) and are intentionally NOT folded into this
|
|
13
|
+
* map — subscribers filter the bubbled stream by namespace. This map
|
|
14
|
+
* carries only the orchestrator's own session-scoped events.
|
|
15
|
+
*
|
|
16
|
+
* Until the shared `contracts/events` taxonomy grows an
|
|
17
|
+
* `orchestrator.*` slice, this local map is the source of truth for the
|
|
18
|
+
* orchestrator `on`/`off`/`stream` surface; it is structured to be
|
|
19
|
+
* promoted into `contracts/events/event-map.type.ts` later without a
|
|
20
|
+
* shape change (Q14 event taxonomy is a v1 design item; see §14).
|
|
21
|
+
*/
|
|
22
|
+
type OrchestratorEventMap = {
|
|
23
|
+
/** Turn N begins (before phase 1). */"orchestrator.turn.starting": {
|
|
24
|
+
sessionId: string;
|
|
25
|
+
turnIndex: number;
|
|
26
|
+
}; /** Phase 1 — checkpoint loaded (or seeded empty on first call). */
|
|
27
|
+
"orchestrator.session.loaded": {
|
|
28
|
+
sessionId: string;
|
|
29
|
+
turnIndex: number;
|
|
30
|
+
found: boolean;
|
|
31
|
+
}; /** Phase 2 — drift signature compared against the loaded checkpoint. */
|
|
32
|
+
"orchestrator.drift.checked": {
|
|
33
|
+
sessionId: string;
|
|
34
|
+
signature: string;
|
|
35
|
+
drifted: boolean;
|
|
36
|
+
}; /** Phase 3 — waiting on the compaction lock (only when locked). */
|
|
37
|
+
"orchestrator.lock.waiting": {
|
|
38
|
+
sessionId: string;
|
|
39
|
+
waitedMs: number;
|
|
40
|
+
}; /** Phase 4 — history windowed for router + agents. */
|
|
41
|
+
"orchestrator.history.windowed": {
|
|
42
|
+
sessionId: string;
|
|
43
|
+
messageCount: number;
|
|
44
|
+
}; /** Phase 5 — route/router produced a dispatch decision. */
|
|
45
|
+
"orchestrator.turn.routed": {
|
|
46
|
+
sessionId: string;
|
|
47
|
+
turnIndex: number;
|
|
48
|
+
source: "route" | "router" | "intent.next";
|
|
49
|
+
raw: unknown;
|
|
50
|
+
}; /** Per-token streaming during the dispatched primitive's run. */
|
|
51
|
+
"orchestrator.turn.streaming": {
|
|
52
|
+
sessionId: string;
|
|
53
|
+
delta: string;
|
|
54
|
+
}; /** Phase 6 — checkpoint row written for the settled turn. */
|
|
55
|
+
"orchestrator.checkpoint.persisted": {
|
|
56
|
+
sessionId: string;
|
|
57
|
+
turnIndex: number;
|
|
58
|
+
}; /** Phase 7 — compaction trigger fired (only when triggered). */
|
|
59
|
+
"orchestrator.compaction.suggested": {
|
|
60
|
+
sessionId: string;
|
|
61
|
+
compaction: CompactionResult;
|
|
62
|
+
}; /** Phase 7 — `onCompact` ran successfully and the summary applied. */
|
|
63
|
+
"orchestrator.compaction.applied": {
|
|
64
|
+
sessionId: string;
|
|
65
|
+
compaction: CompactionResult;
|
|
66
|
+
};
|
|
67
|
+
/**
|
|
68
|
+
* Phase 7 — the summarizer or `onCompact` threw; compaction was skipped
|
|
69
|
+
* for this turn and the session keeps running with unchanged history
|
|
70
|
+
* (§4 Phase 7 skip-and-log). `phase` distinguishes which step failed.
|
|
71
|
+
*/
|
|
72
|
+
"orchestrator.compaction.failed": {
|
|
73
|
+
sessionId: string;
|
|
74
|
+
phase: "summarize" | "onCompact";
|
|
75
|
+
error: unknown;
|
|
76
|
+
}; /** Terminal — turn ran to a usable result. */
|
|
77
|
+
"orchestrator.turn.completed": {
|
|
78
|
+
sessionId: string;
|
|
79
|
+
turnIndex: number;
|
|
80
|
+
}; /** Terminal — turn failed; the typed cause rides on the result. */
|
|
81
|
+
"orchestrator.turn.failed": {
|
|
82
|
+
sessionId: string;
|
|
83
|
+
turnIndex: number;
|
|
84
|
+
}; /** Terminal — caller aborted the turn via `AbortSignal`. */
|
|
85
|
+
"orchestrator.turn.cancelled": {
|
|
86
|
+
sessionId: string;
|
|
87
|
+
turnIndex: number;
|
|
88
|
+
}; /** Non-terminal — session paused waiting for the next user turn (§15.6). */
|
|
89
|
+
"orchestrator.turn.awaiting-input": {
|
|
90
|
+
sessionId: string;
|
|
91
|
+
turnIndex: number;
|
|
92
|
+
};
|
|
93
|
+
};
|
|
94
|
+
/**
|
|
95
|
+
* Discriminated union of every orchestrator event, each tagged with a
|
|
96
|
+
* `type` literal and carrying its payload plus run `EventIdentity`.
|
|
97
|
+
* This is the `TEvent` parameter for `orchestrator.stream()`.
|
|
98
|
+
*/
|
|
99
|
+
type OrchestratorEvent = { [K in keyof OrchestratorEventMap]: {
|
|
100
|
+
type: K;
|
|
101
|
+
} & OrchestratorEventMap[K] & EventIdentity }[keyof OrchestratorEventMap];
|
|
102
|
+
/** Every legal orchestrator event name. */
|
|
103
|
+
type OrchestratorEventName = keyof OrchestratorEventMap;
|
|
104
|
+
/**
|
|
105
|
+
* Handler for a single orchestrator event. Receives the event's typed
|
|
106
|
+
* payload (identity-injected centrally by the orchestrator's `emit`);
|
|
107
|
+
* return value is ignored.
|
|
108
|
+
*/
|
|
109
|
+
type OrchestratorEventHandler<K extends OrchestratorEventName> = (payload: OrchestratorEventMap[K] & EventIdentity) => void;
|
|
110
|
+
/**
|
|
111
|
+
* Definition / instance / per-call handler bag — tier surface accepted
|
|
112
|
+
* by `OrchestratorConfig.on` and the per-call `options.on`. Mirrors
|
|
113
|
+
* `SupervisorEventHandlers`.
|
|
114
|
+
*/
|
|
115
|
+
type OrchestratorEventHandlers = Partial<{ [K in OrchestratorEventName]: OrchestratorEventHandler<K> }>;
|
|
116
|
+
//#endregion
|
|
117
|
+
export { OrchestratorEvent, OrchestratorEventHandler, OrchestratorEventHandlers, OrchestratorEventMap, OrchestratorEventName };
|
|
118
|
+
//# sourceMappingURL=orchestrator-event.type.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"orchestrator-event.type.d.mts","names":[],"sources":["../../../../../../../../@warlock.js/ai/src/contracts/orchestrator/orchestrator-event.type.ts"],"mappings":";;;;;;AAoBA;;;;;;;;;;;;;;;KAAY,oBAAA;EAgBqB,sCAd/B,4BAAA;IAAgC,SAAA;IAAmB,SAAA;EAAA,GAkBnD;EAhBA,6BAAA;IACE,SAAA;IACA,SAAA;IACA,KAAA;EAAA,GAoB+B;EAjBjC,4BAAA;IACE,SAAA;IACA,SAAA;IACA,OAAA;EAAA,GAsBA;EAnBF,2BAAA;IAA+B,SAAA;IAAmB,QAAA;EAAA,GAyBhD;EAvBF,+BAAA;IAAmC,SAAA;IAAmB,YAAA;EAAA,GAiCpD;EA/BF,0BAAA;IACE,SAAA;IACA,SAAA;IACA,MAAA;IACA,GAAA;EAAA,GAkCF;EA/BA,6BAAA;IAAiC,SAAA;IAAmB,KAAA;EAAA,GAmClD;EAjCF,mCAAA;IACE,SAAA;IACA,SAAA;EAAA;EAGF,mCAAA;IACE,SAAA;IACA,UAAA,EAAY,gBAAA;EAAA,GAuCZ;EApCF,iCAAA;IACE,SAAA;IACA,UAAA,EAAY,gBAAgB;EAAA;EA+BlB;;;;;EAxBZ,gCAAA;IACE,SAAA;IACA,KAAA;IACA,KAAA;EAAA,GA4B6B;EAzB/B,6BAAA;IAAiC,SAAA;IAAmB,SAAA;EAAA,GAgClB;EA9BlC,0BAAA;IAA8B,SAAA;IAAmB,SAAA;EAAA,GA+Bd;EA7BnC,6BAAA;IAAiC,SAAA;IAAmB,SAAA;EAAA,GA6B3C;EA3BT,kCAAA;IACE,SAAA;IACA,SAAA;EAAA;AAAA;AAiCJ;;;;;AAAA,KAxBY,iBAAA,iBACE,oBAAA;EACV,IAAA,EAAM,CAAA;AAAA,IACJ,oBAAA,CAAqB,CAAA,IACvB,aAAA,SACI,oBAAA;;KAGI,qBAAA,SAA8B,oBAAoB;;;;AAiBJ;;KAV9C,wBAAA,WAAmC,qBAAA,KAC7C,OAAA,EAAS,oBAAA,CAAqB,CAAA,IAAK,aAAA;;;;;;KAQzB,yBAAA,GAA4B,OAAA,SAChC,qBAAA,GAAwB,wBAAA,CAAyB,CAAA"}
|