@zhushanwen/subagent-core 0.2.0 → 0.5.1
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 +45 -2
- package/agents/analyst.md +60 -0
- package/agents/coder.md +69 -0
- package/agents/debugger.md +66 -0
- package/agents/doc-reviewer.md +49 -0
- package/agents/explorer.md +63 -0
- package/agents/general-purpose.md +32 -0
- package/agents/orchestrator.md +61 -0
- package/agents/planner.md +53 -0
- package/agents/researcher.md +67 -0
- package/agents/reviewer.md +73 -0
- package/dist/chunk-43ONBFZX.js +240 -0
- package/dist/chunk-APZY4IME.js +27 -0
- package/dist/chunk-V3VHZ2VX.js +59 -0
- package/dist/execution/engine/engines/zcode/constants.cjs +62 -9
- package/dist/execution/engine/engines/zcode/constants.d.cts +116 -12
- package/dist/execution/engine/engines/zcode/constants.d.ts +116 -12
- package/dist/execution/engine/engines/zcode/constants.js +39 -7
- package/dist/execution/engine/engines/zcode/reader.d.cts +2 -1
- package/dist/execution/engine/engines/zcode/reader.d.ts +2 -1
- package/dist/execution/engine/engines/zcode/reader.js +4 -234
- package/dist/execution/engine/paths.js +7 -19
- package/dist/index.cjs +18234 -1277
- package/dist/index.d.cts +5646 -673
- package/dist/index.d.ts +5646 -673
- package/dist/index.js +17828 -1277
- package/dist/{types-BxyAidGf.d.cts → types-Dv4QhSJ_.d.cts} +678 -112
- package/dist/{types-BxyAidGf.d.ts → types-Dv4QhSJ_.d.ts} +678 -112
- package/package.json +7 -4
- package/src/__tests__/agent-opts-resolver-schema-prompt.test.ts +0 -1
- package/src/__tests__/append-system-prompt-assembly.test.ts +8 -7
- package/src/__tests__/fr4-get-state-handshake.test.ts +2 -2
- package/src/__tests__/m2-append-content-probe.test.ts +0 -1
- package/src/__tests__/manifest-store.test.ts +10 -9
- package/src/__tests__/record-store-cache.test.ts +0 -2
- package/src/__tests__/record-store-index.test.ts +1 -2
- package/src/__tests__/review-fix-loop-script.test.ts +93 -3
- package/src/__tests__/review-fix-loop-utils.test.ts +31 -10
- package/src/__tests__/robustness-low-batch1.test.ts +6 -5
- package/src/__tests__/robustness-medium-batch1.test.ts +2 -2
- package/src/__tests__/robustness-medium-batch2.test.ts +17 -6
- package/src/__tests__/robustness-medium-batch4.test.ts +2 -2
- package/src/__tests__/session-runner.test.ts +1 -1
- package/src/__tests__/smoke.test.ts +9 -2
- package/src/core/__tests__/host-services.test.ts +2 -2
- package/src/core/__tests__/logger.test.ts +1 -1
- package/src/core/error-message.ts +9 -0
- package/src/core/host-services.ts +21 -5
- package/src/core/notify-ports.ts +18 -5
- package/src/execution/__tests__/agent-profile.test.ts +232 -0
- package/src/execution/__tests__/agent-registry.test.ts +370 -0
- package/src/execution/__tests__/agent-result-mapper.test.ts +18 -2
- package/src/execution/__tests__/agents-assembly.test.ts +219 -0
- package/src/execution/__tests__/ask-user-transit-e2e.test.ts +6 -6
- package/src/execution/__tests__/chat-engine-routing.test.ts +136 -30
- package/src/execution/__tests__/chatmode-first-round-closure-spawn.test.ts +5 -4
- package/src/execution/__tests__/cold-resurrect.test.ts +283 -0
- package/src/execution/__tests__/create-concurrency-pool.test.ts +194 -0
- package/src/execution/__tests__/delivery-methods.test.ts +77 -62
- package/src/execution/__tests__/descendant-sweep-guards.test.ts +220 -0
- package/src/execution/__tests__/descendant-sweep.test.ts +269 -0
- package/src/execution/__tests__/dialog-queue.test.ts +199 -1
- package/src/execution/__tests__/engine-model-validation.test.ts +741 -0
- package/src/execution/__tests__/epipe-fallback.test.ts +31 -24
- package/src/execution/__tests__/execute-and-await-worktree.test.ts +21 -91
- package/src/execution/__tests__/execute-nesting.test.ts +34 -188
- package/src/execution/__tests__/execution-record.test.ts +217 -60
- package/src/execution/__tests__/execution-runtime-face.test.ts +272 -0
- package/src/execution/__tests__/explicit-agent-ref-guard.test.ts +3 -3
- package/src/execution/__tests__/finalize-record.test.ts +278 -16
- package/src/execution/__tests__/gc-timer.test.ts +57 -2
- package/src/execution/__tests__/get-record-for-action-restart.test.ts +14 -12
- package/src/execution/__tests__/get-state-handshake.test.ts +127 -0
- package/src/execution/__tests__/helpers/mock-extension-api.ts +1 -1
- package/src/execution/__tests__/helpers/session-runner-mocks.ts +113 -0
- package/src/execution/__tests__/helpers/spawn-mock.ts +150 -3
- package/src/execution/__tests__/helpers/subagent-service-mocks.ts +137 -0
- package/src/execution/__tests__/keep-alive-no-progress.test.ts +280 -0
- package/src/execution/__tests__/kill-all-escalation.test.ts +196 -0
- package/src/execution/__tests__/lifecycle-manager-idle-timer-identity.test.ts +117 -0
- package/src/execution/__tests__/lifecycle-manager.test.ts +39 -0
- package/src/execution/__tests__/lifecycle-predicates.test.ts +1 -2
- package/src/execution/__tests__/manifest-parentid.test.ts +4 -4
- package/src/execution/__tests__/manifest-store-tmp-recovery.test.ts +99 -0
- package/src/execution/__tests__/max-turns-to-watchdog-ms.test.ts +113 -0
- package/src/execution/__tests__/model-resolver.test.ts +2 -2
- package/src/execution/__tests__/nested-visibility-env-propagation.test.ts +23 -121
- package/src/execution/__tests__/nested-visibility.test.ts +2 -0
- package/src/execution/__tests__/notify-ledger.test.ts +1249 -0
- package/src/execution/__tests__/output-collector.test.ts +117 -6
- package/src/execution/__tests__/pi-invocation.test.ts +1 -1
- package/src/execution/__tests__/record-store-orphan-revive.test.ts +159 -0
- package/src/execution/__tests__/record-store.test.ts +89 -5
- package/src/execution/__tests__/records-cwd-isolation.test.ts +2 -2
- package/src/execution/__tests__/recursive-visibility-baseline.test.ts +29 -132
- package/src/execution/__tests__/recursive-visibility-env.test.ts +55 -179
- package/src/execution/__tests__/rpc-mode.test.ts +2 -2
- package/src/execution/__tests__/run-and-finalize-anchoring.test.ts +387 -0
- package/src/execution/__tests__/run-and-finalize-chatmode.test.ts +19 -9
- package/src/execution/__tests__/run-spawn-chatmode-settled.test.ts +5 -4
- package/src/execution/__tests__/run-spawn-edges.test.ts +418 -26
- package/src/execution/__tests__/run-spawn-integration.test.ts +3 -3
- package/src/execution/__tests__/run-spawn-resume.test.ts +2 -2
- package/src/execution/__tests__/run-spawn-rpc-mode.test.ts +2 -2
- package/src/execution/__tests__/run-spawn-stdout-callback-throw.test.ts +16 -8
- package/src/execution/__tests__/service-kill-escalation.test.ts +91 -0
- package/src/execution/__tests__/session-context-resolver.test.ts +0 -2
- package/src/execution/__tests__/session-file-gc.test.ts +35 -0
- package/src/execution/__tests__/session-pending.test.ts +471 -0
- package/src/execution/__tests__/session-reconstructor.test.ts +366 -15
- package/src/execution/__tests__/session-runner-branch-cache-lru.test.ts +110 -0
- package/src/execution/__tests__/session-runner-close-prune.test.ts +181 -0
- package/src/execution/__tests__/session-runner-dispatch.test.ts +489 -0
- package/src/execution/__tests__/session-runner-epipe.test.ts +4 -3
- package/src/execution/__tests__/session-runner-heartbeat-idle-fallback.test.ts +227 -0
- package/src/execution/__tests__/session-runner-lifecycle-helpers.test.ts +290 -0
- package/src/execution/__tests__/session-runner-schema-env.test.ts +7 -5
- package/src/execution/__tests__/settled-watchdog.test.ts +524 -0
- package/src/execution/__tests__/spawn-args.test.ts +11 -10
- package/src/execution/__tests__/spawn-event-adapter-rpc.test.ts +26 -23
- package/src/execution/__tests__/spawn-event-adapter.test.ts +1 -1
- package/src/execution/__tests__/spawn-worktree-guidance.test.ts +5 -4
- package/src/execution/__tests__/spawned-children.test.ts +155 -11
- package/src/execution/__tests__/start-sync-model-guard.test.ts +4 -4
- package/src/execution/__tests__/stdin-writer.test.ts +6 -4
- package/src/execution/__tests__/stream-sink-retirement.test.ts +6 -6
- package/src/execution/__tests__/subagent-actions-core.test.ts +1017 -0
- package/src/execution/__tests__/subagent-service-message-close.test.ts +99 -35
- package/src/execution/__tests__/subagent-service-multiproc-guard.test.ts +174 -0
- package/src/execution/__tests__/subagent-service-notify-gate.test.ts +271 -0
- package/src/execution/__tests__/subagent-service-parent-guard.test.ts +33 -29
- package/src/execution/__tests__/subagent-service-recovery-bounds.test.ts +341 -0
- package/src/execution/__tests__/subagent-service.test.ts +37 -30
- package/src/execution/__tests__/subprocess-agent-runner-routing.test.ts +88 -12
- package/src/execution/__tests__/subprocess-agent-runner-timeout.test.ts +75 -0
- package/src/execution/__tests__/subprocess-agent-runner.test.ts +22 -20
- package/src/execution/__tests__/temp-prompt.test.ts +1 -1
- package/src/execution/__tests__/timeout-integration.test.ts +13 -12
- package/src/execution/__tests__/turn-limiter-semantics.test.ts +1 -1
- package/src/execution/__tests__/turn-limiter.test.ts +1 -1
- package/src/execution/__tests__/ui-request-handler-factory.test.ts +107 -7
- package/src/execution/__tests__/ui-request-handler.test.ts +4 -3
- package/src/execution/__tests__/ui-request-queue.test.ts +167 -2
- package/src/execution/__tests__/worktree-git-ops.test.ts +571 -0
- package/src/execution/__tests__/worktree-manager.test.ts +14 -5
- package/src/execution/__tests__/worktree-pid-registration.integration.test.ts +4 -3
- package/src/execution/__tests__/worktree-reconcile-aging.test.ts +204 -0
- package/src/execution/agent-registry.ts +298 -30
- package/src/execution/agent-result-mapper.ts +3 -0
- package/src/execution/agents-assembly.ts +88 -0
- package/src/execution/cold-resurrect.ts +199 -0
- package/src/execution/concurrency-pool.ts +71 -9
- package/src/execution/dialog-queue.ts +101 -3
- package/src/execution/engine/__tests__/common/capability-gate.test.ts +91 -0
- package/src/execution/engine/__tests__/common/data-dir.test.ts +1 -1
- package/src/execution/engine/__tests__/common/journal-wiring.test.ts +84 -0
- package/src/execution/engine/__tests__/common/kill-chain.test.ts +34 -7
- package/src/execution/engine/__tests__/common/persona-router.test.ts +4 -5
- package/src/execution/engine/__tests__/common/pool-manager.test.ts +211 -51
- package/src/execution/engine/__tests__/common/session-view-service-zcode-dbpath.test.ts +149 -0
- package/src/execution/engine/__tests__/common/session-view-service.test.ts +499 -0
- package/src/execution/engine/__tests__/conformance/contract.abort.test.ts +56 -99
- package/src/execution/engine/__tests__/conformance/contract.agent-events.test.ts +88 -15
- package/src/execution/engine/__tests__/conformance/engine-conformance.live.test.ts +33 -7
- package/src/execution/engine/__tests__/conformance/golden-replay.pi.test.ts +1 -1
- package/src/execution/engine/__tests__/conformance/golden-replay.zcode.test.ts +75 -54
- package/src/execution/engine/__tests__/conformance/zcode-appserver-harness.ts +128 -0
- package/src/execution/engine/__tests__/engine-discovery.test.ts +15 -3
- package/src/execution/engine/__tests__/model-prompt.test.ts +15 -3
- package/src/execution/engine/__tests__/registry.test.ts +94 -3
- package/src/execution/engine/__tests__/routing.test.ts +115 -6
- package/src/execution/engine/common/capability-gate.ts +92 -0
- package/src/execution/engine/common/journal-wiring.ts +97 -0
- package/src/execution/engine/common/kill-chain.ts +42 -10
- package/src/execution/engine/common/nesting-guard.ts +66 -0
- package/src/execution/engine/common/persona-router.ts +18 -8
- package/src/execution/engine/common/pool-manager.ts +332 -78
- package/src/execution/engine/common/session-view-service.ts +506 -0
- package/src/execution/engine/common/session-view-types.ts +125 -0
- package/src/execution/engine/engine-discovery.ts +12 -16
- package/src/execution/engine/engines/pi/__tests__/pi-engine.test.ts +174 -28
- package/src/execution/engine/engines/pi/__tests__/spawn-opts-direct.test.ts +257 -0
- package/src/execution/{argv-mirror.ts → engine/engines/pi/argv-mirror.ts} +43 -21
- package/src/execution/{get-state-handshake.ts → engine/engines/pi/get-state-handshake.ts} +86 -11
- package/src/execution/{output-collector.ts → engine/engines/pi/output-collector.ts} +108 -19
- package/src/execution/engine/engines/pi/pi-engine.ts +434 -38
- package/src/execution/{pi-invocation.ts → engine/engines/pi/pi-invocation.ts} +2 -2
- package/src/execution/engine/engines/pi/reader.ts +11 -0
- package/src/execution/engine/engines/pi/registration.ts +4 -2
- package/src/execution/engine/engines/pi/session-runner.ts +2840 -0
- package/src/execution/{spawn-event-adapter.ts → engine/engines/pi/spawn-event-adapter.ts} +75 -34
- package/src/execution/{stdin-writer.ts → engine/engines/pi/stdin-writer.ts} +10 -9
- package/src/execution/{temp-prompt.ts → engine/engines/pi/temp-prompt.ts} +2 -2
- package/src/execution/{turn-limiter.ts → engine/engines/pi/turn-limiter.ts} +1 -1
- package/src/execution/engine/engines/zcode/__tests__/__fixtures__/fake-appserver.mjs +301 -0
- package/src/execution/engine/engines/zcode/__tests__/__fixtures__/zcode-golden-appserver.json +36 -0
- package/src/execution/engine/engines/zcode/__tests__/appserver-launcher.test.ts +321 -0
- package/src/execution/engine/engines/zcode/__tests__/connection.test.ts +473 -0
- package/src/execution/engine/engines/zcode/__tests__/parser.test.ts +7 -210
- package/src/execution/engine/engines/zcode/__tests__/preparer.test.ts +6 -110
- package/src/execution/engine/engines/zcode/__tests__/session-channel-dispose-harvest.test.ts +247 -0
- package/src/execution/engine/engines/zcode/__tests__/session-channel-turn-timers.test.ts +451 -0
- package/src/execution/engine/engines/zcode/__tests__/session-channel.test.ts +792 -0
- package/src/execution/engine/engines/zcode/__tests__/zcode-engine-appserver.test.ts +782 -0
- package/src/execution/engine/engines/zcode/__tests__/zcode-engine-degrade.test.ts +168 -0
- package/src/execution/engine/engines/zcode/__tests__/zcode-engine-dispose.test.ts +210 -0
- package/src/execution/engine/engines/zcode/__tests__/zcode-engine-retry.test.ts +353 -0
- package/src/execution/engine/engines/zcode/__tests__/zcode-engine-status.test.ts +282 -0
- package/src/execution/engine/engines/zcode/__tests__/zcode-engine-timeout.test.ts +372 -0
- package/src/execution/engine/engines/zcode/__tests__/zcode-engine.live.test.ts +65 -47
- package/src/execution/engine/engines/zcode/appserver-launcher.ts +167 -0
- package/src/execution/engine/engines/zcode/connection.ts +598 -0
- package/src/execution/engine/engines/zcode/constants.ts +147 -14
- package/src/execution/engine/engines/zcode/golden-sample.ts +42 -34
- package/src/execution/engine/engines/zcode/parser.ts +12 -346
- package/src/execution/engine/engines/zcode/preparer.ts +22 -150
- package/src/execution/engine/engines/zcode/session-channel.ts +968 -0
- package/src/execution/engine/engines/zcode/zcode-engine.ts +1023 -250
- package/src/execution/engine/host-task-spec.ts +32 -36
- package/src/execution/engine/model-validation.ts +177 -0
- package/src/execution/engine/port.ts +65 -7
- package/src/execution/engine/registry.ts +53 -0
- package/src/execution/engine/routing.ts +75 -1
- package/src/execution/engine/types.ts +30 -103
- package/src/execution/execution-record.ts +222 -144
- package/src/execution/finalize-record.ts +181 -85
- package/src/execution/idle-gc.ts +28 -0
- package/src/execution/lifecycle-manager.ts +27 -3
- package/src/execution/lifecycle-predicates.ts +1 -1
- package/src/execution/manifest-store.ts +53 -62
- package/src/execution/notifier.ts +10 -10
- package/src/execution/notify-host.ts +212 -0
- package/src/execution/notify-ledger.ts +117 -16
- package/src/execution/record-entry.ts +8 -2
- package/src/execution/record-store.ts +148 -88
- package/src/execution/round-settlement.ts +93 -0
- package/src/execution/session-file-gc.ts +96 -62
- package/src/execution/session-pending.ts +213 -62
- package/src/execution/session-reconstructor.ts +256 -143
- package/src/execution/sessions-index.ts +127 -102
- package/src/execution/settled-watchdog.ts +311 -0
- package/src/execution/subagent-actions-core.ts +686 -0
- package/src/execution/subagent-service.ts +1106 -907
- package/src/execution/subprocess-agent-runner.ts +144 -97
- package/src/execution/types.ts +9 -0
- package/src/execution/ui-request-handler-factory.ts +126 -75
- package/src/execution/ui-request-queue.ts +50 -19
- package/src/execution/worktree-git-ops.ts +397 -0
- package/src/execution/worktree-manager.ts +72 -10
- package/src/execution/worktree-registry.ts +6 -12
- package/src/index.ts +542 -9
- package/src/orchestration/__tests__/__fixtures__/worker-template.snapshot.txt +42 -3
- package/src/orchestration/__tests__/agent-call-catch-fallback.test.ts +3 -5
- package/src/orchestration/__tests__/agent-call-stream.test.ts +2 -2
- package/src/orchestration/__tests__/args-meta.test.ts +358 -0
- package/src/orchestration/__tests__/args-validator.test.ts +14 -0
- package/src/orchestration/__tests__/error-recovery-rebuild-failure.test.ts +312 -0
- package/src/orchestration/__tests__/error-recovery-terminal-hardening.test.ts +384 -0
- package/src/orchestration/__tests__/execute-agent-call.test.ts +151 -11
- package/src/orchestration/__tests__/file-run-store-prune.test.ts +168 -0
- package/src/orchestration/__tests__/file-run-store-throttle.test.ts +168 -0
- package/src/orchestration/__tests__/file-run-store.test.ts +390 -0
- package/src/orchestration/__tests__/helpers/flush-microtasks.ts +13 -0
- package/src/orchestration/__tests__/launcher-nested-workflow.test.ts +34 -0
- package/src/orchestration/__tests__/lifecycle-abort-broadcast-signal.test.ts +357 -0
- package/src/orchestration/__tests__/lifecycle-recover-crashed.test.ts +289 -0
- package/src/orchestration/__tests__/lifecycle-runid-injection.test.ts +3 -3
- package/src/orchestration/__tests__/lifecycle.test.ts +84 -5
- package/src/orchestration/__tests__/non-cloneable-return-e2e.test.ts +1 -1
- package/src/orchestration/__tests__/run-snapshot.test.ts +356 -0
- package/src/orchestration/__tests__/script-generate.test.ts +314 -0
- package/src/orchestration/__tests__/script-lint.test.ts +17 -0
- package/src/orchestration/__tests__/test-mocks.ts +2 -0
- package/src/orchestration/__tests__/worker-exit-without-result.test.ts +7 -6
- package/src/orchestration/__tests__/worker-message-pump-finalize-run.test.ts +229 -0
- package/src/orchestration/__tests__/{error-recovery-handlers.test.ts → worker-message-pump-handlers.test.ts} +28 -27
- package/src/orchestration/__tests__/{error-recovery-postmessage-defense.test.ts → worker-message-pump-postmessage-defense.test.ts} +8 -8
- package/src/orchestration/__tests__/{error-recovery-serialize-failed-result.test.ts → worker-message-pump-serialize-failed-result.test.ts} +2 -2
- package/src/orchestration/__tests__/{error-recovery-workflow-call.test.ts → worker-message-pump-workflow-call.test.ts} +1 -1
- package/src/orchestration/__tests__/worker-pending-timeout-abort.test.ts +275 -0
- package/src/orchestration/__tests__/worker-script-builder-runtime.test.ts +78 -1
- package/src/orchestration/__tests__/worker-script-builder.test.ts +1 -1
- package/src/orchestration/__tests__/workflow-files.test.ts +186 -0
- package/src/orchestration/__tests__/workflow-nesting-e2e.test.ts +1 -1
- package/src/orchestration/__tests__/workflow-run-summary.test.ts +119 -0
- package/src/orchestration/__tests__/workflow-script-registry-impl.test.ts +124 -0
- package/src/orchestration/agent-opts-resolver.ts +8 -8
- package/src/orchestration/args-meta.ts +198 -0
- package/src/orchestration/args-validator.ts +53 -31
- package/src/orchestration/execute-agent-call.ts +25 -79
- package/src/orchestration/file-run-store.ts +327 -0
- package/src/orchestration/launcher.ts +160 -104
- package/src/orchestration/lifecycle.ts +371 -97
- package/src/orchestration/models/agent-call.ts +7 -7
- package/src/orchestration/models/budget.ts +5 -5
- package/src/orchestration/models/ports.ts +4 -4
- package/src/orchestration/models/run-runtime.ts +15 -15
- package/src/orchestration/models/trace.ts +9 -9
- package/src/orchestration/models/types.ts +111 -22
- package/src/orchestration/models/workflow-run.ts +28 -28
- package/src/orchestration/models/workflow-script.ts +4 -4
- package/src/orchestration/run-snapshot.ts +266 -0
- package/src/orchestration/script-generate.ts +154 -0
- package/src/orchestration/script-lint.ts +123 -90
- package/src/orchestration/worker-handle.ts +10 -10
- package/src/orchestration/worker-host.ts +10 -10
- package/src/orchestration/{error-recovery.ts → worker-message-pump.ts} +498 -221
- package/src/orchestration/worker-script-builder.ts +401 -346
- package/src/orchestration/workflow-files.ts +37 -11
- package/src/orchestration/workflow-run-summary.ts +69 -0
- package/src/orchestration/workflow-script-registry-impl.ts +31 -9
- package/src/shared/__tests__/agent-ref.test.ts +209 -2
- package/src/shared/__tests__/atomic-write.test.ts +267 -0
- package/src/shared/__tests__/bounded-serialize.test.ts +236 -0
- package/src/shared/__tests__/injection-render.test.ts +518 -0
- package/src/shared/__tests__/meta-parser.test.ts +151 -0
- package/src/shared/__tests__/resource-discovery-host-roots.test.ts +474 -0
- package/src/shared/__tests__/resource-discovery.test.ts +261 -217
- package/src/shared/agent-ref.ts +143 -2
- package/src/shared/atomic-write.ts +323 -0
- package/src/shared/bounded-serialize.ts +154 -0
- package/src/shared/injection-render.ts +279 -0
- package/src/shared/meta-parser.ts +182 -68
- package/src/shared/model-ref.ts +15 -2
- package/src/shared/resource-discovery.ts +97 -204
- package/src/shared/resource-meta.ts +14 -0
- package/src/shared/schema-jsonify.ts +1 -1
- package/src/shared/xml-injection.ts +9 -9
- package/workflows/README.md +9 -9
- package/workflows/chain.js +4 -2
- package/workflows/map-reduce.js +5 -3
- package/workflows/parallel.js +5 -3
- package/workflows/review-fix-loop-utils.cjs +165 -92
- package/workflows/review-fix-loop-utils.d.cts +287 -0
- package/workflows/review-fix-loop.js +18 -7
- package/workflows/scatter-gather.js +4 -2
- package/dist/chunk-3VOERJPJ.js +0 -22
- package/src/execution/__tests__/execute-options-mapper.test.ts +0 -200
- package/src/execution/engine/engines/pi/__tests__/task-spec-mapper.test.ts +0 -164
- package/src/execution/engine/engines/pi/task-spec-mapper.ts +0 -100
- package/src/execution/engine/engines/zcode/__tests__/__fixtures__/zcode-golden-spawn.json +0 -39
- package/src/execution/engine/engines/zcode/__tests__/launcher.test.ts +0 -150
- package/src/execution/engine/engines/zcode/__tests__/zcode-engine.test.ts +0 -580
- package/src/execution/engine/engines/zcode/launcher.ts +0 -161
- package/src/execution/execute-options-mapper.ts +0 -115
- package/src/execution/session-runner.ts +0 -1789
- package/src/shared/__tests__/resource-discovery-manifest-cache.test.ts +0 -288
|
@@ -17,7 +17,7 @@ export interface MirrorFlags {
|
|
|
17
17
|
|
|
18
18
|
/**
|
|
19
19
|
* 有值 flag 的解析规则表:成员是「后跟一个值」的 flag 名(含长短形式)。
|
|
20
|
-
* 用于
|
|
20
|
+
* 用于 parseMirrorFlagArgs 跳过其他 flag 的值时不误吃。
|
|
21
21
|
*/
|
|
22
22
|
const VALUED_FLAGS = new Set<string>([
|
|
23
23
|
"--extension", "-e",
|
|
@@ -28,6 +28,23 @@ const VALUED_FLAGS = new Set<string>([
|
|
|
28
28
|
"--thinking", "--models",
|
|
29
29
|
]);
|
|
30
30
|
|
|
31
|
+
/** MirrorFlags 的布尔字段名(extensionPaths 数组字段单列,不进此表)。 */
|
|
32
|
+
type MirrorBooleanKey = "noExtensions" | "approve" | "noContextFiles";
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* 布尔镜像 flag 表:token(长/短形式)→ MirrorFlags 布尔字段。
|
|
36
|
+
* 用 Map 而非对象字面量查表——对象查表对 "__proto__"/"constructor" 等 token
|
|
37
|
+
* 会命中原型链返回非 undefined,Map.get 无此陷阱。
|
|
38
|
+
*/
|
|
39
|
+
const BOOLEAN_FLAGS = new Map<string, MirrorBooleanKey>([
|
|
40
|
+
["--no-extensions", "noExtensions"],
|
|
41
|
+
["-ne", "noExtensions"],
|
|
42
|
+
["--approve", "approve"],
|
|
43
|
+
["-a", "approve"],
|
|
44
|
+
["--no-context-files", "noContextFiles"],
|
|
45
|
+
["-nc", "noContextFiles"],
|
|
46
|
+
]);
|
|
47
|
+
|
|
31
48
|
/** argv 中 flag 的起始索引:argv[0]=runtime, argv[1]=binary 路径。 */
|
|
32
49
|
const ARGV_FLAG_START = 2;
|
|
33
50
|
|
|
@@ -39,7 +56,7 @@ const ARGV_FLAG_START = 2;
|
|
|
39
56
|
* extension/approve 加载行为与主进程一致,且对任意 pi 宿主通用(不止 xyz-agent)。
|
|
40
57
|
*
|
|
41
58
|
* 解析规则:
|
|
42
|
-
* - --no-extensions / -ne、--approve / -a:布尔 flag
|
|
59
|
+
* - --no-extensions / -ne、--approve / -a:布尔 flag(查 BOOLEAN_FLAGS 表)
|
|
43
60
|
* - --no-context-files / -nc:布尔 flag(镜像理由:--extension 镜像会把
|
|
44
61
|
* @zhushanwen/pi-system-prompt 带进每个 subagent,该扩展靠子进程自己的
|
|
45
62
|
* argv 检测此 flag 决定是否注入全局 AGENTS.md——不镜像则用户 opt-out
|
|
@@ -56,26 +73,29 @@ let memoResult: MirrorFlags | undefined;
|
|
|
56
73
|
|
|
57
74
|
export function mirrorMainProcessFlags(argv: readonly string[]): MirrorFlags {
|
|
58
75
|
if (memoResult !== undefined && memoArgv === argv) return memoResult;
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
76
|
+
const result = parseMirrorFlagArgs(
|
|
77
|
+
argv.length > ARGV_FLAG_START ? argv.slice(ARGV_FLAG_START) : [],
|
|
78
|
+
);
|
|
79
|
+
memoArgv = argv;
|
|
80
|
+
memoResult = result;
|
|
81
|
+
return result;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/** 纯解析:扫描 flag 区段(argv[2:])构造 MirrorFlags,不做 memo。 */
|
|
85
|
+
function parseMirrorFlagArgs(flagArgs: readonly string[]): MirrorFlags {
|
|
86
|
+
const flags: Record<MirrorBooleanKey, boolean> = {
|
|
87
|
+
noExtensions: false,
|
|
88
|
+
approve: false,
|
|
89
|
+
noContextFiles: false,
|
|
90
|
+
};
|
|
62
91
|
const extensionPaths: string[] = [];
|
|
63
92
|
|
|
64
93
|
// argv[0]=runtime(bun), argv[1]=pi binary 路径;flag 从 argv[2] 起
|
|
65
|
-
const flagArgs = argv.length > ARGV_FLAG_START ? argv.slice(ARGV_FLAG_START) : [];
|
|
66
|
-
|
|
67
94
|
for (let i = 0; i < flagArgs.length; i++) {
|
|
68
95
|
const tok = flagArgs[i];
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
}
|
|
73
|
-
if (tok === "--approve" || tok === "-a") {
|
|
74
|
-
hasApprove = true;
|
|
75
|
-
continue;
|
|
76
|
-
}
|
|
77
|
-
if (tok === "--no-context-files" || tok === "-nc") {
|
|
78
|
-
hasNoContextFiles = true;
|
|
96
|
+
const booleanKey = BOOLEAN_FLAGS.get(tok);
|
|
97
|
+
if (booleanKey !== undefined) {
|
|
98
|
+
flags[booleanKey] = true;
|
|
79
99
|
continue;
|
|
80
100
|
}
|
|
81
101
|
// 等号形式 --extension=path / -e=path
|
|
@@ -106,8 +126,10 @@ export function mirrorMainProcessFlags(argv: readonly string[]): MirrorFlags {
|
|
|
106
126
|
// 其他情况(未知 flag、--flag=val 形式、positional)忽略
|
|
107
127
|
}
|
|
108
128
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
129
|
+
return {
|
|
130
|
+
noExtensions: flags.noExtensions,
|
|
131
|
+
approve: flags.approve,
|
|
132
|
+
extensionPaths,
|
|
133
|
+
noContextFiles: flags.noContextFiles,
|
|
134
|
+
};
|
|
113
135
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// src/execution/get-state-handshake.ts
|
|
1
|
+
// src/execution/engine/engines/pi/get-state-handshake.ts
|
|
2
2
|
//
|
|
3
3
|
// FR-4: get_state RPC 握手逻辑。
|
|
4
4
|
//
|
|
@@ -30,6 +30,31 @@ export interface GetStateResult {
|
|
|
30
30
|
sessionId?: string;
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
+
/**
|
|
34
|
+
* get_state response 监听器注册函数形态(stdout pump / 测试注入)。
|
|
35
|
+
*
|
|
36
|
+
* 返回值:注销函数(从监听表移除该 resolver),可省略——performGetStateHandshake
|
|
37
|
+
* 忽略返回值(既有语义:迟到 response 靠 resolved 标志自弃,条目由 close 统一清);
|
|
38
|
+
* requestGetStateOnce 消费返回值做单次请求的自清理(不依赖 close 兜底)。
|
|
39
|
+
*/
|
|
40
|
+
export type AddGetStateResponseListener = (
|
|
41
|
+
id: string,
|
|
42
|
+
resolver: (data: unknown) => void,
|
|
43
|
+
) => void | (() => void);
|
|
44
|
+
|
|
45
|
+
/** 从 get_state response data 提取 sessionFile/sessionId(提取规则单一来源,握手与惰性重试共用)。 */
|
|
46
|
+
function extractGetStateFields(data: unknown, into: GetStateResult): void {
|
|
47
|
+
if (data && typeof data === "object") {
|
|
48
|
+
const d = data as Record<string, unknown>;
|
|
49
|
+
if (typeof d.sessionFile === "string" && d.sessionFile.length > 0) {
|
|
50
|
+
into.sessionFile = d.sessionFile;
|
|
51
|
+
}
|
|
52
|
+
if (typeof d.sessionId === "string" && d.sessionId.length > 0) {
|
|
53
|
+
into.sessionId = d.sessionId;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
33
58
|
/**
|
|
34
59
|
* FR-4: 通过 get_state RPC 查询子进程获取 sessionFile/sessionId。
|
|
35
60
|
*
|
|
@@ -43,7 +68,7 @@ export interface GetStateResult {
|
|
|
43
68
|
*/
|
|
44
69
|
export function performGetStateHandshake(
|
|
45
70
|
child: ChildProcess,
|
|
46
|
-
addResponseListener:
|
|
71
|
+
addResponseListener: AddGetStateResponseListener,
|
|
47
72
|
): Promise<GetStateResult> {
|
|
48
73
|
return new Promise<GetStateResult>((resolve) => {
|
|
49
74
|
const collected: GetStateResult = {};
|
|
@@ -81,15 +106,7 @@ export function performGetStateHandshake(
|
|
|
81
106
|
// [#15] 闭包清理本次 tryOnce 的 timer(2s 超时 + 排队中的 retry),不碰其他 reqId 的 timer。
|
|
82
107
|
clearTimeout(timer);
|
|
83
108
|
if (pendingRetry) clearTimeout(pendingRetry);
|
|
84
|
-
|
|
85
|
-
const d = data as Record<string, unknown>;
|
|
86
|
-
if (typeof d.sessionFile === "string" && d.sessionFile.length > 0) {
|
|
87
|
-
collected.sessionFile = d.sessionFile;
|
|
88
|
-
}
|
|
89
|
-
if (typeof d.sessionId === "string" && d.sessionId.length > 0) {
|
|
90
|
-
collected.sessionId = d.sessionId;
|
|
91
|
-
}
|
|
92
|
-
}
|
|
109
|
+
extractGetStateFields(data, collected);
|
|
93
110
|
// sessionFile 已获取——立即 resolve(无需更多重试)
|
|
94
111
|
if (collected.sessionFile) {
|
|
95
112
|
resolved = true;
|
|
@@ -102,3 +119,61 @@ export function performGetStateHandshake(
|
|
|
102
119
|
tryOnce();
|
|
103
120
|
});
|
|
104
121
|
}
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* [T1/RC-1] 单次 get_state 请求(agent_end 决策点惰性回补专用)。
|
|
125
|
+
*
|
|
126
|
+
* 与 performGetStateHandshake 的关系:复用同一消息构造(sendGetStateCommand)与同一
|
|
127
|
+
* 字段提取(extractGetStateFields),但**不做重试循环、不 share 握手语义**——调用方
|
|
128
|
+
* (session-runner agent_end 处置)在子进程 idle 时现场补一次查询(探针 P-T1 实证
|
|
129
|
+
* 应答 0.3-0.4ms),超时/失败即放弃,由调用方走既有保守分支(行为不劣化)。
|
|
130
|
+
*
|
|
131
|
+
* 结果契约与 performGetStateHandshake 一致:resolve GetStateResult(可能为空对象),
|
|
132
|
+
* 永不 reject——stdin 已断(EPIPE/ERR_STREAM_DESTROYED)的同步写失败按「回补失败」
|
|
133
|
+
* 处理 resolve 空对象,调用方无需 try/catch。
|
|
134
|
+
*
|
|
135
|
+
* 自清理:超时或 response 到达后从监听表移除本请求的 resolver(消费注册器的返回值),
|
|
136
|
+
* 不留迟到条目;注册器不返回注销函数时退化为 no-op(与握手同形态,靠 close 统一清)。
|
|
137
|
+
*
|
|
138
|
+
* @param child 子进程(stdin 写入 get_state 命令)
|
|
139
|
+
* @param addResponseListener 注册 response 监听器的函数(stdout pump 中调用)
|
|
140
|
+
* @param timeoutMs 单次超时(决策点预算 1s 量级;P-T1 实测 idle 应答亚毫秒)
|
|
141
|
+
*/
|
|
142
|
+
export function requestGetStateOnce(
|
|
143
|
+
child: ChildProcess,
|
|
144
|
+
addResponseListener: AddGetStateResponseListener,
|
|
145
|
+
timeoutMs: number,
|
|
146
|
+
): Promise<GetStateResult> {
|
|
147
|
+
return new Promise<GetStateResult>((resolve) => {
|
|
148
|
+
let settled = false;
|
|
149
|
+
let removeListener: () => void = () => {};
|
|
150
|
+
|
|
151
|
+
const finish = (r: GetStateResult): void => {
|
|
152
|
+
if (settled) return;
|
|
153
|
+
settled = true;
|
|
154
|
+
clearTimeout(timer);
|
|
155
|
+
removeListener();
|
|
156
|
+
resolve(r);
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
let reqId: string;
|
|
160
|
+
try {
|
|
161
|
+
reqId = sendGetStateCommand(child);
|
|
162
|
+
} catch {
|
|
163
|
+
// stdin 已断等同步写失败 = 回补失败,空结果走调用方保守分支(同超时语义)
|
|
164
|
+
resolve({});
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
167
|
+
removeListener =
|
|
168
|
+
addResponseListener(reqId, (data: unknown) => {
|
|
169
|
+
const r: GetStateResult = {};
|
|
170
|
+
extractGetStateFields(data, r);
|
|
171
|
+
// response 已到达:无论是否含目标字段都不再等(单次语义,无重试)
|
|
172
|
+
finish(r);
|
|
173
|
+
}) ?? (() => {});
|
|
174
|
+
// [#15] 同款时序模式:timer 在 resolver 注册后创建,resolver/finish 闭包引用它——
|
|
175
|
+
// 两者都只在 timer 初始化之后才可能被调用(response 到达是异步事件)。
|
|
176
|
+
const timer: ReturnType<typeof setTimeout> = setTimeout(() => finish({}), timeoutMs);
|
|
177
|
+
timer.unref();
|
|
178
|
+
});
|
|
179
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// src/
|
|
1
|
+
// src/execution/engine/engines/pi/output-collector.ts
|
|
2
2
|
//
|
|
3
3
|
// 结果收集器(Record + CollectResultArgs → AgentResult)。
|
|
4
4
|
//
|
|
@@ -14,21 +14,103 @@ import type {
|
|
|
14
14
|
AgentResult,
|
|
15
15
|
ExecutionRecord,
|
|
16
16
|
ToolCall,
|
|
17
|
-
} from "
|
|
17
|
+
} from "../../../types.ts";
|
|
18
18
|
import {
|
|
19
19
|
getAllToolCalls,
|
|
20
20
|
getFullText,
|
|
21
21
|
getTotalUsage,
|
|
22
|
-
} from "
|
|
23
|
-
//
|
|
24
|
-
//
|
|
25
|
-
|
|
26
|
-
//
|
|
27
|
-
//
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
22
|
+
} from "../../../execution-record.ts";
|
|
23
|
+
// AgentFailureKind 类型 SSOT 在 orchestration/models/types.ts(消费语义「unknown=
|
|
24
|
+
// 可重试」与其文档同源);type-only 引用,编译期擦除,零运行时依赖。
|
|
25
|
+
import type { AgentFailureKind } from "../../../../orchestration/models/types.ts";
|
|
26
|
+
// [D5-③ 词表归属声明] 分诊识别词表(STALE_CONTEXT_PATTERNS /
|
|
27
|
+
// DETERMINISTIC_SCHEMA_FAILURE_PREFIX)SSOT 在本模块(产出侧包内单点识别)——
|
|
28
|
+
// collectResult 识别 pi 错误文案后写 AgentResult.failureKind 结构化字段,消费侧
|
|
29
|
+
// (execute-agent-call)只读字段分诊、不再扫文案子串。文案词表依存并未消除,而是
|
|
30
|
+
// 从「跨模块消费 seam」收窄为「产出侧包内单点识别」;词表漂移的失效模式是
|
|
31
|
+
// failureKind=unknown → 保守重试(安全默认),不再是静默漏诊。
|
|
32
|
+
// (原 SSOT 在 execute-agent-call,2026-09 D5-③ 迁入——execution → orchestration
|
|
33
|
+
// 的值引用随之消除,方向反转为测试/消费侧零依赖。)
|
|
34
|
+
|
|
35
|
+
// ============================================================
|
|
36
|
+
// 失败分诊词表(D5-③,产出侧单点)
|
|
37
|
+
// ============================================================
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Stale context 检测模式(P1-5;W4b 对齐 pi 0.84.x 真实文案)。
|
|
41
|
+
*
|
|
42
|
+
* pi session context 被 compact/cancel 时报告的模式。这种情况下重试无意义——
|
|
43
|
+
* 同样的 call 会再次失败。分诊产出 failureKind="stale_context"(消费侧不重试)。
|
|
44
|
+
*
|
|
45
|
+
* W4b:原 "stale context"/"stalecontext" 与 pi 真实文案零匹配(真实文案为
|
|
46
|
+
* "This extension ctx is stale after session replacement or reload. ..."
|
|
47
|
+
* ——runner.ts:544(dist runner.js:352),词序是 "ctx is stale" 而非 "stale
|
|
48
|
+
* context"),stale 分诊对真实文案失效。现对齐:
|
|
49
|
+
* - "ctx is stale":真实文案核心子串(词序修正)
|
|
50
|
+
* - "stale after session replacement":scheduler 已验证 marker(runtime.ts
|
|
51
|
+
* STALE_CTX_MARKER,同文案锚定)
|
|
52
|
+
* - "context canceled"/"aborted":保留——abort 族错误同样不重试(signal.aborted
|
|
53
|
+
* 分支的先行分诊,防边界竞态漏网),删除会放宽重试语义。
|
|
54
|
+
*/
|
|
55
|
+
export const STALE_CONTEXT_PATTERNS = [
|
|
56
|
+
"ctx is stale",
|
|
57
|
+
"stale after session replacement",
|
|
58
|
+
"context canceled",
|
|
59
|
+
"aborted",
|
|
60
|
+
] as const;
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* 判断错误信息是否表示 stale/canceled pi session context。
|
|
64
|
+
* 命中时分诊 failureKind="stale_context"——重试只会再次失败(P1-5)。
|
|
65
|
+
*/
|
|
66
|
+
export function isStaleContextErrorMsg(msg: string | undefined): boolean {
|
|
67
|
+
if (!msg) return false;
|
|
68
|
+
const lower = msg.toLowerCase();
|
|
69
|
+
return STALE_CONTEXT_PATTERNS.some((p) => lower.includes(p));
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* [MF-1] 确定性 schema 失败标记(error 文本前缀,产出方 = 本模块的
|
|
74
|
+
* describeMissingParsedOutput)。
|
|
75
|
+
*
|
|
76
|
+
* 标记词逐字核对不命中 STALE_CONTEXT_PATTERNS 任一 pattern 与
|
|
77
|
+
* isStaleContextErrorMsg 的子串匹配(否则归因 error 被误诊 stale-context,
|
|
78
|
+
* 虽然同样不重试但归因语义被污染;output-collector.test 有交叉锁定)。
|
|
79
|
+
*
|
|
80
|
+
* 三态可重试性矩阵(F-1 归因):
|
|
81
|
+
* | 归因态 | 带本标记 | 分诊 | 可重试性 | 理由 |
|
|
82
|
+
* |----------------------------|---------|---------------------|---------|------|
|
|
83
|
+
* | ① 从未调用 SO tool | 是 | schema_deterministic | 不可重试 | 缺 extension 是环境确定性(C1 安装盲区),同环境重试必同结果 |
|
|
84
|
+
* | ② SO 调用 isError(gate 终止/不可满足 schema) | 是 | schema_deterministic | 不可重试 | 同 schema 重试必同结果(第五轮实测:3 attempts/4 子进程/235s 纯烧钱) |
|
|
85
|
+
* | ③ 调用过但无 details | 否 | unknown | 可重试 | 可能瞬态(details 提取/序列化异常),保留既有重试语义 |
|
|
86
|
+
*/
|
|
87
|
+
export const DETERMINISTIC_SCHEMA_FAILURE_PREFIX = "Structured output failed deterministically:";
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* [MF-1] 判断错误信息是否为确定性 schema 失败(命中标记前缀)。
|
|
91
|
+
* 命中时分诊 failureKind="schema_deterministic"——同 schema 重试必同结果
|
|
92
|
+
* (矩阵见 DETERMINISTIC_SCHEMA_FAILURE_PREFIX)。
|
|
93
|
+
*/
|
|
94
|
+
export function isDeterministicSchemaFailureMsg(msg: string | undefined): boolean {
|
|
95
|
+
if (!msg) return false;
|
|
96
|
+
return msg.includes(DETERMINISTIC_SCHEMA_FAILURE_PREFIX);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* [D5-③] 错误文案 → 结构化失败分诊标签(产出侧唯一识别点)。
|
|
101
|
+
*
|
|
102
|
+
* 判定优先级与收敛前的消费侧子串分诊一致(stale 在前):标记词与 stale 词表
|
|
103
|
+
* 零交集(交叉锁定测试守护),两序等价。未命中任何词表 → unknown——消费侧
|
|
104
|
+
* 默认退避重试(语义守恒,r1 MF4)。
|
|
105
|
+
*/
|
|
106
|
+
export function classifyFailureKind(
|
|
107
|
+
msg: string | undefined,
|
|
108
|
+
): AgentFailureKind | undefined {
|
|
109
|
+
if (msg === undefined) return undefined;
|
|
110
|
+
if (isStaleContextErrorMsg(msg)) return "stale_context";
|
|
111
|
+
if (isDeterministicSchemaFailureMsg(msg)) return "schema_deterministic";
|
|
112
|
+
return "unknown";
|
|
113
|
+
}
|
|
32
114
|
|
|
33
115
|
// ============================================================
|
|
34
116
|
// Result 收集
|
|
@@ -87,9 +169,8 @@ export function extractParsedOutput(toolCalls: ToolCall[]): unknown {
|
|
|
87
169
|
* 静态文案,已逐字核对无任何 pattern 命中,且由 output-collector.test.ts 的
|
|
88
170
|
* "messages avoid STALE_CONTEXT_PATTERNS substrings" 用例锁定;动态段是
|
|
89
171
|
* 模型/provider 的原始错误文本(可含 "aborted"/"ctx is stale" 等),不受本模块
|
|
90
|
-
* 控制。不中和的话,拼接结果经 collectResult
|
|
91
|
-
*
|
|
92
|
-
* stale-context → 跳过重试。
|
|
172
|
+
* 控制。不中和的话,拼接结果经 collectResult 的 classifyFailureKind 分诊会被
|
|
173
|
+
* 误标为 stale_context(SO 失败归因被误诊),终态虽同样不重试但归因语义被污染。
|
|
93
174
|
*
|
|
94
175
|
* 导出以便直接单测(纯函数契约)。
|
|
95
176
|
*/
|
|
@@ -110,16 +191,16 @@ export function neutralizeStalePatterns(text: string): string {
|
|
|
110
191
|
* 返回 undefined 表示 toolCalls 里有可用的 parsedOutput(无需归因)。
|
|
111
192
|
* 三态判定优先级:校验失败(有 isError 调用)> 从未调用 SO tool > 调用过但无 details。
|
|
112
193
|
*
|
|
113
|
-
* [MF-1] 三态可重试性矩阵(标记 SSOT
|
|
114
|
-
*
|
|
194
|
+
* [MF-1] 三态可重试性矩阵(标记 SSOT 与分类判定均在本模块——D5-③ 收敛为产出侧
|
|
195
|
+
* 单点,消费端 execute-agent-call 只读 failureKind 字段):
|
|
115
196
|
* | 归因态 | 带标记 | 可重试性 | 理由 |
|
|
116
197
|
* |------------------------------|-------|---------|------|
|
|
117
198
|
* | ① 从未调用 SO tool | 是 | 不可重试 | 缺 extension 是环境确定性(C1 安装盲区),同环境重试必同结果 |
|
|
118
199
|
* | ② SO 调用 isError(gate 终止/不可满足 schema) | 是 | 不可重试 | 同 schema 重试必同结果(第五轮实测 retry 放大回归:3 attempts/4 子进程/235s) |
|
|
119
200
|
* | ③ 调用过但无 details | 否 | 可重试 | 可能瞬态(details 提取/序列化异常),保留既有重试语义 |
|
|
120
201
|
*
|
|
121
|
-
*
|
|
122
|
-
*
|
|
202
|
+
* 文案约束:不得命中本模块的 STALE_CONTEXT_PATTERNS("aborted" 等
|
|
203
|
+
* 子串)——命中会被 classifyFailureKind 误标 stale_context。固定前缀(含 MF-1 标记词)静态
|
|
123
204
|
* 无命中(测试锁定);动态段经 neutralizeStalePatterns 中和(F-R1)。
|
|
124
205
|
*
|
|
125
206
|
* 导出以便直接单测(纯函数契约)。
|
|
@@ -224,5 +305,13 @@ export function collectResult(
|
|
|
224
305
|
result.success = false;
|
|
225
306
|
result.error = describeMissingParsedOutput(toolCalls) ?? result.error;
|
|
226
307
|
}
|
|
308
|
+
// [D5-③] 失败分诊结构化:error 最终确定后(含 F-1 归因覆写)一次分类写入。
|
|
309
|
+
// 消费侧(executeAgentCall)读 failureKind 字段分诊,不再扫 error 文案子串;
|
|
310
|
+
// 缺省(成功路径/上游未写)= unknown = 可重试(语义守恒)。H4 合成文案
|
|
311
|
+
// (agent-result-mapper 对 !success && !error 的 abort fallback)在此之后产生,
|
|
312
|
+
// 不经本分类——该场景 signal.aborted 检查兜底,不依赖分诊。
|
|
313
|
+
if (result.error !== undefined) {
|
|
314
|
+
result.failureKind = classifyFailureKind(result.error);
|
|
315
|
+
}
|
|
227
316
|
return result;
|
|
228
317
|
}
|