@warlock.js/ai 4.8.2 → 4.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +10 -0
- package/cjs/index.cjs +263 -241
- package/cjs/index.cjs.map +1 -1
- package/cjs/{magic-string.es-BtxW4VqG.cjs → magic-string.es-BoSa5xIt.cjs} +3 -3
- package/cjs/magic-string.es-BoSa5xIt.cjs.map +1 -0
- package/cjs/{matcher-logic-SBnzYohQ.cjs → matcher-logic-07fFOz7r.cjs} +3 -3
- package/cjs/matcher-logic-07fFOz7r.cjs.map +1 -0
- package/cjs/{matchers-BBh3gyB-.cjs → matchers-DnV47KR_.cjs} +24 -24
- package/cjs/matchers-DnV47KR_.cjs.map +1 -0
- package/esm/agent/agent-config.type.d.mts +1 -1
- package/esm/agent/agent-config.type.d.mts.map +1 -1
- package/esm/agent/agent-input-builder.mjs +1 -1
- package/esm/agent/agent-input-builder.mjs.map +1 -1
- package/esm/agent/agent-log-event.mjs +1 -1
- package/esm/agent/agent-log-event.mjs.map +1 -1
- package/esm/agent/agent-stream.d.mts +1 -1
- package/esm/agent/agent-stream.d.mts.map +1 -1
- package/esm/agent/agent-stream.mjs +1 -1
- package/esm/agent/agent-stream.mjs.map +1 -1
- package/esm/agent/agent-to-stream-event.mjs +1 -1
- package/esm/agent/agent-to-stream-event.mjs.map +1 -1
- package/esm/agent/agent.d.mts +1 -1
- package/esm/agent/agent.d.mts.map +1 -1
- package/esm/agent/agent.mjs +1 -1
- package/esm/agent/agent.mjs.map +1 -1
- package/esm/agent/json-stream-guard.mjs +1 -1
- package/esm/agent/json-stream-guard.mjs.map +1 -1
- package/esm/agent/judge-config.type.d.mts +1 -1
- package/esm/agent/judge-config.type.d.mts.map +1 -1
- package/esm/agent/judge-config.type.mjs +1 -1
- package/esm/agent/judge-config.type.mjs.map +1 -1
- package/esm/agent/signature.mjs +1 -1
- package/esm/agent/signature.mjs.map +1 -1
- package/esm/agent/snapshot.mjs +1 -1
- package/esm/agent/snapshot.mjs.map +1 -1
- package/esm/agent/spawn-sub-agent.d.mts +1 -1
- package/esm/agent/spawn-sub-agent.d.mts.map +1 -1
- package/esm/agent/spawn-sub-agent.mjs +1 -1
- package/esm/agent/spawn-sub-agent.mjs.map +1 -1
- package/esm/ai.d.mts +1 -1
- package/esm/ai.d.mts.map +1 -1
- package/esm/ai.mjs +1 -1
- package/esm/ai.mjs.map +1 -1
- package/esm/batch/batch.d.mts +1 -1
- package/esm/batch/batch.d.mts.map +1 -1
- package/esm/batch/batch.mjs +1 -1
- package/esm/batch/batch.mjs.map +1 -1
- package/esm/batch/batch.type.d.mts +1 -1
- package/esm/batch/batch.type.d.mts.map +1 -1
- package/esm/batch/run-batch-item.mjs +1 -1
- package/esm/batch/run-batch-item.mjs.map +1 -1
- package/esm/batch/run-with-concurrency.mjs +1 -1
- package/esm/batch/run-with-concurrency.mjs.map +1 -1
- package/esm/checkpoint/memory.d.mts +1 -1
- package/esm/checkpoint/memory.d.mts.map +1 -1
- package/esm/checkpoint/memory.mjs +0 -0
- package/esm/checkpoint/memory.mjs.map +1 -1
- package/esm/checkpoint/pg.d.mts +1 -1
- package/esm/checkpoint/pg.d.mts.map +1 -1
- package/esm/checkpoint/pg.mjs +1 -1
- package/esm/checkpoint/pg.mjs.map +1 -1
- package/esm/checkpoint/redis.d.mts +1 -1
- package/esm/checkpoint/redis.d.mts.map +1 -1
- package/esm/checkpoint/redis.mjs +1 -1
- package/esm/checkpoint/redis.mjs.map +1 -1
- package/esm/config.d.mts +1 -1
- package/esm/config.d.mts.map +1 -1
- package/esm/config.mjs +1 -1
- package/esm/config.mjs.map +1 -1
- package/esm/contracts/agent/agent-options.type.d.mts +1 -1
- package/esm/contracts/agent/agent-options.type.d.mts.map +1 -1
- package/esm/contracts/agent/agent-snapshot.type.d.mts +1 -1
- package/esm/contracts/agent/agent-snapshot.type.d.mts.map +1 -1
- package/esm/contracts/agent/agent.contract.d.mts +1 -1
- package/esm/contracts/agent/agent.contract.d.mts.map +1 -1
- package/esm/contracts/agent/eval.type.d.mts +1 -1
- package/esm/contracts/agent/eval.type.d.mts.map +1 -1
- package/esm/contracts/attachment-policy.type.d.mts +1 -1
- package/esm/contracts/attachment-policy.type.d.mts.map +1 -1
- package/esm/contracts/attachment.type.d.mts +1 -1
- package/esm/contracts/attachment.type.d.mts.map +1 -1
- package/esm/contracts/content-part.type.d.mts +1 -1
- package/esm/contracts/content-part.type.d.mts.map +1 -1
- package/esm/contracts/conversation-message.type.d.mts +1 -1
- package/esm/contracts/conversation-message.type.d.mts.map +1 -1
- package/esm/contracts/embedder.contract.d.mts +1 -1
- package/esm/contracts/embedder.contract.d.mts.map +1 -1
- package/esm/contracts/end.type.d.mts +1 -1
- package/esm/contracts/end.type.d.mts.map +1 -1
- package/esm/contracts/end.type.mjs +1 -1
- package/esm/contracts/end.type.mjs.map +1 -1
- package/esm/contracts/events/agent-events.type.d.mts +1 -1
- package/esm/contracts/events/agent-events.type.d.mts.map +1 -1
- package/esm/contracts/events/complete-event.type.d.mts +1 -1
- package/esm/contracts/events/complete-event.type.d.mts.map +1 -1
- package/esm/contracts/events/event-identity.type.d.mts +1 -1
- package/esm/contracts/events/event-identity.type.d.mts.map +1 -1
- package/esm/contracts/events/event-map.type.d.mts +1 -1
- package/esm/contracts/events/event-map.type.d.mts.map +1 -1
- package/esm/contracts/events/supervisor-events.type.d.mts +1 -1
- package/esm/contracts/events/supervisor-events.type.d.mts.map +1 -1
- package/esm/contracts/events/usage-event.type.d.mts +1 -1
- package/esm/contracts/events/usage-event.type.d.mts.map +1 -1
- package/esm/contracts/events/workflow-events.type.d.mts +1 -1
- package/esm/contracts/events/workflow-events.type.d.mts.map +1 -1
- package/esm/contracts/executable.contract.d.mts +1 -1
- package/esm/contracts/executable.contract.d.mts.map +1 -1
- package/esm/contracts/fallback-model.contract.d.mts +1 -1
- package/esm/contracts/fallback-model.contract.d.mts.map +1 -1
- package/esm/contracts/finish-reason.type.d.mts +1 -1
- package/esm/contracts/finish-reason.type.d.mts.map +1 -1
- package/esm/contracts/image-model.contract.d.mts +1 -1
- package/esm/contracts/image-model.contract.d.mts.map +1 -1
- package/esm/contracts/memory/memory-config.type.d.mts +1 -1
- package/esm/contracts/memory/memory-config.type.d.mts.map +1 -1
- package/esm/contracts/memory/memory-item.type.d.mts +1 -1
- package/esm/contracts/memory/memory-item.type.d.mts.map +1 -1
- package/esm/contracts/memory/memory.contract.d.mts +1 -1
- package/esm/contracts/memory/memory.contract.d.mts.map +1 -1
- package/esm/contracts/memory/recall-options.type.d.mts +1 -1
- package/esm/contracts/memory/recall-options.type.d.mts.map +1 -1
- package/esm/contracts/middleware/middleware-context.type.d.mts +1 -1
- package/esm/contracts/middleware/middleware-context.type.d.mts.map +1 -1
- package/esm/contracts/middleware/middleware-state.type.d.mts +1 -1
- package/esm/contracts/middleware/middleware-state.type.d.mts.map +1 -1
- package/esm/contracts/middleware/middleware.contract.d.mts +1 -1
- package/esm/contracts/middleware/middleware.contract.d.mts.map +1 -1
- package/esm/contracts/model-tool-call-request.type.d.mts +1 -1
- package/esm/contracts/model-tool-call-request.type.d.mts.map +1 -1
- package/esm/contracts/model.contract.d.mts +9 -1
- package/esm/contracts/model.contract.d.mts.map +1 -1
- package/esm/contracts/orchestrator/checkpoint-store.contract.d.mts +1 -1
- package/esm/contracts/orchestrator/checkpoint-store.contract.d.mts.map +1 -1
- package/esm/contracts/orchestrator/orchestrator-commands.type.d.mts +1 -1
- package/esm/contracts/orchestrator/orchestrator-commands.type.d.mts.map +1 -1
- package/esm/contracts/orchestrator/orchestrator-config.type.d.mts +1 -1
- package/esm/contracts/orchestrator/orchestrator-config.type.d.mts.map +1 -1
- package/esm/contracts/orchestrator/orchestrator-event.type.d.mts +1 -1
- package/esm/contracts/orchestrator/orchestrator-event.type.d.mts.map +1 -1
- package/esm/contracts/orchestrator/orchestrator-execute-options.type.d.mts +1 -1
- package/esm/contracts/orchestrator/orchestrator-execute-options.type.d.mts.map +1 -1
- package/esm/contracts/orchestrator/orchestrator.contract.d.mts +1 -1
- package/esm/contracts/orchestrator/orchestrator.contract.d.mts.map +1 -1
- package/esm/contracts/orchestrator/session-lock.contract.d.mts +1 -1
- package/esm/contracts/orchestrator/session-lock.contract.d.mts.map +1 -1
- package/esm/contracts/orchestrator/session.contract.d.mts +1 -1
- package/esm/contracts/orchestrator/session.contract.d.mts.map +1 -1
- package/esm/contracts/orchestrator/snapshot-store.contract.d.mts +1 -1
- package/esm/contracts/orchestrator/snapshot-store.contract.d.mts.map +1 -1
- package/esm/contracts/placeholders.type.d.mts +1 -1
- package/esm/contracts/placeholders.type.d.mts.map +1 -1
- package/esm/contracts/planner/planner-capability.type.d.mts +1 -1
- package/esm/contracts/planner/planner-capability.type.d.mts.map +1 -1
- package/esm/contracts/planner/planner-config.type.d.mts +1 -1
- package/esm/contracts/planner/planner-config.type.d.mts.map +1 -1
- package/esm/contracts/planner/planner-execute-options.type.d.mts +1 -1
- package/esm/contracts/planner/planner-execute-options.type.d.mts.map +1 -1
- package/esm/contracts/planner/planner-plan.type.d.mts +1 -1
- package/esm/contracts/planner/planner-plan.type.d.mts.map +1 -1
- package/esm/contracts/planner/planner-result.type.d.mts +1 -1
- package/esm/contracts/planner/planner-result.type.d.mts.map +1 -1
- package/esm/contracts/planner/planner-snapshot.type.d.mts +1 -1
- package/esm/contracts/planner/planner-snapshot.type.d.mts.map +1 -1
- package/esm/contracts/planner/planner.contract.d.mts +1 -1
- package/esm/contracts/planner/planner.contract.d.mts.map +1 -1
- package/esm/contracts/result/agent-result.type.d.mts +1 -1
- package/esm/contracts/result/agent-result.type.d.mts.map +1 -1
- package/esm/contracts/result/attempt-entry.type.d.mts +1 -1
- package/esm/contracts/result/attempt-entry.type.d.mts.map +1 -1
- package/esm/contracts/result/base-report.type.d.mts +1 -1
- package/esm/contracts/result/base-report.type.d.mts.map +1 -1
- package/esm/contracts/result/base-report.type.mjs +1 -1
- package/esm/contracts/result/base-report.type.mjs.map +1 -1
- package/esm/contracts/result/base-result.type.d.mts +1 -1
- package/esm/contracts/result/base-result.type.d.mts.map +1 -1
- package/esm/contracts/result/execute-result.type.d.mts +1 -1
- package/esm/contracts/result/execute-result.type.d.mts.map +1 -1
- package/esm/contracts/result/execution-report.type.d.mts +1 -1
- package/esm/contracts/result/execution-report.type.d.mts.map +1 -1
- package/esm/contracts/result/llm-trip.type.d.mts +1 -1
- package/esm/contracts/result/llm-trip.type.d.mts.map +1 -1
- package/esm/contracts/result/model-pricing.type.d.mts +1 -1
- package/esm/contracts/result/model-pricing.type.d.mts.map +1 -1
- package/esm/contracts/result/orchestrator-result.type.d.mts +1 -1
- package/esm/contracts/result/orchestrator-result.type.d.mts.map +1 -1
- package/esm/contracts/result/session-send-result.type.d.mts +1 -1
- package/esm/contracts/result/session-send-result.type.d.mts.map +1 -1
- package/esm/contracts/result/step-result.type.d.mts +12 -2
- package/esm/contracts/result/step-result.type.d.mts.map +1 -1
- package/esm/contracts/result/supervisor-result.type.d.mts +1 -1
- package/esm/contracts/result/supervisor-result.type.d.mts.map +1 -1
- package/esm/contracts/result/tool-call.type.d.mts +1 -1
- package/esm/contracts/result/tool-call.type.d.mts.map +1 -1
- package/esm/contracts/result/usage.type.d.mts +1 -1
- 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/sdk-adapter.contract.d.mts.map +1 -1
- package/esm/contracts/speech-model.contract.d.mts +1 -1
- package/esm/contracts/speech-model.contract.d.mts.map +1 -1
- package/esm/contracts/stream/stream-event.type.d.mts +1 -1
- package/esm/contracts/stream/stream-event.type.d.mts.map +1 -1
- package/esm/contracts/stream/stream.contract.d.mts +1 -1
- package/esm/contracts/stream/stream.contract.d.mts.map +1 -1
- package/esm/contracts/streaming-tool-guard-config.type.d.mts +1 -1
- package/esm/contracts/streaming-tool-guard-config.type.d.mts.map +1 -1
- package/esm/contracts/supervisor/ack-entry.type.d.mts +1 -1
- package/esm/contracts/supervisor/ack-entry.type.d.mts.map +1 -1
- package/esm/contracts/supervisor/classifier-context.type.d.mts +1 -1
- package/esm/contracts/supervisor/classifier-context.type.d.mts.map +1 -1
- package/esm/contracts/supervisor/dispatch-context.type.d.mts +1 -1
- package/esm/contracts/supervisor/dispatch-context.type.d.mts.map +1 -1
- package/esm/contracts/supervisor/evaluate-context.type.d.mts +1 -1
- package/esm/contracts/supervisor/evaluate-context.type.d.mts.map +1 -1
- package/esm/contracts/supervisor/intent-entry.type.d.mts +1 -1
- package/esm/contracts/supervisor/intent-entry.type.d.mts.map +1 -1
- package/esm/contracts/supervisor/iteration-snapshot.type.d.mts +1 -1
- package/esm/contracts/supervisor/iteration-snapshot.type.d.mts.map +1 -1
- package/esm/contracts/supervisor/next.type.d.mts +1 -1
- package/esm/contracts/supervisor/next.type.d.mts.map +1 -1
- package/esm/contracts/supervisor/route-context.type.d.mts +1 -1
- package/esm/contracts/supervisor/route-context.type.d.mts.map +1 -1
- package/esm/contracts/supervisor/router-entry.type.d.mts +1 -1
- package/esm/contracts/supervisor/router-entry.type.d.mts.map +1 -1
- package/esm/contracts/supervisor/supervisor-config.type.d.mts +1 -1
- package/esm/contracts/supervisor/supervisor-config.type.d.mts.map +1 -1
- package/esm/contracts/supervisor/supervisor-execute-options.type.d.mts +1 -1
- package/esm/contracts/supervisor/supervisor-execute-options.type.d.mts.map +1 -1
- package/esm/contracts/supervisor/supervisor-input.type.d.mts +1 -1
- package/esm/contracts/supervisor/supervisor-input.type.d.mts.map +1 -1
- package/esm/contracts/supervisor/supervisor-snapshot.type.d.mts +1 -1
- package/esm/contracts/supervisor/supervisor-snapshot.type.d.mts.map +1 -1
- package/esm/contracts/supervisor/supervisor-stream-event.type.d.mts +1 -1
- package/esm/contracts/supervisor/supervisor-stream-event.type.d.mts.map +1 -1
- package/esm/contracts/supervisor/supervisor.contract.d.mts +1 -1
- package/esm/contracts/supervisor/supervisor.contract.d.mts.map +1 -1
- package/esm/contracts/system-prompt.contract.d.mts +1 -1
- package/esm/contracts/system-prompt.contract.d.mts.map +1 -1
- package/esm/contracts/team/team-config.type.d.mts +1 -1
- package/esm/contracts/team/team-config.type.d.mts.map +1 -1
- package/esm/contracts/tool.contract.d.mts +1 -1
- package/esm/contracts/tool.contract.d.mts.map +1 -1
- package/esm/contracts/transcription-model.contract.d.mts +1 -1
- package/esm/contracts/transcription-model.contract.d.mts.map +1 -1
- package/esm/contracts/workflow/next-step-result.type.d.mts +1 -1
- package/esm/contracts/workflow/next-step-result.type.d.mts.map +1 -1
- package/esm/contracts/workflow/retry-config.type.d.mts +1 -1
- package/esm/contracts/workflow/retry-config.type.d.mts.map +1 -1
- package/esm/contracts/workflow/step.contract.d.mts +1 -1
- package/esm/contracts/workflow/step.contract.d.mts.map +1 -1
- package/esm/contracts/workflow/workflow-context.type.d.mts +1 -1
- package/esm/contracts/workflow/workflow-context.type.d.mts.map +1 -1
- package/esm/contracts/workflow/workflow-snapshot.type.d.mts +1 -1
- package/esm/contracts/workflow/workflow-snapshot.type.d.mts.map +1 -1
- package/esm/contracts/workflow/workflow.contract.d.mts +1 -1
- package/esm/contracts/workflow/workflow.contract.d.mts.map +1 -1
- package/esm/errors/agent-cancelled-error.d.mts +1 -1
- package/esm/errors/agent-cancelled-error.d.mts.map +1 -1
- package/esm/errors/agent-cancelled-error.mjs +1 -1
- package/esm/errors/agent-cancelled-error.mjs.map +1 -1
- package/esm/errors/agent-drift-error.d.mts +1 -1
- package/esm/errors/agent-drift-error.d.mts.map +1 -1
- package/esm/errors/agent-drift-error.mjs +1 -1
- package/esm/errors/agent-drift-error.mjs.map +1 -1
- package/esm/errors/agent-execution-error.d.mts +1 -1
- package/esm/errors/agent-execution-error.d.mts.map +1 -1
- package/esm/errors/agent-execution-error.mjs +1 -1
- package/esm/errors/agent-execution-error.mjs.map +1 -1
- package/esm/errors/agent-max-trips-error.d.mts +1 -1
- package/esm/errors/agent-max-trips-error.d.mts.map +1 -1
- package/esm/errors/agent-max-trips-error.mjs +1 -1
- package/esm/errors/agent-max-trips-error.mjs.map +1 -1
- package/esm/errors/ai-error.d.mts +1 -1
- package/esm/errors/ai-error.d.mts.map +1 -1
- package/esm/errors/ai-error.mjs +1 -1
- package/esm/errors/ai-error.mjs.map +1 -1
- package/esm/errors/budget-exceeded-error.d.mts +1 -1
- package/esm/errors/budget-exceeded-error.d.mts.map +1 -1
- package/esm/errors/budget-exceeded-error.mjs +1 -1
- package/esm/errors/budget-exceeded-error.mjs.map +1 -1
- package/esm/errors/content-filter-error.d.mts +1 -1
- package/esm/errors/content-filter-error.d.mts.map +1 -1
- package/esm/errors/content-filter-error.mjs +1 -1
- package/esm/errors/content-filter-error.mjs.map +1 -1
- package/esm/errors/context-length-exceeded-error.d.mts +1 -1
- package/esm/errors/context-length-exceeded-error.d.mts.map +1 -1
- package/esm/errors/context-length-exceeded-error.mjs +1 -1
- package/esm/errors/context-length-exceeded-error.mjs.map +1 -1
- package/esm/errors/error-category.type.d.mts +1 -1
- package/esm/errors/error-category.type.d.mts.map +1 -1
- package/esm/errors/error-code.type.d.mts +1 -1
- package/esm/errors/error-code.type.d.mts.map +1 -1
- package/esm/errors/guardrail-violation-error.d.mts +1 -1
- package/esm/errors/guardrail-violation-error.d.mts.map +1 -1
- package/esm/errors/guardrail-violation-error.mjs +1 -1
- package/esm/errors/guardrail-violation-error.mjs.map +1 -1
- package/esm/errors/invalid-request-error.d.mts +1 -1
- package/esm/errors/invalid-request-error.d.mts.map +1 -1
- package/esm/errors/invalid-request-error.mjs +1 -1
- package/esm/errors/invalid-request-error.mjs.map +1 -1
- package/esm/errors/max-iterations-error.d.mts +1 -1
- package/esm/errors/max-iterations-error.d.mts.map +1 -1
- package/esm/errors/max-iterations-error.mjs +1 -1
- package/esm/errors/max-iterations-error.mjs.map +1 -1
- package/esm/errors/max-steps-exceeded-error.d.mts +1 -1
- package/esm/errors/max-steps-exceeded-error.d.mts.map +1 -1
- package/esm/errors/max-steps-exceeded-error.mjs +1 -1
- package/esm/errors/max-steps-exceeded-error.mjs.map +1 -1
- package/esm/errors/orchestrator-cancelled-error.d.mts +1 -1
- package/esm/errors/orchestrator-cancelled-error.d.mts.map +1 -1
- package/esm/errors/orchestrator-cancelled-error.mjs +1 -1
- package/esm/errors/orchestrator-cancelled-error.mjs.map +1 -1
- package/esm/errors/orchestrator-config-error.d.mts +1 -1
- package/esm/errors/orchestrator-config-error.d.mts.map +1 -1
- package/esm/errors/orchestrator-config-error.mjs +1 -1
- package/esm/errors/orchestrator-config-error.mjs.map +1 -1
- package/esm/errors/orchestrator-drift-error.d.mts +1 -1
- package/esm/errors/orchestrator-drift-error.d.mts.map +1 -1
- package/esm/errors/orchestrator-drift-error.mjs +1 -1
- package/esm/errors/orchestrator-drift-error.mjs.map +1 -1
- package/esm/errors/orchestrator-failed-error.d.mts +1 -1
- package/esm/errors/orchestrator-failed-error.d.mts.map +1 -1
- package/esm/errors/orchestrator-failed-error.mjs +1 -1
- package/esm/errors/orchestrator-failed-error.mjs.map +1 -1
- package/esm/errors/outbound-policy-error.d.mts +1 -1
- package/esm/errors/outbound-policy-error.d.mts.map +1 -1
- package/esm/errors/outbound-policy-error.mjs +1 -1
- package/esm/errors/outbound-policy-error.mjs.map +1 -1
- package/esm/errors/planner-cancelled-error.d.mts +1 -1
- package/esm/errors/planner-cancelled-error.d.mts.map +1 -1
- package/esm/errors/planner-cancelled-error.mjs +1 -1
- package/esm/errors/planner-cancelled-error.mjs.map +1 -1
- package/esm/errors/planner-drift-error.d.mts +1 -1
- package/esm/errors/planner-drift-error.d.mts.map +1 -1
- package/esm/errors/planner-drift-error.mjs +1 -1
- package/esm/errors/planner-drift-error.mjs.map +1 -1
- package/esm/errors/planner-failed-error.d.mts +1 -1
- package/esm/errors/planner-failed-error.d.mts.map +1 -1
- package/esm/errors/planner-failed-error.mjs +1 -1
- package/esm/errors/planner-failed-error.mjs.map +1 -1
- package/esm/errors/planner-plan-invalid-error.d.mts +1 -1
- package/esm/errors/planner-plan-invalid-error.d.mts.map +1 -1
- package/esm/errors/planner-plan-invalid-error.mjs +1 -1
- package/esm/errors/planner-plan-invalid-error.mjs.map +1 -1
- package/esm/errors/prompt-refinement-error.d.mts +1 -1
- package/esm/errors/prompt-refinement-error.d.mts.map +1 -1
- package/esm/errors/prompt-refinement-error.mjs +1 -1
- package/esm/errors/prompt-refinement-error.mjs.map +1 -1
- package/esm/errors/provider-auth-error.d.mts +1 -1
- package/esm/errors/provider-auth-error.d.mts.map +1 -1
- package/esm/errors/provider-auth-error.mjs +1 -1
- package/esm/errors/provider-auth-error.mjs.map +1 -1
- package/esm/errors/provider-error.d.mts +1 -1
- package/esm/errors/provider-error.d.mts.map +1 -1
- package/esm/errors/provider-error.mjs +1 -1
- package/esm/errors/provider-error.mjs.map +1 -1
- package/esm/errors/provider-rate-limit-error.d.mts +1 -1
- package/esm/errors/provider-rate-limit-error.d.mts.map +1 -1
- package/esm/errors/provider-rate-limit-error.mjs +1 -1
- package/esm/errors/provider-rate-limit-error.mjs.map +1 -1
- package/esm/errors/provider-timeout-error.d.mts +1 -1
- package/esm/errors/provider-timeout-error.d.mts.map +1 -1
- package/esm/errors/provider-timeout-error.mjs +1 -1
- package/esm/errors/provider-timeout-error.mjs.map +1 -1
- package/esm/errors/quota-exceeded-error.d.mts +1 -1
- package/esm/errors/quota-exceeded-error.d.mts.map +1 -1
- package/esm/errors/quota-exceeded-error.mjs +1 -1
- package/esm/errors/quota-exceeded-error.mjs.map +1 -1
- package/esm/errors/routing-error.d.mts +1 -1
- package/esm/errors/routing-error.d.mts.map +1 -1
- package/esm/errors/routing-error.mjs +1 -1
- package/esm/errors/routing-error.mjs.map +1 -1
- package/esm/errors/schema-validation-error.d.mts +1 -1
- package/esm/errors/schema-validation-error.d.mts.map +1 -1
- package/esm/errors/schema-validation-error.mjs +1 -1
- package/esm/errors/schema-validation-error.mjs.map +1 -1
- package/esm/errors/step-failed-error.d.mts +1 -1
- package/esm/errors/step-failed-error.d.mts.map +1 -1
- package/esm/errors/step-failed-error.mjs +1 -1
- package/esm/errors/step-failed-error.mjs.map +1 -1
- package/esm/errors/supervisor-cancelled-error.d.mts +1 -1
- package/esm/errors/supervisor-cancelled-error.d.mts.map +1 -1
- package/esm/errors/supervisor-cancelled-error.mjs +1 -1
- package/esm/errors/supervisor-cancelled-error.mjs.map +1 -1
- package/esm/errors/supervisor-drift-error.d.mts +1 -1
- package/esm/errors/supervisor-drift-error.d.mts.map +1 -1
- package/esm/errors/supervisor-drift-error.mjs +1 -1
- package/esm/errors/supervisor-drift-error.mjs.map +1 -1
- package/esm/errors/supervisor-failed-error.d.mts +1 -1
- package/esm/errors/supervisor-failed-error.d.mts.map +1 -1
- package/esm/errors/supervisor-failed-error.mjs +1 -1
- package/esm/errors/supervisor-failed-error.mjs.map +1 -1
- package/esm/errors/supervisor-routing-error.d.mts +1 -1
- package/esm/errors/supervisor-routing-error.d.mts.map +1 -1
- package/esm/errors/supervisor-routing-error.mjs +1 -1
- package/esm/errors/supervisor-routing-error.mjs.map +1 -1
- package/esm/errors/tool-execution-error.d.mts +1 -1
- package/esm/errors/tool-execution-error.d.mts.map +1 -1
- package/esm/errors/tool-execution-error.mjs +1 -1
- package/esm/errors/tool-execution-error.mjs.map +1 -1
- package/esm/errors/workflow-cancelled-error.d.mts +1 -1
- package/esm/errors/workflow-cancelled-error.d.mts.map +1 -1
- package/esm/errors/workflow-cancelled-error.mjs +1 -1
- package/esm/errors/workflow-cancelled-error.mjs.map +1 -1
- package/esm/errors/workflow-drift-error.d.mts +1 -1
- package/esm/errors/workflow-drift-error.d.mts.map +1 -1
- package/esm/errors/workflow-drift-error.mjs +1 -1
- package/esm/errors/workflow-drift-error.mjs.map +1 -1
- package/esm/errors/workflow-error.d.mts +1 -1
- package/esm/errors/workflow-error.d.mts.map +1 -1
- package/esm/errors/workflow-error.mjs +1 -1
- package/esm/errors/workflow-error.mjs.map +1 -1
- package/esm/eval/dataset.d.mts +1 -1
- package/esm/eval/dataset.d.mts.map +1 -1
- package/esm/eval/dataset.mjs +1 -1
- package/esm/eval/dataset.mjs.map +1 -1
- package/esm/eval/dataset.type.d.mts +1 -1
- package/esm/eval/dataset.type.d.mts.map +1 -1
- package/esm/eval/eval-runner.d.mts +1 -1
- package/esm/eval/eval-runner.d.mts.map +1 -1
- package/esm/eval/eval-runner.mjs +1 -1
- package/esm/eval/eval-runner.mjs.map +1 -1
- package/esm/eval/index.d.mts +1 -1
- package/esm/eval/index.d.mts.map +1 -1
- package/esm/eval/index.mjs +1 -1
- package/esm/eval/index.mjs.map +1 -1
- package/esm/eval/judge-scorer.d.mts +1 -1
- package/esm/eval/judge-scorer.d.mts.map +1 -1
- package/esm/eval/judge-scorer.mjs +1 -1
- package/esm/eval/judge-scorer.mjs.map +1 -1
- package/esm/eval/regression.d.mts +1 -1
- package/esm/eval/regression.d.mts.map +1 -1
- package/esm/eval/regression.mjs +1 -1
- package/esm/eval/regression.mjs.map +1 -1
- package/esm/eval/report-json.d.mts +1 -1
- package/esm/eval/report-json.d.mts.map +1 -1
- package/esm/eval/report-json.mjs +1 -1
- package/esm/eval/report-json.mjs.map +1 -1
- package/esm/eval/report-junit.d.mts +1 -1
- package/esm/eval/report-junit.d.mts.map +1 -1
- package/esm/eval/report-junit.mjs +1 -1
- package/esm/eval/report-junit.mjs.map +1 -1
- package/esm/eval/scorers.d.mts +1 -1
- package/esm/eval/scorers.d.mts.map +1 -1
- package/esm/eval/scorers.mjs +1 -1
- package/esm/eval/scorers.mjs.map +1 -1
- package/esm/guard/contracts/guard-options.type.d.mts +1 -1
- package/esm/guard/contracts/guard-options.type.d.mts.map +1 -1
- package/esm/guard/contracts/guardrail.contract.d.mts +1 -1
- package/esm/guard/contracts/guardrail.contract.d.mts.map +1 -1
- package/esm/guard/contracts/openai-client.contract.d.mts +1 -1
- package/esm/guard/contracts/openai-client.contract.d.mts.map +1 -1
- package/esm/guard/contracts/verdict.type.d.mts +1 -1
- package/esm/guard/contracts/verdict.type.d.mts.map +1 -1
- package/esm/guard/detectors/injection.d.mts +1 -1
- package/esm/guard/detectors/injection.d.mts.map +1 -1
- package/esm/guard/detectors/injection.mjs +1 -1
- package/esm/guard/detectors/injection.mjs.map +1 -1
- package/esm/guard/detectors/moderation.d.mts +1 -1
- package/esm/guard/detectors/moderation.d.mts.map +1 -1
- package/esm/guard/detectors/moderation.mjs +1 -1
- package/esm/guard/detectors/moderation.mjs.map +1 -1
- package/esm/guard/detectors/pii.d.mts +1 -1
- package/esm/guard/detectors/pii.d.mts.map +1 -1
- package/esm/guard/detectors/pii.mjs +1 -1
- package/esm/guard/detectors/pii.mjs.map +1 -1
- package/esm/guard/detectors/topic.d.mts +1 -1
- package/esm/guard/detectors/topic.d.mts.map +1 -1
- package/esm/guard/detectors/topic.mjs +1 -1
- package/esm/guard/detectors/topic.mjs.map +1 -1
- package/esm/guard/errors.d.mts +1 -1
- package/esm/guard/errors.d.mts.map +1 -1
- package/esm/guard/errors.mjs +1 -1
- package/esm/guard/errors.mjs.map +1 -1
- package/esm/guard/guard.d.mts +1 -1
- package/esm/guard/guard.d.mts.map +1 -1
- package/esm/guard/guard.mjs +1 -1
- package/esm/guard/guard.mjs.map +1 -1
- package/esm/guard/guardrail.d.mts +1 -1
- package/esm/guard/guardrail.d.mts.map +1 -1
- package/esm/guard/guardrail.mjs +1 -1
- package/esm/guard/guardrail.mjs.map +1 -1
- package/esm/human/contracts/approval.type.d.mts +1 -1
- package/esm/human/contracts/approval.type.d.mts.map +1 -1
- package/esm/human/contracts/human-approval.type.d.mts +1 -1
- package/esm/human/contracts/human-approval.type.d.mts.map +1 -1
- package/esm/human/contracts/interrupt-store.contract.d.mts +1 -1
- package/esm/human/contracts/interrupt-store.contract.d.mts.map +1 -1
- package/esm/human/contracts/resume.type.d.mts +1 -1
- package/esm/human/contracts/resume.type.d.mts.map +1 -1
- package/esm/human/errors.d.mts +1 -1
- package/esm/human/errors.d.mts.map +1 -1
- package/esm/human/errors.mjs +1 -1
- package/esm/human/errors.mjs.map +1 -1
- package/esm/human/human-approval.d.mts +1 -1
- package/esm/human/human-approval.d.mts.map +1 -1
- package/esm/human/human-approval.mjs +1 -1
- package/esm/human/human-approval.mjs.map +1 -1
- package/esm/human/policy.d.mts +1 -1
- package/esm/human/policy.d.mts.map +1 -1
- package/esm/human/policy.mjs +1 -1
- package/esm/human/policy.mjs.map +1 -1
- package/esm/human/register.mjs +1 -1
- package/esm/human/register.mjs.map +1 -1
- package/esm/human/resume-seed.mjs +1 -1
- package/esm/human/resume-seed.mjs.map +1 -1
- package/esm/human/resume.d.mts +1 -1
- package/esm/human/resume.d.mts.map +1 -1
- package/esm/human/resume.mjs +1 -1
- package/esm/human/resume.mjs.map +1 -1
- package/esm/human/stores/memory.d.mts +1 -1
- package/esm/human/stores/memory.d.mts.map +1 -1
- package/esm/human/stores/memory.mjs +1 -1
- package/esm/human/stores/memory.mjs.map +1 -1
- package/esm/human/stores/pg.d.mts +1 -1
- package/esm/human/stores/pg.d.mts.map +1 -1
- package/esm/human/stores/pg.mjs +1 -1
- package/esm/human/stores/pg.mjs.map +1 -1
- package/esm/human/stores/redis.d.mts +1 -1
- package/esm/human/stores/redis.d.mts.map +1 -1
- package/esm/human/stores/redis.mjs +1 -1
- package/esm/human/stores/redis.mjs.map +1 -1
- package/esm/image/image-cost.d.mts +1 -1
- package/esm/image/image-cost.d.mts.map +1 -1
- package/esm/image/image-cost.mjs +1 -1
- package/esm/image/image-cost.mjs.map +1 -1
- package/esm/image/image.d.mts +1 -1
- package/esm/image/image.d.mts.map +1 -1
- package/esm/image/image.mjs +1 -1
- package/esm/image/image.mjs.map +1 -1
- package/esm/memory/derive-id.mjs +1 -1
- package/esm/memory/derive-id.mjs.map +1 -1
- package/esm/memory/episodic-memory.mjs +1 -1
- package/esm/memory/episodic-memory.mjs.map +1 -1
- package/esm/memory/memory.d.mts +1 -1
- package/esm/memory/memory.d.mts.map +1 -1
- package/esm/memory/memory.mjs +1 -1
- package/esm/memory/memory.mjs.map +1 -1
- package/esm/memory/procedural-memory.mjs +1 -1
- package/esm/memory/procedural-memory.mjs.map +1 -1
- package/esm/memory/semantic-memory.mjs +1 -1
- package/esm/memory/semantic-memory.mjs.map +1 -1
- package/esm/memory/working-memory.mjs +1 -1
- package/esm/memory/working-memory.mjs.map +1 -1
- package/esm/middleware/builtins/budget-contract.type.d.mts +1 -1
- package/esm/middleware/builtins/budget-contract.type.d.mts.map +1 -1
- package/esm/middleware/builtins/budget.d.mts +1 -1
- package/esm/middleware/builtins/budget.d.mts.map +1 -1
- package/esm/middleware/builtins/budget.mjs +1 -1
- package/esm/middleware/builtins/budget.mjs.map +1 -1
- package/esm/middleware/builtins/guardrail.d.mts +1 -1
- package/esm/middleware/builtins/guardrail.d.mts.map +1 -1
- package/esm/middleware/builtins/guardrail.mjs +1 -1
- package/esm/middleware/builtins/guardrail.mjs.map +1 -1
- package/esm/middleware/builtins/semantic-cache.d.mts +1 -1
- package/esm/middleware/builtins/semantic-cache.d.mts.map +1 -1
- package/esm/middleware/builtins/semantic-cache.mjs +1 -1
- package/esm/middleware/builtins/semantic-cache.mjs.map +1 -1
- package/esm/middleware/helpers/compose.d.mts +1 -1
- package/esm/middleware/helpers/compose.d.mts.map +1 -1
- package/esm/middleware/helpers/compose.mjs +1 -1
- package/esm/middleware/helpers/compose.mjs.map +1 -1
- package/esm/middleware/helpers/for-tool.d.mts +1 -1
- package/esm/middleware/helpers/for-tool.d.mts.map +1 -1
- package/esm/middleware/helpers/for-tool.mjs +1 -1
- package/esm/middleware/helpers/for-tool.mjs.map +1 -1
- package/esm/middleware/pipeline.d.mts +1 -1
- package/esm/middleware/pipeline.d.mts.map +1 -1
- package/esm/middleware/pipeline.mjs +1 -1
- package/esm/middleware/pipeline.mjs.map +1 -1
- package/esm/middleware/utils/extract-user-text.d.mts +1 -1
- package/esm/middleware/utils/extract-user-text.d.mts.map +1 -1
- package/esm/middleware/utils/extract-user-text.mjs +1 -1
- package/esm/middleware/utils/extract-user-text.mjs.map +1 -1
- package/esm/middleware/utils/namespaced-state.d.mts +1 -1
- package/esm/middleware/utils/namespaced-state.d.mts.map +1 -1
- package/esm/middleware/utils/namespaced-state.mjs +1 -1
- package/esm/middleware/utils/namespaced-state.mjs.map +1 -1
- package/esm/mock/mock-agent.d.mts +1 -1
- package/esm/mock/mock-agent.d.mts.map +1 -1
- package/esm/mock/mock-agent.mjs +1 -1
- package/esm/mock/mock-agent.mjs.map +1 -1
- package/esm/mock/mock-config.type.d.mts +1 -1
- package/esm/mock/mock-config.type.d.mts.map +1 -1
- package/esm/mock/mock-image-model.d.mts +1 -1
- package/esm/mock/mock-image-model.d.mts.map +1 -1
- package/esm/mock/mock-image-model.mjs +1 -1
- package/esm/mock/mock-image-model.mjs.map +1 -1
- package/esm/mock/mock-model.d.mts +1 -1
- package/esm/mock/mock-model.d.mts.map +1 -1
- package/esm/mock/mock-model.mjs +1 -1
- package/esm/mock/mock-model.mjs.map +1 -1
- package/esm/mock/mock-router.d.mts +1 -1
- package/esm/mock/mock-router.d.mts.map +1 -1
- package/esm/mock/mock-router.mjs +1 -1
- package/esm/mock/mock-router.mjs.map +1 -1
- package/esm/mock/mock-sdk.d.mts +1 -1
- package/esm/mock/mock-sdk.d.mts.map +1 -1
- package/esm/mock/mock-sdk.mjs +1 -1
- package/esm/mock/mock-sdk.mjs.map +1 -1
- package/esm/mock/mock-speech-model.d.mts +1 -1
- package/esm/mock/mock-speech-model.d.mts.map +1 -1
- package/esm/mock/mock-speech-model.mjs +1 -1
- package/esm/mock/mock-speech-model.mjs.map +1 -1
- package/esm/mock/mock-transcription-model.d.mts +1 -1
- package/esm/mock/mock-transcription-model.d.mts.map +1 -1
- package/esm/mock/mock-transcription-model.mjs +1 -1
- package/esm/mock/mock-transcription-model.mjs.map +1 -1
- package/esm/model/fallback-model.d.mts +1 -1
- package/esm/model/fallback-model.d.mts.map +1 -1
- package/esm/model/fallback-model.mjs +1 -1
- package/esm/model/fallback-model.mjs.map +1 -1
- package/esm/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.mjs +1 -1
- package/esm/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.mjs.map +1 -1
- package/esm/node_modules/@vitest/expect/dist/index.mjs +1 -1
- package/esm/node_modules/@vitest/expect/dist/index.mjs.map +1 -1
- package/esm/node_modules/@vitest/pretty-format/dist/index.mjs +1 -1
- package/esm/node_modules/@vitest/pretty-format/dist/index.mjs.map +1 -1
- package/esm/node_modules/@vitest/runner/dist/chunk-artifact.mjs +1 -1
- package/esm/node_modules/@vitest/runner/dist/chunk-artifact.mjs.map +1 -1
- package/esm/node_modules/@vitest/snapshot/dist/index.mjs +1 -1
- package/esm/node_modules/@vitest/snapshot/dist/index.mjs.map +1 -1
- package/esm/node_modules/@vitest/spy/dist/index.mjs +1 -1
- package/esm/node_modules/@vitest/spy/dist/index.mjs.map +1 -1
- package/esm/node_modules/@vitest/utils/dist/chunk-pathe.M-eThtNZ.mjs +1 -1
- package/esm/node_modules/@vitest/utils/dist/chunk-pathe.M-eThtNZ.mjs.map +1 -1
- package/esm/node_modules/@vitest/utils/dist/diff.mjs +1 -1
- package/esm/node_modules/@vitest/utils/dist/diff.mjs.map +1 -1
- package/esm/node_modules/@vitest/utils/dist/display.mjs +1 -1
- package/esm/node_modules/@vitest/utils/dist/display.mjs.map +1 -1
- package/esm/node_modules/@vitest/utils/dist/error.mjs +1 -1
- package/esm/node_modules/@vitest/utils/dist/error.mjs.map +1 -1
- package/esm/node_modules/@vitest/utils/dist/helpers.mjs +1 -1
- package/esm/node_modules/@vitest/utils/dist/helpers.mjs.map +1 -1
- package/esm/node_modules/@vitest/utils/dist/offset.mjs +1 -1
- package/esm/node_modules/@vitest/utils/dist/offset.mjs.map +1 -1
- package/esm/node_modules/@vitest/utils/dist/serialize.mjs +1 -1
- package/esm/node_modules/@vitest/utils/dist/serialize.mjs.map +1 -1
- package/esm/node_modules/@vitest/utils/dist/source-map.mjs +1 -1
- package/esm/node_modules/@vitest/utils/dist/source-map.mjs.map +1 -1
- package/esm/node_modules/@vitest/utils/dist/timers.mjs +1 -1
- package/esm/node_modules/@vitest/utils/dist/timers.mjs.map +1 -1
- package/esm/node_modules/chai/index.mjs +1 -1
- package/esm/node_modules/chai/index.mjs.map +1 -1
- package/esm/node_modules/magic-string/dist/magic-string.es.mjs +1 -1
- package/esm/node_modules/magic-string/dist/magic-string.es.mjs.map +1 -1
- package/esm/node_modules/tinyrainbow/dist/index.mjs +1 -1
- package/esm/node_modules/tinyrainbow/dist/index.mjs.map +1 -1
- package/esm/node_modules/vitest/dist/chunks/_commonjsHelpers.D26ty3Ew.mjs +1 -1
- package/esm/node_modules/vitest/dist/chunks/_commonjsHelpers.D26ty3Ew.mjs.map +1 -1
- package/esm/node_modules/vitest/dist/chunks/rpc.MzXet3jl.mjs +1 -1
- package/esm/node_modules/vitest/dist/chunks/rpc.MzXet3jl.mjs.map +1 -1
- package/esm/node_modules/vitest/dist/chunks/test.DNmyFkvJ.mjs +1 -1
- package/esm/node_modules/vitest/dist/chunks/test.DNmyFkvJ.mjs.map +1 -1
- package/esm/node_modules/vitest/dist/chunks/utils.BX5Fg8C4.mjs +1 -1
- package/esm/node_modules/vitest/dist/chunks/utils.BX5Fg8C4.mjs.map +1 -1
- package/esm/object-stream/parse-partial-json.d.mts +1 -1
- package/esm/object-stream/parse-partial-json.d.mts.map +1 -1
- package/esm/object-stream/parse-partial-json.mjs +1 -1
- package/esm/object-stream/parse-partial-json.mjs.map +1 -1
- package/esm/object-stream/stream-object.d.mts +1 -1
- package/esm/object-stream/stream-object.d.mts.map +1 -1
- package/esm/object-stream/stream-object.mjs +1 -1
- package/esm/object-stream/stream-object.mjs.map +1 -1
- package/esm/observe/observer-registry.d.mts +1 -1
- package/esm/observe/observer-registry.d.mts.map +1 -1
- package/esm/observe/observer-registry.mjs +1 -1
- package/esm/observe/observer-registry.mjs.map +1 -1
- package/esm/observe/observer.contract.d.mts +1 -1
- package/esm/observe/observer.contract.d.mts.map +1 -1
- package/esm/observe/resolve-observers.d.mts +1 -1
- package/esm/observe/resolve-observers.d.mts.map +1 -1
- package/esm/observe/resolve-observers.mjs +1 -1
- package/esm/observe/resolve-observers.mjs.map +1 -1
- package/esm/orchestrator/as-tool.d.mts +1 -1
- package/esm/orchestrator/as-tool.d.mts.map +1 -1
- package/esm/orchestrator/as-tool.mjs +1 -1
- package/esm/orchestrator/as-tool.mjs.map +1 -1
- package/esm/orchestrator/checkpoint.mjs +1 -1
- package/esm/orchestrator/checkpoint.mjs.map +1 -1
- package/esm/orchestrator/commands.d.mts +1 -1
- package/esm/orchestrator/commands.d.mts.map +1 -1
- package/esm/orchestrator/commands.mjs +1 -1
- package/esm/orchestrator/commands.mjs.map +1 -1
- package/esm/orchestrator/compaction.mjs +1 -1
- package/esm/orchestrator/compaction.mjs.map +1 -1
- package/esm/orchestrator/dispatch.mjs +1 -1
- package/esm/orchestrator/dispatch.mjs.map +1 -1
- package/esm/orchestrator/emitter-port.type.d.mts +1 -1
- package/esm/orchestrator/emitter-port.type.d.mts.map +1 -1
- package/esm/orchestrator/emitter.d.mts +1 -1
- package/esm/orchestrator/emitter.d.mts.map +1 -1
- package/esm/orchestrator/emitter.mjs +1 -1
- package/esm/orchestrator/emitter.mjs.map +1 -1
- package/esm/orchestrator/engine-context.type.d.mts +1 -1
- package/esm/orchestrator/engine-context.type.d.mts.map +1 -1
- package/esm/orchestrator/execution.d.mts +1 -1
- package/esm/orchestrator/execution.d.mts.map +1 -1
- package/esm/orchestrator/execution.mjs +1 -1
- package/esm/orchestrator/execution.mjs.map +1 -1
- package/esm/orchestrator/load.mjs +1 -1
- package/esm/orchestrator/load.mjs.map +1 -1
- package/esm/orchestrator/lock.mjs +1 -1
- package/esm/orchestrator/lock.mjs.map +1 -1
- package/esm/orchestrator/memory.d.mts +1 -1
- package/esm/orchestrator/memory.d.mts.map +1 -1
- package/esm/orchestrator/memory.mjs +1 -1
- package/esm/orchestrator/memory.mjs.map +1 -1
- package/esm/orchestrator/orchestrator-stream.d.mts +1 -1
- package/esm/orchestrator/orchestrator-stream.d.mts.map +1 -1
- package/esm/orchestrator/orchestrator-stream.mjs +1 -1
- package/esm/orchestrator/orchestrator-stream.mjs.map +1 -1
- package/esm/orchestrator/orchestrator.d.mts +1 -1
- package/esm/orchestrator/orchestrator.d.mts.map +1 -1
- package/esm/orchestrator/orchestrator.mjs +1 -1
- package/esm/orchestrator/orchestrator.mjs.map +1 -1
- package/esm/orchestrator/resume.mjs +1 -1
- package/esm/orchestrator/resume.mjs.map +1 -1
- package/esm/orchestrator/session-lock.d.mts +1 -1
- package/esm/orchestrator/session-lock.d.mts.map +1 -1
- package/esm/orchestrator/session-lock.mjs +1 -1
- package/esm/orchestrator/session-lock.mjs.map +1 -1
- package/esm/orchestrator/signature.d.mts +1 -1
- package/esm/orchestrator/signature.d.mts.map +1 -1
- package/esm/orchestrator/signature.mjs +1 -1
- package/esm/orchestrator/signature.mjs.map +1 -1
- package/esm/orchestrator/window.mjs +1 -1
- package/esm/orchestrator/window.mjs.map +1 -1
- package/esm/planner/dag-scheduler.mjs +1 -1
- package/esm/planner/dag-scheduler.mjs.map +1 -1
- package/esm/planner/plan-prompt.d.mts +1 -1
- package/esm/planner/plan-prompt.d.mts.map +1 -1
- package/esm/planner/plan-prompt.mjs +1 -1
- package/esm/planner/plan-prompt.mjs.map +1 -1
- package/esm/planner/plan-schema.d.mts +1 -1
- package/esm/planner/plan-schema.d.mts.map +1 -1
- package/esm/planner/plan-schema.mjs +1 -1
- package/esm/planner/plan-schema.mjs.map +1 -1
- package/esm/planner/planner-run.d.mts +1 -1
- package/esm/planner/planner-run.d.mts.map +1 -1
- package/esm/planner/planner-run.mjs +1 -1
- package/esm/planner/planner-run.mjs.map +1 -1
- package/esm/planner/planner.d.mts +1 -1
- package/esm/planner/planner.d.mts.map +1 -1
- package/esm/planner/planner.mjs +1 -1
- package/esm/planner/planner.mjs.map +1 -1
- package/esm/planner/signature.d.mts +1 -1
- package/esm/planner/signature.d.mts.map +1 -1
- package/esm/planner/signature.mjs +1 -1
- package/esm/planner/signature.mjs.map +1 -1
- package/esm/planner/snapshot.mjs +1 -1
- package/esm/planner/snapshot.mjs.map +1 -1
- package/esm/prompt/errors.d.mts +1 -1
- package/esm/prompt/errors.d.mts.map +1 -1
- package/esm/prompt/errors.mjs +1 -1
- package/esm/prompt/errors.mjs.map +1 -1
- package/esm/prompt/prompt-langfuse-sync.mjs +1 -1
- package/esm/prompt/prompt-langfuse-sync.mjs.map +1 -1
- package/esm/prompt/prompt-langfuse-sync.type.d.mts +1 -1
- package/esm/prompt/prompt-langfuse-sync.type.d.mts.map +1 -1
- package/esm/prompt/prompt-validate.mjs +1 -1
- package/esm/prompt/prompt-validate.mjs.map +1 -1
- package/esm/prompt/prompt.d.mts +1 -1
- package/esm/prompt/prompt.d.mts.map +1 -1
- package/esm/prompt/prompt.mjs +1 -1
- package/esm/prompt/prompt.mjs.map +1 -1
- package/esm/prompt/prompt.type.d.mts +1 -1
- package/esm/prompt/prompt.type.d.mts.map +1 -1
- package/esm/prompts/prompts-manager.contract.d.mts +1 -1
- package/esm/prompts/prompts-manager.contract.d.mts.map +1 -1
- package/esm/prompts/prompts-manager.d.mts +1 -1
- package/esm/prompts/prompts-manager.d.mts.map +1 -1
- package/esm/prompts/prompts-manager.mjs +1 -1
- package/esm/prompts/prompts-manager.mjs.map +1 -1
- package/esm/prompts/prompts-manager.type.d.mts +1 -1
- package/esm/prompts/prompts-manager.type.d.mts.map +1 -1
- package/esm/prompts/prompts-validate.d.mts +1 -1
- package/esm/prompts/prompts-validate.d.mts.map +1 -1
- package/esm/prompts/prompts-validate.mjs +0 -0
- package/esm/prompts/prompts-validate.mjs.map +1 -1
- package/esm/rag/as-tool.mjs +1 -1
- package/esm/rag/as-tool.mjs.map +1 -1
- package/esm/rag/chunk/chunk.d.mts +1 -1
- package/esm/rag/chunk/chunk.d.mts.map +1 -1
- package/esm/rag/chunk/chunk.mjs +1 -1
- package/esm/rag/chunk/chunk.mjs.map +1 -1
- package/esm/rag/chunk/fixed.mjs +1 -1
- package/esm/rag/chunk/fixed.mjs.map +1 -1
- package/esm/rag/chunk/markdown.mjs +1 -1
- package/esm/rag/chunk/markdown.mjs.map +1 -1
- package/esm/rag/chunk/recursive.mjs +1 -1
- package/esm/rag/chunk/recursive.mjs.map +1 -1
- package/esm/rag/chunk/sentence.mjs +1 -1
- package/esm/rag/chunk/sentence.mjs.map +1 -1
- package/esm/rag/contracts/chunk-options.type.d.mts +1 -1
- package/esm/rag/contracts/chunk-options.type.d.mts.map +1 -1
- package/esm/rag/contracts/citation.type.d.mts +1 -1
- package/esm/rag/contracts/citation.type.d.mts.map +1 -1
- package/esm/rag/contracts/rag-config.type.d.mts +1 -1
- package/esm/rag/contracts/rag-config.type.d.mts.map +1 -1
- package/esm/rag/contracts/rag-document.type.d.mts +1 -1
- package/esm/rag/contracts/rag-document.type.d.mts.map +1 -1
- package/esm/rag/hybrid/bm25.d.mts +1 -1
- package/esm/rag/hybrid/bm25.d.mts.map +1 -1
- package/esm/rag/hybrid/bm25.mjs +1 -1
- package/esm/rag/hybrid/bm25.mjs.map +1 -1
- package/esm/rag/hybrid/hybrid-rank.d.mts +1 -1
- package/esm/rag/hybrid/hybrid-rank.d.mts.map +1 -1
- package/esm/rag/hybrid/hybrid-rank.mjs +1 -1
- package/esm/rag/hybrid/hybrid-rank.mjs.map +1 -1
- package/esm/rag/hybrid/rrf.d.mts +1 -1
- package/esm/rag/hybrid/rrf.d.mts.map +1 -1
- package/esm/rag/hybrid/rrf.mjs +1 -1
- package/esm/rag/hybrid/rrf.mjs.map +1 -1
- package/esm/rag/loaders/errors.d.mts +1 -1
- package/esm/rag/loaders/errors.d.mts.map +1 -1
- package/esm/rag/loaders/errors.mjs +1 -1
- package/esm/rag/loaders/errors.mjs.map +1 -1
- package/esm/rag/loaders/load-html.d.mts +1 -1
- package/esm/rag/loaders/load-html.d.mts.map +1 -1
- package/esm/rag/loaders/load-html.mjs +1 -1
- package/esm/rag/loaders/load-html.mjs.map +1 -1
- package/esm/rag/loaders/load-pdf.d.mts +1 -1
- package/esm/rag/loaders/load-pdf.d.mts.map +1 -1
- package/esm/rag/loaders/load-pdf.mjs +1 -1
- package/esm/rag/loaders/load-pdf.mjs.map +1 -1
- package/esm/rag/loaders/load-text.d.mts +1 -1
- package/esm/rag/loaders/load-text.d.mts.map +1 -1
- package/esm/rag/loaders/load-text.mjs +1 -1
- package/esm/rag/loaders/load-text.mjs.map +1 -1
- package/esm/rag/loaders/load-web.d.mts +1 -1
- package/esm/rag/loaders/load-web.d.mts.map +1 -1
- package/esm/rag/loaders/load-web.mjs +1 -1
- package/esm/rag/loaders/load-web.mjs.map +1 -1
- package/esm/rag/loaders/loader.type.d.mts +1 -1
- package/esm/rag/loaders/loader.type.d.mts.map +1 -1
- package/esm/rag/rag.d.mts +1 -1
- package/esm/rag/rag.d.mts.map +1 -1
- package/esm/rag/rag.mjs +1 -1
- package/esm/rag/rag.mjs.map +1 -1
- package/esm/rag/rerank/keyword-reranker.d.mts +1 -1
- package/esm/rag/rerank/keyword-reranker.d.mts.map +1 -1
- package/esm/rag/rerank/keyword-reranker.mjs +1 -1
- package/esm/rag/rerank/keyword-reranker.mjs.map +1 -1
- package/esm/rag/rerank/llm-reranker.d.mts +1 -1
- package/esm/rag/rerank/llm-reranker.d.mts.map +1 -1
- package/esm/rag/rerank/llm-reranker.mjs +1 -1
- package/esm/rag/rerank/llm-reranker.mjs.map +1 -1
- package/esm/rag/rerank/reranker.contract.d.mts +1 -1
- package/esm/rag/rerank/reranker.contract.d.mts.map +1 -1
- package/esm/rag/retrieve.mjs +1 -1
- package/esm/rag/retrieve.mjs.map +1 -1
- package/esm/rag/store/cache-vector-store.d.mts +1 -1
- package/esm/rag/store/cache-vector-store.d.mts.map +1 -1
- package/esm/rag/store/cache-vector-store.mjs +1 -1
- package/esm/rag/store/cache-vector-store.mjs.map +1 -1
- package/esm/rag/store/pg-vector-store.d.mts +1 -1
- package/esm/rag/store/pg-vector-store.d.mts.map +1 -1
- package/esm/rag/store/pg-vector-store.mjs +1 -1
- package/esm/rag/store/pg-vector-store.mjs.map +1 -1
- package/esm/rag/store/vector-store.contract.d.mts +1 -1
- package/esm/rag/store/vector-store.contract.d.mts.map +1 -1
- package/esm/rag/transforms/multi-query.d.mts +1 -1
- package/esm/rag/transforms/multi-query.d.mts.map +1 -1
- package/esm/rag/transforms/multi-query.mjs +1 -1
- package/esm/rag/transforms/multi-query.mjs.map +1 -1
- package/esm/security/outbound-policy.d.mts +1 -1
- package/esm/security/outbound-policy.d.mts.map +1 -1
- package/esm/security/outbound-policy.mjs +1 -1
- package/esm/security/outbound-policy.mjs.map +1 -1
- package/esm/security/outbound-policy.type.d.mts +1 -1
- package/esm/security/outbound-policy.type.d.mts.map +1 -1
- package/esm/security/private-ip.d.mts +1 -1
- package/esm/security/private-ip.d.mts.map +1 -1
- package/esm/security/private-ip.mjs +1 -1
- package/esm/security/private-ip.mjs.map +1 -1
- package/esm/security/redact.d.mts +1 -1
- package/esm/security/redact.d.mts.map +1 -1
- package/esm/security/redact.mjs +1 -1
- package/esm/security/redact.mjs.map +1 -1
- package/esm/serve/serve.d.mts +1 -1
- package/esm/serve/serve.d.mts.map +1 -1
- package/esm/serve/serve.mjs +1 -1
- package/esm/serve/serve.mjs.map +1 -1
- package/esm/serve/sse.d.mts +1 -1
- package/esm/serve/sse.d.mts.map +1 -1
- package/esm/serve/sse.mjs +1 -1
- package/esm/serve/sse.mjs.map +1 -1
- package/esm/serve/stream-to-sse.d.mts +1 -1
- package/esm/serve/stream-to-sse.d.mts.map +1 -1
- package/esm/serve/stream-to-sse.mjs +1 -1
- package/esm/serve/stream-to-sse.mjs.map +1 -1
- package/esm/skills/catalog.d.mts +1 -1
- package/esm/skills/catalog.d.mts.map +1 -1
- package/esm/skills/catalog.mjs +1 -1
- package/esm/skills/catalog.mjs.map +1 -1
- package/esm/skills/contracts/skill-record.type.d.mts +1 -1
- package/esm/skills/contracts/skill-record.type.d.mts.map +1 -1
- package/esm/skills/contracts/skills-config.type.d.mts +1 -1
- package/esm/skills/contracts/skills-config.type.d.mts.map +1 -1
- package/esm/skills/contracts/skills-store.contract.d.mts +1 -1
- package/esm/skills/contracts/skills-store.contract.d.mts.map +1 -1
- package/esm/skills/contracts/skills.contract.d.mts +1 -1
- package/esm/skills/contracts/skills.contract.d.mts.map +1 -1
- package/esm/skills/load-skill-tool.d.mts +1 -1
- package/esm/skills/load-skill-tool.d.mts.map +1 -1
- package/esm/skills/load-skill-tool.mjs +1 -1
- package/esm/skills/load-skill-tool.mjs.map +1 -1
- package/esm/skills/review-gate.d.mts +1 -1
- package/esm/skills/review-gate.d.mts.map +1 -1
- package/esm/skills/review-gate.mjs +1 -1
- package/esm/skills/review-gate.mjs.map +1 -1
- package/esm/skills/save-skill-tool.d.mts +1 -1
- package/esm/skills/save-skill-tool.d.mts.map +1 -1
- package/esm/skills/save-skill-tool.mjs +1 -1
- package/esm/skills/save-skill-tool.mjs.map +1 -1
- package/esm/skills/skills.d.mts +1 -1
- package/esm/skills/skills.d.mts.map +1 -1
- package/esm/skills/skills.mjs +1 -1
- package/esm/skills/skills.mjs.map +1 -1
- package/esm/skills/sources/directory-source.d.mts +1 -1
- package/esm/skills/sources/directory-source.d.mts.map +1 -1
- package/esm/skills/sources/directory-source.mjs +1 -1
- package/esm/skills/sources/directory-source.mjs.map +1 -1
- package/esm/skills/sources/index.d.mts +1 -1
- package/esm/skills/sources/index.d.mts.map +1 -1
- package/esm/skills/sources/index.mjs +1 -1
- package/esm/skills/sources/index.mjs.map +1 -1
- package/esm/skills/sources/parse-frontmatter.d.mts +1 -1
- package/esm/skills/sources/parse-frontmatter.d.mts.map +1 -1
- package/esm/skills/sources/parse-frontmatter.mjs +1 -1
- package/esm/skills/sources/parse-frontmatter.mjs.map +1 -1
- package/esm/skills/sources/store-source.d.mts +1 -1
- package/esm/skills/sources/store-source.d.mts.map +1 -1
- package/esm/skills/sources/store-source.mjs +1 -1
- package/esm/skills/sources/store-source.mjs.map +1 -1
- package/esm/skills/sources/url-source.d.mts +1 -1
- package/esm/skills/sources/url-source.d.mts.map +1 -1
- package/esm/skills/sources/url-source.mjs +1 -1
- package/esm/skills/sources/url-source.mjs.map +1 -1
- package/esm/skills/store/mock-skills-store.d.mts +1 -1
- package/esm/skills/store/mock-skills-store.d.mts.map +1 -1
- package/esm/skills/store/mock-skills-store.mjs +1 -1
- package/esm/skills/store/mock-skills-store.mjs.map +1 -1
- package/esm/skills/store/procedural-skill-store.d.mts +1 -1
- package/esm/skills/store/procedural-skill-store.d.mts.map +1 -1
- package/esm/skills/store/procedural-skill-store.mjs +1 -1
- package/esm/skills/store/procedural-skill-store.mjs.map +1 -1
- package/esm/snapshot/memory.d.mts +1 -1
- package/esm/snapshot/memory.d.mts.map +1 -1
- package/esm/snapshot/memory.mjs +1 -1
- package/esm/snapshot/memory.mjs.map +1 -1
- package/esm/snapshot/pg.d.mts +1 -1
- package/esm/snapshot/pg.d.mts.map +1 -1
- package/esm/snapshot/pg.mjs +1 -1
- package/esm/snapshot/pg.mjs.map +1 -1
- package/esm/snapshot/redis.d.mts +1 -1
- package/esm/snapshot/redis.d.mts.map +1 -1
- package/esm/snapshot/redis.mjs +1 -1
- package/esm/snapshot/redis.mjs.map +1 -1
- package/esm/speech/speech.d.mts +1 -1
- package/esm/speech/speech.d.mts.map +1 -1
- package/esm/speech/speech.mjs +1 -1
- package/esm/speech/speech.mjs.map +1 -1
- package/esm/supervisor/as-tool.d.mts +1 -1
- package/esm/supervisor/as-tool.d.mts.map +1 -1
- package/esm/supervisor/as-tool.mjs +1 -1
- package/esm/supervisor/as-tool.mjs.map +1 -1
- package/esm/supervisor/cancellation.d.mts +1 -1
- package/esm/supervisor/cancellation.d.mts.map +1 -1
- package/esm/supervisor/cancellation.mjs +1 -1
- package/esm/supervisor/cancellation.mjs.map +1 -1
- package/esm/supervisor/decide.mjs +1 -1
- package/esm/supervisor/decide.mjs.map +1 -1
- package/esm/supervisor/emitter.d.mts +1 -1
- package/esm/supervisor/emitter.d.mts.map +1 -1
- package/esm/supervisor/emitter.mjs +1 -1
- package/esm/supervisor/emitter.mjs.map +1 -1
- package/esm/supervisor/entries.d.mts +1 -1
- package/esm/supervisor/entries.d.mts.map +1 -1
- package/esm/supervisor/entries.mjs +1 -1
- package/esm/supervisor/entries.mjs.map +1 -1
- package/esm/supervisor/execution.d.mts +1 -1
- package/esm/supervisor/execution.d.mts.map +1 -1
- package/esm/supervisor/execution.mjs +1 -1
- package/esm/supervisor/execution.mjs.map +1 -1
- package/esm/supervisor/fan-out.d.mts +1 -1
- package/esm/supervisor/fan-out.d.mts.map +1 -1
- package/esm/supervisor/fan-out.mjs +1 -1
- package/esm/supervisor/fan-out.mjs.map +1 -1
- package/esm/supervisor/router-factory.d.mts +1 -1
- package/esm/supervisor/router-factory.d.mts.map +1 -1
- package/esm/supervisor/router-factory.mjs +1 -1
- package/esm/supervisor/router-factory.mjs.map +1 -1
- package/esm/supervisor/router-prompt.d.mts +1 -1
- package/esm/supervisor/router-prompt.d.mts.map +1 -1
- package/esm/supervisor/router-prompt.mjs +1 -1
- package/esm/supervisor/router-prompt.mjs.map +1 -1
- package/esm/supervisor/signature.d.mts +1 -1
- package/esm/supervisor/signature.d.mts.map +1 -1
- package/esm/supervisor/signature.mjs +1 -1
- package/esm/supervisor/signature.mjs.map +1 -1
- package/esm/supervisor/snapshot.d.mts +1 -1
- package/esm/supervisor/snapshot.d.mts.map +1 -1
- package/esm/supervisor/snapshot.mjs +1 -1
- package/esm/supervisor/snapshot.mjs.map +1 -1
- package/esm/supervisor/supervisor-stream.d.mts +1 -1
- package/esm/supervisor/supervisor-stream.d.mts.map +1 -1
- package/esm/supervisor/supervisor-stream.mjs +1 -1
- package/esm/supervisor/supervisor-stream.mjs.map +1 -1
- package/esm/supervisor/supervisor.d.mts +1 -1
- package/esm/supervisor/supervisor.d.mts.map +1 -1
- package/esm/supervisor/supervisor.mjs +1 -1
- package/esm/supervisor/supervisor.mjs.map +1 -1
- package/esm/system-prompt/instruction.d.mts +1 -1
- package/esm/system-prompt/instruction.d.mts.map +1 -1
- package/esm/system-prompt/instruction.mjs +1 -1
- package/esm/system-prompt/instruction.mjs.map +1 -1
- package/esm/system-prompt/persona.d.mts +1 -1
- package/esm/system-prompt/persona.d.mts.map +1 -1
- package/esm/system-prompt/persona.mjs +1 -1
- package/esm/system-prompt/persona.mjs.map +1 -1
- package/esm/system-prompt/refined-system-prompt.d.mts +1 -1
- package/esm/system-prompt/refined-system-prompt.d.mts.map +1 -1
- package/esm/system-prompt/refined-system-prompt.mjs +1 -1
- package/esm/system-prompt/refined-system-prompt.mjs.map +1 -1
- package/esm/system-prompt/render-placeholders.d.mts +1 -1
- package/esm/system-prompt/render-placeholders.d.mts.map +1 -1
- package/esm/system-prompt/render-placeholders.mjs +1 -1
- package/esm/system-prompt/render-placeholders.mjs.map +1 -1
- package/esm/system-prompt/system-prompt.d.mts +1 -1
- package/esm/system-prompt/system-prompt.d.mts.map +1 -1
- package/esm/system-prompt/system-prompt.mjs +1 -1
- package/esm/system-prompt/system-prompt.mjs.map +1 -1
- package/esm/team/gates.mjs +1 -1
- package/esm/team/gates.mjs.map +1 -1
- package/esm/team/team.d.mts +1 -1
- package/esm/team/team.d.mts.map +1 -1
- package/esm/team/team.mjs +1 -1
- package/esm/team/team.mjs.map +1 -1
- package/esm/testing/matcher-logic.d.mts +1 -1
- package/esm/testing/matcher-logic.d.mts.map +1 -1
- package/esm/testing/matcher-logic.mjs +1 -1
- package/esm/testing/matcher-logic.mjs.map +1 -1
- package/esm/testing/matchers.d.mts +1 -1
- package/esm/testing/matchers.d.mts.map +1 -1
- package/esm/testing/matchers.mjs +1 -1
- package/esm/testing/matchers.mjs.map +1 -1
- package/esm/testing/register-lazy.d.mts +1 -1
- package/esm/testing/register-lazy.d.mts.map +1 -1
- package/esm/testing/register-lazy.mjs +1 -1
- package/esm/testing/register-lazy.mjs.map +1 -1
- package/esm/tool/executable-as-tool.d.mts +1 -1
- package/esm/tool/executable-as-tool.d.mts.map +1 -1
- package/esm/tool/executable-as-tool.mjs +1 -1
- package/esm/tool/executable-as-tool.mjs.map +1 -1
- package/esm/tool/tool.d.mts +1 -1
- package/esm/tool/tool.d.mts.map +1 -1
- package/esm/tool/tool.mjs +1 -1
- package/esm/tool/tool.mjs.map +1 -1
- package/esm/transcribe/audio-input.d.mts +1 -1
- package/esm/transcribe/audio-input.d.mts.map +1 -1
- package/esm/transcribe/audio-input.mjs +1 -1
- package/esm/transcribe/audio-input.mjs.map +1 -1
- package/esm/transcribe/transcribe.d.mts +1 -1
- package/esm/transcribe/transcribe.d.mts.map +1 -1
- package/esm/transcribe/transcribe.mjs +1 -1
- package/esm/transcribe/transcribe.mjs.map +1 -1
- package/esm/utils/compute-cost.d.mts +1 -1
- package/esm/utils/compute-cost.d.mts.map +1 -1
- package/esm/utils/compute-cost.mjs +1 -1
- package/esm/utils/compute-cost.mjs.map +1 -1
- package/esm/utils/extract-json-lenient.d.mts +1 -1
- package/esm/utils/extract-json-lenient.d.mts.map +1 -1
- package/esm/utils/extract-json-lenient.mjs +1 -1
- package/esm/utils/extract-json-lenient.mjs.map +1 -1
- package/esm/utils/extract-json-payload.d.mts +1 -1
- package/esm/utils/extract-json-payload.d.mts.map +1 -1
- package/esm/utils/extract-json-payload.mjs +1 -1
- package/esm/utils/extract-json-payload.mjs.map +1 -1
- package/esm/utils/generate-run-id.d.mts +1 -1
- package/esm/utils/generate-run-id.d.mts.map +1 -1
- package/esm/utils/generate-run-id.mjs +1 -1
- package/esm/utils/generate-run-id.mjs.map +1 -1
- package/esm/utils/json-schema.d.mts +1 -1
- package/esm/utils/json-schema.d.mts.map +1 -1
- package/esm/utils/json-schema.mjs +1 -1
- package/esm/utils/json-schema.mjs.map +1 -1
- package/esm/utils/prepare-attachment-part.d.mts +1 -1
- package/esm/utils/prepare-attachment-part.d.mts.map +1 -1
- package/esm/utils/prepare-attachment-part.mjs +1 -1
- package/esm/utils/prepare-attachment-part.mjs.map +1 -1
- package/esm/utils/resolve-attachment.d.mts +1 -1
- package/esm/utils/resolve-attachment.d.mts.map +1 -1
- package/esm/utils/resolve-attachment.mjs +1 -1
- package/esm/utils/resolve-attachment.mjs.map +1 -1
- package/esm/utils/run-context.d.mts +1 -1
- package/esm/utils/run-context.d.mts.map +1 -1
- package/esm/utils/run-context.mjs +1 -1
- package/esm/utils/run-context.mjs.map +1 -1
- package/esm/utils/safe-json-parse.d.mts +1 -1
- package/esm/utils/safe-json-parse.d.mts.map +1 -1
- package/esm/utils/safe-json-parse.mjs +1 -1
- package/esm/utils/safe-json-parse.mjs.map +1 -1
- package/esm/utils/stamp-report-lineage.d.mts +1 -1
- package/esm/utils/stamp-report-lineage.d.mts.map +1 -1
- package/esm/utils/stamp-report-lineage.mjs +1 -1
- package/esm/utils/stamp-report-lineage.mjs.map +1 -1
- package/esm/utils/token-count.d.mts +1 -1
- package/esm/utils/token-count.d.mts.map +1 -1
- package/esm/utils/token-count.mjs +1 -1
- package/esm/utils/token-count.mjs.map +1 -1
- package/esm/vcr/cassette-io.mjs +1 -1
- package/esm/vcr/cassette-io.mjs.map +1 -1
- package/esm/vcr/errors.d.mts +1 -1
- package/esm/vcr/errors.d.mts.map +1 -1
- package/esm/vcr/errors.mjs +1 -1
- package/esm/vcr/errors.mjs.map +1 -1
- package/esm/vcr/hash-request.d.mts +1 -1
- package/esm/vcr/hash-request.d.mts.map +1 -1
- package/esm/vcr/hash-request.mjs +1 -1
- package/esm/vcr/hash-request.mjs.map +1 -1
- package/esm/vcr/vcr.d.mts +1 -1
- package/esm/vcr/vcr.d.mts.map +1 -1
- package/esm/vcr/vcr.mjs +1 -1
- package/esm/vcr/vcr.mjs.map +1 -1
- package/esm/vcr/vcr.type.d.mts +1 -1
- package/esm/vcr/vcr.type.d.mts.map +1 -1
- package/esm/workflow/as-tool.mjs +1 -1
- package/esm/workflow/as-tool.mjs.map +1 -1
- package/esm/workflow/cancellation.mjs +1 -1
- package/esm/workflow/cancellation.mjs.map +1 -1
- package/esm/workflow/emitter.mjs +1 -1
- package/esm/workflow/emitter.mjs.map +1 -1
- package/esm/workflow/engine.mjs +5 -2
- package/esm/workflow/engine.mjs.map +1 -1
- package/esm/workflow/retry.mjs +1 -1
- package/esm/workflow/retry.mjs.map +1 -1
- package/esm/workflow/router.mjs +1 -1
- package/esm/workflow/router.mjs.map +1 -1
- package/esm/workflow/run-scoped-emitter.mjs +1 -1
- package/esm/workflow/run-scoped-emitter.mjs.map +1 -1
- package/esm/workflow/signature.d.mts +1 -1
- package/esm/workflow/signature.d.mts.map +1 -1
- package/esm/workflow/signature.mjs +1 -1
- package/esm/workflow/signature.mjs.map +1 -1
- package/esm/workflow/snapshot.mjs +1 -1
- package/esm/workflow/snapshot.mjs.map +1 -1
- package/esm/workflow/state.mjs +1 -1
- package/esm/workflow/state.mjs.map +1 -1
- package/esm/workflow/step-runner.mjs +25 -6
- package/esm/workflow/step-runner.mjs.map +1 -1
- package/esm/workflow/step.d.mts +1 -1
- package/esm/workflow/step.d.mts.map +1 -1
- package/esm/workflow/step.mjs +1 -1
- package/esm/workflow/step.mjs.map +1 -1
- package/esm/workflow/workflow.d.mts +1 -1
- package/esm/workflow/workflow.d.mts.map +1 -1
- package/esm/workflow/workflow.mjs +1 -1
- package/esm/workflow/workflow.mjs.map +1 -1
- package/llms-full.txt +23 -2
- package/package.json +4 -4
- package/skills/observe-ai-flows/SKILL.md +2 -2
- package/skills/run-ai-workflow/SKILL.md +19 -0
- package/skills/run-supervisor/SKILL.md +2 -0
- package/cjs/magic-string.es-BtxW4VqG.cjs.map +0 -1
- package/cjs/matcher-logic-SBnzYohQ.cjs.map +0 -1
- package/cjs/matchers-BBh3gyB-.cjs.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"emitter.mjs","names":[],"sources":["
|
|
1
|
+
{"version":3,"file":"emitter.mjs","names":[],"sources":["../../../../../../../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"}
|
|
@@ -5,7 +5,7 @@ import { OrchestratorConfig } from "../contracts/orchestrator/orchestrator-confi
|
|
|
5
5
|
import { ResolvedOrchestratorMemory } from "./memory.mjs";
|
|
6
6
|
import { OrchestratorEmitterLike } from "./emitter-port.type.mjs";
|
|
7
7
|
|
|
8
|
-
//#region
|
|
8
|
+
//#region ../ai/src/orchestrator/engine-context.type.d.ts
|
|
9
9
|
/**
|
|
10
10
|
* Everything the C2 engine needs to run a turn, assembled once by the
|
|
11
11
|
* C1 factory at construction and passed into every engine entry point
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"engine-context.type.d.mts","names":[],"sources":["
|
|
1
|
+
{"version":3,"file":"engine-context.type.d.mts","names":[],"sources":["../../../../../../../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"}
|
|
@@ -9,7 +9,7 @@ import { ResolvedIntentEntry } from "../supervisor/entries.mjs";
|
|
|
9
9
|
import { OrchestratorEngineContext } from "./engine-context.type.mjs";
|
|
10
10
|
import { OrchestratorStreamController } from "./orchestrator-stream.mjs";
|
|
11
11
|
|
|
12
|
-
//#region
|
|
12
|
+
//#region ../ai/src/orchestrator/execution.d.ts
|
|
13
13
|
/**
|
|
14
14
|
* Constructor params the C1 factory passes when building an
|
|
15
15
|
* {@link OrchestratorExecution} per call. The factory owns author-time
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"execution.d.mts","names":[],"sources":["
|
|
1
|
+
{"version":3,"file":"execution.d.mts","names":[],"sources":["../../../../../../../ai/src/orchestrator/execution.ts"],"mappings":";;;;;;;;;;;;;;AAqEA;;;;;;;;;;;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;EAiChB;;;;EAAlB,MAAA,IAAU,OAAA,CAAQ,kBAAA,CAAmB,OAAA;EAiBxC;;;;;EAFG,OAAA,CACX,IAAA,EAAM,oBAAA,sBACL,OAAA,CAAQ,oBAAA;AAAA;;;;;;;;;;;;iBAuPS,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;;;;;;;;AA3PG;AAuPjC;;iBA4MsB,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"}
|
|
@@ -14,7 +14,7 @@ import { loadSession } from "./load.mjs";
|
|
|
14
14
|
import { resolveResume } from "./resume.mjs";
|
|
15
15
|
import { windowHistory } from "./window.mjs";
|
|
16
16
|
|
|
17
|
-
//#region
|
|
17
|
+
//#region ../ai/src/orchestrator/execution.ts
|
|
18
18
|
/** Empty rolled-up usage for turns that never dispatched (drift/seed). */
|
|
19
19
|
const ZERO_USAGE = {
|
|
20
20
|
input: 0,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"execution.mjs","names":[],"sources":["../../../../../../../@warlock.js/ai/src/orchestrator/execution.ts"],"sourcesContent":["import type { Message } from \"../contracts/conversation-message.type\";\nimport type { OrchestratorCommands } from \"../contracts/orchestrator/orchestrator-commands.type\";\nimport type { OrchestratorConfig } from \"../contracts/orchestrator/orchestrator-config.type\";\nimport type {\n OrchestratorEvent,\n OrchestratorEventHandlers,\n OrchestratorEventMap,\n OrchestratorEventName,\n} from \"../contracts/orchestrator/orchestrator-event.type\";\nimport type {\n OrchestratorExecuteOptions,\n OrchestratorResumeOptions,\n} from \"../contracts/orchestrator/orchestrator-execute-options.type\";\nimport type {\n CompactionResult,\n OrchestratorReport,\n OrchestratorReportStatus,\n OrchestratorResult,\n TurnSnapshot,\n} from \"../contracts/result/orchestrator-result.type\";\nimport { REPORT_SCHEMA_VERSION } from \"../contracts/result/base-report.type\";\nimport type { BaseReport } from \"../contracts/result/base-report.type\";\nimport type { Usage } from \"../contracts/result/usage.type\";\nimport type { SupervisorInput } from \"../contracts/supervisor/supervisor-input.type\";\nimport type { EventIdentity } from \"../contracts/events/event-identity.type\";\nimport {\n resolveDefaultCheckpointStore,\n resolveDefaultSnapshotStore,\n} from \"../config\";\nimport type { AIError } from \"../errors/ai-error\";\nimport { OrchestratorConfigError, OrchestratorDriftError } from \"../errors\";\nimport { notifyObservers } from \"../observe/resolve-observers\";\nimport type { ResolvedIntentEntry } from \"../supervisor/entries\";\nimport { generateRunId } from \"../utils/generate-run-id\";\nimport { persistCheckpoint, summarizeRoute } from \"./checkpoint\";\nimport { runCompaction, runManualCompaction, shouldCompact } from \"./compaction\";\nimport { deriveRunId, dispatchTurn } from \"./dispatch\";\nimport type { OrchestratorEmitter } from \"./emitter\";\nimport type { OrchestratorEmitterLike } from \"./emitter-port.type\";\nimport type { OrchestratorEngineContext } from \"./engine-context.type\";\nimport { acquireLock } from \"./lock\";\nimport { loadSession } from \"./load\";\nimport {\n injectMemories,\n outcomeTextFromTurn,\n recallForTurn,\n rememberTurnOutcome,\n resolveOrchestratorMemory,\n} from \"./memory\";\nimport type { OrchestratorStreamController } from \"./orchestrator-stream\";\nimport { resolveResume } from \"./resume\";\nimport { windowHistory } from \"./window\";\n\n/** Empty rolled-up usage for turns that never dispatched (drift/seed). */\nconst ZERO_USAGE: Usage = { input: 0, output: 0, total: 0 };\n\n/**\n * Constructor params the C1 factory passes when building an\n * {@link OrchestratorExecution} per call. The factory owns author-time\n * validation, intent-entry resolution, and signature computation; it\n * hands the engine the validated `config`, the resolved `entries`, the\n * computed `signature`, and the shared three-tier `emitter`. The\n * per-call inputs vary by entry point:\n *\n * - `execute` / `stream` — `input` + `options` (and `streamController`\n * for `stream`).\n * - `resume` — `resumeSessionId` + `resumeOptions`.\n * - `command(\"compact\")` — neither; `compact(args)` carries its own.\n */\nexport type OrchestratorExecutionParams<TOutput, TState> = {\n config: OrchestratorConfig<TOutput, TState>;\n /** Resolved intent entries (validated by C1; the engine delegates dispatch to the supervisor). */\n entries?: Map<string, ResolvedIntentEntry>;\n signature: string;\n emitter: OrchestratorEmitter;\n input?: SupervisorInput;\n options?: OrchestratorExecuteOptions<TState>;\n streamController?: OrchestratorStreamController<OrchestratorResult<TOutput>>;\n resumeSessionId?: string;\n resumeOptions?: OrchestratorResumeOptions;\n};\n\n/**\n * Per-call lifecycle engine — the single object the C1 factory\n * constructs and drives. Owns the 7-phase lifecycle (orchestrator.md §3:\n * load → drift → lock → window → dispatch → persist → compaction),\n * resolving the durable stores (own config field → `ai.config` default)\n * and adapting C1's three-tier {@link OrchestratorEmitter} to the\n * {@link OrchestratorEmitterLike} port the phase modules call.\n *\n * The factory creates a fresh instance per `execute` / `stream` /\n * `resume` / `command` call (single-call lifecycle invariant — §18.8);\n * the heavy lifting lives in the standalone phase functions\n * ({@link runTurn} / {@link runResume}) which this class delegates to.\n *\n * @example\n * const execution = new OrchestratorExecution({\n * config, entries, signature, emitter, input, options,\n * });\n * const result = await execution.run();\n */\nexport class OrchestratorExecution<TOutput, TState> {\n private readonly params: OrchestratorExecutionParams<TOutput, TState>;\n private readonly ctx: OrchestratorEngineContext<TOutput, TState>;\n private readonly streamController?: OrchestratorStreamController<\n OrchestratorResult<TOutput>\n >;\n\n public constructor(params: OrchestratorExecutionParams<TOutput, TState>) {\n this.params = params;\n this.streamController = params.streamController;\n this.ctx = {\n config: params.config,\n signature: params.signature,\n checkpointStore: resolveCheckpointStore(params.config),\n snapshotStore: resolveSnapshotStore(params.config),\n emitter: adaptEmitter(\n params.emitter,\n generateRunId(\"orchestrator\"),\n this.streamController as\n | OrchestratorStreamController<unknown>\n | undefined,\n ),\n memory: resolveOrchestratorMemory(params.config.memory),\n };\n }\n\n /**\n * `execute()` / `stream()` entry — run one turn through the 7-phase\n * lifecycle. When a `streamController` was supplied, the adapter mirrors\n * every emitted event into the stream and the controller is settled\n * (`end` / `fail`) once the result resolves.\n */\n public async run(): Promise<OrchestratorResult<TOutput>> {\n if (this.params.input === undefined || !this.params.options) {\n throw new OrchestratorConfigError(\n `ai.orchestrator(\"${this.params.config.name}\"): internal — run() invoked without input/options`,\n );\n }\n\n try {\n const result = await runTurn(\n this.ctx,\n this.params.input,\n this.params.options,\n );\n\n // Route the orchestrator's report to observers (per-flow `observe` +\n // the global observe-all gate) — parity with agent/workflow/supervisor,\n // so a durable session root no longer needs a manual observe.collect().\n await notifyObservers(this.ctx.config.observe, result.report);\n\n this.streamController?.end(result);\n\n return result;\n } catch (error) {\n this.streamController?.fail(error as Error);\n\n throw error;\n }\n }\n\n /**\n * `resume()` entry — drain an interrupted `iterate: true` turn (§9).\n * Returns `null` when nothing is in flight.\n */\n public async resume(): Promise<OrchestratorResult<TOutput> | null> {\n if (!this.params.resumeSessionId) {\n throw new OrchestratorConfigError(\n `ai.orchestrator(\"${this.params.config.name}\"): internal — resume() invoked without a sessionId`,\n );\n }\n\n return runResume(this.ctx, this.params.resumeSessionId, this.params.resumeOptions);\n }\n\n /**\n * `command(\"compact\")` entry — run a manual compaction on demand (§11 /\n * §12.1). Reuses the post-turn compaction code path against the\n * caller-supplied history and returns the raw {@link CompactionResult}.\n */\n public async compact(\n args: OrchestratorCommands[\"compact\"][\"args\"],\n ): Promise<OrchestratorCommands[\"compact\"][\"result\"]> {\n return runManualCompaction(\n this.ctx as OrchestratorEngineContext<unknown, TState>,\n args.history,\n );\n }\n}\n\n/**\n * Resolve the durable checkpoint store: the config's own field, falling\n * back to `ai.config({ defaultCheckpointStore })`. Throws\n * {@link OrchestratorConfigError} when neither resolves — persistence is\n * always on (§8.1), so a turn can never run without a checkpoint store.\n */\nfunction resolveCheckpointStore<TOutput, TState>(\n config: OrchestratorConfig<TOutput, TState>,\n) {\n const store = config.checkpointStore ?? resolveDefaultCheckpointStore();\n\n if (!store) {\n throw new OrchestratorConfigError(\n `ai.orchestrator(\"${config.name}\"): a \\`checkpointStore\\` is required ` +\n `(set one on the config or via \\`ai.config({ defaultCheckpointStore })\\`)`,\n );\n }\n\n return store;\n}\n\n/**\n * Resolve the internal-supervisor snapshot store for `iterate: true`\n * turns: the config's own field, falling back to\n * `ai.config({ defaultSnapshotStore })`. Returns `undefined` for\n * `iterate: false` orchestrators (no mid-turn resume — nothing to\n * snapshot). The factory already guarantees presence when\n * `iterate: true`, so the engine never asserts here.\n */\nfunction resolveSnapshotStore<TOutput, TState>(\n config: OrchestratorConfig<TOutput, TState>,\n) {\n if (config.iterate !== true) {\n return undefined;\n }\n\n return config.snapshotStore ?? resolveDefaultSnapshotStore();\n}\n\n/**\n * Adapt C1's three-tier {@link OrchestratorEmitter} (whose `emit` takes\n * `event, payload, identity, perCallHandlers?`) to the\n * {@link OrchestratorEmitterLike} port the phase modules call (a 2-arg\n * `emit(event, payload)` plus `bindPerCall`).\n *\n * The adapter injects the run identity centrally and, when a stream\n * controller is present, mirrors every fully-stamped event into the\n * stream pipe (§14.1 — the orchestrator's own events surface on the\n * stream alongside the bubbled child events). `bindPerCall` registers\n * the per-call `options.on` bag for the turn's duration and returns a\n * disposer that clears it.\n */\nfunction adaptEmitter(\n emitter: OrchestratorEmitter,\n runId: string,\n streamController: OrchestratorStreamController<unknown> | undefined,\n): OrchestratorEmitterLike {\n // `rootRunId === runId` for a standalone run; nested propagation lands\n // in a follow-up (see `EventIdentity`).\n const fullIdentity: EventIdentity = { runId, rootRunId: runId };\n\n let perCall: OrchestratorEventHandlers | undefined;\n\n return {\n emit<K extends OrchestratorEventName>(\n event: K,\n payload: OrchestratorEventMap[K],\n ): void {\n const fullPayload = emitter.emit(event, payload, fullIdentity, perCall);\n\n // The discriminated-union correlation between `type` and the\n // matching payload variant can't be expressed structurally — the\n // cast mirrors the supervisor stream's established pattern.\n streamController?.push({ type: event, ...fullPayload } as OrchestratorEvent);\n },\n bindPerCall(handlers: OrchestratorEventHandlers | undefined): () => void {\n perCall = handlers;\n\n return () => {\n perCall = undefined;\n };\n },\n };\n}\n\n/**\n * Phase 2 — drift check (orchestrator.md §3 / §4 Phase 2). Compares the\n * loaded checkpoint's `signature` against the current definition's.\n * Mismatch throws `OrchestratorDriftError` synchronously unless\n * `force` is set. Emits `orchestrator.drift.checked` either way. A new\n * session (no loaded signature) never drifts.\n */\nfunction assertNoDrift(\n ctx: OrchestratorEngineContext,\n sessionId: string,\n loadedSignature: string | undefined,\n force: boolean | undefined,\n): void {\n const drifted =\n loadedSignature !== undefined && loadedSignature !== ctx.signature;\n\n ctx.emitter.emit(\"orchestrator.drift.checked\", {\n sessionId,\n signature: ctx.signature,\n drifted,\n });\n\n if (drifted && !force) {\n throw new OrchestratorDriftError(\n `orchestrator \"${ctx.config.name}\": signature drift on session \"${sessionId}\" — ` +\n `the definition changed since this session was last persisted. ` +\n `Pass { force: true } only after reviewing the change, or discard / migrate the session.`,\n {\n savedSignature: loadedSignature as string,\n currentSignature: ctx.signature,\n sessionId,\n },\n );\n }\n}\n\n/**\n * Shallow-merge the per-call `state` patch (§5 — partial state\n * override) over the loaded session-state seed. The merged value\n * becomes the supervisor's seed for this turn.\n */\nfunction applyStatePatch<TState>(\n seed: TState,\n patch: Partial<TState> | undefined,\n): TState {\n if (!patch) {\n return seed;\n }\n\n return { ...seed, ...patch } as TState;\n}\n\n/**\n * Assemble the orchestrator-scope {@link OrchestratorReport} from the\n * dispatched turn's child report and the turn snapshot. Wraps the\n * child supervisor/agent report tree as `children[0]` (§15.6 —\n * `children[]` carries only the CURRENT turn's dispatched primitive\n * reports) while the per-turn forensic record lives on `turns[]`.\n */\nfunction buildReport(\n ctx: OrchestratorEngineContext,\n sessionId: string,\n turnIndex: number,\n status: OrchestratorReportStatus,\n turnSnapshot: TurnSnapshot | undefined,\n childReport: BaseReport | undefined,\n error?: AIError,\n): OrchestratorReport {\n const now = new Date().toISOString();\n const usage = turnSnapshot?.usage ?? childReport?.usage ?? ZERO_USAGE;\n\n return {\n runId: deriveRunId(sessionId, ctx.config.version, turnIndex),\n rootRunId: deriveRunId(sessionId, ctx.config.version, turnIndex),\n name: ctx.config.name,\n version: ctx.config.version,\n sessionId,\n type: \"orchestrator\",\n status,\n // Stamp the terminal error so the observe path surfaces it on the\n // orchestrator span (an observer never sees the result envelope).\n // Absent on a clean turn.\n ...(error ? { error } : {}),\n startedAt: turnSnapshot?.startedAt ?? now,\n endedAt: turnSnapshot?.endedAt ?? now,\n duration: turnSnapshot?.duration ?? 0,\n usage,\n children: childReport ? [childReport] : [],\n reportSchemaVersion: REPORT_SCHEMA_VERSION,\n turnIndex,\n signature: ctx.signature,\n turns: turnSnapshot ? [turnSnapshot] : [],\n };\n}\n\n/**\n * Map the dispatched supervisor result's report status onto the\n * orchestrator's status surface (§15.6). A clean completion that is\n * still mid-conversation reports `\"awaiting-input\"` (the session\n * continues) rather than `\"completed\"`; failures and cancellations\n * pass through.\n */\nfunction deriveStatus(childStatus: BaseReport[\"status\"]): OrchestratorReportStatus {\n if (childStatus === \"completed\") {\n return \"awaiting-input\";\n }\n\n return childStatus;\n}\n\n/**\n * Emit the terminal turn event matching the report status (§14.1).\n */\nfunction emitTerminal(\n ctx: OrchestratorEngineContext,\n sessionId: string,\n turnIndex: number,\n status: OrchestratorReportStatus,\n): void {\n if (status === \"cancelled\") {\n ctx.emitter.emit(\"orchestrator.turn.cancelled\", { sessionId, turnIndex });\n\n return;\n }\n\n if (status === \"failed\" || status === \"max-iterations\") {\n ctx.emitter.emit(\"orchestrator.turn.failed\", { sessionId, turnIndex });\n\n return;\n }\n\n if (status === \"awaiting-input\") {\n ctx.emitter.emit(\"orchestrator.turn.awaiting-input\", {\n sessionId,\n turnIndex,\n });\n\n return;\n }\n\n ctx.emitter.emit(\"orchestrator.turn.completed\", { sessionId, turnIndex });\n}\n\n/**\n * Run one turn end-to-end through the 7-phase lifecycle (orchestrator\n * .md §3). The single entry the C1 factory's `execute()` delegates to.\n *\n * Phase order is the diagram's contract: load → drift → lock → window\n * → dispatch → persist → compaction. Drift / config misuse throw;\n * every other failure surfaces on `result.error` (the contract: the\n * orchestrator never throws on runtime failure). Cancellation and\n * failure do NOT persist a fresh checkpoint (§17 — state reverts to the\n * pre-turn checkpoint).\n */\nexport async function runTurn<TOutput, TState>(\n ctx: OrchestratorEngineContext<TOutput, TState>,\n input: SupervisorInput,\n options: OrchestratorExecuteOptions<TState>,\n): Promise<OrchestratorResult<TOutput>> {\n const sessionId = options.sessionId;\n const disposePerCall = ctx.emitter.bindPerCall(options.on);\n\n try {\n // Phase 1 — load session.\n const loaded = await loadSession(ctx, sessionId);\n\n ctx.emitter.emit(\"orchestrator.turn.starting\", {\n sessionId,\n turnIndex: loaded.turnIndex,\n });\n\n ctx.emitter.emit(\"orchestrator.session.loaded\", {\n sessionId,\n turnIndex: loaded.turnIndex,\n found: loaded.found,\n });\n\n // Phase 2 — drift check.\n assertNoDrift(\n ctx as OrchestratorEngineContext,\n sessionId,\n loaded.record?.signature,\n options.force,\n );\n\n // Phase 3 — lock check (cooperative, fail-open).\n await acquireLock(ctx, sessionId, loaded.record);\n\n // Phase 4 — window history.\n const windowed = windowHistory(\n ctx as OrchestratorEngineContext,\n sessionId,\n options.history,\n );\n\n // Phase 5 — dispatch. When memory is configured, recall the\n // turn-relevant memories and inject them into the request-scoped\n // context bag so every route / router / evaluate / dispatch callback\n // surfaces them at `ctx.context[injectKey]` before routing runs.\n const seedState = applyStatePatch(loaded.state, options.state);\n\n let turnContext = options.context;\n\n if (ctx.memory) {\n const recalled = await recallForTurn(ctx.memory, input);\n turnContext = injectMemories(turnContext, ctx.memory, recalled);\n }\n\n const { result, state, turnSnapshot } = await dispatchTurn<TOutput, TState>({\n ctx,\n sessionId,\n input,\n seedState,\n turnIndex: loaded.turnIndex,\n history: windowed.agents,\n context: turnContext,\n signal: options.signal,\n });\n\n ctx.emitter.emit(\"orchestrator.turn.routed\", {\n sessionId,\n turnIndex: loaded.turnIndex,\n source: turnSnapshot.decision.source,\n raw: turnSnapshot.decision.raw,\n });\n\n const status = result.error\n ? deriveStatus(result.report.status)\n : \"awaiting-input\";\n\n // Cancelled / failed turns revert: no fresh checkpoint, no compaction.\n if (result.error) {\n const report = buildReport(\n ctx as OrchestratorEngineContext,\n sessionId,\n loaded.turnIndex,\n status,\n turnSnapshot,\n result.report,\n result.error,\n );\n\n emitTerminal(ctx as OrchestratorEngineContext, sessionId, loaded.turnIndex, status);\n\n return {\n data: result.data,\n error: result.error,\n usage: result.usage,\n report,\n sessionId,\n turnIndex: loaded.turnIndex,\n };\n }\n\n // Phase 6 — persist checkpoint.\n await persistCheckpoint({\n ctx,\n sessionId,\n turnIndex: loaded.turnIndex,\n state,\n lastRoute: summarizeRoute(turnSnapshot.decision.raw as never),\n summarizedThrough: loaded.record?.summarized_through ?? null,\n });\n\n // Memory write-back (memory core M2). The turn settled cleanly (the\n // `result.error` branch above already returned for cancelled /\n // failed turns, which revert and never remember — §17), so remember\n // the input + its outcome for later recall.\n if (ctx.memory) {\n await rememberTurnOutcome(\n ctx.memory,\n input,\n outcomeTextFromTurn(result.data, turnSnapshot),\n );\n }\n\n // Phase 7 — post-turn compaction (only when triggered).\n let compaction: CompactionResult | undefined;\n\n if (shouldCompact(ctx as OrchestratorEngineContext, loaded.turnIndex)) {\n const outcome = await runCompaction(\n ctx as OrchestratorEngineContext<unknown, TState>,\n sessionId,\n options.history,\n );\n\n if (outcome) {\n compaction = outcome.compaction;\n\n if (outcome.applied) {\n await advanceSummarizedThrough(\n ctx as OrchestratorEngineContext<unknown, TState>,\n sessionId,\n outcome.compaction.replacesToIndex,\n );\n }\n }\n }\n\n const report = buildReport(\n ctx as OrchestratorEngineContext,\n sessionId,\n loaded.turnIndex,\n \"awaiting-input\",\n turnSnapshot,\n result.report,\n );\n\n emitTerminal(ctx as OrchestratorEngineContext, sessionId, loaded.turnIndex, \"awaiting-input\");\n\n return {\n data: result.data,\n error: undefined,\n usage: result.usage,\n report,\n sessionId,\n turnIndex: loaded.turnIndex,\n compaction,\n };\n } finally {\n disposePerCall();\n }\n}\n\n/**\n * After a framework-applied compaction (`onCompact` succeeded), advance\n * the persisted `summarized_through` to the compaction's\n * `replacesToIndex` (§12.2 step 4). Re-saves the latest row with the\n * updated marker (append-only stores keep the prior row).\n */\nasync function advanceSummarizedThrough<TState>(\n ctx: OrchestratorEngineContext<unknown, TState>,\n sessionId: string,\n replacesToIndex: number,\n): Promise<void> {\n const latest = await ctx.checkpointStore.load(ctx.config.name, sessionId);\n\n if (!latest) {\n return;\n }\n\n await ctx.checkpointStore.save({\n ...latest,\n summarized_through: replacesToIndex,\n saved_at: new Date().toISOString(),\n });\n}\n\n/**\n * §9 resume protocol entry the C1 factory's `resume()` delegates to.\n * Returns `null` when no in-flight `iterate: true` turn is detected;\n * otherwise drains the interrupted supervisor run, persists a fresh\n * checkpoint for the resumed turn, and returns the completed result.\n *\n * Runs the same Phase 2 drift check as `runTurn` (§9.4). The heavy\n * lifting lives in `resume.ts`; this wrapper threads the engine\n * context.\n */\nexport async function runResume<TOutput, TState>(\n ctx: OrchestratorEngineContext<TOutput, TState>,\n sessionId: string,\n options?: OrchestratorResumeOptions,\n): Promise<OrchestratorResult<TOutput> | null> {\n const disposePerCall = ctx.emitter.bindPerCall(options?.on);\n\n try {\n return await resolveResume(ctx, sessionId, options, {\n assertNoDrift: (loadedSignature) =>\n assertNoDrift(\n ctx as OrchestratorEngineContext,\n sessionId,\n loadedSignature,\n options?.force,\n ),\n buildReport: (turnIndex, status, turnSnapshot, childReport) =>\n buildReport(\n ctx as OrchestratorEngineContext,\n sessionId,\n turnIndex,\n status,\n turnSnapshot,\n childReport,\n ),\n deriveStatus,\n emitTerminal: (turnIndex, status) =>\n emitTerminal(ctx as OrchestratorEngineContext, sessionId, turnIndex, status),\n persist: (turnIndex, state, lastRoute, summarizedThrough) =>\n persistCheckpoint({\n ctx,\n sessionId,\n turnIndex,\n state,\n lastRoute,\n summarizedThrough,\n }),\n });\n } finally {\n disposePerCall();\n }\n}\n\n/**\n * The `stream()` entry. The orchestrator's streaming surface bubbles\n * child agent/supervisor events under their own namespace (§14.2); the\n * C1 stream controller owns the `StreamContract` wiring. This engine\n * entry runs the same lifecycle as `runTurn` — the C1 factory passes a\n * per-call `on` bag wired to the stream controller, so the engine needs\n * no streaming-specific branch. Exposed as a distinct name for the\n * factory to call, returning the same `OrchestratorResult` the stream's\n * `.result` resolves to.\n */\nexport async function streamTurn<TOutput, TState>(\n ctx: OrchestratorEngineContext<TOutput, TState>,\n input: SupervisorInput,\n options: OrchestratorExecuteOptions<TState>,\n): Promise<OrchestratorResult<TOutput>> {\n return runTurn(ctx, input, options);\n}\n\nexport type { OrchestratorEngineContext } from \"./engine-context.type\";\nexport type { Message };\n"],"mappings":";;;;;;;;;;;;;;;;;;AAsDA,MAAM,aAAoB;CAAE,OAAO;CAAG,QAAQ;CAAG,OAAO;AAAE;;;;;;;;;;;;;;;;;;;;AA+C1D,IAAa,wBAAb,MAAoD;CAOlD,AAAO,YAAY,QAAsD;EACvE,KAAK,SAAS;EACd,KAAK,mBAAmB,OAAO;EAC/B,KAAK,MAAM;GACT,QAAQ,OAAO;GACf,WAAW,OAAO;GAClB,iBAAiB,uBAAuB,OAAO,MAA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IAAI,OAAO,MAAM,SAAS;CAExE,IAAI,CAAC,QACH;CAGF,MAAM,IAAI,gBAAgB,KAAK;EAC7B,GAAG;EACH,oBAAoB;EACpB,2BAAU,IAAI,KAAK,EAAC,CAAC,YAAY;CACnC,CAAC;AACH;;;;;;;;;;;AAYA,eAAsB,UACpB,KACA,WACA,SAC6C;CAC7C,MAAM,iBAAiB,IAAI,QAAQ,YAAY,SAAS,EAAE;CAE1D,IAAI;EACF,OAAO,MAAM,cAAc,KAAK,WAAW,SAAS;GAClD,gBAAgB,oBACd,cACE,KACA,WACA,iBACA,SAAS,KACX;GACF,cAAc,WAAW,QAAQ,cAAc,gBAC7C,YACE,KACA,WACA,WACA,QACA,cACA,WACF;GACF;GACA,eAAe,WAAW,WACxB,aAAa,KAAkC,WAAW,WAAW,MAAM;GAC7E,UAAU,WAAW,OAAO,WAAW,sBACrC,kBAAkB;IAChB;IACA;IACA;IACA;IACA;IACA;GACF,CAAC;EACL,CAAC;CACH,UAAU;EACR,eAAe;CACjB;AACF;;;;;;;;;;;AAYA,eAAsB,WACpB,KACA,OACA,SACsC;CACtC,OAAO,QAAQ,KAAK,OAAO,OAAO;AACpC"}
|
|
1
|
+
{"version":3,"file":"execution.mjs","names":[],"sources":["../../../../../../../ai/src/orchestrator/execution.ts"],"sourcesContent":["import type { Message } from \"../contracts/conversation-message.type\";\nimport type { OrchestratorCommands } from \"../contracts/orchestrator/orchestrator-commands.type\";\nimport type { OrchestratorConfig } from \"../contracts/orchestrator/orchestrator-config.type\";\nimport type {\n OrchestratorEvent,\n OrchestratorEventHandlers,\n OrchestratorEventMap,\n OrchestratorEventName,\n} from \"../contracts/orchestrator/orchestrator-event.type\";\nimport type {\n OrchestratorExecuteOptions,\n OrchestratorResumeOptions,\n} from \"../contracts/orchestrator/orchestrator-execute-options.type\";\nimport type {\n CompactionResult,\n OrchestratorReport,\n OrchestratorReportStatus,\n OrchestratorResult,\n TurnSnapshot,\n} from \"../contracts/result/orchestrator-result.type\";\nimport { REPORT_SCHEMA_VERSION } from \"../contracts/result/base-report.type\";\nimport type { BaseReport } from \"../contracts/result/base-report.type\";\nimport type { Usage } from \"../contracts/result/usage.type\";\nimport type { SupervisorInput } from \"../contracts/supervisor/supervisor-input.type\";\nimport type { EventIdentity } from \"../contracts/events/event-identity.type\";\nimport {\n resolveDefaultCheckpointStore,\n resolveDefaultSnapshotStore,\n} from \"../config\";\nimport type { AIError } from \"../errors/ai-error\";\nimport { OrchestratorConfigError, OrchestratorDriftError } from \"../errors\";\nimport { notifyObservers } from \"../observe/resolve-observers\";\nimport type { ResolvedIntentEntry } from \"../supervisor/entries\";\nimport { generateRunId } from \"../utils/generate-run-id\";\nimport { persistCheckpoint, summarizeRoute } from \"./checkpoint\";\nimport { runCompaction, runManualCompaction, shouldCompact } from \"./compaction\";\nimport { deriveRunId, dispatchTurn } from \"./dispatch\";\nimport type { OrchestratorEmitter } from \"./emitter\";\nimport type { OrchestratorEmitterLike } from \"./emitter-port.type\";\nimport type { OrchestratorEngineContext } from \"./engine-context.type\";\nimport { acquireLock } from \"./lock\";\nimport { loadSession } from \"./load\";\nimport {\n injectMemories,\n outcomeTextFromTurn,\n recallForTurn,\n rememberTurnOutcome,\n resolveOrchestratorMemory,\n} from \"./memory\";\nimport type { OrchestratorStreamController } from \"./orchestrator-stream\";\nimport { resolveResume } from \"./resume\";\nimport { windowHistory } from \"./window\";\n\n/** Empty rolled-up usage for turns that never dispatched (drift/seed). */\nconst ZERO_USAGE: Usage = { input: 0, output: 0, total: 0 };\n\n/**\n * Constructor params the C1 factory passes when building an\n * {@link OrchestratorExecution} per call. The factory owns author-time\n * validation, intent-entry resolution, and signature computation; it\n * hands the engine the validated `config`, the resolved `entries`, the\n * computed `signature`, and the shared three-tier `emitter`. The\n * per-call inputs vary by entry point:\n *\n * - `execute` / `stream` — `input` + `options` (and `streamController`\n * for `stream`).\n * - `resume` — `resumeSessionId` + `resumeOptions`.\n * - `command(\"compact\")` — neither; `compact(args)` carries its own.\n */\nexport type OrchestratorExecutionParams<TOutput, TState> = {\n config: OrchestratorConfig<TOutput, TState>;\n /** Resolved intent entries (validated by C1; the engine delegates dispatch to the supervisor). */\n entries?: Map<string, ResolvedIntentEntry>;\n signature: string;\n emitter: OrchestratorEmitter;\n input?: SupervisorInput;\n options?: OrchestratorExecuteOptions<TState>;\n streamController?: OrchestratorStreamController<OrchestratorResult<TOutput>>;\n resumeSessionId?: string;\n resumeOptions?: OrchestratorResumeOptions;\n};\n\n/**\n * Per-call lifecycle engine — the single object the C1 factory\n * constructs and drives. Owns the 7-phase lifecycle (orchestrator.md §3:\n * load → drift → lock → window → dispatch → persist → compaction),\n * resolving the durable stores (own config field → `ai.config` default)\n * and adapting C1's three-tier {@link OrchestratorEmitter} to the\n * {@link OrchestratorEmitterLike} port the phase modules call.\n *\n * The factory creates a fresh instance per `execute` / `stream` /\n * `resume` / `command` call (single-call lifecycle invariant — §18.8);\n * the heavy lifting lives in the standalone phase functions\n * ({@link runTurn} / {@link runResume}) which this class delegates to.\n *\n * @example\n * const execution = new OrchestratorExecution({\n * config, entries, signature, emitter, input, options,\n * });\n * const result = await execution.run();\n */\nexport class OrchestratorExecution<TOutput, TState> {\n private readonly params: OrchestratorExecutionParams<TOutput, TState>;\n private readonly ctx: OrchestratorEngineContext<TOutput, TState>;\n private readonly streamController?: OrchestratorStreamController<\n OrchestratorResult<TOutput>\n >;\n\n public constructor(params: OrchestratorExecutionParams<TOutput, TState>) {\n this.params = params;\n this.streamController = params.streamController;\n this.ctx = {\n config: params.config,\n signature: params.signature,\n checkpointStore: resolveCheckpointStore(params.config),\n snapshotStore: resolveSnapshotStore(params.config),\n emitter: adaptEmitter(\n params.emitter,\n generateRunId(\"orchestrator\"),\n this.streamController as\n | OrchestratorStreamController<unknown>\n | undefined,\n ),\n memory: resolveOrchestratorMemory(params.config.memory),\n };\n }\n\n /**\n * `execute()` / `stream()` entry — run one turn through the 7-phase\n * lifecycle. When a `streamController` was supplied, the adapter mirrors\n * every emitted event into the stream and the controller is settled\n * (`end` / `fail`) once the result resolves.\n */\n public async run(): Promise<OrchestratorResult<TOutput>> {\n if (this.params.input === undefined || !this.params.options) {\n throw new OrchestratorConfigError(\n `ai.orchestrator(\"${this.params.config.name}\"): internal — run() invoked without input/options`,\n );\n }\n\n try {\n const result = await runTurn(\n this.ctx,\n this.params.input,\n this.params.options,\n );\n\n // Route the orchestrator's report to observers (per-flow `observe` +\n // the global observe-all gate) — parity with agent/workflow/supervisor,\n // so a durable session root no longer needs a manual observe.collect().\n await notifyObservers(this.ctx.config.observe, result.report);\n\n this.streamController?.end(result);\n\n return result;\n } catch (error) {\n this.streamController?.fail(error as Error);\n\n throw error;\n }\n }\n\n /**\n * `resume()` entry — drain an interrupted `iterate: true` turn (§9).\n * Returns `null` when nothing is in flight.\n */\n public async resume(): Promise<OrchestratorResult<TOutput> | null> {\n if (!this.params.resumeSessionId) {\n throw new OrchestratorConfigError(\n `ai.orchestrator(\"${this.params.config.name}\"): internal — resume() invoked without a sessionId`,\n );\n }\n\n return runResume(this.ctx, this.params.resumeSessionId, this.params.resumeOptions);\n }\n\n /**\n * `command(\"compact\")` entry — run a manual compaction on demand (§11 /\n * §12.1). Reuses the post-turn compaction code path against the\n * caller-supplied history and returns the raw {@link CompactionResult}.\n */\n public async compact(\n args: OrchestratorCommands[\"compact\"][\"args\"],\n ): Promise<OrchestratorCommands[\"compact\"][\"result\"]> {\n return runManualCompaction(\n this.ctx as OrchestratorEngineContext<unknown, TState>,\n args.history,\n );\n }\n}\n\n/**\n * Resolve the durable checkpoint store: the config's own field, falling\n * back to `ai.config({ defaultCheckpointStore })`. Throws\n * {@link OrchestratorConfigError} when neither resolves — persistence is\n * always on (§8.1), so a turn can never run without a checkpoint store.\n */\nfunction resolveCheckpointStore<TOutput, TState>(\n config: OrchestratorConfig<TOutput, TState>,\n) {\n const store = config.checkpointStore ?? resolveDefaultCheckpointStore();\n\n if (!store) {\n throw new OrchestratorConfigError(\n `ai.orchestrator(\"${config.name}\"): a \\`checkpointStore\\` is required ` +\n `(set one on the config or via \\`ai.config({ defaultCheckpointStore })\\`)`,\n );\n }\n\n return store;\n}\n\n/**\n * Resolve the internal-supervisor snapshot store for `iterate: true`\n * turns: the config's own field, falling back to\n * `ai.config({ defaultSnapshotStore })`. Returns `undefined` for\n * `iterate: false` orchestrators (no mid-turn resume — nothing to\n * snapshot). The factory already guarantees presence when\n * `iterate: true`, so the engine never asserts here.\n */\nfunction resolveSnapshotStore<TOutput, TState>(\n config: OrchestratorConfig<TOutput, TState>,\n) {\n if (config.iterate !== true) {\n return undefined;\n }\n\n return config.snapshotStore ?? resolveDefaultSnapshotStore();\n}\n\n/**\n * Adapt C1's three-tier {@link OrchestratorEmitter} (whose `emit` takes\n * `event, payload, identity, perCallHandlers?`) to the\n * {@link OrchestratorEmitterLike} port the phase modules call (a 2-arg\n * `emit(event, payload)` plus `bindPerCall`).\n *\n * The adapter injects the run identity centrally and, when a stream\n * controller is present, mirrors every fully-stamped event into the\n * stream pipe (§14.1 — the orchestrator's own events surface on the\n * stream alongside the bubbled child events). `bindPerCall` registers\n * the per-call `options.on` bag for the turn's duration and returns a\n * disposer that clears it.\n */\nfunction adaptEmitter(\n emitter: OrchestratorEmitter,\n runId: string,\n streamController: OrchestratorStreamController<unknown> | undefined,\n): OrchestratorEmitterLike {\n // `rootRunId === runId` for a standalone run; nested propagation lands\n // in a follow-up (see `EventIdentity`).\n const fullIdentity: EventIdentity = { runId, rootRunId: runId };\n\n let perCall: OrchestratorEventHandlers | undefined;\n\n return {\n emit<K extends OrchestratorEventName>(\n event: K,\n payload: OrchestratorEventMap[K],\n ): void {\n const fullPayload = emitter.emit(event, payload, fullIdentity, perCall);\n\n // The discriminated-union correlation between `type` and the\n // matching payload variant can't be expressed structurally — the\n // cast mirrors the supervisor stream's established pattern.\n streamController?.push({ type: event, ...fullPayload } as OrchestratorEvent);\n },\n bindPerCall(handlers: OrchestratorEventHandlers | undefined): () => void {\n perCall = handlers;\n\n return () => {\n perCall = undefined;\n };\n },\n };\n}\n\n/**\n * Phase 2 — drift check (orchestrator.md §3 / §4 Phase 2). Compares the\n * loaded checkpoint's `signature` against the current definition's.\n * Mismatch throws `OrchestratorDriftError` synchronously unless\n * `force` is set. Emits `orchestrator.drift.checked` either way. A new\n * session (no loaded signature) never drifts.\n */\nfunction assertNoDrift(\n ctx: OrchestratorEngineContext,\n sessionId: string,\n loadedSignature: string | undefined,\n force: boolean | undefined,\n): void {\n const drifted =\n loadedSignature !== undefined && loadedSignature !== ctx.signature;\n\n ctx.emitter.emit(\"orchestrator.drift.checked\", {\n sessionId,\n signature: ctx.signature,\n drifted,\n });\n\n if (drifted && !force) {\n throw new OrchestratorDriftError(\n `orchestrator \"${ctx.config.name}\": signature drift on session \"${sessionId}\" — ` +\n `the definition changed since this session was last persisted. ` +\n `Pass { force: true } only after reviewing the change, or discard / migrate the session.`,\n {\n savedSignature: loadedSignature as string,\n currentSignature: ctx.signature,\n sessionId,\n },\n );\n }\n}\n\n/**\n * Shallow-merge the per-call `state` patch (§5 — partial state\n * override) over the loaded session-state seed. The merged value\n * becomes the supervisor's seed for this turn.\n */\nfunction applyStatePatch<TState>(\n seed: TState,\n patch: Partial<TState> | undefined,\n): TState {\n if (!patch) {\n return seed;\n }\n\n return { ...seed, ...patch } as TState;\n}\n\n/**\n * Assemble the orchestrator-scope {@link OrchestratorReport} from the\n * dispatched turn's child report and the turn snapshot. Wraps the\n * child supervisor/agent report tree as `children[0]` (§15.6 —\n * `children[]` carries only the CURRENT turn's dispatched primitive\n * reports) while the per-turn forensic record lives on `turns[]`.\n */\nfunction buildReport(\n ctx: OrchestratorEngineContext,\n sessionId: string,\n turnIndex: number,\n status: OrchestratorReportStatus,\n turnSnapshot: TurnSnapshot | undefined,\n childReport: BaseReport | undefined,\n error?: AIError,\n): OrchestratorReport {\n const now = new Date().toISOString();\n const usage = turnSnapshot?.usage ?? childReport?.usage ?? ZERO_USAGE;\n\n return {\n runId: deriveRunId(sessionId, ctx.config.version, turnIndex),\n rootRunId: deriveRunId(sessionId, ctx.config.version, turnIndex),\n name: ctx.config.name,\n version: ctx.config.version,\n sessionId,\n type: \"orchestrator\",\n status,\n // Stamp the terminal error so the observe path surfaces it on the\n // orchestrator span (an observer never sees the result envelope).\n // Absent on a clean turn.\n ...(error ? { error } : {}),\n startedAt: turnSnapshot?.startedAt ?? now,\n endedAt: turnSnapshot?.endedAt ?? now,\n duration: turnSnapshot?.duration ?? 0,\n usage,\n children: childReport ? [childReport] : [],\n reportSchemaVersion: REPORT_SCHEMA_VERSION,\n turnIndex,\n signature: ctx.signature,\n turns: turnSnapshot ? [turnSnapshot] : [],\n };\n}\n\n/**\n * Map the dispatched supervisor result's report status onto the\n * orchestrator's status surface (§15.6). A clean completion that is\n * still mid-conversation reports `\"awaiting-input\"` (the session\n * continues) rather than `\"completed\"`; failures and cancellations\n * pass through.\n */\nfunction deriveStatus(childStatus: BaseReport[\"status\"]): OrchestratorReportStatus {\n if (childStatus === \"completed\") {\n return \"awaiting-input\";\n }\n\n return childStatus;\n}\n\n/**\n * Emit the terminal turn event matching the report status (§14.1).\n */\nfunction emitTerminal(\n ctx: OrchestratorEngineContext,\n sessionId: string,\n turnIndex: number,\n status: OrchestratorReportStatus,\n): void {\n if (status === \"cancelled\") {\n ctx.emitter.emit(\"orchestrator.turn.cancelled\", { sessionId, turnIndex });\n\n return;\n }\n\n if (status === \"failed\" || status === \"max-iterations\") {\n ctx.emitter.emit(\"orchestrator.turn.failed\", { sessionId, turnIndex });\n\n return;\n }\n\n if (status === \"awaiting-input\") {\n ctx.emitter.emit(\"orchestrator.turn.awaiting-input\", {\n sessionId,\n turnIndex,\n });\n\n return;\n }\n\n ctx.emitter.emit(\"orchestrator.turn.completed\", { sessionId, turnIndex });\n}\n\n/**\n * Run one turn end-to-end through the 7-phase lifecycle (orchestrator\n * .md §3). The single entry the C1 factory's `execute()` delegates to.\n *\n * Phase order is the diagram's contract: load → drift → lock → window\n * → dispatch → persist → compaction. Drift / config misuse throw;\n * every other failure surfaces on `result.error` (the contract: the\n * orchestrator never throws on runtime failure). Cancellation and\n * failure do NOT persist a fresh checkpoint (§17 — state reverts to the\n * pre-turn checkpoint).\n */\nexport async function runTurn<TOutput, TState>(\n ctx: OrchestratorEngineContext<TOutput, TState>,\n input: SupervisorInput,\n options: OrchestratorExecuteOptions<TState>,\n): Promise<OrchestratorResult<TOutput>> {\n const sessionId = options.sessionId;\n const disposePerCall = ctx.emitter.bindPerCall(options.on);\n\n try {\n // Phase 1 — load session.\n const loaded = await loadSession(ctx, sessionId);\n\n ctx.emitter.emit(\"orchestrator.turn.starting\", {\n sessionId,\n turnIndex: loaded.turnIndex,\n });\n\n ctx.emitter.emit(\"orchestrator.session.loaded\", {\n sessionId,\n turnIndex: loaded.turnIndex,\n found: loaded.found,\n });\n\n // Phase 2 — drift check.\n assertNoDrift(\n ctx as OrchestratorEngineContext,\n sessionId,\n loaded.record?.signature,\n options.force,\n );\n\n // Phase 3 — lock check (cooperative, fail-open).\n await acquireLock(ctx, sessionId, loaded.record);\n\n // Phase 4 — window history.\n const windowed = windowHistory(\n ctx as OrchestratorEngineContext,\n sessionId,\n options.history,\n );\n\n // Phase 5 — dispatch. When memory is configured, recall the\n // turn-relevant memories and inject them into the request-scoped\n // context bag so every route / router / evaluate / dispatch callback\n // surfaces them at `ctx.context[injectKey]` before routing runs.\n const seedState = applyStatePatch(loaded.state, options.state);\n\n let turnContext = options.context;\n\n if (ctx.memory) {\n const recalled = await recallForTurn(ctx.memory, input);\n turnContext = injectMemories(turnContext, ctx.memory, recalled);\n }\n\n const { result, state, turnSnapshot } = await dispatchTurn<TOutput, TState>({\n ctx,\n sessionId,\n input,\n seedState,\n turnIndex: loaded.turnIndex,\n history: windowed.agents,\n context: turnContext,\n signal: options.signal,\n });\n\n ctx.emitter.emit(\"orchestrator.turn.routed\", {\n sessionId,\n turnIndex: loaded.turnIndex,\n source: turnSnapshot.decision.source,\n raw: turnSnapshot.decision.raw,\n });\n\n const status = result.error\n ? deriveStatus(result.report.status)\n : \"awaiting-input\";\n\n // Cancelled / failed turns revert: no fresh checkpoint, no compaction.\n if (result.error) {\n const report = buildReport(\n ctx as OrchestratorEngineContext,\n sessionId,\n loaded.turnIndex,\n status,\n turnSnapshot,\n result.report,\n result.error,\n );\n\n emitTerminal(ctx as OrchestratorEngineContext, sessionId, loaded.turnIndex, status);\n\n return {\n data: result.data,\n error: result.error,\n usage: result.usage,\n report,\n sessionId,\n turnIndex: loaded.turnIndex,\n };\n }\n\n // Phase 6 — persist checkpoint.\n await persistCheckpoint({\n ctx,\n sessionId,\n turnIndex: loaded.turnIndex,\n state,\n lastRoute: summarizeRoute(turnSnapshot.decision.raw as never),\n summarizedThrough: loaded.record?.summarized_through ?? null,\n });\n\n // Memory write-back (memory core M2). The turn settled cleanly (the\n // `result.error` branch above already returned for cancelled /\n // failed turns, which revert and never remember — §17), so remember\n // the input + its outcome for later recall.\n if (ctx.memory) {\n await rememberTurnOutcome(\n ctx.memory,\n input,\n outcomeTextFromTurn(result.data, turnSnapshot),\n );\n }\n\n // Phase 7 — post-turn compaction (only when triggered).\n let compaction: CompactionResult | undefined;\n\n if (shouldCompact(ctx as OrchestratorEngineContext, loaded.turnIndex)) {\n const outcome = await runCompaction(\n ctx as OrchestratorEngineContext<unknown, TState>,\n sessionId,\n options.history,\n );\n\n if (outcome) {\n compaction = outcome.compaction;\n\n if (outcome.applied) {\n await advanceSummarizedThrough(\n ctx as OrchestratorEngineContext<unknown, TState>,\n sessionId,\n outcome.compaction.replacesToIndex,\n );\n }\n }\n }\n\n const report = buildReport(\n ctx as OrchestratorEngineContext,\n sessionId,\n loaded.turnIndex,\n \"awaiting-input\",\n turnSnapshot,\n result.report,\n );\n\n emitTerminal(ctx as OrchestratorEngineContext, sessionId, loaded.turnIndex, \"awaiting-input\");\n\n return {\n data: result.data,\n error: undefined,\n usage: result.usage,\n report,\n sessionId,\n turnIndex: loaded.turnIndex,\n compaction,\n };\n } finally {\n disposePerCall();\n }\n}\n\n/**\n * After a framework-applied compaction (`onCompact` succeeded), advance\n * the persisted `summarized_through` to the compaction's\n * `replacesToIndex` (§12.2 step 4). Re-saves the latest row with the\n * updated marker (append-only stores keep the prior row).\n */\nasync function advanceSummarizedThrough<TState>(\n ctx: OrchestratorEngineContext<unknown, TState>,\n sessionId: string,\n replacesToIndex: number,\n): Promise<void> {\n const latest = await ctx.checkpointStore.load(ctx.config.name, sessionId);\n\n if (!latest) {\n return;\n }\n\n await ctx.checkpointStore.save({\n ...latest,\n summarized_through: replacesToIndex,\n saved_at: new Date().toISOString(),\n });\n}\n\n/**\n * §9 resume protocol entry the C1 factory's `resume()` delegates to.\n * Returns `null` when no in-flight `iterate: true` turn is detected;\n * otherwise drains the interrupted supervisor run, persists a fresh\n * checkpoint for the resumed turn, and returns the completed result.\n *\n * Runs the same Phase 2 drift check as `runTurn` (§9.4). The heavy\n * lifting lives in `resume.ts`; this wrapper threads the engine\n * context.\n */\nexport async function runResume<TOutput, TState>(\n ctx: OrchestratorEngineContext<TOutput, TState>,\n sessionId: string,\n options?: OrchestratorResumeOptions,\n): Promise<OrchestratorResult<TOutput> | null> {\n const disposePerCall = ctx.emitter.bindPerCall(options?.on);\n\n try {\n return await resolveResume(ctx, sessionId, options, {\n assertNoDrift: (loadedSignature) =>\n assertNoDrift(\n ctx as OrchestratorEngineContext,\n sessionId,\n loadedSignature,\n options?.force,\n ),\n buildReport: (turnIndex, status, turnSnapshot, childReport) =>\n buildReport(\n ctx as OrchestratorEngineContext,\n sessionId,\n turnIndex,\n status,\n turnSnapshot,\n childReport,\n ),\n deriveStatus,\n emitTerminal: (turnIndex, status) =>\n emitTerminal(ctx as OrchestratorEngineContext, sessionId, turnIndex, status),\n persist: (turnIndex, state, lastRoute, summarizedThrough) =>\n persistCheckpoint({\n ctx,\n sessionId,\n turnIndex,\n state,\n lastRoute,\n summarizedThrough,\n }),\n });\n } finally {\n disposePerCall();\n }\n}\n\n/**\n * The `stream()` entry. The orchestrator's streaming surface bubbles\n * child agent/supervisor events under their own namespace (§14.2); the\n * C1 stream controller owns the `StreamContract` wiring. This engine\n * entry runs the same lifecycle as `runTurn` — the C1 factory passes a\n * per-call `on` bag wired to the stream controller, so the engine needs\n * no streaming-specific branch. Exposed as a distinct name for the\n * factory to call, returning the same `OrchestratorResult` the stream's\n * `.result` resolves to.\n */\nexport async function streamTurn<TOutput, TState>(\n ctx: OrchestratorEngineContext<TOutput, TState>,\n input: SupervisorInput,\n options: OrchestratorExecuteOptions<TState>,\n): Promise<OrchestratorResult<TOutput>> {\n return runTurn(ctx, input, options);\n}\n\nexport type { OrchestratorEngineContext } from \"./engine-context.type\";\nexport type { Message };\n"],"mappings":";;;;;;;;;;;;;;;;;;AAsDA,MAAM,aAAoB;CAAE,OAAO;CAAG,QAAQ;CAAG,OAAO;AAAE;;;;;;;;;;;;;;;;;;;;AA+C1D,IAAa,wBAAb,MAAoD;CAOlD,AAAO,YAAY,QAAsD;EACvE,KAAK,SAAS;EACd,KAAK,mBAAmB,OAAO;EAC/B,KAAK,MAAM;GACT,QAAQ,OAAO;GACf,WAAW,OAAO;GAClB,iBAAiB,uBAAuB,OAAO,MAAM;GACrD,eAAe,qBAAqB,OAAO,MAAM;GACjD,SAAS,aACP,OAAO,SACP,cAAc,cAAc,GAC5B,KAAK,gBAGP;GACA,QAAQ,0BAA0B,OAAO,OAAO,MAAM;EACxD;CACF;;;;;;;CAQA,MAAa,MAA4C;EACvD,IAAI,KAAK,OAAO,UAAU,UAAa,CAAC,KAAK,OAAO,SAClD,MAAM,IAAI,wBACR,oBAAoB,KAAK,OAAO,OAAO,KAAK,mDAC9C;EAGF,IAAI;GACF,MAAM,SAAS,MAAM,QACnB,KAAK,KACL,KAAK,OAAO,OACZ,KAAK,OAAO,OACd;GAKA,MAAM,gBAAgB,KAAK,IAAI,OAAO,SAAS,OAAO,MAAM;GAE5D,KAAK,kBAAkB,IAAI,MAAM;GAEjC,OAAO;EACT,SAAS,OAAO;GACd,KAAK,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7E,UAAU,WAAW,OAAO,WAAW,sBACrC,kBAAkB;IAChB;IACA;IACA;IACA;IACA;IACA;GACF,CAAC;EACL,CAAC;CACH,UAAU;EACR,eAAe;CACjB;AACF;;;;;;;;;;;AAYA,eAAsB,WACpB,KACA,OACA,SACsC;CACtC,OAAO,QAAQ,KAAK,OAAO,OAAO;AACpC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"load.mjs","names":[],"sources":["
|
|
1
|
+
{"version":3,"file":"load.mjs","names":[],"sources":["../../../../../../../ai/src/orchestrator/load.ts"],"sourcesContent":["import type { CheckpointRecord } from \"../contracts/orchestrator/checkpoint-store.contract\";\nimport type { OrchestratorEngineContext } from \"./engine-context.type\";\n\n/**\n * Outcome of Phase 1 — load session (orchestrator.md §4 Phase 1).\n *\n * `record` is the latest persisted checkpoint, or `undefined` for a\n * brand-new session. `state` is the starting accumulator the turn\n * mutates: the rehydrated `state` on a subsequent call, or the\n * `config.state ?? {}` seed on first call (the framework never\n * re-seeds from `config.state` once a session exists — §4 Phase 1).\n * `turnIndex` is the index of the turn ABOUT to run (loaded + 1, or 0\n * on first call). `previousTurnIndex` is the loaded value (or -1 when\n * none) — needed by resume's `runId` derivation (§9.1).\n */\nexport type LoadedSession<TState> = {\n /** Latest persisted checkpoint, or `undefined` for a new session. */\n record: CheckpointRecord | undefined;\n /** Whether a prior checkpoint existed (drives `session.loaded.found`). */\n found: boolean;\n /** Starting state accumulator for this turn. */\n state: TState;\n /** Index of the turn about to run. */\n turnIndex: number;\n /** Index of the last settled turn (-1 when the session is new). */\n previousTurnIndex: number;\n};\n\n/**\n * Deep-clone a JSON-serializable value so a rehydrated checkpoint's\n * `state` can be mutated by the turn without aliasing the stored row\n * (the in-memory store hands back live references). Mirrors the\n * round-trip semantics the design mandates for state (§5 — \"JSON-\n * serializable only\", `JSON.parse(JSON.stringify(...))`-equivalent).\n */\nfunction cloneState<TState>(state: unknown): TState {\n if (state === undefined || state === null) {\n return {} as TState;\n }\n\n return JSON.parse(JSON.stringify(state)) as TState;\n}\n\n/**\n * Phase 1 — load session. Reads the latest checkpoint for the session\n * and resolves the starting state accumulator + the turn index about\n * to run.\n *\n * First-call seeding (Q2): when no checkpoint exists this is the\n * session's birth — `state` defaults to `config.state ?? {}` and\n * `turnIndex` is 0. Subsequent calls rehydrate the persisted `state`\n * and advance the turn index. The dev-passed `options.history` is the\n * per-call seed (Path 2 — the framework never persists messages), so\n * load does not touch history.\n *\n * Does NOT apply the per-call `state` patch — that shallow-merges over\n * this result in the dispatch phase (§5), where the supervisor seed is\n * assembled.\n */\nexport async function loadSession<TState>(\n ctx: OrchestratorEngineContext<unknown, TState>,\n sessionId: string,\n): Promise<LoadedSession<TState>> {\n const record = await ctx.checkpointStore.load(ctx.config.name, sessionId);\n\n if (!record) {\n return {\n record: undefined,\n found: false,\n state: cloneState<TState>(ctx.config.state),\n turnIndex: 0,\n previousTurnIndex: -1,\n };\n }\n\n return {\n record,\n found: true,\n state: cloneState<TState>(record.state),\n turnIndex: record.turn_index + 1,\n previousTurnIndex: record.turn_index,\n };\n}\n"],"mappings":";;;;;;;;AAmCA,SAAS,WAAmB,OAAwB;CAClD,IAAI,UAAU,UAAa,UAAU,MACnC,OAAO,CAAC;CAGV,OAAO,KAAK,MAAM,KAAK,UAAU,KAAK,CAAC;AACzC;;;;;;;;;;;;;;;;;AAkBA,eAAsB,YACpB,KACA,WACgC;CAChC,MAAM,SAAS,MAAM,IAAI,gBAAgB,KAAK,IAAI,OAAO,MAAM,SAAS;CAExE,IAAI,CAAC,QACH,OAAO;EACL,QAAQ;EACR,OAAO;EACP,OAAO,WAAmB,IAAI,OAAO,KAAK;EAC1C,WAAW;EACX,mBAAmB;CACrB;CAGF,OAAO;EACL;EACA,OAAO;EACP,OAAO,WAAmB,OAAO,KAAK;EACtC,WAAW,OAAO,aAAa;EAC/B,mBAAmB,OAAO;CAC5B;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lock.mjs","names":[],"sources":["
|
|
1
|
+
{"version":3,"file":"lock.mjs","names":[],"sources":["../../../../../../../ai/src/orchestrator/lock.ts"],"sourcesContent":["import type { CheckpointRecord } from \"../contracts/orchestrator/checkpoint-store.contract\";\nimport type { SummarizeConfig } from \"../contracts/orchestrator/orchestrator-config.type\";\nimport type { OrchestratorEngineContext } from \"./engine-context.type\";\n\n/** Framework default for the compaction-lock wait, in ms (§3 / §12.3). */\nexport const DEFAULT_LOCK_MAX_WAIT = 30_000;\n\n/** Poll interval while waiting on a held lock, in ms. */\nconst LOCK_POLL_INTERVAL = 100;\n\n/**\n * Resolve the configured `summarize.lock.maxWait`, falling back to the\n * framework default. The callback form of `summarize` carries no lock\n * config, so it uses the default.\n */\nfunction resolveMaxWait(ctx: OrchestratorEngineContext): number {\n const summarize = ctx.config.summarize;\n\n if (typeof summarize === \"function\" || summarize === undefined) {\n return DEFAULT_LOCK_MAX_WAIT;\n }\n\n return (summarize as SummarizeConfig).lock?.maxWait ?? DEFAULT_LOCK_MAX_WAIT;\n}\n\n/** Whether a checkpoint's lock is still held relative to `now`. */\nfunction isLocked(record: CheckpointRecord, now: number): boolean {\n if (!record.lock_expires_at) {\n return false;\n }\n\n const expiresAt = Date.parse(record.lock_expires_at);\n\n return Number.isFinite(expiresAt) && expiresAt > now;\n}\n\n/**\n * Outcome of Phase 3. `waited` is true when the turn observed a held\n * lock and spent time waiting; `waitedMs` is how long. `failedOpen` is\n * true when the wait timed out and the turn proceeds without the lock\n * (orchestrator.md §3 / §12.3 — a stuck summarizer must never block a\n * session forever).\n */\nexport type LockOutcome = {\n waited: boolean;\n waitedMs: number;\n failedOpen: boolean;\n};\n\n/**\n * Phase 3 — lock check (orchestrator.md §3 / §4 Phase 3). The loaded\n * checkpoint may carry a compaction lock written by a prior turn's\n * Phase 7 (or by `command(\"compact\")`). When the lock is still live,\n * wait up to `summarize.lock.maxWait` (default 30s), re-loading the\n * latest checkpoint each poll, then **fail open** — proceed without\n * the lock.\n *\n * Emits `orchestrator.lock.waiting` once, only when a held lock is\n * observed (§14.1 — \"only when locked\"). The dispatch then runs\n * against whatever state was written before the lock was taken (§3).\n *\n * A new session (`loaded === undefined`) is never locked, so this\n * returns immediately.\n */\nexport async function acquireLock<TState>(\n ctx: OrchestratorEngineContext<unknown, TState>,\n sessionId: string,\n loaded: CheckpointRecord | undefined,\n): Promise<LockOutcome> {\n if (!loaded || !isLocked(loaded, Date.now())) {\n return { waited: false, waitedMs: 0, failedOpen: false };\n }\n\n const maxWait = resolveMaxWait(ctx as OrchestratorEngineContext);\n const startedAt = Date.now();\n\n ctx.emitter.emit(\"orchestrator.lock.waiting\", { sessionId, waitedMs: 0 });\n\n let latest: CheckpointRecord | undefined = loaded;\n\n while (latest && isLocked(latest, Date.now())) {\n const waitedMs = Date.now() - startedAt;\n\n if (waitedMs >= maxWait) {\n return { waited: true, waitedMs, failedOpen: true };\n }\n\n await delay(Math.min(LOCK_POLL_INTERVAL, maxWait - waitedMs));\n\n latest = await ctx.checkpointStore.load(ctx.config.name, sessionId);\n }\n\n return { waited: true, waitedMs: Date.now() - startedAt, failedOpen: false };\n}\n\n/** Promise-based sleep used by the cooperative wait loop. */\nfunction delay(ms: number): Promise<void> {\n return new Promise((resolve) => {\n setTimeout(resolve, ms);\n });\n}\n"],"mappings":";;AAKA,MAAa,wBAAwB;;AAGrC,MAAM,qBAAqB;;;;;;AAO3B,SAAS,eAAe,KAAwC;CAC9D,MAAM,YAAY,IAAI,OAAO;CAE7B,IAAI,OAAO,cAAc,cAAc,cAAc,QACnD,OAAO;CAGT,OAAQ,UAA8B,MAAM;AAC9C;;AAGA,SAAS,SAAS,QAA0B,KAAsB;CAChE,IAAI,CAAC,OAAO,iBACV,OAAO;CAGT,MAAM,YAAY,KAAK,MAAM,OAAO,eAAe;CAEnD,OAAO,OAAO,SAAS,SAAS,KAAK,YAAY;AACnD;;;;;;;;;;;;;;;;AA8BA,eAAsB,YACpB,KACA,WACA,QACsB;CACtB,IAAI,CAAC,UAAU,CAAC,SAAS,QAAQ,KAAK,IAAI,CAAC,GACzC,OAAO;EAAE,QAAQ;EAAO,UAAU;EAAG,YAAY;CAAM;CAGzD,MAAM,UAAU,eAAe,GAAgC;CAC/D,MAAM,YAAY,KAAK,IAAI;CAE3B,IAAI,QAAQ,KAAK,6BAA6B;EAAE;EAAW,UAAU;CAAE,CAAC;CAExE,IAAI,SAAuC;CAE3C,OAAO,UAAU,SAAS,QAAQ,KAAK,IAAI,CAAC,GAAG;EAC7C,MAAM,WAAW,KAAK,IAAI,IAAI;EAE9B,IAAI,YAAY,SACd,OAAO;GAAE,QAAQ;GAAM;GAAU,YAAY;EAAK;EAGpD,MAAM,MAAM,KAAK,IAAI,oBAAoB,UAAU,QAAQ,CAAC;EAE5D,SAAS,MAAM,IAAI,gBAAgB,KAAK,IAAI,OAAO,MAAM,SAAS;CACpE;CAEA,OAAO;EAAE,QAAQ;EAAM,UAAU,KAAK,IAAI,IAAI;EAAW,YAAY;CAAM;AAC7E;;AAGA,SAAS,MAAM,IAA2B;CACxC,OAAO,IAAI,SAAS,YAAY;EAC9B,WAAW,SAAS,EAAE;CACxB,CAAC;AACH"}
|
|
@@ -4,7 +4,7 @@ import { RecalledMemory } from "../contracts/memory/memory-item.type.mjs";
|
|
|
4
4
|
import { MemoryContract } from "../contracts/memory/memory.contract.mjs";
|
|
5
5
|
import { OrchestratorMemoryConfig } from "../contracts/orchestrator/orchestrator-config.type.mjs";
|
|
6
6
|
|
|
7
|
-
//#region
|
|
7
|
+
//#region ../ai/src/orchestrator/memory.d.ts
|
|
8
8
|
/**
|
|
9
9
|
* Memory wiring resolved once per turn from `OrchestratorConfig.memory`
|
|
10
10
|
* (memory core M2). Normalizes the two accepted config shapes — a bare
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"memory.d.mts","names":[],"sources":["
|
|
1
|
+
{"version":3,"file":"memory.d.mts","names":[],"sources":["../../../../../../../ai/src/orchestrator/memory.ts"],"mappings":";;;;;;;;;AAmBA;;;;;KAAY,0BAAA;EAYiB,yEAV3B,KAAA,EAAO,cAAA,EAAP;EAEA,CAAA;EAEA,SAAA,WAEA;EAAA,IAAA,GAAO,YAAA,EAEP;EAAA,QAAA,WAEe;EAAf,YAAA,GAAe,YAAA,EAEN;EAAT,SAAA;AAAA;AAAA,KAGG,YAAA,GAAe,WAAW,CAAC,wBAAA;;;AAAwB;AAoBxD;;;iBAAgB,yBAAA,CACd,MAAA,EAAQ,cAAA,GAAiB,wBAAA,eACxB,0BAAA;;;;;;;;iBA+Ba,oBAAA,CAAqB,KAAsB,EAAf,eAAe;;AA/B9B;AA+B7B;;;;AAA2D;AAY3D;iBAAsB,aAAA,CACpB,MAAA,EAAQ,0BAAA,EACR,KAAA,EAAO,eAAA,GACN,OAAA,CAAQ,cAAA;;;;;;;;;;;;;iBAwBK,cAAA,CACd,OAAA,EAAS,MAAA,+BACT,MAAA,EAAQ,0BAAA,EACR,QAAA,EAAU,cAAA,KACT,MAAA;;AA5BsB;AAwBzB;;;;;;;;iBAsBsB,mBAAA,CACpB,MAAA,EAAQ,0BAAA,EACR,KAAA,EAAO,eAAA,EACP,WAAA,uBACC,OAAA;;;;;;;;;iBA4Ca,mBAAA,CACd,IAAA,WACA,YAAA,EAAc,YAAY"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"memory.mjs","names":[],"sources":["
|
|
1
|
+
{"version":3,"file":"memory.mjs","names":[],"sources":["../../../../../../../ai/src/orchestrator/memory.ts"],"sourcesContent":["import type { MemoryContract } from \"../contracts/memory/memory.contract\";\nimport type {\n MemoryItem,\n RecalledMemory,\n} from \"../contracts/memory/memory-item.type\";\nimport type { OrchestratorMemoryConfig } from \"../contracts/orchestrator/orchestrator-config.type\";\nimport type { TurnSnapshot } from \"../contracts/result/orchestrator-result.type\";\nimport type { SupervisorInput } from \"../contracts/supervisor/supervisor-input.type\";\n\n/** Default key the recalled memories are injected under in the context bag. */\nconst DEFAULT_INJECT_KEY = \"memories\";\n\n/**\n * Memory wiring resolved once per turn from `OrchestratorConfig.memory`\n * (memory core M2). Normalizes the two accepted config shapes — a bare\n * {@link MemoryContract} or the richer {@link OrchestratorMemoryConfig} —\n * into a single flat record the lifecycle phase reads, so `runTurn` never\n * branches on which form the dev supplied.\n */\nexport type ResolvedOrchestratorMemory = {\n /** The store recalled-from before dispatch and remembered-into after. */\n store: MemoryContract;\n /** Recall count cap; `0` disables recall (write-only memory). */\n k?: number;\n /** Semantic-similarity floor for recall. */\n threshold?: number;\n /** Single-tier recall restriction. */\n tier?: ResolvedTier;\n /** Whether a clean turn writes its outcome back. Default `true`. */\n remember: boolean;\n /** Tier the remembered outcome lands in. Omit for the memory's `defaultTier`. */\n rememberTier?: ResolvedTier;\n /** Context-bag key the recalled memories are injected under. */\n injectKey: string;\n};\n\ntype ResolvedTier = NonNullable<OrchestratorMemoryConfig[\"recall\"]>[\"tier\"];\n\n/**\n * A `MemoryContract` is the bare-store form; anything carrying a `store`\n * is the {@link OrchestratorMemoryConfig} wrapper. Distinguished by the\n * presence of `recall` — a method on the contract, absent on the config\n * (whose own `recall` is a plain options object, never a function).\n */\nfunction isBareMemory(\n value: MemoryContract | OrchestratorMemoryConfig,\n): value is MemoryContract {\n return typeof (value as MemoryContract).recall === \"function\";\n}\n\n/**\n * Normalize `OrchestratorConfig.memory` into {@link ResolvedOrchestratorMemory},\n * or `undefined` when no memory is configured. Centralizes the\n * bare-store-vs-config distinction so the engine context carries one\n * shape and the lifecycle phase stays branch-free.\n */\nexport function resolveOrchestratorMemory(\n memory: MemoryContract | OrchestratorMemoryConfig | undefined,\n): ResolvedOrchestratorMemory | undefined {\n if (!memory) {\n return undefined;\n }\n\n if (isBareMemory(memory)) {\n return {\n store: memory,\n remember: true,\n injectKey: DEFAULT_INJECT_KEY,\n };\n }\n\n return {\n store: memory.store,\n k: memory.recall?.k,\n threshold: memory.recall?.threshold,\n tier: memory.recall?.tier,\n remember: memory.remember ?? true,\n rememberTier: memory.rememberTier,\n injectKey: memory.injectKey ?? DEFAULT_INJECT_KEY,\n };\n}\n\n/**\n * Coerce a turn's {@link SupervisorInput} (string or structured object)\n * into the natural-language query the memory store recalls / embeds\n * against. Strings pass through; objects are JSON-serialized — the same\n * coercion the supervisor applies when forwarding an object input to a\n * child agent without an explicit `input(ctx)` override.\n */\nexport function memoryQueryFromInput(input: SupervisorInput): string {\n return typeof input === \"string\" ? input : JSON.stringify(input);\n}\n\n/**\n * Recall the memories relevant to a turn's input (memory core M2 — the\n * pre-dispatch half). Returns the scored {@link RecalledMemory}[] the\n * lifecycle injects into the turn's `context` bag under\n * `memory.injectKey`. Returns an empty array — never throws on \"no hits\"\n * — and short-circuits when `k === 0` (recall disabled / write-only\n * memory) so a write-only config never round-trips the embedder.\n */\nexport async function recallForTurn(\n memory: ResolvedOrchestratorMemory,\n input: SupervisorInput,\n): Promise<RecalledMemory[]> {\n if (memory.k === 0) {\n return [];\n }\n\n return memory.store.recall(memoryQueryFromInput(input), {\n k: memory.k,\n threshold: memory.threshold,\n tier: memory.tier,\n });\n}\n\n/**\n * Merge the recalled memories into a fresh per-turn context bag under\n * `memory.injectKey` (memory core M2 — the injection half). Never\n * mutates the caller's `context` object — returns a new bag (or the\n * original when there is nothing to inject) so the request-scoped input\n * stays immutable, and the supervisor's intake (which freezes a\n * shallow copy) sees the recalled set on every `ctx.context[injectKey]`.\n *\n * A pre-existing value at `injectKey` is preserved when recall produced\n * nothing, and overwritten with the recalled set otherwise — the\n * orchestrator owns that key once memory is configured.\n */\nexport function injectMemories(\n context: Record<string, unknown> | undefined,\n memory: ResolvedOrchestratorMemory,\n recalled: RecalledMemory[],\n): Record<string, unknown> | undefined {\n if (recalled.length === 0) {\n return context;\n }\n\n return { ...(context ?? {}), [memory.injectKey]: recalled };\n}\n\n/**\n * Remember a settled turn's outcome (memory core M2 — the post-dispatch\n * half). Called only after a clean turn (cancelled / failed turns revert\n * and never remember — §17). No-ops when `remember` is `false`\n * (read-only memory) or when the produced text is empty.\n *\n * The remembered text is the turn input followed by the model's textual\n * outcome when one is available, so a later `recall` keyed on a similar\n * input surfaces both the prior question and its answer.\n */\nexport async function rememberTurnOutcome(\n memory: ResolvedOrchestratorMemory,\n input: SupervisorInput,\n outcomeText: string | undefined,\n): Promise<void> {\n if (!memory.remember) {\n return;\n }\n\n const text = buildOutcomeText(input, outcomeText);\n\n if (!text) {\n return;\n }\n\n const item: MemoryItem = { text, tier: memory.rememberTier };\n\n await memory.store.remember(item);\n}\n\n/**\n * Compose the text written to memory for a turn: the input query, plus\n * the outcome text on a following line when the dispatch produced one.\n * Returns `undefined` when neither side carries content so an empty turn\n * never pollutes the store.\n */\nfunction buildOutcomeText(\n input: SupervisorInput,\n outcomeText: string | undefined,\n): string | undefined {\n const query = memoryQueryFromInput(input).trim();\n const outcome = outcomeText?.trim();\n\n if (query && outcome) {\n return `${query}\\n${outcome}`;\n }\n\n return query || outcome || undefined;\n}\n\n/**\n * Derive a turn's textual outcome for remembering (memory core M2).\n * Prefers the validated `result.data` (an `output` schema reshaped it);\n * otherwise stringifies the dispatched intents' branch outputs from the\n * turn snapshot, joined newline-wise so a multi-branch fan-out\n * contributes every output. Returns `undefined` when the turn produced\n * no usable text — the caller then remembers the input alone.\n */\nexport function outcomeTextFromTurn(\n data: unknown,\n turnSnapshot: TurnSnapshot,\n): string | undefined {\n const fromData = stringifyOutcome(data);\n\n if (fromData) {\n return fromData;\n }\n\n const outputs = Object.values(turnSnapshot.result)\n .map((branch) => stringifyOutcome(branch.output))\n .filter((text): text is string => Boolean(text));\n\n return outputs.length > 0 ? outputs.join(\"\\n\") : undefined;\n}\n\n/**\n * Coerce one outcome value to text: strings pass through; everything\n * else (objects, numbers) is JSON-serialized. `undefined` / `null` and\n * empty strings collapse to `undefined` so they don't masquerade as\n * content.\n */\nfunction stringifyOutcome(value: unknown): string | undefined {\n if (value === undefined || value === null) {\n return undefined;\n }\n\n const text = typeof value === \"string\" ? value : JSON.stringify(value);\n\n return text.trim() ? text : undefined;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SAAS,SACX,OAAO,GAAG,MAAM,IAAI;CAGtB,OAAO,SAAS,WAAW;AAC7B;;;;;;;;;AAUA,SAAgB,oBACd,MACA,cACoB;CACpB,MAAM,WAAW,iBAAiB,IAAI;CAEtC,IAAI,UACF,OAAO;CAGT,MAAM,UAAU,OAAO,OAAO,aAAa,MAAM,CAAC,CAC/C,KAAK,WAAW,iBAAiB,OAAO,MAAM,CAAC,CAAC,CAChD,QAAQ,SAAyB,QAAQ,IAAI,CAAC;CAEjD,OAAO,QAAQ,SAAS,IAAI,QAAQ,KAAK,IAAI,IAAI;AACnD;;;;;;;AAQA,SAAS,iBAAiB,OAAoC;CAC5D,IAAI,UAAU,UAAa,UAAU,MACnC;CAGF,MAAM,OAAO,OAAO,UAAU,WAAW,QAAQ,KAAK,UAAU,KAAK;CAErE,OAAO,KAAK,KAAK,IAAI,OAAO;AAC9B"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { StreamContract } from "../contracts/stream/stream.contract.mjs";
|
|
2
2
|
import { OrchestratorEvent } from "../contracts/orchestrator/orchestrator-event.type.mjs";
|
|
3
3
|
|
|
4
|
-
//#region
|
|
4
|
+
//#region ../ai/src/orchestrator/orchestrator-stream.d.ts
|
|
5
5
|
/**
|
|
6
6
|
* Internal async-queue controller driving `orchestrator.stream()`.
|
|
7
7
|
* Mirrors {@link import("../supervisor/supervisor-stream").createSupervisorStream}'s
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"orchestrator-stream.d.mts","names":[],"sources":["
|
|
1
|
+
{"version":3,"file":"orchestrator-stream.d.mts","names":[],"sources":["../../../../../../../ai/src/orchestrator/orchestrator-stream.ts"],"mappings":";;;;;;AAaA;;;;;;;;KAAY,4BAAA;EACV,IAAA,CAAK,KAAA,EAAO,iBAAA;EACZ,GAAA,CAAI,MAAA,EAAQ,OAAA;EACZ,IAAA,CAAK,KAAA,EAAO,KAAA;AAAA;;;;;;;AAAK;AAwBnB;;;;;;;;;iBAAgB,wBAAA;EACd,UAAA,EAAY,4BAAA,CAA6B,OAAA;EACzC,MAAA,EAAQ,cAAA,CAAe,OAAA,EAAS,iBAAA;AAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"orchestrator-stream.mjs","names":[],"sources":["
|
|
1
|
+
{"version":3,"file":"orchestrator-stream.mjs","names":[],"sources":["../../../../../../../ai/src/orchestrator/orchestrator-stream.ts"],"sourcesContent":["import type { OrchestratorEvent } from \"../contracts/orchestrator/orchestrator-event.type\";\nimport type { StreamContract } from \"../contracts/stream/stream.contract\";\n\n/**\n * Internal async-queue controller driving `orchestrator.stream()`.\n * Mirrors {@link import(\"../supervisor/supervisor-stream\").createSupervisorStream}'s\n * controller — same producer/consumer pipe, parameterized by the\n * orchestrator event union and the terminal result type.\n *\n * The turn pushes events as it advances through the lifecycle phases,\n * then settles with `end(result)` (the same `OrchestratorResult` that\n * `execute()` resolves) or `fail(error)` on an authoring/drift throw.\n */\nexport type OrchestratorStreamController<TResult> = {\n push(event: OrchestratorEvent): void;\n end(result: TResult): void;\n fail(error: Error): void;\n};\n\ntype PendingRead = {\n resolve(value: IteratorResult<OrchestratorEvent>): void;\n reject(error: Error): void;\n};\n\n/**\n * Factory mirroring `createSupervisorStream`. Returns a paired\n * `{ controller, stream }` — the turn pushes events into the controller\n * while the caller iterates (or awaits `.result`) on the stream side.\n *\n * The `result` promise resolves to the same `OrchestratorResult` value\n * `execute()` produces; it rejects only when the turn throws before\n * producing a result (drift / config misuse) — runtime failures ride on\n * `result.error` and still settle via `end()`.\n *\n * Child `supervisor.*` / `agent.*` events bubble through this same pipe\n * unmodified (the turn forwards them as it observes them on the\n * delegated run); they share the `{ type, ...payload }` shape with the\n * orchestrator's own events so iteration narrows uniformly on\n * `event.type`.\n */\nexport function createOrchestratorStream<TResult>(): {\n controller: OrchestratorStreamController<TResult>;\n stream: StreamContract<TResult, OrchestratorEvent>;\n} {\n const queue: OrchestratorEvent[] = [];\n const pending: PendingRead[] = [];\n const handlers = new Map<string, (event: OrchestratorEvent) => void>();\n\n let closed = false;\n let failure: Error | undefined;\n let resolveResult!: (value: TResult) => void;\n let rejectResult!: (error: Error) => void;\n\n const result = new Promise<TResult>((resolve, reject) => {\n resolveResult = resolve;\n rejectResult = reject;\n });\n\n const controller: OrchestratorStreamController<TResult> = {\n push(event) {\n const handler = handlers.get(event.type);\n\n if (handler) {\n try {\n handler(event);\n } catch {\n // Stream handlers must never crash the orchestrator.\n }\n }\n\n const reader = pending.shift();\n\n if (reader) {\n reader.resolve({ value: event, done: false });\n return;\n }\n\n queue.push(event);\n },\n\n end(finalResult) {\n closed = true;\n resolveResult(finalResult);\n\n while (pending.length > 0) {\n pending.shift()?.resolve({ value: undefined, done: true });\n }\n },\n\n fail(error) {\n closed = true;\n failure = error;\n rejectResult(error);\n\n while (pending.length > 0) {\n pending.shift()?.reject(error);\n }\n },\n };\n\n const iterator: AsyncIterator<OrchestratorEvent> = {\n next() {\n if (queue.length > 0) {\n return Promise.resolve({ value: queue.shift()!, done: false });\n }\n\n if (closed) {\n if (failure) {\n return Promise.reject(failure);\n }\n\n return Promise.resolve({ value: undefined, done: true });\n }\n\n return new Promise<IteratorResult<OrchestratorEvent>>(\n (resolve, reject) => {\n pending.push({ resolve, reject });\n },\n );\n },\n };\n\n const stream = {\n result,\n on(handlerMap) {\n for (const [key, handler] of Object.entries(handlerMap)) {\n if (handler) {\n handlers.set(key, handler as (event: OrchestratorEvent) => void);\n }\n }\n\n return stream;\n },\n [Symbol.asyncIterator]() {\n return iterator;\n },\n } as StreamContract<TResult, OrchestratorEvent>;\n\n return { controller, stream };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAwCA,SAAgB,2BAGd;CACA,MAAM,QAA6B,CAAC;CACpC,MAAM,UAAyB,CAAC;CAChC,MAAM,2BAAW,IAAI,IAAgD;CAErE,IAAI,SAAS;CACb,IAAI;CACJ,IAAI;CACJ,IAAI;CAEJ,MAAM,SAAS,IAAI,SAAkB,SAAS,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+2,7 @@ import { SupervisorIntentValue } from "../contracts/supervisor/intent-entry.type
|
|
|
2
2
|
import { OrchestratorContract } from "../contracts/orchestrator/orchestrator.contract.mjs";
|
|
3
3
|
import { OrchestratorConfig } from "../contracts/orchestrator/orchestrator-config.type.mjs";
|
|
4
4
|
|
|
5
|
-
//#region
|
|
5
|
+
//#region ../ai/src/orchestrator/orchestrator.d.ts
|
|
6
6
|
/**
|
|
7
7
|
* `ai.orchestrator(config)` — construct an {@link OrchestratorContract}:
|
|
8
8
|
* a session-state manager wrapped around a supervisor (orchestrator.md
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"orchestrator.d.mts","names":[],"sources":["
|
|
1
|
+
{"version":3,"file":"orchestrator.d.mts","names":[],"sources":["../../../../../../../ai/src/orchestrator/orchestrator.ts"],"mappings":";;;;;;;AA8DA;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAAgB,YAAA,6BAEL,OAAA,mBACQ,MAAA,SAAe,qBAAA,IAAyB,MAAA,SAEvD,qBAAA,GAGF,MAAA,EAAQ,kBAAA,CAAmB,OAAA,EAAS,MAAA,EAAQ,QAAA,IAC3C,oBAAA,CAAqB,OAAA,EAAS,MAAA"}
|
|
@@ -11,7 +11,7 @@ import { createOrchestratorStream } from "./orchestrator-stream.mjs";
|
|
|
11
11
|
import { inProcessSessionLock, noopSessionLock } from "./session-lock.mjs";
|
|
12
12
|
import { computeOrchestratorSignature } from "./signature.mjs";
|
|
13
13
|
|
|
14
|
-
//#region
|
|
14
|
+
//#region ../ai/src/orchestrator/orchestrator.ts
|
|
15
15
|
/**
|
|
16
16
|
* `ai.orchestrator(config)` — construct an {@link OrchestratorContract}:
|
|
17
17
|
* a session-state manager wrapped around a supervisor (orchestrator.md
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"orchestrator.mjs","names":["orchestratorAsTool"],"sources":["../../../../../../../@warlock.js/ai/src/orchestrator/orchestrator.ts"],"sourcesContent":["import type { OrchestratorConfig } from \"../contracts/orchestrator/orchestrator-config.type\";\nimport type {\n OrchestratorEventHandler,\n OrchestratorEventName,\n} from \"../contracts/orchestrator/orchestrator-event.type\";\nimport type {\n OrchestratorAsToolOptions,\n OrchestratorContract,\n} from \"../contracts/orchestrator/orchestrator.contract\";\nimport type { OrchestratorCommands } from \"../contracts/orchestrator/orchestrator-commands.type\";\nimport type {\n OrchestratorExecuteOptions,\n OrchestratorResumeOptions,\n} from \"../contracts/orchestrator/orchestrator-execute-options.type\";\nimport type { OrchestratorEvent } from \"../contracts/orchestrator/orchestrator-event.type\";\nimport type { OrchestratorResult } from \"../contracts/result/orchestrator-result.type\";\nimport type { StreamContract } from \"../contracts/stream/stream.contract\";\nimport type { SupervisorIntentValue } from \"../contracts/supervisor/intent-entry.type\";\nimport type { SupervisorInput } from \"../contracts/supervisor/supervisor-input.type\";\nimport { resolveDefaultSnapshotStore } from \"../config\";\nimport { OrchestratorConfigError } from \"../errors/orchestrator-config-error\";\nimport { resolveIntentEntries, type ResolvedIntentEntry } from \"../supervisor/entries\";\nimport { SupervisorFailedError } from \"../errors\";\nimport type { ToolContract } from \"../tool/tool\";\nimport type { SessionLock } from \"../contracts/orchestrator/session-lock.contract\";\nimport { asTool as orchestratorAsTool } from \"./as-tool\";\nimport { createCommandDispatcher } from \"./commands\";\nimport { OrchestratorEmitter } from \"./emitter\";\nimport { OrchestratorExecution } from \"./execution\";\nimport { createOrchestratorStream } from \"./orchestrator-stream\";\nimport { inProcessSessionLock, noopSessionLock } from \"./session-lock\";\nimport { computeOrchestratorSignature } from \"./signature\";\n\n/**\n * `ai.orchestrator(config)` — construct an {@link OrchestratorContract}:\n * a session-state manager wrapped around a supervisor (orchestrator.md\n * §1, §15). Validates the config at author time (throws\n * {@link OrchestratorConfigError} on bad shape), resolves the intent\n * entries, computes a stable structural signature for drift detection\n * (§10.1), wires the three-tier event emitter, and returns a handle that\n * runs one durable session turn per `execute` / `stream` call, resumes\n * an interrupted `iterate: true` turn via `resume`, and exposes typed\n * built-in commands plus an `asTool` wrapper.\n *\n * The \"what runs\" fields (`intents`, `route` / `router`, `evaluate`,\n * `state`, `output`, `initialAgent`, `maxIterations`) are the\n * supervisor's surface spread directly — the lifecycle builds the\n * supervisor lazily per turn and delegates to it (§3 Phase 5). Users\n * never see the supervisor object.\n *\n * @example\n * const supportBot = ai.orchestrator<SessionState>({\n * name: \"refund-support\",\n * intents: { classify, lookup, process, compose },\n * route: (ctx) => (ctx.iteration === 0 ? \"classify\" : END),\n * iterate: true,\n * checkpointStore: ai.checkpoint.pg({ client: pg }),\n * snapshotStore: ai.snapshot.pg({ client: pg }),\n * });\n *\n * const result = await supportBot.execute(message, { sessionId, history });\n */\nexport function orchestrator<\n TOutput = unknown,\n TState = TOutput,\n TIntents extends Record<string, SupervisorIntentValue> = Record<\n string,\n SupervisorIntentValue\n >,\n>(\n config: OrchestratorConfig<TOutput, TState, TIntents>,\n): OrchestratorContract<TOutput, TState> {\n validateFactoryConfig(config as unknown as OrchestratorConfig<unknown>);\n\n const entries = resolveEntries(config as unknown as OrchestratorConfig<unknown>);\n\n assertInitialAgent(config as unknown as OrchestratorConfig<unknown>, entries);\n\n const signature = computeOrchestratorSignature(\n config as unknown as OrchestratorConfig<unknown>,\n entries,\n );\n const emitter = new OrchestratorEmitter(config.on);\n\n // Per-session turn serialization (C4). Resolved ONCE so every turn on\n // this orchestrator shares the same lock — that's what lets the\n // in-process default actually serialize concurrent same-session calls.\n const sessionLock = resolveSessionLock(config as unknown as OrchestratorConfig<unknown>);\n warnOnUnlockedDurableStore(config as unknown as OrchestratorConfig<unknown>);\n\n async function execute(\n input: SupervisorInput,\n options: OrchestratorExecuteOptions<TState>,\n ): Promise<OrchestratorResult<TOutput>> {\n const execution = new OrchestratorExecution<TOutput, TState>({\n config: config as unknown as OrchestratorConfig<TOutput, TState>,\n entries,\n signature,\n emitter,\n input,\n options,\n });\n\n // Serialize the whole turn (load → dispatch → persist) against any\n // concurrent turn for the same session, so the checkpoint's\n // read-modify-write can't lose an update.\n return sessionLock.withLock(options.sessionId, () => execution.run(), {\n signal: options.signal,\n });\n }\n\n function stream(\n input: SupervisorInput,\n options: OrchestratorExecuteOptions<TState>,\n ): StreamContract<OrchestratorResult<TOutput>, OrchestratorEvent> {\n const { controller, stream: contract } = createOrchestratorStream<\n OrchestratorResult<TOutput>\n >();\n\n const execution = new OrchestratorExecution<TOutput, TState>({\n config: config as unknown as OrchestratorConfig<TOutput, TState>,\n entries,\n signature,\n emitter,\n input,\n options,\n streamController: controller,\n });\n\n // The background run waits for the session lock before it starts —\n // same serialization guarantee as `execute`; the stream contract is\n // still returned synchronously.\n void sessionLock.withLock(options.sessionId, () => execution.run(), {\n signal: options.signal,\n });\n\n return contract;\n }\n\n async function resume(\n sessionId: string,\n options?: OrchestratorResumeOptions,\n ): Promise<OrchestratorResult<TOutput> | null> {\n const execution = new OrchestratorExecution<TOutput, TState>({\n config: config as unknown as OrchestratorConfig<TOutput, TState>,\n entries,\n signature,\n emitter,\n resumeSessionId: sessionId,\n resumeOptions: options,\n });\n\n return sessionLock.withLock(sessionId, () => execution.resume(), {\n signal: options?.signal,\n });\n }\n\n // The dispatcher owns command ROUTING only; the `compact` handler\n // delegates to the shared compaction code path on the lifecycle engine\n // (§11 / §12.2 — manual compact reuses the post-turn compaction path).\n const command = createCommandDispatcher({\n compact: (args: OrchestratorCommands[\"compact\"][\"args\"]) => {\n const execution = new OrchestratorExecution<TOutput, TState>({\n config: config as unknown as OrchestratorConfig<TOutput, TState>,\n entries,\n signature,\n emitter,\n });\n\n return execution.compact(args);\n },\n });\n\n const instance: OrchestratorContract<TOutput, TState> = {\n name: config.name,\n signature,\n version: config.version,\n execute,\n stream,\n resume,\n command,\n asTool<TToolInput = string>(\n options: OrchestratorAsToolOptions<TToolInput>,\n ): ToolContract<TToolInput, TOutput> {\n return orchestratorAsTool<TOutput, TState, TToolInput>(instance, options);\n },\n on<K extends OrchestratorEventName>(\n event: K,\n handler: OrchestratorEventHandler<K>,\n ): () => void {\n return emitter.on(event, handler);\n },\n off<K extends OrchestratorEventName>(\n event: K,\n handler: OrchestratorEventHandler<K>,\n ): void {\n emitter.off(event, handler);\n },\n };\n\n return instance;\n}\n\n/**\n * Author-time validation (orchestrator.md §17). Enforces the rules that\n * must fail at construction rather than on the first turn:\n *\n * - `name` present and a string.\n * - `intents` present.\n * - `route` XOR `router` (mutually exclusive; at least one required) —\n * the supervisor's dispatch-source rule, surfaced as an orchestrator\n * config error.\n * - `router` is a valid agent contract or `{ agent, ... }` entry.\n * - `maxIterations >= 1` when set.\n * - `snapshotStore` resolvable when `iterate: true` — explicit field or\n * the global `ai.config({ defaultSnapshotStore })` fallback.\n *\n * `initialAgent` membership is checked separately once the intent\n * entries are resolved.\n */\nfunction validateFactoryConfig(config: OrchestratorConfig<unknown>): void {\n if (!config.name || typeof config.name !== \"string\") {\n throw new OrchestratorConfigError(\n \"ai.orchestrator: `name` is required and must be a string\",\n { context: { authoring: true } },\n );\n }\n\n if (!config.intents || typeof config.intents !== \"object\") {\n throw new OrchestratorConfigError(\n `ai.orchestrator(\"${config.name}\"): \\`intents\\` is required`,\n { context: { authoring: true } },\n );\n }\n\n const hasRoute = typeof config.route === \"function\";\n const hasRouter = Boolean(config.router);\n\n if (hasRouter) {\n const router = config.router;\n const isBareAgent = typeof (router as { execute?: unknown }).execute === \"function\";\n const isEntryForm =\n !isBareAgent &&\n typeof (router as { agent?: { execute?: unknown } }).agent === \"object\" &&\n typeof (router as { agent?: { execute?: unknown } }).agent?.execute === \"function\";\n\n if (!isBareAgent && !isEntryForm) {\n throw new OrchestratorConfigError(\n `ai.orchestrator(\"${config.name}\"): \\`router\\` must be an agent contract or a \\`{ agent, placeholders?, input? }\\` entry`,\n { context: { authoring: true } },\n );\n }\n }\n\n if (hasRoute && hasRouter) {\n throw new OrchestratorConfigError(\n `ai.orchestrator(\"${config.name}\"): \\`route\\` and \\`router\\` are mutually exclusive — configure exactly one`,\n { context: { authoring: true } },\n );\n }\n\n if (!hasRoute && !hasRouter) {\n throw new OrchestratorConfigError(\n `ai.orchestrator(\"${config.name}\"): one of \\`route\\` or \\`router\\` is required`,\n { context: { authoring: true } },\n );\n }\n\n if (config.maxIterations !== undefined && config.maxIterations < 1) {\n throw new OrchestratorConfigError(\n `ai.orchestrator(\"${config.name}\"): \\`maxIterations\\` must be >= 1`,\n { context: { authoring: true, maxIterations: config.maxIterations } },\n );\n }\n\n if (config.iterate && !config.snapshotStore && !resolveDefaultSnapshotStore()) {\n throw new OrchestratorConfigError(\n `ai.orchestrator(\"${config.name}\"): \\`iterate: true\\` requires a \\`snapshotStore\\` (or \\`ai.config({ defaultSnapshotStore })\\`) for mid-turn resume`,\n { context: { authoring: true } },\n );\n }\n}\n\n/**\n * Resolve the `intents` map into the supervisor's internal entry shape,\n * re-wrapping the supervisor's authoring failure as an\n * {@link OrchestratorConfigError} so misuse surfaces under the\n * orchestrator's error family rather than the supervisor's.\n */\nfunction resolveEntries(\n config: OrchestratorConfig<unknown>,\n): Map<string, ResolvedIntentEntry> {\n try {\n return resolveIntentEntries(config.intents, config.name);\n } catch (error) {\n if (error instanceof SupervisorFailedError) {\n throw new OrchestratorConfigError(error.message, {\n context: { authoring: true },\n cause: error,\n });\n }\n\n throw error;\n }\n}\n\n/**\n * Enforce the `initialAgent` membership rule (§17) once entries are\n * resolved — `initialAgent`, when set, must name a key in `intents`.\n */\nfunction assertInitialAgent(\n config: OrchestratorConfig<unknown>,\n entries: Map<string, ResolvedIntentEntry>,\n): void {\n if (config.initialAgent && !entries.has(config.initialAgent)) {\n throw new OrchestratorConfigError(\n `ai.orchestrator(\"${config.name}\"): \\`initialAgent\\` \"${config.initialAgent}\" is not a key in \\`intents\\``,\n { context: { authoring: true } },\n );\n }\n}\n\n/**\n * Resolve the per-session lock (C4): an explicit {@link SessionLock} when\n * supplied, a no-op when `sessionLock: false`, otherwise the framework\n * default in-process mutex.\n */\nfunction resolveSessionLock(config: OrchestratorConfig<unknown>): SessionLock {\n if (config.sessionLock === false) return noopSessionLock();\n if (config.sessionLock) return config.sessionLock;\n return inProcessSessionLock();\n}\n\n/** Orchestrator names already warned about an unlocked durable store. */\nconst warnedUnlockedStores = new Set<string>();\n\n/**\n * Warn once when a durable `checkpointStore` is configured but no explicit\n * `sessionLock` was supplied (C4). The in-process default serializes\n * same-session turns within one process only — a horizontally-scaled\n * deployment needs a distributed lock or sticky routing. Suppressed in\n * tests and when the dev explicitly chose a lock (or `sessionLock: false`).\n */\nfunction warnOnUnlockedDurableStore(config: OrchestratorConfig<unknown>): void {\n if (config.sessionLock !== undefined) return;\n if (!config.checkpointStore) return;\n if (process.env.NODE_ENV === \"test\" || process.env.VITEST) return;\n if (warnedUnlockedStores.has(config.name)) return;\n warnedUnlockedStores.add(config.name);\n\n console.warn(\n `[warlock-ai] orchestrator \"${config.name}\" uses a durable checkpointStore with the default in-process sessionLock. ` +\n \"That serializes same-session turns within ONE process only; in a horizontally-scaled deployment supply a distributed \" +\n \"`sessionLock` (Redis/Postgres advisory locks) or use sticky routing. Pass `sessionLock: false` to silence this.\",\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8DA,SAAgB,aAQd,QACuC;CACvC,sBAAsB,MAAgD;CAEtE,MAAM,UAAU,eAAe,MAAgD;CAE/E,mBAAmB,QAAkD,OAAO;CAE5E,MAAM,YAAY,6BAChB,QACA,OACF;CACA,MAAM,UAAU,IAAI,oBAAoB,OAAO,EAAE;CAKjD,MAAM,cAAc,mBAAmB,MAAgD;CACvF,2BAA2B,MAAgD;CAE3E,eAAe,QACb,OACA,SACsC;EACtC,MAAM,YAAY,IAAI,sBAAuC;GACnD;GACR;GACA;GACA;GACA;GACA;EACF,CAAC;EAKD,OAAO,YAAY,SAAS,QAAQ,iBAAiB,UAAU,IAAI,GAAG,EACpE,QAAQ,QAAQ,OAClB,CAAC;CACH;CAEA,SAAS,OACP,OACA,SACgE;EAChE,MAAM,EAAE,YAAY,QAAQ,aAAa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a,gCAC5E,EAAE,SAAS,EAAE,WAAW,KAAK,EAAE,CACjC;AAEJ;;;;;;AAOA,SAAS,mBAAmB,QAAkD;CAC5E,IAAI,OAAO,gBAAgB,OAAO,OAAO,gBAAgB;CACzD,IAAI,OAAO,aAAa,OAAO,OAAO;CACtC,OAAO,qBAAqB;AAC9B;;AAGA,MAAM,uCAAuB,IAAI,IAAY;;;;;;;;AAS7C,SAAS,2BAA2B,QAA2C;CAC7E,IAAI,OAAO,gBAAgB,QAAW;CACtC,IAAI,CAAC,OAAO,iBAAiB;CAC7B,IAAI,QAAQ,IAAI,aAAa,UAAU,QAAQ,IAAI,QAAQ;CAC3D,IAAI,qBAAqB,IAAI,OAAO,IAAI,GAAG;CAC3C,qBAAqB,IAAI,OAAO,IAAI;CAEpC,QAAQ,KACN,8BAA8B,OAAO,KAAK,mTAG5C;AACF"}
|
|
1
|
+
{"version":3,"file":"orchestrator.mjs","names":["orchestratorAsTool"],"sources":["../../../../../../../ai/src/orchestrator/orchestrator.ts"],"sourcesContent":["import type { OrchestratorConfig } from \"../contracts/orchestrator/orchestrator-config.type\";\nimport type {\n OrchestratorEventHandler,\n OrchestratorEventName,\n} from \"../contracts/orchestrator/orchestrator-event.type\";\nimport type {\n OrchestratorAsToolOptions,\n OrchestratorContract,\n} from \"../contracts/orchestrator/orchestrator.contract\";\nimport type { OrchestratorCommands } from \"../contracts/orchestrator/orchestrator-commands.type\";\nimport type {\n OrchestratorExecuteOptions,\n OrchestratorResumeOptions,\n} from \"../contracts/orchestrator/orchestrator-execute-options.type\";\nimport type { OrchestratorEvent } from \"../contracts/orchestrator/orchestrator-event.type\";\nimport type { OrchestratorResult } from \"../contracts/result/orchestrator-result.type\";\nimport type { StreamContract } from \"../contracts/stream/stream.contract\";\nimport type { SupervisorIntentValue } from \"../contracts/supervisor/intent-entry.type\";\nimport type { SupervisorInput } from \"../contracts/supervisor/supervisor-input.type\";\nimport { resolveDefaultSnapshotStore } from \"../config\";\nimport { OrchestratorConfigError } from \"../errors/orchestrator-config-error\";\nimport { resolveIntentEntries, type ResolvedIntentEntry } from \"../supervisor/entries\";\nimport { SupervisorFailedError } from \"../errors\";\nimport type { ToolContract } from \"../tool/tool\";\nimport type { SessionLock } from \"../contracts/orchestrator/session-lock.contract\";\nimport { asTool as orchestratorAsTool } from \"./as-tool\";\nimport { createCommandDispatcher } from \"./commands\";\nimport { OrchestratorEmitter } from \"./emitter\";\nimport { OrchestratorExecution } from \"./execution\";\nimport { createOrchestratorStream } from \"./orchestrator-stream\";\nimport { inProcessSessionLock, noopSessionLock } from \"./session-lock\";\nimport { computeOrchestratorSignature } from \"./signature\";\n\n/**\n * `ai.orchestrator(config)` — construct an {@link OrchestratorContract}:\n * a session-state manager wrapped around a supervisor (orchestrator.md\n * §1, §15). Validates the config at author time (throws\n * {@link OrchestratorConfigError} on bad shape), resolves the intent\n * entries, computes a stable structural signature for drift detection\n * (§10.1), wires the three-tier event emitter, and returns a handle that\n * runs one durable session turn per `execute` / `stream` call, resumes\n * an interrupted `iterate: true` turn via `resume`, and exposes typed\n * built-in commands plus an `asTool` wrapper.\n *\n * The \"what runs\" fields (`intents`, `route` / `router`, `evaluate`,\n * `state`, `output`, `initialAgent`, `maxIterations`) are the\n * supervisor's surface spread directly — the lifecycle builds the\n * supervisor lazily per turn and delegates to it (§3 Phase 5). Users\n * never see the supervisor object.\n *\n * @example\n * const supportBot = ai.orchestrator<SessionState>({\n * name: \"refund-support\",\n * intents: { classify, lookup, process, compose },\n * route: (ctx) => (ctx.iteration === 0 ? \"classify\" : END),\n * iterate: true,\n * checkpointStore: ai.checkpoint.pg({ client: pg }),\n * snapshotStore: ai.snapshot.pg({ client: pg }),\n * });\n *\n * const result = await supportBot.execute(message, { sessionId, history });\n */\nexport function orchestrator<\n TOutput = unknown,\n TState = TOutput,\n TIntents extends Record<string, SupervisorIntentValue> = Record<\n string,\n SupervisorIntentValue\n >,\n>(\n config: OrchestratorConfig<TOutput, TState, TIntents>,\n): OrchestratorContract<TOutput, TState> {\n validateFactoryConfig(config as unknown as OrchestratorConfig<unknown>);\n\n const entries = resolveEntries(config as unknown as OrchestratorConfig<unknown>);\n\n assertInitialAgent(config as unknown as OrchestratorConfig<unknown>, entries);\n\n const signature = computeOrchestratorSignature(\n config as unknown as OrchestratorConfig<unknown>,\n entries,\n );\n const emitter = new OrchestratorEmitter(config.on);\n\n // Per-session turn serialization (C4). Resolved ONCE so every turn on\n // this orchestrator shares the same lock — that's what lets the\n // in-process default actually serialize concurrent same-session calls.\n const sessionLock = resolveSessionLock(config as unknown as OrchestratorConfig<unknown>);\n warnOnUnlockedDurableStore(config as unknown as OrchestratorConfig<unknown>);\n\n async function execute(\n input: SupervisorInput,\n options: OrchestratorExecuteOptions<TState>,\n ): Promise<OrchestratorResult<TOutput>> {\n const execution = new OrchestratorExecution<TOutput, TState>({\n config: config as unknown as OrchestratorConfig<TOutput, TState>,\n entries,\n signature,\n emitter,\n input,\n options,\n });\n\n // Serialize the whole turn (load → dispatch → persist) against any\n // concurrent turn for the same session, so the checkpoint's\n // read-modify-write can't lose an update.\n return sessionLock.withLock(options.sessionId, () => execution.run(), {\n signal: options.signal,\n });\n }\n\n function stream(\n input: SupervisorInput,\n options: OrchestratorExecuteOptions<TState>,\n ): StreamContract<OrchestratorResult<TOutput>, OrchestratorEvent> {\n const { controller, stream: contract } = createOrchestratorStream<\n OrchestratorResult<TOutput>\n >();\n\n const execution = new OrchestratorExecution<TOutput, TState>({\n config: config as unknown as OrchestratorConfig<TOutput, TState>,\n entries,\n signature,\n emitter,\n input,\n options,\n streamController: controller,\n });\n\n // The background run waits for the session lock before it starts —\n // same serialization guarantee as `execute`; the stream contract is\n // still returned synchronously.\n void sessionLock.withLock(options.sessionId, () => execution.run(), {\n signal: options.signal,\n });\n\n return contract;\n }\n\n async function resume(\n sessionId: string,\n options?: OrchestratorResumeOptions,\n ): Promise<OrchestratorResult<TOutput> | null> {\n const execution = new OrchestratorExecution<TOutput, TState>({\n config: config as unknown as OrchestratorConfig<TOutput, TState>,\n entries,\n signature,\n emitter,\n resumeSessionId: sessionId,\n resumeOptions: options,\n });\n\n return sessionLock.withLock(sessionId, () => execution.resume(), {\n signal: options?.signal,\n });\n }\n\n // The dispatcher owns command ROUTING only; the `compact` handler\n // delegates to the shared compaction code path on the lifecycle engine\n // (§11 / §12.2 — manual compact reuses the post-turn compaction path).\n const command = createCommandDispatcher({\n compact: (args: OrchestratorCommands[\"compact\"][\"args\"]) => {\n const execution = new OrchestratorExecution<TOutput, TState>({\n config: config as unknown as OrchestratorConfig<TOutput, TState>,\n entries,\n signature,\n emitter,\n });\n\n return execution.compact(args);\n },\n });\n\n const instance: OrchestratorContract<TOutput, TState> = {\n name: config.name,\n signature,\n version: config.version,\n execute,\n stream,\n resume,\n command,\n asTool<TToolInput = string>(\n options: OrchestratorAsToolOptions<TToolInput>,\n ): ToolContract<TToolInput, TOutput> {\n return orchestratorAsTool<TOutput, TState, TToolInput>(instance, options);\n },\n on<K extends OrchestratorEventName>(\n event: K,\n handler: OrchestratorEventHandler<K>,\n ): () => void {\n return emitter.on(event, handler);\n },\n off<K extends OrchestratorEventName>(\n event: K,\n handler: OrchestratorEventHandler<K>,\n ): void {\n emitter.off(event, handler);\n },\n };\n\n return instance;\n}\n\n/**\n * Author-time validation (orchestrator.md §17). Enforces the rules that\n * must fail at construction rather than on the first turn:\n *\n * - `name` present and a string.\n * - `intents` present.\n * - `route` XOR `router` (mutually exclusive; at least one required) —\n * the supervisor's dispatch-source rule, surfaced as an orchestrator\n * config error.\n * - `router` is a valid agent contract or `{ agent, ... }` entry.\n * - `maxIterations >= 1` when set.\n * - `snapshotStore` resolvable when `iterate: true` — explicit field or\n * the global `ai.config({ defaultSnapshotStore })` fallback.\n *\n * `initialAgent` membership is checked separately once the intent\n * entries are resolved.\n */\nfunction validateFactoryConfig(config: OrchestratorConfig<unknown>): void {\n if (!config.name || typeof config.name !== \"string\") {\n throw new OrchestratorConfigError(\n \"ai.orchestrator: `name` is required and must be a string\",\n { context: { authoring: true } },\n );\n }\n\n if (!config.intents || typeof config.intents !== \"object\") {\n throw new OrchestratorConfigError(\n `ai.orchestrator(\"${config.name}\"): \\`intents\\` is required`,\n { context: { authoring: true } },\n );\n }\n\n const hasRoute = typeof config.route === \"function\";\n const hasRouter = Boolean(config.router);\n\n if (hasRouter) {\n const router = config.router;\n const isBareAgent = typeof (router as { execute?: unknown }).execute === \"function\";\n const isEntryForm =\n !isBareAgent &&\n typeof (router as { agent?: { execute?: unknown } }).agent === \"object\" &&\n typeof (router as { agent?: { execute?: unknown } }).agent?.execute === \"function\";\n\n if (!isBareAgent && !isEntryForm) {\n throw new OrchestratorConfigError(\n `ai.orchestrator(\"${config.name}\"): \\`router\\` must be an agent contract or a \\`{ agent, placeholders?, input? }\\` entry`,\n { context: { authoring: true } },\n );\n }\n }\n\n if (hasRoute && hasRouter) {\n throw new OrchestratorConfigError(\n `ai.orchestrator(\"${config.name}\"): \\`route\\` and \\`router\\` are mutually exclusive — configure exactly one`,\n { context: { authoring: true } },\n );\n }\n\n if (!hasRoute && !hasRouter) {\n throw new OrchestratorConfigError(\n `ai.orchestrator(\"${config.name}\"): one of \\`route\\` or \\`router\\` is required`,\n { context: { authoring: true } },\n );\n }\n\n if (config.maxIterations !== undefined && config.maxIterations < 1) {\n throw new OrchestratorConfigError(\n `ai.orchestrator(\"${config.name}\"): \\`maxIterations\\` must be >= 1`,\n { context: { authoring: true, maxIterations: config.maxIterations } },\n );\n }\n\n if (config.iterate && !config.snapshotStore && !resolveDefaultSnapshotStore()) {\n throw new OrchestratorConfigError(\n `ai.orchestrator(\"${config.name}\"): \\`iterate: true\\` requires a \\`snapshotStore\\` (or \\`ai.config({ defaultSnapshotStore })\\`) for mid-turn resume`,\n { context: { authoring: true } },\n );\n }\n}\n\n/**\n * Resolve the `intents` map into the supervisor's internal entry shape,\n * re-wrapping the supervisor's authoring failure as an\n * {@link OrchestratorConfigError} so misuse surfaces under the\n * orchestrator's error family rather than the supervisor's.\n */\nfunction resolveEntries(\n config: OrchestratorConfig<unknown>,\n): Map<string, ResolvedIntentEntry> {\n try {\n return resolveIntentEntries(config.intents, config.name);\n } catch (error) {\n if (error instanceof SupervisorFailedError) {\n throw new OrchestratorConfigError(error.message, {\n context: { authoring: true },\n cause: error,\n });\n }\n\n throw error;\n }\n}\n\n/**\n * Enforce the `initialAgent` membership rule (§17) once entries are\n * resolved — `initialAgent`, when set, must name a key in `intents`.\n */\nfunction assertInitialAgent(\n config: OrchestratorConfig<unknown>,\n entries: Map<string, ResolvedIntentEntry>,\n): void {\n if (config.initialAgent && !entries.has(config.initialAgent)) {\n throw new OrchestratorConfigError(\n `ai.orchestrator(\"${config.name}\"): \\`initialAgent\\` \"${config.initialAgent}\" is not a key in \\`intents\\``,\n { context: { authoring: true } },\n );\n }\n}\n\n/**\n * Resolve the per-session lock (C4): an explicit {@link SessionLock} when\n * supplied, a no-op when `sessionLock: false`, otherwise the framework\n * default in-process mutex.\n */\nfunction resolveSessionLock(config: OrchestratorConfig<unknown>): SessionLock {\n if (config.sessionLock === false) return noopSessionLock();\n if (config.sessionLock) return config.sessionLock;\n return inProcessSessionLock();\n}\n\n/** Orchestrator names already warned about an unlocked durable store. */\nconst warnedUnlockedStores = new Set<string>();\n\n/**\n * Warn once when a durable `checkpointStore` is configured but no explicit\n * `sessionLock` was supplied (C4). The in-process default serializes\n * same-session turns within one process only — a horizontally-scaled\n * deployment needs a distributed lock or sticky routing. Suppressed in\n * tests and when the dev explicitly chose a lock (or `sessionLock: false`).\n */\nfunction warnOnUnlockedDurableStore(config: OrchestratorConfig<unknown>): void {\n if (config.sessionLock !== undefined) return;\n if (!config.checkpointStore) return;\n if (process.env.NODE_ENV === \"test\" || process.env.VITEST) return;\n if (warnedUnlockedStores.has(config.name)) return;\n warnedUnlockedStores.add(config.name);\n\n console.warn(\n `[warlock-ai] orchestrator \"${config.name}\" uses a durable checkpointStore with the default in-process sessionLock. ` +\n \"That serializes same-session turns within ONE process only; in a horizontally-scaled deployment supply a distributed \" +\n \"`sessionLock` (Redis/Postgres advisory locks) or use sticky routing. Pass `sessionLock: false` to silence this.\",\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8DA,SAAgB,aAQd,QACuC;CACvC,sBAAsB,MAAgD;CAEtE,MAAM,UAAU,eAAe,MAAgD;CAE/E,mBAAmB,QAAkD,OAAO;CAE5E,MAAM,YAAY,6BAChB,QACA,OACF;CACA,MAAM,UAAU,IAAI,oBAAoB,OAAO,EAAE;CAKjD,MAAM,cAAc,mBAAmB,MAAgD;CACvF,2BAA2B,MAAgD;CAE3E,eAAe,QACb,OACA,SACsC;EACtC,MAAM,YAAY,IAAI,sBAAuC;GACnD;GACR;GACA;GACA;GACA;GACA;EACF,CAAC;EAKD,OAAO,YAAY,SAAS,QAAQ,iBAAiB,UAAU,IAAI,GAAG,EACpE,QAAQ,QAAQ,OAClB,CAAC;CACH;CAEA,SAAS,OACP,OACA,SACgE;EAChE,MAAM,EAAE,YAAY,QAAQ,aAAa,yBAEvC;EAEF,MAAM,YAAY,IAAI,sBAAuC;GACnD;GACR;GACA;GACA;GACA;GACA;GACA,kBAAkB;EACpB,CAAC;EAKD,AAAK,YAAY,SAAS,QAAQ,iBAAiB,UAAU,IAAI,GAAG,EAClE,QAAQ,QAAQ,OAClB,CAAC;EAED,OAAO;CACT;CAEA,eAAe,OACb,WACA,SAC6C;EAC7C,MAAM,YAAY,IAAI,sBAAuC;GACnD;GACR;GACA;GACA;GACA,iBAAiB;GACjB,eAAe;EACjB,CAAC;EAED,OAAO,YAAY,SAAS,iBAAiB,UAAU,OAAO,GAAG,EAC/D,QAAQ,SAAS,OACnB,CAAC;CACH;CAKA,MAAM,UAAU,wBAAwB,EACtC,UAAU,SAAkD;EAQ1D,OAAO,IAPe,sBAAuC;GACnD;GACR;GACA;GACA;EACF,CAEe,CAAC,CAAC,QAAQ,IAAI;CAC/B,EACF,CAAC;CAED,MAAM,WAAkD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checkpoint.mjs";
|
|
|
2
2
|
import { deriveRunId, dispatchTurn } from "./dispatch.mjs";
|
|
3
3
|
import { loadSession } from "./load.mjs";
|
|
4
4
|
|
|
5
|
-
//#region
|
|
5
|
+
//#region ../ai/src/orchestrator/resume.ts
|
|
6
6
|
/**
|
|
7
7
|
* §9 resume protocol. Detects and drains an interrupted `iterate: true`
|
|
8
8
|
* turn:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resume.mjs","names":[],"sources":["
|
|
1
|
+
{"version":3,"file":"resume.mjs","names":[],"sources":["../../../../../../../ai/src/orchestrator/resume.ts"],"sourcesContent":["import type { OrchestratorResumeOptions } from \"../contracts/orchestrator/orchestrator-execute-options.type\";\nimport type {\n OrchestratorReport,\n OrchestratorReportStatus,\n OrchestratorResult,\n TurnSnapshot,\n} from \"../contracts/result/orchestrator-result.type\";\nimport type { BaseReport } from \"../contracts/result/base-report.type\";\nimport { summarizeRoute } from \"./checkpoint\";\nimport { deriveRunId, dispatchTurn } from \"./dispatch\";\nimport type { OrchestratorEngineContext } from \"./engine-context.type\";\nimport { loadSession } from \"./load\";\n\n/**\n * Hooks the resume protocol borrows from the execution module so it can\n * reuse the drift check, report assembly, status mapping, terminal\n * event emission, and checkpoint persistence without a circular import\n * (execution.ts owns those; resume.ts is called by it).\n */\nexport type ResumeHooks = {\n assertNoDrift(loadedSignature: string | undefined): void;\n buildReport(\n turnIndex: number,\n status: OrchestratorReportStatus,\n turnSnapshot: TurnSnapshot | undefined,\n childReport: BaseReport | undefined,\n ): OrchestratorReport;\n deriveStatus(childStatus: BaseReport[\"status\"]): OrchestratorReportStatus;\n emitTerminal(turnIndex: number, status: OrchestratorReportStatus): void;\n persist(\n turnIndex: number,\n state: unknown,\n lastRoute: string | string[] | null,\n summarizedThrough: number | null,\n ): Promise<unknown>;\n};\n\n/**\n * §9 resume protocol. Detects and drains an interrupted `iterate: true`\n * turn:\n *\n * 1. Load the latest checkpoint (§9.1 step 1).\n * 2. Compute the candidate `runId` for the NEXT turn — the one that was\n * in flight — `${sessionId}.${version}.${turn_index + 1}` (§9.1 step 2).\n * 3. Load the supervisor snapshot for that runId (§9.1 step 3).\n * 4. If a still-`running` snapshot exists, resume the supervisor, persist\n * a fresh checkpoint for `turn_index + 1`, and return the result\n * (§9.1 step 4).\n * 5. Otherwise return `null` — nothing in flight; the caller proceeds to\n * `execute()` normally (§9.1 step 5, §9.3 drain idempotency).\n *\n * Runs the same Phase 2 drift check as `execute()` (§9.4). Resume is a\n * no-op for `iterate: false` orchestrators (no SnapshotStore, nothing to\n * resume) — it returns `null`.\n */\nexport async function resolveResume<TOutput, TState>(\n ctx: OrchestratorEngineContext<TOutput, TState>,\n sessionId: string,\n options: OrchestratorResumeOptions | undefined,\n hooks: ResumeHooks,\n): Promise<OrchestratorResult<TOutput> | null> {\n if (!ctx.snapshotStore || ctx.config.iterate !== true) {\n return null;\n }\n\n const loaded = await loadSession(ctx, sessionId);\n\n // Drift guard — same as execute() (§9.4).\n hooks.assertNoDrift(loaded.record?.signature);\n\n // The in-flight turn is the one AFTER the last settled checkpoint.\n const resumedTurnIndex = (loaded.record?.turn_index ?? -1) + 1;\n const runId = deriveRunId(sessionId, ctx.config.version, resumedTurnIndex);\n\n const snapshot = await ctx.snapshotStore.load(runId);\n\n if (!snapshot || snapshot.status !== \"running\") {\n return null;\n }\n\n ctx.emitter.emit(\"orchestrator.turn.starting\", {\n sessionId,\n turnIndex: resumedTurnIndex,\n });\n\n // Re-dispatch: dispatchTurn detects the in-flight snapshot for this\n // runId and calls supervisor.resume() rather than execute() (§5 step 5).\n const { result, state, turnSnapshot } = await dispatchTurn<TOutput, TState>({\n ctx,\n sessionId,\n input: snapshot.input,\n seedState: loaded.state,\n turnIndex: resumedTurnIndex,\n history: [],\n context: options?.context,\n signal: options?.signal,\n });\n\n const status = result.error\n ? hooks.deriveStatus(result.report.status)\n : \"awaiting-input\";\n\n if (result.error) {\n const report = hooks.buildReport(\n resumedTurnIndex,\n status,\n turnSnapshot,\n result.report,\n );\n\n hooks.emitTerminal(resumedTurnIndex, status);\n\n return {\n data: result.data,\n error: result.error,\n usage: result.usage,\n report,\n sessionId,\n turnIndex: resumedTurnIndex,\n };\n }\n\n // Finalize: persist a fresh checkpoint for the resumed turn (§9.1 step 4).\n await hooks.persist(\n resumedTurnIndex,\n state,\n summarizeRoute(turnSnapshot.decision.raw as never),\n loaded.record?.summarized_through ?? null,\n );\n\n const report = hooks.buildReport(\n resumedTurnIndex,\n \"awaiting-input\",\n turnSnapshot,\n result.report,\n );\n\n hooks.emitTerminal(resumedTurnIndex, \"awaiting-input\");\n\n return {\n data: result.data,\n error: undefined,\n usage: result.usage,\n report,\n sessionId,\n turnIndex: resumedTurnIndex,\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAuDA,eAAsB,cACpB,KACA,WACA,SACA,OAC6C;CAC7C,IAAI,CAAC,IAAI,iBAAiB,IAAI,OAAO,YAAY,MAC/C,OAAO;CAGT,MAAM,SAAS,MAAM,YAAY,KAAK,SAAS;CAG/C,MAAM,cAAc,OAAO,QAAQ,SAAS;CAG5C,MAAM,oBAAoB,OAAO,QAAQ,cAAc,MAAM;CAC7D,MAAM,QAAQ,YAAY,WAAW,IAAI,OAAO,SAAS,gBAAgB;CAEzE,MAAM,WAAW,MAAM,IAAI,cAAc,KAAK,KAAK;CAEnD,IAAI,CAAC,YAAY,SAAS,WAAW,WACnC,OAAO;CAGT,IAAI,QAAQ,KAAK,8BAA8B;EAC7C;EACA,WAAW;CACb,CAAC;CAID,MAAM,EAAE,QAAQ,OAAO,iBAAiB,MAAM,aAA8B;EAC1E;EACA;EACA,OAAO,SAAS;EAChB,WAAW,OAAO;EAClB,WAAW;EACX,SAAS,CAAC;EACV,SAAS,SAAS;EAClB,QAAQ,SAAS;CACnB,CAAC;CAED,MAAM,SAAS,OAAO,QAClB,MAAM,aAAa,OAAO,OAAO,MAAM,IACvC;CAEJ,IAAI,OAAO,OAAO;EAChB,MAA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