@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
|
@@ -29,6 +29,13 @@ import type { AgentCallOpts, AgentResult } from "../../orchestration/models/type
|
|
|
29
29
|
import { ModelConfigService, setModelConfigService } from "../model-config-service.ts";
|
|
30
30
|
import type { ModelInfo, ModelRegistryLike } from "../model-resolver.ts";
|
|
31
31
|
import { replayJournal } from "../engine/common/event-journal.ts";
|
|
32
|
+
import { clearEngines, registerEngine } from "../engine/registry.ts";
|
|
33
|
+
import type { EnginePort, RunContext } from "../engine/port.ts";
|
|
34
|
+
import type {
|
|
35
|
+
AgentOutcome,
|
|
36
|
+
EngineCapabilities,
|
|
37
|
+
ProbeReport,
|
|
38
|
+
} from "../engine/types.ts";
|
|
32
39
|
import type { SubprocessAgentRunnerDeps } from "../subprocess-agent-runner.ts";
|
|
33
40
|
import type { SubagentService } from "../subagent-service.ts";
|
|
34
41
|
import { SubprocessAgentRunner } from "../subprocess-agent-runner.ts";
|
|
@@ -48,9 +55,41 @@ function makeMockResult(overrides: Partial<AgentResult> = {}): AgentResult {
|
|
|
48
55
|
};
|
|
49
56
|
}
|
|
50
57
|
|
|
58
|
+
/** 协议替身的引擎内「任务声明 → 执行选项」映射(原 core PiEngine
|
|
59
|
+
* agentCallToExecuteOptions 的最小同构还原——[W3] 该映射本体已随 inproc pi 引擎目录 迁入
|
|
60
|
+
* pi-subagent-cli 引擎包,此处仅为保留 executeAndAwait 委托断言面)。 */
|
|
61
|
+
function fakeAgentCallToExecuteOptions(task: AgentCallOpts, ctxModel?: ModelInfo): Record<string, unknown> {
|
|
62
|
+
const rawSlug = task.description ?? task.agent ?? "workflow-agent";
|
|
63
|
+
return {
|
|
64
|
+
task: task.prompt,
|
|
65
|
+
slug: rawSlug.length > 35 ? rawSlug.slice(0, 35) : rawSlug,
|
|
66
|
+
agent: task.agent,
|
|
67
|
+
model: task.model,
|
|
68
|
+
thinkingLevel: task.thinkingLevel,
|
|
69
|
+
skillPath: task.skillPath,
|
|
70
|
+
appendSystemPrompt: task.appendSystemPrompt,
|
|
71
|
+
schema: task.schema,
|
|
72
|
+
schemaEnv: task.schemaEnv,
|
|
73
|
+
maxTurns: task.maxTurns,
|
|
74
|
+
graceTurns: task.graceTurns,
|
|
75
|
+
ctxModel,
|
|
76
|
+
fork: task.fork,
|
|
77
|
+
worktree: task.worktree,
|
|
78
|
+
cwd: task.cwd,
|
|
79
|
+
conversation: task.conversation,
|
|
80
|
+
idleTimeoutMs: task.idleTimeoutMs,
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/** 引擎 run 捕获面(T3.19 直传保真断言用:SAR → engine.run 的 task 原样性)。 */
|
|
85
|
+
const engineRunSpy = vi.fn();
|
|
86
|
+
|
|
51
87
|
/** 创建 mock SubagentService(只实现 executeAndAwait)。
|
|
52
|
-
* [D4 聚合连带] SAR 构造器经 asEngineService
|
|
53
|
-
*
|
|
88
|
+
* [D4 聚合连带] SAR 构造器经 asEngineService 显式视图取引擎服务面——fake 的 face
|
|
89
|
+
* 即自身,getter 直接返回 self。
|
|
90
|
+
* [W3 改写] 同步注册「委托式」替身 pi 引擎:run() 还原引擎内 task→ExecuteOptions
|
|
91
|
+
* 映射后委托 mock 的 executeAndAwait(原 inproc PiEngine 的 workflow 分支形态)——
|
|
92
|
+
* resolveHostPiEnginePort 对已注册 port 原样返回,SAR 路由命中替身。 */
|
|
54
93
|
function createMockService(impl?: typeof vi.fn): SubagentService {
|
|
55
94
|
const executeAndAwait = impl ?? vi.fn().mockResolvedValue(makeMockResult());
|
|
56
95
|
// partial mock(仅 executeAndAwait + asEngineService self-引用)——SAR 测试路径
|
|
@@ -58,6 +97,50 @@ function createMockService(impl?: typeof vi.fn): SubagentService {
|
|
|
58
97
|
const partial: { executeAndAwait: typeof executeAndAwait; asEngineService?: unknown } = { executeAndAwait };
|
|
59
98
|
const service = partial as unknown as SubagentService;
|
|
60
99
|
partial.asEngineService = service;
|
|
100
|
+
|
|
101
|
+
const fakePort: EnginePort = {
|
|
102
|
+
id: "pi",
|
|
103
|
+
capabilities: (): EngineCapabilities => ({
|
|
104
|
+
schemaEnforcement: "native",
|
|
105
|
+
steer: "unsupported",
|
|
106
|
+
conversation: "native",
|
|
107
|
+
personaInjection: "flag",
|
|
108
|
+
eventGranularity: "stream",
|
|
109
|
+
sandbox: "emulated",
|
|
110
|
+
sessionRead: "full",
|
|
111
|
+
resume: "native",
|
|
112
|
+
interrupt: "kill-only",
|
|
113
|
+
permissionMode: "native",
|
|
114
|
+
maxTurns: true,
|
|
115
|
+
}),
|
|
116
|
+
probe: async (): Promise<ProbeReport> => ({ ok: true, engineVersion: "fake", checks: [] }),
|
|
117
|
+
run: async (task: AgentCallOpts, ctx: RunContext) => {
|
|
118
|
+
engineRunSpy(task, ctx);
|
|
119
|
+
const wfResult = await executeAndAwait(
|
|
120
|
+
fakeAgentCallToExecuteOptions(task, ctx.ctxModel),
|
|
121
|
+
ctx.signal,
|
|
122
|
+
ctx.onEvent,
|
|
123
|
+
ctx.stream,
|
|
124
|
+
) as { content: string; parsedOutput?: unknown; durationMs?: number; error?: string };
|
|
125
|
+
const outcome: AgentOutcome = {
|
|
126
|
+
content: wfResult.content,
|
|
127
|
+
parsedOutput: wfResult.parsedOutput,
|
|
128
|
+
durationMs: wfResult.durationMs,
|
|
129
|
+
error: wfResult.error,
|
|
130
|
+
engineId: "pi",
|
|
131
|
+
};
|
|
132
|
+
return {
|
|
133
|
+
handle: {
|
|
134
|
+
data: { v: 1, engineId: "pi", sessionRef: {}, poolKey: "shared", adapterVersion: "fake-sar" },
|
|
135
|
+
},
|
|
136
|
+
outcome,
|
|
137
|
+
};
|
|
138
|
+
},
|
|
139
|
+
interact: async () => ({ ok: false, code: "engine_interact_failed", message: "not supported in this test" }),
|
|
140
|
+
read: async () => ({ engineId: "pi", turns: [], source: "outcome-only" }),
|
|
141
|
+
};
|
|
142
|
+
clearEngines();
|
|
143
|
+
registerEngine("pi", () => fakePort);
|
|
61
144
|
return service;
|
|
62
145
|
}
|
|
63
146
|
|
|
@@ -83,6 +166,9 @@ function makeBaseOpts(): AgentCallOpts {
|
|
|
83
166
|
describe("SubprocessAgentRunner (wave-4 delegate)", () => {
|
|
84
167
|
beforeEach(() => {
|
|
85
168
|
configureCore({ dataRoot: () => "/fake-sar-data-root", log: () => {} });
|
|
169
|
+
// [U-2 一致性修复] pi 未注册时 resolveHostPiEnginePort 返回 engine_not_found stub
|
|
170
|
+
// ——替身 pi 引擎在 createMockService 内按测试服务注册([W3] 委托式协议替身)。
|
|
171
|
+
engineRunSpy.mockClear();
|
|
86
172
|
});
|
|
87
173
|
|
|
88
174
|
afterEach(() => {
|
|
@@ -441,7 +527,7 @@ describe("SubprocessAgentRunner (wave-4 delegate)", () => {
|
|
|
441
527
|
const workflowOnEvent = vi.fn();
|
|
442
528
|
await sar.run(makeBaseOpts(), new AbortController().signal, workflowOnEvent);
|
|
443
529
|
|
|
444
|
-
// journal 落在 <dataDir>/
|
|
530
|
+
// journal 落在 <dataDir>/inproc pi 引擎目录/shared/journal-<taskId>.jsonl
|
|
445
531
|
const journalFile = join(dataDir, "engines", "pi", "shared");
|
|
446
532
|
const files = readdirSync(journalFile).filter((f) => f.startsWith("journal-") && f.endsWith(".jsonl"));
|
|
447
533
|
expect(files.length).toBe(1);
|
|
@@ -491,17 +577,14 @@ describe("SubprocessAgentRunner (wave-4 delegate)", () => {
|
|
|
491
577
|
});
|
|
492
578
|
|
|
493
579
|
// ────────────────────────────────────────────────
|
|
494
|
-
// T3.19:
|
|
580
|
+
// T3.19: SAR → engine.run 任务声明直传保真
|
|
581
|
+
// [W3 改写] 「AgentCallOpts → ExecuteOptions 映射点在 PiEngine 边界」随 inproc pi 引擎目录
|
|
582
|
+
// 删除迁入 pi-subagent-cli(引擎包 spawn-args 测试守护);core 侧存留契约 =
|
|
583
|
+
// SAR 对 AgentCallOpts 直传零映射(engine.run 的 task 原样性)。
|
|
495
584
|
// ────────────────────────────────────────────────
|
|
496
|
-
describe("T3.19
|
|
497
|
-
it("prompt
|
|
498
|
-
|
|
499
|
-
const mockService = createMockService(
|
|
500
|
-
vi.fn().mockImplementation((opts: Record<string, unknown>) => {
|
|
501
|
-
capturedOpts = opts;
|
|
502
|
-
return Promise.resolve(makeMockResult());
|
|
503
|
-
}),
|
|
504
|
-
);
|
|
585
|
+
describe("T3.19 直传保真(D6:SAR 直传零映射,任务声明原样到达 engine.run)", () => {
|
|
586
|
+
it("prompt/agent/skillPath/schemaEnv 原样到达 engine.run", async () => {
|
|
587
|
+
const mockService = createMockService();
|
|
505
588
|
const deps: SubprocessAgentRunnerDeps = { subagentService: mockService };
|
|
506
589
|
const sar = new SubprocessAgentRunner(deps);
|
|
507
590
|
|
|
@@ -514,35 +597,24 @@ describe("SubprocessAgentRunner (wave-4 delegate)", () => {
|
|
|
514
597
|
};
|
|
515
598
|
await sar.run(opts, new AbortController().signal);
|
|
516
599
|
|
|
517
|
-
expect(
|
|
518
|
-
|
|
519
|
-
expect(
|
|
520
|
-
expect(
|
|
521
|
-
|
|
522
|
-
expect(
|
|
600
|
+
expect(engineRunSpy).toHaveBeenCalledTimes(1);
|
|
601
|
+
const [task] = engineRunSpy.mock.calls[0] as [AgentCallOpts, unknown];
|
|
602
|
+
expect(task.prompt).toBe("do the thing");
|
|
603
|
+
expect(task.agent).toBe("code-reviewer");
|
|
604
|
+
expect(task.skillPath).toBe("/skills/code-review.md");
|
|
605
|
+
expect(task.schemaEnv).toBe('{"type":"object"}');
|
|
523
606
|
});
|
|
524
607
|
|
|
525
|
-
it("schema
|
|
526
|
-
|
|
527
|
-
const mockService = createMockService(
|
|
528
|
-
vi.fn().mockImplementation((opts: Record<string, unknown>) => {
|
|
529
|
-
capturedOpts = opts;
|
|
530
|
-
return Promise.resolve(makeMockResult());
|
|
531
|
-
}),
|
|
532
|
-
);
|
|
608
|
+
it("schema 原样透传为原始对象", async () => {
|
|
609
|
+
const mockService = createMockService();
|
|
533
610
|
const deps: SubprocessAgentRunnerDeps = { subagentService: mockService };
|
|
534
611
|
const sar = new SubprocessAgentRunner(deps);
|
|
535
612
|
|
|
536
|
-
const
|
|
537
|
-
|
|
538
|
-
schema: { type: "object", properties: { name: { type: "string" } } },
|
|
539
|
-
};
|
|
540
|
-
await sar.run(opts, new AbortController().signal);
|
|
613
|
+
const schema = { type: "object", properties: { name: { type: "string" } } };
|
|
614
|
+
await sar.run({ ...makeBaseOpts(), schema }, new AbortController().signal);
|
|
541
615
|
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
properties: { name: { type: "string" } },
|
|
545
|
-
});
|
|
616
|
+
const [task] = engineRunSpy.mock.calls[0] as [AgentCallOpts, unknown];
|
|
617
|
+
expect(task.schema).toEqual(schema);
|
|
546
618
|
});
|
|
547
619
|
});
|
|
548
620
|
|