@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,101 @@
|
|
|
1
|
+
//#region ../@warlock.js/ai/src/eval/scorers.ts
|
|
2
|
+
/**
|
|
3
|
+
* Normalize a value for case-insensitive, whitespace-trimmed string
|
|
4
|
+
* comparison. Non-string values are JSON-serialized first so a
|
|
5
|
+
* structured `expected` can still be matched against structured
|
|
6
|
+
* `output`.
|
|
7
|
+
*/
|
|
8
|
+
function normalizeForComparison(value) {
|
|
9
|
+
return (typeof value === "string" ? value : JSON.stringify(value)).trim().toLowerCase();
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Exact-match scorer. Compares the agent's output against the case's
|
|
13
|
+
* `expected` reference. Prefers `result.data` (parsed structured
|
|
14
|
+
* output) when present, falling back to `result.text`. Comparison is
|
|
15
|
+
* trimmed and case-insensitive; structured values are compared by
|
|
16
|
+
* canonical JSON.
|
|
17
|
+
*
|
|
18
|
+
* Scores `1` / `passed: true` on a match, `0` / `passed: false`
|
|
19
|
+
* otherwise. A case with no `expected` always scores `0` — exact
|
|
20
|
+
* matching is meaningless without a reference.
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* const report = await agent.eval({
|
|
24
|
+
* cases: [{ name: "q", input: "2+2?", expected: "4" }],
|
|
25
|
+
* scorers: [exact()],
|
|
26
|
+
* });
|
|
27
|
+
*/
|
|
28
|
+
function exact() {
|
|
29
|
+
return (context) => {
|
|
30
|
+
if (context.case.expected === void 0) return {
|
|
31
|
+
score: 0,
|
|
32
|
+
passed: false,
|
|
33
|
+
reason: "no expected value supplied for exact match"
|
|
34
|
+
};
|
|
35
|
+
const actual = context.output ?? context.text;
|
|
36
|
+
if (actual === void 0) return {
|
|
37
|
+
score: 0,
|
|
38
|
+
passed: false,
|
|
39
|
+
reason: "agent produced no output"
|
|
40
|
+
};
|
|
41
|
+
const matches = normalizeForComparison(actual) === normalizeForComparison(context.case.expected);
|
|
42
|
+
return {
|
|
43
|
+
score: matches ? 1 : 0,
|
|
44
|
+
passed: matches,
|
|
45
|
+
reason: matches ? "exact match" : "output did not match expected"
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Substring / contains scorer. Passes when the normalized `expected`
|
|
51
|
+
* string appears anywhere in the agent's normalized output. Useful
|
|
52
|
+
* when the agent's phrasing varies but a key fact must be present.
|
|
53
|
+
*
|
|
54
|
+
* @example
|
|
55
|
+
* scorers: [contains()] // expected "Cairo" passes "The capital is Cairo."
|
|
56
|
+
*/
|
|
57
|
+
function contains() {
|
|
58
|
+
return (context) => {
|
|
59
|
+
if (context.case.expected === void 0) return {
|
|
60
|
+
score: 0,
|
|
61
|
+
passed: false,
|
|
62
|
+
reason: "no expected value supplied for contains match"
|
|
63
|
+
};
|
|
64
|
+
const actual = context.output ?? context.text;
|
|
65
|
+
if (actual === void 0) return {
|
|
66
|
+
score: 0,
|
|
67
|
+
passed: false,
|
|
68
|
+
reason: "agent produced no output"
|
|
69
|
+
};
|
|
70
|
+
const found = normalizeForComparison(actual).includes(normalizeForComparison(context.case.expected));
|
|
71
|
+
return {
|
|
72
|
+
score: found ? 1 : 0,
|
|
73
|
+
passed: found,
|
|
74
|
+
reason: found ? "expected substring found" : "expected substring not found"
|
|
75
|
+
};
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Predicate scorer. Wraps a boolean-returning callback into a scorer —
|
|
80
|
+
* `true` scores `1` / `passed`, `false` scores `0` / fails. The
|
|
81
|
+
* escape hatch for arbitrary assertions ("output is valid JSON", "no
|
|
82
|
+
* tool errored", "duration under budget") that don't fit exact or
|
|
83
|
+
* judge scoring.
|
|
84
|
+
*
|
|
85
|
+
* @example
|
|
86
|
+
* scorers: [predicate((ctx) => ctx.result.report.children.every(c => c.status === "completed"))]
|
|
87
|
+
*/
|
|
88
|
+
function predicate(fn) {
|
|
89
|
+
return async (context) => {
|
|
90
|
+
const result = await fn(context);
|
|
91
|
+
return {
|
|
92
|
+
score: result ? 1 : 0,
|
|
93
|
+
passed: result,
|
|
94
|
+
reason: result ? "predicate passed" : "predicate failed"
|
|
95
|
+
};
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
//#endregion
|
|
100
|
+
export { contains, exact, predicate };
|
|
101
|
+
//# sourceMappingURL=scorers.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scorers.mjs","names":[],"sources":["../../../../../../../@warlock.js/ai/src/eval/scorers.ts"],"sourcesContent":["import type {\n EvalScore,\n EvalScorer,\n EvalScorerContext,\n} from \"../contracts/agent/eval.type\";\n\n/**\n * Predicate signature for {@link predicate}. Receives the same context\n * a full scorer does and returns a boolean (sync or async). A `true`\n * verdict scores `1`, `false` scores `0`.\n */\nexport type EvalPredicate<TOutput = unknown> = (\n context: EvalScorerContext<TOutput>,\n) => boolean | Promise<boolean>;\n\n/**\n * Normalize a value for case-insensitive, whitespace-trimmed string\n * comparison. Non-string values are JSON-serialized first so a\n * structured `expected` can still be matched against structured\n * `output`.\n */\nfunction normalizeForComparison(value: unknown): string {\n const text = typeof value === \"string\" ? value : JSON.stringify(value);\n return text.trim().toLowerCase();\n}\n\n/**\n * Exact-match scorer. Compares the agent's output against the case's\n * `expected` reference. Prefers `result.data` (parsed structured\n * output) when present, falling back to `result.text`. Comparison is\n * trimmed and case-insensitive; structured values are compared by\n * canonical JSON.\n *\n * Scores `1` / `passed: true` on a match, `0` / `passed: false`\n * otherwise. A case with no `expected` always scores `0` — exact\n * matching is meaningless without a reference.\n *\n * @example\n * const report = await agent.eval({\n * cases: [{ name: \"q\", input: \"2+2?\", expected: \"4\" }],\n * scorers: [exact()],\n * });\n */\nexport function exact<TOutput = unknown>(): EvalScorer<TOutput> {\n return (context: EvalScorerContext<TOutput>): EvalScore => {\n if (context.case.expected === undefined) {\n return {\n score: 0,\n passed: false,\n reason: \"no expected value supplied for exact match\",\n };\n }\n\n const actual = context.output ?? context.text;\n\n if (actual === undefined) {\n return { score: 0, passed: false, reason: \"agent produced no output\" };\n }\n\n const matches =\n normalizeForComparison(actual) === normalizeForComparison(context.case.expected);\n\n return {\n score: matches ? 1 : 0,\n passed: matches,\n reason: matches ? \"exact match\" : \"output did not match expected\",\n };\n };\n}\n\n/**\n * Substring / contains scorer. Passes when the normalized `expected`\n * string appears anywhere in the agent's normalized output. Useful\n * when the agent's phrasing varies but a key fact must be present.\n *\n * @example\n * scorers: [contains()] // expected \"Cairo\" passes \"The capital is Cairo.\"\n */\nexport function contains<TOutput = unknown>(): EvalScorer<TOutput> {\n return (context: EvalScorerContext<TOutput>): EvalScore => {\n if (context.case.expected === undefined) {\n return {\n score: 0,\n passed: false,\n reason: \"no expected value supplied for contains match\",\n };\n }\n\n const actual = context.output ?? context.text;\n\n if (actual === undefined) {\n return { score: 0, passed: false, reason: \"agent produced no output\" };\n }\n\n const found = normalizeForComparison(actual).includes(\n normalizeForComparison(context.case.expected),\n );\n\n return {\n score: found ? 1 : 0,\n passed: found,\n reason: found ? \"expected substring found\" : \"expected substring not found\",\n };\n };\n}\n\n/**\n * Predicate scorer. Wraps a boolean-returning callback into a scorer —\n * `true` scores `1` / `passed`, `false` scores `0` / fails. The\n * escape hatch for arbitrary assertions (\"output is valid JSON\", \"no\n * tool errored\", \"duration under budget\") that don't fit exact or\n * judge scoring.\n *\n * @example\n * scorers: [predicate((ctx) => ctx.result.report.children.every(c => c.status === \"completed\"))]\n */\nexport function predicate<TOutput = unknown>(\n fn: EvalPredicate<TOutput>,\n): EvalScorer<TOutput> {\n return async (context: EvalScorerContext<TOutput>): Promise<EvalScore> => {\n const result = await fn(context);\n\n return {\n score: result ? 1 : 0,\n passed: result,\n reason: result ? \"predicate passed\" : \"predicate failed\",\n };\n };\n}\n"],"mappings":";;;;;;;AAqBA,SAAS,uBAAuB,OAAwB;CAEtD,QADa,OAAO,UAAU,WAAW,QAAQ,KAAK,UAAU,KAAK,EAC1D,CAAC,KAAK,CAAC,CAAC,YAAY;AACjC;;;;;;;;;;;;;;;;;;AAmBA,SAAgB,QAAgD;CAC9D,QAAQ,YAAmD;EACzD,IAAI,QAAQ,KAAK,aAAa,QAC5B,OAAO;GACL,OAAO;GACP,QAAQ;GACR,QAAQ;EACV;EAGF,MAAM,SAAS,QAAQ,UAAU,QAAQ;EAEzC,IAAI,WAAW,QACb,OAAO;GAAE,OAAO;GAAG,QAAQ;GAAO,QAAQ;EAA2B;EAGvE,MAAM,UACJ,uBAAuB,MAAM,MAAM,uBAAuB,QAAQ,KAAK,QAAQ;EAEjF,OAAO;GACL,OAAO,UAAU,IAAI;GACrB,QAAQ;GACR,QAAQ,UAAU,gBAAgB;EACpC;CACF;AACF;;;;;;;;;AAUA,SAAgB,WAAmD;CACjE,QAAQ,YAAmD;EACzD,IAAI,QAAQ,KAAK,aAAa,QAC5B,OAAO;GACL,OAAO;GACP,QAAQ;GACR,QAAQ;EACV;EAGF,MAAM,SAAS,QAAQ,UAAU,QAAQ;EAEzC,IAAI,WAAW,QACb,OAAO;GAAE,OAAO;GAAG,QAAQ;GAAO,QAAQ;EAA2B;EAGvE,MAAM,QAAQ,uBAAuB,MAAM,CAAC,CAAC,SAC3C,uBAAuB,QAAQ,KAAK,QAAQ,CAC9C;EAEA,OAAO;GACL,OAAO,QAAQ,IAAI;GACnB,QAAQ;GACR,QAAQ,QAAQ,6BAA6B;EAC/C;CACF;AACF;;;;;;;;;;;AAYA,SAAgB,UACd,IACqB;CACrB,OAAO,OAAO,YAA4D;EACxE,MAAM,SAAS,MAAM,GAAG,OAAO;EAE/B,OAAO;GACL,OAAO,SAAS,IAAI;GACpB,QAAQ;GACR,QAAQ,SAAS,qBAAqB;EACxC;CACF;AACF"}
|
package/esm/index.d.mts
CHANGED
|
@@ -21,8 +21,10 @@ import { ExecuteResult } from "./contracts/result/execute-result.type.mjs";
|
|
|
21
21
|
import { ExecutableContract } from "./contracts/executable.contract.mjs";
|
|
22
22
|
import { StreamEvent, StreamEventBody } from "./contracts/stream/stream-event.type.mjs";
|
|
23
23
|
import { StreamContract } from "./contracts/stream/stream.contract.mjs";
|
|
24
|
+
import { EvalCase, EvalCaseResult, EvalJudge, EvalOptions, EvalReport, EvalScore, EvalScorer, EvalScorerContext } from "./contracts/agent/eval.type.mjs";
|
|
24
25
|
import { AgentContract, AgentEventHandler } from "./contracts/agent/agent.contract.mjs";
|
|
25
26
|
import { END, EndSentinel } from "./contracts/end.type.mjs";
|
|
27
|
+
import { SupervisorReport, SupervisorResult, SupervisorTerminatedBy } from "./contracts/result/supervisor-result.type.mjs";
|
|
26
28
|
import { StepSnapshot } from "./contracts/result/step-result.type.mjs";
|
|
27
29
|
import { WorkflowReport, WorkflowResult } from "./contracts/result/workflow-result.type.mjs";
|
|
28
30
|
import { ToolConfig, ToolContext, ToolMeta, ToolMode } from "./contracts/tool.contract.mjs";
|
|
@@ -39,6 +41,13 @@ import { SupervisorFailedError } from "./errors/supervisor-failed-error.mjs";
|
|
|
39
41
|
import { MaxIterationsError, MaxIterationsErrorOptions } from "./errors/max-iterations-error.mjs";
|
|
40
42
|
import { WorkflowError } from "./errors/workflow-error.mjs";
|
|
41
43
|
import { MaxStepsExceededError, MaxStepsExceededErrorOptions } from "./errors/max-steps-exceeded-error.mjs";
|
|
44
|
+
import { OrchestratorFailedError } from "./errors/orchestrator-failed-error.mjs";
|
|
45
|
+
import { OrchestratorCancelledError, OrchestratorCancelledErrorOptions } from "./errors/orchestrator-cancelled-error.mjs";
|
|
46
|
+
import { OrchestratorConfigError } from "./errors/orchestrator-config-error.mjs";
|
|
47
|
+
import { OrchestratorDriftError, OrchestratorDriftErrorOptions } from "./errors/orchestrator-drift-error.mjs";
|
|
48
|
+
import { PlannerFailedError } from "./errors/planner-failed-error.mjs";
|
|
49
|
+
import { PlannerCancelledError, PlannerCancelledErrorOptions } from "./errors/planner-cancelled-error.mjs";
|
|
50
|
+
import { PlannerPlanInvalidError } from "./errors/planner-plan-invalid-error.mjs";
|
|
42
51
|
import { ProviderAuthError } from "./errors/provider-auth-error.mjs";
|
|
43
52
|
import { ProviderRateLimitError, ProviderRateLimitErrorOptions } from "./errors/provider-rate-limit-error.mjs";
|
|
44
53
|
import { ProviderTimeoutError } from "./errors/provider-timeout-error.mjs";
|
|
@@ -53,76 +62,128 @@ import { ToolExecutionError, ToolExecutionErrorOptions } from "./errors/tool-exe
|
|
|
53
62
|
import { WorkflowCancelledError, WorkflowCancelledErrorOptions } from "./errors/workflow-cancelled-error.mjs";
|
|
54
63
|
import { WorkflowDriftError, WorkflowDriftErrorOptions } from "./errors/workflow-drift-error.mjs";
|
|
55
64
|
import { ToolContract, ToolInvokeResult, tool } from "./tool/tool.mjs";
|
|
65
|
+
import { SupervisorInput } from "./contracts/supervisor/supervisor-input.type.mjs";
|
|
66
|
+
import { SupervisorSnapshot, SupervisorSnapshotStatus } from "./contracts/supervisor/supervisor-snapshot.type.mjs";
|
|
67
|
+
import { PgClientLike, RedisClientLike, SnapshotStore } from "./contracts/orchestrator/snapshot-store.contract.mjs";
|
|
56
68
|
import { NextStepResult } from "./contracts/workflow/next-step-result.type.mjs";
|
|
57
69
|
import { RetryBackoff, RetryConfig } from "./contracts/workflow/retry-config.type.mjs";
|
|
58
70
|
import { WorkflowContext } from "./contracts/workflow/workflow-context.type.mjs";
|
|
59
71
|
import { StepAgentInput, StepDefinition, StepLocalEvents, StepOutputSpec } from "./contracts/workflow/step.contract.mjs";
|
|
72
|
+
import { WorkflowSnapshot } from "./contracts/workflow/workflow-snapshot.type.mjs";
|
|
60
73
|
import { WorkflowDefinition, WorkflowEventHandler, WorkflowEventHandlers, WorkflowExecuteOptions, WorkflowInstance, WorkflowResumeOptions, WorkflowRunOptions } from "./contracts/workflow/workflow.contract.mjs";
|
|
74
|
+
import { AgentToolEntry, ExecutableTool, executableToTool, isExecutableTool, normalizeAgentTools } from "./tool/executable-as-tool.mjs";
|
|
75
|
+
import { ModelCallOptions, ModelCapabilities, ModelContract, ModelResponse, ModelStreamChunk, ReasoningEffort } from "./contracts/model.contract.mjs";
|
|
76
|
+
import { SupervisorExecuteOptions, SupervisorResumeOptions } from "./contracts/supervisor/supervisor-execute-options.type.mjs";
|
|
77
|
+
import { MiddlewareState } from "./contracts/middleware/middleware-state.type.mjs";
|
|
78
|
+
import { MiddlewareAgentRef, MiddlewareExecuteContext, MiddlewareModelRef, MiddlewareSupervisorContext, MiddlewareSupervisorRef, MiddlewareToolContext, MiddlewareTripContext } from "./contracts/middleware/middleware-context.type.mjs";
|
|
79
|
+
import { AgentMiddleware, AgentMiddlewareExecuteHooks, AgentMiddlewareSupervisorHooks, AgentMiddlewareToolHooks, AgentMiddlewareTripHooks } from "./contracts/middleware/middleware.contract.mjs";
|
|
61
80
|
import { Placeholders } from "./contracts/placeholders.type.mjs";
|
|
62
81
|
import { InstructionContract, PersonaContract, SystemPromptBlockContract, SystemPromptContract } from "./contracts/system-prompt.contract.mjs";
|
|
63
|
-
import { Next } from "./contracts/supervisor/next.type.mjs";
|
|
64
|
-
import { AckSnapshot, AgentBranchSnapshot, DecisionSource, IterationDecision, IterationSnapshot } from "./contracts/supervisor/iteration-snapshot.type.mjs";
|
|
65
|
-
import { SupervisorInput } from "./contracts/supervisor/supervisor-input.type.mjs";
|
|
66
|
-
import { EvaluateBranchResult, EvaluateContext, EvaluateResult } from "./contracts/supervisor/evaluate-context.type.mjs";
|
|
67
82
|
import { RouteContext } from "./contracts/supervisor/route-context.type.mjs";
|
|
68
83
|
import { AckCallback, AckConfig, AckEntry, AckRunEntry } from "./contracts/supervisor/ack-entry.type.mjs";
|
|
69
84
|
import { DispatchRawResult, IntentCallback, IntentEntry, IntentRunEntry, SupervisorIntentValue } from "./contracts/supervisor/intent-entry.type.mjs";
|
|
85
|
+
import { Next } from "./contracts/supervisor/next.type.mjs";
|
|
70
86
|
import { RouterEntry } from "./contracts/supervisor/router-entry.type.mjs";
|
|
71
87
|
import { SupervisorConfig, SupervisorEventHandler, SupervisorEventHandlers } from "./contracts/supervisor/supervisor-config.type.mjs";
|
|
72
|
-
import { SupervisorExecuteOptions, SupervisorResumeOptions } from "./contracts/supervisor/supervisor-execute-options.type.mjs";
|
|
73
88
|
import { SupervisorStreamEvent } from "./contracts/supervisor/supervisor-stream-event.type.mjs";
|
|
74
89
|
import { SupervisorAsToolOptions, SupervisorContract } from "./contracts/supervisor/supervisor.contract.mjs";
|
|
75
90
|
import { DispatchContext, IntentRunner, IntentRunnerMap } from "./contracts/supervisor/dispatch-context.type.mjs";
|
|
76
91
|
import { ClassifierAgentEntry, ClassifierCallback, ClassifierConfig, ClassifierContext, ClassifierOutput, ClassifierRefineContext, ClassifierRefineResult, ClassifierRunEntry, ClassifierSnapshot } from "./contracts/supervisor/classifier-context.type.mjs";
|
|
77
|
-
import {
|
|
92
|
+
import { EvaluateBranchResult, EvaluateContext, EvaluateResult } from "./contracts/supervisor/evaluate-context.type.mjs";
|
|
93
|
+
import { AckSnapshot, AgentBranchSnapshot, DecisionSource, IterationDecision, IterationSnapshot } from "./contracts/supervisor/iteration-snapshot.type.mjs";
|
|
94
|
+
import { CompactionResult, OrchestratorAwaitingStatus, OrchestratorReport, OrchestratorReportStatus, OrchestratorReportType, OrchestratorResult, TurnSnapshot } from "./contracts/result/orchestrator-result.type.mjs";
|
|
78
95
|
import { SessionSendResult } from "./contracts/result/session-send-result.type.mjs";
|
|
79
|
-
import { SupervisorSnapshot, SupervisorSnapshotStatus } from "./contracts/supervisor/supervisor-snapshot.type.mjs";
|
|
80
96
|
import { SupervisorAgentCompletedPayload, SupervisorAgentFailedPayload, SupervisorAgentStartingPayload, SupervisorAgentStreamingPayload, SupervisorCancelledPayload, SupervisorCompletedPayload, SupervisorErrorPayload, SupervisorEvaluateVerdictPayload, SupervisorIterationCompletedPayload, SupervisorIterationStartingPayload, SupervisorRouterDecidedPayload, SupervisorRouterDecidingPayload, SupervisorStartingPayload } from "./contracts/events/supervisor-events.type.mjs";
|
|
81
97
|
import { WorkflowCancelledPayload, WorkflowCompletedPayload, WorkflowErrorPayload, WorkflowLoopWarningPayload, WorkflowStartingPayload, WorkflowStepCompletedPayload, WorkflowStepFailedPayload, WorkflowStepRetryingPayload, WorkflowStepSkippedPayload, WorkflowStepStartingPayload, WorkflowStepStreamingPayload } from "./contracts/events/workflow-events.type.mjs";
|
|
82
98
|
import { AgentEventMap, SupervisorEventMap, WorkflowEventMap } from "./contracts/events/event-map.type.mjs";
|
|
83
99
|
import { StreamingToolGuardConfig } from "./contracts/streaming-tool-guard-config.type.mjs";
|
|
84
100
|
import { AgentExecuteOptions } from "./contracts/agent/agent-options.type.mjs";
|
|
85
101
|
import { EmbedderConfig, EmbedderContract, EmbeddingBatchResult, EmbeddingResult, EmbeddingUsage } from "./contracts/embedder.contract.mjs";
|
|
86
|
-
import {
|
|
87
|
-
import {
|
|
88
|
-
import {
|
|
89
|
-
import {
|
|
102
|
+
import { MemoryItem, MemoryTier, RecalledMemory } from "./contracts/memory/memory-item.type.mjs";
|
|
103
|
+
import { RecallOptions } from "./contracts/memory/recall-options.type.mjs";
|
|
104
|
+
import { MemoryContract } from "./contracts/memory/memory.contract.mjs";
|
|
105
|
+
import { EpisodicMemoryConfig, MemoryConfig, ProceduralMemoryConfig, SemanticMemoryConfig } from "./contracts/memory/memory-config.type.mjs";
|
|
106
|
+
import { CheckpointRecord, CheckpointStore } from "./contracts/orchestrator/checkpoint-store.contract.mjs";
|
|
107
|
+
import { OrchestratorCommands } from "./contracts/orchestrator/orchestrator-commands.type.mjs";
|
|
108
|
+
import { OrchestratorEvent, OrchestratorEventHandler, OrchestratorEventHandlers, OrchestratorEventMap, OrchestratorEventName } from "./contracts/orchestrator/orchestrator-event.type.mjs";
|
|
109
|
+
import { OrchestratorExecuteOptions, OrchestratorResumeOptions } from "./contracts/orchestrator/orchestrator-execute-options.type.mjs";
|
|
110
|
+
import { OrchestratorAsToolOptions, OrchestratorContract, OrchestratorSessionScope, SessionContextOverrides } from "./contracts/orchestrator/orchestrator.contract.mjs";
|
|
111
|
+
import { OrchestratorConfig, OrchestratorMemoryConfig, SummarizeCallback, SummarizeConfig } from "./contracts/orchestrator/orchestrator-config.type.mjs";
|
|
112
|
+
import { SessionContract } from "./contracts/orchestrator/session.contract.mjs";
|
|
113
|
+
import { PlannerCapability } from "./contracts/planner/planner-capability.type.mjs";
|
|
114
|
+
import { PlannerConfig } from "./contracts/planner/planner-config.type.mjs";
|
|
115
|
+
import { PlannerExecuteOptions } from "./contracts/planner/planner-execute-options.type.mjs";
|
|
116
|
+
import { PlannerPlan, PlannerStep } from "./contracts/planner/planner-plan.type.mjs";
|
|
117
|
+
import { PlannerReport, PlannerReportType, PlannerResult, PlannerStepSnapshot } from "./contracts/planner/planner-result.type.mjs";
|
|
118
|
+
import { PlannerContract } from "./contracts/planner/planner.contract.mjs";
|
|
90
119
|
import { ModelConfig, SDKAdapterContract } from "./contracts/sdk-adapter.contract.mjs";
|
|
91
|
-
import { WorkflowSnapshot } from "./contracts/workflow/workflow-snapshot.type.mjs";
|
|
92
120
|
import { CompleteEvent } from "./contracts/events/complete-event.type.mjs";
|
|
93
121
|
import { UsageEvent } from "./contracts/events/usage-event.type.mjs";
|
|
94
122
|
import { AgentConfig } from "./agent/agent-config.type.mjs";
|
|
95
123
|
import { agent } from "./agent/agent.mjs";
|
|
96
124
|
import { StreamController, createAgentStream } from "./agent/agent-stream.mjs";
|
|
97
|
-
import {
|
|
98
|
-
import { BudgetOptions, BudgetPricing, budget } from "./middleware/builtins/budget.mjs";
|
|
125
|
+
import { BudgetContract, BudgetContractDimension, BudgetContractFallback, BudgetContractViolation, BudgetContractViolationMode } from "./middleware/builtins/budget-contract.type.mjs";
|
|
126
|
+
import { BudgetFallbackSignal, BudgetOptions, BudgetPricing, budget, readBudgetFallbackSignal } from "./middleware/builtins/budget.mjs";
|
|
127
|
+
import { SpawnSubAgentSpec, spawnSubAgent } from "./agent/spawn-sub-agent.mjs";
|
|
128
|
+
import { SystemPrompt, systemPrompt } from "./system-prompt/system-prompt.mjs";
|
|
129
|
+
import { judge } from "./eval/judge-scorer.mjs";
|
|
130
|
+
import { EvalPredicate, contains, exact, predicate } from "./eval/scorers.mjs";
|
|
131
|
+
import { runEval } from "./eval/eval-runner.mjs";
|
|
132
|
+
import { evalScorers } from "./eval/index.mjs";
|
|
133
|
+
import { BatchItemHandler, BatchItemResult, BatchItemStatus, BatchOptions, BatchReport, BatchResult } from "./batch/batch.type.mjs";
|
|
134
|
+
import { batch } from "./batch/batch.mjs";
|
|
135
|
+
import { memory } from "./checkpoint/memory.mjs";
|
|
136
|
+
import { PgCheckpointOptions, pg } from "./checkpoint/pg.mjs";
|
|
137
|
+
import { RedisCheckpointOptions, redis } from "./checkpoint/redis.mjs";
|
|
138
|
+
import { AIConfig, getAIConfig, resolveDefaultCheckpointStore, resolveDefaultSnapshotStore, resolveDefaultStore, setAIConfig } from "./config.mjs";
|
|
139
|
+
import { memory as memory$1 } from "./memory/memory.mjs";
|
|
99
140
|
import { GuardrailCheck, GuardrailCheckResult, GuardrailOptions, guardrail } from "./middleware/builtins/guardrail.mjs";
|
|
100
141
|
import { SemanticCacheOptions, semanticCache } from "./middleware/builtins/semantic-cache.mjs";
|
|
101
142
|
import { composeMiddleware } from "./middleware/helpers/compose.mjs";
|
|
102
143
|
import { forTool } from "./middleware/helpers/for-tool.mjs";
|
|
103
|
-
import { supervisor } from "./supervisor/supervisor.mjs";
|
|
104
|
-
import { Instruction, instruction } from "./system-prompt/instruction.mjs";
|
|
105
|
-
import { Persona, persona } from "./system-prompt/persona.mjs";
|
|
106
|
-
import { SystemPrompt, systemPrompt } from "./system-prompt/system-prompt.mjs";
|
|
107
|
-
import { step } from "./workflow/step.mjs";
|
|
108
|
-
import { workflow } from "./workflow/workflow.mjs";
|
|
109
|
-
import { ai } from "./ai.mjs";
|
|
110
|
-
import { MiddlewareContextByLevel, MiddlewareLevel, runPipeline } from "./middleware/pipeline.mjs";
|
|
111
|
-
import { extractUserText } from "./middleware/utils/extract-user-text.mjs";
|
|
112
|
-
import { NamespacedStateAccessor, namespacedState } from "./middleware/utils/namespaced-state.mjs";
|
|
113
144
|
import { MockModelResponse, MockSDKConfig } from "./mock/mock-config.type.mjs";
|
|
114
145
|
import { mockAgent } from "./mock/mock-agent.mjs";
|
|
115
146
|
import { MockModel } from "./mock/mock-model.mjs";
|
|
147
|
+
import { MockRouterDecision, MockRouterExhaustion, MockRouterOptions, mockRouter } from "./mock/mock-router.mjs";
|
|
116
148
|
import { MockSDK } from "./mock/mock-sdk.mjs";
|
|
117
|
-
import {
|
|
149
|
+
import { FallbackAttempt, FallbackModelContract, FallbackModelOptions, FallbackRetryPredicate } from "./contracts/fallback-model.contract.mjs";
|
|
150
|
+
import { fallbackModel } from "./model/fallback-model.mjs";
|
|
151
|
+
import { asTool } from "./orchestrator/as-tool.mjs";
|
|
152
|
+
import { OrchestratorCommandHandlers, createCommandDispatcher } from "./orchestrator/commands.mjs";
|
|
153
|
+
import { OrchestratorEmitter } from "./orchestrator/emitter.mjs";
|
|
154
|
+
import { ResolvedOrchestratorMemory, injectMemories, memoryQueryFromInput, outcomeTextFromTurn, recallForTurn, rememberTurnOutcome, resolveOrchestratorMemory } from "./orchestrator/memory.mjs";
|
|
155
|
+
import { ResolvedIntentEntry, resolveIntentEntries } from "./supervisor/entries.mjs";
|
|
156
|
+
import { OrchestratorStreamController, createOrchestratorStream } from "./orchestrator/orchestrator-stream.mjs";
|
|
157
|
+
import { OrchestratorExecution, OrchestratorExecutionParams, runResume, runTurn, streamTurn } from "./orchestrator/execution.mjs";
|
|
158
|
+
import { orchestrator } from "./orchestrator/orchestrator.mjs";
|
|
159
|
+
import { computeOrchestratorSignature } from "./orchestrator/signature.mjs";
|
|
160
|
+
import { planner } from "./planner/planner.mjs";
|
|
161
|
+
import { planSchema } from "./planner/plan-schema.mjs";
|
|
162
|
+
import { buildPlanSystemPrompt } from "./planner/plan-prompt.mjs";
|
|
163
|
+
import { computeSignature } from "./planner/signature.mjs";
|
|
164
|
+
import { PlannerRunArgs } from "./planner/planner-run.mjs";
|
|
165
|
+
import { memory as memory$2 } from "./snapshot/memory.mjs";
|
|
166
|
+
import { PgSnapshotStoreOptions, pg as pg$1 } from "./snapshot/pg.mjs";
|
|
167
|
+
import { RedisSnapshotStoreOptions, redis as redis$1 } from "./snapshot/redis.mjs";
|
|
168
|
+
import { asTool as asTool$1 } from "./supervisor/as-tool.mjs";
|
|
118
169
|
import { createCancelledError } from "./supervisor/cancellation.mjs";
|
|
119
170
|
import { SupervisorEmitter } from "./supervisor/emitter.mjs";
|
|
120
|
-
import { ResolvedIntentEntry, resolveIntentEntries } from "./supervisor/entries.mjs";
|
|
121
171
|
import { SupervisorStreamController, createSupervisorStream } from "./supervisor/supervisor-stream.mjs";
|
|
122
172
|
import { SupervisorExecution } from "./supervisor/execution.mjs";
|
|
173
|
+
import { FanOutOptions, FanOutUnit, fanOut } from "./supervisor/fan-out.mjs";
|
|
174
|
+
import { RouterConfig, RouterIntents, RouterOutput, router } from "./supervisor/router-factory.mjs";
|
|
123
175
|
import { buildRouterContextMessage } from "./supervisor/router-prompt.mjs";
|
|
124
|
-
import { computeSignature as computeSignature$
|
|
125
|
-
import { loadSnapshotForResume, persistSupervisorSnapshot
|
|
176
|
+
import { computeSignature as computeSignature$2 } from "./supervisor/signature.mjs";
|
|
177
|
+
import { loadSnapshotForResume, persistSupervisorSnapshot } from "./supervisor/snapshot.mjs";
|
|
178
|
+
import { supervisor } from "./supervisor/supervisor.mjs";
|
|
179
|
+
import { Instruction, instruction } from "./system-prompt/instruction.mjs";
|
|
180
|
+
import { Persona, persona } from "./system-prompt/persona.mjs";
|
|
181
|
+
import { step } from "./workflow/step.mjs";
|
|
182
|
+
import { workflow } from "./workflow/workflow.mjs";
|
|
183
|
+
import { ai } from "./ai.mjs";
|
|
184
|
+
import { MiddlewareContextByLevel, MiddlewareLevel, runPipeline } from "./middleware/pipeline.mjs";
|
|
185
|
+
import { extractUserText } from "./middleware/utils/extract-user-text.mjs";
|
|
186
|
+
import { NamespacedStateAccessor, namespacedState } from "./middleware/utils/namespaced-state.mjs";
|
|
126
187
|
import { renderPlaceholders } from "./system-prompt/render-placeholders.mjs";
|
|
127
188
|
import { accumulateCost, computeCost } from "./utils/compute-cost.mjs";
|
|
128
189
|
import { extractJsonPayload } from "./utils/extract-json-payload.mjs";
|
|
@@ -133,5 +194,9 @@ import { resolveAttachment } from "./utils/resolve-attachment.mjs";
|
|
|
133
194
|
import { safeJsonParse } from "./utils/safe-json-parse.mjs";
|
|
134
195
|
import { LineageStamp, stampReportLineage } from "./utils/stamp-report-lineage.mjs";
|
|
135
196
|
import { approximateTokenCount } from "./utils/token-count.mjs";
|
|
136
|
-
import { computeSignature } from "./workflow/signature.mjs";
|
|
137
|
-
|
|
197
|
+
import { computeSignature as computeSignature$1 } from "./workflow/signature.mjs";
|
|
198
|
+
import { MatcherVerdict, matchConverge, matchOutputShape, matchPassStep, matchRouteTo } from "./testing/matcher-logic.mjs";
|
|
199
|
+
import { AiMatchers } from "./testing/matchers.mjs";
|
|
200
|
+
import { registerAiMatchers } from "./testing/register-lazy.mjs";
|
|
201
|
+
export { AIConfig, AIError, type AIErrorCode, type AIErrorOptions, type AckCallback, type AckConfig, type AckEntry, type AckRunEntry, type AckSnapshot, type AgentBranchSnapshot, AgentCancelledError, type AgentCancelledErrorOptions, type AgentCompletedPayload, type AgentConfig, type AgentContract, type AgentErrorPayload, type AgentEventHandler, type AgentEventMap, type AgentExecuteOptions, AgentExecutionError, AgentMaxTripsError, type AgentMaxTripsErrorOptions, type AgentMiddleware, type AgentMiddlewareExecuteHooks, type AgentMiddlewareSupervisorHooks, type AgentMiddlewareToolHooks, type AgentMiddlewareTripHooks, type AgentReport, type AgentResult, type AgentStartingPayload, type AgentStreamingPayload, type AgentToolCalledPayload, type AgentToolCallingFailedPayload, type AgentToolCallingPayload, type AgentToolEntry, type AgentTripCompletedPayload, type AgentTripStartedPayload, type AiMatchers, Attachment, AttachmentSource, type AttemptEntry, type BaseReport, type BaseResult, type BatchItemHandler, type BatchItemResult, type BatchItemStatus, type BatchOptions, type BatchReport, type BatchResult, type BudgetContract, type BudgetContractDimension, type BudgetContractFallback, type BudgetContractViolation, type BudgetContractViolationMode, BudgetExceededError, type BudgetExceededErrorOptions, type BudgetFallbackSignal, type BudgetOptions, type BudgetPricing, type BudgetUnit, type CheckpointRecord, type CheckpointStore, type ClassifierAgentEntry, type ClassifierCallback, type ClassifierConfig, type ClassifierContext, type ClassifierOutput, type ClassifierRefineContext, type ClassifierRefineResult, type ClassifierRunEntry, type ClassifierSnapshot, type CompactionResult, type CompleteEvent, ContentFilterError, type ContentFilterErrorOptions, ContentPart, ContextLengthExceededError, type ContextLengthExceededErrorOptions, type DecisionSource, type DispatchContext, type DispatchRawResult, END, EmbedderConfig, EmbedderContract, EmbeddingBatchResult, EmbeddingResult, EmbeddingUsage, EndSentinel, type EpisodicMemoryConfig, type ErrorCategory, type EvalCase, type EvalCaseResult, type EvalJudge, type EvalOptions, type EvalPredicate, type EvalReport, type EvalScore, type EvalScorer, type EvalScorerContext, type EvaluateBranchResult, type EvaluateContext, type EvaluateResult, type EventIdentity, ExecutableContract, type ExecutableTool, type ExecuteResult, type ExecutionReport, type ExecutionStatus, type FallbackAttempt, type FallbackModelContract, type FallbackModelOptions, type FallbackRetryPredicate, type FanOutOptions, type FanOutUnit, FinishReason, type GuardrailCheck, type GuardrailCheckResult, type GuardrailOptions, type GuardrailPhase, GuardrailViolationError, type GuardrailViolationErrorOptions, ImageSource, Instruction, InstructionContract, type IntentCallback, type IntentEntry, type IntentRunEntry, type IntentRunner, type IntentRunnerMap, InvalidRequestError, type IterationDecision, type IterationSnapshot, type LLMTrip, type LineageStamp, type MatcherVerdict, MaxIterationsError, type MaxIterationsErrorOptions, MaxStepsExceededError, type MaxStepsExceededErrorOptions, type MemoryConfig, type MemoryContract, type MemoryItem, type MemoryTier, Message, type MiddlewareAgentRef, type MiddlewareContextByLevel, type MiddlewareExecuteContext, type MiddlewareLevel, type MiddlewareModelRef, type MiddlewareState, type MiddlewareSupervisorContext, type MiddlewareSupervisorRef, type MiddlewareToolContext, type MiddlewareTripContext, MockModel, type MockModelResponse, type MockRouterDecision, type MockRouterExhaustion, type MockRouterOptions, MockSDK, type MockSDKConfig, ModelCallOptions, ModelCapabilities, ModelConfig, ModelContract, type ModelPricing, ModelResponse, ModelStreamChunk, ModelToolCallRequest, type NamespacedStateAccessor, type Next, type NextStepResult, type OrchestratorAsToolOptions, type OrchestratorAwaitingStatus, OrchestratorCancelledError, type OrchestratorCancelledErrorOptions, type OrchestratorCommandHandlers, type OrchestratorCommands, type OrchestratorConfig, OrchestratorConfigError, type OrchestratorContract, OrchestratorDriftError, type OrchestratorDriftErrorOptions, OrchestratorEmitter, type OrchestratorEvent, type OrchestratorEventHandler, type OrchestratorEventHandlers, type OrchestratorEventMap, type OrchestratorEventName, type OrchestratorExecuteOptions, OrchestratorExecution, type OrchestratorExecutionParams, OrchestratorFailedError, type OrchestratorMemoryConfig, type OrchestratorReport, type OrchestratorReportStatus, type OrchestratorReportType, type OrchestratorResult, type OrchestratorResumeOptions, type OrchestratorSessionScope, type OrchestratorStreamController, Persona, PersonaContract, type PgCheckpointOptions, type PgClientLike, type PgSnapshotStoreOptions, Placeholders, PlannerCancelledError, type PlannerCancelledErrorOptions, type PlannerCapability, type PlannerConfig, type PlannerContract, type PlannerExecuteOptions, PlannerFailedError, type PlannerPlan, PlannerPlanInvalidError, type PlannerReport, type PlannerReportType, type PlannerResult, type PlannerRunArgs, type PlannerStep, type PlannerStepSnapshot, type ProceduralMemoryConfig, ProviderAuthError, ProviderError, ProviderRateLimitError, type ProviderRateLimitErrorOptions, ProviderTimeoutError, QuotaExceededError, REPORT_SCHEMA_VERSION, ReasoningEffort, type RecallOptions, type RecalledMemory, type RedisCheckpointOptions, type RedisClientLike, type RedisSnapshotStoreOptions, type ReportStatus, type ReportType, ResolvedAttachment, type ResolvedIntentEntry, type ResolvedOrchestratorMemory, type RetryBackoff, type RetryConfig, type RouteContext, type RouterConfig, type RouterEntry, type RouterIntents, type RouterOutput, RoutingError, type RoutingErrorOptions, SDKAdapterContract, SchemaValidationError, type SchemaValidationErrorOptions, type SemanticCacheOptions, type SemanticMemoryConfig, type SessionContextOverrides, type SessionContract, type SessionSendResult, type SnapshotStore, type SpawnSubAgentSpec, type StepAgentInput, type StepDefinition, StepFailedError, type StepFailedErrorOptions, type StepLocalEvents, type StepOutputSpec, type StepSnapshot, StorageFileShape, type StreamContract, type StreamController, type StreamEvent, type StreamEventBody, StreamingToolGuardConfig, type SummarizeCallback, type SummarizeConfig, type SupervisorAgentCompletedPayload, type SupervisorAgentFailedPayload, type SupervisorAgentStartingPayload, type SupervisorAgentStreamingPayload, type SupervisorAsToolOptions, SupervisorCancelledError, type SupervisorCancelledErrorOptions, type SupervisorCancelledPayload, type SupervisorCompletedPayload, type SupervisorConfig, type SupervisorContract, SupervisorDriftError, type SupervisorDriftErrorOptions, SupervisorEmitter, type SupervisorErrorPayload, type SupervisorEvaluateVerdictPayload, type SupervisorEventHandler, type SupervisorEventHandlers, type SupervisorEventMap, type SupervisorExecuteOptions, SupervisorExecution, SupervisorFailedError, type SupervisorInput, type SupervisorIntentValue, type SupervisorIterationCompletedPayload, type SupervisorIterationStartingPayload, type SupervisorReport, type SupervisorResult, type SupervisorResumeOptions, type SupervisorRouterDecidedPayload, type SupervisorRouterDecidingPayload, SupervisorRoutingError, type SupervisorRoutingErrorOptions, type SupervisorSnapshot, type SupervisorSnapshotStatus, type SupervisorStartingPayload, type SupervisorStreamController, type SupervisorStreamEvent, type SupervisorTerminatedBy, SystemPrompt, SystemPromptBlockContract, SystemPromptContract, type ToolCall, ToolConfig, ToolContext, type ToolContract, type ToolEventMeta, ToolExecutionError, type ToolExecutionErrorOptions, type ToolInvokeResult, ToolMeta, ToolMode, type TurnSnapshot, type Usage, type UsageEvent, type WithoutIdentity, WorkflowCancelledError, type WorkflowCancelledErrorOptions, type WorkflowCancelledPayload, type WorkflowCompletedPayload, type WorkflowContext, type WorkflowDefinition, WorkflowDriftError, type WorkflowDriftErrorOptions, WorkflowError, type WorkflowErrorPayload, type WorkflowEventHandler, type WorkflowEventHandlers, type WorkflowEventMap, type WorkflowExecuteOptions, type WorkflowInstance, type WorkflowLoopWarningPayload, type WorkflowReport, type WorkflowResult, type WorkflowResumeOptions, type WorkflowRunOptions, type WorkflowSnapshot, type WorkflowStartingPayload, type WorkflowStepCompletedPayload, type WorkflowStepFailedPayload, type WorkflowStepRetryingPayload, type WorkflowStepSkippedPayload, type WorkflowStepStartingPayload, type WorkflowStepStreamingPayload, accumulateCost, agent, ai, approximateTokenCount, batch, budget, buildPlanSystemPrompt, buildRouterContextMessage, memory as checkpointMemory, pg as checkpointPg, redis as checkpointRedis, composeMiddleware, computeCost, computeOrchestratorSignature, computeSignature as computePlannerSignature, computeSignature$1 as computeSignature, computeSignature$2 as computeSupervisorSignature, contains, createAgentStream, createCommandDispatcher as createOrchestratorCommandDispatcher, createOrchestratorStream, createCancelledError as createSupervisorCancelledError, createSupervisorStream, evalScorers, exact, executableToTool, extractJsonPayload, extractJsonSchema, extractUserText, fallbackModel, fanOut, forTool, generateRunId, getAIConfig, guardrail, injectMemories as injectOrchestratorMemories, instruction, isExecutableTool, judge, loadSnapshotForResume as loadSupervisorSnapshotForResume, matchConverge, matchOutputShape, matchPassStep, matchRouteTo, memory$1 as memory, mockAgent, mockRouter, namespacedState, normalizeAgentTools, orchestrator, asTool as orchestratorAsTool, memoryQueryFromInput as orchestratorMemoryQueryFromInput, outcomeTextFromTurn as orchestratorOutcomeTextFromTurn, persistSupervisorSnapshot, persona, planSchema, planner, predicate, prepareAttachmentPart, readBudgetFallbackSignal, recallForTurn as recallOrchestratorMemory, registerAiMatchers, rememberTurnOutcome as rememberOrchestratorTurnOutcome, renderPlaceholders, resolveAttachment, resolveDefaultCheckpointStore, resolveDefaultSnapshotStore, resolveDefaultStore, resolveIntentEntries, resolveOrchestratorMemory, router, runEval, runResume as runOrchestratorResume, runTurn as runOrchestratorTurn, runPipeline, safeJsonParse, semanticCache, setAIConfig, memory$2 as snapshotMemory, pg$1 as snapshotPg, redis$1 as snapshotRedis, spawnSubAgent, stampReportLineage, step, streamTurn as streamOrchestratorTurn, supervisor, asTool$1 as supervisorAsTool, systemPrompt, tool, workflow };
|
|
202
|
+
import "./testing/matchers.mjs";
|
package/esm/index.mjs
CHANGED
|
@@ -12,6 +12,13 @@ import { SupervisorFailedError } from "./errors/supervisor-failed-error.mjs";
|
|
|
12
12
|
import { MaxIterationsError } from "./errors/max-iterations-error.mjs";
|
|
13
13
|
import { WorkflowError } from "./errors/workflow-error.mjs";
|
|
14
14
|
import { MaxStepsExceededError } from "./errors/max-steps-exceeded-error.mjs";
|
|
15
|
+
import { OrchestratorFailedError } from "./errors/orchestrator-failed-error.mjs";
|
|
16
|
+
import { OrchestratorCancelledError } from "./errors/orchestrator-cancelled-error.mjs";
|
|
17
|
+
import { OrchestratorConfigError } from "./errors/orchestrator-config-error.mjs";
|
|
18
|
+
import { OrchestratorDriftError } from "./errors/orchestrator-drift-error.mjs";
|
|
19
|
+
import { PlannerFailedError } from "./errors/planner-failed-error.mjs";
|
|
20
|
+
import { PlannerCancelledError } from "./errors/planner-cancelled-error.mjs";
|
|
21
|
+
import { PlannerPlanInvalidError } from "./errors/planner-plan-invalid-error.mjs";
|
|
15
22
|
import { ProviderAuthError } from "./errors/provider-auth-error.mjs";
|
|
16
23
|
import { ProviderRateLimitError } from "./errors/provider-rate-limit-error.mjs";
|
|
17
24
|
import { ProviderTimeoutError } from "./errors/provider-timeout-error.mjs";
|
|
@@ -26,16 +33,6 @@ import { ToolExecutionError } from "./errors/tool-execution-error.mjs";
|
|
|
26
33
|
import { WorkflowCancelledError } from "./errors/workflow-cancelled-error.mjs";
|
|
27
34
|
import { WorkflowDriftError } from "./errors/workflow-drift-error.mjs";
|
|
28
35
|
import "./errors/index.mjs";
|
|
29
|
-
import { extractUserText } from "./middleware/utils/extract-user-text.mjs";
|
|
30
|
-
import { namespacedState } from "./middleware/utils/namespaced-state.mjs";
|
|
31
|
-
import { budget } from "./middleware/builtins/budget.mjs";
|
|
32
|
-
import { guardrail } from "./middleware/builtins/guardrail.mjs";
|
|
33
|
-
import { getAIConfig, resolveDefaultStore, setAIConfig } from "./config.mjs";
|
|
34
|
-
import { semanticCache } from "./middleware/builtins/semantic-cache.mjs";
|
|
35
|
-
import { composeMiddleware } from "./middleware/helpers/compose.mjs";
|
|
36
|
-
import { forTool } from "./middleware/helpers/for-tool.mjs";
|
|
37
|
-
import { runPipeline } from "./middleware/pipeline.mjs";
|
|
38
|
-
import "./middleware/index.mjs";
|
|
39
36
|
import { accumulateCost, computeCost } from "./utils/compute-cost.mjs";
|
|
40
37
|
import { extractJsonPayload } from "./utils/extract-json-payload.mjs";
|
|
41
38
|
import { generateRunId } from "./utils/generate-run-id.mjs";
|
|
@@ -47,35 +44,82 @@ import { REPORT_SCHEMA_VERSION } from "./contracts/result/base-report.type.mjs";
|
|
|
47
44
|
import { stampReportLineage } from "./utils/stamp-report-lineage.mjs";
|
|
48
45
|
import { approximateTokenCount } from "./utils/token-count.mjs";
|
|
49
46
|
import "./utils/index.mjs";
|
|
47
|
+
import { judge } from "./eval/judge-scorer.mjs";
|
|
48
|
+
import { runEval } from "./eval/eval-runner.mjs";
|
|
49
|
+
import { extractUserText } from "./middleware/utils/extract-user-text.mjs";
|
|
50
|
+
import { namespacedState } from "./middleware/utils/namespaced-state.mjs";
|
|
51
|
+
import { budget, readBudgetFallbackSignal } from "./middleware/builtins/budget.mjs";
|
|
52
|
+
import { guardrail } from "./middleware/builtins/guardrail.mjs";
|
|
53
|
+
import { getAIConfig, resolveDefaultCheckpointStore, resolveDefaultSnapshotStore, resolveDefaultStore, setAIConfig } from "./config.mjs";
|
|
54
|
+
import { semanticCache } from "./middleware/builtins/semantic-cache.mjs";
|
|
55
|
+
import { composeMiddleware } from "./middleware/helpers/compose.mjs";
|
|
56
|
+
import { forTool } from "./middleware/helpers/for-tool.mjs";
|
|
57
|
+
import { runPipeline } from "./middleware/pipeline.mjs";
|
|
58
|
+
import "./middleware/index.mjs";
|
|
59
|
+
import { tool } from "./tool/tool.mjs";
|
|
60
|
+
import { executableToTool, isExecutableTool, normalizeAgentTools } from "./tool/executable-as-tool.mjs";
|
|
50
61
|
import { createAgentStream } from "./agent/agent-stream.mjs";
|
|
51
62
|
import { agent } from "./agent/agent.mjs";
|
|
63
|
+
import { spawnSubAgent } from "./agent/spawn-sub-agent.mjs";
|
|
52
64
|
import "./agent/index.mjs";
|
|
53
|
-
import {
|
|
54
|
-
import
|
|
65
|
+
import { batch } from "./batch/batch.mjs";
|
|
66
|
+
import "./batch/index.mjs";
|
|
67
|
+
import { memory } from "./checkpoint/memory.mjs";
|
|
68
|
+
import { pg } from "./checkpoint/pg.mjs";
|
|
69
|
+
import { redis } from "./checkpoint/redis.mjs";
|
|
70
|
+
import { contains, exact, predicate } from "./eval/scorers.mjs";
|
|
71
|
+
import { evalScorers } from "./eval/index.mjs";
|
|
72
|
+
import { memory as memory$1 } from "./memory/memory.mjs";
|
|
73
|
+
import { MockModel } from "./mock/mock-model.mjs";
|
|
74
|
+
import { MockSDK } from "./mock/mock-sdk.mjs";
|
|
75
|
+
import { mockAgent } from "./mock/mock-agent.mjs";
|
|
76
|
+
import { END } from "./contracts/end.type.mjs";
|
|
77
|
+
import { mockRouter } from "./mock/mock-router.mjs";
|
|
78
|
+
import "./mock/index.mjs";
|
|
79
|
+
import { fallbackModel } from "./model/fallback-model.mjs";
|
|
80
|
+
import "./model/index.mjs";
|
|
81
|
+
import { asTool } from "./orchestrator/as-tool.mjs";
|
|
82
|
+
import { createCommandDispatcher } from "./orchestrator/commands.mjs";
|
|
83
|
+
import { OrchestratorEmitter } from "./orchestrator/emitter.mjs";
|
|
84
|
+
import { injectMemories, memoryQueryFromInput, outcomeTextFromTurn, recallForTurn, rememberTurnOutcome, resolveOrchestratorMemory } from "./orchestrator/memory.mjs";
|
|
85
|
+
import { asTool as asTool$1 } from "./supervisor/as-tool.mjs";
|
|
55
86
|
import { SupervisorEmitter } from "./supervisor/emitter.mjs";
|
|
56
87
|
import { resolveIntentEntries } from "./supervisor/entries.mjs";
|
|
57
|
-
import { END } from "./contracts/end.type.mjs";
|
|
58
88
|
import { createCancelledError } from "./supervisor/cancellation.mjs";
|
|
59
89
|
import { buildRouterContextMessage } from "./supervisor/router-prompt.mjs";
|
|
60
|
-
import { loadSnapshotForResume, persistSupervisorSnapshot
|
|
90
|
+
import { loadSnapshotForResume, persistSupervisorSnapshot } from "./supervisor/snapshot.mjs";
|
|
61
91
|
import { SupervisorExecution } from "./supervisor/execution.mjs";
|
|
62
|
-
import { computeSignature as computeSignature$
|
|
92
|
+
import { computeSignature as computeSignature$2 } from "./supervisor/signature.mjs";
|
|
63
93
|
import { createSupervisorStream } from "./supervisor/supervisor-stream.mjs";
|
|
64
94
|
import { supervisor } from "./supervisor/supervisor.mjs";
|
|
95
|
+
import { OrchestratorExecution, runResume, runTurn, streamTurn } from "./orchestrator/execution.mjs";
|
|
96
|
+
import { createOrchestratorStream } from "./orchestrator/orchestrator-stream.mjs";
|
|
97
|
+
import { computeOrchestratorSignature } from "./orchestrator/signature.mjs";
|
|
98
|
+
import { orchestrator } from "./orchestrator/orchestrator.mjs";
|
|
99
|
+
import "./orchestrator/index.mjs";
|
|
100
|
+
import { buildPlanSystemPrompt } from "./planner/plan-prompt.mjs";
|
|
101
|
+
import { planSchema } from "./planner/plan-schema.mjs";
|
|
102
|
+
import { computeSignature } from "./planner/signature.mjs";
|
|
103
|
+
import { planner } from "./planner/planner.mjs";
|
|
104
|
+
import "./planner/index.mjs";
|
|
105
|
+
import { memory as memory$2 } from "./snapshot/memory.mjs";
|
|
106
|
+
import { pg as pg$1 } from "./snapshot/pg.mjs";
|
|
107
|
+
import { redis as redis$1 } from "./snapshot/redis.mjs";
|
|
108
|
+
import { fanOut } from "./supervisor/fan-out.mjs";
|
|
109
|
+
import { router } from "./supervisor/router-factory.mjs";
|
|
110
|
+
import "./supervisor/index.mjs";
|
|
65
111
|
import { renderPlaceholders } from "./system-prompt/render-placeholders.mjs";
|
|
66
112
|
import { Instruction, instruction } from "./system-prompt/instruction.mjs";
|
|
67
113
|
import { Persona, persona } from "./system-prompt/persona.mjs";
|
|
68
114
|
import { SystemPrompt, systemPrompt } from "./system-prompt/system-prompt.mjs";
|
|
69
115
|
import { step } from "./workflow/step.mjs";
|
|
70
|
-
import { computeSignature } from "./workflow/signature.mjs";
|
|
116
|
+
import { computeSignature as computeSignature$1 } from "./workflow/signature.mjs";
|
|
71
117
|
import { workflow } from "./workflow/workflow.mjs";
|
|
72
118
|
import { ai } from "./ai.mjs";
|
|
73
|
-
import
|
|
74
|
-
import { MockSDK } from "./mock/mock-sdk.mjs";
|
|
75
|
-
import { mockAgent } from "./mock/mock-agent.mjs";
|
|
76
|
-
import "./mock/index.mjs";
|
|
77
|
-
import "./supervisor/index.mjs";
|
|
119
|
+
import "./system-prompt/index.mjs";
|
|
78
120
|
import "./tool/index.mjs";
|
|
79
121
|
import "./workflow/index.mjs";
|
|
122
|
+
import { matchConverge, matchOutputShape, matchPassStep, matchRouteTo } from "./testing/matcher-logic.mjs";
|
|
123
|
+
import { registerAiMatchers } from "./testing/register-lazy.mjs";
|
|
80
124
|
|
|
81
|
-
export { AIError, AgentCancelledError, AgentExecutionError, AgentMaxTripsError, BudgetExceededError, ContentFilterError, ContextLengthExceededError, END, GuardrailViolationError, Instruction, InvalidRequestError, MaxIterationsError, MaxStepsExceededError, MockModel, MockSDK, Persona, ProviderAuthError, ProviderError, ProviderRateLimitError, ProviderTimeoutError, QuotaExceededError, REPORT_SCHEMA_VERSION, RoutingError, SchemaValidationError, StepFailedError, SupervisorCancelledError, SupervisorDriftError, SupervisorEmitter, SupervisorExecution, SupervisorFailedError, SupervisorRoutingError, SystemPrompt, ToolExecutionError, WorkflowCancelledError, WorkflowDriftError, WorkflowError, accumulateCost, agent, ai, approximateTokenCount, budget, buildRouterContextMessage, composeMiddleware, computeCost, computeSignature, computeSignature$1 as computeSupervisorSignature, createAgentStream, createCancelledError as createSupervisorCancelledError, createSupervisorStream, extractJsonPayload, extractJsonSchema, extractUserText, forTool, generateRunId, getAIConfig, guardrail, instruction, loadSnapshotForResume as loadSupervisorSnapshotForResume, mockAgent, namespacedState, persistSupervisorSnapshot, persona, prepareAttachmentPart, renderPlaceholders, resolveAttachment, resolveDefaultStore, resolveIntentEntries, runPipeline, safeJsonParse, semanticCache, setAIConfig, stampReportLineage, step, supervisor, asTool as supervisorAsTool,
|
|
125
|
+
export { AIError, AgentCancelledError, AgentExecutionError, AgentMaxTripsError, BudgetExceededError, ContentFilterError, ContextLengthExceededError, END, GuardrailViolationError, Instruction, InvalidRequestError, MaxIterationsError, MaxStepsExceededError, MockModel, MockSDK, OrchestratorCancelledError, OrchestratorConfigError, OrchestratorDriftError, OrchestratorEmitter, OrchestratorExecution, OrchestratorFailedError, Persona, PlannerCancelledError, PlannerFailedError, PlannerPlanInvalidError, ProviderAuthError, ProviderError, ProviderRateLimitError, ProviderTimeoutError, QuotaExceededError, REPORT_SCHEMA_VERSION, RoutingError, SchemaValidationError, StepFailedError, SupervisorCancelledError, SupervisorDriftError, SupervisorEmitter, SupervisorExecution, SupervisorFailedError, SupervisorRoutingError, SystemPrompt, ToolExecutionError, WorkflowCancelledError, WorkflowDriftError, WorkflowError, accumulateCost, agent, ai, approximateTokenCount, batch, budget, buildPlanSystemPrompt, buildRouterContextMessage, memory as checkpointMemory, pg as checkpointPg, redis as checkpointRedis, composeMiddleware, computeCost, computeOrchestratorSignature, computeSignature as computePlannerSignature, computeSignature$1 as computeSignature, computeSignature$2 as computeSupervisorSignature, contains, createAgentStream, createCommandDispatcher as createOrchestratorCommandDispatcher, createOrchestratorStream, createCancelledError as createSupervisorCancelledError, createSupervisorStream, evalScorers, exact, executableToTool, extractJsonPayload, extractJsonSchema, extractUserText, fallbackModel, fanOut, forTool, generateRunId, getAIConfig, guardrail, injectMemories as injectOrchestratorMemories, instruction, isExecutableTool, judge, loadSnapshotForResume as loadSupervisorSnapshotForResume, matchConverge, matchOutputShape, matchPassStep, matchRouteTo, memory$1 as memory, mockAgent, mockRouter, namespacedState, normalizeAgentTools, orchestrator, asTool as orchestratorAsTool, memoryQueryFromInput as orchestratorMemoryQueryFromInput, outcomeTextFromTurn as orchestratorOutcomeTextFromTurn, persistSupervisorSnapshot, persona, planSchema, planner, predicate, prepareAttachmentPart, readBudgetFallbackSignal, recallForTurn as recallOrchestratorMemory, registerAiMatchers, rememberTurnOutcome as rememberOrchestratorTurnOutcome, renderPlaceholders, resolveAttachment, resolveDefaultCheckpointStore, resolveDefaultSnapshotStore, resolveDefaultStore, resolveIntentEntries, resolveOrchestratorMemory, router, runEval, runResume as runOrchestratorResume, runTurn as runOrchestratorTurn, runPipeline, safeJsonParse, semanticCache, setAIConfig, memory$2 as snapshotMemory, pg$1 as snapshotPg, redis$1 as snapshotRedis, spawnSubAgent, stampReportLineage, step, streamTurn as streamOrchestratorTurn, supervisor, asTool$1 as supervisorAsTool, systemPrompt, tool, workflow };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
//#region ../@warlock.js/ai/src/memory/derive-id.ts
|
|
2
|
+
/**
|
|
3
|
+
* Derive a stable memory id from its text when the caller didn't supply
|
|
4
|
+
* one. Re-remembering identical text therefore lands on the same id and
|
|
5
|
+
* overwrites in place rather than duplicating.
|
|
6
|
+
*
|
|
7
|
+
* FNV-1a variant — cheap, dependency-free, collision-resistant enough
|
|
8
|
+
* for de-duplicating memory entries. NOT cryptographic: a collision
|
|
9
|
+
* would merge two distinct memories, not breach security in the current
|
|
10
|
+
* trust model. Mirrors the prompt hash in
|
|
11
|
+
* `middleware/builtins/semantic-cache.ts`.
|
|
12
|
+
*/
|
|
13
|
+
function deriveMemoryId(text) {
|
|
14
|
+
let hash = 2166136261;
|
|
15
|
+
for (let index = 0; index < text.length; index++) {
|
|
16
|
+
hash ^= text.charCodeAt(index);
|
|
17
|
+
hash = Math.imul(hash, 16777619);
|
|
18
|
+
}
|
|
19
|
+
return (hash >>> 0).toString(16);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
//#endregion
|
|
23
|
+
export { deriveMemoryId };
|
|
24
|
+
//# sourceMappingURL=derive-id.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"derive-id.mjs","names":[],"sources":["../../../../../../../@warlock.js/ai/src/memory/derive-id.ts"],"sourcesContent":["/**\n * Derive a stable memory id from its text when the caller didn't supply\n * one. Re-remembering identical text therefore lands on the same id and\n * overwrites in place rather than duplicating.\n *\n * FNV-1a variant — cheap, dependency-free, collision-resistant enough\n * for de-duplicating memory entries. NOT cryptographic: a collision\n * would merge two distinct memories, not breach security in the current\n * trust model. Mirrors the prompt hash in\n * `middleware/builtins/semantic-cache.ts`.\n */\nexport function deriveMemoryId(text: string): string {\n let hash = 0x811c9dc5;\n\n for (let index = 0; index < text.length; index++) {\n hash ^= text.charCodeAt(index);\n hash = Math.imul(hash, 0x01000193);\n }\n\n return (hash >>> 0).toString(16);\n}\n"],"mappings":";;;;;;;;;;;;AAWA,SAAgB,eAAe,MAAsB;CACnD,IAAI,OAAO;CAEX,KAAK,IAAI,QAAQ,GAAG,QAAQ,KAAK,QAAQ,SAAS;EAChD,QAAQ,KAAK,WAAW,KAAK;EAC7B,OAAO,KAAK,KAAK,MAAM,QAAU;CACnC;CAEA,QAAQ,SAAS,EAAC,CAAE,SAAS,EAAE;AACjC"}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { deriveMemoryId } from "./derive-id.mjs";
|
|
2
|
+
|
|
3
|
+
//#region ../@warlock.js/ai/src/memory/episodic-memory.ts
|
|
4
|
+
/**
|
|
5
|
+
* How many extra candidates to pull from `similar()` before re-ranking by
|
|
6
|
+
* the recency-blended score and slicing to `k`. Recency can promote a
|
|
7
|
+
* slightly-less-similar-but-recent episode past a stale exact match, so
|
|
8
|
+
* the raw top-`k` by similarity alone would miss it — overscan, then
|
|
9
|
+
* re-rank.
|
|
10
|
+
*/
|
|
11
|
+
const RECALL_OVERSCAN = 5;
|
|
12
|
+
/**
|
|
13
|
+
* Episodic recall tier (memory core M2).
|
|
14
|
+
*
|
|
15
|
+
* Holds a durable, timestamped log of *what happened* — events/episodes —
|
|
16
|
+
* and retrieves the ones most relevant to a query, **blended with
|
|
17
|
+
* recency** so recent episodes outrank stale ones at equal similarity.
|
|
18
|
+
* That recency weighting is the whole difference from the {@link
|
|
19
|
+
* import("./semantic-memory").SemanticMemory} tier (pure similarity over
|
|
20
|
+
* timeless facts): episodic memory is time-anchored.
|
|
21
|
+
*
|
|
22
|
+
* Like the semantic tier it delegates the similarity search to the
|
|
23
|
+
* `@warlock.js/cache` driver's `similar()` and never implements ANN
|
|
24
|
+
* itself; it adds a stored `ts` per entry and a decay curve at recall.
|
|
25
|
+
* The blended `score` stays in `[0, 1]` so a consumer can merge episodic
|
|
26
|
+
* hits with the other tiers and sort on one field.
|
|
27
|
+
*
|
|
28
|
+
* Internal to the `memory()` factory — never exported on the package
|
|
29
|
+
* surface.
|
|
30
|
+
*/
|
|
31
|
+
var EpisodicMemory = class {
|
|
32
|
+
constructor(embedder, store, namespace, recencyWeight, halfLifeMs, now) {
|
|
33
|
+
this.embedder = embedder;
|
|
34
|
+
this.store = store;
|
|
35
|
+
this.namespace = namespace;
|
|
36
|
+
this.recencyWeight = recencyWeight;
|
|
37
|
+
this.halfLifeMs = halfLifeMs;
|
|
38
|
+
this.now = now;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Embed the episode text and index it under a namespaced, id-derived
|
|
42
|
+
* key, stamping the current time. Re-remembering the same id overwrites
|
|
43
|
+
* the prior entry (and refreshes its timestamp).
|
|
44
|
+
*/
|
|
45
|
+
async remember(item) {
|
|
46
|
+
const id = item.id ?? deriveMemoryId(item.text);
|
|
47
|
+
const { vector } = await this.embedder.embed(item.text);
|
|
48
|
+
const value = {
|
|
49
|
+
id,
|
|
50
|
+
text: item.text,
|
|
51
|
+
ts: this.now(),
|
|
52
|
+
metadata: item.metadata
|
|
53
|
+
};
|
|
54
|
+
await this.store.set(this.keyFor(id), value, { vector });
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Embed `query`, pull the nearest episodes clearing the similarity
|
|
58
|
+
* `threshold`, then re-rank each by a recency-blended score before
|
|
59
|
+
* returning the top `k`. The similarity floor still gates relevance —
|
|
60
|
+
* recency only reorders episodes that already cleared it, it never
|
|
61
|
+
* surfaces an irrelevant-but-recent one.
|
|
62
|
+
*/
|
|
63
|
+
async recall(query, k, threshold) {
|
|
64
|
+
const { vector } = await this.embedder.embed(query);
|
|
65
|
+
const hits = await this.store.similar(vector, {
|
|
66
|
+
topK: Math.max(k * RECALL_OVERSCAN, k),
|
|
67
|
+
threshold
|
|
68
|
+
});
|
|
69
|
+
const prefix = `${this.namespace}.`;
|
|
70
|
+
const now = this.now();
|
|
71
|
+
return hits.filter((hit) => hit.key.startsWith(prefix)).map((hit) => ({
|
|
72
|
+
id: hit.value.id,
|
|
73
|
+
text: hit.value.text,
|
|
74
|
+
tier: "episodic",
|
|
75
|
+
score: this.blend(hit.score, hit.value.ts, now),
|
|
76
|
+
metadata: hit.value.metadata
|
|
77
|
+
})).sort((first, second) => second.score - first.score).slice(0, k);
|
|
78
|
+
}
|
|
79
|
+
/** Drop every episode written under this instance's namespace. */
|
|
80
|
+
async clear() {
|
|
81
|
+
await this.store.removeNamespace(this.namespace);
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Combine raw similarity with an exponential recency decay:
|
|
85
|
+
* `(1 - w)·similarity + w·0.5^(age / halfLife)`. A just-remembered
|
|
86
|
+
* episode contributes a recency of `1`; one `halfLife` old, `0.5`;
|
|
87
|
+
* older trends toward `0`. With `recencyWeight` 0 the score is pure
|
|
88
|
+
* similarity (an opt-out back to semantic-style ranking).
|
|
89
|
+
*/
|
|
90
|
+
blend(similarity, ts, now) {
|
|
91
|
+
const recency = .5 ** (Math.max(0, now - ts) / this.halfLifeMs);
|
|
92
|
+
return (1 - this.recencyWeight) * similarity + this.recencyWeight * recency;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Namespaced key for an entry. Mirrors the semantic tier's dot
|
|
96
|
+
* separator so the prefix used here matches the `hit.key` the driver
|
|
97
|
+
* returns from `similar()`.
|
|
98
|
+
*/
|
|
99
|
+
keyFor(id) {
|
|
100
|
+
return `${this.namespace}.${id}`;
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
//#endregion
|
|
105
|
+
export { EpisodicMemory };
|
|
106
|
+
//# sourceMappingURL=episodic-memory.mjs.map
|