@warlock.js/ai 4.2.11 → 4.4.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 +68 -1
- package/cjs/index.cjs +10155 -4626
- 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 +88 -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 +143 -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 +2 -2
- package/esm/contracts/result/supervisor-result.type.d.mts.map +1 -1
- package/esm/contracts/result/tool-call.type.d.mts +2 -2
- package/esm/contracts/result/tool-call.type.d.mts.map +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/result/workflow-result.type.d.mts +1 -1
- package/esm/contracts/result/workflow-result.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 +120 -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
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
import { supervisor } from "../supervisor/supervisor.mjs";
|
|
2
|
+
|
|
3
|
+
//#region ../@warlock.js/ai/src/orchestrator/dispatch.ts
|
|
4
|
+
/**
|
|
5
|
+
* Derive the deterministic supervisor `runId` for an `iterate: true`
|
|
6
|
+
* turn (orchestrator.md §5 Phase 5 / §10.2 / §18.7):
|
|
7
|
+
* `${sessionId}.${version ?? "unversioned"}.${turnIndex}`. No base64,
|
|
8
|
+
* no hashing — the `sessionId` is the dev's responsibility to make
|
|
9
|
+
* unique. Deploying a new `version` cleanly partitions in-flight runs
|
|
10
|
+
* across deploys so old runIds never collide with new ones.
|
|
11
|
+
*/
|
|
12
|
+
function deriveRunId(sessionId, version, turnIndex) {
|
|
13
|
+
return `${sessionId}.${version ?? "unversioned"}.${turnIndex}`;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Build the internal supervisor config by spreading the orchestrator's
|
|
17
|
+
* supervisor-surface fields (orchestrator.md §1 / §5 Phase 5) and
|
|
18
|
+
* seeding `state` from the session-state seed.
|
|
19
|
+
*
|
|
20
|
+
* `iterate: false` caps `maxIterations` at 1 — a single dispatch per
|
|
21
|
+
* turn ("the supervisor's Phase A + Phase B once, no iteration loop" —
|
|
22
|
+
* §5). `iterate: true` keeps the configured `maxIterations` (default
|
|
23
|
+
* 10) and wires the `snapshotStore` for mid-turn resume.
|
|
24
|
+
*
|
|
25
|
+
* The orchestrator DELEGATES to the existing supervisor — it never
|
|
26
|
+
* reimplements dispatch / route / evaluate / strip-merge logic.
|
|
27
|
+
*/
|
|
28
|
+
function buildSupervisorConfig(ctx, seedState, iterate, snapshotStore) {
|
|
29
|
+
const config = ctx.config;
|
|
30
|
+
return {
|
|
31
|
+
name: config.name,
|
|
32
|
+
version: config.version,
|
|
33
|
+
systemPrompt: config.systemPrompt,
|
|
34
|
+
intents: config.intents,
|
|
35
|
+
route: config.route,
|
|
36
|
+
router: config.router,
|
|
37
|
+
evaluate: config.evaluate,
|
|
38
|
+
state: seedState,
|
|
39
|
+
output: config.output,
|
|
40
|
+
initialAgent: config.initialAgent,
|
|
41
|
+
maxIterations: iterate ? config.maxIterations : 1,
|
|
42
|
+
historyWindow: config.historyWindow ? {
|
|
43
|
+
router: toNumber(config.historyWindow.router),
|
|
44
|
+
agents: toNumber(config.historyWindow.agents)
|
|
45
|
+
} : void 0,
|
|
46
|
+
snapshotStore: iterate ? snapshotStore : void 0
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* The supervisor's `historyWindow` tiers accept only numbers; the
|
|
51
|
+
* orchestrator's accept a number OR a slicer callback. The callback
|
|
52
|
+
* form is already applied at the orchestrator level (Phase 4), so any
|
|
53
|
+
* non-number here has already done its slicing — drop it for the
|
|
54
|
+
* supervisor (which sees the pre-sliced history) by returning
|
|
55
|
+
* `undefined`.
|
|
56
|
+
*/
|
|
57
|
+
function toNumber(value) {
|
|
58
|
+
return typeof value === "number" ? value : void 0;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Build the forensic {@link TurnSnapshot} for the dispatched turn from
|
|
62
|
+
* the supervisor's result. Mirrors the supervisor's `IterationSnapshot`
|
|
63
|
+
* shape (§15.5) so a turn reads uniformly whether one agent ran
|
|
64
|
+
* (`iterate: false`) or the internal supervisor iterated
|
|
65
|
+
* (`iterate: true`). The terminal iteration's branch records and
|
|
66
|
+
* decision are lifted onto the turn; the supervisor's full report tree
|
|
67
|
+
* becomes the turn's `childReport`.
|
|
68
|
+
*/
|
|
69
|
+
function buildTurnSnapshot(input, turnIndex, result, state) {
|
|
70
|
+
const report = result.report;
|
|
71
|
+
const snapshots = report.snapshots;
|
|
72
|
+
const terminal = snapshots.length > 0 ? snapshots[snapshots.length - 1] : void 0;
|
|
73
|
+
const decisionSource = mapDecisionSource(terminal?.decision.source);
|
|
74
|
+
return Object.freeze({
|
|
75
|
+
turn: turnIndex,
|
|
76
|
+
input,
|
|
77
|
+
decision: {
|
|
78
|
+
source: decisionSource,
|
|
79
|
+
raw: terminal?.decision.next ?? null,
|
|
80
|
+
reasoning: terminal?.decision.reasoning
|
|
81
|
+
},
|
|
82
|
+
result: terminal?.result ?? {},
|
|
83
|
+
state,
|
|
84
|
+
evaluate: terminal?.evaluateVerdict,
|
|
85
|
+
startedAt: report.startedAt,
|
|
86
|
+
endedAt: report.endedAt,
|
|
87
|
+
duration: report.duration,
|
|
88
|
+
usage: report.usage,
|
|
89
|
+
childReport: report
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Map the supervisor's `DecisionSource` onto the narrower turn-snapshot
|
|
94
|
+
* decision source (§15.5 — `"route" | "router" | "intent.next"`). The
|
|
95
|
+
* supervisor's `initialAgent` / `classifier` first-turn sources collapse
|
|
96
|
+
* to `"intent.next"` (a non-route/router origin) at the orchestrator
|
|
97
|
+
* layer, which only distinguishes the three coarse decision origins.
|
|
98
|
+
*/
|
|
99
|
+
function mapDecisionSource(source) {
|
|
100
|
+
if (source === "route" || source === "router") return source;
|
|
101
|
+
return "intent.next";
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Phase 5 — dispatch turn (orchestrator.md §3 / §4 Phase 5).
|
|
105
|
+
*
|
|
106
|
+
* Constructs a fresh internal supervisor seeded from the session state,
|
|
107
|
+
* then:
|
|
108
|
+
*
|
|
109
|
+
* - `iterate: false` — runs a single dispatch (`maxIterations: 1`).
|
|
110
|
+
* - `iterate: true` — runs the full supervisor with a deterministic
|
|
111
|
+
* `runId`, resuming an in-flight run when the `SnapshotStore` already
|
|
112
|
+
* has one for that `runId` (§5 step 5).
|
|
113
|
+
*
|
|
114
|
+
* The supervisor's final state replaces the session state (§5 — replace
|
|
115
|
+
* semantics). The supervisor is never kept alive across turns
|
|
116
|
+
* (single-call lifecycle invariant — §18.8).
|
|
117
|
+
*/
|
|
118
|
+
async function dispatchTurn(params) {
|
|
119
|
+
const { ctx, sessionId, input, seedState, turnIndex, history, context, signal } = params;
|
|
120
|
+
const iterate = ctx.config.iterate === true;
|
|
121
|
+
const sup = supervisor(buildSupervisorConfig(ctx, seedState, iterate, ctx.snapshotStore));
|
|
122
|
+
let result;
|
|
123
|
+
if (iterate) {
|
|
124
|
+
const runId = deriveRunId(sessionId, ctx.config.version, turnIndex);
|
|
125
|
+
const inFlight = ctx.snapshotStore ? await ctx.snapshotStore.load(runId) : void 0;
|
|
126
|
+
if (inFlight && inFlight.status === "running") result = await sup.resume(runId, {
|
|
127
|
+
context,
|
|
128
|
+
signal,
|
|
129
|
+
history,
|
|
130
|
+
sessionId
|
|
131
|
+
});
|
|
132
|
+
else result = await sup.execute(input, {
|
|
133
|
+
runId,
|
|
134
|
+
context,
|
|
135
|
+
signal,
|
|
136
|
+
history,
|
|
137
|
+
sessionId
|
|
138
|
+
});
|
|
139
|
+
} else result = await sup.execute(input, {
|
|
140
|
+
context,
|
|
141
|
+
signal,
|
|
142
|
+
history,
|
|
143
|
+
sessionId
|
|
144
|
+
});
|
|
145
|
+
const state = deriveFinalState(result, seedState);
|
|
146
|
+
const turnSnapshot = buildTurnSnapshot(input, turnIndex, result, state);
|
|
147
|
+
return {
|
|
148
|
+
result,
|
|
149
|
+
state,
|
|
150
|
+
turnSnapshot
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Derive the post-turn session state from the supervisor result.
|
|
155
|
+
* Prefers the terminal iteration's accumulated `state`; falls back to
|
|
156
|
+
* the validated `data` (when an `output` schema reshaped it), then to
|
|
157
|
+
* the seed when the run produced neither (e.g. it terminated before
|
|
158
|
+
* dispatching anything). Replace semantics — the supervisor is the
|
|
159
|
+
* authority on state evolution within its loop (§5).
|
|
160
|
+
*/
|
|
161
|
+
function deriveFinalState(result, seedState) {
|
|
162
|
+
const snapshots = result.report.snapshots;
|
|
163
|
+
const terminal = snapshots.length > 0 ? snapshots[snapshots.length - 1] : void 0;
|
|
164
|
+
if (terminal && terminal.state !== void 0) return terminal.state;
|
|
165
|
+
if (result.data !== void 0) return result.data;
|
|
166
|
+
return seedState;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
//#endregion
|
|
170
|
+
export { deriveRunId, dispatchTurn };
|
|
171
|
+
//# sourceMappingURL=dispatch.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dispatch.mjs","names":["createSupervisor"],"sources":["../../../../../../../@warlock.js/ai/src/orchestrator/dispatch.ts"],"sourcesContent":["import type { Message } from \"../contracts/conversation-message.type\";\nimport type { SnapshotStore } from \"../contracts/orchestrator/snapshot-store.contract\";\nimport type { SupervisorResult } from \"../contracts/result/supervisor-result.type\";\nimport type { TurnSnapshot } from \"../contracts/result/orchestrator-result.type\";\nimport type { SupervisorConfig } from \"../contracts/supervisor/supervisor-config.type\";\nimport type { SupervisorInput } from \"../contracts/supervisor/supervisor-input.type\";\nimport type { SupervisorReport } from \"../contracts/result/supervisor-result.type\";\nimport type { OrchestratorEngineContext } from \"./engine-context.type\";\nimport { supervisor as createSupervisor } from \"../supervisor/supervisor\";\n\n/**\n * Derive the deterministic supervisor `runId` for an `iterate: true`\n * turn (orchestrator.md §5 Phase 5 / §10.2 / §18.7):\n * `${sessionId}.${version ?? \"unversioned\"}.${turnIndex}`. No base64,\n * no hashing — the `sessionId` is the dev's responsibility to make\n * unique. Deploying a new `version` cleanly partitions in-flight runs\n * across deploys so old runIds never collide with new ones.\n */\nexport function deriveRunId(\n sessionId: string,\n version: string | undefined,\n turnIndex: number,\n): string {\n return `${sessionId}.${version ?? \"unversioned\"}.${turnIndex}`;\n}\n\n/** Parameters for one Phase-5 dispatch. */\nexport type DispatchParams<TOutput, TState> = {\n ctx: OrchestratorEngineContext<TOutput, TState>;\n sessionId: string;\n input: SupervisorInput;\n /** The session-state seed assembled in Phase 1 + the per-call patch. */\n seedState: TState;\n turnIndex: number;\n /** Agent-windowed history from Phase 4. */\n history: Message[];\n context?: Record<string, unknown>;\n signal?: AbortSignal;\n};\n\n/** Outcome of Phase 5 — the supervisor result plus the turn's snapshot. */\nexport type DispatchOutcome<TOutput> = {\n result: SupervisorResult<TOutput>;\n /** Post-dispatch session state (replaces session state per §5). */\n state: unknown;\n turnSnapshot: TurnSnapshot;\n};\n\n/**\n * Build the internal supervisor config by spreading the orchestrator's\n * supervisor-surface fields (orchestrator.md §1 / §5 Phase 5) and\n * seeding `state` from the session-state seed.\n *\n * `iterate: false` caps `maxIterations` at 1 — a single dispatch per\n * turn (\"the supervisor's Phase A + Phase B once, no iteration loop\" —\n * §5). `iterate: true` keeps the configured `maxIterations` (default\n * 10) and wires the `snapshotStore` for mid-turn resume.\n *\n * The orchestrator DELEGATES to the existing supervisor — it never\n * reimplements dispatch / route / evaluate / strip-merge logic.\n */\nfunction buildSupervisorConfig<TOutput, TState>(\n ctx: OrchestratorEngineContext<TOutput, TState>,\n seedState: TState,\n iterate: boolean,\n snapshotStore: SnapshotStore | undefined,\n): SupervisorConfig<TOutput, TState> {\n const config = ctx.config;\n\n const supervisorConfig: SupervisorConfig<TOutput, TState> = {\n name: config.name,\n version: config.version,\n systemPrompt: config.systemPrompt,\n intents: config.intents,\n route: config.route,\n router: config.router,\n evaluate: config.evaluate,\n state: seedState,\n output: config.output,\n initialAgent: config.initialAgent,\n maxIterations: iterate ? config.maxIterations : 1,\n historyWindow: config.historyWindow\n ? { router: toNumber(config.historyWindow.router), agents: toNumber(config.historyWindow.agents) }\n : undefined,\n snapshotStore: iterate ? snapshotStore : undefined,\n };\n\n return supervisorConfig;\n}\n\n/**\n * The supervisor's `historyWindow` tiers accept only numbers; the\n * orchestrator's accept a number OR a slicer callback. The callback\n * form is already applied at the orchestrator level (Phase 4), so any\n * non-number here has already done its slicing — drop it for the\n * supervisor (which sees the pre-sliced history) by returning\n * `undefined`.\n */\nfunction toNumber(\n value: number | ((messages: Message[]) => Message[]) | undefined,\n): number | undefined {\n return typeof value === \"number\" ? value : undefined;\n}\n\n/**\n * Build the forensic {@link TurnSnapshot} for the dispatched turn from\n * the supervisor's result. Mirrors the supervisor's `IterationSnapshot`\n * shape (§15.5) so a turn reads uniformly whether one agent ran\n * (`iterate: false`) or the internal supervisor iterated\n * (`iterate: true`). The terminal iteration's branch records and\n * decision are lifted onto the turn; the supervisor's full report tree\n * becomes the turn's `childReport`.\n */\nfunction buildTurnSnapshot(\n input: SupervisorInput,\n turnIndex: number,\n result: SupervisorResult<unknown>,\n state: unknown,\n): TurnSnapshot {\n const report = result.report;\n const snapshots = report.snapshots;\n const terminal = snapshots.length > 0 ? snapshots[snapshots.length - 1] : undefined;\n\n const decisionSource = mapDecisionSource(terminal?.decision.source);\n\n return Object.freeze({\n turn: turnIndex,\n input,\n decision: {\n source: decisionSource,\n raw: terminal?.decision.next ?? null,\n reasoning: terminal?.decision.reasoning,\n },\n result: terminal?.result ?? {},\n state,\n evaluate: terminal?.evaluateVerdict,\n startedAt: report.startedAt,\n endedAt: report.endedAt,\n duration: report.duration,\n usage: report.usage,\n childReport: report,\n });\n}\n\n/**\n * Map the supervisor's `DecisionSource` onto the narrower turn-snapshot\n * decision source (§15.5 — `\"route\" | \"router\" | \"intent.next\"`). The\n * supervisor's `initialAgent` / `classifier` first-turn sources collapse\n * to `\"intent.next\"` (a non-route/router origin) at the orchestrator\n * layer, which only distinguishes the three coarse decision origins.\n */\nfunction mapDecisionSource(\n source: \"route\" | \"router\" | \"initialAgent\" | \"classifier\" | undefined,\n): \"route\" | \"router\" | \"intent.next\" {\n if (source === \"route\" || source === \"router\") {\n return source;\n }\n\n return \"intent.next\";\n}\n\n/**\n * Phase 5 — dispatch turn (orchestrator.md §3 / §4 Phase 5).\n *\n * Constructs a fresh internal supervisor seeded from the session state,\n * then:\n *\n * - `iterate: false` — runs a single dispatch (`maxIterations: 1`).\n * - `iterate: true` — runs the full supervisor with a deterministic\n * `runId`, resuming an in-flight run when the `SnapshotStore` already\n * has one for that `runId` (§5 step 5).\n *\n * The supervisor's final state replaces the session state (§5 — replace\n * semantics). The supervisor is never kept alive across turns\n * (single-call lifecycle invariant — §18.8).\n */\nexport async function dispatchTurn<TOutput, TState>(\n params: DispatchParams<TOutput, TState>,\n): Promise<DispatchOutcome<TOutput>> {\n const { ctx, sessionId, input, seedState, turnIndex, history, context, signal } =\n params;\n\n const iterate = ctx.config.iterate === true;\n const sup = createSupervisor<TOutput, TState>(\n buildSupervisorConfig(ctx, seedState, iterate, ctx.snapshotStore),\n );\n\n let result: SupervisorResult<TOutput>;\n\n if (iterate) {\n const runId = deriveRunId(sessionId, ctx.config.version, turnIndex);\n const inFlight = ctx.snapshotStore\n ? await ctx.snapshotStore.load(runId)\n : undefined;\n\n if (inFlight && inFlight.status === \"running\") {\n result = await sup.resume(runId, { context, signal, history, sessionId });\n } else {\n result = await sup.execute(input, { runId, context, signal, history, sessionId });\n }\n } else {\n result = await sup.execute(input, { context, signal, history, sessionId });\n }\n\n const state = deriveFinalState(result, seedState);\n const turnSnapshot = buildTurnSnapshot(input, turnIndex, result, state);\n\n return { result, state, turnSnapshot };\n}\n\n/**\n * Derive the post-turn session state from the supervisor result.\n * Prefers the terminal iteration's accumulated `state`; falls back to\n * the validated `data` (when an `output` schema reshaped it), then to\n * the seed when the run produced neither (e.g. it terminated before\n * dispatching anything). Replace semantics — the supervisor is the\n * authority on state evolution within its loop (§5).\n */\nfunction deriveFinalState<TOutput, TState>(\n result: SupervisorResult<TOutput>,\n seedState: TState,\n): unknown {\n const report: SupervisorReport = result.report;\n const snapshots = report.snapshots;\n const terminal = snapshots.length > 0 ? snapshots[snapshots.length - 1] : undefined;\n\n if (terminal && terminal.state !== undefined) {\n return terminal.state;\n }\n\n if (result.data !== undefined) {\n return result.data;\n }\n\n return seedState;\n}\n"],"mappings":";;;;;;;;;;;AAkBA,SAAgB,YACd,WACA,SACA,WACQ;CACR,OAAO,GAAG,UAAU,GAAG,WAAW,cAAc,GAAG;AACrD;;;;;;;;;;;;;;AAqCA,SAAS,sBACP,KACA,WACA,SACA,eACmC;CACnC,MAAM,SAAS,IAAI;CAoBnB,OAAO;EAjBL,MAAM,OAAO;EACb,SAAS,OAAO;EAChB,cAAc,OAAO;EACrB,SAAS,OAAO;EAChB,OAAO,OAAO;EACd,QAAQ,OAAO;EACf,UAAU,OAAO;EACjB,OAAO;EACP,QAAQ,OAAO;EACf,cAAc,OAAO;EACrB,eAAe,UAAU,OAAO,gBAAgB;EAChD,eAAe,OAAO,gBAClB;GAAE,QAAQ,SAAS,OAAO,cAAc,MAAM;GAAG,QAAQ,SAAS,OAAO,cAAc,MAAM;EAAE,IAC/F;EACJ,eAAe,UAAU,gBAAgB;CAGrB;AACxB;;;;;;;;;AAUA,SAAS,SACP,OACoB;CACpB,OAAO,OAAO,UAAU,WAAW,QAAQ;AAC7C;;;;;;;;;;AAWA,SAAS,kBACP,OACA,WACA,QACA,OACc;CACd,MAAM,SAAS,OAAO;CACtB,MAAM,YAAY,OAAO;CACzB,MAAM,WAAW,UAAU,SAAS,IAAI,UAAU,UAAU,SAAS,KAAK;CAE1E,MAAM,iBAAiB,kBAAkB,UAAU,SAAS,MAAM;CAElE,OAAO,OAAO,OAAO;EACnB,MAAM;EACN;EACA,UAAU;GACR,QAAQ;GACR,KAAK,UAAU,SAAS,QAAQ;GAChC,WAAW,UAAU,SAAS;EAChC;EACA,QAAQ,UAAU,UAAU,CAAC;EAC7B;EACA,UAAU,UAAU;EACpB,WAAW,OAAO;EAClB,SAAS,OAAO;EAChB,UAAU,OAAO;EACjB,OAAO,OAAO;EACd,aAAa;CACf,CAAC;AACH;;;;;;;;AASA,SAAS,kBACP,QACoC;CACpC,IAAI,WAAW,WAAW,WAAW,UACnC,OAAO;CAGT,OAAO;AACT;;;;;;;;;;;;;;;;AAiBA,eAAsB,aACpB,QACmC;CACnC,MAAM,EAAE,KAAK,WAAW,OAAO,WAAW,WAAW,SAAS,SAAS,WACrE;CAEF,MAAM,UAAU,IAAI,OAAO,YAAY;CACvC,MAAM,MAAMA,WACV,sBAAsB,KAAK,WAAW,SAAS,IAAI,aAAa,CAClE;CAEA,IAAI;CAEJ,IAAI,SAAS;EACX,MAAM,QAAQ,YAAY,WAAW,IAAI,OAAO,SAAS,SAAS;EAClE,MAAM,WAAW,IAAI,gBACjB,MAAM,IAAI,cAAc,KAAK,KAAK,IAClC;EAEJ,IAAI,YAAY,SAAS,WAAW,WAClC,SAAS,MAAM,IAAI,OAAO,OAAO;GAAE;GAAS;GAAQ;GAAS;EAAU,CAAC;OAExE,SAAS,MAAM,IAAI,QAAQ,OAAO;GAAE;GAAO;GAAS;GAAQ;GAAS;EAAU,CAAC;CAEpF,OACE,SAAS,MAAM,IAAI,QAAQ,OAAO;EAAE;EAAS;EAAQ;EAAS;CAAU,CAAC;CAG3E,MAAM,QAAQ,iBAAiB,QAAQ,SAAS;CAChD,MAAM,eAAe,kBAAkB,OAAO,WAAW,QAAQ,KAAK;CAEtE,OAAO;EAAE;EAAQ;EAAO;CAAa;AACvC;;;;;;;;;AAUA,SAAS,iBACP,QACA,WACS;CAET,MAAM,YAD2B,OAAO,OACf;CACzB,MAAM,WAAW,UAAU,SAAS,IAAI,UAAU,UAAU,SAAS,KAAK;CAE1E,IAAI,YAAY,SAAS,UAAU,QACjC,OAAO,SAAS;CAGlB,IAAI,OAAO,SAAS,QAClB,OAAO,OAAO;CAGhB,OAAO;AACT"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { OrchestratorEventHandlers, OrchestratorEventMap } from "../contracts/orchestrator/orchestrator-event.type.mjs";
|
|
2
|
+
|
|
3
|
+
//#region ../@warlock.js/ai/src/orchestrator/emitter-port.type.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Minimal structural surface the C2 engine needs from the orchestrator
|
|
6
|
+
* emitter (owned by C1's `emitter.ts`). Declared as a port so the
|
|
7
|
+
* engine depends only on the shape it calls, never on C1's concrete
|
|
8
|
+
* emitter class — keeping the two components decoupled.
|
|
9
|
+
*
|
|
10
|
+
* The engine emits one event per lifecycle phase (orchestrator.md
|
|
11
|
+
* §14.1) and registers the per-call `options.on` handlers (tier 3) for
|
|
12
|
+
* the duration of a single turn. `emit` injects run `EventIdentity`
|
|
13
|
+
* centrally inside the emitter, so the engine passes only the typed
|
|
14
|
+
* payload.
|
|
15
|
+
*/
|
|
16
|
+
type OrchestratorEmitterLike = {
|
|
17
|
+
/**
|
|
18
|
+
* Fire an event to all three tiers (definition → instance →
|
|
19
|
+
* per-call) in order. Identity is injected by the emitter.
|
|
20
|
+
*/
|
|
21
|
+
emit<K extends keyof OrchestratorEventMap>(event: K, payload: OrchestratorEventMap[K]): void;
|
|
22
|
+
/**
|
|
23
|
+
* Register the per-call handler bag (tier 3) for the scope of one
|
|
24
|
+
* turn. Returns a disposer the engine calls in a `finally` to unwind
|
|
25
|
+
* the per-call subscriptions when the turn settles.
|
|
26
|
+
*/
|
|
27
|
+
bindPerCall(handlers: OrchestratorEventHandlers | undefined): () => void;
|
|
28
|
+
};
|
|
29
|
+
//#endregion
|
|
30
|
+
export { OrchestratorEmitterLike };
|
|
31
|
+
//# sourceMappingURL=emitter-port.type.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"emitter-port.type.d.mts","names":[],"sources":["../../../../../../../@warlock.js/ai/src/orchestrator/emitter-port.type.ts"],"mappings":";;;;;AAiBA;;;;;;;;;;KAAY,uBAAA;EAKL;;;;EAAL,IAAA,iBAAqB,oBAAA,EACnB,KAAA,EAAO,CAAA,EACP,OAAA,EAAS,oBAAA,CAAqB,CAAA;EAAA;;;;;EAQhC,WAAA,CAAY,QAAA,EAAU,yBAAA;AAAA"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { EventIdentity, WithoutIdentity } from "../contracts/events/event-identity.type.mjs";
|
|
2
|
+
import { OrchestratorEventHandler, OrchestratorEventHandlers, OrchestratorEventMap, OrchestratorEventName } from "../contracts/orchestrator/orchestrator-event.type.mjs";
|
|
3
|
+
|
|
4
|
+
//#region ../@warlock.js/ai/src/orchestrator/emitter.d.ts
|
|
5
|
+
/** Full identity-stamped payload an orchestrator handler receives. */
|
|
6
|
+
type EventPayload<K extends OrchestratorEventName> = OrchestratorEventMap[K] & EventIdentity;
|
|
7
|
+
/**
|
|
8
|
+
* Three-tier orchestrator event emitter — definition (factory) →
|
|
9
|
+
* instance → per-call — for the `orchestrator.*` namespace (design
|
|
10
|
+
* §14.3). Mirrors {@link import("../supervisor/emitter").SupervisorEmitter}
|
|
11
|
+
* structurally; the differences are the event map and a central
|
|
12
|
+
* identity-injection chokepoint (`emit` accepts an identity-less
|
|
13
|
+
* payload and stamps {@link EventIdentity} once so all three tiers, and
|
|
14
|
+
* any mirror like the stream, see the same value).
|
|
15
|
+
*
|
|
16
|
+
* Owns: the instance-handler registry and the fan-out order. Does NOT
|
|
17
|
+
* own: child `supervisor.*` / `agent.*` events — those bubble up
|
|
18
|
+
* unmodified under their own identity (§14.2) and never pass through
|
|
19
|
+
* this emitter. All matching handlers fire in tier order; a handler
|
|
20
|
+
* throwing never derails the turn.
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* const emitter = new OrchestratorEmitter(config.on);
|
|
24
|
+
* const off = emitter.on("orchestrator.turn.completed", (event) => log(event));
|
|
25
|
+
* emitter.emit(
|
|
26
|
+
* "orchestrator.turn.starting",
|
|
27
|
+
* { sessionId, turnIndex },
|
|
28
|
+
* { runId, rootRunId },
|
|
29
|
+
* perCallHandlers,
|
|
30
|
+
* );
|
|
31
|
+
*/
|
|
32
|
+
declare class OrchestratorEmitter {
|
|
33
|
+
private readonly factoryHandlers?;
|
|
34
|
+
private readonly instanceHandlers;
|
|
35
|
+
constructor(factoryHandlers?: OrchestratorEventHandlers);
|
|
36
|
+
/**
|
|
37
|
+
* Subscribe an instance-level handler (tier 2). Returns an
|
|
38
|
+
* unsubscribe function equivalent to `off(event, handler)`.
|
|
39
|
+
*/
|
|
40
|
+
on<K extends OrchestratorEventName>(event: K, handler: OrchestratorEventHandler<K>): () => void;
|
|
41
|
+
/**
|
|
42
|
+
* Remove a previously-subscribed instance handler. No-op when the
|
|
43
|
+
* handler was never registered or already removed.
|
|
44
|
+
*/
|
|
45
|
+
off<K extends OrchestratorEventName>(event: K, handler: OrchestratorEventHandler<K>): void;
|
|
46
|
+
/**
|
|
47
|
+
* Stamp run identity onto the payload, then fan out through all three
|
|
48
|
+
* tiers in order: definition → instance → per-call. Returns the full
|
|
49
|
+
* identity-stamped payload so the caller can mirror the same value
|
|
50
|
+
* into the stream controller (keeping `.on()` and iteration in lockstep).
|
|
51
|
+
*/
|
|
52
|
+
emit<K extends OrchestratorEventName>(event: K, payload: WithoutIdentity<OrchestratorEventMap[K]>, identity: EventIdentity, perCallHandlers?: OrchestratorEventHandlers): EventPayload<K>;
|
|
53
|
+
}
|
|
54
|
+
//#endregion
|
|
55
|
+
export { OrchestratorEmitter };
|
|
56
|
+
//# sourceMappingURL=emitter.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"emitter.d.mts","names":[],"sources":["../../../../../../../@warlock.js/ai/src/orchestrator/emitter.ts"],"mappings":";;;;;KAYK,YAAA,WAAuB,qBAAA,IAAyB,oBAAA,CAAqB,CAAA,IACxE,aAAA;AAJyD;;;;;;;;;;;;;;;AAI5C;AAoCf;;;;;;;;;AAxC2D,cAwC9C,mBAAA;EAAA,iBACM,eAAA;EAAA,iBACA,gBAAA;cAKE,eAAA,GAAkB,yBAAA;EA0C5B;;;;EAlCF,EAAA,WAAa,qBAAA,EAClB,KAAA,EAAO,CAAA,EACP,OAAA,EAAS,wBAAA,CAAyB,CAAA;EAmChB;;;;EAjBb,GAAA,WAAc,qBAAA,EACnB,KAAA,EAAO,CAAA,EACP,OAAA,EAAS,wBAAA,CAAyB,CAAA;EApCnB;;;;;;EA+CV,IAAA,WAAe,qBAAA,EACpB,KAAA,EAAO,CAAA,EACP,OAAA,EAAS,eAAA,CAAgB,oBAAA,CAAqB,CAAA,IAC9C,QAAA,EAAU,aAAA,EACV,eAAA,GAAkB,yBAAA,GACjB,YAAA,CAAa,CAAA;AAAA"}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
//#region ../@warlock.js/ai/src/orchestrator/emitter.ts
|
|
2
|
+
/**
|
|
3
|
+
* Three-tier orchestrator event emitter — definition (factory) →
|
|
4
|
+
* instance → per-call — for the `orchestrator.*` namespace (design
|
|
5
|
+
* §14.3). Mirrors {@link import("../supervisor/emitter").SupervisorEmitter}
|
|
6
|
+
* structurally; the differences are the event map and a central
|
|
7
|
+
* identity-injection chokepoint (`emit` accepts an identity-less
|
|
8
|
+
* payload and stamps {@link EventIdentity} once so all three tiers, and
|
|
9
|
+
* any mirror like the stream, see the same value).
|
|
10
|
+
*
|
|
11
|
+
* Owns: the instance-handler registry and the fan-out order. Does NOT
|
|
12
|
+
* own: child `supervisor.*` / `agent.*` events — those bubble up
|
|
13
|
+
* unmodified under their own identity (§14.2) and never pass through
|
|
14
|
+
* this emitter. All matching handlers fire in tier order; a handler
|
|
15
|
+
* throwing never derails the turn.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* const emitter = new OrchestratorEmitter(config.on);
|
|
19
|
+
* const off = emitter.on("orchestrator.turn.completed", (event) => log(event));
|
|
20
|
+
* emitter.emit(
|
|
21
|
+
* "orchestrator.turn.starting",
|
|
22
|
+
* { sessionId, turnIndex },
|
|
23
|
+
* { runId, rootRunId },
|
|
24
|
+
* perCallHandlers,
|
|
25
|
+
* );
|
|
26
|
+
*/
|
|
27
|
+
var OrchestratorEmitter = class {
|
|
28
|
+
constructor(factoryHandlers) {
|
|
29
|
+
this.instanceHandlers = /* @__PURE__ */ new Map();
|
|
30
|
+
this.factoryHandlers = factoryHandlers;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Subscribe an instance-level handler (tier 2). Returns an
|
|
34
|
+
* unsubscribe function equivalent to `off(event, handler)`.
|
|
35
|
+
*/
|
|
36
|
+
on(event, handler) {
|
|
37
|
+
let bucket = this.instanceHandlers.get(event);
|
|
38
|
+
if (!bucket) {
|
|
39
|
+
bucket = /* @__PURE__ */ new Set();
|
|
40
|
+
this.instanceHandlers.set(event, bucket);
|
|
41
|
+
}
|
|
42
|
+
bucket.add(handler);
|
|
43
|
+
return () => this.off(event, handler);
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Remove a previously-subscribed instance handler. No-op when the
|
|
47
|
+
* handler was never registered or already removed.
|
|
48
|
+
*/
|
|
49
|
+
off(event, handler) {
|
|
50
|
+
this.instanceHandlers.get(event)?.delete(handler);
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Stamp run identity onto the payload, then fan out through all three
|
|
54
|
+
* tiers in order: definition → instance → per-call. Returns the full
|
|
55
|
+
* identity-stamped payload so the caller can mirror the same value
|
|
56
|
+
* into the stream controller (keeping `.on()` and iteration in lockstep).
|
|
57
|
+
*/
|
|
58
|
+
emit(event, payload, identity, perCallHandlers) {
|
|
59
|
+
const fullPayload = {
|
|
60
|
+
...payload,
|
|
61
|
+
...identity
|
|
62
|
+
};
|
|
63
|
+
invoke(this.factoryHandlers?.[event], fullPayload);
|
|
64
|
+
const bucket = this.instanceHandlers.get(event);
|
|
65
|
+
if (bucket) for (const handler of bucket) invoke(handler, fullPayload);
|
|
66
|
+
invoke(perCallHandlers?.[event], fullPayload);
|
|
67
|
+
return fullPayload;
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
/**
|
|
71
|
+
* Invoke a single handler, swallowing any throw. A listener bug must
|
|
72
|
+
* never derail the orchestrator turn. Typed structurally (a plain
|
|
73
|
+
* `(payload) => void`) so the identity-stamped payload flows in without
|
|
74
|
+
* fighting the contravariant `OrchestratorEventHandler<K>` union.
|
|
75
|
+
*/
|
|
76
|
+
function invoke(handler, payload) {
|
|
77
|
+
if (typeof handler !== "function") return;
|
|
78
|
+
try {
|
|
79
|
+
handler(payload);
|
|
80
|
+
} catch {}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
//#endregion
|
|
84
|
+
export { OrchestratorEmitter };
|
|
85
|
+
//# sourceMappingURL=emitter.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"emitter.mjs","names":[],"sources":["../../../../../../../@warlock.js/ai/src/orchestrator/emitter.ts"],"sourcesContent":["import type {\n EventIdentity,\n WithoutIdentity,\n} from \"../contracts/events/event-identity.type\";\nimport type {\n OrchestratorEventHandler,\n OrchestratorEventHandlers,\n OrchestratorEventMap,\n OrchestratorEventName,\n} from \"../contracts/orchestrator/orchestrator-event.type\";\n\n/** Full identity-stamped payload an orchestrator handler receives. */\ntype EventPayload<K extends OrchestratorEventName> = OrchestratorEventMap[K] &\n EventIdentity;\n\n/**\n * Erased handler shape for the instance registry. Per-event handlers\n * are contravariant in their payload, so the registry stores them under\n * a single structural `(payload) => void` and re-narrows at the call\n * site — the `on` / `off` public surface keeps the precise per-event\n * typing.\n */\ntype AnyHandler = (payload: EventPayload<OrchestratorEventName>) => void;\n\n/**\n * Three-tier orchestrator event emitter — definition (factory) →\n * instance → per-call — for the `orchestrator.*` namespace (design\n * §14.3). Mirrors {@link import(\"../supervisor/emitter\").SupervisorEmitter}\n * structurally; the differences are the event map and a central\n * identity-injection chokepoint (`emit` accepts an identity-less\n * payload and stamps {@link EventIdentity} once so all three tiers, and\n * any mirror like the stream, see the same value).\n *\n * Owns: the instance-handler registry and the fan-out order. Does NOT\n * own: child `supervisor.*` / `agent.*` events — those bubble up\n * unmodified under their own identity (§14.2) and never pass through\n * this emitter. All matching handlers fire in tier order; a handler\n * throwing never derails the turn.\n *\n * @example\n * const emitter = new OrchestratorEmitter(config.on);\n * const off = emitter.on(\"orchestrator.turn.completed\", (event) => log(event));\n * emitter.emit(\n * \"orchestrator.turn.starting\",\n * { sessionId, turnIndex },\n * { runId, rootRunId },\n * perCallHandlers,\n * );\n */\nexport class OrchestratorEmitter {\n private readonly factoryHandlers?: OrchestratorEventHandlers;\n private readonly instanceHandlers = new Map<\n OrchestratorEventName,\n Set<AnyHandler>\n >();\n\n public constructor(factoryHandlers?: OrchestratorEventHandlers) {\n this.factoryHandlers = factoryHandlers;\n }\n\n /**\n * Subscribe an instance-level handler (tier 2). Returns an\n * unsubscribe function equivalent to `off(event, handler)`.\n */\n public on<K extends OrchestratorEventName>(\n event: K,\n handler: OrchestratorEventHandler<K>,\n ): () => void {\n let bucket = this.instanceHandlers.get(event);\n\n if (!bucket) {\n bucket = new Set();\n this.instanceHandlers.set(event, bucket);\n }\n\n bucket.add(handler as unknown as AnyHandler);\n\n return () => this.off(event, handler);\n }\n\n /**\n * Remove a previously-subscribed instance handler. No-op when the\n * handler was never registered or already removed.\n */\n public off<K extends OrchestratorEventName>(\n event: K,\n handler: OrchestratorEventHandler<K>,\n ): void {\n this.instanceHandlers.get(event)?.delete(handler as unknown as AnyHandler);\n }\n\n /**\n * Stamp run identity onto the payload, then fan out through all three\n * tiers in order: definition → instance → per-call. Returns the full\n * identity-stamped payload so the caller can mirror the same value\n * into the stream controller (keeping `.on()` and iteration in lockstep).\n */\n public emit<K extends OrchestratorEventName>(\n event: K,\n payload: WithoutIdentity<OrchestratorEventMap[K]>,\n identity: EventIdentity,\n perCallHandlers?: OrchestratorEventHandlers,\n ): EventPayload<K> {\n const fullPayload = { ...payload, ...identity } as EventPayload<K>;\n\n invoke(this.factoryHandlers?.[event], fullPayload);\n\n const bucket = this.instanceHandlers.get(event);\n\n if (bucket) {\n for (const handler of bucket) {\n invoke(handler as unknown as (payload: EventPayload<K>) => void, fullPayload);\n }\n }\n\n invoke(perCallHandlers?.[event], fullPayload);\n\n return fullPayload;\n }\n}\n\n/**\n * Invoke a single handler, swallowing any throw. A listener bug must\n * never derail the orchestrator turn. Typed structurally (a plain\n * `(payload) => void`) so the identity-stamped payload flows in without\n * fighting the contravariant `OrchestratorEventHandler<K>` union.\n */\nfunction invoke<K extends OrchestratorEventName>(\n handler: ((payload: EventPayload<K>) => void) | undefined,\n payload: EventPayload<K>,\n): void {\n if (typeof handler !== \"function\") {\n return;\n }\n\n try {\n handler(payload);\n } catch {\n // Listener bugs must not derail the orchestrator.\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAiDA,IAAa,sBAAb,MAAiC;CAO/B,AAAO,YAAY,iBAA6C;0CAL5B,IAAI,IAGtC;EAGA,KAAK,kBAAkB;CACzB;;;;;CAMA,AAAO,GACL,OACA,SACY;EACZ,IAAI,SAAS,KAAK,iBAAiB,IAAI,KAAK;EAE5C,IAAI,CAAC,QAAQ;GACX,yBAAS,IAAI,IAAI;GACjB,KAAK,iBAAiB,IAAI,OAAO,MAAM;EACzC;EAEA,OAAO,IAAI,OAAgC;EAE3C,aAAa,KAAK,IAAI,OAAO,OAAO;CACtC;;;;;CAMA,AAAO,IACL,OACA,SACM;EACN,KAAK,iBAAiB,IAAI,KAAK,CAAC,EAAE,OAAO,OAAgC;CAC3E;;;;;;;CAQA,AAAO,KACL,OACA,SACA,UACA,iBACiB;EACjB,MAAM,cAAc;GAAE,GAAG;GAAS,GAAG;EAAS;EAE9C,OAAO,KAAK,kBAAkB,QAAQ,WAAW;EAEjD,MAAM,SAAS,KAAK,iBAAiB,IAAI,KAAK;EAE9C,IAAI,QACF,KAAK,MAAM,WAAW,QACpB,OAAO,SAA0D,WAAW;EAIhF,OAAO,kBAAkB,QAAQ,WAAW;EAE5C,OAAO;CACT;AACF;;;;;;;AAQA,SAAS,OACP,SACA,SACM;CACN,IAAI,OAAO,YAAY,YACrB;CAGF,IAAI;EACF,QAAQ,OAAO;CACjB,QAAQ,CAER;AACF"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { SnapshotStore } from "../contracts/orchestrator/snapshot-store.contract.mjs";
|
|
2
|
+
import { SupervisorIntentValue } from "../contracts/supervisor/intent-entry.type.mjs";
|
|
3
|
+
import { CheckpointStore } from "../contracts/orchestrator/checkpoint-store.contract.mjs";
|
|
4
|
+
import { OrchestratorConfig } from "../contracts/orchestrator/orchestrator-config.type.mjs";
|
|
5
|
+
import { ResolvedOrchestratorMemory } from "./memory.mjs";
|
|
6
|
+
import { OrchestratorEmitterLike } from "./emitter-port.type.mjs";
|
|
7
|
+
|
|
8
|
+
//#region ../@warlock.js/ai/src/orchestrator/engine-context.type.d.ts
|
|
9
|
+
/**
|
|
10
|
+
* Everything the C2 engine needs to run a turn, assembled once by the
|
|
11
|
+
* C1 factory at construction and passed into every engine entry point
|
|
12
|
+
* (`runTurn` / `streamTurn` / `runResume` / `runCommand`).
|
|
13
|
+
*
|
|
14
|
+
* The factory owns construction, author-time validation, and signature
|
|
15
|
+
* computation; the engine owns the 7-phase lifecycle (orchestrator.md
|
|
16
|
+
* §3). Splitting the config from the resolved stores keeps the engine
|
|
17
|
+
* agnostic to how the factory resolved its `checkpointStore` /
|
|
18
|
+
* `snapshotStore` (own field vs `ai.config` default vs throw).
|
|
19
|
+
*
|
|
20
|
+
* `TState` flows through so the engine's state seed/patch merge is
|
|
21
|
+
* typed against the orchestrator's session state shape.
|
|
22
|
+
*/
|
|
23
|
+
type OrchestratorEngineContext<TOutput = unknown, TState = TOutput, TIntents extends Record<string, SupervisorIntentValue> = Record<string, SupervisorIntentValue>> = {
|
|
24
|
+
/** The validated factory config (C1 has already run author-time checks). */config: OrchestratorConfig<TOutput, TState, TIntents>; /** Structural drift fingerprint computed by C1's `signature.ts`. */
|
|
25
|
+
signature: string;
|
|
26
|
+
/**
|
|
27
|
+
* Resolved durable session store (own field → `ai.config`
|
|
28
|
+
* default). C1 guarantees this is present — it throws
|
|
29
|
+
* `OrchestratorConfigError` at construction when none resolves.
|
|
30
|
+
*/
|
|
31
|
+
checkpointStore: CheckpointStore;
|
|
32
|
+
/**
|
|
33
|
+
* Resolved internal-supervisor snapshot store, or `undefined` when
|
|
34
|
+
* `iterate: false`. C1 guarantees it is present whenever
|
|
35
|
+
* `iterate: true`.
|
|
36
|
+
*/
|
|
37
|
+
snapshotStore: SnapshotStore | undefined;
|
|
38
|
+
/**
|
|
39
|
+
* The orchestrator-scope event emitter (3-tier: definition →
|
|
40
|
+
* instance → per-call). Owned by C1; the engine calls `emit` per
|
|
41
|
+
* phase. Kept structurally minimal so the engine never depends on
|
|
42
|
+
* C1's concrete emitter class.
|
|
43
|
+
*/
|
|
44
|
+
emitter: OrchestratorEmitterLike;
|
|
45
|
+
/**
|
|
46
|
+
* Resolved per-turn memory wiring (memory core M2), or `undefined`
|
|
47
|
+
* when the config declared no `memory`. Resolved once by the engine
|
|
48
|
+
* at construction from the bare-store / config form so the lifecycle
|
|
49
|
+
* reads one flat shape. When present, Phase 5 recalls + injects before
|
|
50
|
+
* dispatch and remembers the outcome after a clean turn.
|
|
51
|
+
*/
|
|
52
|
+
memory?: ResolvedOrchestratorMemory;
|
|
53
|
+
};
|
|
54
|
+
//#endregion
|
|
55
|
+
export { OrchestratorEngineContext };
|
|
56
|
+
//# sourceMappingURL=engine-context.type.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"engine-context.type.d.mts","names":[],"sources":["../../../../../../../@warlock.js/ai/src/orchestrator/engine-context.type.ts"],"mappings":";;;;;;;;;;AAqBA;;;;;;;;;;;;KAAY,yBAAA,6BAED,OAAA,mBACQ,MAAA,SAAe,qBAAA,IAAyB,MAAA,SAEvD,qBAAA;EAkBa,4EAdf,MAAA,EAAQ,kBAAA,CAAmB,OAAA,EAAS,MAAA,EAAQ,QAAA,GA6BnC;EA3BT,SAAA;EA2BmC;;;;;EArBnC,eAAA,EAAiB,eAAA;EAde;;;;;EAoBhC,aAAA,EAAe,aAAA;EAdqB;;;;;;EAqBpC,OAAA,EAAS,uBAAA;EAAT;;;;;AAQmC;;EAAnC,MAAA,GAAS,0BAAA;AAAA"}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { Message } from "../contracts/conversation-message.type.mjs";
|
|
2
|
+
import { SupervisorInput } from "../contracts/supervisor/supervisor-input.type.mjs";
|
|
3
|
+
import { OrchestratorResult } from "../contracts/result/orchestrator-result.type.mjs";
|
|
4
|
+
import { OrchestratorCommands } from "../contracts/orchestrator/orchestrator-commands.type.mjs";
|
|
5
|
+
import { OrchestratorExecuteOptions, OrchestratorResumeOptions } from "../contracts/orchestrator/orchestrator-execute-options.type.mjs";
|
|
6
|
+
import { OrchestratorConfig } from "../contracts/orchestrator/orchestrator-config.type.mjs";
|
|
7
|
+
import { OrchestratorEmitter } from "./emitter.mjs";
|
|
8
|
+
import { ResolvedIntentEntry } from "../supervisor/entries.mjs";
|
|
9
|
+
import { OrchestratorEngineContext } from "./engine-context.type.mjs";
|
|
10
|
+
import { OrchestratorStreamController } from "./orchestrator-stream.mjs";
|
|
11
|
+
|
|
12
|
+
//#region ../@warlock.js/ai/src/orchestrator/execution.d.ts
|
|
13
|
+
/**
|
|
14
|
+
* Constructor params the C1 factory passes when building an
|
|
15
|
+
* {@link OrchestratorExecution} per call. The factory owns author-time
|
|
16
|
+
* validation, intent-entry resolution, and signature computation; it
|
|
17
|
+
* hands the engine the validated `config`, the resolved `entries`, the
|
|
18
|
+
* computed `signature`, and the shared three-tier `emitter`. The
|
|
19
|
+
* per-call inputs vary by entry point:
|
|
20
|
+
*
|
|
21
|
+
* - `execute` / `stream` — `input` + `options` (and `streamController`
|
|
22
|
+
* for `stream`).
|
|
23
|
+
* - `resume` — `resumeSessionId` + `resumeOptions`.
|
|
24
|
+
* - `command("compact")` — neither; `compact(args)` carries its own.
|
|
25
|
+
*/
|
|
26
|
+
type OrchestratorExecutionParams<TOutput, TState> = {
|
|
27
|
+
config: OrchestratorConfig<TOutput, TState>; /** Resolved intent entries (validated by C1; the engine delegates dispatch to the supervisor). */
|
|
28
|
+
entries?: Map<string, ResolvedIntentEntry>;
|
|
29
|
+
signature: string;
|
|
30
|
+
emitter: OrchestratorEmitter;
|
|
31
|
+
input?: SupervisorInput;
|
|
32
|
+
options?: OrchestratorExecuteOptions<TState>;
|
|
33
|
+
streamController?: OrchestratorStreamController<OrchestratorResult<TOutput>>;
|
|
34
|
+
resumeSessionId?: string;
|
|
35
|
+
resumeOptions?: OrchestratorResumeOptions;
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* Per-call lifecycle engine — the single object the C1 factory
|
|
39
|
+
* constructs and drives. Owns the 7-phase lifecycle (orchestrator.md §3:
|
|
40
|
+
* load → drift → lock → window → dispatch → persist → compaction),
|
|
41
|
+
* resolving the durable stores (own config field → `ai.config` default)
|
|
42
|
+
* and adapting C1's three-tier {@link OrchestratorEmitter} to the
|
|
43
|
+
* {@link OrchestratorEmitterLike} port the phase modules call.
|
|
44
|
+
*
|
|
45
|
+
* The factory creates a fresh instance per `execute` / `stream` /
|
|
46
|
+
* `resume` / `command` call (single-call lifecycle invariant — §18.8);
|
|
47
|
+
* the heavy lifting lives in the standalone phase functions
|
|
48
|
+
* ({@link runTurn} / {@link runResume}) which this class delegates to.
|
|
49
|
+
*
|
|
50
|
+
* @example
|
|
51
|
+
* const execution = new OrchestratorExecution({
|
|
52
|
+
* config, entries, signature, emitter, input, options,
|
|
53
|
+
* });
|
|
54
|
+
* const result = await execution.run();
|
|
55
|
+
*/
|
|
56
|
+
declare class OrchestratorExecution<TOutput, TState> {
|
|
57
|
+
private readonly params;
|
|
58
|
+
private readonly ctx;
|
|
59
|
+
private readonly streamController?;
|
|
60
|
+
constructor(params: OrchestratorExecutionParams<TOutput, TState>);
|
|
61
|
+
/**
|
|
62
|
+
* `execute()` / `stream()` entry — run one turn through the 7-phase
|
|
63
|
+
* lifecycle. When a `streamController` was supplied, the adapter mirrors
|
|
64
|
+
* every emitted event into the stream and the controller is settled
|
|
65
|
+
* (`end` / `fail`) once the result resolves.
|
|
66
|
+
*/
|
|
67
|
+
run(): Promise<OrchestratorResult<TOutput>>;
|
|
68
|
+
/**
|
|
69
|
+
* `resume()` entry — drain an interrupted `iterate: true` turn (§9).
|
|
70
|
+
* Returns `null` when nothing is in flight.
|
|
71
|
+
*/
|
|
72
|
+
resume(): Promise<OrchestratorResult<TOutput> | null>;
|
|
73
|
+
/**
|
|
74
|
+
* `command("compact")` entry — run a manual compaction on demand (§11 /
|
|
75
|
+
* §12.1). Reuses the post-turn compaction code path against the
|
|
76
|
+
* caller-supplied history and returns the raw {@link CompactionResult}.
|
|
77
|
+
*/
|
|
78
|
+
compact(args: OrchestratorCommands["compact"]["args"]): Promise<OrchestratorCommands["compact"]["result"]>;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Run one turn end-to-end through the 7-phase lifecycle (orchestrator
|
|
82
|
+
* .md §3). The single entry the C1 factory's `execute()` delegates to.
|
|
83
|
+
*
|
|
84
|
+
* Phase order is the diagram's contract: load → drift → lock → window
|
|
85
|
+
* → dispatch → persist → compaction. Drift / config misuse throw;
|
|
86
|
+
* every other failure surfaces on `result.error` (the contract: the
|
|
87
|
+
* orchestrator never throws on runtime failure). Cancellation and
|
|
88
|
+
* failure do NOT persist a fresh checkpoint (§17 — state reverts to the
|
|
89
|
+
* pre-turn checkpoint).
|
|
90
|
+
*/
|
|
91
|
+
declare function runTurn<TOutput, TState>(ctx: OrchestratorEngineContext<TOutput, TState>, input: SupervisorInput, options: OrchestratorExecuteOptions<TState>): Promise<OrchestratorResult<TOutput>>;
|
|
92
|
+
/**
|
|
93
|
+
* §9 resume protocol entry the C1 factory's `resume()` delegates to.
|
|
94
|
+
* Returns `null` when no in-flight `iterate: true` turn is detected;
|
|
95
|
+
* otherwise drains the interrupted supervisor run, persists a fresh
|
|
96
|
+
* checkpoint for the resumed turn, and returns the completed result.
|
|
97
|
+
*
|
|
98
|
+
* Runs the same Phase 2 drift check as `runTurn` (§9.4). The heavy
|
|
99
|
+
* lifting lives in `resume.ts`; this wrapper threads the engine
|
|
100
|
+
* context.
|
|
101
|
+
*/
|
|
102
|
+
declare function runResume<TOutput, TState>(ctx: OrchestratorEngineContext<TOutput, TState>, sessionId: string, options?: OrchestratorResumeOptions): Promise<OrchestratorResult<TOutput> | null>;
|
|
103
|
+
/**
|
|
104
|
+
* The `stream()` entry. The orchestrator's streaming surface bubbles
|
|
105
|
+
* child agent/supervisor events under their own namespace (§14.2); the
|
|
106
|
+
* C1 stream controller owns the `StreamContract` wiring. This engine
|
|
107
|
+
* entry runs the same lifecycle as `runTurn` — the C1 factory passes a
|
|
108
|
+
* per-call `on` bag wired to the stream controller, so the engine needs
|
|
109
|
+
* no streaming-specific branch. Exposed as a distinct name for the
|
|
110
|
+
* factory to call, returning the same `OrchestratorResult` the stream's
|
|
111
|
+
* `.result` resolves to.
|
|
112
|
+
*/
|
|
113
|
+
declare function streamTurn<TOutput, TState>(ctx: OrchestratorEngineContext<TOutput, TState>, input: SupervisorInput, options: OrchestratorExecuteOptions<TState>): Promise<OrchestratorResult<TOutput>>;
|
|
114
|
+
//#endregion
|
|
115
|
+
export { OrchestratorExecution, OrchestratorExecutionParams, runResume, runTurn, streamTurn };
|
|
116
|
+
//# sourceMappingURL=execution.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"execution.d.mts","names":[],"sources":["../../../../../../../@warlock.js/ai/src/orchestrator/execution.ts"],"mappings":";;;;;;;;;;;;;;AAmEA;;;;;;;;;;;KAAY,2BAAA;EACV,MAAA,EAAQ,kBAAA,CAAmB,OAAA,EAAS,MAAA,GAOY;EALhD,OAAA,GAAU,GAAA,SAAY,mBAAA;EACtB,SAAA;EACA,OAAA,EAAS,mBAAA;EACT,KAAA,GAAQ,eAAA;EACR,OAAA,GAAU,0BAAA,CAA2B,MAAA;EACrC,gBAAA,GAAmB,4BAAA,CAA6B,kBAAA,CAAmB,OAAA;EACnE,eAAA;EACA,aAAA,GAAgB,yBAAA;AAAA;;;;;;;;;;;;;;;;;;;;cAsBL,qBAAA;EAAA,iBACM,MAAA;EAAA,iBACA,GAAA;EAAA,iBACA,gBAAA;cAIE,MAAA,EAAQ,2BAAA,CAA4B,OAAA,EAAS,MAAA;EAAT;;;;;;EAyB1C,GAAA,IAAO,OAAA,CAAQ,kBAAA,CAAmB,OAAA;EA4BhB;;;;EAAlB,MAAA,IAAU,OAAA,CAAQ,kBAAA,CAAmB,OAAA;EAiBxC;;;;;EAFG,OAAA,CACX,IAAA,EAAM,oBAAA,sBACL,OAAA,CAAQ,oBAAA;AAAA;;;;;;;;;;;;iBAkPS,OAAA,kBACpB,GAAA,EAAK,yBAAA,CAA0B,OAAA,EAAS,MAAA,GACxC,KAAA,EAAO,eAAA,EACP,OAAA,EAAS,0BAAA,CAA2B,MAAA,IACnC,OAAA,CAAQ,kBAAA,CAAmB,OAAA;;;;;;;;AAtPG;AAkPjC;;iBA2MsB,SAAA,kBACpB,GAAA,EAAK,yBAAA,CAA0B,OAAA,EAAS,MAAA,GACxC,SAAA,UACA,OAAA,GAAU,yBAAA,GACT,OAAA,CAAQ,kBAAA,CAAmB,OAAA;;;;;;;;;;;iBAiDR,UAAA,kBACpB,GAAA,EAAK,yBAAA,CAA0B,OAAA,EAAS,MAAA,GACxC,KAAA,EAAO,eAAA,EACP,OAAA,EAAS,0BAAA,CAA2B,MAAA,IACnC,OAAA,CAAQ,kBAAA,CAAmB,OAAA"}
|