@cuylabs/agent-core 4.8.1 → 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
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Tool
|
|
3
|
-
} from "./chunk-Q742PSH3.js";
|
|
4
1
|
import {
|
|
5
2
|
buildEntryPath,
|
|
6
3
|
deserializeMessage
|
|
7
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-VMGZKIFT.js";
|
|
5
|
+
import {
|
|
6
|
+
Tool
|
|
7
|
+
} from "./chunk-MJML3A2F.js";
|
|
8
8
|
|
|
9
9
|
// src/agent/session.ts
|
|
10
10
|
async function ensureSessionLoaded(options) {
|
|
@@ -67,14 +67,17 @@ function getVisibleSessionMessages(sessions) {
|
|
|
67
67
|
let skipUntilId;
|
|
68
68
|
for (const entry of path) {
|
|
69
69
|
if (entry.type === "compaction") {
|
|
70
|
-
visible.
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
70
|
+
visible.length = 0;
|
|
71
|
+
if (entry.displaySummary !== false) {
|
|
72
|
+
visible.push({
|
|
73
|
+
id: entry.id,
|
|
74
|
+
role: "system",
|
|
75
|
+
content: `## Previous Conversation Summary
|
|
74
76
|
|
|
75
77
|
${entry.summary}`,
|
|
76
|
-
|
|
77
|
-
|
|
78
|
+
createdAt: new Date(entry.timestamp)
|
|
79
|
+
});
|
|
80
|
+
}
|
|
78
81
|
skipUntilId = entry.firstKeptEntryId !== entry.id ? entry.firstKeptEntryId : void 0;
|
|
79
82
|
continue;
|
|
80
83
|
}
|
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
// src/memory/config.ts
|
|
2
|
+
function isMemoryConfig(input) {
|
|
3
|
+
return "provider" in input;
|
|
4
|
+
}
|
|
5
|
+
function resolveAgentMemoryConfig(input) {
|
|
6
|
+
if (!input) return void 0;
|
|
7
|
+
const config = isMemoryConfig(input) ? input : { provider: input };
|
|
8
|
+
const recall = typeof config.recall === "object" ? config.recall : { enabled: config.recall !== false };
|
|
9
|
+
const tools = typeof config.tools === "object" ? config.tools : { enabled: config.tools !== false };
|
|
10
|
+
return {
|
|
11
|
+
provider: config.provider,
|
|
12
|
+
recall: {
|
|
13
|
+
enabled: recall.enabled ?? true,
|
|
14
|
+
frequency: recall.frequency ?? "per-turn",
|
|
15
|
+
limit: recall.limit ?? 5,
|
|
16
|
+
maxRecords: recall.maxRecords ?? recall.limit ?? 5,
|
|
17
|
+
maxRecordChars: recall.maxRecordChars ?? 700
|
|
18
|
+
},
|
|
19
|
+
turns: resolveAgentMemoryTurnConfig(config.turns),
|
|
20
|
+
tools: {
|
|
21
|
+
enabled: tools.enabled ?? true,
|
|
22
|
+
deferred: tools.deferred ?? false
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
function resolveAgentMemoryTurnConfig(input) {
|
|
27
|
+
const turns = input && typeof input === "object" ? input : { enabled: input !== false };
|
|
28
|
+
return {
|
|
29
|
+
enabled: turns.enabled ?? true,
|
|
30
|
+
contextMessageLimit: resolveContextMessageLimit(turns.contextMessageLimit)
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
function resolveContextMessageLimit(value) {
|
|
34
|
+
if (value === void 0) return 0;
|
|
35
|
+
if (!Number.isFinite(value)) return 0;
|
|
36
|
+
return Math.max(0, Math.floor(value));
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// src/memory/format.ts
|
|
40
|
+
function normalizeMemoryRecords(result) {
|
|
41
|
+
if (!result) return [];
|
|
42
|
+
if (Array.isArray(result)) return result;
|
|
43
|
+
return result.records ?? [];
|
|
44
|
+
}
|
|
45
|
+
function truncateText(text, maxChars) {
|
|
46
|
+
if (text.length <= maxChars) return text;
|
|
47
|
+
return `${text.slice(0, Math.max(0, maxChars - 1)).trimEnd()}...`;
|
|
48
|
+
}
|
|
49
|
+
function formatMemoryRecord(record, maxRecordChars) {
|
|
50
|
+
const label = record.title?.trim() || record.kind || record.id;
|
|
51
|
+
const scope = record.scope ? ` [${record.scope}]` : "";
|
|
52
|
+
const tags = record.tags && record.tags.length > 0 ? ` (${record.tags.join(", ")})` : "";
|
|
53
|
+
return `- ${label}${scope}${tags}: ${truncateText(record.content.trim(), maxRecordChars)}`;
|
|
54
|
+
}
|
|
55
|
+
function formatMemoryContextFragment(options) {
|
|
56
|
+
const lines = [
|
|
57
|
+
"Relevant memory recalled for this step. Use it only when it helps answer the current user request."
|
|
58
|
+
];
|
|
59
|
+
if (options.instructions?.trim()) {
|
|
60
|
+
lines.push("", options.instructions.trim());
|
|
61
|
+
}
|
|
62
|
+
lines.push(
|
|
63
|
+
"",
|
|
64
|
+
...options.records.map(
|
|
65
|
+
(record) => formatMemoryRecord(record, options.maxRecordChars)
|
|
66
|
+
)
|
|
67
|
+
);
|
|
68
|
+
return lines.join("\n");
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// src/memory/middleware.ts
|
|
72
|
+
function latestRealUserMessage(messages) {
|
|
73
|
+
for (let index = messages.length - 1; index >= 0; index--) {
|
|
74
|
+
const message = messages[index];
|
|
75
|
+
if (message?.role === "user" && !message.contextFragment) {
|
|
76
|
+
return message.content;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
return "";
|
|
80
|
+
}
|
|
81
|
+
function turnKey(sessionId, turnId) {
|
|
82
|
+
return `${sessionId}:${turnId ?? "latest"}`;
|
|
83
|
+
}
|
|
84
|
+
function recallKey(options) {
|
|
85
|
+
return `${options.sessionId}:${options.turnId ?? options.query}`;
|
|
86
|
+
}
|
|
87
|
+
function removeLatestMatchingMessage(messages, role, content) {
|
|
88
|
+
if (content === void 0) return [...messages];
|
|
89
|
+
const next = [...messages];
|
|
90
|
+
for (let index = next.length - 1; index >= 0; index--) {
|
|
91
|
+
const message = next[index];
|
|
92
|
+
if (message?.role === role && message.content === content) {
|
|
93
|
+
next.splice(index, 1);
|
|
94
|
+
break;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
return next;
|
|
98
|
+
}
|
|
99
|
+
function collectTurnContextMessages(options) {
|
|
100
|
+
if (!options.history || options.limit <= 0) return [];
|
|
101
|
+
const currentTurnMessageAllowance = 1 + (options.output !== void 0 ? 1 : 0);
|
|
102
|
+
const messages = options.history.getRecentMessages({
|
|
103
|
+
limit: options.limit + currentTurnMessageAllowance
|
|
104
|
+
});
|
|
105
|
+
const withoutCurrentInput = removeLatestMatchingMessage(
|
|
106
|
+
messages,
|
|
107
|
+
"user",
|
|
108
|
+
options.input
|
|
109
|
+
);
|
|
110
|
+
const withoutCurrentTurn = removeLatestMatchingMessage(
|
|
111
|
+
withoutCurrentInput,
|
|
112
|
+
"assistant",
|
|
113
|
+
options.output
|
|
114
|
+
);
|
|
115
|
+
return withoutCurrentTurn.slice(-options.limit);
|
|
116
|
+
}
|
|
117
|
+
async function notifyTurnStart(options) {
|
|
118
|
+
if (!options.provider.onTurnStart) return;
|
|
119
|
+
await options.provider.onTurnStart({
|
|
120
|
+
sessionId: options.sessionId,
|
|
121
|
+
...options.turnId ? { turnId: options.turnId } : {},
|
|
122
|
+
cwd: options.cwd,
|
|
123
|
+
input: options.input,
|
|
124
|
+
messages: options.messages
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
async function notifyTurnEnd(options) {
|
|
128
|
+
if (!options.provider.onTurnEnd) return;
|
|
129
|
+
const input = {
|
|
130
|
+
sessionId: options.sessionId,
|
|
131
|
+
...options.turnId ? { turnId: options.turnId } : {},
|
|
132
|
+
cwd: options.cwd,
|
|
133
|
+
input: options.input,
|
|
134
|
+
...options.output !== void 0 ? { output: options.output } : {},
|
|
135
|
+
...options.error ? { error: options.error } : {},
|
|
136
|
+
...options.usage ? { usage: options.usage } : {},
|
|
137
|
+
messages: options.messages
|
|
138
|
+
};
|
|
139
|
+
await options.provider.onTurnEnd(input);
|
|
140
|
+
}
|
|
141
|
+
function createMemoryMiddleware(options) {
|
|
142
|
+
const activeInputs = /* @__PURE__ */ new Map();
|
|
143
|
+
const recallCache = /* @__PURE__ */ new Map();
|
|
144
|
+
const turns = resolveAgentMemoryTurnConfig(options.turns);
|
|
145
|
+
const recallFrequency = options.recall.frequency ?? "per-turn";
|
|
146
|
+
return {
|
|
147
|
+
name: `memory:${options.provider.id}`,
|
|
148
|
+
async contextFragments(ctx) {
|
|
149
|
+
if (!options.recall.enabled || !options.provider.recall) return void 0;
|
|
150
|
+
const query = latestRealUserMessage(ctx.messages);
|
|
151
|
+
if (query.trim().length === 0) return void 0;
|
|
152
|
+
const cacheKey = recallKey({
|
|
153
|
+
sessionId: ctx.sessionId,
|
|
154
|
+
...ctx.turnId ? { turnId: ctx.turnId } : {},
|
|
155
|
+
query
|
|
156
|
+
});
|
|
157
|
+
let response;
|
|
158
|
+
if (recallFrequency === "per-turn" && recallCache.has(cacheKey)) {
|
|
159
|
+
response = recallCache.get(cacheKey);
|
|
160
|
+
} else {
|
|
161
|
+
response = await options.provider.recall({
|
|
162
|
+
sessionId: ctx.sessionId,
|
|
163
|
+
...ctx.turnId ? { turnId: ctx.turnId } : {},
|
|
164
|
+
step: ctx.step,
|
|
165
|
+
cwd: ctx.cwd,
|
|
166
|
+
query,
|
|
167
|
+
messages: ctx.messages,
|
|
168
|
+
limit: options.recall.limit,
|
|
169
|
+
toolNames: ctx.toolNames,
|
|
170
|
+
mcpToolNames: ctx.mcpToolNames,
|
|
171
|
+
...ctx.abort ? { abort: ctx.abort } : {}
|
|
172
|
+
});
|
|
173
|
+
if (recallFrequency === "per-turn") {
|
|
174
|
+
recallCache.set(cacheKey, response);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
const records = normalizeMemoryRecords(response).slice(
|
|
178
|
+
0,
|
|
179
|
+
options.recall.maxRecords
|
|
180
|
+
);
|
|
181
|
+
if (records.length === 0) return void 0;
|
|
182
|
+
const instructions = response && !Array.isArray(response) ? response.instructions : void 0;
|
|
183
|
+
return {
|
|
184
|
+
kind: "memory",
|
|
185
|
+
title: "Relevant Memory",
|
|
186
|
+
source: options.provider.id,
|
|
187
|
+
placement: "after-latest-user",
|
|
188
|
+
lifetime: "turn",
|
|
189
|
+
budgetBehavior: "droppable",
|
|
190
|
+
dedupeKey: `memory:${options.provider.id}:recall`,
|
|
191
|
+
content: formatMemoryContextFragment({
|
|
192
|
+
records,
|
|
193
|
+
instructions,
|
|
194
|
+
maxRecordChars: options.recall.maxRecordChars
|
|
195
|
+
}),
|
|
196
|
+
metadata: {
|
|
197
|
+
providerId: options.provider.id,
|
|
198
|
+
recordIds: records.map((record) => record.id)
|
|
199
|
+
}
|
|
200
|
+
};
|
|
201
|
+
},
|
|
202
|
+
async onChatStart(sessionId, message, ctx) {
|
|
203
|
+
activeInputs.set(turnKey(sessionId, ctx?.turnId), message);
|
|
204
|
+
if (!turns.enabled) return;
|
|
205
|
+
await notifyTurnStart({
|
|
206
|
+
provider: options.provider,
|
|
207
|
+
sessionId,
|
|
208
|
+
...ctx?.turnId ? { turnId: ctx.turnId } : {},
|
|
209
|
+
cwd: options.cwd ?? process.cwd(),
|
|
210
|
+
input: message,
|
|
211
|
+
messages: collectTurnContextMessages({
|
|
212
|
+
history: ctx?.history,
|
|
213
|
+
limit: turns.contextMessageLimit,
|
|
214
|
+
input: message
|
|
215
|
+
})
|
|
216
|
+
});
|
|
217
|
+
},
|
|
218
|
+
async onChatEnd(sessionId, result, ctx) {
|
|
219
|
+
const key = turnKey(sessionId, ctx?.turnId);
|
|
220
|
+
const input = activeInputs.get(key);
|
|
221
|
+
activeInputs.delete(key);
|
|
222
|
+
if (!input) return;
|
|
223
|
+
recallCache.delete(
|
|
224
|
+
recallKey({
|
|
225
|
+
sessionId,
|
|
226
|
+
...ctx?.turnId ? { turnId: ctx.turnId } : {},
|
|
227
|
+
query: input
|
|
228
|
+
})
|
|
229
|
+
);
|
|
230
|
+
if (!turns.enabled) return;
|
|
231
|
+
await notifyTurnEnd({
|
|
232
|
+
provider: options.provider,
|
|
233
|
+
sessionId,
|
|
234
|
+
...ctx?.turnId ? { turnId: ctx.turnId } : {},
|
|
235
|
+
cwd: options.cwd ?? process.cwd(),
|
|
236
|
+
input,
|
|
237
|
+
...result.output !== void 0 ? { output: result.output } : {},
|
|
238
|
+
...result.error ? { error: result.error } : {},
|
|
239
|
+
...result.usage ? { usage: result.usage } : {},
|
|
240
|
+
messages: collectTurnContextMessages({
|
|
241
|
+
history: ctx?.history,
|
|
242
|
+
limit: turns.contextMessageLimit,
|
|
243
|
+
input,
|
|
244
|
+
...result.output !== void 0 ? { output: result.output } : {}
|
|
245
|
+
})
|
|
246
|
+
});
|
|
247
|
+
}
|
|
248
|
+
};
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
export {
|
|
252
|
+
resolveAgentMemoryConfig,
|
|
253
|
+
resolveAgentMemoryTurnConfig,
|
|
254
|
+
normalizeMemoryRecords,
|
|
255
|
+
formatMemoryContextFragment,
|
|
256
|
+
createMemoryMiddleware
|
|
257
|
+
};
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import {
|
|
2
|
+
applyAgentContextFragmentsWithReport
|
|
3
|
+
} from "./chunk-AAGKWUXR.js";
|
|
4
|
+
|
|
5
|
+
// src/context/assembly/prepare.ts
|
|
6
|
+
var DEFAULT_CONTEXT_FRAGMENT_BUDGET_RATIO = 0.1;
|
|
7
|
+
var DEFAULT_MAX_CONTEXT_FRAGMENT_ESTIMATED_TOKENS = 8e3;
|
|
8
|
+
var DEFAULT_MIN_CONTEXT_FRAGMENT_ESTIMATED_TOKENS = 512;
|
|
9
|
+
async function collectRequestedContextFragments(options) {
|
|
10
|
+
const explicitContextFragments = [...options.contextFragments ?? []];
|
|
11
|
+
const collector = options.contextFragmentCollector;
|
|
12
|
+
if (!collector || collector.hasMiddleware === false) {
|
|
13
|
+
return explicitContextFragments;
|
|
14
|
+
}
|
|
15
|
+
const collected = await collector.collectContextFragments({
|
|
16
|
+
sessionId: options.sessionId,
|
|
17
|
+
...options.turnId ? { turnId: options.turnId } : {},
|
|
18
|
+
step: options.step,
|
|
19
|
+
cwd: options.cwd,
|
|
20
|
+
messages: options.messages,
|
|
21
|
+
toolNames: options.toolNames ?? [],
|
|
22
|
+
mcpToolNames: options.mcpToolNames ?? [],
|
|
23
|
+
...options.abort ? { abort: options.abort } : {}
|
|
24
|
+
});
|
|
25
|
+
return [...explicitContextFragments, ...collected];
|
|
26
|
+
}
|
|
27
|
+
function normalizeMaxEstimatedTokens(value) {
|
|
28
|
+
if (value === void 0 || !Number.isFinite(value)) return void 0;
|
|
29
|
+
return Math.max(0, Math.floor(value));
|
|
30
|
+
}
|
|
31
|
+
function resolveContextFragmentBudget(options) {
|
|
32
|
+
const configuredMaxEstimatedTokens = normalizeMaxEstimatedTokens(
|
|
33
|
+
options.configured?.maxEstimatedTokens
|
|
34
|
+
);
|
|
35
|
+
if (configuredMaxEstimatedTokens !== void 0) {
|
|
36
|
+
return { maxEstimatedTokens: configuredMaxEstimatedTokens };
|
|
37
|
+
}
|
|
38
|
+
if (!options.windowBefore) return void 0;
|
|
39
|
+
const proportional = Math.floor(
|
|
40
|
+
options.windowBefore.limit * DEFAULT_CONTEXT_FRAGMENT_BUDGET_RATIO
|
|
41
|
+
);
|
|
42
|
+
return {
|
|
43
|
+
maxEstimatedTokens: Math.min(
|
|
44
|
+
DEFAULT_MAX_CONTEXT_FRAGMENT_ESTIMATED_TOKENS,
|
|
45
|
+
Math.max(DEFAULT_MIN_CONTEXT_FRAGMENT_ESTIMATED_TOKENS, proportional)
|
|
46
|
+
)
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
async function assembleModelContext(options) {
|
|
50
|
+
const baseMessages = [...options.messages];
|
|
51
|
+
const windowBefore = options.window?.getStats(baseMessages);
|
|
52
|
+
const requestedContextFragments = await collectRequestedContextFragments(options);
|
|
53
|
+
const contextFragmentBudget = resolveContextFragmentBudget({
|
|
54
|
+
configured: options.contextFragmentBudget,
|
|
55
|
+
windowBefore
|
|
56
|
+
});
|
|
57
|
+
const contextFragmentResult = applyAgentContextFragmentsWithReport(
|
|
58
|
+
baseMessages,
|
|
59
|
+
requestedContextFragments,
|
|
60
|
+
contextFragmentBudget ? { budget: contextFragmentBudget } : {}
|
|
61
|
+
);
|
|
62
|
+
const messages = contextFragmentResult.messages;
|
|
63
|
+
const windowAfter = options.window?.getStats(messages);
|
|
64
|
+
const report = {
|
|
65
|
+
sessionId: options.sessionId,
|
|
66
|
+
...options.turnId ? { turnId: options.turnId } : {},
|
|
67
|
+
step: options.step,
|
|
68
|
+
messages: {
|
|
69
|
+
inputCount: baseMessages.length,
|
|
70
|
+
outputCount: messages.length
|
|
71
|
+
},
|
|
72
|
+
contextFragments: contextFragmentResult.report,
|
|
73
|
+
window: {
|
|
74
|
+
...windowBefore ? { before: windowBefore } : {},
|
|
75
|
+
...windowAfter ? { after: windowAfter } : {}
|
|
76
|
+
},
|
|
77
|
+
...options.compaction ? { compaction: options.compaction } : {}
|
|
78
|
+
};
|
|
79
|
+
return { messages, report };
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export {
|
|
83
|
+
assembleModelContext
|
|
84
|
+
};
|
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
import {
|
|
2
|
+
advanceAgentTurnState,
|
|
3
|
+
createAgentTurnState,
|
|
4
|
+
failAgentTurnState
|
|
5
|
+
} from "./chunk-E66PKKDL.js";
|
|
6
|
+
import {
|
|
7
|
+
currentScope,
|
|
8
|
+
snapshotScope,
|
|
9
|
+
withinScope
|
|
10
|
+
} from "./chunk-AHDCR7SX.js";
|
|
11
|
+
import {
|
|
12
|
+
silentLogger
|
|
13
|
+
} from "./chunk-S6AKEPAX.js";
|
|
14
|
+
|
|
15
|
+
// src/execution/task/observer.ts
|
|
16
|
+
function defaultAgentTaskCheckpointStrategy(input) {
|
|
17
|
+
switch (input.event.type) {
|
|
18
|
+
case "step-finish":
|
|
19
|
+
return "step-finish";
|
|
20
|
+
case "tool-result":
|
|
21
|
+
return "tool-result";
|
|
22
|
+
case "tool-error":
|
|
23
|
+
return "tool-error";
|
|
24
|
+
case "turn-boundary":
|
|
25
|
+
return input.event.boundary;
|
|
26
|
+
case "complete":
|
|
27
|
+
return "task-complete";
|
|
28
|
+
default:
|
|
29
|
+
return void 0;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// src/execution/task/runner.ts
|
|
34
|
+
import { randomUUID } from "crypto";
|
|
35
|
+
function normalizeNonEmpty(value, label) {
|
|
36
|
+
const normalized = value.trim();
|
|
37
|
+
if (!normalized) {
|
|
38
|
+
throw new Error(`${label} must not be empty`);
|
|
39
|
+
}
|
|
40
|
+
return normalized;
|
|
41
|
+
}
|
|
42
|
+
function sanitizeSegment(input) {
|
|
43
|
+
return input.trim().toLowerCase().replace(/[^a-z0-9._-]+/g, "-").replace(/-+/g, "-").replace(/^-|-$/g, "");
|
|
44
|
+
}
|
|
45
|
+
function buildRuntimeSessionId(prefix, key) {
|
|
46
|
+
const timestamp = Date.now().toString(36);
|
|
47
|
+
const suffix = randomUUID().slice(0, 8);
|
|
48
|
+
const normalizedPrefix = sanitizeSegment(prefix) || "runtime";
|
|
49
|
+
const normalizedKey = key ? sanitizeSegment(key) : "";
|
|
50
|
+
if (normalizedKey) {
|
|
51
|
+
return `${normalizedPrefix}:${normalizedKey}:${timestamp}:${suffix}`;
|
|
52
|
+
}
|
|
53
|
+
return `${normalizedPrefix}:${timestamp}:${suffix}`;
|
|
54
|
+
}
|
|
55
|
+
function nowIso() {
|
|
56
|
+
return (/* @__PURE__ */ new Date()).toISOString();
|
|
57
|
+
}
|
|
58
|
+
async function notifyObservers(observers, invoke, logger) {
|
|
59
|
+
for (const observer of observers) {
|
|
60
|
+
try {
|
|
61
|
+
await invoke(observer);
|
|
62
|
+
} catch (error) {
|
|
63
|
+
logger.warn("observer error", {
|
|
64
|
+
error: error instanceof Error ? error.message : String(error)
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
function createAgentTaskRunner(agent, options = {}) {
|
|
70
|
+
const prefix = options.sessionPrefix ?? "runtime";
|
|
71
|
+
const baseObservers = options.observers ?? [];
|
|
72
|
+
const checkpointStrategy = options.checkpointStrategy ?? defaultAgentTaskCheckpointStrategy;
|
|
73
|
+
const log = options.logger?.child("task-runner") ?? silentLogger;
|
|
74
|
+
return async (payload, context = {}) => {
|
|
75
|
+
const message = normalizeNonEmpty(payload.message, "payload.message");
|
|
76
|
+
const resolvedSessionId = payload.sessionId?.trim() || options.resolveSessionId?.(payload, context)?.trim() || buildRuntimeSessionId(prefix, context.fallbackSessionKey);
|
|
77
|
+
const sessionId = normalizeNonEmpty(resolvedSessionId, "sessionId");
|
|
78
|
+
const startedAt = nowIso();
|
|
79
|
+
const executionId = context.executionId?.trim() || `${sessionId}:${startedAt}`;
|
|
80
|
+
return withinScope(
|
|
81
|
+
{
|
|
82
|
+
kind: "task",
|
|
83
|
+
name: "agent-task",
|
|
84
|
+
sessionId,
|
|
85
|
+
taskId: context.fallbackSessionKey ?? sessionId,
|
|
86
|
+
attributes: {
|
|
87
|
+
...context.trigger ? { trigger: context.trigger } : {}
|
|
88
|
+
}
|
|
89
|
+
},
|
|
90
|
+
async () => {
|
|
91
|
+
const run = {
|
|
92
|
+
payload,
|
|
93
|
+
context,
|
|
94
|
+
sessionId,
|
|
95
|
+
executionId,
|
|
96
|
+
startedAt: context.restoreFrom?.startedAt ?? startedAt,
|
|
97
|
+
scope: snapshotScope()
|
|
98
|
+
};
|
|
99
|
+
const toolCalls = context.restoreFrom?.toolCalls.map((tc) => ({ ...tc })) ?? [];
|
|
100
|
+
let turnState = createAgentTurnState({
|
|
101
|
+
sessionId,
|
|
102
|
+
startedAt: context.restoreFrom?.startedAt ?? startedAt,
|
|
103
|
+
restoreFrom: context.restoreFrom ? {
|
|
104
|
+
response: context.restoreFrom.response,
|
|
105
|
+
usage: { ...context.restoreFrom.usage },
|
|
106
|
+
step: context.restoreFrom.step,
|
|
107
|
+
eventCount: context.restoreFrom.eventCount
|
|
108
|
+
} : void 0
|
|
109
|
+
});
|
|
110
|
+
const createSnapshot = () => ({
|
|
111
|
+
sessionId,
|
|
112
|
+
response: turnState.response,
|
|
113
|
+
usage: { ...turnState.usage },
|
|
114
|
+
toolCalls: toolCalls.map((toolCall) => ({ ...toolCall })),
|
|
115
|
+
eventCount: turnState.eventCount,
|
|
116
|
+
activeStep: turnState.step > 0 ? turnState.step : void 0,
|
|
117
|
+
lastEvent: turnState.lastEvent,
|
|
118
|
+
error: turnState.error,
|
|
119
|
+
startedAt: turnState.startedAt,
|
|
120
|
+
updatedAt: turnState.updatedAt,
|
|
121
|
+
turnState,
|
|
122
|
+
scope: currentScope() ?? run.scope
|
|
123
|
+
});
|
|
124
|
+
const emitCheckpoint = async (reason, event) => {
|
|
125
|
+
if (baseObservers.length === 0) {
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
const checkpoint = {
|
|
129
|
+
run,
|
|
130
|
+
reason,
|
|
131
|
+
snapshot: createSnapshot(),
|
|
132
|
+
event,
|
|
133
|
+
createdAt: turnState.updatedAt
|
|
134
|
+
};
|
|
135
|
+
await notifyObservers(
|
|
136
|
+
baseObservers,
|
|
137
|
+
async (observer) => {
|
|
138
|
+
await observer.onCheckpoint?.(checkpoint);
|
|
139
|
+
},
|
|
140
|
+
log
|
|
141
|
+
);
|
|
142
|
+
};
|
|
143
|
+
await notifyObservers(
|
|
144
|
+
baseObservers,
|
|
145
|
+
async (observer) => {
|
|
146
|
+
await observer.onTaskStart?.(run, createSnapshot());
|
|
147
|
+
},
|
|
148
|
+
log
|
|
149
|
+
);
|
|
150
|
+
await emitCheckpoint("task-start");
|
|
151
|
+
const activateCtx = baseObservers.find((o) => o.activateContext)?.activateContext?.bind(void 0, sessionId, executionId);
|
|
152
|
+
try {
|
|
153
|
+
const processChatStream = async () => {
|
|
154
|
+
for await (const event of agent.chat(sessionId, message, {
|
|
155
|
+
abort: context.signal,
|
|
156
|
+
system: payload.system
|
|
157
|
+
})) {
|
|
158
|
+
turnState = advanceAgentTurnState(turnState, event, nowIso());
|
|
159
|
+
if (event.type === "tool-result") {
|
|
160
|
+
toolCalls.push({ name: event.toolName, result: event.result });
|
|
161
|
+
}
|
|
162
|
+
const snapshot = createSnapshot();
|
|
163
|
+
await notifyObservers(
|
|
164
|
+
baseObservers,
|
|
165
|
+
async (observer) => {
|
|
166
|
+
await observer.onTaskEvent?.(run, event, snapshot);
|
|
167
|
+
},
|
|
168
|
+
log
|
|
169
|
+
);
|
|
170
|
+
const checkpointReason = checkpointStrategy({
|
|
171
|
+
run,
|
|
172
|
+
event,
|
|
173
|
+
snapshot
|
|
174
|
+
});
|
|
175
|
+
if (checkpointReason) {
|
|
176
|
+
await emitCheckpoint(checkpointReason, event);
|
|
177
|
+
}
|
|
178
|
+
if (event.type === "error") {
|
|
179
|
+
throw event.error;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
};
|
|
183
|
+
if (activateCtx) {
|
|
184
|
+
await activateCtx(processChatStream);
|
|
185
|
+
} else {
|
|
186
|
+
await processChatStream();
|
|
187
|
+
}
|
|
188
|
+
const result = {
|
|
189
|
+
response: turnState.response,
|
|
190
|
+
sessionId,
|
|
191
|
+
usage: { ...turnState.usage },
|
|
192
|
+
toolCalls
|
|
193
|
+
};
|
|
194
|
+
await notifyObservers(
|
|
195
|
+
baseObservers,
|
|
196
|
+
async (observer) => {
|
|
197
|
+
await observer.onTaskComplete?.(run, result, createSnapshot());
|
|
198
|
+
},
|
|
199
|
+
log
|
|
200
|
+
);
|
|
201
|
+
return result;
|
|
202
|
+
} catch (error) {
|
|
203
|
+
const normalizedError = error instanceof Error ? error : new Error(String(error));
|
|
204
|
+
turnState = failAgentTurnState(turnState, normalizedError, nowIso());
|
|
205
|
+
await notifyObservers(
|
|
206
|
+
baseObservers,
|
|
207
|
+
async (observer) => {
|
|
208
|
+
await observer.onTaskError?.(
|
|
209
|
+
run,
|
|
210
|
+
normalizedError,
|
|
211
|
+
createSnapshot()
|
|
212
|
+
);
|
|
213
|
+
},
|
|
214
|
+
log
|
|
215
|
+
);
|
|
216
|
+
await emitCheckpoint("task-error");
|
|
217
|
+
throw normalizedError;
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
);
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
export {
|
|
225
|
+
defaultAgentTaskCheckpointStrategy,
|
|
226
|
+
createAgentTaskRunner
|
|
227
|
+
};
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
import {
|
|
2
|
+
snapshotScope,
|
|
3
|
+
withinScope
|
|
4
|
+
} from "./chunk-AHDCR7SX.js";
|
|
1
5
|
import {
|
|
2
6
|
formatApprovalDeniedReason
|
|
3
7
|
} from "./chunk-T33MQXUP.js";
|
|
@@ -5,82 +9,6 @@ import {
|
|
|
5
9
|
requiresToolHost
|
|
6
10
|
} from "./chunk-FII65CN7.js";
|
|
7
11
|
|
|
8
|
-
// src/scope/store.ts
|
|
9
|
-
import { AsyncLocalStorage } from "async_hooks";
|
|
10
|
-
import { randomUUID } from "crypto";
|
|
11
|
-
var scopeStore = new AsyncLocalStorage();
|
|
12
|
-
function cloneAttributes(attributes) {
|
|
13
|
-
return { ...attributes };
|
|
14
|
-
}
|
|
15
|
-
function cloneScope(scope) {
|
|
16
|
-
return {
|
|
17
|
-
...scope,
|
|
18
|
-
attributes: cloneAttributes(scope.attributes)
|
|
19
|
-
};
|
|
20
|
-
}
|
|
21
|
-
function getStoredScope() {
|
|
22
|
-
return scopeStore.getStore();
|
|
23
|
-
}
|
|
24
|
-
function buildScope(options, current) {
|
|
25
|
-
const parent = options.parent === void 0 ? current : options.parent ?? void 0;
|
|
26
|
-
const id = options.id ?? randomUUID();
|
|
27
|
-
return {
|
|
28
|
-
id,
|
|
29
|
-
rootId: parent?.rootId ?? id,
|
|
30
|
-
kind: options.kind,
|
|
31
|
-
name: options.name,
|
|
32
|
-
parentId: parent?.id,
|
|
33
|
-
depth: (parent?.depth ?? -1) + 1,
|
|
34
|
-
startedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
35
|
-
sessionId: options.sessionId ?? parent?.sessionId,
|
|
36
|
-
taskId: options.taskId ?? parent?.taskId,
|
|
37
|
-
step: options.step ?? parent?.step,
|
|
38
|
-
attributes: cloneAttributes(options.attributes ?? {})
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
function runWithScope(scope, fn) {
|
|
42
|
-
return Promise.resolve(scopeStore.run(scope, fn));
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
// src/scope/run.ts
|
|
46
|
-
function currentScope() {
|
|
47
|
-
const scope = getStoredScope();
|
|
48
|
-
return scope ? cloneScope(scope) : void 0;
|
|
49
|
-
}
|
|
50
|
-
function snapshotScope(scope = getStoredScope()) {
|
|
51
|
-
return scope ? cloneScope(scope) : void 0;
|
|
52
|
-
}
|
|
53
|
-
function withinScope(options, fn) {
|
|
54
|
-
return runWithScope(buildScope(options, getStoredScope()), fn);
|
|
55
|
-
}
|
|
56
|
-
function restoreScope(snapshot, fn) {
|
|
57
|
-
if (!snapshot) {
|
|
58
|
-
return Promise.resolve(fn());
|
|
59
|
-
}
|
|
60
|
-
return runWithScope(cloneScope(snapshot), fn);
|
|
61
|
-
}
|
|
62
|
-
async function* streamWithinScope(options, iterable) {
|
|
63
|
-
const scope = buildScope(options, getStoredScope());
|
|
64
|
-
const iterator = await runWithScope(
|
|
65
|
-
scope,
|
|
66
|
-
() => iterable[Symbol.asyncIterator]()
|
|
67
|
-
);
|
|
68
|
-
try {
|
|
69
|
-
while (true) {
|
|
70
|
-
const next = await runWithScope(scope, () => iterator.next());
|
|
71
|
-
if (next.done) {
|
|
72
|
-
return next.value;
|
|
73
|
-
}
|
|
74
|
-
yield next.value;
|
|
75
|
-
}
|
|
76
|
-
} finally {
|
|
77
|
-
const returnFn = iterator.return?.bind(iterator);
|
|
78
|
-
if (returnFn) {
|
|
79
|
-
await runWithScope(scope, () => returnFn(void 0));
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
|
|
84
12
|
// src/tracking/file-tracking.ts
|
|
85
13
|
function extractFilePathsFromArgs(args, meta) {
|
|
86
14
|
if (!meta.pathArgs || meta.pathArgs.length === 0) {
|
|
@@ -252,11 +180,6 @@ ${transformed.supplement}` : transformed.output;
|
|
|
252
180
|
}
|
|
253
181
|
|
|
254
182
|
export {
|
|
255
|
-
currentScope,
|
|
256
|
-
snapshotScope,
|
|
257
|
-
withinScope,
|
|
258
|
-
restoreScope,
|
|
259
|
-
streamWithinScope,
|
|
260
183
|
extractFilePathsFromArgs,
|
|
261
184
|
shouldCaptureBaseline,
|
|
262
185
|
executeAgentToolCall
|