@zhushanwen/subagent-core 0.4.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-4KN4TTG7.js → chunk-43ONBFZX.js} +1 -1
- package/dist/{chunk-X7SZ5HLQ.js → chunk-V3VHZ2VX.js} +20 -27
- package/dist/execution/engine/engines/zcode/constants.cjs +29 -41
- package/dist/execution/engine/engines/zcode/constants.d.cts +65 -53
- package/dist/execution/engine/engines/zcode/constants.d.ts +65 -53
- package/dist/execution/engine/engines/zcode/constants.js +17 -27
- 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 +2 -2
- package/dist/index.cjs +17100 -14082
- package/dist/index.d.cts +5336 -4033
- package/dist/index.d.ts +5336 -4033
- package/dist/index.js +17020 -14055
- package/dist/{types-DpUO16pj.d.cts → types-C3fE3R9x.d.cts} +280 -112
- package/dist/{types-DpUO16pj.d.ts → types-C3fE3R9x.d.ts} +280 -112
- package/dist.bundle/index.cjs +34933 -0
- package/package.json +3 -3
- 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 +4 -2
- package/src/__tests__/review-fix-loop-utils.test.ts +10 -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/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 +4 -4
- 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 +2 -2
- package/src/execution/__tests__/alive-store.test.ts +1 -1
- package/src/execution/__tests__/ask-user-transit-e2e.test.ts +6 -6
- package/src/execution/__tests__/chat-engine-routing.test.ts +68 -33
- package/src/execution/__tests__/chatmode-first-round-closure-spawn.test.ts +4 -4
- package/src/execution/__tests__/cold-resurrect.test.ts +283 -0
- package/src/execution/__tests__/collect-budget.test.ts +291 -0
- package/src/execution/__tests__/collect-coordinator-service.test.ts +327 -0
- package/src/execution/__tests__/collect-coordinator.test.ts +371 -0
- package/src/execution/__tests__/collect-mixed-dispatch.test.ts +262 -0
- package/src/execution/__tests__/config-collect-sync.test.ts +120 -0
- package/src/execution/__tests__/config.test.ts +1 -1
- package/src/execution/__tests__/delivery-methods.test.ts +75 -62
- package/src/execution/__tests__/descendant-sweep-guards.test.ts +220 -0
- package/src/execution/__tests__/descendant-sweep.test.ts +6 -6
- package/src/execution/__tests__/dialog-queue.test.ts +2 -2
- package/src/execution/__tests__/engine-model-validation.test.ts +741 -0
- package/src/execution/__tests__/epipe-fallback.test.ts +29 -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 +5 -5
- package/src/execution/__tests__/explicit-agent-ref-guard.test.ts +4 -4
- package/src/execution/__tests__/finalize-record.test.ts +173 -17
- package/src/execution/__tests__/finalized-marker.test.ts +1 -1
- package/src/execution/__tests__/gc-timer.test.ts +56 -3
- package/src/execution/__tests__/get-record-for-action-restart.test.ts +12 -12
- package/src/execution/__tests__/get-state-handshake.test.ts +1 -1
- 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 +50 -148
- package/src/execution/__tests__/kill-all-escalation.test.ts +2 -2
- 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 +1 -1
- package/src/execution/__tests__/max-turns-to-watchdog-ms.test.ts +1 -1
- 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-batch.test.ts +500 -0
- package/src/execution/__tests__/notify-ledger.test.ts +1000 -18
- package/src/execution/__tests__/output-collector.test.ts +117 -6
- package/src/execution/__tests__/pi-invocation.test.ts +36 -4
- package/src/execution/__tests__/record-entry-collect.test.ts +102 -0
- package/src/execution/__tests__/record-store.test.ts +10 -9
- 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__/relay-env.test.ts +12 -1
- 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 +15 -9
- package/src/execution/__tests__/run-spawn-chatmode-settled.test.ts +4 -4
- package/src/execution/__tests__/run-spawn-edges.test.ts +17 -15
- package/src/execution/__tests__/run-spawn-integration.test.ts +2 -2
- 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 +4 -4
- package/src/execution/__tests__/service-kill-escalation.test.ts +7 -5
- package/src/execution/__tests__/session-context-resolver.test.ts +0 -2
- package/src/execution/__tests__/session-file-gc.test.ts +36 -1
- package/src/execution/__tests__/session-pending.test.ts +257 -14
- package/src/execution/__tests__/session-reconstructor.test.ts +366 -15
- package/src/execution/__tests__/session-runner-branch-cache-lru.test.ts +1 -1
- package/src/execution/__tests__/session-runner-close-prune.test.ts +2 -2
- package/src/execution/__tests__/session-runner-dispatch.test.ts +489 -0
- package/src/execution/__tests__/session-runner-epipe.test.ts +3 -3
- package/src/execution/__tests__/session-runner-heartbeat-idle-fallback.test.ts +5 -4
- 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 +282 -47
- 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 +3 -3
- package/src/execution/__tests__/spawn-worktree-guidance.test.ts +5 -4
- package/src/execution/__tests__/spawned-children.test.ts +2 -1
- package/src/execution/__tests__/start-collect-guard.test.ts +255 -0
- package/src/execution/__tests__/start-sync-model-guard.test.ts +5 -5
- 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 +48 -22
- package/src/execution/__tests__/subagent-service-message-close.test.ts +29 -26
- package/src/execution/__tests__/subagent-service-multiproc-guard.test.ts +21 -8
- package/src/execution/__tests__/subagent-service-notify-gate.test.ts +27 -22
- package/src/execution/__tests__/subagent-service-parent-guard.test.ts +30 -29
- package/src/execution/__tests__/subagent-service-recovery-bounds.test.ts +45 -20
- 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__/sync-collect-recovery.test.ts +1117 -0
- package/src/execution/__tests__/temp-prompt.test.ts +1 -1
- package/src/execution/__tests__/timeout-integration.test.ts +6 -5
- package/src/execution/__tests__/tombstone-store.test.ts +1 -1
- 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 +12 -6
- package/src/execution/__tests__/ui-request-handler.test.ts +4 -3
- package/src/execution/__tests__/ui-request-queue.test.ts +142 -2
- package/src/execution/__tests__/worktree-git-ops.test.ts +1 -1
- 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 +2 -2
- package/src/execution/__tests__/worktree-reconcile.integration.test.ts +1 -1
- package/src/execution/__tests__/worktree-registry.test.ts +1 -1
- package/src/execution/agent-registry.ts +74 -30
- package/src/execution/agent-result-mapper.ts +3 -0
- package/src/execution/cold-resurrect.ts +199 -0
- package/src/execution/collect-coordinator.ts +200 -0
- package/src/execution/config.ts +77 -5
- 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/event-journal.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 +213 -53
- 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 +22 -112
- package/src/execution/engine/__tests__/conformance/contract.agent-events.test.ts +15 -28
- package/src/execution/engine/__tests__/conformance/contract.read-degradation.test.ts +1 -1
- package/src/execution/engine/__tests__/conformance/engine-conformance.live.test.ts +12 -12
- package/src/execution/engine/__tests__/conformance/golden-replay.pi.test.ts +2 -2
- package/src/execution/engine/__tests__/conformance/golden-replay.zcode.test.ts +21 -82
- package/src/execution/engine/__tests__/conformance/zcode-appserver-harness.ts +4 -7
- 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 +4 -2
- 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/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} +1 -1
- 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/{session-runner.ts → engine/engines/pi/session-runner.ts} +617 -412
- 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 +54 -27
- package/src/execution/engine/engines/zcode/__tests__/appserver-launcher.test.ts +321 -0
- package/src/execution/engine/engines/zcode/__tests__/connection.test.ts +13 -12
- 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 +20 -8
- package/src/execution/engine/engines/zcode/__tests__/zcode-engine-appserver.test.ts +77 -110
- package/src/execution/engine/engines/zcode/__tests__/zcode-engine-degrade.test.ts +26 -320
- 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 +48 -148
- package/src/execution/engine/engines/zcode/appserver-launcher.ts +167 -0
- package/src/execution/engine/engines/zcode/connection.ts +24 -11
- package/src/execution/engine/engines/zcode/constants.ts +75 -71
- package/src/execution/engine/engines/zcode/golden-sample.ts +8 -46
- package/src/execution/engine/engines/zcode/parser.ts +12 -346
- package/src/execution/engine/engines/zcode/preparer.ts +12 -143
- package/src/execution/engine/engines/zcode/session-channel.ts +351 -39
- package/src/execution/engine/engines/zcode/zcode-engine.ts +665 -760
- 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 +24 -6
- package/src/execution/engine/routing.ts +75 -1
- package/src/execution/engine/types.ts +30 -103
- package/src/execution/execution-record.ts +229 -144
- package/src/execution/finalize-record.ts +141 -99
- package/src/execution/idle-gc.ts +28 -0
- package/src/execution/lifecycle-predicates.ts +1 -1
- package/src/execution/notifier.ts +234 -25
- package/src/execution/notify-host.ts +232 -0
- package/src/execution/record-entry.ts +16 -0
- package/src/execution/record-store.ts +280 -103
- package/src/execution/round-settlement.ts +93 -0
- package/src/execution/session-file-gc.ts +96 -62
- package/src/execution/session-reconstructor.ts +256 -143
- package/src/execution/sessions-index.ts +117 -47
- package/src/execution/settled-watchdog.ts +264 -52
- package/src/execution/subagent-actions-core.ts +84 -28
- package/src/execution/subagent-service.ts +1225 -964
- package/src/execution/subprocess-agent-runner.ts +144 -97
- package/src/execution/sync-rebuild.ts +87 -0
- package/src/execution/types.ts +72 -0
- package/src/execution/ui-request-handler-factory.ts +102 -74
- package/src/execution/ui-request-queue.ts +50 -19
- package/src/index.ts +442 -316
- package/src/orchestration/__tests__/agent-call-catch-fallback.test.ts +1 -1
- package/src/orchestration/__tests__/agent-call-stream.test.ts +2 -2
- package/src/orchestration/__tests__/args-validator.test.ts +14 -0
- package/src/orchestration/__tests__/config-loader.test.ts +1 -1
- package/src/orchestration/__tests__/error-recovery-rebuild-failure.test.ts +1 -1
- package/src/orchestration/__tests__/error-recovery-terminal-hardening.test.ts +11 -9
- package/src/orchestration/__tests__/execute-agent-call.test.ts +151 -11
- package/src/orchestration/__tests__/file-run-store-prune.test.ts +1 -1
- package/src/orchestration/__tests__/file-run-store-throttle.test.ts +1 -1
- package/src/orchestration/__tests__/file-run-store.test.ts +7 -6
- package/src/orchestration/__tests__/launcher-nested-workflow.test.ts +2 -2
- package/src/orchestration/__tests__/lifecycle-abort-broadcast-signal.test.ts +1 -1
- package/src/orchestration/__tests__/lifecycle-runid-injection.test.ts +3 -3
- package/src/orchestration/__tests__/lifecycle.test.ts +7 -5
- package/src/orchestration/__tests__/non-cloneable-return-e2e.test.ts +1 -1
- package/src/orchestration/__tests__/review-fix-loop-scriptpath-failfast.test.ts +1 -1
- package/src/orchestration/__tests__/run-snapshot.test.ts +8 -5
- package/src/orchestration/__tests__/script-generate.test.ts +5 -5
- package/src/orchestration/__tests__/script-lint.test.ts +17 -0
- package/src/orchestration/__tests__/skill-discovery.test.ts +2 -2
- 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} +27 -19
- 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 +1 -1
- package/src/orchestration/__tests__/worker-script-builder.test.ts +1 -1
- package/src/orchestration/__tests__/workflow-files.test.ts +10 -10
- package/src/orchestration/__tests__/workflow-nesting-e2e.test.ts +1 -1
- package/src/orchestration/__tests__/workflow-script-registry-impl.test.ts +1 -1
- package/src/orchestration/agent-opts-resolver.ts +1 -1
- package/src/orchestration/args-validator.ts +53 -31
- package/src/orchestration/execute-agent-call.ts +19 -73
- package/src/orchestration/launcher.ts +128 -81
- package/src/orchestration/lifecycle.ts +43 -45
- package/src/orchestration/models/ports.ts +4 -4
- package/src/orchestration/models/run-runtime.ts +2 -2
- package/src/orchestration/models/trace.ts +1 -1
- package/src/orchestration/models/types.ts +111 -22
- package/src/orchestration/models/workflow-run.ts +1 -1
- package/src/orchestration/script-lint.ts +91 -58
- package/src/orchestration/{error-recovery.ts → worker-message-pump.ts} +157 -150
- package/src/shared/__tests__/atomic-write.test.ts +1 -1
- package/src/shared/__tests__/meta-parser.test.ts +151 -0
- package/src/shared/__tests__/resource-discovery-host-roots.test.ts +5 -5
- package/src/shared/__tests__/resource-discovery.test.ts +258 -215
- package/src/shared/atomic-write.ts +12 -9
- package/src/shared/meta-parser.ts +158 -84
- package/src/shared/model-ref.ts +15 -2
- package/src/shared/resource-discovery.ts +9 -183
- package/src/shared/schema-jsonify.ts +1 -1
- package/workflows/review-fix-loop-utils.cjs +151 -89
- package/workflows/review-fix-loop-utils.d.cts +287 -0
- 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__/preparer-appserver.test.ts +0 -387
- package/src/execution/engine/engines/zcode/__tests__/zcode-engine.test.ts +0 -710
- package/src/execution/engine/engines/zcode/appserver-home.ts +0 -442
- package/src/execution/engine/engines/zcode/appserver-probe.ts +0 -141
- package/src/execution/engine/engines/zcode/launcher.ts +0 -161
- package/src/execution/execute-options-mapper.ts +0 -115
- package/src/shared/__tests__/resource-discovery-manifest-cache.test.ts +0 -288
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
* 「releaseRuntime → 改 status」原子顺序。
|
|
25
25
|
*
|
|
26
26
|
* **G3-001**(run 一次性生命周期):AbortController 一次性无法复用,runtime 释放后
|
|
27
|
-
* 只有两类重建——rebuildRuntime(
|
|
27
|
+
* 只有两类重建——rebuildRuntime(worker-message-pump,崩溃重试路径,run 保持 running、
|
|
28
28
|
* replaceRuntime 原子换新)与 abort/terminate 的终态释放(transition("done") 内
|
|
29
29
|
* releaseRuntime,run 不再恢复)。
|
|
30
30
|
* (旧并发门闩 gate 抽象已删——no-op 无生产语义,实际并发由 SubagentService
|
|
@@ -42,12 +42,11 @@ import { assertSafeTimerDelay } from "../shared/timer-delay.ts";
|
|
|
42
42
|
import { validateRunArgs } from "./args-validator.ts";
|
|
43
43
|
import {
|
|
44
44
|
closeOutInFlightCalls,
|
|
45
|
-
|
|
46
|
-
emitTerminalSideEffects,
|
|
45
|
+
finalizeRun,
|
|
47
46
|
handleWorkerError,
|
|
48
47
|
handleWorkerExit,
|
|
49
48
|
handleWorkerMessage,
|
|
50
|
-
} from "./
|
|
49
|
+
} from "./worker-message-pump.ts";
|
|
51
50
|
import { Budget } from "./models/budget.ts";
|
|
52
51
|
import type { LifecycleDeps, RunStore, WorkerHandlers } from "./models/ports.ts";
|
|
53
52
|
import { RunRuntime } from "./models/run-runtime.ts";
|
|
@@ -56,6 +55,7 @@ import { Trace } from "./models/trace.ts";
|
|
|
56
55
|
import type { DoneReason } from "./models/types.ts";
|
|
57
56
|
import { WorkflowRun } from "./models/workflow-run.ts";
|
|
58
57
|
import type { WorkerHandle } from "./worker-handle.ts";
|
|
58
|
+
import { toErrorMessage } from "../core/error-message.ts";
|
|
59
59
|
|
|
60
60
|
const logger = getLogger("subagents");
|
|
61
61
|
|
|
@@ -118,24 +118,24 @@ function broadcastAbortToWorker(run: WorkflowRun, reason: string): void {
|
|
|
118
118
|
try {
|
|
119
119
|
run.runtime?.worker.postMessage({ type: "abort", reason });
|
|
120
120
|
} catch (err) {
|
|
121
|
-
const msg =
|
|
121
|
+
const msg = toErrorMessage(err);
|
|
122
122
|
logger.debug(
|
|
123
123
|
`[workflow] abort broadcast to worker failed (runId=${run.runId}, worker likely already exited): ${msg}`,
|
|
124
124
|
);
|
|
125
125
|
}
|
|
126
126
|
}
|
|
127
127
|
|
|
128
|
-
// ── makeHandlers(路由 worker 事件到
|
|
128
|
+
// ── makeHandlers(路由 worker 事件到 worker-message-pump handle* 函数) ──────
|
|
129
129
|
|
|
130
130
|
/**
|
|
131
131
|
* 构造 WorkerHandlers——将 worker 的 onMessage/onError/onExit 事件路由到
|
|
132
|
-
*
|
|
132
|
+
* worker-message-pump 的 handleWorker* 函数。
|
|
133
133
|
*
|
|
134
134
|
* 闭包捕获 run + deps。runtime 重建(replaceRuntime)后 run 实例不变、deps 不变,
|
|
135
|
-
* 故 handlers 对新 worker 仍有效(lifecycle 与
|
|
135
|
+
* 故 handlers 对新 worker 仍有效(lifecycle 与 worker-message-pump 共用 handlers)。
|
|
136
136
|
*
|
|
137
137
|
* **onExit G-025**:handleWorkerExit 内部检查 handle.isCurrent(stale exit 丢弃)。
|
|
138
|
-
* 本函数不在 onExit 里重复检查——
|
|
138
|
+
* 本函数不在 onExit 里重复检查——worker-message-pump.handleWorkerExit 是单一守卫点。
|
|
139
139
|
*
|
|
140
140
|
* **workerErrorCount**:onError 触发时递增(C.5 跨 runtime 存活的重试计数载体)。
|
|
141
141
|
* 注意 handleWorkerError 内部也会递增——这里 onError 递增是 worker 事件层面的
|
|
@@ -144,10 +144,10 @@ function broadcastAbortToWorker(run: WorkflowRun, reason: string): void {
|
|
|
144
144
|
*/
|
|
145
145
|
function makeHandlers(run: WorkflowRun, deps: LifecycleDeps): WorkerHandlers {
|
|
146
146
|
// [OR-7] per-run deps 视图:包装 onRunDone,把「run 终态」转译为「移除 signal abort
|
|
147
|
-
// listener」。
|
|
147
|
+
// listener」。worker-message-pump 全部终态路径(handleReturn / handleWorkerError /
|
|
148
148
|
// handleScriptError / handleWorkerExit / 预算终止 / time_limited / [OR-2] rebuild
|
|
149
|
-
//
|
|
150
|
-
// abortRun / terminateRunningRuns 两个 lifecycle 自有终态路径另行显式 dispose。
|
|
149
|
+
// 失败收敛——均经 finalizeRun)都经 handlers 调用链消费本视图——消息面终态在此
|
|
150
|
+
// 统一收口;abortRun / terminateRunningRuns 两个 lifecycle 自有终态路径另行显式 dispose。
|
|
151
151
|
const depsWithTerminalCleanup: LifecycleDeps = {
|
|
152
152
|
...deps,
|
|
153
153
|
onRunDone: (doneRun: WorkflowRun): void => {
|
|
@@ -155,7 +155,7 @@ function makeHandlers(run: WorkflowRun, deps: LifecycleDeps): WorkerHandlers {
|
|
|
155
155
|
deps.onRunDone?.(doneRun);
|
|
156
156
|
},
|
|
157
157
|
};
|
|
158
|
-
// 自引用——
|
|
158
|
+
// 自引用——worker-message-pump rebuildRuntime 需要 handlers 参数(handlers 引用自身)
|
|
159
159
|
const handlers: WorkerHandlers = {
|
|
160
160
|
async onMessage(raw: unknown): Promise<void> {
|
|
161
161
|
await handleWorkerMessage(run, raw, depsWithTerminalCleanup, handlers);
|
|
@@ -198,7 +198,7 @@ export function scheduleTimeBudget(
|
|
|
198
198
|
const timer = setTimeout(() => {
|
|
199
199
|
void abortRun(runId, deps, "Time budget exceeded", "time_limited").catch(
|
|
200
200
|
(err: unknown) => {
|
|
201
|
-
const msg =
|
|
201
|
+
const msg = toErrorMessage(err);
|
|
202
202
|
logger.error(`[workflow] time budget abort failed: ${msg}`);
|
|
203
203
|
},
|
|
204
204
|
);
|
|
@@ -213,7 +213,7 @@ export function scheduleTimeBudget(
|
|
|
213
213
|
/**
|
|
214
214
|
* rfl 仪表(tier-1 §7.1):向 spec.args 原地注入稳定 _runId。runAndWait 与
|
|
215
215
|
* executeNestedWorkflow 两个 args 入口都经 runWorkflow 这一 choke point;
|
|
216
|
-
* rebuildRuntime 复用 run.spec.args 同一对象(
|
|
216
|
+
* rebuildRuntime 复用 run.spec.args 同一对象(worker-message-pump.ts),worker rebuild
|
|
217
217
|
* 后脚本侧 $ARGS._runId 不漂移——修复「rebuild 回退 run-<Date.now()> 导致同一
|
|
218
218
|
* 逻辑 run 碎裂到多个 state 目录」。注入在 validateRunArgs 之后,不参与脚本
|
|
219
219
|
* 参数 schema 校验(引擎内部字段)。
|
|
@@ -307,7 +307,7 @@ function registerSignalAbortListener(
|
|
|
307
307
|
const onAbort = (): void => {
|
|
308
308
|
disposeSignalAbortListener(run);
|
|
309
309
|
void abortRun(runId, deps, "External signal aborted").catch((err: unknown) => {
|
|
310
|
-
const msg =
|
|
310
|
+
const msg = toErrorMessage(err);
|
|
311
311
|
logger.error(`[workflow] abortRun on signal failed: ${msg}`);
|
|
312
312
|
});
|
|
313
313
|
};
|
|
@@ -426,20 +426,16 @@ export async function abortRun(
|
|
|
426
426
|
// [OR-3] 先广播 abort 再 transition(transition 内 releaseRuntime→terminate,
|
|
427
427
|
// terminate 之后广播发不进去)——worker 侧 pending 优雅解阻
|
|
428
428
|
broadcastAbortToWorker(run, reason ?? `Workflow aborted (${doneReason})`);
|
|
429
|
-
// A4: transition 内部 releaseRuntime(cleanup before mutate)
|
|
430
|
-
run.transition("done", doneReason);
|
|
431
429
|
// [OR-7] run 终态:移除 signal abort listener(幂等;abort 由 signal 触发时
|
|
432
|
-
// listener 已在 onAbort 内自移除,此处为其余 abort
|
|
430
|
+
// listener 已在 onAbort 内自移除,此处为其余 abort 入口的收口;即使 finalizeRun
|
|
431
|
+
// 因并发终态化让位,WeakMap 条目也应清除,不依赖 transition 成败)
|
|
433
432
|
disposeSignalAbortListener(run);
|
|
434
|
-
//
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
//
|
|
439
|
-
|
|
440
|
-
// listener 同步抛错不再跳过 onRunDone 或把错误抛给 abort 调用方;错误 error 留痕后
|
|
441
|
-
// 本函数仍按 abort 成功语义正常返回(内存态已终态)。
|
|
442
|
-
emitTerminalSideEffects(run, deps, `abortRun (done,${doneReason})`);
|
|
433
|
+
// A4 + C-4: transition 内部 releaseRuntime(cleanup before mutate);到达 done 终态
|
|
434
|
+
// → 注销 pending-notification + 通知 Interface 层(D5-② 终态 coda 收敛为
|
|
435
|
+
// worker-message-pump 的 finalizeRun 单写点——OR-8 in-flight 收口 + save best-effort
|
|
436
|
+
// (SW-DATA-3)不再向上抛,内存态已终态,调用方无需因落盘失败收到 abort 异常;
|
|
437
|
+
// OR-4/B-4 unregister 与 onRunDone 各自独立围栏)
|
|
438
|
+
await finalizeRun(run, deps, doneReason, { context: `abortRun (${doneReason})` });
|
|
443
439
|
}
|
|
444
440
|
|
|
445
441
|
// ── terminateRunningRuns(session 切换/关闭:终止全部 running run) ────────
|
|
@@ -451,11 +447,12 @@ export async function abortRun(
|
|
|
451
447
|
* done,failed 持久化落盘——重启后 kill-9 恢复不误判,也不再存在「挂起待恢复」
|
|
452
448
|
* 的中间态。
|
|
453
449
|
*
|
|
454
|
-
* per-run 行为:`state.error = reason` → `
|
|
455
|
-
* releaseRuntime,A4
|
|
456
|
-
* {reason:"failed"})
|
|
450
|
+
* per-run 行为:`state.error = reason` → `finalizeRun(run, deps, "failed",
|
|
451
|
+
* {notifyDone:false})`(transition("done","failed") 内部先 releaseRuntime,A4 →
|
|
452
|
+
* save best-effort → `eventBus.emit("pending:unregister", {reason:"failed"})`)。
|
|
457
453
|
*
|
|
458
|
-
* **不调 deps.onRunDone
|
|
454
|
+
* **不调 deps.onRunDone**(经 finalizeRun 的 notifyDone:false 承载,D5-②):
|
|
455
|
+
* 对齐 session_start 恢复先例(index.ts kill-9 恢复只发
|
|
459
456
|
* unregister、不发 onRunDone)——session 切换/关闭语境下主 agent 已离开本 session,
|
|
460
457
|
* 注入完成通知只会把消息发给已离开的 session。
|
|
461
458
|
*
|
|
@@ -480,21 +477,22 @@ export async function terminateRunningRuns(
|
|
|
480
477
|
run.state.error = reason;
|
|
481
478
|
// [OR-3] 同 abortRun:先广播 abort 再 transition(worker 侧 pending 优雅解阻)
|
|
482
479
|
broadcastAbortToWorker(run, reason);
|
|
483
|
-
// A4: transition 内部先 releaseRuntime(cleanup before mutate)
|
|
484
|
-
run.transition("done", "failed");
|
|
485
480
|
// [OR-7] run 终态:移除 signal abort listener(terminateRunningRuns 不走
|
|
486
|
-
// onRunDone
|
|
481
|
+
// onRunDone——本路径显式收口,不依赖 finalizeRun 的 notifyDone 分支)
|
|
487
482
|
disposeSignalAbortListener(run);
|
|
488
|
-
//
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
//
|
|
492
|
-
//
|
|
493
|
-
//
|
|
494
|
-
|
|
483
|
+
// A4 + C-4: transition 内部 releaseRuntime(cleanup before mutate);done 终态 →
|
|
484
|
+
// 注销 pending-notification(D5-② 终态 coda 收敛为 finalizeRun 单写点)。
|
|
485
|
+
// notifyDone: false——**不调 deps.onRunDone**(真差异经参数承载):对齐
|
|
486
|
+
// session_start 恢复先例(index.ts kill-9 恢复只发 unregister、不发
|
|
487
|
+
// onRunDone)——session 切换/关闭语境下主 agent 已离开本 session,注入完成
|
|
488
|
+
// 通知只会把消息发给已离开的 session。OR-8 in-flight 收口由 finalizeRun 承载。
|
|
489
|
+
await finalizeRun(run, deps, "failed", {
|
|
490
|
+
context: "terminateRunningRuns",
|
|
491
|
+
notifyDone: false,
|
|
492
|
+
});
|
|
495
493
|
deps.log?.("debug", "workflow:lifecycle", "run terminated", { runId: run.runId, reason: run.state.reason });
|
|
496
494
|
} catch (err) {
|
|
497
|
-
const msg =
|
|
495
|
+
const msg = toErrorMessage(err);
|
|
498
496
|
logger.error(
|
|
499
497
|
`[workflow] terminateRunningRuns failed for run ${run.runId}: ${msg} (reason: ${reason})`,
|
|
500
498
|
);
|
|
@@ -644,7 +642,7 @@ export async function recoverCrashedRuns(
|
|
|
644
642
|
try {
|
|
645
643
|
hooks?.onRunRecovered?.({ id: run.runId, reason: "failed" });
|
|
646
644
|
} catch (err) {
|
|
647
|
-
const msg =
|
|
645
|
+
const msg = toErrorMessage(err);
|
|
648
646
|
logger.warn(
|
|
649
647
|
`[workflow] recoverCrashedRuns onRunRecovered hook failed for run ${run.runId} (recovery continues): ${msg}`,
|
|
650
648
|
);
|
|
@@ -653,7 +651,7 @@ export async function recoverCrashedRuns(
|
|
|
653
651
|
try {
|
|
654
652
|
await store.save(run);
|
|
655
653
|
} catch (err) {
|
|
656
|
-
const msg =
|
|
654
|
+
const msg = toErrorMessage(err);
|
|
657
655
|
logger.error(
|
|
658
656
|
`[workflow] recoverCrashedRuns store.save failed for run ${run.runId}: ${msg} (reason: ${reason})`,
|
|
659
657
|
);
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* 是真需要 mock 测试的依赖(子进程/文件系统/线程)。
|
|
6
6
|
*
|
|
7
7
|
* 编排层共享类型(WorkerHandlers / LifecycleDeps)——打破 lifecycle ↔
|
|
8
|
-
*
|
|
8
|
+
* worker-message-pump 循环依赖:2 个 engine 函数文件各自独立,共用同一组
|
|
9
9
|
* 依赖签名(D-12)。
|
|
10
10
|
*
|
|
11
11
|
* 层归属:Engine。零 infra 依赖(AC-1)。
|
|
@@ -71,7 +71,7 @@ export interface WorkerHost {
|
|
|
71
71
|
|
|
72
72
|
/**
|
|
73
73
|
* Worker 线程事件回调集合——WorkerHost.start 的入参,由 lifecycle
|
|
74
|
-
* 构造并注入。2 个 engine 文件(lifecycle /
|
|
74
|
+
* 构造并注入。2 个 engine 文件(lifecycle / worker-message-pump)共用此签名,
|
|
75
75
|
* 避免各自定义形状不一致的 handler bag(打破循环依赖)。
|
|
76
76
|
*
|
|
77
77
|
* 所有回调返回 Promise——允许 engine 层在回调内做 await persistState 等异步操作。
|
|
@@ -88,7 +88,7 @@ export interface WorkerHandlers {
|
|
|
88
88
|
// ── 编排层共享类型 2: LifecycleDeps ────────────────────────────
|
|
89
89
|
|
|
90
90
|
/**
|
|
91
|
-
* lifecycle /
|
|
91
|
+
* lifecycle / worker-message-pump 2 个 engine 函数文件的共同依赖 bag。
|
|
92
92
|
*
|
|
93
93
|
* 取代旧 4 个 Context factory(errorHandlerContext / agentCallContext /
|
|
94
94
|
* budgetCallbacks / 旧 terminate bag,AC-2 目标)。函数签名 `(deps: LifecycleDeps, ...)`
|
|
@@ -142,7 +142,7 @@ export interface LifecycleDeps {
|
|
|
142
142
|
* workflow() 嵌套调用回调(可选)。Worker 脚本内调 workflow(name, args) 时触发。
|
|
143
143
|
*
|
|
144
144
|
* 由 Interface 层 makeDeps 注入(闭包捕获 registry + deps)。Engine 层的
|
|
145
|
-
*
|
|
145
|
+
* worker-message-pump.handleWorkerMessage 收到 workflow-call 消息后调本回调,
|
|
146
146
|
* 拿到子 workflow 执行结果后 postMessage(workflow-result) 回 worker。
|
|
147
147
|
*
|
|
148
148
|
* 不注入时 workflow() 返回 error result(向后兼容,不影响非嵌套场景)。
|
|
@@ -7,11 +7,11 @@
|
|
|
7
7
|
* 职责:封装一次 running-segment 的所有技术资源(worker 线程 +
|
|
8
8
|
* abort controller),统一 release 入口(AC-2:单 release 替代多 boolean flag)。
|
|
9
9
|
* (旧并发门闩 gate 抽象已删——no-op,实际并发由 SubagentService ConcurrencyPool 管理;
|
|
10
|
-
* 原 withSlot 的 pre-abort 检查内联到
|
|
10
|
+
* 原 withSlot 的 pre-abort 检查内联到 worker-message-pump dispatchAgentCall。)
|
|
11
11
|
*
|
|
12
12
|
* 一次性生命周期(G3-001):runtime 释放后不再复用——AbortController 一次性
|
|
13
13
|
* 语义决定 controller 无法跨释放复用,所以整个 RunRuntime 重建。唯一注入路径:
|
|
14
|
-
* assignRuntime(runWorkflow 创建)与 replaceRuntime(
|
|
14
|
+
* assignRuntime(runWorkflow 创建)与 replaceRuntime(worker-message-pump 崩溃重试)。
|
|
15
15
|
*
|
|
16
16
|
* 参考:domain-models.md §10、clarification.md G3-001。
|
|
17
17
|
*/
|
|
@@ -153,7 +153,7 @@ export class Trace {
|
|
|
153
153
|
/**
|
|
154
154
|
* 按 stepIndex 移除节点(崩溃重建清理在飞 call 用)。
|
|
155
155
|
*
|
|
156
|
-
* 正常运行不调用(append-only 不变式)。仅
|
|
156
|
+
* 正常运行不调用(append-only 不变式)。仅 worker-message-pump 的 discardInFlightCalls
|
|
157
157
|
* (rebuildRuntime 内,F2)清理被旧 runtime abort 的在飞 call 时用——移除其 trace
|
|
158
158
|
* 节点,让重跑重发 agent-call 时 append 全新节点走全新执行路径(避免 stale
|
|
159
159
|
* "running" 节点残留 + trace.update 命中旧节点导致新节点 orphan)。
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
* 层归属:Engine(数据结构 + 不变式守卫)。
|
|
14
14
|
*/
|
|
15
15
|
|
|
16
|
-
import type { ExecutionRecord } from "../../execution/types.ts";
|
|
16
|
+
import type { ExecutionRecord, WorktreeHandle } from "../../execution/types.ts";
|
|
17
17
|
|
|
18
18
|
// ── 状态机 ────────────────────────────────────────────────────
|
|
19
19
|
|
|
@@ -65,7 +65,37 @@ export function canRunTransition(from: RunStatus, to: RunStatus): boolean {
|
|
|
65
65
|
// ── Agent 调用 ────────────────────────────────────────────────
|
|
66
66
|
|
|
67
67
|
/**
|
|
68
|
-
*
|
|
68
|
+
* slug 最大长度(D6 合流迁入本文件,原权威定义在已删除的 execution/execute-options-mapper.ts)。
|
|
69
|
+
* 历史值 20 偏紧——描述性 slug 如 "audit-structured-output"(23)/ "fix-subagent-wf-tools"(21)
|
|
70
|
+
* 会撞上限,放宽到 35 兼顾「短到能塞进 TUI 标题行」与「容纳合理描述性 kebab-case 名」。
|
|
71
|
+
* 放本文件的原因:约束对象是 AgentCallOpts.description(slug 的源字段,见下方 slug 派生说明),
|
|
72
|
+
* 与字段同文件;worker-message-pump(live record slug 截断)与壳侧 tool schema maxLength 共享引用。
|
|
73
|
+
*/
|
|
74
|
+
export const SLUG_MAX_LENGTH = 35;
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* 单次 agent 调用的任务声明(D6 任务形状合流后的单一形状)。
|
|
78
|
+
*
|
|
79
|
+
* [D6 合流裁决] 本类型 = 原 AgentCallOpts(workflow 调用方声明,18 字段)与原
|
|
80
|
+
* AgentTaskSpec(engine 中立任务声明,已删除)的合流形态,从模型脚本 agent() API
|
|
81
|
+
* 到 EnginePort.run 直达 pi 边界一次映射——SAR 链路上的 ExecuteOptions/AgentTaskSpec
|
|
82
|
+
* 中间态消除(设计 docs/design/subagent-dual-track-convergence.md §3.3 D6 / 终态四)。
|
|
83
|
+
*
|
|
84
|
+
* 终态命名按变化轴裁定为 AgentCallOpts,理由:
|
|
85
|
+
* - 字段演进的首要驱动轴是「调用方要表达的任务语义」(agent() API 是唯一生产写入方,
|
|
86
|
+
* 合流字段中 prompt/description/skill/skillPath/schemaEnv/thinkingLevel 等多数派
|
|
87
|
+
* 已是调用方命名);
|
|
88
|
+
* - 原 AgentTaskSpec 的中立重命名层(task/slug/effort/persona)与调用方命名是
|
|
89
|
+
* 形式同构、语义同构的假差异(prompt≡task、slug=description 截断、effort≡thinkingLevel、
|
|
90
|
+
* persona≡skillPath+appendSystemPrompt 平铺),按「消假差异」原则并入调用方命名;
|
|
91
|
+
* - 持久化兼容反向锁定 prompt 形态:jsonl run 快照的 AgentCall.opts 与 worker 消息
|
|
92
|
+
* opts 均以 prompt 字段落盘,改名会破坏旧快照重水合。
|
|
93
|
+
*
|
|
94
|
+
* 引擎中立字段的并入方式(可选字段,原 AgentTaskSpec 独有字段去向):
|
|
95
|
+
* - graceTurns / conversation / idleTimeoutMs / denyTools / permissionMode:可选并入;
|
|
96
|
+
* - persona.agentRef:裁撤(无生产写入方、无消费者——pi 走 agent 字段解析身份);
|
|
97
|
+
* - requires:裁撤(P4 形状预留、无生产写入方;且并入需 import EngineCapabilities
|
|
98
|
+
* 形成 orchestration↔engine 类型环)。将来能力依赖声明下钻时在本形状上加回。
|
|
69
99
|
*
|
|
70
100
|
* D-12 仅重组执行编排,AgentCallOpts 形状保持兼容。
|
|
71
101
|
*/
|
|
@@ -101,14 +131,20 @@ export interface AgentCallOpts {
|
|
|
101
131
|
*/
|
|
102
132
|
timeoutMs?: number;
|
|
103
133
|
/**
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
134
|
+
* Turn 上限(turn limiter 用)。
|
|
135
|
+
*
|
|
136
|
+
* [预算语义对齐] 未传或 <=0 = 不限 turn;此时也不按 turns 估算 spawn watchdog——
|
|
137
|
+
* 仅当 env XYZ_SUBAGENT_SPAWN_WATCHDOG_MS 设置时才按绝对时限挂 watchdog(见
|
|
138
|
+
* session-runner.resolveSpawnWatchdogMs)。pi 边界直出为 ExecuteOptions.maxTurns
|
|
139
|
+
* → runSpawn(D6 合流后无中间映射层)。
|
|
140
|
+
*/
|
|
111
141
|
maxTurns?: number;
|
|
142
|
+
/**
|
|
143
|
+
* Turn limiter 的宽限轮数(原 AgentTaskSpec.graceTurns 并入):超 maxTurns 后
|
|
144
|
+
* 允许继续的轮数(等待在途工具收尾)。pi 引擎消费;workflow agent() 无写入方,
|
|
145
|
+
* chat 域(ExecuteOptions.graceTurns 同名透传)经 host-task-spec 填充。
|
|
146
|
+
*/
|
|
147
|
+
graceTurns?: number;
|
|
112
148
|
/**
|
|
113
149
|
* Skill name to load (e.g. "code-review"). Resolved to SKILL.md path
|
|
114
150
|
* and injected via --skill flag in the subprocess.
|
|
@@ -129,18 +165,18 @@ export interface AgentCallOpts {
|
|
|
129
165
|
*/
|
|
130
166
|
agent?: string;
|
|
131
167
|
/**
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
*/
|
|
168
|
+
* System prompt injection CONTENT (not file paths).
|
|
169
|
+
* Set by agent-opts-resolver: schema structured-output instruction string.
|
|
170
|
+
* Agent systemPrompt is NOT included here (handled by resolveIdentity/agentConfig).
|
|
171
|
+
* pi 边界直出为 ExecuteOptions.appendSystemPrompt(同名同义透传,D6 合流后无中间映射层)。
|
|
172
|
+
*/
|
|
138
173
|
appendSystemPrompt?: string[];
|
|
139
174
|
/**
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
175
|
+
* Schema JSON for PI_WORKFLOW_SCHEMA env var.
|
|
176
|
+
* Set by agent-opts-resolver when opts.schema is present (值 = stringifySchemaCached
|
|
177
|
+
* compact,与 schema 派生等值); passed as env var to activate the structured-output
|
|
178
|
+
* tool + hook. pi 边界直出时 schema 派生优先、本字段兜底(解耦形态通道,生产不可达)。
|
|
179
|
+
*/
|
|
144
180
|
schemaEnv?: string;
|
|
145
181
|
/**
|
|
146
182
|
* Per-call 工作目录(ADR-029 决策 1)。传给 child_process.spawn 的 cwd option。
|
|
@@ -159,11 +195,36 @@ export interface AgentCallOpts {
|
|
|
159
195
|
* agent() → execute-agent-call → SAR 路由层。
|
|
160
196
|
*/
|
|
161
197
|
engine?: string;
|
|
162
|
-
/** Filesystem isolation: when true, creates a new git worktree for the agent. Independent of fork.
|
|
163
|
-
|
|
198
|
+
/** Filesystem isolation: when true, creates a new git worktree for the agent. Independent of fork.
|
|
199
|
+
* [D6 合流] 类型扩展为 boolean | WorktreeHandle(原 AgentTaskSpec.worktree 的超集)——
|
|
200
|
+
* WorktreeHandle 形态仅在 chat 域(复用外部已创建的 worktree)出现,workflow agent()
|
|
201
|
+
* 恒传 boolean。 */
|
|
202
|
+
worktree?: boolean | WorktreeHandle;
|
|
164
203
|
/** When true, agent() resolves {value, sessionFile, worktreePath, error} instead of a bare value.
|
|
165
|
-
* Worker-layer flag only — not
|
|
204
|
+
* Worker-layer flag only — not consumed by any engine (dropped at the pi boundary). */
|
|
166
205
|
returnMeta?: boolean;
|
|
206
|
+
/**
|
|
207
|
+
* 可持续对话模式(原 AgentTaskSpec.conversation 并入):true = record 标记 chatMode,
|
|
208
|
+
* 轮次完成进 idle 态等待 message 续聊。chat 域(ExecuteOptions.conversation 同名)经
|
|
209
|
+
* host-task-spec 填充;workflow agent() 无写入方。
|
|
210
|
+
*/
|
|
211
|
+
conversation?: boolean;
|
|
212
|
+
/**
|
|
213
|
+
* 空闲超时毫秒数(原 AgentTaskSpec.idleTimeoutMs 并入,仅 conversation 模式有意义)。
|
|
214
|
+
* 优先级:参数 > env XYZ_SUBAGENT_IDLE_TIMEOUT_MS > 默认 300000ms;显式 0/负 = 禁用
|
|
215
|
+
* idle GC。chat 域经 host-task-spec 填充。
|
|
216
|
+
*/
|
|
217
|
+
idleTimeoutMs?: number;
|
|
218
|
+
/**
|
|
219
|
+
* 工具 denylist(原 AgentTaskSpec.denyTools 并入,中立新增面):各引擎做语法映射
|
|
220
|
+
* (zcode buildZcodeArgv 消费;pi 链路暂无对应面)。无 workflow 写入方,预留形状。
|
|
221
|
+
*/
|
|
222
|
+
denyTools?: string[];
|
|
223
|
+
/**
|
|
224
|
+
* 中立权限模式(原 AgentTaskSpec.permissionMode 并入,预留形状):映射按各引擎
|
|
225
|
+
* capabilities.permissionMode。无生产写入方/消费者。
|
|
226
|
+
*/
|
|
227
|
+
permissionMode?: string;
|
|
167
228
|
}
|
|
168
229
|
|
|
169
230
|
/**
|
|
@@ -189,6 +250,24 @@ export interface ToolCallEntry {
|
|
|
189
250
|
input: string;
|
|
190
251
|
}
|
|
191
252
|
|
|
253
|
+
/**
|
|
254
|
+
* 失败分诊结构化标签(D5-③,r1 MF4 钉正语义)。
|
|
255
|
+
*
|
|
256
|
+
* - stale_context:pi session context 被 compact/cancel/替换——重试无意义(同 call
|
|
257
|
+
* 再次失败),不重试。
|
|
258
|
+
* - schema_deterministic:确定性 schema 失败(SO tool 从未调用 / gate 终止 /
|
|
259
|
+
* 不可满足 schema)——同 schema 重试必同结果,不重试。
|
|
260
|
+
* - unknown:其余一切失败(瞬态 provider 错误、spawn 失败等)——**默认可重试**。
|
|
261
|
+
*
|
|
262
|
+
* **语义守恒(最高优先约束)**:unknown(含字段缺省)= 可重试——保持收敛前的
|
|
263
|
+
* 默认重试语义;仅 stale_context 与 schema_deterministic 两态维持不重试特判。
|
|
264
|
+
* 词表归属(产出侧单点识别):stale_context / schema_deterministic 的识别词表
|
|
265
|
+
* (stale 词表与确定性 schema 失败标记前缀)保留在产出侧
|
|
266
|
+
* execution/engine/engines/pi/output-collector.ts 包内——词表漂移的失效模式是
|
|
267
|
+
* failureKind=unknown → 保守重试(安全默认),不再是静默漏诊。
|
|
268
|
+
*/
|
|
269
|
+
export type AgentFailureKind = "stale_context" | "schema_deterministic" | "unknown";
|
|
270
|
+
|
|
192
271
|
/**
|
|
193
272
|
* 单次 agent 调用的结果(统一形态)。
|
|
194
273
|
*
|
|
@@ -199,6 +278,16 @@ export interface AgentResult {
|
|
|
199
278
|
/** Raw text output from the agent. */
|
|
200
279
|
content: string;
|
|
201
280
|
/**
|
|
281
|
+
* [D5-③] 失败分诊结构化标签(AgentFailureKind)。产出侧唯一识别点 =
|
|
282
|
+
* execution/engine/engines/pi/output-collector.ts(collectResult 对最终 error
|
|
283
|
+
* 分类后写入,经 agent-result-mapper / AgentOutcome 透传到本形态);消费侧
|
|
284
|
+
* execute-agent-call 读本字段分诊,不再扫 error 文案子串。
|
|
285
|
+
*
|
|
286
|
+
* 仅在 error !== undefined 时有意义(成功时缺省);缺省视为 unknown = 可重试
|
|
287
|
+
* (语义守恒,见 AgentFailureKind)。
|
|
288
|
+
*/
|
|
289
|
+
failureKind?: AgentFailureKind;
|
|
290
|
+
/**
|
|
202
291
|
* Parsed structured output.
|
|
203
292
|
* Present when `schema` was provided and the output was valid JSON.
|
|
204
293
|
* Source: tool_execution_end.result.details(validated data object)。
|
|
@@ -39,7 +39,7 @@ import { canRunTransition } from "./types.ts";
|
|
|
39
39
|
/**
|
|
40
40
|
* 聚合根级 meta(非 RunState 的一部分,不随 trace 持久化到 worker JSONL)。
|
|
41
41
|
*
|
|
42
|
-
* workerErrorCount/scriptErrorCount 跨 runtime 存活(C.5:
|
|
42
|
+
* workerErrorCount/scriptErrorCount 跨 runtime 存活(C.5:worker-message-pump 重试计数载体),
|
|
43
43
|
* 因为 retry 会 replaceRuntime,但计数是 run 级而非 runtime 级。
|
|
44
44
|
*/
|
|
45
45
|
export interface WorkflowRunMeta {
|