@cuylabs/agent-core 4.9.0 → 5.0.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 +33 -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 +42 -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 +182 -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 +76 -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 +45 -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 +18 -0
- package/dist/agent/turn-context/compaction/memory.d.ts.map +1 -0
- package/dist/agent/turn-context/compaction/results.d.ts +25 -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 +30 -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 +206 -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-346FIYKT.js +960 -0
- package/dist/{chunk-HSUPTXNV.js → chunk-556CPZ3J.js} +13 -10
- package/dist/chunk-AHDCR7SX.js +83 -0
- package/dist/{chunk-CSR75JVC.js → chunk-ASXF5AC6.js} +1 -1
- package/dist/{chunk-BJC46FIF.js → chunk-BKHWKKSG.js} +2 -2
- package/dist/{chunk-2TTOLHBT.js → chunk-CFBSQLP5.js} +1 -1
- package/dist/chunk-CGP6UNCQ.js +554 -0
- package/dist/{chunk-GJFP5L2V.js → chunk-CNM6OROH.js} +15 -3
- package/dist/chunk-DD7S7ZG4.js +274 -0
- package/dist/chunk-DYZGHHDB.js +1458 -0
- package/dist/chunk-E66PKKDL.js +772 -0
- package/dist/{chunk-H3GRHFFG.js → chunk-EDKZOPUV.js} +63 -306
- package/dist/{chunk-GEBFHREI.js → chunk-GHVW7L4P.js} +71 -5
- 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-MJRZ2ZRI.js +498 -0
- package/dist/{chunk-UMIVJDEJ.js → chunk-SAWRDGBE.js} +30 -7
- package/dist/chunk-TYQWH6XH.js +88 -0
- 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-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 +64 -0
- package/dist/context/assembly/types.d.ts.map +1 -0
- package/dist/context/config.d.ts +20 -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 +12 -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 +96 -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 +135 -0
- package/dist/context/window/budget.d.ts.map +1 -0
- package/dist/context/window/compactor.d.ts +89 -0
- package/dist/context/window/compactor.d.ts.map +1 -0
- package/dist/context/window/cut-planner.d.ts +67 -0
- package/dist/context/window/cut-planner.d.ts.map +1 -0
- package/dist/context/window/decision.d.ts +50 -0
- package/dist/context/window/decision.d.ts.map +1 -0
- package/dist/context/window/estimation.d.ts +60 -0
- package/dist/context/window/estimation.d.ts.map +1 -0
- package/dist/context/window/index.d.ts +28 -0
- package/dist/context/window/index.d.ts.map +1 -0
- package/dist/context/window/manager.d.ts +113 -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 +65 -0
- package/dist/context/window/summary.d.ts.map +1 -0
- package/dist/context/window/tool-pruning.d.ts +73 -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 +2681 -1859
- 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 +251 -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 +25 -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 +115 -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 +426 -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/sessions/index.d.ts +13 -0
- package/dist/sessions/index.d.ts.map +1 -0
- package/dist/{storage → sessions}/index.js +6 -17
- package/dist/sessions/manager/default.d.ts +11 -0
- package/dist/sessions/manager/default.d.ts.map +1 -0
- package/dist/sessions/manager/index.d.ts +12 -0
- package/dist/sessions/manager/index.d.ts.map +1 -0
- package/dist/sessions/manager/session-manager.d.ts +67 -0
- package/dist/sessions/manager/session-manager.d.ts.map +1 -0
- package/dist/sessions/manager/types.d.ts +42 -0
- package/dist/sessions/manager/types.d.ts.map +1 -0
- package/dist/sessions/store/lock.d.ts +18 -0
- package/dist/sessions/store/lock.d.ts.map +1 -0
- package/dist/sessions/store/memory.d.ts +22 -0
- package/dist/sessions/store/memory.d.ts.map +1 -0
- package/dist/sessions/types.d.ts +215 -0
- package/dist/sessions/types.d.ts.map +1 -0
- package/dist/sessions/utils.d.ts +77 -0
- package/dist/sessions/utils.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/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 +191 -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 +196 -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 +49 -12
- 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/storage/index.d.ts +0 -191
- 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
|
+
};
|
|
@@ -554,6 +554,35 @@ function describeFetchTarget(input, init) {
|
|
|
554
554
|
}
|
|
555
555
|
|
|
556
556
|
// src/mcp/auth.ts
|
|
557
|
+
function isRecord(value) {
|
|
558
|
+
return typeof value === "object" && value !== null;
|
|
559
|
+
}
|
|
560
|
+
function readOptionalString(data, key) {
|
|
561
|
+
const value = data[key];
|
|
562
|
+
return typeof value === "string" ? value : void 0;
|
|
563
|
+
}
|
|
564
|
+
function readOptionalNumber(data, key) {
|
|
565
|
+
const value = data[key];
|
|
566
|
+
return typeof value === "number" && Number.isFinite(value) ? value : void 0;
|
|
567
|
+
}
|
|
568
|
+
function parseOAuthTokenResponse(data) {
|
|
569
|
+
if (!isRecord(data)) {
|
|
570
|
+
throw new Error("ClientCredentialsProvider: token response was not JSON.");
|
|
571
|
+
}
|
|
572
|
+
const accessToken = readOptionalString(data, "access_token");
|
|
573
|
+
if (!accessToken) {
|
|
574
|
+
throw new Error(
|
|
575
|
+
'ClientCredentialsProvider: token response missing "access_token".'
|
|
576
|
+
);
|
|
577
|
+
}
|
|
578
|
+
return {
|
|
579
|
+
access_token: accessToken,
|
|
580
|
+
token_type: readOptionalString(data, "token_type") ?? "bearer",
|
|
581
|
+
expires_in: readOptionalNumber(data, "expires_in"),
|
|
582
|
+
scope: readOptionalString(data, "scope"),
|
|
583
|
+
refresh_token: readOptionalString(data, "refresh_token")
|
|
584
|
+
};
|
|
585
|
+
}
|
|
557
586
|
var ClientCredentialsProvider = class {
|
|
558
587
|
_tokens;
|
|
559
588
|
_expiresAt;
|
|
@@ -658,13 +687,7 @@ var ClientCredentialsProvider = class {
|
|
|
658
687
|
);
|
|
659
688
|
}
|
|
660
689
|
const json = await response.json();
|
|
661
|
-
const tokens =
|
|
662
|
-
access_token: String(json.access_token),
|
|
663
|
-
token_type: String(json.token_type ?? "bearer"),
|
|
664
|
-
expires_in: typeof json.expires_in === "number" ? json.expires_in : void 0,
|
|
665
|
-
scope: typeof json.scope === "string" ? json.scope : void 0,
|
|
666
|
-
refresh_token: typeof json.refresh_token === "string" ? json.refresh_token : void 0
|
|
667
|
-
};
|
|
690
|
+
const tokens = parseOAuthTokenResponse(json);
|
|
668
691
|
await this.saveTokens(tokens);
|
|
669
692
|
return tokens;
|
|
670
693
|
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import {
|
|
2
|
+
applyAgentContextFragmentsWithReport
|
|
3
|
+
} from "./chunk-CGP6UNCQ.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 tokenEstimator = options.window?.getTokenEstimator?.();
|
|
58
|
+
const contextFragmentResult = applyAgentContextFragmentsWithReport(
|
|
59
|
+
baseMessages,
|
|
60
|
+
requestedContextFragments,
|
|
61
|
+
{
|
|
62
|
+
...contextFragmentBudget ? { budget: contextFragmentBudget } : {},
|
|
63
|
+
...tokenEstimator ? { tokenEstimator } : {}
|
|
64
|
+
}
|
|
65
|
+
);
|
|
66
|
+
const messages = contextFragmentResult.messages;
|
|
67
|
+
const windowAfter = options.window?.getStats(messages);
|
|
68
|
+
const report = {
|
|
69
|
+
sessionId: options.sessionId,
|
|
70
|
+
...options.turnId ? { turnId: options.turnId } : {},
|
|
71
|
+
step: options.step,
|
|
72
|
+
messages: {
|
|
73
|
+
inputCount: baseMessages.length,
|
|
74
|
+
outputCount: messages.length
|
|
75
|
+
},
|
|
76
|
+
contextFragments: contextFragmentResult.report,
|
|
77
|
+
window: {
|
|
78
|
+
...windowBefore ? { before: windowBefore } : {},
|
|
79
|
+
...windowAfter ? { after: windowAfter } : {}
|
|
80
|
+
},
|
|
81
|
+
...options.compaction ? { compaction: options.compaction } : {}
|
|
82
|
+
};
|
|
83
|
+
return { messages, report };
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export {
|
|
87
|
+
assembleModelContext
|
|
88
|
+
};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
// src/events/signal/local.ts
|
|
2
|
+
var LocalSignal = class {
|
|
3
|
+
/** type → Set<handler> for typed subscriptions */
|
|
4
|
+
typed = /* @__PURE__ */ new Map();
|
|
5
|
+
/** handlers that receive every event */
|
|
6
|
+
wildcard = /* @__PURE__ */ new Set();
|
|
7
|
+
on(type, handler) {
|
|
8
|
+
let set = this.typed.get(type);
|
|
9
|
+
if (!set) {
|
|
10
|
+
set = /* @__PURE__ */ new Set();
|
|
11
|
+
this.typed.set(type, set);
|
|
12
|
+
}
|
|
13
|
+
const wrapped = (event) => {
|
|
14
|
+
handler(event);
|
|
15
|
+
};
|
|
16
|
+
set.add(wrapped);
|
|
17
|
+
return () => {
|
|
18
|
+
set.delete(wrapped);
|
|
19
|
+
if (set.size === 0) this.typed.delete(type);
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
onAny(handler) {
|
|
23
|
+
this.wildcard.add(handler);
|
|
24
|
+
return () => {
|
|
25
|
+
this.wildcard.delete(handler);
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
emit(event) {
|
|
29
|
+
const set = this.typed.get(event.type);
|
|
30
|
+
if (set) {
|
|
31
|
+
for (const fn of set) {
|
|
32
|
+
try {
|
|
33
|
+
fn(event);
|
|
34
|
+
} catch {
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
for (const fn of this.wildcard) {
|
|
39
|
+
try {
|
|
40
|
+
fn(event);
|
|
41
|
+
} catch {
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
clear() {
|
|
46
|
+
this.typed.clear();
|
|
47
|
+
this.wildcard.clear();
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
export {
|
|
52
|
+
LocalSignal
|
|
53
|
+
};
|