@zhushanwen/subagent-core 0.5.1 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/chunk-KXVBIVOU.js +16 -0
- package/dist/chunk-T2SYBW3I.js +24 -0
- package/dist/chunk-VURUAGMM.js +2305 -0
- package/dist/{types-Dv4QhSJ_.d.cts → engine-discovery-scan-ocpM8FmI.d.cts} +835 -668
- package/dist/{types-Dv4QhSJ_.d.ts → engine-discovery-scan-ocpM8FmI.d.ts} +835 -668
- package/dist/execution/engine/engine-discovery-scan.cjs +2210 -0
- package/dist/execution/engine/engine-discovery-scan.d.cts +4 -0
- package/dist/execution/engine/engine-discovery-scan.d.ts +4 -0
- package/dist/execution/engine/engine-discovery-scan.js +20 -0
- package/dist/execution/engine/paths.cjs +6 -23
- package/dist/execution/engine/paths.d.cts +1 -8
- package/dist/execution/engine/paths.d.ts +1 -8
- package/dist/execution/engine/paths.js +1 -1
- package/dist/execution/relay-env.cjs +12 -28
- package/dist/execution/relay-env.d.cts +1 -33
- package/dist/execution/relay-env.d.ts +1 -33
- package/dist/execution/relay-env.js +5 -3
- package/dist/index.cjs +14123 -15467
- package/dist/index.d.cts +1179 -1540
- package/dist/index.d.ts +1179 -1540
- package/dist/index.js +7694 -10986
- package/dist.bundle/index.cjs +33485 -0
- package/package.json +20 -26
- package/src/__tests__/record-store-last-line.test.ts +16 -7
- package/src/core/error-message.ts +7 -6
- package/src/core/host-services.ts +8 -2
- package/src/core/notify-ports.ts +17 -2
- package/src/execution/__tests__/agent-registry.test.ts +1 -1
- package/src/execution/__tests__/alive-store.test.ts +1 -1
- package/src/execution/__tests__/chat-engine-routing.test.ts +62 -28
- package/src/execution/__tests__/chat-round-first-round-watchdog.test.ts +255 -0
- package/src/execution/__tests__/collect-budget.test.ts +291 -0
- package/src/execution/__tests__/collect-coordinator-service.test.ts +316 -0
- package/src/execution/__tests__/collect-coordinator.test.ts +371 -0
- package/src/execution/__tests__/collect-mixed-dispatch.test.ts +229 -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 +179 -237
- package/src/execution/__tests__/execute-and-await-worktree.test.ts +0 -2
- package/src/execution/__tests__/execute-nesting.test.ts +20 -13
- package/src/execution/__tests__/explicit-agent-ref-guard.test.ts +21 -34
- package/src/execution/__tests__/finalized-marker.test.ts +1 -1
- package/src/execution/__tests__/gc-timer.test.ts +8 -23
- package/src/execution/__tests__/get-record-for-action-restart.test.ts +20 -10
- package/src/execution/__tests__/helpers/fake-engine-port.ts +187 -0
- package/src/execution/__tests__/helpers/spawn-mock.ts +36 -9
- package/src/execution/__tests__/helpers/subagent-service-mocks.ts +1 -1
- package/src/execution/__tests__/idle-gc.test.ts +200 -0
- package/src/execution/__tests__/lifecycle-predicates.test.ts +26 -21
- package/src/execution/__tests__/manifest-store-tmp-recovery.test.ts +1 -1
- package/src/execution/__tests__/nested-visibility-env-propagation.test.ts +5 -2
- package/src/execution/__tests__/notify-batch.test.ts +500 -0
- package/src/execution/__tests__/notify-ledger.test.ts +27 -0
- package/src/execution/__tests__/reconcile-sweep.test.ts +200 -0
- package/src/execution/__tests__/record-entry-collect.test.ts +102 -0
- package/src/execution/__tests__/record-store.test.ts +60 -6
- package/src/execution/__tests__/recursive-visibility-baseline.test.ts +20 -13
- package/src/execution/__tests__/relay-env.test.ts +12 -1
- package/src/execution/__tests__/round-supervisor.test.ts +293 -0
- package/src/execution/__tests__/session-file-gc.test.ts +1 -1
- package/src/execution/__tests__/session-pending.test.ts +119 -17
- package/src/execution/__tests__/start-collect-guard.test.ts +255 -0
- package/src/execution/__tests__/stream-sink-retirement.test.ts +10 -10
- package/src/execution/__tests__/subagent-actions-core.test.ts +6 -0
- package/src/execution/__tests__/subagent-service-multiproc-guard.test.ts +14 -11
- package/src/execution/__tests__/subagent-service-notify-gate.test.ts +33 -30
- package/src/execution/__tests__/subagent-service-parent-guard.test.ts +2 -9
- package/src/execution/__tests__/subagent-service-recovery-bounds.test.ts +59 -129
- package/src/execution/__tests__/subagent-service.test.ts +2 -2
- package/src/execution/__tests__/subprocess-agent-runner-routing.test.ts +109 -7
- package/src/execution/__tests__/subprocess-agent-runner.test.ts +108 -36
- package/src/execution/__tests__/sync-collect-recovery.test.ts +1102 -0
- package/src/execution/__tests__/tombstone-store.test.ts +1 -1
- package/src/execution/__tests__/workflow-state-root.test.ts +232 -0
- package/src/execution/__tests__/worktree-git-ops.test.ts +1 -1
- 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 +6 -2
- package/src/execution/collect-coordinator.ts +200 -0
- package/src/execution/config.ts +77 -5
- package/src/execution/dialog-queue.ts +6 -73
- package/src/execution/engine/__tests__/common/capability-gate.test.ts +115 -15
- package/src/execution/engine/__tests__/common/errors.test.ts +11 -18
- package/src/execution/engine/__tests__/common/event-journal.test.ts +1 -1
- package/src/execution/engine/__tests__/common/kill-chain.test.ts +7 -0
- package/src/execution/engine/__tests__/common/nesting-guard.test.ts +9 -3
- package/src/execution/engine/__tests__/common/pool-manager.test.ts +2 -2
- package/src/execution/engine/__tests__/common/session-view-service.test.ts +90 -3
- package/src/execution/engine/__tests__/conformance/H9-test-disposition.md +116 -0
- package/src/execution/engine/__tests__/conformance/__fixtures__/engine-protocol/fake-engine-protocol.mjs +377 -0
- package/src/execution/engine/__tests__/conformance/__fixtures__/engine-protocol/recorded.fixture.json +331 -0
- package/src/execution/engine/__tests__/conformance/__fixtures__/engine-protocol/smoke-run.fixture.json +213 -0
- package/src/execution/engine/__tests__/conformance/chat-round-protocol.test.ts +230 -0
- package/src/execution/engine/__tests__/conformance/contract.abort.test.ts +69 -42
- package/src/execution/engine/__tests__/conformance/contract.agent-events.test.ts +4 -81
- package/src/execution/engine/__tests__/conformance/contract.probe.test.ts +67 -44
- package/src/execution/engine/__tests__/conformance/contract.read-degradation.test.ts +82 -55
- package/src/execution/engine/__tests__/conformance/engine-conformance.live.test.ts +133 -70
- package/src/execution/engine/__tests__/conformance/engine-crash.test.ts +143 -0
- package/src/execution/engine/__tests__/conformance/fake-engine-capabilities.ts +19 -0
- package/src/execution/engine/__tests__/conformance/golden-replay.pi.test.ts +8 -3
- package/src/execution/engine/__tests__/conformance/golden-replay.zcode.test.ts +6 -5
- package/src/execution/engine/__tests__/conformance/protocol-blackbox.test.ts +398 -0
- package/src/execution/engine/__tests__/conformance/registry-fork-filter.test.ts +221 -0
- package/src/execution/engine/__tests__/conformance/round-liveness-supervisor.test.ts +302 -0
- package/src/execution/engine/__tests__/conformance/static-spawn-guard.test.ts +58 -0
- package/src/execution/engine/__tests__/engine-discovery-scan.test.ts +558 -0
- package/src/execution/engine/__tests__/host-task-spec.test.ts +45 -0
- package/src/execution/engine/__tests__/model-ref-split.test.ts +74 -0
- package/src/execution/engine/__tests__/registry.test.ts +206 -1
- package/src/execution/engine/__tests__/routing.test.ts +97 -0
- package/src/execution/engine/__tests__/run-failure-worktree-cleanup.test.ts +97 -0
- package/src/execution/engine/client/__tests__/__fixtures__/fake-engine.mjs +294 -0
- package/src/execution/engine/client/__tests__/engine-client.test.ts +516 -0
- package/src/execution/engine/client/__tests__/mirror.test.ts +67 -0
- package/src/execution/engine/client/__tests__/pid-file.test.ts +257 -0
- package/src/execution/engine/client/__tests__/protocol-closure.test.ts +95 -0
- package/src/execution/engine/client/__tests__/remote-engine.test.ts +457 -0
- package/src/execution/engine/client/client-options.ts +103 -0
- package/src/execution/engine/client/engine-client.ts +687 -0
- package/src/execution/engine/client/mirror.ts +167 -0
- package/src/execution/engine/client/pid-file.ts +392 -0
- package/src/execution/engine/client/reaper.ts +95 -0
- package/src/execution/engine/client/remote-engine.ts +441 -0
- package/src/execution/engine/client/reverse-router.ts +255 -0
- package/src/execution/engine/common/capability-gate.ts +109 -22
- package/src/execution/engine/common/errors.ts +9 -25
- package/src/execution/engine/common/event-journal.ts +4 -50
- package/src/execution/engine/common/journal-replay.ts +3 -1
- package/src/execution/engine/common/kill-chain.ts +18 -251
- package/src/execution/engine/common/nesting-guard.ts +18 -114
- package/src/execution/engine/common/pool-manager.ts +4 -0
- package/src/execution/engine/common/session-view-service.ts +56 -84
- package/src/execution/engine/config.ts +151 -0
- package/src/execution/engine/d8-compat.ts +346 -0
- package/src/execution/engine/engine-discovery-roots.ts +107 -0
- package/src/execution/engine/engine-discovery-scan.ts +269 -0
- package/src/execution/engine/engine-discovery.ts +30 -7
- package/src/execution/engine/engine-inspect-package.ts +282 -0
- package/src/execution/engine/engine-manifest.ts +244 -0
- package/src/execution/engine/host/__tests__/host-askuser-endpoint.test.ts +123 -0
- package/src/execution/engine/host/__tests__/host-bridge.test.ts +135 -0
- package/src/execution/engine/host/__tests__/spawned-children.test.ts +73 -0
- package/src/execution/engine/host/host-bridge.ts +150 -0
- package/src/execution/engine/host/host-ui-endpoint.ts +47 -0
- package/src/execution/engine/host/pi-host-binding.ts +91 -0
- package/src/execution/engine/host/spawned-children.ts +139 -0
- package/src/execution/engine/host-task-spec.ts +29 -2
- package/src/execution/engine/model-validation.ts +55 -2
- package/src/execution/engine/paths.ts +16 -41
- package/src/execution/engine/port.ts +48 -2
- package/src/execution/engine/registry.ts +153 -34
- package/src/execution/engine/routing.ts +225 -52
- package/src/execution/engine/types.ts +25 -200
- package/src/execution/execution-record.ts +7 -0
- package/src/execution/finalize-record.ts +40 -11
- package/src/execution/idle-gc.ts +89 -14
- package/src/execution/lifecycle-manager.ts +10 -7
- package/src/execution/lifecycle-predicates.ts +10 -8
- package/src/execution/notifier.ts +234 -25
- package/src/execution/notify-host.ts +21 -1
- package/src/execution/record-entry.ts +16 -0
- package/src/execution/record-store.ts +189 -31
- package/src/execution/relay-env.ts +19 -36
- package/src/execution/round-supervisor/domain.ts +89 -0
- package/src/execution/round-supervisor/index.ts +33 -0
- package/src/execution/round-supervisor/notify-accounting.ts +87 -0
- package/src/execution/round-supervisor/reconcile-sweep.ts +235 -0
- package/src/execution/round-supervisor/service-binding.test.ts +661 -0
- package/src/execution/round-supervisor/service-binding.ts +273 -0
- package/src/execution/round-supervisor/supervisor.ts +426 -0
- package/src/execution/session-pending.ts +68 -74
- package/src/execution/settled-watchdog.ts +39 -0
- package/src/execution/subagent-actions-core.ts +62 -6
- package/src/execution/subagent-service.ts +1161 -406
- package/src/execution/subprocess-agent-runner.ts +16 -8
- package/src/execution/sync-rebuild.ts +87 -0
- package/src/execution/types.ts +104 -117
- package/src/execution/ui-channels.ts +13 -214
- package/src/execution/ui-request-handler-factory.ts +7 -4
- package/src/execution/ui-request-observability.ts +2 -2
- package/src/execution/workflow-state-root.ts +67 -0
- package/src/execution/worktree-git-ops.ts +5 -0
- package/src/execution/worktree-manager.ts +11 -1
- package/src/index.ts +55 -26
- package/src/orchestration/__tests__/config-loader.test.ts +1 -1
- package/src/orchestration/__tests__/execute-agent-call.test.ts +1 -1
- 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__/review-fix-loop-scriptpath-failfast.test.ts +1 -1
- package/src/orchestration/__tests__/script-generate.test.ts +5 -5
- package/src/orchestration/__tests__/skill-discovery.test.ts +2 -2
- package/src/orchestration/__tests__/workflow-files.test.ts +10 -10
- package/src/orchestration/__tests__/workflow-script-registry-impl.test.ts +1 -1
- package/src/orchestration/execute-agent-call.ts +1 -1
- package/src/orchestration/file-run-store.ts +144 -59
- package/src/orchestration/models/types.ts +43 -42
- package/src/shared/__tests__/atomic-write.test.ts +1 -1
- package/src/shared/__tests__/resource-discovery-host-roots.test.ts +5 -5
- package/src/shared/zcode-model-ref.ts +31 -0
- package/dist/chunk-43ONBFZX.js +0 -240
- package/dist/chunk-A4IVZWVX.js +0 -31
- package/dist/chunk-APZY4IME.js +0 -27
- package/dist/chunk-V3VHZ2VX.js +0 -59
- package/dist/execution/engine/engines/zcode/constants.cjs +0 -107
- package/dist/execution/engine/engines/zcode/constants.d.cts +0 -135
- package/dist/execution/engine/engines/zcode/constants.d.ts +0 -135
- package/dist/execution/engine/engines/zcode/constants.js +0 -54
- package/dist/execution/engine/engines/zcode/reader.cjs +0 -276
- package/dist/execution/engine/engines/zcode/reader.d.cts +0 -21
- package/dist/execution/engine/engines/zcode/reader.d.ts +0 -21
- package/dist/execution/engine/engines/zcode/reader.js +0 -9
- package/src/__tests__/append-system-prompt-assembly.test.ts +0 -243
- package/src/__tests__/fr4-get-state-handshake.test.ts +0 -125
- package/src/__tests__/session-runner.test.ts +0 -69
- package/src/execution/__tests__/ask-user-transit-e2e.test.ts +0 -490
- package/src/execution/__tests__/chatmode-first-round-closure-spawn.test.ts +0 -191
- package/src/execution/__tests__/descendant-sweep-guards.test.ts +0 -220
- package/src/execution/__tests__/descendant-sweep.test.ts +0 -269
- package/src/execution/__tests__/engine-model-validation.test.ts +0 -741
- package/src/execution/__tests__/epipe-fallback.test.ts +0 -248
- package/src/execution/__tests__/execution-runtime-face.test.ts +0 -272
- package/src/execution/__tests__/get-state-handshake.test.ts +0 -127
- package/src/execution/__tests__/helpers/session-runner-mocks.ts +0 -113
- package/src/execution/__tests__/keep-alive-no-progress.test.ts +0 -280
- package/src/execution/__tests__/kill-all-escalation.test.ts +0 -196
- package/src/execution/__tests__/max-turns-to-watchdog-ms.test.ts +0 -113
- package/src/execution/__tests__/output-collector.test.ts +0 -469
- package/src/execution/__tests__/pi-invocation.test.ts +0 -134
- package/src/execution/__tests__/recursive-visibility-env.test.ts +0 -149
- package/src/execution/__tests__/rpc-mode.test.ts +0 -89
- package/src/execution/__tests__/run-and-finalize-anchoring.test.ts +0 -387
- package/src/execution/__tests__/run-and-finalize-chatmode.test.ts +0 -277
- package/src/execution/__tests__/run-spawn-chatmode-settled.test.ts +0 -254
- package/src/execution/__tests__/run-spawn-edges.test.ts +0 -1079
- package/src/execution/__tests__/run-spawn-integration.test.ts +0 -933
- package/src/execution/__tests__/run-spawn-resume.test.ts +0 -322
- package/src/execution/__tests__/run-spawn-rpc-mode.test.ts +0 -196
- package/src/execution/__tests__/run-spawn-stdout-callback-throw.test.ts +0 -207
- package/src/execution/__tests__/service-kill-escalation.test.ts +0 -91
- package/src/execution/__tests__/session-runner-branch-cache-lru.test.ts +0 -110
- package/src/execution/__tests__/session-runner-close-prune.test.ts +0 -181
- package/src/execution/__tests__/session-runner-dispatch.test.ts +0 -489
- package/src/execution/__tests__/session-runner-epipe.test.ts +0 -179
- package/src/execution/__tests__/session-runner-heartbeat-idle-fallback.test.ts +0 -227
- package/src/execution/__tests__/session-runner-lifecycle-helpers.test.ts +0 -290
- package/src/execution/__tests__/session-runner-schema-env.test.ts +0 -352
- package/src/execution/__tests__/settled-watchdog.test.ts +0 -524
- package/src/execution/__tests__/spawn-args.test.ts +0 -446
- package/src/execution/__tests__/spawn-event-adapter-rpc.test.ts +0 -192
- package/src/execution/__tests__/spawn-event-adapter.test.ts +0 -167
- package/src/execution/__tests__/spawn-worktree-guidance.test.ts +0 -208
- package/src/execution/__tests__/spawned-children.test.ts +0 -236
- package/src/execution/__tests__/start-sync-model-guard.test.ts +0 -150
- package/src/execution/__tests__/stdin-writer.test.ts +0 -464
- package/src/execution/__tests__/subagent-service-message-close.test.ts +0 -693
- package/src/execution/__tests__/temp-prompt.test.ts +0 -53
- package/src/execution/__tests__/timeout-integration.test.ts +0 -616
- package/src/execution/__tests__/turn-limiter-semantics.test.ts +0 -194
- package/src/execution/__tests__/turn-limiter.test.ts +0 -65
- package/src/execution/__tests__/ui-request-handler.test.ts +0 -205
- package/src/execution/__tests__/ui-request-queue.test.ts +0 -298
- package/src/execution/__tests__/worktree-pid-registration.integration.test.ts +0 -230
- package/src/execution/engine/__tests__/common/schema-emulation.test.ts +0 -128
- package/src/execution/engine/__tests__/common/session-view-service-zcode-dbpath.test.ts +0 -149
- package/src/execution/engine/__tests__/conformance/__fixtures__/pi-golden-events.json +0 -28
- package/src/execution/engine/__tests__/conformance/zcode-appserver-harness.ts +0 -128
- package/src/execution/engine/__tests__/paths.test.ts +0 -39
- package/src/execution/engine/common/schema-emulation.ts +0 -189
- package/src/execution/engine/common/session-view-projection.ts +0 -51
- package/src/execution/engine/engines/pi/__tests__/pi-engine.test.ts +0 -615
- package/src/execution/engine/engines/pi/__tests__/reader.test.ts +0 -155
- package/src/execution/engine/engines/pi/__tests__/spawn-opts-direct.test.ts +0 -257
- package/src/execution/engine/engines/pi/argv-mirror.ts +0 -135
- package/src/execution/engine/engines/pi/get-state-handshake.ts +0 -179
- package/src/execution/engine/engines/pi/output-collector.ts +0 -317
- package/src/execution/engine/engines/pi/pi-engine.ts +0 -811
- package/src/execution/engine/engines/pi/pi-invocation.ts +0 -120
- package/src/execution/engine/engines/pi/reader.ts +0 -59
- package/src/execution/engine/engines/pi/registration.ts +0 -37
- package/src/execution/engine/engines/pi/session-runner.ts +0 -2840
- package/src/execution/engine/engines/pi/spawn-event-adapter.ts +0 -404
- package/src/execution/engine/engines/pi/stdin-writer.ts +0 -199
- package/src/execution/engine/engines/pi/temp-prompt.ts +0 -62
- package/src/execution/engine/engines/pi/turn-limiter.ts +0 -102
- package/src/execution/engine/engines/zcode/__tests__/__fixtures__/fake-appserver.mjs +0 -301
- package/src/execution/engine/engines/zcode/__tests__/__fixtures__/zcode-golden-appserver.json +0 -36
- package/src/execution/engine/engines/zcode/__tests__/appserver-launcher.test.ts +0 -321
- package/src/execution/engine/engines/zcode/__tests__/connection.test.ts +0 -473
- package/src/execution/engine/engines/zcode/__tests__/parser.test.ts +0 -43
- package/src/execution/engine/engines/zcode/__tests__/preparer.test.ts +0 -124
- package/src/execution/engine/engines/zcode/__tests__/reader.test.ts +0 -210
- package/src/execution/engine/engines/zcode/__tests__/registration.test.ts +0 -71
- package/src/execution/engine/engines/zcode/__tests__/session-channel-dispose-harvest.test.ts +0 -247
- package/src/execution/engine/engines/zcode/__tests__/session-channel-turn-timers.test.ts +0 -451
- package/src/execution/engine/engines/zcode/__tests__/session-channel.test.ts +0 -792
- package/src/execution/engine/engines/zcode/__tests__/zcode-engine-appserver.test.ts +0 -782
- package/src/execution/engine/engines/zcode/__tests__/zcode-engine-degrade.test.ts +0 -168
- package/src/execution/engine/engines/zcode/__tests__/zcode-engine-dispose.test.ts +0 -210
- package/src/execution/engine/engines/zcode/__tests__/zcode-engine-retry.test.ts +0 -353
- package/src/execution/engine/engines/zcode/__tests__/zcode-engine-status.test.ts +0 -282
- package/src/execution/engine/engines/zcode/__tests__/zcode-engine-timeout.test.ts +0 -372
- package/src/execution/engine/engines/zcode/__tests__/zcode-engine.live.test.ts +0 -145
- package/src/execution/engine/engines/zcode/appserver-launcher.ts +0 -167
- package/src/execution/engine/engines/zcode/connection.ts +0 -598
- package/src/execution/engine/engines/zcode/constants.ts +0 -176
- package/src/execution/engine/engines/zcode/golden-sample.ts +0 -47
- package/src/execution/engine/engines/zcode/parser.ts +0 -102
- package/src/execution/engine/engines/zcode/preparer.ts +0 -235
- package/src/execution/engine/engines/zcode/reader.ts +0 -381
- package/src/execution/engine/engines/zcode/registration.ts +0 -37
- package/src/execution/engine/engines/zcode/session-channel.ts +0 -968
- package/src/execution/engine/engines/zcode/zcode-engine.ts +0 -1431
- package/src/execution/round-settlement.ts +0 -93
- package/src/execution/ui-request-queue.ts +0 -215
- package/src/shared/schema-env.ts +0 -44
|
@@ -30,7 +30,10 @@ import type { AgentEvent } from "../shared/agent-event.ts";
|
|
|
30
30
|
import { assertTaskShapeSupported } from "./engine/common/capability-gate.ts";
|
|
31
31
|
import { HOST_TIMEOUT_ABORT_REASON } from "./engine/common/kill-chain.ts";
|
|
32
32
|
import { JOURNAL_INITIAL_POOL_KEY, wireEventJournal } from "./engine/common/journal-wiring.ts";
|
|
33
|
-
|
|
33
|
+
// [W6 R1 MF-5] pi EnginePort 解析改经 host 公共面(engine/host/pi-host-binding.ts):
|
|
34
|
+
// registry cli 形态经 descriptor 路由(W3 双模 getEngine),inproc/未注册回落 per-session
|
|
35
|
+
// DI 直构(行为与改线前 createPiEngine 逐点一致)。
|
|
36
|
+
import { resolveHostPiEnginePort } from "./engine/host/pi-host-binding.ts";
|
|
34
37
|
import type { EnginePort, RunContext } from "./engine/port.ts";
|
|
35
38
|
import { validateModelForEngine } from "./engine/model-validation.ts";
|
|
36
39
|
import { routeEngineForHost, type EngineRouteResult, type EngineRoutingInput } from "./engine/routing.ts";
|
|
@@ -39,7 +42,9 @@ import type { AgentOutcome } from "./engine/types.ts";
|
|
|
39
42
|
import { getModelConfigService } from "./model-config-service.ts";
|
|
40
43
|
import type { ModelInfo } from "./model-resolver.ts";
|
|
41
44
|
import { modelRefFromVerified } from "../shared/model-ref";
|
|
42
|
-
|
|
45
|
+
// [W6 R1 MF-5] 子进程注册改经 spawnedChildren 状态镜像公共面(engine/host/
|
|
46
|
+
// spawned-children.ts——镜像 + inproc 过渡委托,不再深路径 import inproc pi 引擎目录)。
|
|
47
|
+
import { registerSpawnedChildForRecord } from "./engine/host/spawned-children.ts";
|
|
43
48
|
import type { SubagentStream } from "./stream-sink.ts";
|
|
44
49
|
import type { SubagentService } from "./subagent-service.ts";
|
|
45
50
|
import { toErrorMessage } from "../core/error-message.ts";
|
|
@@ -95,7 +100,8 @@ export class SubprocessAgentRunner implements AgentRunner {
|
|
|
95
100
|
this.subagentService = deps.subagentService;
|
|
96
101
|
this.ctxModel = deps.ctxModel;
|
|
97
102
|
// [D4 聚合连带] 经 asEngineService 显式视图适配(原结构化直绑依赖查询面 public)。
|
|
98
|
-
|
|
103
|
+
// [W6] 解析经 host 公共面(descriptor 路由 / inproc DI,见 pi-host-binding 注释)。
|
|
104
|
+
this.piEngine = resolveHostPiEnginePort(() => this.subagentService.asEngineService);
|
|
99
105
|
}
|
|
100
106
|
|
|
101
107
|
/**
|
|
@@ -138,10 +144,12 @@ export class SubprocessAgentRunner implements AgentRunner {
|
|
|
138
144
|
|
|
139
145
|
// ── P4 路由(D3-② 单点:routeEngineForHost)+ D3-④ 预检 ──
|
|
140
146
|
// 路由在最前——引擎身份决定 journal 路径与后续一切执行面。pi 快路径同步短路
|
|
141
|
-
//(routed 非 Promise
|
|
142
|
-
//
|
|
143
|
-
//
|
|
144
|
-
//
|
|
147
|
+
//(routed 非 Promise,零微任务)——首个 await 前完成**路由决策**(engine id 已定,
|
|
148
|
+
// A2 观测点);其后的执行经进程边界(cli 形态 spawn + 握手 + 帧往返必经 await),
|
|
149
|
+
// 旧「run 内首个 await 前已触达 executeAndAwait」时序契约由引擎协议化设计
|
|
150
|
+
// §3.5.3 作废放宽。路由失败(未注册 id / probe 失败 + strict/守卫)与预检命中
|
|
151
|
+
//(capabilities 驱动,含 worktree——workflow 域漏拦缺口修复)一并按「不 reject」
|
|
152
|
+
// 契约转 result.error。
|
|
145
153
|
let route: EngineRouteResult;
|
|
146
154
|
try {
|
|
147
155
|
const routed = routeEngineForHost({
|
|
@@ -227,7 +235,7 @@ export class SubprocessAgentRunner implements AgentRunner {
|
|
|
227
235
|
const { handle, outcome } = await route.engine.run(
|
|
228
236
|
// [D6 合流] opts 直传——AgentCallOpts 即 EnginePort 任务形状(缺省路径零映射;
|
|
229
237
|
// pi 边界一次直出由 PiEngine.agentCallToExecuteOptions 承担,逐字段等值由
|
|
230
|
-
//
|
|
238
|
+
// inproc pi 引擎目录/__tests__/spawn-opts-direct.test.ts 对照表锁定)
|
|
231
239
|
opts,
|
|
232
240
|
runCtx,
|
|
233
241
|
);
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
// src/execution/sync-rebuild.ts
|
|
2
|
+
//
|
|
3
|
+
// [E1 恢复批语义修复] sync 批崩溃恢复(E1)与批闭合 flush(S11 兜底)的两条
|
|
4
|
+
// BgNotifyRecord/SubagentRecord 映射,从 subagent-service 拆出(D4 按变化轴拆分:
|
|
5
|
+
// 改恢复批的通知语义 / 落标数据源形态,只改本文件)。两函数均纯映射——零 service/
|
|
6
|
+
// store 依赖,rootSessionId 由调用方注入。
|
|
7
|
+
|
|
8
|
+
import { deriveOutcome } from "./execution-record.ts";
|
|
9
|
+
import type { BgNotifyRecord } from "./notifier.ts";
|
|
10
|
+
import type { SubagentRecord } from "./types.ts";
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* E1 末条 entry 终态快照 → BgNotifyRecord(补发成员;sync 仅 one-shot,round/
|
|
14
|
+
* sessionFile 不透传——与 route() 缓冲快照的 one-shot 形态对齐)。
|
|
15
|
+
*
|
|
16
|
+
* [E1 恢复批语义修复] status/outcome/patchFile 三点对齐 notify-host toNotifyRecord
|
|
17
|
+
* 的映射(正常 flush 路径对同一成员的补发形态),不再直通 rec.status:
|
|
18
|
+
* - status:one-shot 成功成员崩溃时末条 entry 恒为 running+resumable(SP-5 轮终
|
|
19
|
+
* 形态,resumable 豁免正据此放行其入批)——直通会让补发记录仍是 running 形态:
|
|
20
|
+
* buildBatchLlmContent 批头只统计 closed 成员(全员成功的恢复批显示
|
|
21
|
+
* 「0 finished, 0 failed, 0 cancelled」),条目文案落「finished a round」
|
|
22
|
+
* (对话轮次语义)。同 toNotifyRecord:closed 或非 chatMode → "closed"(仅
|
|
23
|
+
* chatMode 轮次形态保持 running——sync 成员恒 one-shot,此分支为防御完整性)。
|
|
24
|
+
* - outcome:closed 状态物化(单一权威 deriveOutcome)——resumable 成员末条未
|
|
25
|
+
* 终态化,closedReason 缺省与正常 flush 路径同形,无 error 即 completed、有
|
|
26
|
+
* error 即 failed;notifier.notifyBatch 投影边界的 `??` 兜底对此幂等。
|
|
27
|
+
* - patchFile:透传(依赖 rebuildEntryRecord 的同名投影)——worktree one-shot
|
|
28
|
+
* 成员的 git-apply 回收指针只在 closed+completed 分支文案携带(running 分支
|
|
29
|
+
* 不含),正常 flush 路径经 toNotifyRecord 特意携带,恢复批不得缺失。
|
|
30
|
+
*/
|
|
31
|
+
export function syncRebuildToNotifyMember(rec: SubagentRecord): BgNotifyRecord {
|
|
32
|
+
const status: BgNotifyRecord["status"] =
|
|
33
|
+
rec.status === "closed" || !rec.chatMode ? "closed" : "running";
|
|
34
|
+
return {
|
|
35
|
+
id: rec.id,
|
|
36
|
+
status,
|
|
37
|
+
closedReason: rec.closedReason,
|
|
38
|
+
outcome: status === "closed" ? deriveOutcome(rec.closedReason, rec.error) : undefined,
|
|
39
|
+
agent: rec.agent,
|
|
40
|
+
model: rec.model,
|
|
41
|
+
result: rec.result,
|
|
42
|
+
error: rec.error,
|
|
43
|
+
startedAt: rec.startedAt,
|
|
44
|
+
endedAt: rec.endedAt,
|
|
45
|
+
patchFile: rec.patchFile,
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* [S11] getFullRecord miss 成员的缓冲快照兜底 → 最小 SubagentRecord(batchFinalized
|
|
51
|
+
* 落标数据源)。getFullRecord 不可达(子 session 文件缺失/已 GC)时,缓冲的
|
|
52
|
+
* BgNotifyRecord 是该成员唯一残存数据。最小形态只保标记链路必需字段:
|
|
53
|
+
* id/agent/task/startedAt 是 rebuildEntryRecord 的解析门槛(缺 task 的 entry 会被
|
|
54
|
+
* E1 扫描判损坏跳过——标记失效方向,task 占位空串保 entry 可解析);终态字段
|
|
55
|
+
* (closedReason/result/error/endedAt/model/patchFile)自缓冲快照如实投影;
|
|
56
|
+
* rootSessionId 取当前 session 根(E1 候选过滤的归属口径)。
|
|
57
|
+
*/
|
|
58
|
+
export function bufferedMemberFallbackRecord(
|
|
59
|
+
m: BgNotifyRecord,
|
|
60
|
+
rootSessionId: string | undefined,
|
|
61
|
+
): SubagentRecord {
|
|
62
|
+
return {
|
|
63
|
+
id: m.id,
|
|
64
|
+
agent: m.agent,
|
|
65
|
+
task: "",
|
|
66
|
+
slug: "",
|
|
67
|
+
status: "closed",
|
|
68
|
+
closedReason: m.closedReason,
|
|
69
|
+
mode: "background",
|
|
70
|
+
startedAt: m.startedAt,
|
|
71
|
+
rootSessionId,
|
|
72
|
+
parentRecordId: undefined,
|
|
73
|
+
depth: 0,
|
|
74
|
+
endedAt: m.endedAt,
|
|
75
|
+
turns: 0,
|
|
76
|
+
totalTokens: 0,
|
|
77
|
+
model: m.model ?? "",
|
|
78
|
+
thinkingLevel: undefined,
|
|
79
|
+
eventLog: [],
|
|
80
|
+
displayItems: [],
|
|
81
|
+
result: m.result,
|
|
82
|
+
error: m.error,
|
|
83
|
+
sessionFile: undefined,
|
|
84
|
+
chatMode: false,
|
|
85
|
+
patchFile: m.patchFile,
|
|
86
|
+
};
|
|
87
|
+
}
|
package/src/execution/types.ts
CHANGED
|
@@ -8,6 +8,14 @@
|
|
|
8
8
|
// - TUI 只读 Record/Details 快照,永不持有可变引用
|
|
9
9
|
|
|
10
10
|
import type { GuiRenderResult } from "@xyz-agent/extension-protocol";
|
|
11
|
+
import type {
|
|
12
|
+
AgentUsage,
|
|
13
|
+
AgentUsageTotal,
|
|
14
|
+
ToolCall,
|
|
15
|
+
ToolCallResult,
|
|
16
|
+
Turn,
|
|
17
|
+
WorktreeHandle,
|
|
18
|
+
} from "@zhushanwen/subagent-engine-sdk";
|
|
11
19
|
|
|
12
20
|
import type { AgentFailureKind } from "../orchestration/models/types.ts";
|
|
13
21
|
import type { ModelInfo, ModelRegistryLike } from "./model-resolver.ts";
|
|
@@ -146,47 +154,35 @@ export type ExecutionMode = "background";
|
|
|
146
154
|
// Agent 事件流(Core → Record 的唯一更新驱动)
|
|
147
155
|
// ============================================================
|
|
148
156
|
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
cacheRead: number;
|
|
179
|
-
cacheWrite: number;
|
|
180
|
-
/** 本 message 的成本(USD,来自 SDK usage.cost.total)。可选——无成本数据时缺省。 */
|
|
181
|
-
cost?: number;
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
export interface AgentUsageTotal extends AgentUsage {
|
|
185
|
-
/** 上述四项之和。投影时不再手工求和。 */
|
|
186
|
-
total: number;
|
|
187
|
-
/** 累计成本(USD,来自 SdkEvent.message.usage.cost.total 求和)。无成本数据时为 0。 */
|
|
188
|
-
cost: number;
|
|
189
|
-
}
|
|
157
|
+
// [S4 簇 3 收编] 事件面契约类型单源化(type-only):AgentEvent / AgentUsage /
|
|
158
|
+
// AgentUsageTotal / ToolCallResult / ToolCall / InternalToolCall / Turn 的本地定义
|
|
159
|
+
// 已删除,自 @zhushanwen/subagent-engine-sdk re-export(SDK protocol/contract-types.ts
|
|
160
|
+
// 是类型闭包 SSOT,core 反向 re-export 保上层消费面——import 方路径零改动;
|
|
161
|
+
// shared/agent-event.ts 转发层链条保持)。结构等价由 protocol-closure.test.ts
|
|
162
|
+
// 断言族守卫。
|
|
163
|
+
//
|
|
164
|
+
// AgentEvent 语义锚定(SDK 侧注释指向本处的对照权威源,勿删):
|
|
165
|
+
// - Pi session.subscribe 上报的事件。Runtime 把它喂给 updateFromEvent。
|
|
166
|
+
// - 设计:AgentEvent 携带 updateFromEvent 收口进 record 所需的**全部数据**——
|
|
167
|
+
// tool_end 带 result(供 turn.toolCalls 存完整 ToolCall),无需翻译层旁路累积。
|
|
168
|
+
//
|
|
169
|
+
// ACP 词汇对照(D11 注记级校准,零行为变更;新引擎实现者按本表对齐语义,
|
|
170
|
+
// 详见 docs/architecture/subagent-engine-gui-visibility.md §3.3 D11):
|
|
171
|
+
// text_delta / thinking_delta ↔ ACP content blocks(text / thinking)
|
|
172
|
+
// tool_start / tool_end ↔ ACP tool_call / tool_call_update
|
|
173
|
+
// turn_end / message_end ↔ ACP prompt turn 终态(stop_reason + usage)
|
|
174
|
+
// compaction ↔ ACP session/compaction
|
|
175
|
+
// 本协议以 pi 为语义锚点(D3)——命名不迁移,对照表仅保证未来 AcpEngine 适配器
|
|
176
|
+
// 与跨引擎 trace 映射的翻译成本最低。
|
|
177
|
+
export type {
|
|
178
|
+
AgentEvent,
|
|
179
|
+
AgentUsage,
|
|
180
|
+
AgentUsageTotal,
|
|
181
|
+
InternalToolCall,
|
|
182
|
+
ToolCall,
|
|
183
|
+
ToolCallResult,
|
|
184
|
+
Turn,
|
|
185
|
+
} from "@zhushanwen/subagent-engine-sdk";
|
|
190
186
|
|
|
191
187
|
/**
|
|
192
188
|
* eventLog 条目(getEventLog 派生产出的元素)。所有字段 readonly。
|
|
@@ -249,69 +245,6 @@ export type SdkEvent = {
|
|
|
249
245
|
reason?: string;
|
|
250
246
|
};
|
|
251
247
|
|
|
252
|
-
/** tool 调用结果(tool_execution_end 时累积,含 structured-output 的 details)。 */
|
|
253
|
-
export interface ToolCallResult {
|
|
254
|
-
content?: unknown[];
|
|
255
|
-
details?: unknown;
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
/**
|
|
259
|
-
* tool 调用(导出的纯净数据形状,不含内部状态)。
|
|
260
|
-
*
|
|
261
|
-
* tool_start 到达但 tool_end 未到时,调用为进行中;一旦 tool_end 到达,
|
|
262
|
-
* result/isError 填充完成。对外投影(AgentResult.toolCalls / getAllToolCalls)
|
|
263
|
-
* 一律返回此类型——**不泄漏 running/done/failed 内部状态机**。
|
|
264
|
-
*
|
|
265
|
-
* 进行中状态由 execution-record 内部的 `InternalToolCall`(= ToolCall + _status)承载,
|
|
266
|
-
* 只存在于 record.turns[].toolCalls,跨边界导出时由 getAllToolCalls strip _status。
|
|
267
|
-
*/
|
|
268
|
-
export interface ToolCall {
|
|
269
|
-
toolName: string;
|
|
270
|
-
args?: unknown;
|
|
271
|
-
result?: ToolCallResult;
|
|
272
|
-
isError?: boolean;
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
/**
|
|
276
|
-
* 内部 ToolCall:在 ToolCall 基础上追加 _status 进行中状态标记与 startedTs 时间戳。
|
|
277
|
-
*
|
|
278
|
-
* running = tool_start 已收到但 tool_end 未到;
|
|
279
|
-
* done/failed = tool_end 已到。
|
|
280
|
-
*
|
|
281
|
-
* 仅存在于 ExecutionRecord.turns[].toolCalls(Core 内部可变状态)。
|
|
282
|
-
* 跨边界导出(getAllToolCalls → AgentResult.toolCalls / 持久化)由 getAllToolCalls
|
|
283
|
-
* 映射回 ToolCall(丢弃 _status / startedTs),保证导出形状清洁。
|
|
284
|
-
*/
|
|
285
|
-
export interface InternalToolCall extends ToolCall {
|
|
286
|
-
_status: "running" | "done" | "failed";
|
|
287
|
-
/** tool_start 到达时的墙钟时间戳(Date.now(),ms)。getEventLog 派生 tool 条目 ts 用。 */
|
|
288
|
-
startedTs: number;
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
/**
|
|
292
|
-
* 一个 turn 的完整内容(ExecutionRecord.turns[] 的元素)。
|
|
293
|
-
*
|
|
294
|
-
* 收口设计:text/thinking 流式累积**完整内容**(非 100 字切片),
|
|
295
|
-
* toolCalls 存完整 ToolCall(含 result + _status 内部状态)。turn_end 到达后 closed=true,
|
|
296
|
-
* 下次 text/thinking/tool 时开新 turn。
|
|
297
|
-
*
|
|
298
|
-
* eventLog / currentActivity / result 均从 turns[] 派生,不再独立存储。
|
|
299
|
-
*/
|
|
300
|
-
export interface Turn {
|
|
301
|
-
/** 本 turn assistant 正文(text_delta 流式累积,完整)。 */
|
|
302
|
-
text: string;
|
|
303
|
-
/** 本 turn 推理(thinking_delta 流式累积,完整)。 */
|
|
304
|
-
thinking: string;
|
|
305
|
-
/** 本 turn 工具调用(InternalToolCall:含完整 result + _status 进行中标记)。 */
|
|
306
|
-
toolCalls: InternalToolCall[];
|
|
307
|
-
/** 本 turn message_end 的 token 增量(聚合得 totalUsage)。 */
|
|
308
|
-
usageDelta?: AgentUsage;
|
|
309
|
-
/** turn_end 是否已到达。false=正在进行;true=已闭合,下次内容开新 turn。 */
|
|
310
|
-
closed: boolean;
|
|
311
|
-
/** turn_end 到达时的墙钟时间戳(Date.now(),ms)。getEventLog 派生 turn_end 条目 ts 用。 */
|
|
312
|
-
closedTs?: number;
|
|
313
|
-
}
|
|
314
|
-
|
|
315
248
|
/** 一次 session 执行的完整结果。collectResult 产出,写入 Record.outcome。 */
|
|
316
249
|
export interface AgentResult {
|
|
317
250
|
text: string;
|
|
@@ -341,19 +274,10 @@ export interface AgentResult {
|
|
|
341
274
|
// 本 section 先声明 ExecutionRecord 的组成值对象(WorktreeHandle / AliveMarker /
|
|
342
275
|
// PatchResult 等),ExecutionRecord 本体及其文档注释在 section 末尾。
|
|
343
276
|
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
*/
|
|
349
|
-
export interface WorktreeHandle {
|
|
350
|
-
/** checkout 目录(子 agent 工作目录,tmpdir 下)。 */
|
|
351
|
-
readonly path: string;
|
|
352
|
-
readonly branch: string;
|
|
353
|
-
readonly baseCommit: string;
|
|
354
|
-
/** 主仓库根目录(cleanup/scan 需要,不再靠路径反推)。 */
|
|
355
|
-
readonly mainCwd: string;
|
|
356
|
-
}
|
|
277
|
+
// [S4 簇 3 收编] WorktreeHandle 本地定义已删除,自 SDK re-export(原为结构等价
|
|
278
|
+
// 副本,单源化后 SDK contract-types 是唯一定义点;「仅 worktree:true 时持有、
|
|
279
|
+
// Object.freeze 守卫不可变」的语义注释见消费方 worktree-manager / worktree-git-ops)。
|
|
280
|
+
export type { WorktreeHandle } from "@zhushanwen/subagent-engine-sdk";
|
|
357
281
|
|
|
358
282
|
/** alive marker:子进程存活标记,用于心跳检测和 crash 推断。 */
|
|
359
283
|
export interface AliveMarker {
|
|
@@ -479,6 +403,14 @@ export interface ExecutionRecord {
|
|
|
479
403
|
* 回填(sessionFile 即定位符)。持久化经 subagent-record entry。
|
|
480
404
|
*/
|
|
481
405
|
engineHandle?: { sessionRef: Record<string, string>; journalPath?: string; poolKey: string };
|
|
406
|
+
/**
|
|
407
|
+
* 同步收集模式标记(subagent-sync-collect 设计 §3.1.3,U1 foundation 契约)。
|
|
408
|
+
* 创建时确定不可变;undefined = async(缺省语义,旧记录零迁移)。持久化经
|
|
409
|
+
* subagent-record entry(record-entry.ts 序列化白名单,entry 唯一写点)。
|
|
410
|
+
* 消费方:U2 collectCoordinator 路由(sync→批缓冲)、U5 E1 重建投影。
|
|
411
|
+
* U2 接线点:service.createRecordForMode 从 ExecuteOptions.collect 读入 identity。
|
|
412
|
+
*/
|
|
413
|
+
readonly collectMode?: "sync";
|
|
482
414
|
|
|
483
415
|
// ── 状态(实时更新)──
|
|
484
416
|
status: ExecutionStatus;
|
|
@@ -492,6 +424,13 @@ export interface ExecutionRecord {
|
|
|
492
424
|
* record 无此字段,投影层按 projectOutcome 兜底(closed-legacy 语义)。
|
|
493
425
|
*/
|
|
494
426
|
outcome?: ExecutionOutcome;
|
|
427
|
+
/**
|
|
428
|
+
* 离开批的终局标记(subagent-sync-collect 设计 §3.1.3,U1 foundation 契约)。
|
|
429
|
+
* 两出口统一落标:① 批闭合 flush 写账成功后;② E9 dispose 逐条转 async 写账后
|
|
430
|
+
* (均 appendEntry 持久化,U3/U5 写点)。undefined = 未离开批 / 旧记录零迁移。
|
|
431
|
+
* 消费方:U5 E1 重建扫描只收「collectMode=sync 且无本标记」的成员(防双重通知)。
|
|
432
|
+
*/
|
|
433
|
+
batchFinalized?: boolean;
|
|
495
434
|
/** 完整执行内容,按 turn 组织。createRecord 初始化为 [空 turn]。 */
|
|
496
435
|
turns: Turn[];
|
|
497
436
|
/** turn 计数(= turns.filter(closed).length,冗余存储供投影直接读)。 */
|
|
@@ -676,6 +615,17 @@ export interface ExecuteOptions {
|
|
|
676
615
|
* undefined/false = 一次性模式(默认,行为完全不变)。service.execute 透传到 createRecordForMode。
|
|
677
616
|
*/
|
|
678
617
|
conversation?: boolean;
|
|
618
|
+
/**
|
|
619
|
+
* 同步收集模式(subagent-sync-collect 设计 §3.1.3,U1 foundation 契约)。
|
|
620
|
+
* undefined = config collectSync.default(缺省 "async",新 session 生效)。
|
|
621
|
+
* schema 层枚举限 "async"|"sync";运行时宽收 string 与 engine 字段同风格
|
|
622
|
+
* (非法值 ≠ "sync" 按 async 处理)。
|
|
623
|
+
* "sync" + conversation:true 组合在 startHandler E4 校验即拒
|
|
624
|
+
* (immediate throw,不产生半启动 record)。
|
|
625
|
+
* U2 接线点:service.createRecordForMode 读入 createRecord identity.collectMode
|
|
626
|
+
* (U1 打通类型与 startHandler 透传,record 落点归 U2)。
|
|
627
|
+
*/
|
|
628
|
+
collect?: string;
|
|
679
629
|
/**
|
|
680
630
|
* 空闲超时毫秒数(仅 conversation 模式有意义)。覆盖默认 5min idle timeout。
|
|
681
631
|
* 优先级:参数 > env XYZ_SUBAGENT_IDLE_TIMEOUT_MS > 默认 300000ms。
|
|
@@ -764,6 +714,13 @@ export interface BgResponse {
|
|
|
764
714
|
* 值语义由 U2(execution/notify-ledger.ts)兑现。
|
|
765
715
|
*/
|
|
766
716
|
notifyContract: "ledger+at-least-once";
|
|
717
|
+
/**
|
|
718
|
+
* 同步收集登记回显段(subagent-sync-collect 设计 §3.1.1 交互样例,U1 foundation)。
|
|
719
|
+
* 仅 resolved 模式为 sync 时附带(async 响应字节零变化,G3):mode = 生效模式;
|
|
720
|
+
* pendingSyncCount = 当前未闭合批的 sync 成员总数(含本条;跨轮派发续累不重置,
|
|
721
|
+
* 与 D2 隐式批一致)。
|
|
722
|
+
*/
|
|
723
|
+
collect?: { mode: "sync"; pendingSyncCount: number };
|
|
767
724
|
}
|
|
768
725
|
|
|
769
726
|
/** list 的内层响应(挂在 SubagentToolResult.listResponse)。 */
|
|
@@ -902,12 +859,37 @@ export interface SubagentRecord {
|
|
|
902
859
|
* subagent-engine-history);缺省 = pi(走 JSONL 直读链)。
|
|
903
860
|
*/
|
|
904
861
|
engineHandle?: { sessionRef: Record<string, string>; journalPath?: string; poolKey: string };
|
|
862
|
+
/**
|
|
863
|
+
* 同步收集模式标记(与 ExecutionRecord.collectMode 同源投影/重建,U1 foundation)。
|
|
864
|
+
* 缺省(存量 record)= async 投影,消费方零迁移。
|
|
865
|
+
*/
|
|
866
|
+
collectMode?: "sync";
|
|
867
|
+
/**
|
|
868
|
+
* 离开批终局标记(与 ExecutionRecord.batchFinalized 同源投影/重建,U1 foundation)。
|
|
869
|
+
* 缺省 = 未离开批;U5 E1 重建扫描据此排除已离场成员。
|
|
870
|
+
*/
|
|
871
|
+
batchFinalized?: boolean;
|
|
905
872
|
}
|
|
906
873
|
|
|
907
874
|
// ============================================================
|
|
908
875
|
// 配置(global + session)
|
|
909
876
|
// ============================================================
|
|
910
877
|
|
|
878
|
+
/**
|
|
879
|
+
* 同步收集(sync collect)配置节类型(subagent-sync-collect 设计 §3.1.3,U1 foundation)。
|
|
880
|
+
* 权威默认值在 config.ts DEFAULT_COLLECT_SYNC;坏值 sanitize 回默认不炸启动(E5,
|
|
881
|
+
* 与 maxConcurrent 同判)。类型定义于 types.ts(避免 config → types 反向依赖成环),
|
|
882
|
+
* config.ts re-export。
|
|
883
|
+
*/
|
|
884
|
+
export interface CollectSyncConfig {
|
|
885
|
+
/** start 未显式传 collect 时的缺省模式。新 session 生效(与 engine 配置时机一致)。 */
|
|
886
|
+
default: "async" | "sync";
|
|
887
|
+
/** 批通知单条目结果正文预算(字符):超出截断并接 session_read 指针行。flush 时热读。 */
|
|
888
|
+
perItemChars: number;
|
|
889
|
+
/** 批通知结果正文总量预算(字符):Σ 超限时统一收紧 effectivePerItem(U4 算法)。flush 时热读。 */
|
|
890
|
+
totalChars: number;
|
|
891
|
+
}
|
|
892
|
+
|
|
911
893
|
/**
|
|
912
894
|
* 全局配置(~/.pi/agent/subagents/config.json)。
|
|
913
895
|
*
|
|
@@ -925,6 +907,11 @@ export interface SubagentsGlobalConfig {
|
|
|
925
907
|
defaultEngine?: string;
|
|
926
908
|
/** 引擎路由策略(D9①):strict=true 时一切 probe 失败直接报错(不 fallback)。 */
|
|
927
909
|
engineRouting?: { strict: boolean };
|
|
910
|
+
/**
|
|
911
|
+
* 同步收集配置节(subagent-sync-collect 设计 §3.1.3,U1 foundation)。
|
|
912
|
+
* 整节缺省 = DEFAULT_COLLECT_SYNC(config.ts);逐字段 sanitize 回默认(E5)。
|
|
913
|
+
*/
|
|
914
|
+
collectSync?: CollectSyncConfig;
|
|
928
915
|
}
|
|
929
916
|
|
|
930
917
|
// ============================================================
|