@cuylabs/agent-core 4.9.0 → 4.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11 -12
- package/dist/agent/chat-loop/commit-batch.d.ts +10 -0
- package/dist/agent/chat-loop/commit-batch.d.ts.map +1 -0
- package/dist/agent/chat-loop/context-recovery.d.ts +29 -0
- package/dist/agent/chat-loop/context-recovery.d.ts.map +1 -0
- package/dist/agent/chat-loop/finalize-turn.d.ts +19 -0
- package/dist/agent/chat-loop/finalize-turn.d.ts.map +1 -0
- package/dist/agent/chat-loop/index.d.ts +7 -0
- package/dist/agent/chat-loop/index.d.ts.map +1 -0
- package/dist/agent/chat-loop/loop.d.ts +8 -0
- package/dist/agent/chat-loop/loop.d.ts.map +1 -0
- package/dist/agent/chat-loop/model-step-runner.d.ts +26 -0
- package/dist/agent/chat-loop/model-step-runner.d.ts.map +1 -0
- package/dist/agent/chat-loop/model-step-snapshot.d.ts +49 -0
- package/dist/agent/chat-loop/model-step-snapshot.d.ts.map +1 -0
- package/dist/agent/chat-loop/turn-tools.d.ts +19 -0
- package/dist/agent/chat-loop/turn-tools.d.ts.map +1 -0
- package/dist/agent/chat-loop/types.d.ts +60 -0
- package/dist/agent/chat-loop/types.d.ts.map +1 -0
- package/dist/agent/defaults.d.ts +69 -0
- package/dist/agent/defaults.d.ts.map +1 -0
- package/dist/agent/event-printer.d.ts +94 -0
- package/dist/agent/event-printer.d.ts.map +1 -0
- package/dist/agent/fork.d.ts +59 -0
- package/dist/agent/fork.d.ts.map +1 -0
- package/dist/agent/index.d.ts +17 -0
- package/dist/agent/index.d.ts.map +1 -0
- package/dist/agent/instance/context-management.d.ts +29 -0
- package/dist/agent/instance/context-management.d.ts.map +1 -0
- package/dist/agent/instance/forking.d.ts +26 -0
- package/dist/agent/instance/forking.d.ts.map +1 -0
- package/dist/agent/instance/index.d.ts +170 -0
- package/dist/agent/instance/index.d.ts.map +1 -0
- package/dist/agent/instance/interventions.d.ts +10 -0
- package/dist/agent/instance/interventions.d.ts.map +1 -0
- package/dist/agent/instance/mcp.d.ts +21 -0
- package/dist/agent/instance/mcp.d.ts.map +1 -0
- package/dist/agent/instance/sessions.d.ts +8 -0
- package/dist/agent/instance/sessions.d.ts.map +1 -0
- package/dist/agent/instance/tools.d.ts +16 -0
- package/dist/agent/instance/tools.d.ts.map +1 -0
- package/dist/agent/instance/turn-lifecycle.d.ts +61 -0
- package/dist/agent/instance/turn-lifecycle.d.ts.map +1 -0
- package/dist/agent/session.d.ts +16 -0
- package/dist/agent/session.d.ts.map +1 -0
- package/dist/agent/setup/config.d.ts +8 -0
- package/dist/agent/setup/config.d.ts.map +1 -0
- package/dist/agent/setup/context-window.d.ts +4 -0
- package/dist/agent/setup/context-window.d.ts.map +1 -0
- package/dist/agent/setup/environment.d.ts +5 -0
- package/dist/agent/setup/environment.d.ts.map +1 -0
- package/dist/agent/setup/middleware.d.ts +9 -0
- package/dist/agent/setup/middleware.d.ts.map +1 -0
- package/dist/agent/setup/runtime-config.d.ts +9 -0
- package/dist/agent/setup/runtime-config.d.ts.map +1 -0
- package/dist/agent/setup/state.d.ts +4 -0
- package/dist/agent/setup/state.d.ts.map +1 -0
- package/dist/agent/setup/tools.d.ts +8 -0
- package/dist/agent/setup/tools.d.ts.map +1 -0
- package/dist/agent/setup.d.ts +47 -0
- package/dist/agent/setup.d.ts.map +1 -0
- package/dist/agent/stream-provider.d.ts +27 -0
- package/dist/agent/stream-provider.d.ts.map +1 -0
- package/dist/agent/turn-context/compaction/agent-context.d.ts +53 -0
- package/dist/agent/turn-context/compaction/agent-context.d.ts.map +1 -0
- package/dist/agent/turn-context/compaction/budget.d.ts +4 -0
- package/dist/agent/turn-context/compaction/budget.d.ts.map +1 -0
- package/dist/agent/turn-context/compaction/check.d.ts +39 -0
- package/dist/agent/turn-context/compaction/check.d.ts.map +1 -0
- package/dist/agent/turn-context/compaction/fragments.d.ts +4 -0
- package/dist/agent/turn-context/compaction/fragments.d.ts.map +1 -0
- package/dist/agent/turn-context/compaction/index.d.ts +5 -0
- package/dist/agent/turn-context/compaction/index.d.ts.map +1 -0
- package/dist/agent/turn-context/compaction/memory.d.ts +17 -0
- package/dist/agent/turn-context/compaction/memory.d.ts.map +1 -0
- package/dist/agent/turn-context/compaction/results.d.ts +19 -0
- package/dist/agent/turn-context/compaction/results.d.ts.map +1 -0
- package/dist/agent/turn-context/compaction/summary.d.ts +3 -0
- package/dist/agent/turn-context/compaction/summary.d.ts.map +1 -0
- package/dist/agent/turn-context/compaction/types.d.ts +24 -0
- package/dist/agent/turn-context/compaction/types.d.ts.map +1 -0
- package/dist/agent/turn-context/fit-model-context.d.ts +29 -0
- package/dist/agent/turn-context/fit-model-context.d.ts.map +1 -0
- package/dist/agent/turn-context/index.d.ts +5 -0
- package/dist/agent/turn-context/index.d.ts.map +1 -0
- package/dist/agent/turn-context/system-prompts.d.ts +12 -0
- package/dist/agent/turn-context/system-prompts.d.ts.map +1 -0
- package/dist/agent/types/config.d.ts +199 -0
- package/dist/agent/types/config.d.ts.map +1 -0
- package/dist/agent/types/index.d.ts +11 -0
- package/dist/agent/types/index.d.ts.map +1 -0
- package/dist/agent/types/state.d.ts +16 -0
- package/dist/agent/types/state.d.ts.map +1 -0
- package/dist/agent/types/tracing.d.ts +12 -0
- package/dist/agent/types/tracing.d.ts.map +1 -0
- package/dist/{chunk-KYLPMBHD.js → chunk-336EDIBL.js} +1 -1
- package/dist/chunk-AAGKWUXR.js +539 -0
- package/dist/chunk-AHDCR7SX.js +83 -0
- package/dist/{chunk-CSR75JVC.js → chunk-ASXF5AC6.js} +1 -1
- package/dist/{chunk-2TTOLHBT.js → chunk-CFBSQLP5.js} +1 -1
- package/dist/{chunk-GJFP5L2V.js → chunk-CNM6OROH.js} +15 -3
- package/dist/chunk-E66PKKDL.js +772 -0
- package/dist/{chunk-HSUPTXNV.js → chunk-EBVSPHXA.js} +13 -10
- package/dist/chunk-EEAGM5MS.js +257 -0
- package/dist/chunk-IQA64CAO.js +84 -0
- package/dist/chunk-JFH6HBUG.js +227 -0
- package/dist/{chunk-MWPU2EVV.js → chunk-JUIL2NJC.js} +4 -81
- package/dist/{chunk-NS7D7JJU.js → chunk-K453AFTL.js} +35 -16
- package/dist/chunk-LX4AHGI3.js +960 -0
- package/dist/chunk-MJRZ2ZRI.js +498 -0
- package/dist/chunk-NMJNN6LS.js +1155 -0
- package/dist/{chunk-UMIVJDEJ.js → chunk-SAWRDGBE.js} +30 -7
- package/dist/{chunk-GEBFHREI.js → chunk-TU5KDFWI.js} +30 -5
- package/dist/{chunk-QJV5XPPS.js → chunk-UEEHZ4QH.js} +1 -1
- package/dist/chunk-UG5PVNZV.js +53 -0
- package/dist/{chunk-BGG2HVIR.js → chunk-V4MIDL5B.js} +9 -0
- package/dist/{chunk-BJC46FIF.js → chunk-V4YQ6MBK.js} +2 -2
- package/dist/{chunk-H3GRHFFG.js → chunk-VMGZKIFT.js} +30 -9
- package/dist/chunk-W6LWIMIX.js +8 -0
- package/dist/context/assembly/index.d.ts +3 -0
- package/dist/context/assembly/index.d.ts.map +1 -0
- package/dist/context/assembly/prepare.d.ts +11 -0
- package/dist/context/assembly/prepare.d.ts.map +1 -0
- package/dist/context/assembly/types.d.ts +60 -0
- package/dist/context/assembly/types.d.ts.map +1 -0
- package/dist/context/config.d.ts +11 -0
- package/dist/context/config.d.ts.map +1 -0
- package/dist/context/fragments/index.d.ts +4 -0
- package/dist/context/fragments/index.d.ts.map +1 -0
- package/dist/context/fragments/messages.d.ts +10 -0
- package/dist/context/fragments/messages.d.ts.map +1 -0
- package/dist/context/fragments/render.d.ts +16 -0
- package/dist/context/fragments/render.d.ts.map +1 -0
- package/dist/context/fragments/types.d.ts +87 -0
- package/dist/context/fragments/types.d.ts.map +1 -0
- package/dist/context/index.d.ts +13 -0
- package/dist/context/index.d.ts.map +1 -0
- package/dist/context/index.js +90 -0
- package/dist/context/text/truncation.d.ts +13 -0
- package/dist/context/text/truncation.d.ts.map +1 -0
- package/dist/context/window/budget.d.ts +108 -0
- package/dist/context/window/budget.d.ts.map +1 -0
- package/dist/context/window/compactor.d.ts +74 -0
- package/dist/context/window/compactor.d.ts.map +1 -0
- package/dist/context/window/cut-planner.d.ts +64 -0
- package/dist/context/window/cut-planner.d.ts.map +1 -0
- package/dist/context/window/decision.d.ts +41 -0
- package/dist/context/window/decision.d.ts.map +1 -0
- package/dist/context/window/estimation.d.ts +45 -0
- package/dist/context/window/estimation.d.ts.map +1 -0
- package/dist/context/window/index.d.ts +26 -0
- package/dist/context/window/index.d.ts.map +1 -0
- package/dist/context/window/manager.d.ts +80 -0
- package/dist/context/window/manager.d.ts.map +1 -0
- package/dist/context/window/summary-policy.d.ts +50 -0
- package/dist/context/window/summary-policy.d.ts.map +1 -0
- package/dist/context/window/summary.d.ts +56 -0
- package/dist/context/window/summary.d.ts.map +1 -0
- package/dist/context/window/tool-pruning.d.ts +62 -0
- package/dist/context/window/tool-pruning.d.ts.map +1 -0
- package/dist/dispatch/executor.d.ts +56 -0
- package/dist/dispatch/executor.d.ts.map +1 -0
- package/dist/dispatch/index.d.ts +7 -95
- package/dist/dispatch/index.d.ts.map +1 -0
- package/dist/dispatch/index.js +4 -3
- package/dist/dispatch/results.d.ts +9 -0
- package/dist/dispatch/results.d.ts.map +1 -0
- package/dist/dispatch/runtime.d.ts +19 -0
- package/dist/dispatch/runtime.d.ts.map +1 -0
- package/dist/dispatch/tool-factories.d.ts +8 -0
- package/dist/dispatch/tool-factories.d.ts.map +1 -0
- package/dist/dispatch/tools.d.ts +10 -0
- package/dist/dispatch/tools.d.ts.map +1 -0
- package/dist/dispatch/types.d.ts +131 -0
- package/dist/dispatch/types.d.ts.map +1 -0
- package/dist/events/event-bus/index.d.ts +13 -0
- package/dist/events/event-bus/index.d.ts.map +1 -0
- package/dist/events/event-bus/index.js +6 -0
- package/dist/events/event-bus/local.d.ts +14 -0
- package/dist/events/event-bus/local.d.ts.map +1 -0
- package/dist/events/event-bus/types.d.ts +78 -0
- package/dist/events/event-bus/types.d.ts.map +1 -0
- package/dist/events/index.d.ts +10 -89
- package/dist/events/index.d.ts.map +1 -0
- package/dist/events/index.js +6 -1
- package/dist/events/signal/index.d.ts +18 -0
- package/dist/events/signal/index.d.ts.map +1 -0
- package/dist/events/signal/index.js +6 -0
- package/dist/events/signal/local.d.ts +22 -0
- package/dist/events/signal/local.d.ts.map +1 -0
- package/dist/events/signal/types.d.ts +69 -0
- package/dist/events/signal/types.d.ts.map +1 -0
- package/dist/execution/index.d.ts +33 -481
- package/dist/execution/index.d.ts.map +1 -0
- package/dist/execution/index.js +45 -19
- package/dist/execution/scope/index.d.ts +10 -0
- package/dist/execution/scope/index.d.ts.map +1 -0
- package/dist/execution/scope/index.js +12 -0
- package/dist/execution/scope/run.d.ts +8 -0
- package/dist/execution/scope/run.d.ts.map +1 -0
- package/dist/execution/scope/store.d.ts +6 -0
- package/dist/execution/scope/store.d.ts.map +1 -0
- package/dist/execution/scope/types.d.ts +28 -0
- package/dist/execution/scope/types.d.ts.map +1 -0
- package/dist/execution/shared/usage.d.ts +9 -0
- package/dist/execution/shared/usage.d.ts.map +1 -0
- package/dist/execution/task/index.d.ts +6 -0
- package/dist/execution/task/index.d.ts.map +1 -0
- package/dist/execution/task/observer.d.ts +80 -0
- package/dist/execution/task/observer.d.ts.map +1 -0
- package/dist/execution/task/runner.d.ts +39 -0
- package/dist/execution/task/runner.d.ts.map +1 -0
- package/dist/execution/task/types.d.ts +85 -0
- package/dist/execution/task/types.d.ts.map +1 -0
- package/dist/execution/turn/engine/commit-batch.d.ts +16 -0
- package/dist/execution/turn/engine/commit-batch.d.ts.map +1 -0
- package/dist/execution/turn/engine/engine.d.ts +32 -0
- package/dist/execution/turn/engine/engine.d.ts.map +1 -0
- package/dist/execution/turn/engine/index.d.ts +12 -0
- package/dist/execution/turn/engine/index.d.ts.map +1 -0
- package/dist/execution/turn/engine/types.d.ts +67 -0
- package/dist/execution/turn/engine/types.d.ts.map +1 -0
- package/dist/execution/turn/index.d.ts +18 -0
- package/dist/execution/turn/index.d.ts.map +1 -0
- package/dist/execution/turn/index.js +52 -0
- package/dist/execution/turn/runner/commit.d.ts +11 -0
- package/dist/execution/turn/runner/commit.d.ts.map +1 -0
- package/dist/execution/turn/runner/index.d.ts +16 -0
- package/dist/execution/turn/runner/index.d.ts.map +1 -0
- package/dist/execution/turn/runner/prepare.d.ts +6 -0
- package/dist/execution/turn/runner/prepare.d.ts.map +1 -0
- package/dist/execution/turn/runner/stream-step.d.ts +8 -0
- package/dist/execution/turn/runner/stream-step.d.ts.map +1 -0
- package/dist/execution/turn/runner/tool-batch.d.ts +13 -0
- package/dist/execution/turn/runner/tool-batch.d.ts.map +1 -0
- package/dist/execution/turn/runner/types.d.ts +111 -0
- package/dist/execution/turn/runner/types.d.ts.map +1 -0
- package/dist/execution/turn/state.d.ts +110 -0
- package/dist/execution/turn/state.d.ts.map +1 -0
- package/dist/execution/turn/step-ledger.d.ts +89 -0
- package/dist/execution/turn/step-ledger.d.ts.map +1 -0
- package/dist/execution/turn/step-processing/doom-loop.d.ts +28 -0
- package/dist/execution/turn/step-processing/doom-loop.d.ts.map +1 -0
- package/dist/execution/turn/step-processing/index.d.ts +14 -0
- package/dist/execution/turn/step-processing/index.d.ts.map +1 -0
- package/dist/execution/turn/step-processing/overflow.d.ts +17 -0
- package/dist/execution/turn/step-processing/overflow.d.ts.map +1 -0
- package/dist/execution/turn/step-processing/process.d.ts +7 -0
- package/dist/execution/turn/step-processing/process.d.ts.map +1 -0
- package/dist/execution/turn/step-processing/types.d.ts +65 -0
- package/dist/execution/turn/step-processing/types.d.ts.map +1 -0
- package/dist/execution/workflow/index.d.ts +12 -0
- package/dist/execution/workflow/index.d.ts.map +1 -0
- package/dist/execution/workflow/index.js +39 -0
- package/dist/execution/workflow/planner/apply.d.ts +30 -0
- package/dist/execution/workflow/planner/apply.d.ts.map +1 -0
- package/dist/execution/workflow/planner/helpers.d.ts +6 -0
- package/dist/execution/workflow/planner/helpers.d.ts.map +1 -0
- package/dist/execution/workflow/planner/index.d.ts +13 -0
- package/dist/execution/workflow/planner/index.d.ts.map +1 -0
- package/dist/execution/workflow/planner/plan.d.ts +7 -0
- package/dist/execution/workflow/planner/plan.d.ts.map +1 -0
- package/dist/execution/workflow/planner/types.d.ts +49 -0
- package/dist/execution/workflow/planner/types.d.ts.map +1 -0
- package/dist/execution/workflow/snapshot.d.ts +11 -0
- package/dist/execution/workflow/snapshot.d.ts.map +1 -0
- package/dist/execution/workflow/state.d.ts +161 -0
- package/dist/execution/workflow/state.d.ts.map +1 -0
- package/dist/human/controller.d.ts +24 -0
- package/dist/human/controller.d.ts.map +1 -0
- package/dist/human/handler.d.ts +15 -0
- package/dist/human/handler.d.ts.map +1 -0
- package/dist/human/index.d.ts +5 -0
- package/dist/human/index.d.ts.map +1 -0
- package/dist/human/tool.d.ts +17 -0
- package/dist/human/tool.d.ts.map +1 -0
- package/dist/human/types.d.ts +62 -0
- package/dist/human/types.d.ts.map +1 -0
- package/dist/index.d.ts +66 -567
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2482 -1846
- package/dist/inference/defaults.d.ts +8 -0
- package/dist/inference/defaults.d.ts.map +1 -0
- package/dist/inference/errors/classify.d.ts +5 -0
- package/dist/inference/errors/classify.d.ts.map +1 -0
- package/dist/inference/errors/extract.d.ts +3 -0
- package/dist/inference/errors/extract.d.ts.map +1 -0
- package/dist/inference/errors/index.d.ts +8 -11
- package/dist/inference/errors/index.d.ts.map +1 -0
- package/dist/inference/errors/llm-error.d.ts +14 -0
- package/dist/inference/errors/llm-error.d.ts.map +1 -0
- package/dist/inference/errors/types.d.ts +18 -0
- package/dist/inference/errors/types.d.ts.map +1 -0
- package/dist/inference/errors/utils.d.ts +5 -0
- package/dist/inference/errors/utils.d.ts.map +1 -0
- package/dist/inference/index.d.ts +17 -49
- package/dist/inference/index.d.ts.map +1 -0
- package/dist/inference/index.js +7 -7
- package/dist/inference/middleware-support.d.ts +14 -0
- package/dist/inference/middleware-support.d.ts.map +1 -0
- package/dist/{model-messages-n_ZMZwIm.d.ts → inference/model-messages.d.ts} +4 -6
- package/dist/inference/model-messages.d.ts.map +1 -0
- package/dist/inference/retry.d.ts +73 -0
- package/dist/inference/retry.d.ts.map +1 -0
- package/dist/inference/stream.d.ts +16 -0
- package/dist/inference/stream.d.ts.map +1 -0
- package/dist/inference/toolset.d.ts +26 -0
- package/dist/inference/toolset.d.ts.map +1 -0
- package/dist/inference/types.d.ts +129 -0
- package/dist/inference/types.d.ts.map +1 -0
- package/dist/intervention/follow-up-policy.d.ts +41 -0
- package/dist/intervention/follow-up-policy.d.ts.map +1 -0
- package/dist/intervention/index.d.ts +5 -0
- package/dist/intervention/index.d.ts.map +1 -0
- package/dist/intervention/intervention.d.ts +130 -0
- package/dist/intervention/intervention.d.ts.map +1 -0
- package/dist/intervention/types.d.ts +74 -0
- package/dist/intervention/types.d.ts.map +1 -0
- package/dist/logger/index.d.ts +5 -47
- package/dist/logger/index.d.ts.map +1 -0
- package/dist/logger/logger.d.ts +46 -0
- package/dist/logger/logger.d.ts.map +1 -0
- package/dist/{types-RSCv7nQ4.d.ts → logger/types.d.ts} +6 -7
- package/dist/logger/types.d.ts.map +1 -0
- package/dist/mcp/auth.d.ts +109 -0
- package/dist/mcp/auth.d.ts.map +1 -0
- package/dist/mcp/diagnostics.d.ts +23 -0
- package/dist/mcp/diagnostics.d.ts.map +1 -0
- package/dist/mcp/factories.d.ts +47 -0
- package/dist/mcp/factories.d.ts.map +1 -0
- package/dist/mcp/index.d.ts +14 -175
- package/dist/mcp/index.d.ts.map +1 -0
- package/dist/mcp/index.js +1 -1
- package/dist/mcp/manager.d.ts +45 -0
- package/dist/mcp/manager.d.ts.map +1 -0
- package/dist/mcp/modules.d.ts +6 -0
- package/dist/mcp/modules.d.ts.map +1 -0
- package/dist/{types-DMjoFKKv.d.ts → mcp/types.d.ts} +18 -19
- package/dist/mcp/types.d.ts.map +1 -0
- package/dist/memory/config.d.ts +4 -0
- package/dist/memory/config.d.ts.map +1 -0
- package/dist/memory/format.d.ts +8 -0
- package/dist/memory/format.d.ts.map +1 -0
- package/dist/memory/index.d.ts +5 -0
- package/dist/memory/index.d.ts.map +1 -0
- package/dist/memory/index.js +14 -0
- package/dist/memory/middleware.d.ts +14 -0
- package/dist/memory/middleware.d.ts.map +1 -0
- package/dist/memory/types.d.ts +232 -0
- package/dist/memory/types.d.ts.map +1 -0
- package/dist/middleware/approval.d.ts +70 -0
- package/dist/middleware/approval.d.ts.map +1 -0
- package/dist/middleware/index.d.ts +24 -110
- package/dist/middleware/index.d.ts.map +1 -0
- package/dist/middleware/index.js +2 -2
- package/dist/middleware/prompt-cache/cache.d.ts +44 -0
- package/dist/middleware/prompt-cache/cache.d.ts.map +1 -0
- package/dist/middleware/prompt-cache/index.d.ts +14 -0
- package/dist/middleware/prompt-cache/index.d.ts.map +1 -0
- package/dist/middleware/prompt-cache/types.d.ts +50 -0
- package/dist/middleware/prompt-cache/types.d.ts.map +1 -0
- package/dist/middleware/runner.d.ts +100 -0
- package/dist/middleware/runner.d.ts.map +1 -0
- package/dist/middleware/telemetry/index.d.ts +12 -0
- package/dist/middleware/telemetry/index.d.ts.map +1 -0
- package/dist/middleware/telemetry/otel.d.ts +4 -0
- package/dist/middleware/telemetry/otel.d.ts.map +1 -0
- package/dist/middleware/telemetry/provider.d.ts +3 -0
- package/dist/middleware/telemetry/provider.d.ts.map +1 -0
- package/dist/middleware/telemetry/types.d.ts +150 -0
- package/dist/middleware/telemetry/types.d.ts.map +1 -0
- package/dist/middleware/types.d.ts +371 -0
- package/dist/middleware/types.d.ts.map +1 -0
- package/dist/models/cache/adapters.d.ts +4 -0
- package/dist/models/cache/adapters.d.ts.map +1 -0
- package/dist/models/cache/index.d.ts +5 -0
- package/dist/models/cache/index.d.ts.map +1 -0
- package/dist/models/cache/manager.d.ts +32 -0
- package/dist/models/cache/manager.d.ts.map +1 -0
- package/dist/models/cache/types.d.ts +17 -0
- package/dist/models/cache/types.d.ts.map +1 -0
- package/dist/models/capability-resolver.d.ts +104 -0
- package/dist/models/capability-resolver.d.ts.map +1 -0
- package/dist/models/identifiers.d.ts +23 -0
- package/dist/models/identifiers.d.ts.map +1 -0
- package/dist/models/index.d.ts +35 -256
- package/dist/models/index.d.ts.map +1 -0
- package/dist/models/index.js +1 -1
- package/dist/models/overrides.d.ts +10 -0
- package/dist/models/overrides.d.ts.map +1 -0
- package/dist/models/profiles.d.ts +38 -0
- package/dist/models/profiles.d.ts.map +1 -0
- package/dist/models/reasoning/config.d.ts +49 -0
- package/dist/models/reasoning/config.d.ts.map +1 -0
- package/dist/models/reasoning/index.d.ts +12 -4
- package/dist/models/reasoning/index.d.ts.map +1 -0
- package/dist/models/reasoning/index.js +1 -1
- package/dist/models/reasoning/providers.d.ts +63 -0
- package/dist/models/reasoning/providers.d.ts.map +1 -0
- package/dist/{types-CQaXbRsS.d.ts → models/reasoning/types.d.ts} +7 -8
- package/dist/models/reasoning/types.d.ts.map +1 -0
- package/dist/models/remote/fetcher.d.ts +13 -0
- package/dist/models/remote/fetcher.d.ts.map +1 -0
- package/dist/models/remote/index.d.ts +8 -0
- package/dist/models/remote/index.d.ts.map +1 -0
- package/dist/models/remote/network.d.ts +6 -0
- package/dist/models/remote/network.d.ts.map +1 -0
- package/dist/models/remote/source.d.ts +16 -0
- package/dist/models/remote/source.d.ts.map +1 -0
- package/dist/models/remote/transform.d.ts +4 -0
- package/dist/models/remote/transform.d.ts.map +1 -0
- package/dist/models/remote/types.d.ts +28 -0
- package/dist/models/remote/types.d.ts.map +1 -0
- package/dist/models/resolver.d.ts +26 -0
- package/dist/models/resolver.d.ts.map +1 -0
- package/dist/models/types.d.ts +137 -0
- package/dist/models/types.d.ts.map +1 -0
- package/dist/plugin/compatibility.d.ts +11 -0
- package/dist/plugin/compatibility.d.ts.map +1 -0
- package/dist/plugin/define.d.ts +77 -0
- package/dist/plugin/define.d.ts.map +1 -0
- package/dist/plugin/event-bus.d.ts +31 -0
- package/dist/plugin/event-bus.d.ts.map +1 -0
- package/dist/plugin/index.d.ts +9 -458
- package/dist/plugin/index.d.ts.map +1 -0
- package/dist/plugin/loader.d.ts +63 -0
- package/dist/plugin/loader.d.ts.map +1 -0
- package/dist/plugin/registry.d.ts +81 -0
- package/dist/plugin/registry.d.ts.map +1 -0
- package/dist/plugin/settings.d.ts +36 -0
- package/dist/plugin/settings.d.ts.map +1 -0
- package/dist/plugin/types.d.ts +168 -0
- package/dist/plugin/types.d.ts.map +1 -0
- package/dist/profiles/apply.d.ts +17 -0
- package/dist/profiles/apply.d.ts.map +1 -0
- package/dist/profiles/builtins.d.ts +18 -0
- package/dist/profiles/builtins.d.ts.map +1 -0
- package/dist/profiles/index.d.ts +12 -55
- package/dist/profiles/index.d.ts.map +1 -0
- package/dist/profiles/patterns.d.ts +12 -0
- package/dist/profiles/patterns.d.ts.map +1 -0
- package/dist/profiles/types.d.ts +48 -0
- package/dist/profiles/types.d.ts.map +1 -0
- package/dist/prompt/builder/builder.d.ts +27 -0
- package/dist/prompt/builder/builder.d.ts.map +1 -0
- package/dist/prompt/builder/index.d.ts +11 -0
- package/dist/prompt/builder/index.d.ts.map +1 -0
- package/dist/prompt/builder/priorities.d.ts +13 -0
- package/dist/prompt/builder/priorities.d.ts.map +1 -0
- package/dist/prompt/builder/sections.d.ts +30 -0
- package/dist/prompt/builder/sections.d.ts.map +1 -0
- package/dist/prompt/environment.d.ts +46 -0
- package/dist/prompt/environment.d.ts.map +1 -0
- package/dist/prompt/index.d.ts +31 -220
- package/dist/prompt/index.d.ts.map +1 -0
- package/dist/prompt/index.js +3 -1
- package/dist/prompt/instructions.d.ts +104 -0
- package/dist/prompt/instructions.d.ts.map +1 -0
- package/dist/prompt/templates.d.ts +56 -0
- package/dist/prompt/templates.d.ts.map +1 -0
- package/dist/prompt/types.d.ts +218 -0
- package/dist/prompt/types.d.ts.map +1 -0
- package/dist/safety/errors.d.ts +18 -0
- package/dist/safety/errors.d.ts.map +1 -0
- package/dist/safety/handler.d.ts +16 -0
- package/dist/safety/handler.d.ts.map +1 -0
- package/dist/safety/index.d.ts +11 -133
- package/dist/safety/index.d.ts.map +1 -0
- package/dist/safety/patterns.d.ts +17 -0
- package/dist/safety/patterns.d.ts.map +1 -0
- package/dist/safety/policy.d.ts +31 -0
- package/dist/safety/policy.d.ts.map +1 -0
- package/dist/safety/presets.d.ts +43 -0
- package/dist/safety/presets.d.ts.map +1 -0
- package/dist/safety/risk.d.ts +14 -0
- package/dist/safety/risk.d.ts.map +1 -0
- package/dist/safety/types.d.ts +165 -0
- package/dist/safety/types.d.ts.map +1 -0
- package/dist/sandbox/index.d.ts +2 -81
- package/dist/sandbox/index.d.ts.map +1 -0
- package/dist/sandbox/types.d.ts +79 -0
- package/dist/sandbox/types.d.ts.map +1 -0
- package/dist/skill/discovery/constants.d.ts +6 -0
- package/dist/skill/discovery/constants.d.ts.map +1 -0
- package/dist/skill/discovery/dedupe.d.ts +3 -0
- package/dist/skill/discovery/dedupe.d.ts.map +1 -0
- package/dist/skill/discovery/discover.d.ts +3 -0
- package/dist/skill/discovery/discover.d.ts.map +1 -0
- package/dist/skill/discovery/fs.d.ts +4 -0
- package/dist/skill/discovery/fs.d.ts.map +1 -0
- package/dist/skill/discovery/index.d.ts +6 -0
- package/dist/skill/discovery/index.d.ts.map +1 -0
- package/dist/skill/discovery/scan.d.ts +3 -0
- package/dist/skill/discovery/scan.d.ts.map +1 -0
- package/dist/skill/discovery/types.d.ts +15 -0
- package/dist/skill/discovery/types.d.ts.map +1 -0
- package/dist/skill/index.d.ts +67 -89
- package/dist/skill/index.d.ts.map +1 -0
- package/dist/skill/index.js +2 -2
- package/dist/skill/loader/constants.d.ts +5 -0
- package/dist/skill/loader/constants.d.ts.map +1 -0
- package/dist/skill/loader/frontmatter.d.ts +5 -0
- package/dist/skill/loader/frontmatter.d.ts.map +1 -0
- package/dist/skill/loader/index.d.ts +8 -0
- package/dist/skill/loader/index.d.ts.map +1 -0
- package/dist/skill/loader/metadata.d.ts +3 -0
- package/dist/skill/loader/metadata.d.ts.map +1 -0
- package/dist/skill/loader/resources.d.ts +5 -0
- package/dist/skill/loader/resources.d.ts.map +1 -0
- package/dist/skill/registry.d.ts +177 -0
- package/dist/skill/registry.d.ts.map +1 -0
- package/dist/skill/tools.d.ts +77 -0
- package/dist/skill/tools.d.ts.map +1 -0
- package/dist/skill/types.d.ts +291 -0
- package/dist/skill/types.d.ts.map +1 -0
- package/dist/storage/file/helpers.d.ts +16 -0
- package/dist/storage/file/helpers.d.ts.map +1 -0
- package/dist/storage/file/index.d.ts +6 -0
- package/dist/storage/file/index.d.ts.map +1 -0
- package/dist/storage/file/storage.d.ts +29 -0
- package/dist/storage/file/storage.d.ts.map +1 -0
- package/dist/storage/file/types.d.ts +6 -0
- package/dist/storage/file/types.d.ts.map +1 -0
- package/dist/storage/index.d.ts +11 -188
- package/dist/storage/index.d.ts.map +1 -0
- package/dist/storage/index.js +2 -1
- package/dist/storage/lock.d.ts +18 -0
- package/dist/storage/lock.d.ts.map +1 -0
- package/dist/storage/manager/default.d.ts +11 -0
- package/dist/storage/manager/default.d.ts.map +1 -0
- package/dist/storage/manager/index.d.ts +12 -0
- package/dist/storage/manager/index.d.ts.map +1 -0
- package/dist/storage/manager/session-manager.d.ts +57 -0
- package/dist/storage/manager/session-manager.d.ts.map +1 -0
- package/dist/storage/manager/types.d.ts +42 -0
- package/dist/storage/manager/types.d.ts.map +1 -0
- package/dist/storage/memory.d.ts +22 -0
- package/dist/storage/memory.d.ts.map +1 -0
- package/dist/storage/paths.d.ts +37 -0
- package/dist/storage/paths.d.ts.map +1 -0
- package/dist/storage/types.d.ts +205 -0
- package/dist/storage/types.d.ts.map +1 -0
- package/dist/storage/utils.d.ts +77 -0
- package/dist/storage/utils.d.ts.map +1 -0
- package/dist/subagents/index.d.ts +8 -179
- package/dist/subagents/index.d.ts.map +1 -0
- package/dist/subagents/index.js +5 -4
- package/dist/subagents/installation.d.ts +23 -0
- package/dist/subagents/installation.d.ts.map +1 -0
- package/dist/subagents/results.d.ts +15 -0
- package/dist/subagents/results.d.ts.map +1 -0
- package/dist/subagents/roles/discovery.d.ts +38 -0
- package/dist/subagents/roles/discovery.d.ts.map +1 -0
- package/dist/subagents/roles/index.d.ts +5 -0
- package/dist/subagents/roles/index.d.ts.map +1 -0
- package/dist/subagents/roles/markdown-profile.d.ts +61 -0
- package/dist/subagents/roles/markdown-profile.d.ts.map +1 -0
- package/dist/subagents/tool-factories.d.ts +11 -0
- package/dist/subagents/tool-factories.d.ts.map +1 -0
- package/dist/subagents/tools.d.ts +13 -0
- package/dist/subagents/tools.d.ts.map +1 -0
- package/dist/subagents/types.d.ts +21 -0
- package/dist/subagents/types.d.ts.map +1 -0
- package/dist/team/coordinator/coordinator.d.ts +342 -0
- package/dist/team/coordinator/coordinator.d.ts.map +1 -0
- package/dist/team/coordinator/inbox.d.ts +99 -0
- package/dist/team/coordinator/inbox.d.ts.map +1 -0
- package/dist/team/coordinator/index.d.ts +19 -0
- package/dist/team/coordinator/index.d.ts.map +1 -0
- package/dist/team/coordinator/planning.d.ts +33 -0
- package/dist/team/coordinator/planning.d.ts.map +1 -0
- package/dist/team/coordinator/policy.d.ts +31 -0
- package/dist/team/coordinator/policy.d.ts.map +1 -0
- package/dist/team/coordinator/round-engine.d.ts +25 -0
- package/dist/team/coordinator/round-engine.d.ts.map +1 -0
- package/dist/team/coordinator/synthesis.d.ts +20 -0
- package/dist/team/coordinator/synthesis.d.ts.map +1 -0
- package/dist/team/coordinator/turn.d.ts +107 -0
- package/dist/team/coordinator/turn.d.ts.map +1 -0
- package/dist/team/coordinator/types.d.ts +344 -0
- package/dist/team/coordinator/types.d.ts.map +1 -0
- package/dist/team/events.d.ts +148 -0
- package/dist/team/events.d.ts.map +1 -0
- package/dist/team/execution.d.ts +51 -0
- package/dist/team/execution.d.ts.map +1 -0
- package/dist/team/index.d.ts +23 -545
- package/dist/team/index.d.ts.map +1 -0
- package/dist/team/index.js +2 -2
- package/dist/team/mailbox.d.ts +91 -0
- package/dist/team/mailbox.d.ts.map +1 -0
- package/dist/team/notifications.d.ts +23 -0
- package/dist/team/notifications.d.ts.map +1 -0
- package/dist/team/permissions.d.ts +88 -0
- package/dist/team/permissions.d.ts.map +1 -0
- package/dist/team/shutdown.d.ts +38 -0
- package/dist/team/shutdown.d.ts.map +1 -0
- package/dist/team/task-board.d.ts +161 -0
- package/dist/team/task-board.d.ts.map +1 -0
- package/dist/team/types.d.ts +233 -0
- package/dist/team/types.d.ts.map +1 -0
- package/dist/team/work-loop.d.ts +30 -0
- package/dist/team/work-loop.d.ts.map +1 -0
- package/dist/tool/executor.d.ts +59 -0
- package/dist/tool/executor.d.ts.map +1 -0
- package/dist/tool/host/index.d.ts +7 -38
- package/dist/tool/host/index.d.ts.map +1 -0
- package/dist/tool/host/local.d.ts +15 -0
- package/dist/tool/host/local.d.ts.map +1 -0
- package/dist/tool/host/registry.d.ts +17 -0
- package/dist/tool/host/registry.d.ts.map +1 -0
- package/dist/{types-C_LCeYNg.d.ts → tool/host/types.d.ts} +6 -7
- package/dist/tool/host/types.d.ts.map +1 -0
- package/dist/tool/index.d.ts +21 -285
- package/dist/tool/index.d.ts.map +1 -0
- package/dist/tool/index.js +4 -3
- package/dist/tool/registry.d.ts +130 -0
- package/dist/tool/registry.d.ts.map +1 -0
- package/dist/tool/replay.d.ts +11 -0
- package/dist/tool/replay.d.ts.map +1 -0
- package/dist/tool/tool-search.d.ts +50 -0
- package/dist/tool/tool-search.d.ts.map +1 -0
- package/dist/tool/tool.d.ts +308 -0
- package/dist/tool/tool.d.ts.map +1 -0
- package/dist/tool/truncation.d.ts +34 -0
- package/dist/tool/truncation.d.ts.map +1 -0
- package/dist/tool/turn-tools.d.ts +71 -0
- package/dist/tool/turn-tools.d.ts.map +1 -0
- package/dist/tracking/file-tracking.d.ts +25 -0
- package/dist/tracking/file-tracking.d.ts.map +1 -0
- package/dist/tracking/index.d.ts +9 -0
- package/dist/tracking/index.d.ts.map +1 -0
- package/dist/tracking/turn-tracker/diff.d.ts +11 -0
- package/dist/tracking/turn-tracker/diff.d.ts.map +1 -0
- package/dist/tracking/turn-tracker/index.d.ts +11 -0
- package/dist/tracking/turn-tracker/index.d.ts.map +1 -0
- package/dist/tracking/turn-tracker/tracker.d.ts +31 -0
- package/dist/tracking/turn-tracker/tracker.d.ts.map +1 -0
- package/dist/tracking/turn-tracker/types.d.ts +66 -0
- package/dist/tracking/turn-tracker/types.d.ts.map +1 -0
- package/dist/types/compaction.d.ts +142 -0
- package/dist/types/compaction.d.ts.map +1 -0
- package/dist/types/doom-loop.d.ts +25 -0
- package/dist/types/doom-loop.d.ts.map +1 -0
- package/dist/types/events.d.ts +194 -0
- package/dist/types/events.d.ts.map +1 -0
- package/dist/types/index.d.ts +17 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/messages.d.ts +119 -0
- package/dist/types/messages.d.ts.map +1 -0
- package/dist/types/stream.d.ts +172 -0
- package/dist/types/stream.d.ts.map +1 -0
- package/dist/types/tool.d.ts +309 -0
- package/dist/types/tool.d.ts.map +1 -0
- package/dist/types/turn-source.d.ts +36 -0
- package/dist/types/turn-source.d.ts.map +1 -0
- package/dist/utils/sleep.d.ts +7 -0
- package/dist/utils/sleep.d.ts.map +1 -0
- package/package.json +45 -8
- package/dist/chunk-CJI7PVS2.js +0 -58
- package/dist/chunk-V6ETEYST.js +0 -2091
- package/dist/index-BCqEGzBj.d.ts +0 -251
- package/dist/instance-Bg61WSyz.d.ts +0 -6004
- package/dist/llm-error-D93FNNLY.d.ts +0 -32
- package/dist/turn-tools/index.d.ts +0 -12
- package/dist/turn-tools/index.js +0 -1
- package/dist/{chunk-O2WCYSXQ.js → chunk-3NBTQHVV.js} +0 -0
- package/dist/{chunk-Q742PSH3.js → chunk-MJML3A2F.js} +36 -36
|
@@ -0,0 +1,498 @@
|
|
|
1
|
+
import {
|
|
2
|
+
accumulateUsage,
|
|
3
|
+
cloneUsage,
|
|
4
|
+
mergeAgentTurnStateProgress
|
|
5
|
+
} from "./chunk-E66PKKDL.js";
|
|
6
|
+
|
|
7
|
+
// src/execution/workflow/state.ts
|
|
8
|
+
function cloneMessageSnapshot(message) {
|
|
9
|
+
return {
|
|
10
|
+
...message,
|
|
11
|
+
...message.role === "assistant" && message.toolCalls ? {
|
|
12
|
+
toolCalls: message.toolCalls.map((toolCall) => ({ ...toolCall }))
|
|
13
|
+
} : {},
|
|
14
|
+
...message.role === "assistant" && message.tokens ? {
|
|
15
|
+
tokens: { ...message.tokens }
|
|
16
|
+
} : {},
|
|
17
|
+
...message.role === "assistant" && message.error ? {
|
|
18
|
+
error: { ...message.error }
|
|
19
|
+
} : {},
|
|
20
|
+
...message.role === "tool" && message.metadata ? {
|
|
21
|
+
metadata: structuredClone(message.metadata)
|
|
22
|
+
} : {},
|
|
23
|
+
..."contextFragment" in message && message.contextFragment ? {
|
|
24
|
+
contextFragment: structuredClone(message.contextFragment)
|
|
25
|
+
} : {}
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
function createAgentWorkflowTurnState(options) {
|
|
29
|
+
const pendingInput = options.initialInput ? cloneMessageSnapshot(options.initialInput) : void 0;
|
|
30
|
+
return {
|
|
31
|
+
sessionId: options.sessionId,
|
|
32
|
+
turnId: options.turnId,
|
|
33
|
+
systemPrompts: [...options.systemPrompts ?? []],
|
|
34
|
+
messages: (options.initialMessages ?? []).map(cloneMessageSnapshot),
|
|
35
|
+
phase: pendingInput ? "input-commit" : "model-step",
|
|
36
|
+
...pendingInput ? { pendingInput } : {},
|
|
37
|
+
step: options.initialStep ?? 1,
|
|
38
|
+
maxSteps: options.maxSteps,
|
|
39
|
+
replayDecisions: {},
|
|
40
|
+
startedAt: options.startedAt,
|
|
41
|
+
updatedAt: options.startedAt
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
function cloneAgentWorkflowTurnState(state) {
|
|
45
|
+
return {
|
|
46
|
+
...state,
|
|
47
|
+
systemPrompts: [...state.systemPrompts],
|
|
48
|
+
messages: state.messages.map(cloneMessageSnapshot),
|
|
49
|
+
...state.pendingInput ? {
|
|
50
|
+
pendingInput: cloneMessageSnapshot(
|
|
51
|
+
state.pendingInput
|
|
52
|
+
)
|
|
53
|
+
} : {},
|
|
54
|
+
...state.usage ? { usage: cloneUsage(state.usage) } : {},
|
|
55
|
+
...state.turnState ? { turnState: structuredClone(state.turnState) } : {},
|
|
56
|
+
...state.lastModelStep ? { lastModelStep: structuredClone(state.lastModelStep) } : {},
|
|
57
|
+
...state.lastContextCompaction ? { lastContextCompaction: structuredClone(state.lastContextCompaction) } : {},
|
|
58
|
+
replayDecisions: Object.fromEntries(
|
|
59
|
+
Object.entries(state.replayDecisions).map(([toolCallId, decision]) => [
|
|
60
|
+
toolCallId,
|
|
61
|
+
{ ...decision }
|
|
62
|
+
])
|
|
63
|
+
),
|
|
64
|
+
...state.pendingInterventions?.length ? {
|
|
65
|
+
pendingInterventions: state.pendingInterventions.map(
|
|
66
|
+
(intervention) => ({ ...intervention })
|
|
67
|
+
)
|
|
68
|
+
} : {},
|
|
69
|
+
...state.queuedFollowUps?.length ? {
|
|
70
|
+
queuedFollowUps: state.queuedFollowUps.map((intervention) => ({
|
|
71
|
+
...intervention
|
|
72
|
+
}))
|
|
73
|
+
} : {}
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
function applyWorkflowInterventions(state, interventions, updatedAt) {
|
|
77
|
+
if (interventions.length === 0) {
|
|
78
|
+
return state;
|
|
79
|
+
}
|
|
80
|
+
const injected = interventions.map(
|
|
81
|
+
(intervention) => ({
|
|
82
|
+
id: intervention.id,
|
|
83
|
+
role: "user",
|
|
84
|
+
createdAt: intervention.createdAt,
|
|
85
|
+
content: intervention.message
|
|
86
|
+
})
|
|
87
|
+
);
|
|
88
|
+
return {
|
|
89
|
+
...state,
|
|
90
|
+
messages: [...state.messages, ...injected],
|
|
91
|
+
pendingInterventions: void 0,
|
|
92
|
+
updatedAt
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
function drainWorkflowInterventions(state, updatedAt) {
|
|
96
|
+
if (!state.pendingInterventions?.length) {
|
|
97
|
+
return state;
|
|
98
|
+
}
|
|
99
|
+
return applyWorkflowInterventions(
|
|
100
|
+
state,
|
|
101
|
+
state.pendingInterventions,
|
|
102
|
+
updatedAt
|
|
103
|
+
);
|
|
104
|
+
}
|
|
105
|
+
function queueWorkflowFollowUps(state, followUps, updatedAt) {
|
|
106
|
+
if (followUps.length === 0) {
|
|
107
|
+
return state;
|
|
108
|
+
}
|
|
109
|
+
return {
|
|
110
|
+
...state,
|
|
111
|
+
queuedFollowUps: [
|
|
112
|
+
...state.queuedFollowUps ?? [],
|
|
113
|
+
...followUps.map((followUp) => ({ ...followUp }))
|
|
114
|
+
],
|
|
115
|
+
updatedAt
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
// src/execution/workflow/snapshot.ts
|
|
120
|
+
function snapshotAgentWorkflowMessage(message) {
|
|
121
|
+
switch (message.role) {
|
|
122
|
+
case "user":
|
|
123
|
+
return {
|
|
124
|
+
id: message.id,
|
|
125
|
+
role: "user",
|
|
126
|
+
createdAt: message.createdAt.toISOString(),
|
|
127
|
+
content: message.content,
|
|
128
|
+
...message.contextFragment ? { contextFragment: structuredClone(message.contextFragment) } : {},
|
|
129
|
+
...message.system ? { system: message.system } : {}
|
|
130
|
+
};
|
|
131
|
+
case "assistant":
|
|
132
|
+
return {
|
|
133
|
+
id: message.id,
|
|
134
|
+
role: "assistant",
|
|
135
|
+
createdAt: message.createdAt.toISOString(),
|
|
136
|
+
content: message.content,
|
|
137
|
+
...message.finish ? { finish: message.finish } : {},
|
|
138
|
+
...message.tokens ? { tokens: { ...message.tokens } } : {},
|
|
139
|
+
...message.cost !== void 0 ? { cost: message.cost } : {},
|
|
140
|
+
...message.error ? { error: { ...message.error } } : {},
|
|
141
|
+
...message.toolCalls ? {
|
|
142
|
+
toolCalls: message.toolCalls.map((toolCall) => ({
|
|
143
|
+
toolCallId: toolCall.toolCallId,
|
|
144
|
+
toolName: toolCall.toolName,
|
|
145
|
+
args: toolCall.args
|
|
146
|
+
}))
|
|
147
|
+
} : {}
|
|
148
|
+
};
|
|
149
|
+
case "tool":
|
|
150
|
+
return {
|
|
151
|
+
id: message.id,
|
|
152
|
+
role: "tool",
|
|
153
|
+
createdAt: message.createdAt.toISOString(),
|
|
154
|
+
content: message.content,
|
|
155
|
+
toolCallId: message.toolCallId,
|
|
156
|
+
toolName: message.toolName,
|
|
157
|
+
result: message.result,
|
|
158
|
+
...message.metadata ? { metadata: structuredClone(message.metadata) } : {},
|
|
159
|
+
...message.compactedAt !== void 0 ? { compactedAt: message.compactedAt } : {}
|
|
160
|
+
};
|
|
161
|
+
case "system":
|
|
162
|
+
return {
|
|
163
|
+
id: message.id,
|
|
164
|
+
role: "system",
|
|
165
|
+
createdAt: message.createdAt.toISOString(),
|
|
166
|
+
content: message.content,
|
|
167
|
+
...message.contextFragment ? { contextFragment: structuredClone(message.contextFragment) } : {}
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
function snapshotAgentWorkflowMessages(messages) {
|
|
172
|
+
return messages.map((message) => snapshotAgentWorkflowMessage(message));
|
|
173
|
+
}
|
|
174
|
+
function restoreAgentWorkflowMessage(snapshot) {
|
|
175
|
+
const createdAt = new Date(snapshot.createdAt);
|
|
176
|
+
switch (snapshot.role) {
|
|
177
|
+
case "user":
|
|
178
|
+
return {
|
|
179
|
+
id: snapshot.id,
|
|
180
|
+
role: "user",
|
|
181
|
+
createdAt,
|
|
182
|
+
content: snapshot.content,
|
|
183
|
+
...snapshot.contextFragment ? { contextFragment: structuredClone(snapshot.contextFragment) } : {},
|
|
184
|
+
...snapshot.system ? { system: snapshot.system } : {}
|
|
185
|
+
};
|
|
186
|
+
case "assistant":
|
|
187
|
+
return {
|
|
188
|
+
id: snapshot.id,
|
|
189
|
+
role: "assistant",
|
|
190
|
+
createdAt,
|
|
191
|
+
content: snapshot.content,
|
|
192
|
+
...snapshot.finish ? { finish: snapshot.finish } : {},
|
|
193
|
+
...snapshot.tokens ? { tokens: { ...snapshot.tokens } } : {},
|
|
194
|
+
...snapshot.cost !== void 0 ? { cost: snapshot.cost } : {},
|
|
195
|
+
...snapshot.error ? { error: { ...snapshot.error } } : {},
|
|
196
|
+
...snapshot.toolCalls ? {
|
|
197
|
+
toolCalls: snapshot.toolCalls.map((toolCall) => ({
|
|
198
|
+
toolCallId: toolCall.toolCallId,
|
|
199
|
+
toolName: toolCall.toolName,
|
|
200
|
+
args: toolCall.args
|
|
201
|
+
}))
|
|
202
|
+
} : {}
|
|
203
|
+
};
|
|
204
|
+
case "tool":
|
|
205
|
+
return {
|
|
206
|
+
id: snapshot.id,
|
|
207
|
+
role: "tool",
|
|
208
|
+
createdAt,
|
|
209
|
+
content: snapshot.content,
|
|
210
|
+
toolCallId: snapshot.toolCallId,
|
|
211
|
+
toolName: snapshot.toolName,
|
|
212
|
+
result: snapshot.result,
|
|
213
|
+
...snapshot.metadata ? { metadata: structuredClone(snapshot.metadata) } : {},
|
|
214
|
+
...snapshot.compactedAt !== void 0 ? { compactedAt: snapshot.compactedAt } : {}
|
|
215
|
+
};
|
|
216
|
+
case "system":
|
|
217
|
+
return {
|
|
218
|
+
id: snapshot.id,
|
|
219
|
+
role: "system",
|
|
220
|
+
createdAt,
|
|
221
|
+
content: snapshot.content,
|
|
222
|
+
...snapshot.contextFragment ? { contextFragment: structuredClone(snapshot.contextFragment) } : {}
|
|
223
|
+
};
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
function restoreAgentWorkflowMessages(snapshots) {
|
|
227
|
+
return snapshots.map(restoreAgentWorkflowMessage);
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
// src/execution/workflow/planner/helpers.ts
|
|
231
|
+
function cloneRelevantReplayDecisions(state, snapshot) {
|
|
232
|
+
return Object.fromEntries(
|
|
233
|
+
snapshot.toolCalls.flatMap((toolCall) => {
|
|
234
|
+
const decision = state.replayDecisions[toolCall.toolCallId];
|
|
235
|
+
return decision ? [[toolCall.toolCallId, { ...decision }]] : [];
|
|
236
|
+
})
|
|
237
|
+
);
|
|
238
|
+
}
|
|
239
|
+
function findAllUnresolvedToolCalls(snapshot) {
|
|
240
|
+
const resolvedIds = new Set(
|
|
241
|
+
snapshot.toolResults.map((toolResult) => toolResult.toolCallId)
|
|
242
|
+
);
|
|
243
|
+
return snapshot.toolCalls.filter(
|
|
244
|
+
(toolCall) => !resolvedIds.has(toolCall.toolCallId)
|
|
245
|
+
);
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
// src/execution/workflow/planner/plan.ts
|
|
249
|
+
function planNextAgentWorkflowOperation(state) {
|
|
250
|
+
switch (state.phase) {
|
|
251
|
+
case "input-commit":
|
|
252
|
+
if (!state.pendingInput) {
|
|
253
|
+
throw new Error(
|
|
254
|
+
`Workflow state for session '${state.sessionId}' is in input-commit phase without a pending input message`
|
|
255
|
+
);
|
|
256
|
+
}
|
|
257
|
+
return {
|
|
258
|
+
kind: "input-commit",
|
|
259
|
+
sessionId: state.sessionId,
|
|
260
|
+
messages: [structuredClone(state.pendingInput)]
|
|
261
|
+
};
|
|
262
|
+
case "model-step":
|
|
263
|
+
return {
|
|
264
|
+
kind: "model-step",
|
|
265
|
+
sessionId: state.sessionId,
|
|
266
|
+
turnId: state.turnId,
|
|
267
|
+
step: state.step,
|
|
268
|
+
maxSteps: state.maxSteps,
|
|
269
|
+
systemPrompts: [...state.systemPrompts],
|
|
270
|
+
messages: state.messages.map((message) => structuredClone(message)),
|
|
271
|
+
...state.lastContextCompaction ? { contextCompaction: structuredClone(state.lastContextCompaction) } : {}
|
|
272
|
+
};
|
|
273
|
+
case "tool-batch": {
|
|
274
|
+
if (!state.lastModelStep?.stepCommit) {
|
|
275
|
+
throw new Error(
|
|
276
|
+
`Workflow state for session '${state.sessionId}' is in tool-batch phase without a stepCommit snapshot`
|
|
277
|
+
);
|
|
278
|
+
}
|
|
279
|
+
const allUnresolved = findAllUnresolvedToolCalls(
|
|
280
|
+
state.lastModelStep.stepCommit
|
|
281
|
+
);
|
|
282
|
+
if (allUnresolved.length === 0) {
|
|
283
|
+
throw new Error(
|
|
284
|
+
`Workflow state for session '${state.sessionId}' is in tool-batch phase without unresolved tool calls`
|
|
285
|
+
);
|
|
286
|
+
}
|
|
287
|
+
if (allUnresolved.length === 1) {
|
|
288
|
+
return {
|
|
289
|
+
kind: "tool-call",
|
|
290
|
+
step: state.step,
|
|
291
|
+
sessionId: state.sessionId,
|
|
292
|
+
toolCall: structuredClone(allUnresolved[0]),
|
|
293
|
+
turnState: state.turnState ? structuredClone(state.turnState) : void 0,
|
|
294
|
+
replayDecision: cloneRelevantReplayDecisions(
|
|
295
|
+
state,
|
|
296
|
+
state.lastModelStep.stepCommit
|
|
297
|
+
)[allUnresolved[0].toolCallId]
|
|
298
|
+
};
|
|
299
|
+
}
|
|
300
|
+
return {
|
|
301
|
+
kind: "tool-batch",
|
|
302
|
+
step: state.step,
|
|
303
|
+
sessionId: state.sessionId,
|
|
304
|
+
toolCalls: allUnresolved.map((tc) => structuredClone(tc)),
|
|
305
|
+
turnState: state.turnState ? structuredClone(state.turnState) : void 0,
|
|
306
|
+
replayDecisions: cloneRelevantReplayDecisions(
|
|
307
|
+
state,
|
|
308
|
+
state.lastModelStep.stepCommit
|
|
309
|
+
)
|
|
310
|
+
};
|
|
311
|
+
}
|
|
312
|
+
case "step-commit":
|
|
313
|
+
if (!state.lastModelStep?.stepCommit) {
|
|
314
|
+
throw new Error(
|
|
315
|
+
`Workflow state for session '${state.sessionId}' is in step-commit phase without a stepCommit snapshot`
|
|
316
|
+
);
|
|
317
|
+
}
|
|
318
|
+
return {
|
|
319
|
+
kind: "step-commit",
|
|
320
|
+
sessionId: state.sessionId,
|
|
321
|
+
step: state.step,
|
|
322
|
+
snapshot: structuredClone(state.lastModelStep.stepCommit)
|
|
323
|
+
};
|
|
324
|
+
case "output-commit":
|
|
325
|
+
if (!state.lastModelStep) {
|
|
326
|
+
throw new Error(
|
|
327
|
+
`Workflow state for session '${state.sessionId}' is in output-commit phase without a last model step`
|
|
328
|
+
);
|
|
329
|
+
}
|
|
330
|
+
return {
|
|
331
|
+
kind: "output-commit",
|
|
332
|
+
sessionId: state.sessionId,
|
|
333
|
+
text: state.lastModelStep.text,
|
|
334
|
+
...state.lastModelStep.usage ? { usage: { ...state.lastModelStep.usage } } : {}
|
|
335
|
+
};
|
|
336
|
+
case "completed":
|
|
337
|
+
case "failed":
|
|
338
|
+
return void 0;
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
// src/execution/workflow/planner/apply.ts
|
|
343
|
+
function applyAgentWorkflowContextCompactionResult(state, result, updatedAt) {
|
|
344
|
+
if (state.phase !== "model-step") {
|
|
345
|
+
throw new Error(
|
|
346
|
+
`Cannot apply context compaction while workflow state is in '${state.phase}' phase`
|
|
347
|
+
);
|
|
348
|
+
}
|
|
349
|
+
const next = cloneAgentWorkflowTurnState(state);
|
|
350
|
+
next.lastContextCompaction = {
|
|
351
|
+
applied: result.compacted,
|
|
352
|
+
phase: "pre-step",
|
|
353
|
+
inputTokens: result.inputTokens,
|
|
354
|
+
limit: result.limit,
|
|
355
|
+
decision: result.decision,
|
|
356
|
+
effectiveness: result.effectiveness,
|
|
357
|
+
removedCount: result.removedCount,
|
|
358
|
+
tokensRemoved: result.tokensRemoved,
|
|
359
|
+
summarized: result.summarized,
|
|
360
|
+
...result.cutIndex !== void 0 ? { cutIndex: result.cutIndex } : {},
|
|
361
|
+
...result.cutReason ? { cutReason: result.cutReason } : {}
|
|
362
|
+
};
|
|
363
|
+
if (result.compacted) {
|
|
364
|
+
next.messages = result.messages.map((message) => structuredClone(message));
|
|
365
|
+
}
|
|
366
|
+
next.updatedAt = updatedAt;
|
|
367
|
+
return next;
|
|
368
|
+
}
|
|
369
|
+
function applyAgentWorkflowModelStepResult(state, result, updatedAt) {
|
|
370
|
+
const next = cloneAgentWorkflowTurnState(state);
|
|
371
|
+
next.lastModelStep = structuredClone(result);
|
|
372
|
+
next.turnState = structuredClone(result.turnState);
|
|
373
|
+
next.usage = accumulateUsage(next.usage, result.usage);
|
|
374
|
+
next.updatedAt = updatedAt;
|
|
375
|
+
next.phase = result.finishReason === "tool-calls" ? "tool-batch" : "output-commit";
|
|
376
|
+
return next;
|
|
377
|
+
}
|
|
378
|
+
function applyAgentWorkflowToolBatchResult(state, result, updatedAt) {
|
|
379
|
+
if (state.phase !== "tool-batch") {
|
|
380
|
+
throw new Error(
|
|
381
|
+
`Cannot apply a tool-batch result while workflow state is in '${state.phase}' phase`
|
|
382
|
+
);
|
|
383
|
+
}
|
|
384
|
+
const next = cloneAgentWorkflowTurnState(state);
|
|
385
|
+
next.updatedAt = updatedAt;
|
|
386
|
+
next.phase = "step-commit";
|
|
387
|
+
if (!next.lastModelStep) {
|
|
388
|
+
throw new Error(
|
|
389
|
+
`Workflow state for session '${state.sessionId}' has no model step to update after tool-batch`
|
|
390
|
+
);
|
|
391
|
+
}
|
|
392
|
+
next.lastModelStep.stepCommit = structuredClone(result.stepCommit);
|
|
393
|
+
if (result.turnState) {
|
|
394
|
+
next.turnState = mergeAgentTurnStateProgress(
|
|
395
|
+
next.turnState,
|
|
396
|
+
result.turnState
|
|
397
|
+
);
|
|
398
|
+
}
|
|
399
|
+
return next;
|
|
400
|
+
}
|
|
401
|
+
function applyAgentWorkflowToolCallResult(state, result, updatedAt) {
|
|
402
|
+
if (state.phase !== "tool-batch") {
|
|
403
|
+
throw new Error(
|
|
404
|
+
`Cannot apply a tool-call result while workflow state is in '${state.phase}' phase`
|
|
405
|
+
);
|
|
406
|
+
}
|
|
407
|
+
if (!state.lastModelStep?.stepCommit) {
|
|
408
|
+
throw new Error(
|
|
409
|
+
`Workflow state for session '${state.sessionId}' has no stepCommit snapshot in tool-batch phase`
|
|
410
|
+
);
|
|
411
|
+
}
|
|
412
|
+
const next = cloneAgentWorkflowTurnState(state);
|
|
413
|
+
const snapshot = structuredClone(state.lastModelStep.stepCommit);
|
|
414
|
+
const existingResultIndex = snapshot.toolResults.findIndex(
|
|
415
|
+
(toolResult) => toolResult.toolCallId === result.toolResult.toolCallId
|
|
416
|
+
);
|
|
417
|
+
if (existingResultIndex >= 0) {
|
|
418
|
+
snapshot.toolResults[existingResultIndex] = structuredClone(
|
|
419
|
+
result.toolResult
|
|
420
|
+
);
|
|
421
|
+
} else {
|
|
422
|
+
snapshot.toolResults.push(structuredClone(result.toolResult));
|
|
423
|
+
}
|
|
424
|
+
next.lastModelStep = {
|
|
425
|
+
...next.lastModelStep,
|
|
426
|
+
stepCommit: snapshot
|
|
427
|
+
};
|
|
428
|
+
next.updatedAt = updatedAt;
|
|
429
|
+
if (result.turnState) {
|
|
430
|
+
next.turnState = mergeAgentTurnStateProgress(
|
|
431
|
+
next.turnState,
|
|
432
|
+
result.turnState
|
|
433
|
+
);
|
|
434
|
+
}
|
|
435
|
+
next.phase = snapshot.toolResults.length >= snapshot.toolCalls.length ? "step-commit" : "tool-batch";
|
|
436
|
+
return next;
|
|
437
|
+
}
|
|
438
|
+
function applyAgentWorkflowCommitResult(state, result, updatedAt) {
|
|
439
|
+
const next = cloneAgentWorkflowTurnState(state);
|
|
440
|
+
next.messages = [
|
|
441
|
+
...next.messages,
|
|
442
|
+
...result.messages.map((message) => structuredClone(message))
|
|
443
|
+
];
|
|
444
|
+
next.updatedAt = updatedAt;
|
|
445
|
+
switch (state.phase) {
|
|
446
|
+
case "input-commit":
|
|
447
|
+
next.phase = "model-step";
|
|
448
|
+
delete next.pendingInput;
|
|
449
|
+
return next;
|
|
450
|
+
case "step-commit":
|
|
451
|
+
next.step = state.step + 1;
|
|
452
|
+
next.phase = "model-step";
|
|
453
|
+
delete next.lastModelStep;
|
|
454
|
+
return next;
|
|
455
|
+
case "output-commit":
|
|
456
|
+
next.phase = "completed";
|
|
457
|
+
next.finalResponse = state.lastModelStep?.text ?? state.finalResponse;
|
|
458
|
+
delete next.lastModelStep;
|
|
459
|
+
return next;
|
|
460
|
+
default:
|
|
461
|
+
throw new Error(
|
|
462
|
+
`Cannot apply a commit result while workflow state is in '${state.phase}' phase`
|
|
463
|
+
);
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
function recordAgentWorkflowReplayDecision(state, decision, updatedAt) {
|
|
467
|
+
const next = cloneAgentWorkflowTurnState(state);
|
|
468
|
+
next.replayDecisions[decision.toolCallId] = { ...decision };
|
|
469
|
+
next.updatedAt = updatedAt;
|
|
470
|
+
return next;
|
|
471
|
+
}
|
|
472
|
+
function failAgentWorkflowTurnState(state, error, updatedAt) {
|
|
473
|
+
const next = cloneAgentWorkflowTurnState(state);
|
|
474
|
+
next.phase = "failed";
|
|
475
|
+
next.error = error.message;
|
|
476
|
+
next.updatedAt = updatedAt;
|
|
477
|
+
return next;
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
export {
|
|
481
|
+
createAgentWorkflowTurnState,
|
|
482
|
+
cloneAgentWorkflowTurnState,
|
|
483
|
+
applyWorkflowInterventions,
|
|
484
|
+
drainWorkflowInterventions,
|
|
485
|
+
queueWorkflowFollowUps,
|
|
486
|
+
snapshotAgentWorkflowMessage,
|
|
487
|
+
snapshotAgentWorkflowMessages,
|
|
488
|
+
restoreAgentWorkflowMessage,
|
|
489
|
+
restoreAgentWorkflowMessages,
|
|
490
|
+
planNextAgentWorkflowOperation,
|
|
491
|
+
applyAgentWorkflowContextCompactionResult,
|
|
492
|
+
applyAgentWorkflowModelStepResult,
|
|
493
|
+
applyAgentWorkflowToolBatchResult,
|
|
494
|
+
applyAgentWorkflowToolCallResult,
|
|
495
|
+
applyAgentWorkflowCommitResult,
|
|
496
|
+
recordAgentWorkflowReplayDecision,
|
|
497
|
+
failAgentWorkflowTurnState
|
|
498
|
+
};
|