gsd-pi 2.80.0-dev.2be7caf18 → 2.80.0-dev.3065f7bfa
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 +1 -0
- package/dist/resources/.managed-resources-content-hash +1 -1
- package/dist/resources/extensions/gsd/auto/phases.js +178 -108
- package/dist/resources/extensions/gsd/auto/resolve.js +17 -0
- package/dist/resources/extensions/gsd/auto/run-unit.js +20 -30
- package/dist/resources/extensions/gsd/auto/session.js +8 -0
- package/dist/resources/extensions/gsd/auto-direct-dispatch.js +5 -32
- package/dist/resources/extensions/gsd/auto-dispatch.js +16 -0
- package/dist/resources/extensions/gsd/auto-post-unit.js +17 -4
- package/dist/resources/extensions/gsd/auto-prompts.js +90 -15
- package/dist/resources/extensions/gsd/auto-recovery.js +43 -1
- package/dist/resources/extensions/gsd/auto-start.js +197 -6
- package/dist/resources/extensions/gsd/auto-supervisor.js +8 -1
- package/dist/resources/extensions/gsd/auto-timeout-recovery.js +2 -2
- package/dist/resources/extensions/gsd/auto-worktree.js +111 -1
- package/dist/resources/extensions/gsd/auto.js +79 -24
- package/dist/resources/extensions/gsd/bootstrap/agent-end-recovery.js +42 -2
- package/dist/resources/extensions/gsd/bootstrap/db-tools.js +49 -36
- package/dist/resources/extensions/gsd/bootstrap/dynamic-tools.js +15 -5
- package/dist/resources/extensions/gsd/bootstrap/exec-tools.js +9 -3
- package/dist/resources/extensions/gsd/bootstrap/journal-tools.js +7 -1
- package/dist/resources/extensions/gsd/bootstrap/memory-tools.js +9 -3
- package/dist/resources/extensions/gsd/bootstrap/query-tools.js +8 -2
- package/dist/resources/extensions/gsd/bootstrap/register-hooks.js +238 -28
- package/dist/resources/extensions/gsd/bootstrap/system-context.js +82 -23
- package/dist/resources/extensions/gsd/clean-root-preflight.js +24 -6
- package/dist/resources/extensions/gsd/commands-handlers.js +23 -9
- package/dist/resources/extensions/gsd/context-budget.js +37 -2
- package/dist/resources/extensions/gsd/db/unit-dispatches.js +39 -0
- package/dist/resources/extensions/gsd/db-base-schema.js +4 -2
- package/dist/resources/extensions/gsd/db-migration-steps.js +6 -0
- package/dist/resources/extensions/gsd/ecosystem/gsd-extension-api.js +2 -0
- package/dist/resources/extensions/gsd/git-service.js +36 -4
- package/dist/resources/extensions/gsd/gsd-db.js +46 -13
- package/dist/resources/extensions/gsd/guided-flow.js +66 -32
- package/dist/resources/extensions/gsd/memory-store.js +69 -12
- package/dist/resources/extensions/gsd/native-git-bridge.js +32 -8
- package/dist/resources/extensions/gsd/orphan-stash-audit.js +101 -0
- package/dist/resources/extensions/gsd/parallel-orchestrator.js +13 -3
- package/dist/resources/extensions/gsd/pre-execution-checks.js +22 -0
- package/dist/resources/extensions/gsd/prompt-loader.js +28 -2
- package/dist/resources/extensions/gsd/prompts/complete-milestone.md +16 -13
- package/dist/resources/extensions/gsd/prompts/complete-slice.md +1 -1
- package/dist/resources/extensions/gsd/prompts/execute-task.md +4 -2
- package/dist/resources/extensions/gsd/prompts/plan-slice.md +1 -1
- package/dist/resources/extensions/gsd/prompts/replan-slice.md +2 -2
- package/dist/resources/extensions/gsd/tools/memory-tools.js +1 -0
- package/dist/resources/extensions/gsd/tools/workflow-tool-executors.js +1 -1
- package/dist/resources/extensions/gsd/unit-runtime.js +11 -0
- package/dist/resources/extensions/gsd/workflow-protocol.js +131 -0
- package/dist/resources/extensions/gsd/worktree-resolver.js +68 -21
- package/dist/tsconfig.extensions.tsbuildinfo +1 -1
- package/dist/web/standalone/.next/BUILD_ID +1 -1
- package/dist/web/standalone/.next/app-path-routes-manifest.json +15 -15
- package/dist/web/standalone/.next/build-manifest.json +2 -2
- package/dist/web/standalone/.next/prerender-manifest.json +3 -3
- package/dist/web/standalone/.next/server/app/_global-error.html +1 -1
- package/dist/web/standalone/.next/server/app/_global-error.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_global-error.segments/_global-error.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_not-found.html +1 -1
- package/dist/web/standalone/.next/server/app/_not-found.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_not-found.segments/_full.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_not-found.segments/_head.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_not-found.segments/_index.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_not-found.segments/_tree.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/index.html +1 -1
- package/dist/web/standalone/.next/server/app/index.rsc +1 -1
- package/dist/web/standalone/.next/server/app/index.segments/__PAGE__.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/index.segments/_full.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/index.segments/_head.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/index.segments/_index.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/index.segments/_tree.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app-paths-manifest.json +15 -15
- package/dist/web/standalone/.next/server/middleware-build-manifest.js +1 -1
- package/dist/web/standalone/.next/server/pages/404.html +1 -1
- package/dist/web/standalone/.next/server/pages/500.html +1 -1
- package/dist/web/standalone/.next/server/server-reference-manifest.json +1 -1
- package/package.json +3 -3
- package/packages/mcp-server/src/workflow-tools.test.ts +9 -2
- package/packages/native/tsconfig.tsbuildinfo +1 -1
- package/packages/pi-agent-core/dist/agent-loop.d.ts.map +1 -1
- package/packages/pi-agent-core/dist/agent-loop.js +4 -1
- package/packages/pi-agent-core/dist/agent-loop.js.map +1 -1
- package/packages/pi-agent-core/dist/agent.d.ts +5 -0
- package/packages/pi-agent-core/dist/agent.d.ts.map +1 -1
- package/packages/pi-agent-core/dist/agent.js +2 -0
- package/packages/pi-agent-core/dist/agent.js.map +1 -1
- package/packages/pi-agent-core/dist/index.d.ts +1 -0
- package/packages/pi-agent-core/dist/index.d.ts.map +1 -1
- package/packages/pi-agent-core/dist/index.js +2 -0
- package/packages/pi-agent-core/dist/index.js.map +1 -1
- package/packages/pi-agent-core/dist/token-audit.d.ts +47 -0
- package/packages/pi-agent-core/dist/token-audit.d.ts.map +1 -0
- package/packages/pi-agent-core/dist/token-audit.js +221 -0
- package/packages/pi-agent-core/dist/token-audit.js.map +1 -0
- package/packages/pi-agent-core/dist/types.d.ts +9 -0
- package/packages/pi-agent-core/dist/types.d.ts.map +1 -1
- package/packages/pi-agent-core/dist/types.js.map +1 -1
- package/packages/pi-agent-core/src/agent-loop.test.ts +128 -0
- package/packages/pi-agent-core/src/agent-loop.ts +4 -1
- package/packages/pi-agent-core/src/agent.ts +8 -0
- package/packages/pi-agent-core/src/index.ts +2 -0
- package/packages/pi-agent-core/src/token-audit.test.ts +189 -0
- package/packages/pi-agent-core/src/token-audit.ts +287 -0
- package/packages/pi-agent-core/src/types.ts +14 -0
- package/packages/pi-agent-core/tsconfig.tsbuildinfo +1 -1
- package/packages/pi-coding-agent/dist/core/agent-session-abort-order.test.js +32 -0
- package/packages/pi-coding-agent/dist/core/agent-session-abort-order.test.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/agent-session-tool-refresh.test.js +18 -0
- package/packages/pi-coding-agent/dist/core/agent-session-tool-refresh.test.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/agent-session.d.ts +12 -0
- package/packages/pi-coding-agent/dist/core/agent-session.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/agent-session.js +41 -7
- package/packages/pi-coding-agent/dist/core/agent-session.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/extensions/loader.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/extensions/loader.js +8 -0
- package/packages/pi-coding-agent/dist/core/extensions/loader.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/extensions/runner.d.ts +2 -0
- package/packages/pi-coding-agent/dist/core/extensions/runner.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/extensions/runner.js +3 -6
- package/packages/pi-coding-agent/dist/core/extensions/runner.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/extensions/runner.test.js +3 -3
- package/packages/pi-coding-agent/dist/core/extensions/runner.test.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/extensions/types.d.ts +32 -1
- package/packages/pi-coding-agent/dist/core/extensions/types.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/extensions/types.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/hooks-runner.test.js +2 -0
- package/packages/pi-coding-agent/dist/core/hooks-runner.test.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/sdk-tool-filter.test.d.ts +2 -0
- package/packages/pi-coding-agent/dist/core/sdk-tool-filter.test.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/core/sdk-tool-filter.test.js +46 -0
- package/packages/pi-coding-agent/dist/core/sdk-tool-filter.test.js.map +1 -0
- package/packages/pi-coding-agent/dist/core/sdk.d.ts +10 -2
- package/packages/pi-coding-agent/dist/core/sdk.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/sdk.js +74 -2
- package/packages/pi-coding-agent/dist/core/sdk.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/skill-tool.test.js +22 -0
- package/packages/pi-coding-agent/dist/core/skill-tool.test.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/system-prompt.d.ts +6 -7
- package/packages/pi-coding-agent/dist/core/system-prompt.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/system-prompt.js +2 -3
- package/packages/pi-coding-agent/dist/core/system-prompt.js.map +1 -1
- package/packages/pi-coding-agent/src/core/agent-session-abort-order.test.ts +36 -0
- package/packages/pi-coding-agent/src/core/agent-session-tool-refresh.test.ts +25 -0
- package/packages/pi-coding-agent/src/core/agent-session.ts +45 -7
- package/packages/pi-coding-agent/src/core/extensions/loader.ts +10 -0
- package/packages/pi-coding-agent/src/core/extensions/runner.test.ts +3 -3
- package/packages/pi-coding-agent/src/core/extensions/runner.ts +5 -5
- package/packages/pi-coding-agent/src/core/extensions/types.ts +35 -1
- package/packages/pi-coding-agent/src/core/hooks-runner.test.ts +2 -0
- package/packages/pi-coding-agent/src/core/sdk-tool-filter.test.ts +60 -0
- package/packages/pi-coding-agent/src/core/sdk.ts +85 -3
- package/packages/pi-coding-agent/src/core/skill-tool.test.ts +28 -0
- package/packages/pi-coding-agent/src/core/system-prompt.ts +8 -10
- package/packages/pi-coding-agent/tsconfig.tsbuildinfo +1 -1
- package/src/resources/extensions/gsd/auto/loop-deps.ts +2 -2
- package/src/resources/extensions/gsd/auto/phases.ts +251 -172
- package/src/resources/extensions/gsd/auto/resolve.ts +23 -1
- package/src/resources/extensions/gsd/auto/run-unit.ts +25 -30
- package/src/resources/extensions/gsd/auto/session.ts +8 -0
- package/src/resources/extensions/gsd/auto-direct-dispatch.ts +8 -34
- package/src/resources/extensions/gsd/auto-dispatch.ts +16 -0
- package/src/resources/extensions/gsd/auto-post-unit.ts +18 -4
- package/src/resources/extensions/gsd/auto-prompts.ts +95 -14
- package/src/resources/extensions/gsd/auto-recovery.ts +54 -0
- package/src/resources/extensions/gsd/auto-start.ts +230 -9
- package/src/resources/extensions/gsd/auto-supervisor.ts +7 -0
- package/src/resources/extensions/gsd/auto-timeout-recovery.ts +2 -2
- package/src/resources/extensions/gsd/auto-worktree.ts +123 -0
- package/src/resources/extensions/gsd/auto.ts +87 -19
- package/src/resources/extensions/gsd/bootstrap/agent-end-recovery.ts +49 -1
- package/src/resources/extensions/gsd/bootstrap/db-tools.ts +50 -36
- package/src/resources/extensions/gsd/bootstrap/dynamic-tools.ts +16 -5
- package/src/resources/extensions/gsd/bootstrap/exec-tools.ts +10 -3
- package/src/resources/extensions/gsd/bootstrap/journal-tools.ts +8 -1
- package/src/resources/extensions/gsd/bootstrap/memory-tools.ts +10 -3
- package/src/resources/extensions/gsd/bootstrap/query-tools.ts +9 -2
- package/src/resources/extensions/gsd/bootstrap/register-hooks.ts +283 -28
- package/src/resources/extensions/gsd/bootstrap/system-context.ts +90 -22
- package/src/resources/extensions/gsd/clean-root-preflight.ts +32 -7
- package/src/resources/extensions/gsd/commands-handlers.ts +34 -15
- package/src/resources/extensions/gsd/context-budget.ts +44 -2
- package/src/resources/extensions/gsd/db/unit-dispatches.ts +41 -0
- package/src/resources/extensions/gsd/db-base-schema.ts +4 -2
- package/src/resources/extensions/gsd/db-migration-steps.ts +8 -0
- package/src/resources/extensions/gsd/ecosystem/gsd-extension-api.ts +3 -0
- package/src/resources/extensions/gsd/git-service.ts +46 -8
- package/src/resources/extensions/gsd/gsd-db.ts +50 -13
- package/src/resources/extensions/gsd/guided-flow.ts +84 -39
- package/src/resources/extensions/gsd/memory-store.ts +77 -12
- package/src/resources/extensions/gsd/native-git-bridge.ts +39 -6
- package/src/resources/extensions/gsd/orphan-stash-audit.ts +117 -0
- package/src/resources/extensions/gsd/parallel-orchestrator.ts +13 -3
- package/src/resources/extensions/gsd/pre-execution-checks.ts +23 -0
- package/src/resources/extensions/gsd/prompt-loader.ts +27 -2
- package/src/resources/extensions/gsd/prompts/complete-milestone.md +16 -13
- package/src/resources/extensions/gsd/prompts/complete-slice.md +1 -1
- package/src/resources/extensions/gsd/prompts/execute-task.md +4 -2
- package/src/resources/extensions/gsd/prompts/plan-slice.md +1 -1
- package/src/resources/extensions/gsd/prompts/replan-slice.md +2 -2
- package/src/resources/extensions/gsd/tests/artifact-retry-cap.test.ts +2 -2
- package/src/resources/extensions/gsd/tests/auto-loop.test.ts +417 -10
- package/src/resources/extensions/gsd/tests/auto-phases-lifecycle.test.ts +56 -13
- package/src/resources/extensions/gsd/tests/auto-recovery.test.ts +14 -1
- package/src/resources/extensions/gsd/tests/auto-wrapup-inflight-guard.test.ts +168 -6
- package/src/resources/extensions/gsd/tests/clean-root-preflight.test.ts +15 -6
- package/src/resources/extensions/gsd/tests/compaction-snapshot.test.ts +3 -1
- package/src/resources/extensions/gsd/tests/complete-milestone-excerpt.test.ts +31 -0
- package/src/resources/extensions/gsd/tests/complete-slice-composer.test.ts +3 -2
- package/src/resources/extensions/gsd/tests/context-budget.test.ts +10 -1
- package/src/resources/extensions/gsd/tests/context-store.test.ts +7 -1
- package/src/resources/extensions/gsd/tests/custom-engine-loop-integration.test.ts +5 -1
- package/src/resources/extensions/gsd/tests/dispatch-rule-coverage.test.ts +313 -0
- package/src/resources/extensions/gsd/tests/execute-task-rendering.test.ts +5 -2
- package/src/resources/extensions/gsd/tests/fast-forward-reused-milestone-branch.test.ts +219 -0
- package/src/resources/extensions/gsd/tests/finalize-survivor-branch.test.ts +132 -0
- package/src/resources/extensions/gsd/tests/integration/git-service.test.ts +54 -0
- package/src/resources/extensions/gsd/tests/isolation-none-branch-guard.test.ts +6 -3
- package/src/resources/extensions/gsd/tests/journal-integration.test.ts +239 -1
- package/src/resources/extensions/gsd/tests/journal-query-tool.test.ts +32 -0
- package/src/resources/extensions/gsd/tests/knowledge.test.ts +47 -0
- package/src/resources/extensions/gsd/tests/memory-decay-factor.test.ts +90 -0
- package/src/resources/extensions/gsd/tests/merge-conflict-stops-loop.test.ts +1 -0
- package/src/resources/extensions/gsd/tests/milestone-merge-stash-restore.test.ts +242 -0
- package/src/resources/extensions/gsd/tests/native-git-bridge-exec-fallback.test.ts +34 -2
- package/src/resources/extensions/gsd/tests/originalbase-path-comparison.test.ts +3 -0
- package/src/resources/extensions/gsd/tests/orphan-merge-bootstrap.test.ts +133 -0
- package/src/resources/extensions/gsd/tests/orphan-stash-audit.test.ts +201 -0
- package/src/resources/extensions/gsd/tests/parallel-orchestrator-fast-forward.test.ts +113 -0
- package/src/resources/extensions/gsd/tests/pre-execution-checks.test.ts +45 -5
- package/src/resources/extensions/gsd/tests/prompt-duplication-cuts.test.ts +230 -0
- package/src/resources/extensions/gsd/tests/prompt-step-ordering.test.ts +19 -0
- package/src/resources/extensions/gsd/tests/query-tools-db-open.test.ts +3 -3
- package/src/resources/extensions/gsd/tests/restore-tools-after-discuss.test.ts +38 -17
- package/src/resources/extensions/gsd/tests/schema-v27-v28-sequence.test.ts +156 -0
- package/src/resources/extensions/gsd/tests/select-resumable-milestone.test.ts +96 -0
- package/src/resources/extensions/gsd/tests/session-switch-abort-misclassification.test.ts +106 -0
- package/src/resources/extensions/gsd/tests/signal-handlers.test.ts +27 -0
- package/src/resources/extensions/gsd/tests/stalled-tool-recovery.test.ts +49 -1
- package/src/resources/extensions/gsd/tests/start-auto-detached.test.ts +38 -0
- package/src/resources/extensions/gsd/tests/state-corruption-2945.test.ts +1 -0
- package/src/resources/extensions/gsd/tests/system-context-memory.test.ts +112 -0
- package/src/resources/extensions/gsd/tests/system-context-message-routing.test.ts +7 -9
- package/src/resources/extensions/gsd/tests/token-tool-gating.test.ts +291 -0
- package/src/resources/extensions/gsd/tests/unit-dispatches.test.ts +30 -0
- package/src/resources/extensions/gsd/tests/unit-runtime.test.ts +30 -0
- package/src/resources/extensions/gsd/tests/unstructured-continue-context-injection.test.ts +5 -4
- package/src/resources/extensions/gsd/tests/workflow-protocol-excerpt.test.ts +99 -0
- package/src/resources/extensions/gsd/tests/workflow-tool-executors.test.ts +3 -0
- package/src/resources/extensions/gsd/tests/worktree-journal-events.test.ts +1 -0
- package/src/resources/extensions/gsd/tests/worktree-path-injection.test.ts +22 -19
- package/src/resources/extensions/gsd/tests/worktree-project-root-degrade.test.ts +66 -0
- package/src/resources/extensions/gsd/tests/worktree-resolver.test.ts +167 -4
- package/src/resources/extensions/gsd/tools/memory-tools.ts +1 -0
- package/src/resources/extensions/gsd/tools/workflow-tool-executors.ts +1 -1
- package/src/resources/extensions/gsd/unit-runtime.ts +11 -0
- package/src/resources/extensions/gsd/workflow-protocol.ts +160 -0
- package/src/resources/extensions/gsd/worktree-resolver.ts +85 -19
- package/src/resources/extensions/gsd/tests/phases-merge-error-stops-auto.test.ts +0 -97
- /package/dist/web/standalone/.next/static/{3EDDd9ULaybSupPoA_vf- → O2WvnXROue6l7nAp_4dhC}/_buildManifest.js +0 -0
- /package/dist/web/standalone/.next/static/{3EDDd9ULaybSupPoA_vf- → O2WvnXROue6l7nAp_4dhC}/_ssgManifest.js +0 -0
|
@@ -23,7 +23,7 @@ import { debugLog } from "./debug-logger.js";
|
|
|
23
23
|
import { logWarning, logError } from "./workflow-logger.js";
|
|
24
24
|
import { loadEffectiveGSDPreferences } from "./preferences.js";
|
|
25
25
|
import { MILESTONE_ID_RE } from "./milestone-ids.js";
|
|
26
|
-
import { nativeGetCurrentBranch, nativeDetectMainBranch, nativeWorkingTreeStatus, nativeAddAllWithExclusions, nativeCommit, nativeCheckoutBranch, nativeMergeSquash, nativeConflictFiles, nativeCheckoutTheirs, nativeAddPaths, nativeRmForce, nativeBranchDelete, nativeBranchForceReset, nativeBranchExists, nativeDiffNumstat, nativeUpdateRef, nativeIsAncestor, nativeMergeAbort, } from "./native-git-bridge.js";
|
|
26
|
+
import { nativeGetCurrentBranch, nativeDetectMainBranch, nativeWorkingTreeStatus, nativeAddAllWithExclusions, nativeCommit, nativeCheckoutBranch, nativeMergeSquash, nativeConflictFiles, nativeCheckoutTheirs, nativeAddPaths, nativeRmForce, nativeBranchDelete, nativeBranchForceReset, nativeBranchExists, nativeDiffNumstat, nativeUpdateRef, nativeIsAncestor, nativeMergeAbort, nativeWorktreeList, } from "./native-git-bridge.js";
|
|
27
27
|
import { gsdHome } from "./gsd-home.js";
|
|
28
28
|
import { createWorkspace } from "./workspace.js";
|
|
29
29
|
const PROJECT_PREFERENCES_FILE = "PREFERENCES.md";
|
|
@@ -1018,6 +1018,111 @@ export function enterBranchModeForMilestone(basePath, milestoneId) {
|
|
|
1018
1018
|
* for both reads and writes. copyPlanningArtifacts and reconcilePlanCheckboxes
|
|
1019
1019
|
* (both formerly here) became dead.
|
|
1020
1020
|
*/
|
|
1021
|
+
/**
|
|
1022
|
+
* True when `branch` is checked out in any worktree listed by
|
|
1023
|
+
* `git worktree list --porcelain`. Used to gate ref updates that would
|
|
1024
|
+
* otherwise leave a concurrent worktree's HEAD inconsistent with its
|
|
1025
|
+
* index/working tree (Codex peer-review of #5538-followup).
|
|
1026
|
+
*
|
|
1027
|
+
* Best-effort: a `nativeWorktreeList` failure returns true so we err on
|
|
1028
|
+
* the side of NOT moving the ref. Better to skip a fast-forward than to
|
|
1029
|
+
* silently corrupt another worktree.
|
|
1030
|
+
*/
|
|
1031
|
+
export function _isBranchCheckedOutElsewhere(basePath, branch) {
|
|
1032
|
+
try {
|
|
1033
|
+
const entries = nativeWorktreeList(basePath);
|
|
1034
|
+
return entries.some((entry) => entry.branch === branch);
|
|
1035
|
+
}
|
|
1036
|
+
catch {
|
|
1037
|
+
return true;
|
|
1038
|
+
}
|
|
1039
|
+
}
|
|
1040
|
+
/**
|
|
1041
|
+
* Resolve the integration branch using the same 3-tier fallback as the
|
|
1042
|
+
* fresh-create path: META.json → git.main_branch preference → detected
|
|
1043
|
+
* main branch. Returns null when no usable target exists.
|
|
1044
|
+
*/
|
|
1045
|
+
function _resolveIntegrationBranchForReuse(basePath, milestoneId) {
|
|
1046
|
+
const fromMeta = readIntegrationBranch(basePath, milestoneId);
|
|
1047
|
+
if (fromMeta)
|
|
1048
|
+
return fromMeta;
|
|
1049
|
+
const gitPrefs = loadEffectiveGSDPreferences()?.preferences?.git;
|
|
1050
|
+
const fromPref = gitPrefs?.main_branch &&
|
|
1051
|
+
typeof gitPrefs.main_branch === "string" &&
|
|
1052
|
+
gitPrefs.main_branch.length > 0 &&
|
|
1053
|
+
nativeBranchExists(basePath, gitPrefs.main_branch)
|
|
1054
|
+
? gitPrefs.main_branch
|
|
1055
|
+
: null;
|
|
1056
|
+
if (fromPref)
|
|
1057
|
+
return fromPref;
|
|
1058
|
+
try {
|
|
1059
|
+
return nativeDetectMainBranch(basePath);
|
|
1060
|
+
}
|
|
1061
|
+
catch {
|
|
1062
|
+
return null;
|
|
1063
|
+
}
|
|
1064
|
+
}
|
|
1065
|
+
/**
|
|
1066
|
+
* When reusing an existing milestone branch, fast-forward it onto the
|
|
1067
|
+
* integration branch when that's safe (branch is a strict ancestor of
|
|
1068
|
+
* integration — no commits would be lost). Skips when the branch has its
|
|
1069
|
+
* own commits ahead of integration, when the integration branch can't be
|
|
1070
|
+
* resolved, or when any git operation fails — the merge gate at milestone
|
|
1071
|
+
* completion will surface real divergence as a conflict.
|
|
1072
|
+
*
|
|
1073
|
+
* The previous behavior re-attached the worktree to whatever stale tip
|
|
1074
|
+
* the branch held, which caused new milestone work to fork from a base
|
|
1075
|
+
* missing prior milestones' merges (#5538-followup).
|
|
1076
|
+
*/
|
|
1077
|
+
export function fastForwardReusedMilestoneBranchIfSafe(basePath, milestoneId, branch) {
|
|
1078
|
+
try {
|
|
1079
|
+
const integrationBranch = _resolveIntegrationBranchForReuse(basePath, milestoneId);
|
|
1080
|
+
if (!integrationBranch || integrationBranch === branch)
|
|
1081
|
+
return;
|
|
1082
|
+
if (!nativeBranchExists(basePath, integrationBranch))
|
|
1083
|
+
return;
|
|
1084
|
+
// Pure fast-forward only: branch must be a strict ancestor of integration.
|
|
1085
|
+
// If the branch has its own commits ahead, leave it alone.
|
|
1086
|
+
if (!nativeIsAncestor(basePath, branch, integrationBranch)) {
|
|
1087
|
+
debugLog("createAutoWorktree", {
|
|
1088
|
+
phase: "skip-ff-branch-not-ancestor",
|
|
1089
|
+
milestoneId,
|
|
1090
|
+
branch,
|
|
1091
|
+
integration: integrationBranch,
|
|
1092
|
+
});
|
|
1093
|
+
return;
|
|
1094
|
+
}
|
|
1095
|
+
// Codex peer-review: `nativeUpdateRef` succeeds even when the branch is
|
|
1096
|
+
// currently checked out in another worktree, leaving that worktree's HEAD
|
|
1097
|
+
// inconsistent with its index/work tree. Skip the fast-forward if any
|
|
1098
|
+
// listed worktree has this branch checked out — the merge gate at
|
|
1099
|
+
// milestone-completion will surface stale-base divergence as a conflict
|
|
1100
|
+
// instead of silently corrupting the other worktree's state.
|
|
1101
|
+
if (_isBranchCheckedOutElsewhere(basePath, branch)) {
|
|
1102
|
+
debugLog("createAutoWorktree", {
|
|
1103
|
+
phase: "skip-ff-branch-checked-out-elsewhere",
|
|
1104
|
+
milestoneId,
|
|
1105
|
+
branch,
|
|
1106
|
+
});
|
|
1107
|
+
return;
|
|
1108
|
+
}
|
|
1109
|
+
nativeUpdateRef(basePath, `refs/heads/${branch}`, integrationBranch);
|
|
1110
|
+
debugLog("createAutoWorktree", {
|
|
1111
|
+
phase: "fast-forward-reused-branch",
|
|
1112
|
+
milestoneId,
|
|
1113
|
+
branch,
|
|
1114
|
+
integration: integrationBranch,
|
|
1115
|
+
});
|
|
1116
|
+
}
|
|
1117
|
+
catch (err) {
|
|
1118
|
+
debugLog("createAutoWorktree", {
|
|
1119
|
+
phase: "fast-forward-reused-branch-failed",
|
|
1120
|
+
milestoneId,
|
|
1121
|
+
branch,
|
|
1122
|
+
error: err instanceof Error ? err.message : String(err),
|
|
1123
|
+
});
|
|
1124
|
+
}
|
|
1125
|
+
}
|
|
1021
1126
|
export function createAutoWorktree(basePath, milestoneId) {
|
|
1022
1127
|
basePath = resolveWorktreeProjectRoot(basePath);
|
|
1023
1128
|
// Check if repo has commits — git worktree requires a valid HEAD
|
|
@@ -1035,6 +1140,11 @@ export function createAutoWorktree(basePath, milestoneId) {
|
|
|
1035
1140
|
const branchExists = nativeBranchExists(basePath, branch);
|
|
1036
1141
|
let info;
|
|
1037
1142
|
if (branchExists) {
|
|
1143
|
+
// #5538-followup: fast-forward the reused branch onto the integration
|
|
1144
|
+
// branch when safe so the next milestone forks from up-to-date code.
|
|
1145
|
+
// Without this, a milestone that was created before another milestone
|
|
1146
|
+
// merged into main would carry a stale base into its worktree.
|
|
1147
|
+
fastForwardReusedMilestoneBranchIfSafe(basePath, milestoneId, branch);
|
|
1038
1148
|
// Re-attach worktree to the existing milestone branch (preserving commits)
|
|
1039
1149
|
info = createWorktree(basePath, milestoneId, {
|
|
1040
1150
|
branch,
|
|
@@ -20,7 +20,7 @@ import { gsdRoot, resolveMilestoneFile, resolveMilestonePath, resolveDir, milest
|
|
|
20
20
|
import { invalidateAllCaches } from "./cache.js";
|
|
21
21
|
import { clearActivityLogState } from "./activity-log.js";
|
|
22
22
|
import { synthesizeCrashRecovery, getDeepDiagnostic, readActiveMilestoneId, } from "./session-forensics.js";
|
|
23
|
-
import { writeLock, clearLock, readCrashLock, isLockProcessAlive, formatCrashInfo, emitCrashRecoveredUnitEnd, } from "./crash-recovery.js";
|
|
23
|
+
import { writeLock, clearLock, readCrashLock, isLockProcessAlive, formatCrashInfo, emitCrashRecoveredUnitEnd, emitOpenUnitEndForUnit, } from "./crash-recovery.js";
|
|
24
24
|
import { acquireSessionLock, getSessionLockStatus, releaseSessionLock, updateSessionLock, } from "./session-lock.js";
|
|
25
25
|
import { resolveAutoSupervisorConfig, loadEffectiveGSDPreferences, getIsolationMode, } from "./preferences.js";
|
|
26
26
|
import { sendDesktopNotification } from "./notifications.js";
|
|
@@ -45,6 +45,7 @@ import { readFileSync, existsSync, mkdirSync } from "node:fs";
|
|
|
45
45
|
import { atomicWriteSync } from "./atomic-write.js";
|
|
46
46
|
import { autoCommitCurrentBranch, captureIntegrationBranch, detectWorktreeName, getCurrentBranch, getMainBranch, setActiveMilestoneId, resolveProjectRoot, } from "./worktree.js";
|
|
47
47
|
import { GitServiceImpl } from "./git-service.js";
|
|
48
|
+
import { nativeCheckoutBranch } from "./native-git-bridge.js";
|
|
48
49
|
import { getPriorSliceCompletionBlocker } from "./dispatch-guard.js";
|
|
49
50
|
import { createAutoWorktree, enterAutoWorktree, enterBranchModeForMilestone, teardownAutoWorktree, isInAutoWorktree, getAutoWorktreePath, mergeMilestoneToMain, autoWorktreeBranch, syncWorktreeStateBack, syncProjectRootToWorktree, checkResourcesStale, escapeStaleWorktree, } from "./auto-worktree.js";
|
|
50
51
|
import { pruneQueueOrder } from "./queue-order.js";
|
|
@@ -61,6 +62,8 @@ import { isClosedStatus } from "./status-guards.js";
|
|
|
61
62
|
import { updateProgressWidget as _updateProgressWidget, updateSliceProgressCache, clearSliceProgressCache, } from "./auto-dashboard.js";
|
|
62
63
|
import { registerSigtermHandler as _registerSigtermHandler, deregisterSigtermHandler as _deregisterSigtermHandler, } from "./auto-supervisor.js";
|
|
63
64
|
import { isDbAvailable, getMilestone } from "./gsd-db.js";
|
|
65
|
+
import { markLatestActiveForWorkerCanceled } from "./db/unit-dispatches.js";
|
|
66
|
+
import { writeUnitRuntimeRecord } from "./unit-runtime.js";
|
|
64
67
|
import { countPendingCaptures } from "./captures.js";
|
|
65
68
|
import { CMUX_CHANNELS } from "../shared/cmux-events.js";
|
|
66
69
|
import { ensureDbOpen } from "./bootstrap/dynamic-tools.js";
|
|
@@ -85,6 +88,16 @@ import { validateDirectory } from "./validate-directory.js";
|
|
|
85
88
|
import { createAutoOrchestrator } from "./auto/orchestrator.js";
|
|
86
89
|
import { WorktreeResolver, } from "./worktree-resolver.js";
|
|
87
90
|
import { reorderForCaching } from "./prompt-ordering.js";
|
|
91
|
+
import { initTokenCounter } from "./token-counter.js";
|
|
92
|
+
// Warm the tiktoken encoder at extension startup so context-budget computations
|
|
93
|
+
// can use accurate token counts via countTokensSync without paying the load
|
|
94
|
+
// cost mid-prompt-build. Fire-and-forget — failure falls back to the
|
|
95
|
+
// provider-aware char-ratio estimator already used by getCharsPerToken().
|
|
96
|
+
// Catch rejections explicitly: an unhandled rejection at module-import time
|
|
97
|
+
// can destabilize startup before the engine logger is configured.
|
|
98
|
+
void initTokenCounter().catch((err) => {
|
|
99
|
+
logWarning("engine", `token counter warm-up failed: ${err instanceof Error ? err.message : String(err)}`);
|
|
100
|
+
});
|
|
88
101
|
export { STUB_RECOVERY_THRESHOLD, NEW_SESSION_TIMEOUT_MS, } from "./auto/session.js";
|
|
89
102
|
import { autoSession as s } from "./auto-runtime-state.js";
|
|
90
103
|
import { gsdHome } from "./gsd-home.js";
|
|
@@ -273,9 +286,50 @@ export function shouldUseWorktreeIsolation(basePath) {
|
|
|
273
286
|
*/
|
|
274
287
|
// Re-export budget utilities for external consumers
|
|
275
288
|
export { getBudgetAlertLevel, getNewBudgetAlertLevel, getBudgetEnforcementAction, } from "./auto-budget.js";
|
|
289
|
+
function closeOutSignalInterruptedUnit(currentBasePath) {
|
|
290
|
+
const currentUnit = s.currentUnit;
|
|
291
|
+
if (!currentUnit)
|
|
292
|
+
return;
|
|
293
|
+
const reason = "Auto-mode process received a termination signal";
|
|
294
|
+
const errorContext = {
|
|
295
|
+
message: reason,
|
|
296
|
+
category: "aborted",
|
|
297
|
+
isTransient: false,
|
|
298
|
+
};
|
|
299
|
+
const basePath = s.basePath || currentBasePath;
|
|
300
|
+
try {
|
|
301
|
+
emitOpenUnitEndForUnit(basePath, currentUnit.type, currentUnit.id, "cancelled", errorContext);
|
|
302
|
+
}
|
|
303
|
+
catch (err) {
|
|
304
|
+
logWarning("engine", `signal unit-end cleanup failed: ${getErrorMessage(err)}`, { file: "auto.ts" });
|
|
305
|
+
}
|
|
306
|
+
try {
|
|
307
|
+
writeUnitRuntimeRecord(basePath, currentUnit.type, currentUnit.id, currentUnit.startedAt, {
|
|
308
|
+
phase: "crashed",
|
|
309
|
+
lastProgressAt: Date.now(),
|
|
310
|
+
lastProgressKind: "signal",
|
|
311
|
+
});
|
|
312
|
+
}
|
|
313
|
+
catch (err) {
|
|
314
|
+
logWarning("engine", `signal runtime cleanup failed: ${getErrorMessage(err)}`, { file: "auto.ts" });
|
|
315
|
+
}
|
|
316
|
+
try {
|
|
317
|
+
if (s.workerId)
|
|
318
|
+
markLatestActiveForWorkerCanceled(s.workerId, "signal-exit");
|
|
319
|
+
}
|
|
320
|
+
catch (err) {
|
|
321
|
+
logWarning("engine", `signal dispatch cleanup failed: ${getErrorMessage(err)}`, { file: "auto.ts" });
|
|
322
|
+
}
|
|
323
|
+
try {
|
|
324
|
+
resolveAgentEndCancelled(errorContext);
|
|
325
|
+
}
|
|
326
|
+
catch (err) {
|
|
327
|
+
logWarning("engine", `signal resolve cleanup failed: ${getErrorMessage(err)}`, { file: "auto.ts" });
|
|
328
|
+
}
|
|
329
|
+
}
|
|
276
330
|
/** Wrapper: register SIGTERM handler and store reference. */
|
|
277
331
|
function registerSigtermHandler(currentBasePath) {
|
|
278
|
-
s.sigtermHandler = _registerSigtermHandler(currentBasePath, s.sigtermHandler);
|
|
332
|
+
s.sigtermHandler = _registerSigtermHandler(currentBasePath, s.sigtermHandler, () => closeOutSignalInterruptedUnit(currentBasePath));
|
|
279
333
|
}
|
|
280
334
|
/** Wrapper: deregister SIGTERM handler and clear reference. */
|
|
281
335
|
function deregisterSigtermHandler() {
|
|
@@ -667,6 +721,8 @@ export async function stopAuto(ctx, pi, reason) {
|
|
|
667
721
|
if (s.workerId) {
|
|
668
722
|
markWorkerStopping(s.workerId);
|
|
669
723
|
}
|
|
724
|
+
s.workerId = null;
|
|
725
|
+
s.milestoneLeaseToken = null;
|
|
670
726
|
}
|
|
671
727
|
catch (e) {
|
|
672
728
|
debugLog("stop-cleanup-coordination", { error: e instanceof Error ? e.message : String(e) });
|
|
@@ -799,6 +855,21 @@ export async function stopAuto(ctx, pi, reason) {
|
|
|
799
855
|
catch (e) {
|
|
800
856
|
debugLog("stop-cleanup-basepath", { error: e instanceof Error ? e.message : String(e) });
|
|
801
857
|
}
|
|
858
|
+
// Re-root the active command session/tool runtime after worktree teardown.
|
|
859
|
+
// mergeAndExit restores process.cwd(), but AgentSession has already captured
|
|
860
|
+
// its own cwd for tools and system prompt; refresh it before returning to the
|
|
861
|
+
// user so follow-up commands do not target a removed milestone worktree.
|
|
862
|
+
if (s.originalBasePath && ctx && s.cmdCtx) {
|
|
863
|
+
try {
|
|
864
|
+
const result = await s.cmdCtx.newSession({ workspaceRoot: s.basePath });
|
|
865
|
+
if (result.cancelled) {
|
|
866
|
+
logWarning("engine", "post-stop session re-root was cancelled", { file: "auto.ts", basePath: s.basePath });
|
|
867
|
+
}
|
|
868
|
+
}
|
|
869
|
+
catch (err) {
|
|
870
|
+
logWarning("engine", `post-stop session re-root failed: ${err instanceof Error ? err.message : String(err)}`, { file: "auto.ts", basePath: s.basePath });
|
|
871
|
+
}
|
|
872
|
+
}
|
|
802
873
|
// ── Step 8: Ledger notification ──
|
|
803
874
|
try {
|
|
804
875
|
const ledger = getLedger();
|
|
@@ -1047,6 +1118,7 @@ function buildResolverDeps() {
|
|
|
1047
1118
|
getAutoWorktreePath,
|
|
1048
1119
|
autoCommitCurrentBranch,
|
|
1049
1120
|
getCurrentBranch,
|
|
1121
|
+
checkoutBranch: nativeCheckoutBranch,
|
|
1050
1122
|
autoWorktreeBranch,
|
|
1051
1123
|
resolveMilestoneFile,
|
|
1052
1124
|
readFileSync: (path, encoding) => readFileSync(path, encoding),
|
|
@@ -1567,6 +1639,10 @@ export async function startAuto(ctx, pi, base, verboseMode, options) {
|
|
|
1567
1639
|
: new URL("../../../resource-loader.js", import.meta.url).href;
|
|
1568
1640
|
const { initResources } = await import(resourceLoaderPath);
|
|
1569
1641
|
initResources(agentDir);
|
|
1642
|
+
// initResources() uses synchronous fs APIs, so the prompt-template cache
|
|
1643
|
+
// can be primed immediately — no need for the legacy 1s setTimeout deferral.
|
|
1644
|
+
const { primeCache } = await import("./prompt-loader.js");
|
|
1645
|
+
primeCache();
|
|
1570
1646
|
// Open the project DB before rebuild/derive so resume uses DB-backed
|
|
1571
1647
|
// state instead of falling back to stale markdown parsing (#2940).
|
|
1572
1648
|
await openProjectDbIfPresent(s.basePath);
|
|
@@ -1753,28 +1829,7 @@ export async function dispatchHookUnit(ctx, pi, hookName, triggerUnitType, trigg
|
|
|
1753
1829
|
id: triggerUnitId,
|
|
1754
1830
|
startedAt: hookStartedAt,
|
|
1755
1831
|
};
|
|
1756
|
-
|
|
1757
|
-
// newSession() snapshots process.cwd() during construction; chdir-ing
|
|
1758
|
-
// afterward leaves the session rooted to whatever cwd was when the call
|
|
1759
|
-
// was made. Must be synchronous — no awaits between chdir and newSession.
|
|
1760
|
-
try {
|
|
1761
|
-
if (process.cwd() !== s.basePath)
|
|
1762
|
-
process.chdir(s.basePath);
|
|
1763
|
-
}
|
|
1764
|
-
catch (err) {
|
|
1765
|
-
const msg = `Failed to chdir before hook newSession (basePath: ${s.basePath}): ${err instanceof Error ? err.message : String(err)}`;
|
|
1766
|
-
logWarning("engine", msg, { file: "auto.ts", basePath: s.basePath, error: err instanceof Error ? err.message : String(err) });
|
|
1767
|
-
ctx.ui.notify(`${msg}. Cancelling hook dispatch to avoid running in the wrong directory.`, "error");
|
|
1768
|
-
if (wasActive) {
|
|
1769
|
-
s.basePath = previousBasePath;
|
|
1770
|
-
s.currentUnit = previousCurrentUnit;
|
|
1771
|
-
}
|
|
1772
|
-
else {
|
|
1773
|
-
s.reset();
|
|
1774
|
-
}
|
|
1775
|
-
return false;
|
|
1776
|
-
}
|
|
1777
|
-
const result = await s.cmdCtx.newSession();
|
|
1832
|
+
const result = await s.cmdCtx.newSession({ workspaceRoot: s.basePath });
|
|
1778
1833
|
if (result.cancelled) {
|
|
1779
1834
|
await stopAuto(ctx, pi);
|
|
1780
1835
|
return false;
|
|
@@ -53,6 +53,44 @@ export function isUserInitiatedAbortMessage(message) {
|
|
|
53
53
|
return false;
|
|
54
54
|
return /\b(?:claude code process aborted by user|request aborted by user|process aborted by user)\b/i.test(message);
|
|
55
55
|
}
|
|
56
|
+
/**
|
|
57
|
+
* Resolve an agent_end event observed while a session switch is in flight.
|
|
58
|
+
*
|
|
59
|
+
* #5538-followup: When `newSession()` aborts an in-flight stream as part of a
|
|
60
|
+
* session transition (run-unit.ts:63 → _settleCurrentTurnForSessionTransition
|
|
61
|
+
* → agent.abort()), the SDK emits "Claude Code process aborted by user" or
|
|
62
|
+
* "Request aborted by user" against the previous unit's turn. The previous
|
|
63
|
+
* code path treated that as a user cancellation and propagated it to the next
|
|
64
|
+
* unit via the pending-switch-cancellation queue, killing auto-mode with
|
|
65
|
+
* "Auto-mode stopped — Unit aborted: Claude Code process aborted by user"
|
|
66
|
+
* even though no user input occurred.
|
|
67
|
+
*
|
|
68
|
+
* The user-abort branch is intentionally ignored when the abort fires while
|
|
69
|
+
* the session-switch is in flight: the abort is the expected side-effect of
|
|
70
|
+
* the transition, not a user signal. Other branches (genuine `stopReason ===
|
|
71
|
+
* "aborted"` with content/errorMessage) preserve the prior behavior.
|
|
72
|
+
*/
|
|
73
|
+
export function _handleSessionSwitchAgentEnd(lastMsg, resolveCancelled) {
|
|
74
|
+
if (!lastMsg || typeof lastMsg !== "object")
|
|
75
|
+
return;
|
|
76
|
+
const m = lastMsg;
|
|
77
|
+
if (m.stopReason === "error") {
|
|
78
|
+
const rawErrorMsg = m.errorMessage ? String(m.errorMessage) : "";
|
|
79
|
+
if (isUserInitiatedAbortMessage(rawErrorMsg)) {
|
|
80
|
+
// Internal abort from in-flight session transition — drop on the floor.
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
if (m.stopReason === "aborted") {
|
|
86
|
+
const content = m.content;
|
|
87
|
+
const hasEmptyContent = Array.isArray(content) && content.length === 0;
|
|
88
|
+
const hasErrorMessage = !!m.errorMessage;
|
|
89
|
+
if (!hasEmptyContent || hasErrorMessage) {
|
|
90
|
+
resolveCancelled(_buildAbortedPauseContext(m));
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
56
94
|
async function pauseTransientWithBackoff(cls, pi, ctx, errorDetail, isRateLimit) {
|
|
57
95
|
retryState.consecutiveTransientCount += 1;
|
|
58
96
|
const baseRetryAfterMs = "retryAfterMs" in cls ? cls.retryAfterMs : 15_000;
|
|
@@ -118,9 +156,11 @@ export async function handleAgentEnd(pi, event, ctx) {
|
|
|
118
156
|
return;
|
|
119
157
|
if (!isAutoActive())
|
|
120
158
|
return;
|
|
121
|
-
if (isSessionSwitchInFlight())
|
|
122
|
-
return;
|
|
123
159
|
const lastMsg = event.messages[event.messages.length - 1];
|
|
160
|
+
if (isSessionSwitchInFlight()) {
|
|
161
|
+
_handleSessionSwitchAgentEnd(lastMsg, resolveAgentEndCancelled);
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
124
164
|
if (lastMsg && "stopReason" in lastMsg && lastMsg.stopReason === "aborted") {
|
|
125
165
|
// Empty content with aborted stopReason is a non-fatal agent stop (the LLM
|
|
126
166
|
// chose to end without producing output). Only pause on genuine fatal aborts
|