pulseed 0.6.3 → 0.6.4
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/dist/adapters/datasources/artifact-metric-datasource.d.ts +11 -1
- package/dist/adapters/datasources/artifact-metric-datasource.d.ts.map +1 -1
- package/dist/adapters/datasources/artifact-metric-datasource.js +238 -8
- package/dist/adapters/datasources/artifact-metric-datasource.js.map +1 -1
- package/dist/base/config/global-config.d.ts +4 -4
- package/dist/base/protocol/exact-protocol.d.ts +47 -0
- package/dist/base/protocol/exact-protocol.d.ts.map +1 -0
- package/dist/base/protocol/exact-protocol.js +175 -0
- package/dist/base/protocol/exact-protocol.js.map +1 -0
- package/dist/base/types/core.d.ts +1 -1
- package/dist/base/types/core.d.ts.map +1 -1
- package/dist/base/types/core.js +1 -0
- package/dist/base/types/core.js.map +1 -1
- package/dist/base/utils/workspace-path.d.ts +6 -0
- package/dist/base/utils/workspace-path.d.ts.map +1 -0
- package/dist/base/utils/workspace-path.js +24 -0
- package/dist/base/utils/workspace-path.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/interface/chat/chat-event-state.d.ts +2 -0
- package/dist/interface/chat/chat-event-state.d.ts.map +1 -1
- package/dist/interface/chat/chat-event-state.js +22 -41
- package/dist/interface/chat/chat-event-state.js.map +1 -1
- package/dist/interface/chat/chat-events.d.ts +15 -1
- package/dist/interface/chat/chat-events.d.ts.map +1 -1
- package/dist/interface/chat/chat-history.d.ts +3816 -192
- package/dist/interface/chat/chat-history.d.ts.map +1 -1
- package/dist/interface/chat/chat-history.js +529 -5
- package/dist/interface/chat/chat-history.js.map +1 -1
- package/dist/interface/chat/chat-runner-commands.d.ts.map +1 -1
- package/dist/interface/chat/chat-runner-commands.js +22 -18
- package/dist/interface/chat/chat-runner-commands.js.map +1 -1
- package/dist/interface/chat/chat-runner-contracts.d.ts +5 -1
- package/dist/interface/chat/chat-runner-contracts.d.ts.map +1 -1
- package/dist/interface/chat/chat-runner-event-bridge.d.ts +13 -1
- package/dist/interface/chat/chat-runner-event-bridge.d.ts.map +1 -1
- package/dist/interface/chat/chat-runner-event-bridge.js +51 -3
- package/dist/interface/chat/chat-runner-event-bridge.js.map +1 -1
- package/dist/interface/chat/chat-runner-routes.d.ts +5 -17
- package/dist/interface/chat/chat-runner-routes.d.ts.map +1 -1
- package/dist/interface/chat/chat-runner-routes.js +80 -51
- package/dist/interface/chat/chat-runner-routes.js.map +1 -1
- package/dist/interface/chat/chat-runner-runtime.d.ts.map +1 -1
- package/dist/interface/chat/chat-runner-runtime.js +4 -0
- package/dist/interface/chat/chat-runner-runtime.js.map +1 -1
- package/dist/interface/chat/chat-runner.d.ts +7 -1
- package/dist/interface/chat/chat-runner.d.ts.map +1 -1
- package/dist/interface/chat/chat-runner.js +135 -49
- package/dist/interface/chat/chat-runner.js.map +1 -1
- package/dist/interface/chat/chat-session-store.d.ts +3 -0
- package/dist/interface/chat/chat-session-store.d.ts.map +1 -1
- package/dist/interface/chat/chat-session-store.js +12 -0
- package/dist/interface/chat/chat-session-store.js.map +1 -1
- package/dist/interface/chat/cross-platform-session.d.ts +15 -0
- package/dist/interface/chat/cross-platform-session.d.ts.map +1 -1
- package/dist/interface/chat/cross-platform-session.js +260 -42
- package/dist/interface/chat/cross-platform-session.js.map +1 -1
- package/dist/interface/chat/failure-recovery.d.ts.map +1 -1
- package/dist/interface/chat/failure-recovery.js +15 -1
- package/dist/interface/chat/failure-recovery.js.map +1 -1
- package/dist/interface/chat/freeform-route-classifier.d.ts +2 -2
- package/dist/interface/chat/ingress-router.d.ts +3 -0
- package/dist/interface/chat/ingress-router.d.ts.map +1 -1
- package/dist/interface/chat/ingress-router.js +3 -0
- package/dist/interface/chat/ingress-router.js.map +1 -1
- package/dist/interface/chat/model-request-builder.d.ts +37 -0
- package/dist/interface/chat/model-request-builder.d.ts.map +1 -0
- package/dist/interface/chat/model-request-builder.js +76 -0
- package/dist/interface/chat/model-request-builder.js.map +1 -0
- package/dist/interface/chat/turn-context.d.ts +200 -0
- package/dist/interface/chat/turn-context.d.ts.map +1 -0
- package/dist/interface/chat/turn-context.js +249 -0
- package/dist/interface/chat/turn-context.js.map +1 -0
- package/dist/interface/chat/turn-protocol.d.ts +35 -0
- package/dist/interface/chat/turn-protocol.d.ts.map +1 -0
- package/dist/interface/chat/turn-protocol.js +27 -0
- package/dist/interface/chat/turn-protocol.js.map +1 -0
- package/dist/interface/chat/user-input.d.ts +55 -0
- package/dist/interface/chat/user-input.d.ts.map +1 -0
- package/dist/interface/chat/user-input.js +52 -0
- package/dist/interface/chat/user-input.js.map +1 -0
- package/dist/interface/cli/cli-command-registry.d.ts +1 -1
- package/dist/interface/cli/cli-command-registry.d.ts.map +1 -1
- package/dist/interface/cli/cli-command-registry.js +12 -16
- package/dist/interface/cli/cli-command-registry.js.map +1 -1
- package/dist/interface/cli/commands/daemon-shared.d.ts +8 -0
- package/dist/interface/cli/commands/daemon-shared.d.ts.map +1 -1
- package/dist/interface/cli/commands/daemon-shared.js +18 -2
- package/dist/interface/cli/commands/daemon-shared.js.map +1 -1
- package/dist/interface/cli/commands/daemon.d.ts.map +1 -1
- package/dist/interface/cli/commands/daemon.js +5 -1
- package/dist/interface/cli/commands/daemon.js.map +1 -1
- package/dist/interface/cli/commands/doctor.d.ts.map +1 -1
- package/dist/interface/cli/commands/doctor.js +14 -1
- package/dist/interface/cli/commands/doctor.js.map +1 -1
- package/dist/interface/cli/commands/goal-dispatch.d.ts.map +1 -1
- package/dist/interface/cli/commands/goal-dispatch.js +10 -6
- package/dist/interface/cli/commands/goal-dispatch.js.map +1 -1
- package/dist/interface/cli/commands/goal-utils.d.ts.map +1 -1
- package/dist/interface/cli/commands/goal-utils.js +3 -5
- package/dist/interface/cli/commands/goal-utils.js.map +1 -1
- package/dist/interface/cli/commands/run.d.ts.map +1 -1
- package/dist/interface/cli/commands/run.js +50 -0
- package/dist/interface/cli/commands/run.js.map +1 -1
- package/dist/interface/cli/setup.d.ts +1 -1
- package/dist/interface/cli/setup.d.ts.map +1 -1
- package/dist/interface/cli/setup.js +4 -3
- package/dist/interface/cli/setup.js.map +1 -1
- package/dist/interface/cli/utils/loop-runner.d.ts +1 -0
- package/dist/interface/cli/utils/loop-runner.d.ts.map +1 -1
- package/dist/interface/cli/utils/loop-runner.js +12 -3
- package/dist/interface/cli/utils/loop-runner.js.map +1 -1
- package/dist/interface/tui/app.d.ts +6 -1
- package/dist/interface/tui/app.d.ts.map +1 -1
- package/dist/interface/tui/app.js +29 -12
- package/dist/interface/tui/app.js.map +1 -1
- package/dist/interface/tui/bash-mode.d.ts.map +1 -1
- package/dist/interface/tui/bash-mode.js +2 -9
- package/dist/interface/tui/bash-mode.js.map +1 -1
- package/dist/interface/tui/chat/viewport.d.ts.map +1 -1
- package/dist/interface/tui/chat/viewport.js +57 -11
- package/dist/interface/tui/chat/viewport.js.map +1 -1
- package/dist/interface/tui/entry-deps.d.ts +6 -1
- package/dist/interface/tui/entry-deps.d.ts.map +1 -1
- package/dist/interface/tui/entry-deps.js +3 -0
- package/dist/interface/tui/entry-deps.js.map +1 -1
- package/dist/interface/tui/entry.d.ts.map +1 -1
- package/dist/interface/tui/entry.js +6 -2
- package/dist/interface/tui/entry.js.map +1 -1
- package/dist/interface/tui/input-action.d.ts.map +1 -1
- package/dist/interface/tui/input-action.js +3 -2
- package/dist/interface/tui/input-action.js.map +1 -1
- package/dist/interface/tui/intent-recognizer.d.ts.map +1 -1
- package/dist/interface/tui/intent-recognizer.js +21 -33
- package/dist/interface/tui/intent-recognizer.js.map +1 -1
- package/dist/orchestrator/execution/adapter-layer.d.ts +6 -1
- package/dist/orchestrator/execution/adapter-layer.d.ts.map +1 -1
- package/dist/orchestrator/execution/adapter-layer.js.map +1 -1
- package/dist/orchestrator/execution/agent-loop/agent-loop-command-classifier.d.ts +12 -1
- package/dist/orchestrator/execution/agent-loop/agent-loop-command-classifier.d.ts.map +1 -1
- package/dist/orchestrator/execution/agent-loop/agent-loop-command-classifier.js +16 -31
- package/dist/orchestrator/execution/agent-loop/agent-loop-command-classifier.js.map +1 -1
- package/dist/orchestrator/execution/agent-loop/agent-loop-compaction-record.d.ts +75 -0
- package/dist/orchestrator/execution/agent-loop/agent-loop-compaction-record.d.ts.map +1 -0
- package/dist/orchestrator/execution/agent-loop/agent-loop-compaction-record.js +10 -0
- package/dist/orchestrator/execution/agent-loop/agent-loop-compaction-record.js.map +1 -0
- package/dist/orchestrator/execution/agent-loop/agent-loop-compactor.d.ts +3 -2
- package/dist/orchestrator/execution/agent-loop/agent-loop-compactor.d.ts.map +1 -1
- package/dist/orchestrator/execution/agent-loop/agent-loop-compactor.js +185 -22
- package/dist/orchestrator/execution/agent-loop/agent-loop-compactor.js.map +1 -1
- package/dist/orchestrator/execution/agent-loop/agent-loop-default-profile.d.ts.map +1 -1
- package/dist/orchestrator/execution/agent-loop/agent-loop-default-profile.js +7 -1
- package/dist/orchestrator/execution/agent-loop/agent-loop-default-profile.js.map +1 -1
- package/dist/orchestrator/execution/agent-loop/agent-loop-events.d.ts +8 -1
- package/dist/orchestrator/execution/agent-loop/agent-loop-events.d.ts.map +1 -1
- package/dist/orchestrator/execution/agent-loop/agent-loop-events.js.map +1 -1
- package/dist/orchestrator/execution/agent-loop/agent-loop-history.d.ts +3 -1
- package/dist/orchestrator/execution/agent-loop/agent-loop-history.d.ts.map +1 -1
- package/dist/orchestrator/execution/agent-loop/agent-loop-history.js +12 -3
- package/dist/orchestrator/execution/agent-loop/agent-loop-history.js.map +1 -1
- package/dist/orchestrator/execution/agent-loop/agent-loop-model-client.d.ts.map +1 -1
- package/dist/orchestrator/execution/agent-loop/agent-loop-model-client.js +7 -1
- package/dist/orchestrator/execution/agent-loop/agent-loop-model-client.js.map +1 -1
- package/dist/orchestrator/execution/agent-loop/agent-loop-model.d.ts +37 -0
- package/dist/orchestrator/execution/agent-loop/agent-loop-model.d.ts.map +1 -1
- package/dist/orchestrator/execution/agent-loop/agent-loop-model.js +21 -0
- package/dist/orchestrator/execution/agent-loop/agent-loop-model.js.map +1 -1
- package/dist/orchestrator/execution/agent-loop/agent-loop-result.d.ts +17 -11
- package/dist/orchestrator/execution/agent-loop/agent-loop-result.d.ts.map +1 -1
- package/dist/orchestrator/execution/agent-loop/agent-loop-session-state.d.ts +4 -0
- package/dist/orchestrator/execution/agent-loop/agent-loop-session-state.d.ts.map +1 -1
- package/dist/orchestrator/execution/agent-loop/agent-loop-session-state.js +135 -0
- package/dist/orchestrator/execution/agent-loop/agent-loop-session-state.js.map +1 -1
- package/dist/orchestrator/execution/agent-loop/agent-loop-tool-runtime.d.ts +3 -2
- package/dist/orchestrator/execution/agent-loop/agent-loop-tool-runtime.d.ts.map +1 -1
- package/dist/orchestrator/execution/agent-loop/agent-loop-tool-runtime.js +68 -61
- package/dist/orchestrator/execution/agent-loop/agent-loop-tool-runtime.js.map +1 -1
- package/dist/orchestrator/execution/agent-loop/agent-loop-turn-context.d.ts +3 -1
- package/dist/orchestrator/execution/agent-loop/agent-loop-turn-context.d.ts.map +1 -1
- package/dist/orchestrator/execution/agent-loop/agent-loop-turn-context.js.map +1 -1
- package/dist/orchestrator/execution/agent-loop/agent-timeline.d.ts +12 -1
- package/dist/orchestrator/execution/agent-loop/agent-timeline.d.ts.map +1 -1
- package/dist/orchestrator/execution/agent-loop/agent-timeline.js +19 -56
- package/dist/orchestrator/execution/agent-loop/agent-timeline.js.map +1 -1
- package/dist/orchestrator/execution/agent-loop/anthropic-messages-agent-loop-model-client.d.ts.map +1 -1
- package/dist/orchestrator/execution/agent-loop/anthropic-messages-agent-loop-model-client.js +8 -2
- package/dist/orchestrator/execution/agent-loop/anthropic-messages-agent-loop-model-client.js.map +1 -1
- package/dist/orchestrator/execution/agent-loop/bounded-agent-loop-runner.d.ts +12 -0
- package/dist/orchestrator/execution/agent-loop/bounded-agent-loop-runner.d.ts.map +1 -1
- package/dist/orchestrator/execution/agent-loop/bounded-agent-loop-runner.js +400 -80
- package/dist/orchestrator/execution/agent-loop/bounded-agent-loop-runner.js.map +1 -1
- package/dist/orchestrator/execution/agent-loop/chat-agent-loop-runner.d.ts +1 -1
- package/dist/orchestrator/execution/agent-loop/chat-agent-loop-runner.d.ts.map +1 -1
- package/dist/orchestrator/execution/agent-loop/chat-agent-loop-runner.js +80 -12
- package/dist/orchestrator/execution/agent-loop/chat-agent-loop-runner.js.map +1 -1
- package/dist/orchestrator/execution/agent-loop/chat-display-output.d.ts +1 -0
- package/dist/orchestrator/execution/agent-loop/chat-display-output.d.ts.map +1 -1
- package/dist/orchestrator/execution/agent-loop/chat-display-output.js +3 -1
- package/dist/orchestrator/execution/agent-loop/chat-display-output.js.map +1 -1
- package/dist/orchestrator/execution/agent-loop/index.d.ts +3 -0
- package/dist/orchestrator/execution/agent-loop/index.d.ts.map +1 -1
- package/dist/orchestrator/execution/agent-loop/index.js +3 -0
- package/dist/orchestrator/execution/agent-loop/index.js.map +1 -1
- package/dist/orchestrator/execution/agent-loop/openai-responses-agent-loop-model-client.d.ts +1 -0
- package/dist/orchestrator/execution/agent-loop/openai-responses-agent-loop-model-client.d.ts.map +1 -1
- package/dist/orchestrator/execution/agent-loop/openai-responses-agent-loop-model-client.js +51 -9
- package/dist/orchestrator/execution/agent-loop/openai-responses-agent-loop-model-client.js.map +1 -1
- package/dist/orchestrator/execution/agent-loop/response-item-tool-router.d.ts +20 -0
- package/dist/orchestrator/execution/agent-loop/response-item-tool-router.d.ts.map +1 -0
- package/dist/orchestrator/execution/agent-loop/response-item-tool-router.js +180 -0
- package/dist/orchestrator/execution/agent-loop/response-item-tool-router.js.map +1 -0
- package/dist/orchestrator/execution/agent-loop/response-item.d.ts +805 -0
- package/dist/orchestrator/execution/agent-loop/response-item.d.ts.map +1 -0
- package/dist/orchestrator/execution/agent-loop/response-item.js +104 -0
- package/dist/orchestrator/execution/agent-loop/response-item.js.map +1 -0
- package/dist/orchestrator/execution/agent-loop/task-agent-loop-context.d.ts +7 -2
- package/dist/orchestrator/execution/agent-loop/task-agent-loop-context.d.ts.map +1 -1
- package/dist/orchestrator/execution/agent-loop/task-agent-loop-context.js +20 -1
- package/dist/orchestrator/execution/agent-loop/task-agent-loop-context.js.map +1 -1
- package/dist/orchestrator/execution/agent-loop/task-agent-loop-result.d.ts +5 -3
- package/dist/orchestrator/execution/agent-loop/task-agent-loop-result.d.ts.map +1 -1
- package/dist/orchestrator/execution/agent-loop/task-agent-loop-result.js +109 -10
- package/dist/orchestrator/execution/agent-loop/task-agent-loop-result.js.map +1 -1
- package/dist/orchestrator/execution/agent-loop/task-agent-loop-runner.d.ts +2 -0
- package/dist/orchestrator/execution/agent-loop/task-agent-loop-runner.d.ts.map +1 -1
- package/dist/orchestrator/execution/agent-loop/task-agent-loop-runner.js +9 -4
- package/dist/orchestrator/execution/agent-loop/task-agent-loop-runner.js.map +1 -1
- package/dist/orchestrator/execution/agent-loop/task-agent-loop-verification.d.ts +0 -1
- package/dist/orchestrator/execution/agent-loop/task-agent-loop-verification.d.ts.map +1 -1
- package/dist/orchestrator/execution/agent-loop/task-agent-loop-verification.js +7 -87
- package/dist/orchestrator/execution/agent-loop/task-agent-loop-verification.js.map +1 -1
- package/dist/orchestrator/execution/agent-loop/task-agent-loop-worktree.d.ts.map +1 -1
- package/dist/orchestrator/execution/agent-loop/task-agent-loop-worktree.js +25 -0
- package/dist/orchestrator/execution/agent-loop/task-agent-loop-worktree.js.map +1 -1
- package/dist/orchestrator/execution/context/issue-context-fetcher.d.ts +5 -1
- package/dist/orchestrator/execution/context/issue-context-fetcher.d.ts.map +1 -1
- package/dist/orchestrator/execution/context/issue-context-fetcher.js +7 -4
- package/dist/orchestrator/execution/context/issue-context-fetcher.js.map +1 -1
- package/dist/orchestrator/execution/task/task-artifact-contract.d.ts +18 -0
- package/dist/orchestrator/execution/task/task-artifact-contract.d.ts.map +1 -0
- package/dist/orchestrator/execution/task/task-artifact-contract.js +176 -0
- package/dist/orchestrator/execution/task/task-artifact-contract.js.map +1 -0
- package/dist/orchestrator/execution/task/task-diff-capture.d.ts +14 -1
- package/dist/orchestrator/execution/task/task-diff-capture.d.ts.map +1 -1
- package/dist/orchestrator/execution/task/task-diff-capture.js +269 -17
- package/dist/orchestrator/execution/task/task-diff-capture.js.map +1 -1
- package/dist/orchestrator/execution/task/task-execution-helpers.d.ts +1 -0
- package/dist/orchestrator/execution/task/task-execution-helpers.d.ts.map +1 -1
- package/dist/orchestrator/execution/task/task-execution-helpers.js +76 -17
- package/dist/orchestrator/execution/task/task-execution-helpers.js.map +1 -1
- package/dist/orchestrator/execution/task/task-executor.d.ts +16 -1
- package/dist/orchestrator/execution/task/task-executor.d.ts.map +1 -1
- package/dist/orchestrator/execution/task/task-executor.js +55 -50
- package/dist/orchestrator/execution/task/task-executor.js.map +1 -1
- package/dist/orchestrator/execution/task/task-generation.d.ts +54 -1
- package/dist/orchestrator/execution/task/task-generation.d.ts.map +1 -1
- package/dist/orchestrator/execution/task/task-generation.js +19 -3
- package/dist/orchestrator/execution/task/task-generation.js.map +1 -1
- package/dist/orchestrator/execution/task/task-lifecycle-runner.d.ts +2 -2
- package/dist/orchestrator/execution/task/task-lifecycle-runner.d.ts.map +1 -1
- package/dist/orchestrator/execution/task/task-lifecycle-runner.js +31 -4
- package/dist/orchestrator/execution/task/task-lifecycle-runner.js.map +1 -1
- package/dist/orchestrator/execution/task/task-lifecycle.d.ts +3 -3
- package/dist/orchestrator/execution/task/task-lifecycle.d.ts.map +1 -1
- package/dist/orchestrator/execution/task/task-lifecycle.js +51 -10
- package/dist/orchestrator/execution/task/task-lifecycle.js.map +1 -1
- package/dist/orchestrator/execution/task/task-outcome-ledger.d.ts +8 -0
- package/dist/orchestrator/execution/task/task-outcome-ledger.d.ts.map +1 -1
- package/dist/orchestrator/execution/task/task-outcome-ledger.js +59 -3
- package/dist/orchestrator/execution/task/task-outcome-ledger.js.map +1 -1
- package/dist/orchestrator/execution/task/task-prompt-builder.d.ts +3 -1
- package/dist/orchestrator/execution/task/task-prompt-builder.d.ts.map +1 -1
- package/dist/orchestrator/execution/task/task-prompt-builder.js +23 -12
- package/dist/orchestrator/execution/task/task-prompt-builder.js.map +1 -1
- package/dist/orchestrator/execution/task/task-verifier-rules.d.ts +3 -2
- package/dist/orchestrator/execution/task/task-verifier-rules.d.ts.map +1 -1
- package/dist/orchestrator/execution/task/task-verifier-rules.js +328 -90
- package/dist/orchestrator/execution/task/task-verifier-rules.js.map +1 -1
- package/dist/orchestrator/execution/task/task-verifier-types.d.ts +13 -0
- package/dist/orchestrator/execution/task/task-verifier-types.d.ts.map +1 -1
- package/dist/orchestrator/execution/task/task-verifier-types.js.map +1 -1
- package/dist/orchestrator/execution/task/task-verifier.d.ts +5 -4
- package/dist/orchestrator/execution/task/task-verifier.d.ts.map +1 -1
- package/dist/orchestrator/execution/task/task-verifier.js +229 -22
- package/dist/orchestrator/execution/task/task-verifier.js.map +1 -1
- package/dist/orchestrator/execution/task/task-workspace.d.ts +5 -0
- package/dist/orchestrator/execution/task/task-workspace.d.ts.map +1 -1
- package/dist/orchestrator/execution/task/task-workspace.js +20 -10
- package/dist/orchestrator/execution/task/task-workspace.js.map +1 -1
- package/dist/orchestrator/execution/types/task-group.d.ts +76 -5
- package/dist/orchestrator/execution/types/task-group.d.ts.map +1 -1
- package/dist/orchestrator/execution/types/task.d.ts +117 -3
- package/dist/orchestrator/execution/types/task.d.ts.map +1 -1
- package/dist/orchestrator/execution/types/task.js +12 -0
- package/dist/orchestrator/execution/types/task.js.map +1 -1
- package/dist/orchestrator/loop/durable-loop/preparation.d.ts.map +1 -1
- package/dist/orchestrator/loop/durable-loop/preparation.js +7 -1
- package/dist/orchestrator/loop/durable-loop/preparation.js.map +1 -1
- package/dist/platform/corrections/memory-correction-ledger.d.ts +30 -30
- package/dist/platform/corrections/memory-governance.d.ts +2 -2
- package/dist/platform/knowledge/types/agent-memory.d.ts +30 -30
- package/dist/platform/observation/context-provider/collector.d.ts.map +1 -1
- package/dist/platform/observation/context-provider/collector.js +89 -24
- package/dist/platform/observation/context-provider/collector.js.map +1 -1
- package/dist/platform/observation/data-source-adapter.d.ts +2 -0
- package/dist/platform/observation/data-source-adapter.d.ts.map +1 -1
- package/dist/platform/observation/data-source-adapter.js.map +1 -1
- package/dist/platform/observation/observation-apply.d.ts.map +1 -1
- package/dist/platform/observation/observation-apply.js +8 -2
- package/dist/platform/observation/observation-apply.js.map +1 -1
- package/dist/platform/observation/observation-engine.d.ts.map +1 -1
- package/dist/platform/observation/observation-engine.js +118 -70
- package/dist/platform/observation/observation-engine.js.map +1 -1
- package/dist/platform/observation/observation-helpers.d.ts +2 -0
- package/dist/platform/observation/observation-helpers.d.ts.map +1 -1
- package/dist/platform/observation/observation-helpers.js.map +1 -1
- package/dist/platform/observation/types/data-source.d.ts +48 -0
- package/dist/platform/observation/types/data-source.d.ts.map +1 -1
- package/dist/platform/observation/types/data-source.js +4 -0
- package/dist/platform/observation/types/data-source.js.map +1 -1
- package/dist/platform/observation/workspace-context.d.ts.map +1 -1
- package/dist/platform/observation/workspace-context.js +13 -18
- package/dist/platform/observation/workspace-context.js.map +1 -1
- package/dist/platform/soil/contracts.d.ts +56 -56
- package/dist/reporting/types/report.d.ts +7 -0
- package/dist/reporting/types/report.d.ts.map +1 -1
- package/dist/runtime/approval-broker.d.ts +12 -0
- package/dist/runtime/approval-broker.d.ts.map +1 -1
- package/dist/runtime/approval-broker.js +27 -7
- package/dist/runtime/approval-broker.js.map +1 -1
- package/dist/runtime/control/daemon-runtime-control-executor.d.ts.map +1 -1
- package/dist/runtime/control/daemon-runtime-control-executor.js +9 -4
- package/dist/runtime/control/daemon-runtime-control-executor.js.map +1 -1
- package/dist/runtime/control/runtime-control-intent.d.ts.map +1 -1
- package/dist/runtime/control/runtime-control-intent.js +3 -2
- package/dist/runtime/control/runtime-control-intent.js.map +1 -1
- package/dist/runtime/control/runtime-control-service.d.ts +2 -1
- package/dist/runtime/control/runtime-control-service.d.ts.map +1 -1
- package/dist/runtime/control/runtime-control-service.js +9 -2
- package/dist/runtime/control/runtime-control-service.js.map +1 -1
- package/dist/runtime/control/runtime-target-resolver.js +2 -0
- package/dist/runtime/control/runtime-target-resolver.js.map +1 -1
- package/dist/runtime/daemon/runner-goal-cycle.d.ts.map +1 -1
- package/dist/runtime/daemon/runner-goal-cycle.js +1 -2
- package/dist/runtime/daemon/runner-goal-cycle.js.map +1 -1
- package/dist/runtime/daemon/runner-recovery.d.ts +17 -3
- package/dist/runtime/daemon/runner-recovery.d.ts.map +1 -1
- package/dist/runtime/daemon/runner-recovery.js +50 -12
- package/dist/runtime/daemon/runner-recovery.js.map +1 -1
- package/dist/runtime/daemon/runner-startup.d.ts.map +1 -1
- package/dist/runtime/daemon/runner-startup.js +18 -1
- package/dist/runtime/daemon/runner-startup.js.map +1 -1
- package/dist/runtime/daemon/runner.d.ts.map +1 -1
- package/dist/runtime/daemon/runner.js +3 -2
- package/dist/runtime/daemon/runner.js.map +1 -1
- package/dist/runtime/daemon/runtime-ownership.d.ts +0 -1
- package/dist/runtime/daemon/runtime-ownership.d.ts.map +1 -1
- package/dist/runtime/daemon/runtime-ownership.js +18 -18
- package/dist/runtime/daemon/runtime-ownership.js.map +1 -1
- package/dist/runtime/daemon/wait-deadline-resolver.d.ts.map +1 -1
- package/dist/runtime/daemon/wait-deadline-resolver.js +2 -0
- package/dist/runtime/daemon/wait-deadline-resolver.js.map +1 -1
- package/dist/runtime/evidence-answer.d.ts.map +1 -1
- package/dist/runtime/evidence-answer.js +34 -7
- package/dist/runtime/evidence-answer.js.map +1 -1
- package/dist/runtime/gateway/channel-adapter.d.ts +3 -0
- package/dist/runtime/gateway/channel-adapter.d.ts.map +1 -1
- package/dist/runtime/gateway/channel-display-policy.d.ts +42 -0
- package/dist/runtime/gateway/channel-display-policy.d.ts.map +1 -0
- package/dist/runtime/gateway/channel-display-policy.js +85 -0
- package/dist/runtime/gateway/channel-display-policy.js.map +1 -0
- package/dist/runtime/gateway/chat-event-rendering.d.ts +2 -1
- package/dist/runtime/gateway/chat-event-rendering.d.ts.map +1 -1
- package/dist/runtime/gateway/chat-event-rendering.js +2 -0
- package/dist/runtime/gateway/chat-event-rendering.js.map +1 -1
- package/dist/runtime/gateway/chat-session-dispatch.d.ts.map +1 -1
- package/dist/runtime/gateway/chat-session-dispatch.js +4 -9
- package/dist/runtime/gateway/chat-session-dispatch.js.map +1 -1
- package/dist/runtime/gateway/chat-session-port.d.ts +2 -0
- package/dist/runtime/gateway/chat-session-port.d.ts.map +1 -1
- package/dist/runtime/gateway/chat-session-port.js.map +1 -1
- package/dist/runtime/gateway/discord-gateway-adapter.d.ts +4 -0
- package/dist/runtime/gateway/discord-gateway-adapter.d.ts.map +1 -1
- package/dist/runtime/gateway/discord-gateway-adapter.js +100 -31
- package/dist/runtime/gateway/discord-gateway-adapter.js.map +1 -1
- package/dist/runtime/gateway/index.d.ts +4 -0
- package/dist/runtime/gateway/index.d.ts.map +1 -1
- package/dist/runtime/gateway/index.js +2 -0
- package/dist/runtime/gateway/index.js.map +1 -1
- package/dist/runtime/gateway/non-tui-display-projector.d.ts +40 -0
- package/dist/runtime/gateway/non-tui-display-projector.d.ts.map +1 -0
- package/dist/runtime/gateway/non-tui-display-projector.js +166 -0
- package/dist/runtime/gateway/non-tui-display-projector.js.map +1 -0
- package/dist/runtime/gateway/signal-gateway-adapter.d.ts +1 -0
- package/dist/runtime/gateway/signal-gateway-adapter.d.ts.map +1 -1
- package/dist/runtime/gateway/signal-gateway-adapter.js +47 -4
- package/dist/runtime/gateway/signal-gateway-adapter.js.map +1 -1
- package/dist/runtime/gateway/slack-channel-adapter.d.ts +1 -0
- package/dist/runtime/gateway/slack-channel-adapter.d.ts.map +1 -1
- package/dist/runtime/gateway/slack-channel-adapter.js +93 -18
- package/dist/runtime/gateway/slack-channel-adapter.js.map +1 -1
- package/dist/runtime/gateway/telegram-gateway-adapter.d.ts +2 -0
- package/dist/runtime/gateway/telegram-gateway-adapter.d.ts.map +1 -1
- package/dist/runtime/gateway/telegram-gateway-adapter.js +61 -113
- package/dist/runtime/gateway/telegram-gateway-adapter.js.map +1 -1
- package/dist/runtime/gateway/whatsapp-gateway-adapter.d.ts +1 -0
- package/dist/runtime/gateway/whatsapp-gateway-adapter.d.ts.map +1 -1
- package/dist/runtime/gateway/whatsapp-gateway-adapter.js +49 -4
- package/dist/runtime/gateway/whatsapp-gateway-adapter.js.map +1 -1
- package/dist/runtime/permission-dialogue.d.ts +113 -0
- package/dist/runtime/permission-dialogue.d.ts.map +1 -0
- package/dist/runtime/permission-dialogue.js +82 -0
- package/dist/runtime/permission-dialogue.js.map +1 -0
- package/dist/runtime/run-spec/derive.d.ts +14 -14
- package/dist/runtime/run-spec/handoff.js +2 -0
- package/dist/runtime/run-spec/handoff.js.map +1 -1
- package/dist/runtime/run-spec/types.d.ts +16 -16
- package/dist/runtime/session-registry/types.d.ts +12 -12
- package/dist/runtime/store/artifact-retention.d.ts +2 -0
- package/dist/runtime/store/artifact-retention.d.ts.map +1 -1
- package/dist/runtime/store/artifact-retention.js +24 -21
- package/dist/runtime/store/artifact-retention.js.map +1 -1
- package/dist/runtime/store/budget-store.d.ts +8 -8
- package/dist/runtime/store/evidence-ledger.d.ts.map +1 -1
- package/dist/runtime/store/evidence-ledger.js +39 -1
- package/dist/runtime/store/evidence-ledger.js.map +1 -1
- package/dist/runtime/store/evidence-types.d.ts +118 -118
- package/dist/runtime/store/experiment-queue-store.d.ts +20 -20
- package/dist/runtime/store/reproducibility-manifest.d.ts +20 -20
- package/dist/runtime/store/runtime-operation-schemas.d.ts +18 -18
- package/dist/runtime/store/runtime-operation-schemas.d.ts.map +1 -1
- package/dist/runtime/store/runtime-operation-schemas.js +1 -0
- package/dist/runtime/store/runtime-operation-schemas.js.map +1 -1
- package/dist/runtime/store/runtime-schemas.d.ts +58 -28
- package/dist/runtime/store/runtime-schemas.d.ts.map +1 -1
- package/dist/runtime/store/runtime-schemas.js +1 -0
- package/dist/runtime/store/runtime-schemas.js.map +1 -1
- package/dist/tools/execution/MemorySaveTool/MemorySaveTool.d.ts +8 -8
- package/dist/tools/execution/RunAdapterTool/RunAdapterTool.d.ts +6 -0
- package/dist/tools/execution/RunAdapterTool/RunAdapterTool.d.ts.map +1 -1
- package/dist/tools/execution/RunAdapterTool/RunAdapterTool.js +2 -0
- package/dist/tools/execution/RunAdapterTool/RunAdapterTool.js.map +1 -1
- package/dist/tools/execution-orchestrator.d.ts +29 -0
- package/dist/tools/execution-orchestrator.d.ts.map +1 -0
- package/dist/tools/execution-orchestrator.js +153 -0
- package/dist/tools/execution-orchestrator.js.map +1 -0
- package/dist/tools/executor.d.ts +6 -0
- package/dist/tools/executor.d.ts.map +1 -1
- package/dist/tools/executor.js +48 -11
- package/dist/tools/executor.js.map +1 -1
- package/dist/tools/fs/ApplyPatchTool/ApplyPatchTool.d.ts.map +1 -1
- package/dist/tools/fs/ApplyPatchTool/ApplyPatchTool.js +130 -17
- package/dist/tools/fs/ApplyPatchTool/ApplyPatchTool.js.map +1 -1
- package/dist/tools/mutation/TaskStopTool/TaskStopTool.d.ts.map +1 -1
- package/dist/tools/mutation/TaskStopTool/TaskStopTool.js +8 -0
- package/dist/tools/mutation/TaskStopTool/TaskStopTool.js.map +1 -1
- package/dist/tools/mutation/TaskUpdateTool/TaskUpdateTool.d.ts +6 -6
- package/dist/tools/network/GitHubCliTool/GitHubCliTool.d.ts +4 -4
- package/dist/tools/network/McpStdioTool/McpStdioTool.d.ts +4 -4
- package/dist/tools/permission.d.ts +0 -1
- package/dist/tools/permission.d.ts.map +1 -1
- package/dist/tools/permission.js +9 -33
- package/dist/tools/permission.js.map +1 -1
- package/dist/tools/query/CodeReadContextTool/CodeReadContextTool.d.ts +4 -4
- package/dist/tools/query/CodeSearchRepairTool/CodeSearchRepairTool.d.ts +8 -8
- package/dist/tools/query/CodeSearchTool/CodeSearchTool.d.ts +4 -4
- package/dist/tools/query/MemoryRecallTool/MemoryRecallTool.d.ts +4 -4
- package/dist/tools/query/runtime-session-tools.d.ts +73 -5
- package/dist/tools/query/runtime-session-tools.d.ts.map +1 -1
- package/dist/tools/query/runtime-session-tools.js +114 -0
- package/dist/tools/query/runtime-session-tools.js.map +1 -1
- package/dist/tools/runtime/LongRunningRuntimeTools.d.ts +60 -42
- package/dist/tools/runtime/LongRunningRuntimeTools.d.ts.map +1 -1
- package/dist/tools/runtime/LongRunningRuntimeTools.js +4 -1
- package/dist/tools/runtime/LongRunningRuntimeTools.js.map +1 -1
- package/dist/tools/runtime/RunSpecHandoffTools.d.ts.map +1 -1
- package/dist/tools/runtime/RunSpecHandoffTools.js +162 -2
- package/dist/tools/runtime/RunSpecHandoffTools.js.map +1 -1
- package/dist/tools/runtime/SetupRuntimeControlTools.d.ts.map +1 -1
- package/dist/tools/runtime/SetupRuntimeControlTools.js +169 -17
- package/dist/tools/runtime/SetupRuntimeControlTools.js.map +1 -1
- package/dist/tools/system/GitDiffTool/GitDiffTool.d.ts +4 -4
- package/dist/tools/system/ShellCommandTool/ShellCommandTool.d.ts.map +1 -1
- package/dist/tools/system/ShellCommandTool/ShellCommandTool.js +7 -1
- package/dist/tools/system/ShellCommandTool/ShellCommandTool.js.map +1 -1
- package/dist/tools/system/ShellTool/ShellTool.d.ts.map +1 -1
- package/dist/tools/system/ShellTool/ShellTool.js +24 -10
- package/dist/tools/system/ShellTool/ShellTool.js.map +1 -1
- package/dist/tools/system/ShellTool/command-policy.d.ts +11 -8
- package/dist/tools/system/ShellTool/command-policy.d.ts.map +1 -1
- package/dist/tools/system/ShellTool/command-policy.js +402 -98
- package/dist/tools/system/ShellTool/command-policy.js.map +1 -1
- package/dist/tools/system/TestRunnerTool/TestRunnerTool.d.ts +1 -1
- package/dist/tools/system/TestRunnerTool/TestRunnerTool.d.ts.map +1 -1
- package/dist/tools/system/TestRunnerTool/TestRunnerTool.js +152 -8
- package/dist/tools/system/TestRunnerTool/TestRunnerTool.js.map +1 -1
- package/dist/tools/system/UpdatePlanTool/UpdatePlanTool.js +1 -1
- package/dist/tools/system/UpdatePlanTool/UpdatePlanTool.js.map +1 -1
- package/dist/tools/types.d.ts +34 -12
- package/dist/tools/types.d.ts.map +1 -1
- package/dist/tools/types.js +26 -3
- package/dist/tools/types.js.map +1 -1
- package/dist/tools/workspace-scope.d.ts +11 -0
- package/dist/tools/workspace-scope.d.ts.map +1 -0
- package/dist/tools/workspace-scope.js +77 -0
- package/dist/tools/workspace-scope.js.map +1 -0
- package/package.json +1 -1
|
@@ -1,9 +1,37 @@
|
|
|
1
|
-
import { randomUUID } from "node:crypto";
|
|
1
|
+
import { createHash, randomUUID } from "node:crypto";
|
|
2
|
+
import * as fsp from "node:fs/promises";
|
|
3
|
+
import * as path from "node:path";
|
|
2
4
|
import { execFileNoThrow } from "../../../base/utils/execFileNoThrow.js";
|
|
3
5
|
import { createAgentLoopHistory } from "./agent-loop-history.js";
|
|
4
6
|
import { formatAgentLoopModelRef } from "./agent-loop-model.js";
|
|
5
7
|
import { ExtractiveAgentLoopCompactor } from "./agent-loop-compactor.js";
|
|
8
|
+
import { cloneAgentLoopCompactionRecords } from "./agent-loop-compaction-record.js";
|
|
6
9
|
import { classifyAgentLoopCommandResult } from "./agent-loop-command-classifier.js";
|
|
10
|
+
import { assistantTextResponseItem, functionToolCallResponseItem, } from "./response-item.js";
|
|
11
|
+
function readToolResultCheckOnly(result) {
|
|
12
|
+
const data = result.rawResult?.data;
|
|
13
|
+
if (result.toolName === "apply_patch" &&
|
|
14
|
+
data &&
|
|
15
|
+
typeof data === "object" &&
|
|
16
|
+
"checkOnly" in data &&
|
|
17
|
+
typeof data.checkOnly === "boolean") {
|
|
18
|
+
return data.checkOnly;
|
|
19
|
+
}
|
|
20
|
+
return undefined;
|
|
21
|
+
}
|
|
22
|
+
const FILESYSTEM_SNAPSHOT_EXCLUDED_DIRS = new Set([
|
|
23
|
+
".git",
|
|
24
|
+
"node_modules",
|
|
25
|
+
".venv",
|
|
26
|
+
"venv",
|
|
27
|
+
"__pycache__",
|
|
28
|
+
".cache",
|
|
29
|
+
"dist",
|
|
30
|
+
"build",
|
|
31
|
+
]);
|
|
32
|
+
const FILESYSTEM_SNAPSHOT_MAX_FILES = 5_000;
|
|
33
|
+
const FILESYSTEM_SNAPSHOT_HASH_MAX_BYTES = 1_000_000;
|
|
34
|
+
const MIN_MUTATING_TOOL_BATCH_REMAINING_MS = 1_000;
|
|
7
35
|
export class BoundedAgentLoopRunner {
|
|
8
36
|
deps;
|
|
9
37
|
compactor;
|
|
@@ -22,12 +50,14 @@ export class BoundedAgentLoopRunner {
|
|
|
22
50
|
let completionValidationAttempts = resumed?.completionValidationAttempts ?? 0;
|
|
23
51
|
let finalText = resumed?.finalText ?? "";
|
|
24
52
|
let compactions = resumed?.compactions ?? 0;
|
|
53
|
+
let compactionRecords = cloneAgentLoopCompactionRecords(resumed?.compactionRecords);
|
|
25
54
|
const calledTools = new Set(resumed?.calledTools ?? []);
|
|
26
55
|
let lastToolLoopSignature = resumed?.lastToolLoopSignature ?? null;
|
|
27
56
|
let repeatedToolLoopCount = resumed?.repeatedToolLoopCount ?? 0;
|
|
28
57
|
const commandResults = [];
|
|
29
58
|
const toolResultSummaries = [];
|
|
30
59
|
const initialWorkspaceSnapshot = await this.captureWorkspaceSnapshot(turn.cwd);
|
|
60
|
+
const stop = (reason, startedAt, modelTurns, toolCalls, finalText, output, success = false, compactions = 0, changedFiles = [], toolResults = [], commandResults = [], messages, calledTools, lastToolLoopSignature, repeatedToolLoopCount, completionValidationAttempts, reasonDetail, failureReason) => this.stop(turn, reason, startedAt, modelTurns, toolCalls, finalText, output, success, compactions, changedFiles, toolResults, commandResults, messages, calledTools, lastToolLoopSignature, repeatedToolLoopCount, completionValidationAttempts, reasonDetail, failureReason, compactionRecords);
|
|
31
61
|
await this.record(turn, {
|
|
32
62
|
type: "started",
|
|
33
63
|
...this.baseEvent(turn),
|
|
@@ -41,25 +71,26 @@ export class BoundedAgentLoopRunner {
|
|
|
41
71
|
});
|
|
42
72
|
}
|
|
43
73
|
let messages = resumed?.messages ? [...resumed.messages] : [...turn.messages];
|
|
44
|
-
const preTurnCompaction = await this.compactIfNeeded(turn, messages, "pre_turn", "context_limit", undefined, compactions);
|
|
74
|
+
const preTurnCompaction = await this.compactIfNeeded(turn, messages, "pre_turn", "context_limit", undefined, compactions, compactionRecords);
|
|
45
75
|
if (preTurnCompaction.error) {
|
|
46
|
-
return
|
|
76
|
+
return stop("fatal_error", startedAt, modelTurns, toolCalls, finalText, null, false, compactions, [], toolResultSummaries, commandResults, messages, calledTools, lastToolLoopSignature, repeatedToolLoopCount);
|
|
47
77
|
}
|
|
48
78
|
messages = preTurnCompaction.messages;
|
|
79
|
+
compactionRecords = preTurnCompaction.compactionRecords;
|
|
49
80
|
compactions += preTurnCompaction.compacted ? 1 : 0;
|
|
50
|
-
await this.saveState(turn, messages, modelTurns, toolCalls, compactions, completionValidationAttempts, calledTools, lastToolLoopSignature, repeatedToolLoopCount, finalText, "running");
|
|
81
|
+
await this.saveState(turn, messages, compactionRecords, modelTurns, toolCalls, compactions, completionValidationAttempts, calledTools, lastToolLoopSignature, repeatedToolLoopCount, finalText, "running");
|
|
51
82
|
while (true) {
|
|
52
83
|
if (Date.now() - startedAt > turn.budget.maxWallClockMs) {
|
|
53
|
-
return
|
|
84
|
+
return stop("timeout", startedAt, modelTurns, toolCalls, finalText, null, false, compactions, await this.collectChangedFiles(turn.cwd, initialWorkspaceSnapshot), toolResultSummaries, commandResults, messages, calledTools, lastToolLoopSignature, repeatedToolLoopCount);
|
|
54
85
|
}
|
|
55
86
|
if (modelTurns >= turn.budget.maxModelTurns) {
|
|
56
|
-
return
|
|
87
|
+
return stop("max_model_turns", startedAt, modelTurns, toolCalls, finalText, null, false, compactions, await this.collectChangedFiles(turn.cwd, initialWorkspaceSnapshot), toolResultSummaries, commandResults, messages, calledTools, lastToolLoopSignature, repeatedToolLoopCount);
|
|
57
88
|
}
|
|
58
89
|
if (toolCalls >= turn.budget.maxToolCalls) {
|
|
59
|
-
return
|
|
90
|
+
return stop("max_tool_calls", startedAt, modelTurns, toolCalls, finalText, null, false, compactions, await this.collectChangedFiles(turn.cwd, initialWorkspaceSnapshot), toolResultSummaries, commandResults, messages, calledTools, lastToolLoopSignature, repeatedToolLoopCount);
|
|
60
91
|
}
|
|
61
92
|
if (turn.abortSignal?.aborted) {
|
|
62
|
-
return
|
|
93
|
+
return stop("cancelled", startedAt, modelTurns, toolCalls, finalText, null, false, compactions, await this.collectChangedFiles(turn.cwd, initialWorkspaceSnapshot), toolResultSummaries, commandResults, messages, calledTools, lastToolLoopSignature, repeatedToolLoopCount);
|
|
63
94
|
}
|
|
64
95
|
const tools = this.deps.toolRouter.modelVisibleTools(turn);
|
|
65
96
|
if (modelTurns === 0) {
|
|
@@ -83,16 +114,16 @@ export class BoundedAgentLoopRunner {
|
|
|
83
114
|
}
|
|
84
115
|
catch (err) {
|
|
85
116
|
if (turn.abortSignal?.aborted) {
|
|
86
|
-
return
|
|
117
|
+
return stop("cancelled", startedAt, modelTurns, toolCalls, "Agent loop stopped: operator stop aborted active model work.", null, false, compactions, await this.collectChangedFiles(turn.cwd, initialWorkspaceSnapshot), toolResultSummaries, commandResults, messages, calledTools, lastToolLoopSignature, repeatedToolLoopCount, completionValidationAttempts, err instanceof Error ? err.message : String(err));
|
|
87
118
|
}
|
|
88
119
|
const failure = this.classifyRunFailure(err);
|
|
89
|
-
return
|
|
120
|
+
return stop(failure.reason, startedAt, modelTurns, toolCalls, failure.message, null, false, compactions, await this.collectChangedFiles(turn.cwd, initialWorkspaceSnapshot), toolResultSummaries, commandResults, messages, calledTools, lastToolLoopSignature, repeatedToolLoopCount, completionValidationAttempts, failure.detail, failure.failureReason);
|
|
90
121
|
}
|
|
91
122
|
if (!protocol.responseCompleted) {
|
|
92
|
-
return
|
|
123
|
+
return stop("protocol_incomplete", startedAt, modelTurns, toolCalls, finalText, null, false, compactions, await this.collectChangedFiles(turn.cwd, initialWorkspaceSnapshot), toolResultSummaries, commandResults, messages, calledTools, lastToolLoopSignature, repeatedToolLoopCount);
|
|
93
124
|
}
|
|
94
125
|
if (turn.abortSignal?.aborted) {
|
|
95
|
-
return
|
|
126
|
+
return stop("cancelled", startedAt, modelTurns, toolCalls, finalText, null, false, compactions, await this.collectChangedFiles(turn.cwd, initialWorkspaceSnapshot), toolResultSummaries, commandResults, messages, calledTools, lastToolLoopSignature, repeatedToolLoopCount);
|
|
96
127
|
}
|
|
97
128
|
const response = this.protocolToResponse(protocol);
|
|
98
129
|
modelTurns++;
|
|
@@ -111,20 +142,21 @@ export class BoundedAgentLoopRunner {
|
|
|
111
142
|
if (response.content.trim().length === 0) {
|
|
112
143
|
schemaRepairAttempts++;
|
|
113
144
|
if (schemaRepairAttempts > turn.budget.maxSchemaRepairAttempts) {
|
|
114
|
-
return
|
|
145
|
+
return stop("schema_error", startedAt, modelTurns, toolCalls, response.content, null, false, compactions, await this.collectChangedFiles(turn.cwd, initialWorkspaceSnapshot), toolResultSummaries, commandResults, messages, calledTools, lastToolLoopSignature, repeatedToolLoopCount);
|
|
115
146
|
}
|
|
116
147
|
messages.push({ role: "assistant", content: response.content, phase: "final_answer" });
|
|
117
148
|
messages.push({
|
|
118
149
|
role: "user",
|
|
119
150
|
content: "Your final answer was empty. Return a user-visible Markdown or plain text answer for the user.",
|
|
120
151
|
});
|
|
121
|
-
const compacted = await this.compactIfNeeded(turn, messages, "mid_turn", "context_limit", this.responseUsageTokens(protocol), compactions);
|
|
152
|
+
const compacted = await this.compactIfNeeded(turn, messages, "mid_turn", "context_limit", this.responseUsageTokens(protocol), compactions, compactionRecords);
|
|
122
153
|
if (compacted.error) {
|
|
123
|
-
return
|
|
154
|
+
return stop("fatal_error", startedAt, modelTurns, toolCalls, finalText, null, false, compactions, await this.collectChangedFiles(turn.cwd, initialWorkspaceSnapshot), toolResultSummaries, commandResults, messages, calledTools, lastToolLoopSignature, repeatedToolLoopCount);
|
|
124
155
|
}
|
|
125
156
|
messages = compacted.messages;
|
|
157
|
+
compactionRecords = compacted.compactionRecords;
|
|
126
158
|
compactions += compacted.compacted ? 1 : 0;
|
|
127
|
-
await this.saveState(turn, messages, modelTurns, toolCalls, compactions, completionValidationAttempts, calledTools, lastToolLoopSignature, repeatedToolLoopCount, finalText, "running");
|
|
159
|
+
await this.saveState(turn, messages, compactionRecords, modelTurns, toolCalls, compactions, completionValidationAttempts, calledTools, lastToolLoopSignature, repeatedToolLoopCount, finalText, "running");
|
|
128
160
|
continue;
|
|
129
161
|
}
|
|
130
162
|
const missingRequiredTools = this.missingRequiredTools(turn, calledTools);
|
|
@@ -134,13 +166,14 @@ export class BoundedAgentLoopRunner {
|
|
|
134
166
|
role: "user",
|
|
135
167
|
content: `Before the final answer, call these required tool(s) at least once: ${missingRequiredTools.join(", ")}.`,
|
|
136
168
|
});
|
|
137
|
-
const compacted = await this.compactIfNeeded(turn, messages, "mid_turn", "context_limit", this.responseUsageTokens(protocol), compactions);
|
|
169
|
+
const compacted = await this.compactIfNeeded(turn, messages, "mid_turn", "context_limit", this.responseUsageTokens(protocol), compactions, compactionRecords);
|
|
138
170
|
if (compacted.error) {
|
|
139
|
-
return
|
|
171
|
+
return stop("fatal_error", startedAt, modelTurns, toolCalls, finalText, null, false, compactions, await this.collectChangedFiles(turn.cwd, initialWorkspaceSnapshot), toolResultSummaries, commandResults, messages, calledTools, lastToolLoopSignature, repeatedToolLoopCount);
|
|
140
172
|
}
|
|
141
173
|
messages = compacted.messages;
|
|
174
|
+
compactionRecords = compacted.compactionRecords;
|
|
142
175
|
compactions += compacted.compacted ? 1 : 0;
|
|
143
|
-
await this.saveState(turn, messages, modelTurns, toolCalls, compactions, completionValidationAttempts, calledTools, lastToolLoopSignature, repeatedToolLoopCount, finalText, "running");
|
|
176
|
+
await this.saveState(turn, messages, compactionRecords, modelTurns, toolCalls, compactions, completionValidationAttempts, calledTools, lastToolLoopSignature, repeatedToolLoopCount, finalText, "running");
|
|
144
177
|
continue;
|
|
145
178
|
}
|
|
146
179
|
const changedFiles = await this.collectChangedFiles(turn.cwd, initialWorkspaceSnapshot);
|
|
@@ -150,7 +183,7 @@ export class BoundedAgentLoopRunner {
|
|
|
150
183
|
success: true,
|
|
151
184
|
outputPreview: this.preview(response.content),
|
|
152
185
|
});
|
|
153
|
-
return
|
|
186
|
+
return stop("completed", startedAt, modelTurns, toolCalls, response.content, null, true, compactions, changedFiles, toolResultSummaries, commandResults, messages, calledTools, lastToolLoopSignature, repeatedToolLoopCount, completionValidationAttempts);
|
|
154
187
|
}
|
|
155
188
|
const parsed = this.parseFinal(response.content, turn.outputSchema);
|
|
156
189
|
if (parsed.success) {
|
|
@@ -161,41 +194,45 @@ export class BoundedAgentLoopRunner {
|
|
|
161
194
|
role: "user",
|
|
162
195
|
content: `Before the final answer, call these required tool(s) at least once: ${missingRequiredTools.join(", ")}.`,
|
|
163
196
|
});
|
|
164
|
-
const compacted = await this.compactIfNeeded(turn, messages, "mid_turn", "context_limit", this.responseUsageTokens(protocol), compactions);
|
|
197
|
+
const compacted = await this.compactIfNeeded(turn, messages, "mid_turn", "context_limit", this.responseUsageTokens(protocol), compactions, compactionRecords);
|
|
165
198
|
if (compacted.error) {
|
|
166
|
-
return
|
|
199
|
+
return stop("fatal_error", startedAt, modelTurns, toolCalls, finalText, null, false, compactions, await this.collectChangedFiles(turn.cwd, initialWorkspaceSnapshot), toolResultSummaries, commandResults, messages, calledTools, lastToolLoopSignature, repeatedToolLoopCount);
|
|
167
200
|
}
|
|
168
201
|
messages = compacted.messages;
|
|
202
|
+
compactionRecords = compacted.compactionRecords;
|
|
169
203
|
compactions += compacted.compacted ? 1 : 0;
|
|
170
|
-
await this.saveState(turn, messages, modelTurns, toolCalls, compactions, completionValidationAttempts, calledTools, lastToolLoopSignature, repeatedToolLoopCount, finalText, "running");
|
|
204
|
+
await this.saveState(turn, messages, compactionRecords, modelTurns, toolCalls, compactions, completionValidationAttempts, calledTools, lastToolLoopSignature, repeatedToolLoopCount, finalText, "running");
|
|
171
205
|
continue;
|
|
172
206
|
}
|
|
173
207
|
const changedFiles = await this.collectChangedFiles(turn.cwd, initialWorkspaceSnapshot);
|
|
174
|
-
const completionValidation = turn.completionValidator
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
208
|
+
const completionValidation = turn.completionValidator
|
|
209
|
+
? await turn.completionValidator({
|
|
210
|
+
output: parsed.output,
|
|
211
|
+
changedFiles,
|
|
212
|
+
commandResults,
|
|
213
|
+
calledTools: [...calledTools],
|
|
214
|
+
modelTurns,
|
|
215
|
+
toolCalls,
|
|
216
|
+
})
|
|
217
|
+
: undefined;
|
|
182
218
|
if (completionValidation && !completionValidation.ok) {
|
|
183
219
|
completionValidationAttempts++;
|
|
184
220
|
if (completionValidationAttempts > turn.budget.maxCompletionValidationAttempts) {
|
|
185
|
-
return
|
|
221
|
+
return stop("completion_gate_failed", startedAt, modelTurns, toolCalls, response.content, null, false, compactions, changedFiles, toolResultSummaries, commandResults, messages, calledTools, lastToolLoopSignature, repeatedToolLoopCount, completionValidationAttempts);
|
|
186
222
|
}
|
|
187
223
|
messages.push({ role: "assistant", content: response.content, phase: "final_answer" });
|
|
188
224
|
messages.push({
|
|
189
225
|
role: "user",
|
|
190
226
|
content: this.buildCompletionRepairPrompt(completionValidation.reasons),
|
|
191
227
|
});
|
|
192
|
-
const compacted = await this.compactIfNeeded(turn, messages, "mid_turn", "context_limit", this.responseUsageTokens(protocol), compactions);
|
|
228
|
+
const compacted = await this.compactIfNeeded(turn, messages, "mid_turn", "context_limit", this.responseUsageTokens(protocol), compactions, compactionRecords);
|
|
193
229
|
if (compacted.error) {
|
|
194
|
-
return
|
|
230
|
+
return stop("fatal_error", startedAt, modelTurns, toolCalls, finalText, null, false, compactions, changedFiles, toolResultSummaries, commandResults, messages, calledTools, lastToolLoopSignature, repeatedToolLoopCount, completionValidationAttempts);
|
|
195
231
|
}
|
|
196
232
|
messages = compacted.messages;
|
|
233
|
+
compactionRecords = compacted.compactionRecords;
|
|
197
234
|
compactions += compacted.compacted ? 1 : 0;
|
|
198
|
-
await this.saveState(turn, messages, modelTurns, toolCalls, compactions, completionValidationAttempts, calledTools, lastToolLoopSignature, repeatedToolLoopCount, finalText, "running");
|
|
235
|
+
await this.saveState(turn, messages, compactionRecords, modelTurns, toolCalls, compactions, completionValidationAttempts, calledTools, lastToolLoopSignature, repeatedToolLoopCount, finalText, "running");
|
|
199
236
|
continue;
|
|
200
237
|
}
|
|
201
238
|
await this.record(turn, {
|
|
@@ -204,26 +241,31 @@ export class BoundedAgentLoopRunner {
|
|
|
204
241
|
success: true,
|
|
205
242
|
outputPreview: this.preview(response.content),
|
|
206
243
|
});
|
|
207
|
-
return
|
|
244
|
+
return stop("completed", startedAt, modelTurns, toolCalls, response.content, parsed.output, true, compactions, changedFiles, toolResultSummaries, commandResults, messages, calledTools, lastToolLoopSignature, repeatedToolLoopCount, completionValidationAttempts);
|
|
208
245
|
}
|
|
209
246
|
schemaRepairAttempts++;
|
|
210
247
|
if (schemaRepairAttempts > turn.budget.maxSchemaRepairAttempts) {
|
|
211
|
-
return
|
|
248
|
+
return stop("schema_error", startedAt, modelTurns, toolCalls, response.content, null, false, compactions, await this.collectChangedFiles(turn.cwd, initialWorkspaceSnapshot), toolResultSummaries, commandResults, messages, calledTools, lastToolLoopSignature, repeatedToolLoopCount);
|
|
212
249
|
}
|
|
213
250
|
messages.push({ role: "assistant", content: response.content, phase: "final_answer" });
|
|
214
251
|
messages.push({
|
|
215
252
|
role: "user",
|
|
216
253
|
content: `Your final answer did not match the required JSON schema. Return only valid JSON. Parse error: ${parsed.error}`,
|
|
217
254
|
});
|
|
218
|
-
const compacted = await this.compactIfNeeded(turn, messages, "mid_turn", "context_limit", this.responseUsageTokens(protocol), compactions);
|
|
255
|
+
const compacted = await this.compactIfNeeded(turn, messages, "mid_turn", "context_limit", this.responseUsageTokens(protocol), compactions, compactionRecords);
|
|
219
256
|
if (compacted.error) {
|
|
220
|
-
return
|
|
257
|
+
return stop("fatal_error", startedAt, modelTurns, toolCalls, finalText, null, false, compactions, await this.collectChangedFiles(turn.cwd, initialWorkspaceSnapshot), toolResultSummaries, commandResults, messages, calledTools, lastToolLoopSignature, repeatedToolLoopCount);
|
|
221
258
|
}
|
|
222
259
|
messages = compacted.messages;
|
|
260
|
+
compactionRecords = compacted.compactionRecords;
|
|
223
261
|
compactions += compacted.compacted ? 1 : 0;
|
|
224
|
-
await this.saveState(turn, messages, modelTurns, toolCalls, compactions, completionValidationAttempts, calledTools, lastToolLoopSignature, repeatedToolLoopCount, finalText, "running");
|
|
262
|
+
await this.saveState(turn, messages, compactionRecords, modelTurns, toolCalls, compactions, completionValidationAttempts, calledTools, lastToolLoopSignature, repeatedToolLoopCount, finalText, "running");
|
|
225
263
|
continue;
|
|
226
264
|
}
|
|
265
|
+
const toolBatchBudgetRefusal = this.toolBatchBudgetRefusalReason(response.toolCalls, turn, startedAt);
|
|
266
|
+
if (toolBatchBudgetRefusal) {
|
|
267
|
+
return stop("timeout", startedAt, modelTurns, toolCalls, toolBatchBudgetRefusal, null, false, compactions, await this.collectChangedFiles(turn.cwd, initialWorkspaceSnapshot), toolResultSummaries, commandResults, messages, calledTools, lastToolLoopSignature, repeatedToolLoopCount, completionValidationAttempts, toolBatchBudgetRefusal, "tool_batch_deadline_exceeded");
|
|
268
|
+
}
|
|
227
269
|
messages.push({
|
|
228
270
|
role: "assistant",
|
|
229
271
|
content: response.content || `Calling ${response.toolCalls.map((call) => call.name).join(", ")}`,
|
|
@@ -238,10 +280,10 @@ export class BoundedAgentLoopRunner {
|
|
|
238
280
|
repeatedToolLoopCount = 1;
|
|
239
281
|
}
|
|
240
282
|
if (repeatedToolLoopCount > turn.budget.maxRepeatedToolCalls) {
|
|
241
|
-
return
|
|
283
|
+
return stop("stalled_tool_loop", startedAt, modelTurns, toolCalls, finalText, null, false, compactions, await this.collectChangedFiles(turn.cwd, initialWorkspaceSnapshot), toolResultSummaries, commandResults, messages, calledTools, lastToolLoopSignature, repeatedToolLoopCount, undefined, undefined, "repeated_tool_calls");
|
|
242
284
|
}
|
|
243
285
|
if (turn.abortSignal?.aborted) {
|
|
244
|
-
return
|
|
286
|
+
return stop("cancelled", startedAt, modelTurns, toolCalls, finalText, null, false, compactions, await this.collectChangedFiles(turn.cwd, initialWorkspaceSnapshot), toolResultSummaries, commandResults, messages, calledTools, lastToolLoopSignature, repeatedToolLoopCount);
|
|
245
287
|
}
|
|
246
288
|
for (const call of response.toolCalls) {
|
|
247
289
|
const activityCategory = this.deps.toolRouter.resolveTool(call.name)?.metadata.activityCategory;
|
|
@@ -254,18 +296,40 @@ export class BoundedAgentLoopRunner {
|
|
|
254
296
|
...(activityCategory ? { activityCategory } : {}),
|
|
255
297
|
});
|
|
256
298
|
}
|
|
257
|
-
|
|
299
|
+
let toolBatch;
|
|
300
|
+
try {
|
|
301
|
+
toolBatch = await this.executeToolBatchWithinBudget(response.toolCalls, turn, startedAt);
|
|
302
|
+
}
|
|
303
|
+
catch (err) {
|
|
304
|
+
const detail = this.errorDetail(err);
|
|
305
|
+
const message = `Agent loop stopped: tool runtime failed. ${detail ? `Detail: ${detail}. ` : ""}Inspect the tool execution trace.`;
|
|
306
|
+
return stop("fatal_error", startedAt, modelTurns, toolCalls, message, null, false, compactions, await this.collectChangedFiles(turn.cwd, initialWorkspaceSnapshot), toolResultSummaries, commandResults, messages, calledTools, lastToolLoopSignature, repeatedToolLoopCount, completionValidationAttempts, detail, "tool_runtime_failure");
|
|
307
|
+
}
|
|
308
|
+
const { results: toolResults, timedOut: toolBatchTimedOut } = toolBatch;
|
|
309
|
+
if (toolBatchTimedOut && toolResults.length === 0) {
|
|
310
|
+
const timeoutReason = this.formatToolBatchWallClockExhaustedReason(response.toolCalls, turn.budget.maxWallClockMs);
|
|
311
|
+
return stop("timeout", startedAt, modelTurns, toolCalls, timeoutReason, null, false, compactions, await this.collectChangedFiles(turn.cwd, initialWorkspaceSnapshot), toolResultSummaries, commandResults, messages, calledTools, lastToolLoopSignature, repeatedToolLoopCount, completionValidationAttempts, timeoutReason, "tool_batch_timed_out");
|
|
312
|
+
}
|
|
258
313
|
for (const result of toolResults) {
|
|
259
|
-
|
|
314
|
+
const sourceCall = response.toolCalls.find((call) => call.id === result.callId);
|
|
315
|
+
const observation = this.createToolObservation(result, sourceCall, toolBatchTimedOut);
|
|
316
|
+
if (result.execution?.status !== "not_executed") {
|
|
317
|
+
calledTools.add(result.toolName);
|
|
318
|
+
}
|
|
260
319
|
toolCalls++;
|
|
320
|
+
const toolResultSequence = toolCalls;
|
|
261
321
|
if (result.success)
|
|
262
322
|
consecutiveToolErrors = 0;
|
|
263
323
|
else
|
|
264
324
|
consecutiveToolErrors++;
|
|
325
|
+
const checkOnly = readToolResultCheckOnly(result);
|
|
265
326
|
toolResultSummaries.push({
|
|
327
|
+
sequence: toolResultSequence,
|
|
266
328
|
toolName: result.toolName,
|
|
267
329
|
success: result.success,
|
|
268
330
|
...(result.execution ? { execution: result.execution } : {}),
|
|
331
|
+
...(result.artifacts ? { artifacts: result.artifacts } : {}),
|
|
332
|
+
...(checkOnly !== undefined ? { checkOnly } : {}),
|
|
269
333
|
outputSummary: this.preview(result.content),
|
|
270
334
|
durationMs: result.durationMs,
|
|
271
335
|
});
|
|
@@ -274,6 +338,7 @@ export class BoundedAgentLoopRunner {
|
|
|
274
338
|
toolCallId: result.callId,
|
|
275
339
|
toolName: result.toolName,
|
|
276
340
|
content: result.content,
|
|
341
|
+
observation,
|
|
277
342
|
});
|
|
278
343
|
await this.record(turn, {
|
|
279
344
|
type: "tool_call_finished",
|
|
@@ -289,6 +354,11 @@ export class BoundedAgentLoopRunner {
|
|
|
289
354
|
...(result.truncated ? { truncated: result.truncated } : {}),
|
|
290
355
|
...(result.activityCategory ? { activityCategory: result.activityCategory } : {}),
|
|
291
356
|
});
|
|
357
|
+
await this.record(turn, {
|
|
358
|
+
type: "tool_observation",
|
|
359
|
+
...this.baseEvent(turn),
|
|
360
|
+
observation,
|
|
361
|
+
});
|
|
292
362
|
if (result.disposition === "approval_denied") {
|
|
293
363
|
await this.record(turn, {
|
|
294
364
|
type: "approval",
|
|
@@ -309,36 +379,42 @@ export class BoundedAgentLoopRunner {
|
|
|
309
379
|
const commandClassification = classifyAgentLoopCommandResult({
|
|
310
380
|
toolName: result.toolName,
|
|
311
381
|
command: result.command,
|
|
382
|
+
activityCategory: result.activityCategory,
|
|
383
|
+
verificationPlan: turn.verificationPlan,
|
|
312
384
|
});
|
|
313
385
|
commandResults.push({
|
|
386
|
+
sequence: toolResultSequence,
|
|
314
387
|
toolName: result.toolName,
|
|
315
388
|
command: result.command,
|
|
316
389
|
cwd: result.cwd,
|
|
317
390
|
success: result.success,
|
|
318
391
|
...(result.execution ? { execution: result.execution } : {}),
|
|
392
|
+
...(result.activityCategory ? { activityCategory: result.activityCategory } : {}),
|
|
319
393
|
category: commandClassification.category,
|
|
320
394
|
evidenceEligible: commandClassification.evidenceEligible,
|
|
395
|
+
...(commandClassification.evidenceSource ? { evidenceSource: commandClassification.evidenceSource } : {}),
|
|
321
396
|
outputSummary: this.preview(result.content),
|
|
322
397
|
durationMs: result.durationMs,
|
|
323
398
|
});
|
|
324
399
|
}
|
|
325
400
|
if (result.disposition === "fatal" || result.fatal) {
|
|
326
|
-
return
|
|
401
|
+
return stop("fatal_error", startedAt, modelTurns, toolCalls, finalText, null, false, compactions, await this.collectChangedFiles(turn.cwd, initialWorkspaceSnapshot), toolResultSummaries, commandResults, messages, calledTools, lastToolLoopSignature, repeatedToolLoopCount, undefined, undefined, "tool_fatal");
|
|
327
402
|
}
|
|
328
403
|
if (result.disposition === "cancelled") {
|
|
329
|
-
return
|
|
404
|
+
return stop(toolBatchTimedOut ? "timeout" : "cancelled", startedAt, modelTurns, toolCalls, finalText, null, false, compactions, await this.collectChangedFiles(turn.cwd, initialWorkspaceSnapshot), toolResultSummaries, commandResults, messages, calledTools, lastToolLoopSignature, repeatedToolLoopCount, undefined, undefined, toolBatchTimedOut ? "tool_batch_timed_out" : "tool_cancelled");
|
|
330
405
|
}
|
|
331
406
|
if (consecutiveToolErrors >= turn.budget.maxConsecutiveToolErrors) {
|
|
332
|
-
return
|
|
407
|
+
return stop("consecutive_tool_errors", startedAt, modelTurns, toolCalls, finalText, null, false, compactions, await this.collectChangedFiles(turn.cwd, initialWorkspaceSnapshot), toolResultSummaries, commandResults, messages, calledTools, lastToolLoopSignature, repeatedToolLoopCount, undefined, undefined, "consecutive_tool_errors");
|
|
333
408
|
}
|
|
334
409
|
}
|
|
335
|
-
const compacted = await this.compactIfNeeded(turn, messages, "mid_turn", "context_limit", this.responseUsageTokens(protocol), compactions);
|
|
410
|
+
const compacted = await this.compactIfNeeded(turn, messages, "mid_turn", "context_limit", this.responseUsageTokens(protocol), compactions, compactionRecords);
|
|
336
411
|
if (compacted.error) {
|
|
337
|
-
return
|
|
412
|
+
return stop("fatal_error", startedAt, modelTurns, toolCalls, finalText, null, false, compactions, await this.collectChangedFiles(turn.cwd, initialWorkspaceSnapshot), toolResultSummaries, commandResults, messages, calledTools, lastToolLoopSignature, repeatedToolLoopCount);
|
|
338
413
|
}
|
|
339
414
|
messages = compacted.messages;
|
|
415
|
+
compactionRecords = compacted.compactionRecords;
|
|
340
416
|
compactions += compacted.compacted ? 1 : 0;
|
|
341
|
-
await this.saveState(turn, messages, modelTurns, toolCalls, compactions, completionValidationAttempts, calledTools, lastToolLoopSignature, repeatedToolLoopCount, finalText, "running");
|
|
417
|
+
await this.saveState(turn, messages, compactionRecords, modelTurns, toolCalls, compactions, completionValidationAttempts, calledTools, lastToolLoopSignature, repeatedToolLoopCount, finalText, "running");
|
|
342
418
|
}
|
|
343
419
|
}
|
|
344
420
|
parseFinal(content, schema) {
|
|
@@ -354,12 +430,14 @@ export class BoundedAgentLoopRunner {
|
|
|
354
430
|
const fence = content.match(/```json\s*([\s\S]*?)\s*```/);
|
|
355
431
|
return fence?.[1] ?? content;
|
|
356
432
|
}
|
|
357
|
-
async stop(turn, reason, startedAt, modelTurns, toolCalls, finalText, output, success = false, compactions = 0, changedFiles = [], toolResults = [], commandResults = [], messages, calledTools, lastToolLoopSignature, repeatedToolLoopCount, completionValidationAttempts, reasonDetail) {
|
|
358
|
-
|
|
433
|
+
async stop(turn, reason, startedAt, modelTurns, toolCalls, finalText, output, success = false, compactions = 0, changedFiles = [], toolResults = [], commandResults = [], messages, calledTools, lastToolLoopSignature, repeatedToolLoopCount, completionValidationAttempts, reasonDetail, failureReason, compactionRecords = []) {
|
|
434
|
+
const resolvedFailureReason = success ? undefined : failureReason ?? this.defaultFailureReason(reason);
|
|
435
|
+
await this.saveState(turn, messages ?? turn.messages, compactionRecords, modelTurns, toolCalls, compactions, completionValidationAttempts ?? 0, calledTools ?? new Set(), lastToolLoopSignature ?? null, repeatedToolLoopCount ?? 0, finalText, success ? "completed" : "failed", reason, reasonDetail, resolvedFailureReason);
|
|
359
436
|
await this.record(turn, {
|
|
360
437
|
type: "stopped",
|
|
361
438
|
...this.baseEvent(turn),
|
|
362
439
|
reason,
|
|
440
|
+
...(resolvedFailureReason ? { failureReason: resolvedFailureReason } : {}),
|
|
363
441
|
...(reasonDetail ? { reasonDetail } : {}),
|
|
364
442
|
});
|
|
365
443
|
return {
|
|
@@ -367,6 +445,8 @@ export class BoundedAgentLoopRunner {
|
|
|
367
445
|
output,
|
|
368
446
|
finalText,
|
|
369
447
|
stopReason: reason,
|
|
448
|
+
...(resolvedFailureReason ? { failureReason: resolvedFailureReason } : {}),
|
|
449
|
+
...(reasonDetail ? { failureDetail: reasonDetail } : {}),
|
|
370
450
|
elapsedMs: Date.now() - startedAt,
|
|
371
451
|
modelTurns,
|
|
372
452
|
toolCalls,
|
|
@@ -378,6 +458,9 @@ export class BoundedAgentLoopRunner {
|
|
|
378
458
|
traceId: turn.session.traceId,
|
|
379
459
|
sessionId: turn.session.sessionId,
|
|
380
460
|
turnId: turn.turnId,
|
|
461
|
+
...(turn.profileName ? { profileName: turn.profileName } : {}),
|
|
462
|
+
...(turn.reasoningEffort ? { reasoningEffort: turn.reasoningEffort } : {}),
|
|
463
|
+
...(turn.executionPolicy ? { executionPolicy: turn.executionPolicy } : {}),
|
|
381
464
|
};
|
|
382
465
|
}
|
|
383
466
|
buildCompletionRepairPrompt(reasons) {
|
|
@@ -419,47 +502,101 @@ export class BoundedAgentLoopRunner {
|
|
|
419
502
|
return String(value);
|
|
420
503
|
}
|
|
421
504
|
}
|
|
505
|
+
defaultFailureReason(reason) {
|
|
506
|
+
switch (reason) {
|
|
507
|
+
case "timeout":
|
|
508
|
+
return "wall_clock_timeout";
|
|
509
|
+
case "max_model_turns":
|
|
510
|
+
return "max_model_turns";
|
|
511
|
+
case "max_tool_calls":
|
|
512
|
+
return "max_tool_calls";
|
|
513
|
+
case "consecutive_tool_errors":
|
|
514
|
+
return "consecutive_tool_errors";
|
|
515
|
+
case "stalled_tool_loop":
|
|
516
|
+
return "repeated_tool_calls";
|
|
517
|
+
case "schema_error":
|
|
518
|
+
return "schema_validation_failed";
|
|
519
|
+
case "cancelled":
|
|
520
|
+
return "operator_cancelled";
|
|
521
|
+
case "protocol_incomplete":
|
|
522
|
+
return "protocol_incomplete";
|
|
523
|
+
case "completion_gate_failed":
|
|
524
|
+
return "completion_gate_failed";
|
|
525
|
+
case "fatal_error":
|
|
526
|
+
default:
|
|
527
|
+
return "provider_failure";
|
|
528
|
+
}
|
|
529
|
+
}
|
|
422
530
|
classifyRunFailure(error) {
|
|
423
|
-
const detail = error
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
.join(": ")
|
|
427
|
-
: String(error);
|
|
428
|
-
const lowered = detail.toLowerCase();
|
|
429
|
-
if (lowered.includes("timeout")
|
|
430
|
-
|| lowered.includes("timed out")
|
|
431
|
-
|| lowered.includes("aborterror")
|
|
432
|
-
|| lowered.includes("aborted")) {
|
|
531
|
+
const detail = this.errorDetail(error);
|
|
532
|
+
const structured = this.structuredRunFailureReason(error);
|
|
533
|
+
if (structured === "model_request_timeout") {
|
|
433
534
|
return {
|
|
434
535
|
reason: "timeout",
|
|
536
|
+
failureReason: "model_request_timeout",
|
|
435
537
|
detail,
|
|
436
538
|
message: "Agent loop stopped: model request timed out. Narrow broad repo-wide searches or increase `codex_timeout_ms` if this workload is expected.",
|
|
437
539
|
};
|
|
438
540
|
}
|
|
541
|
+
if (structured === "model_request_aborted") {
|
|
542
|
+
return {
|
|
543
|
+
reason: "fatal_error",
|
|
544
|
+
failureReason: "model_request_aborted",
|
|
545
|
+
detail,
|
|
546
|
+
message: "Agent loop stopped: model request was aborted by the provider or transport. Retry the turn or inspect the provider connection.",
|
|
547
|
+
};
|
|
548
|
+
}
|
|
439
549
|
return {
|
|
440
550
|
reason: "fatal_error",
|
|
551
|
+
failureReason: "provider_failure",
|
|
441
552
|
detail,
|
|
442
553
|
message: `Agent loop stopped: model request failed. ${detail ? `Detail: ${detail}. ` : ""}Retry the turn or inspect the provider connection.`,
|
|
443
554
|
};
|
|
444
555
|
}
|
|
445
|
-
|
|
556
|
+
structuredRunFailureReason(error) {
|
|
557
|
+
if (!error || typeof error !== "object")
|
|
558
|
+
return null;
|
|
559
|
+
const value = error;
|
|
560
|
+
if (value.agentLoopFailureReason === "model_request_timeout" || value.agentLoopFailureReason === "model_request_aborted") {
|
|
561
|
+
return value.agentLoopFailureReason;
|
|
562
|
+
}
|
|
563
|
+
if (value.name === "TimeoutError" || value.code === "ETIMEDOUT" || value.code === "UND_ERR_HEADERS_TIMEOUT" || value.code === "UND_ERR_BODY_TIMEOUT") {
|
|
564
|
+
return "model_request_timeout";
|
|
565
|
+
}
|
|
566
|
+
if (value.name === "AbortError" || value.code === "ABORT_ERR") {
|
|
567
|
+
return "model_request_aborted";
|
|
568
|
+
}
|
|
569
|
+
return this.structuredRunFailureReason(value.cause);
|
|
570
|
+
}
|
|
571
|
+
errorDetail(error) {
|
|
572
|
+
return error instanceof Error
|
|
573
|
+
? [error.name !== "Error" ? error.name : null, error.message]
|
|
574
|
+
.filter((part) => typeof part === "string" && part.length > 0)
|
|
575
|
+
.join(": ")
|
|
576
|
+
: String(error);
|
|
577
|
+
}
|
|
578
|
+
async compactIfNeeded(turn, messages, phase, reason, usageTokens, compactions, compactionRecords) {
|
|
446
579
|
const limit = this.autoCompactLimit(turn);
|
|
447
580
|
if (!limit || compactions >= turn.budget.maxCompactions) {
|
|
448
|
-
return { messages, compacted: false };
|
|
581
|
+
return { messages, compactionRecords: cloneAgentLoopCompactionRecords(compactionRecords), compacted: false };
|
|
449
582
|
}
|
|
450
583
|
const tokens = usageTokens && usageTokens > 0 ? usageTokens : this.estimateTokens(messages);
|
|
451
584
|
if (tokens < limit) {
|
|
452
|
-
return { messages, compacted: false };
|
|
585
|
+
return { messages, compactionRecords: cloneAgentLoopCompactionRecords(compactionRecords), compacted: false };
|
|
453
586
|
}
|
|
454
587
|
try {
|
|
455
588
|
const result = await this.compactor.compact({
|
|
456
|
-
history: createAgentLoopHistory(messages),
|
|
589
|
+
history: createAgentLoopHistory(messages, compactionRecords),
|
|
457
590
|
maxMessages: turn.budget.compactionMaxMessages,
|
|
458
591
|
phase,
|
|
459
592
|
reason,
|
|
460
593
|
});
|
|
461
594
|
if (!result.compacted) {
|
|
462
|
-
return {
|
|
595
|
+
return {
|
|
596
|
+
messages: result.history.messages,
|
|
597
|
+
compactionRecords: cloneAgentLoopCompactionRecords(result.history.compactionRecords),
|
|
598
|
+
compacted: false,
|
|
599
|
+
};
|
|
463
600
|
}
|
|
464
601
|
await this.record(turn, {
|
|
465
602
|
type: "context_compaction",
|
|
@@ -470,10 +607,19 @@ export class BoundedAgentLoopRunner {
|
|
|
470
607
|
outputMessages: result.history.messages.length,
|
|
471
608
|
summaryPreview: this.preview(result.summary ?? ""),
|
|
472
609
|
});
|
|
473
|
-
return {
|
|
610
|
+
return {
|
|
611
|
+
messages: result.history.messages,
|
|
612
|
+
compactionRecords: cloneAgentLoopCompactionRecords(result.history.compactionRecords),
|
|
613
|
+
compacted: true,
|
|
614
|
+
};
|
|
474
615
|
}
|
|
475
616
|
catch (err) {
|
|
476
|
-
return {
|
|
617
|
+
return {
|
|
618
|
+
messages,
|
|
619
|
+
compactionRecords: cloneAgentLoopCompactionRecords(compactionRecords),
|
|
620
|
+
compacted: false,
|
|
621
|
+
error: err instanceof Error ? err.message : String(err),
|
|
622
|
+
};
|
|
477
623
|
}
|
|
478
624
|
}
|
|
479
625
|
autoCompactLimit(turn) {
|
|
@@ -484,7 +630,10 @@ export class BoundedAgentLoopRunner {
|
|
|
484
630
|
return contextLimit && contextLimit > 0 ? Math.floor(contextLimit * 0.9) : undefined;
|
|
485
631
|
}
|
|
486
632
|
async executeToolBatchWithinBudget(calls, turn, startedAt) {
|
|
487
|
-
const remainingMs =
|
|
633
|
+
const remainingMs = turn.budget.maxWallClockMs - (Date.now() - startedAt);
|
|
634
|
+
if (remainingMs <= 0) {
|
|
635
|
+
return { results: [], timedOut: true };
|
|
636
|
+
}
|
|
488
637
|
const controller = new AbortController();
|
|
489
638
|
const parentSignal = turn.abortSignal;
|
|
490
639
|
let timedOut = false;
|
|
@@ -517,6 +666,34 @@ export class BoundedAgentLoopRunner {
|
|
|
517
666
|
parentSignal?.removeEventListener("abort", abortFromParent);
|
|
518
667
|
}
|
|
519
668
|
}
|
|
669
|
+
toolBatchBudgetRefusalReason(calls, turn, startedAt) {
|
|
670
|
+
const remainingMs = turn.budget.maxWallClockMs - (Date.now() - startedAt);
|
|
671
|
+
if (remainingMs <= 0) {
|
|
672
|
+
return this.formatToolBatchWallClockExhaustedReason(calls, turn.budget.maxWallClockMs);
|
|
673
|
+
}
|
|
674
|
+
const mutatingToolNames = calls
|
|
675
|
+
.filter((call) => this.isMutatingToolCall(call))
|
|
676
|
+
.map((call) => call.name);
|
|
677
|
+
if (mutatingToolNames.length === 0 || remainingMs >= MIN_MUTATING_TOOL_BATCH_REMAINING_MS) {
|
|
678
|
+
return null;
|
|
679
|
+
}
|
|
680
|
+
return [
|
|
681
|
+
"Tool batch was not started because the remaining wall-clock budget",
|
|
682
|
+
`(${Math.floor(remainingMs)}ms) is below the ${MIN_MUTATING_TOOL_BATCH_REMAINING_MS}ms minimum`,
|
|
683
|
+
`for mutating tools: ${[...new Set(mutatingToolNames)].join(", ")}.`,
|
|
684
|
+
].join(" ");
|
|
685
|
+
}
|
|
686
|
+
formatToolBatchWallClockExhaustedReason(calls, maxWallClockMs) {
|
|
687
|
+
return [
|
|
688
|
+
"Tool batch was not started because the agent loop wall-clock budget is exhausted",
|
|
689
|
+
`(0ms remaining; limit ${maxWallClockMs}ms).`,
|
|
690
|
+
`Requested tools: ${calls.map((call) => call.name).join(", ")}.`,
|
|
691
|
+
].join(" ");
|
|
692
|
+
}
|
|
693
|
+
isMutatingToolCall(call) {
|
|
694
|
+
const metadata = this.deps.toolRouter.resolveTool(call.name)?.metadata;
|
|
695
|
+
return metadata?.isReadOnly !== true;
|
|
696
|
+
}
|
|
520
697
|
responseUsageTokens(response) {
|
|
521
698
|
if (!response.usage)
|
|
522
699
|
return undefined;
|
|
@@ -529,6 +706,56 @@ export class BoundedAgentLoopRunner {
|
|
|
529
706
|
missingRequiredTools(turn, calledTools) {
|
|
530
707
|
return [...(turn.toolPolicy.requiredTools ?? [])].filter((toolName) => !calledTools.has(toolName));
|
|
531
708
|
}
|
|
709
|
+
createToolObservation(result, sourceCall, toolBatchTimedOut) {
|
|
710
|
+
const state = this.toolObservationState(result, toolBatchTimedOut);
|
|
711
|
+
const execution = this.toolObservationExecution(result, state);
|
|
712
|
+
const rawResult = result.rawResult;
|
|
713
|
+
return {
|
|
714
|
+
type: "tool_observation",
|
|
715
|
+
callId: result.callId,
|
|
716
|
+
toolName: result.toolName,
|
|
717
|
+
arguments: sourceCall?.input ?? {},
|
|
718
|
+
state,
|
|
719
|
+
success: result.success,
|
|
720
|
+
execution,
|
|
721
|
+
durationMs: result.durationMs,
|
|
722
|
+
output: {
|
|
723
|
+
content: result.content,
|
|
724
|
+
...(rawResult?.summary ? { summary: rawResult.summary } : {}),
|
|
725
|
+
...(rawResult && Object.prototype.hasOwnProperty.call(rawResult, "data") ? { data: rawResult.data } : {}),
|
|
726
|
+
...(rawResult?.error ? { error: rawResult.error } : {}),
|
|
727
|
+
},
|
|
728
|
+
...(result.command ? { command: result.command } : {}),
|
|
729
|
+
...(result.cwd ? { cwd: result.cwd } : {}),
|
|
730
|
+
...(result.artifacts ? { artifacts: result.artifacts } : {}),
|
|
731
|
+
...(result.truncated ? { truncated: result.truncated } : {}),
|
|
732
|
+
...(result.activityCategory ? { activityCategory: result.activityCategory } : {}),
|
|
733
|
+
};
|
|
734
|
+
}
|
|
735
|
+
toolObservationState(result, toolBatchTimedOut) {
|
|
736
|
+
const reason = result.execution?.reason;
|
|
737
|
+
if (reason === "timed_out" || (toolBatchTimedOut && result.disposition === "cancelled"))
|
|
738
|
+
return "timed_out";
|
|
739
|
+
if (reason === "interrupted" || result.disposition === "cancelled")
|
|
740
|
+
return "interrupted";
|
|
741
|
+
if (reason === "approval_denied" || reason === "permission_denied")
|
|
742
|
+
return "denied";
|
|
743
|
+
if (reason === "policy_blocked" || reason === "dry_run")
|
|
744
|
+
return "blocked";
|
|
745
|
+
return result.success ? "success" : "failure";
|
|
746
|
+
}
|
|
747
|
+
toolObservationExecution(result, state) {
|
|
748
|
+
if (result.execution)
|
|
749
|
+
return result.execution;
|
|
750
|
+
if (state === "timed_out" || state === "interrupted") {
|
|
751
|
+
return {
|
|
752
|
+
status: "executed",
|
|
753
|
+
reason: state === "timed_out" ? "timed_out" : "interrupted",
|
|
754
|
+
message: result.content,
|
|
755
|
+
};
|
|
756
|
+
}
|
|
757
|
+
return { status: "executed" };
|
|
758
|
+
}
|
|
532
759
|
async createTurnProtocol(turn, messages, tools) {
|
|
533
760
|
if (this.deps.modelClient.createTurnProtocol) {
|
|
534
761
|
return this.deps.modelClient.createTurnProtocol({
|
|
@@ -550,18 +777,36 @@ export class BoundedAgentLoopRunner {
|
|
|
550
777
|
phase: response.toolCalls.length > 0 ? "commentary" : "final_answer",
|
|
551
778
|
}] : [],
|
|
552
779
|
toolCalls: response.toolCalls,
|
|
780
|
+
responseItems: [
|
|
781
|
+
...(response.content || response.toolCalls.length > 0
|
|
782
|
+
? [assistantTextResponseItem(response.content || `Calling ${response.toolCalls.map((call) => call.name).join(", ")}`, response.toolCalls.length > 0 ? "commentary" : "final_answer")]
|
|
783
|
+
: []),
|
|
784
|
+
...response.toolCalls.map((call) => functionToolCallResponseItem(call)),
|
|
785
|
+
],
|
|
553
786
|
stopReason: response.stopReason,
|
|
554
787
|
responseCompleted: true,
|
|
555
788
|
usage: response.usage,
|
|
556
789
|
};
|
|
557
790
|
}
|
|
558
791
|
protocolToResponse(protocol) {
|
|
792
|
+
const responseItemText = protocol.responseItems
|
|
793
|
+
?.filter((item) => item.type === "assistant_text")
|
|
794
|
+
.map((item) => item.content)
|
|
795
|
+
.filter(Boolean)
|
|
796
|
+
.join("\n");
|
|
797
|
+
const responseItemToolCalls = protocol.responseItems
|
|
798
|
+
?.filter((item) => item.type === "function_tool_call")
|
|
799
|
+
.map((item) => ({
|
|
800
|
+
id: item.id,
|
|
801
|
+
name: item.name,
|
|
802
|
+
input: item.arguments,
|
|
803
|
+
}));
|
|
559
804
|
return {
|
|
560
|
-
content: protocol.assistant.map((item) => item.content).filter(Boolean).join("\n"),
|
|
561
|
-
toolCalls: protocol.toolCalls,
|
|
805
|
+
content: protocol.assistant.map((item) => item.content).filter(Boolean).join("\n") || responseItemText || "",
|
|
806
|
+
toolCalls: protocol.responseItems ? responseItemToolCalls ?? [] : protocol.toolCalls,
|
|
562
807
|
};
|
|
563
808
|
}
|
|
564
|
-
async saveState(turn, messages, modelTurns, toolCalls, compactions, completionValidationAttempts, calledTools, lastToolLoopSignature, repeatedToolLoopCount, finalText, status, stopReason, stopDetail) {
|
|
809
|
+
async saveState(turn, messages, compactionRecords, modelTurns, toolCalls, compactions, completionValidationAttempts, calledTools, lastToolLoopSignature, repeatedToolLoopCount, finalText, status, stopReason, stopDetail, failureReason) {
|
|
565
810
|
const state = {
|
|
566
811
|
sessionId: turn.session.sessionId,
|
|
567
812
|
traceId: turn.session.traceId,
|
|
@@ -571,6 +816,7 @@ export class BoundedAgentLoopRunner {
|
|
|
571
816
|
cwd: turn.cwd,
|
|
572
817
|
modelRef: formatAgentLoopModelRef(turn.model),
|
|
573
818
|
messages,
|
|
819
|
+
compactionRecords: cloneAgentLoopCompactionRecords(compactionRecords),
|
|
574
820
|
modelTurns,
|
|
575
821
|
toolCalls,
|
|
576
822
|
compactions,
|
|
@@ -581,6 +827,7 @@ export class BoundedAgentLoopRunner {
|
|
|
581
827
|
finalText,
|
|
582
828
|
status,
|
|
583
829
|
...(stopReason ? { stopReason } : {}),
|
|
830
|
+
...(failureReason ? { failureReason } : {}),
|
|
584
831
|
...(stopDetail ? { stopDetail } : {}),
|
|
585
832
|
updatedAt: new Date().toISOString(),
|
|
586
833
|
};
|
|
@@ -588,18 +835,22 @@ export class BoundedAgentLoopRunner {
|
|
|
588
835
|
}
|
|
589
836
|
async captureWorkspaceSnapshot(cwd) {
|
|
590
837
|
const result = await execFileNoThrow("git", ["status", "--porcelain", "--untracked-files=all"], { cwd, timeoutMs: 10_000 });
|
|
591
|
-
if ((result.exitCode ?? 1)
|
|
592
|
-
return
|
|
593
|
-
|
|
838
|
+
if ((result.exitCode ?? 1) === 0) {
|
|
839
|
+
return { kind: "git", paths: new Set(this.parseGitStatusPaths(result.stdout)) };
|
|
840
|
+
}
|
|
841
|
+
return { kind: "filesystem", files: await this.captureFilesystemSnapshot(cwd) };
|
|
594
842
|
}
|
|
595
843
|
async collectChangedFiles(cwd, before) {
|
|
596
844
|
const afterResult = await execFileNoThrow("git", ["status", "--porcelain", "--untracked-files=all"], { cwd, timeoutMs: 10_000 });
|
|
597
|
-
if ((afterResult.exitCode ?? 1) !== 0)
|
|
598
|
-
|
|
845
|
+
if ((afterResult.exitCode ?? 1) !== 0) {
|
|
846
|
+
if (before?.kind !== "filesystem")
|
|
847
|
+
return [];
|
|
848
|
+
return this.collectFilesystemChangedPaths(before.files, await this.captureFilesystemSnapshot(cwd));
|
|
849
|
+
}
|
|
599
850
|
const after = new Set(this.parseGitStatusPaths(afterResult.stdout));
|
|
600
|
-
if (!before)
|
|
851
|
+
if (!before || before.kind !== "git")
|
|
601
852
|
return [...after];
|
|
602
|
-
return [...after].filter((file) => !before.has(file));
|
|
853
|
+
return [...after].filter((file) => !before.paths.has(file));
|
|
603
854
|
}
|
|
604
855
|
parseGitStatusPaths(stdout) {
|
|
605
856
|
return stdout
|
|
@@ -609,5 +860,74 @@ export class BoundedAgentLoopRunner {
|
|
|
609
860
|
.map((line) => line.slice(3).trim())
|
|
610
861
|
.map((filePath) => filePath.includes(" -> ") ? filePath.split(" -> ").at(-1) ?? filePath : filePath);
|
|
611
862
|
}
|
|
863
|
+
async captureFilesystemSnapshot(cwd) {
|
|
864
|
+
const files = new Map();
|
|
865
|
+
const root = path.resolve(cwd);
|
|
866
|
+
const visit = async (dir) => {
|
|
867
|
+
if (files.size >= FILESYSTEM_SNAPSHOT_MAX_FILES)
|
|
868
|
+
return;
|
|
869
|
+
let entries;
|
|
870
|
+
try {
|
|
871
|
+
entries = await fsp.readdir(dir, { withFileTypes: true });
|
|
872
|
+
}
|
|
873
|
+
catch {
|
|
874
|
+
return;
|
|
875
|
+
}
|
|
876
|
+
for (const entry of entries) {
|
|
877
|
+
if (files.size >= FILESYSTEM_SNAPSHOT_MAX_FILES)
|
|
878
|
+
return;
|
|
879
|
+
if (entry.name.startsWith(".pulseed-"))
|
|
880
|
+
continue;
|
|
881
|
+
const absolutePath = path.join(dir, entry.name);
|
|
882
|
+
if (entry.isDirectory()) {
|
|
883
|
+
if (!FILESYSTEM_SNAPSHOT_EXCLUDED_DIRS.has(entry.name)) {
|
|
884
|
+
await visit(absolutePath);
|
|
885
|
+
}
|
|
886
|
+
continue;
|
|
887
|
+
}
|
|
888
|
+
if (!entry.isFile())
|
|
889
|
+
continue;
|
|
890
|
+
const relativePath = path.relative(root, absolutePath).replace(/\\/g, "/");
|
|
891
|
+
try {
|
|
892
|
+
const stat = await fsp.stat(absolutePath);
|
|
893
|
+
const snapshotEntry = {
|
|
894
|
+
size: stat.size,
|
|
895
|
+
mtimeMs: stat.mtimeMs,
|
|
896
|
+
};
|
|
897
|
+
if (stat.size <= FILESYSTEM_SNAPSHOT_HASH_MAX_BYTES) {
|
|
898
|
+
snapshotEntry.hash = createHash("sha256")
|
|
899
|
+
.update(await fsp.readFile(absolutePath))
|
|
900
|
+
.digest("hex");
|
|
901
|
+
}
|
|
902
|
+
files.set(relativePath, snapshotEntry);
|
|
903
|
+
}
|
|
904
|
+
catch {
|
|
905
|
+
// File may have changed while scanning; skip and let the next scan observe it.
|
|
906
|
+
}
|
|
907
|
+
}
|
|
908
|
+
};
|
|
909
|
+
await visit(root);
|
|
910
|
+
return files;
|
|
911
|
+
}
|
|
912
|
+
collectFilesystemChangedPaths(before, after) {
|
|
913
|
+
const changed = new Set();
|
|
914
|
+
for (const [filePath, afterEntry] of after) {
|
|
915
|
+
const beforeEntry = before.get(filePath);
|
|
916
|
+
if (!beforeEntry || !this.sameFilesystemEntry(beforeEntry, afterEntry)) {
|
|
917
|
+
changed.add(filePath);
|
|
918
|
+
}
|
|
919
|
+
}
|
|
920
|
+
for (const filePath of before.keys()) {
|
|
921
|
+
if (!after.has(filePath)) {
|
|
922
|
+
changed.add(filePath);
|
|
923
|
+
}
|
|
924
|
+
}
|
|
925
|
+
return [...changed].sort();
|
|
926
|
+
}
|
|
927
|
+
sameFilesystemEntry(left, right) {
|
|
928
|
+
if (left.hash && right.hash)
|
|
929
|
+
return left.hash === right.hash;
|
|
930
|
+
return left.size === right.size && left.mtimeMs === right.mtimeMs;
|
|
931
|
+
}
|
|
612
932
|
}
|
|
613
933
|
//# sourceMappingURL=bounded-agent-loop-runner.js.map
|