stitchkit 0.132.2 → 0.133.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/CHANGELOG.md +181 -1
- package/dist/agent-executor/acp/v1-connect.d.ts +12 -1
- package/dist/agent-executor/acp/v1-connect.d.ts.map +1 -1
- package/dist/agent-executor/acp/v1-driver.d.ts +3 -1
- package/dist/agent-executor/acp/v1-driver.d.ts.map +1 -1
- package/dist/agent-executor/acp/v1-handlers.d.ts +9 -1
- package/dist/agent-executor/acp/v1-handlers.d.ts.map +1 -1
- package/dist/agent-executor/acp/v1-permission.d.ts +3 -2
- package/dist/agent-executor/acp/v1-permission.d.ts.map +1 -1
- package/dist/agent-executor/acp/v1-probe.d.ts +10 -1
- package/dist/agent-executor/acp/v1-probe.d.ts.map +1 -1
- package/dist/agent-executor/acp/v1-session.d.ts +11 -2
- package/dist/agent-executor/acp/v1-session.d.ts.map +1 -1
- package/dist/agent-executor/acp/v1-turn.d.ts +13 -10
- package/dist/agent-executor/acp/v1-turn.d.ts.map +1 -1
- package/dist/agent-executor/claude/cli-driver.d.ts +6 -0
- package/dist/agent-executor/claude/cli-driver.d.ts.map +1 -1
- package/dist/agent-executor/claude/record-router.d.ts +44 -0
- package/dist/agent-executor/claude/record-router.d.ts.map +1 -0
- package/dist/agent-executor/claude/session.d.ts +2 -0
- package/dist/agent-executor/claude/session.d.ts.map +1 -1
- package/dist/agent-executor/claude-sdk/controls.d.ts +1 -0
- package/dist/agent-executor/claude-sdk/controls.d.ts.map +1 -1
- package/dist/agent-executor/claude-sdk/driver.d.ts +20 -2
- package/dist/agent-executor/claude-sdk/driver.d.ts.map +1 -1
- package/dist/agent-executor/claude-sdk/engine-spawn.d.ts +18 -0
- package/dist/agent-executor/claude-sdk/engine-spawn.d.ts.map +1 -0
- package/dist/agent-executor/claude-sdk/query-loop.d.ts +9 -7
- package/dist/agent-executor/claude-sdk/query-loop.d.ts.map +1 -1
- package/dist/agent-executor/claude-sdk/query-manager.d.ts +42 -0
- package/dist/agent-executor/claude-sdk/query-manager.d.ts.map +1 -0
- package/dist/agent-executor/claude-sdk/query-options.d.ts +4 -1
- package/dist/agent-executor/claude-sdk/query-options.d.ts.map +1 -1
- package/dist/agent-executor/claude-sdk/session.d.ts.map +1 -1
- package/dist/agent-executor/codex/capabilities.d.ts +8 -0
- package/dist/agent-executor/codex/capabilities.d.ts.map +1 -0
- package/dist/agent-executor/codex/connect.d.ts +6 -1
- package/dist/agent-executor/codex/connect.d.ts.map +1 -1
- package/dist/agent-executor/codex/driver.d.ts +10 -0
- package/dist/agent-executor/codex/driver.d.ts.map +1 -1
- package/dist/agent-executor/codex/event-routing.d.ts +23 -1
- package/dist/agent-executor/codex/event-routing.d.ts.map +1 -1
- package/dist/agent-executor/codex/handlers.d.ts +24 -4
- package/dist/agent-executor/codex/handlers.d.ts.map +1 -1
- package/dist/agent-executor/codex/limits.d.ts +17 -0
- package/dist/agent-executor/codex/limits.d.ts.map +1 -1
- package/dist/agent-executor/codex/request-answers.d.ts +23 -3
- package/dist/agent-executor/codex/request-answers.d.ts.map +1 -1
- package/dist/agent-executor/codex/session-bind.d.ts +6 -1
- package/dist/agent-executor/codex/session-bind.d.ts.map +1 -1
- package/dist/agent-executor/codex/session-types.d.ts +5 -1
- package/dist/agent-executor/codex/session-types.d.ts.map +1 -1
- package/dist/agent-executor/codex/session.d.ts.map +1 -1
- package/dist/agent-executor/codex/shared-server.d.ts.map +1 -1
- package/dist/agent-executor/codex/shared-thread.d.ts +7 -7
- package/dist/agent-executor/codex/shared-thread.d.ts.map +1 -1
- package/dist/agent-executor/codex/thread-open.d.ts +12 -3
- package/dist/agent-executor/codex/thread-open.d.ts.map +1 -1
- package/dist/agent-executor/engine-requests.d.ts +42 -0
- package/dist/agent-executor/engine-requests.d.ts.map +1 -1
- package/dist/agent-executor/handoff-schemas.d.ts.map +1 -1
- package/dist/agent-executor/handoff.d.ts.map +1 -1
- package/dist/agent-executor/image-input.d.ts +6 -5
- package/dist/agent-executor/image-input.d.ts.map +1 -1
- package/dist/agent-executor/profile.d.ts +3 -5
- package/dist/agent-executor/profile.d.ts.map +1 -1
- package/dist/agent-executor/session-primitives.d.ts +64 -3
- package/dist/agent-executor/session-primitives.d.ts.map +1 -1
- package/dist/agent-executor/testing/claude-sdk-stubs.d.ts +5 -0
- package/dist/agent-executor/testing/claude-sdk-stubs.d.ts.map +1 -0
- package/dist/agent-executor/testing/conformance-lifecycle.d.ts +11 -0
- package/dist/agent-executor/testing/conformance-lifecycle.d.ts.map +1 -0
- package/dist/agent-executor/testing/conformance-support.d.ts +23 -0
- package/dist/agent-executor/testing/conformance-support.d.ts.map +1 -0
- package/dist/agent-executor/testing/conformance.d.ts +7 -2
- package/dist/agent-executor/testing/conformance.d.ts.map +1 -1
- package/dist/agent-executor/testing/consumer-stubs.d.ts +5 -3
- package/dist/agent-executor/testing/consumer-stubs.d.ts.map +1 -1
- package/dist/agent-executor/testing/fake-codex-app-server.d.ts +5 -1
- package/dist/agent-executor/testing/fake-codex-app-server.d.ts.map +1 -1
- package/dist/agent-executor/testing/replay-driver.d.ts +6 -0
- package/dist/agent-executor/testing/replay-driver.d.ts.map +1 -1
- package/dist/agent-executor/testing/replay-gate.d.ts +4 -1
- package/dist/agent-executor/testing/replay-gate.d.ts.map +1 -1
- package/dist/agent-runtime/deferred-tool-types.d.ts +2 -0
- package/dist/agent-runtime/deferred-tool-types.d.ts.map +1 -1
- package/dist/agent-runtime/deferred-tools.d.ts.map +1 -1
- package/dist/agent-runtime/sql-rows.d.ts +10 -10
- package/dist/agent-runtime/store-conformance-lifecycle.d.ts +20 -20
- package/dist/agent-runtime/store-conformance-support.d.ts +10 -10
- package/dist/agent-runtime/terminal-commit.d.ts +10 -10
- package/dist/browser/client.d.ts.map +1 -1
- package/dist/browser/operation-refusal.d.ts +10 -0
- package/dist/browser/operation-refusal.d.ts.map +1 -0
- package/dist/contract/client-types.d.ts +13 -4
- package/dist/contract/client-types.d.ts.map +1 -1
- package/dist/contract/define-validation.d.ts +6 -0
- package/dist/contract/define-validation.d.ts.map +1 -1
- package/dist/contract/define.d.ts +3 -0
- package/dist/contract/define.d.ts.map +1 -1
- package/dist/contract/errors-factory.d.ts +8 -2
- package/dist/contract/errors-factory.d.ts.map +1 -1
- package/dist/contract/errors.d.ts +9 -0
- package/dist/contract/errors.d.ts.map +1 -1
- package/dist/contract/fingerprint.d.ts +4 -1
- package/dist/contract/fingerprint.d.ts.map +1 -1
- package/dist/contract/operation-refusals.d.ts +51 -0
- package/dist/contract/operation-refusals.d.ts.map +1 -0
- package/dist/contract/tool-options.d.ts +4 -0
- package/dist/contract/tool-options.d.ts.map +1 -1
- package/dist/entrypoints/agent-executor/acp.js +254 -196
- package/dist/entrypoints/agent-executor/claude-sdk.js +467 -294
- package/dist/entrypoints/agent-executor/claude.js +130 -99
- package/dist/entrypoints/agent-executor/codex.js +441 -314
- package/dist/entrypoints/agent-executor/testing/claude-sdk.d.ts +3 -0
- package/dist/entrypoints/agent-executor/testing/claude-sdk.d.ts.map +1 -0
- package/dist/entrypoints/agent-executor/testing/claude-sdk.js +329 -0
- package/dist/entrypoints/agent-executor/testing.d.ts +1 -2
- package/dist/entrypoints/agent-executor/testing.d.ts.map +1 -1
- package/dist/entrypoints/agent-executor/testing.js +413 -667
- package/dist/entrypoints/agent-executor.d.ts +1 -1
- package/dist/entrypoints/agent-executor.d.ts.map +1 -1
- package/dist/entrypoints/agent-executor.js +12 -12
- package/dist/entrypoints/agent-runtime/browser.js +2 -2
- package/dist/entrypoints/agent-runtime/coding-tools.js +3 -3
- package/dist/entrypoints/agent-runtime/harness.js +8 -8
- package/dist/entrypoints/agent-runtime/postgres.js +5 -5
- package/dist/entrypoints/agent-runtime/realtime.js +2 -2
- package/dist/entrypoints/agent-runtime/sandbox.js +3 -3
- package/dist/entrypoints/agent-runtime/sqlite/bun.js +6 -6
- package/dist/entrypoints/agent-runtime/sqlite/node.js +6 -6
- package/dist/entrypoints/agent-runtime/testing.js +5 -5
- package/dist/entrypoints/agent-runtime.js +26 -18
- package/dist/entrypoints/application/grammy.js +1 -1
- package/dist/entrypoints/application.js +2 -2
- package/dist/entrypoints/cli.js +8 -8
- package/dist/entrypoints/contract.d.ts +3 -2
- package/dist/entrypoints/contract.d.ts.map +1 -1
- package/dist/entrypoints/contract.js +6 -4
- package/dist/entrypoints/files/packaging.d.ts +4 -1
- package/dist/entrypoints/files/packaging.d.ts.map +1 -1
- package/dist/entrypoints/files/packaging.js +868 -167
- package/dist/entrypoints/files.js +1 -1
- package/dist/entrypoints/handler.js +7 -7
- package/dist/entrypoints/http.js +2 -2
- package/dist/entrypoints/index.js +10 -8
- package/dist/entrypoints/node.js +11 -11
- package/dist/entrypoints/observability.js +1 -1
- package/dist/entrypoints/process/bootstrap.d.ts +3 -0
- package/dist/entrypoints/process/bootstrap.d.ts.map +1 -0
- package/dist/entrypoints/process/bootstrap.js +16 -0
- package/dist/entrypoints/process.js +7 -7
- package/dist/entrypoints/realtime.js +3 -3
- package/dist/entrypoints/remote.js +8 -7
- package/dist/entrypoints/server.js +30 -14
- package/dist/entrypoints/service-host/macos.js +72 -206
- package/dist/entrypoints/service-host/work.d.ts +15 -0
- package/dist/entrypoints/service-host/work.d.ts.map +1 -0
- package/dist/entrypoints/service-host/work.js +676 -0
- package/dist/entrypoints/service-host.js +146 -536
- package/dist/entrypoints/telegram/screens.js +4 -4
- package/dist/entrypoints/telegram.js +4 -4
- package/dist/entrypoints/testing.d.ts +2 -1
- package/dist/entrypoints/testing.d.ts.map +1 -1
- package/dist/entrypoints/testing.js +27 -8
- package/dist/entrypoints/tools/agent.js +6 -6
- package/dist/entrypoints/tools/connections.js +2 -2
- package/dist/entrypoints/tools/invoker.js +5 -5
- package/dist/entrypoints/tools/mcp.js +8 -6
- package/dist/entrypoints/tools/toolkit.js +11 -9
- package/dist/entrypoints/tools.js +19 -17
- package/dist/entrypoints/tracking/contract.js +1 -1
- package/dist/entrypoints/tracking/performance.js +3 -3
- package/dist/files/client-artifact.d.ts +14 -42
- package/dist/files/client-artifact.d.ts.map +1 -1
- package/dist/files/client-build.d.ts +57 -0
- package/dist/files/client-build.d.ts.map +1 -0
- package/dist/files/client-declarations.d.ts +35 -0
- package/dist/files/client-declarations.d.ts.map +1 -0
- package/dist/files/client-package-contract.d.ts +162 -0
- package/dist/files/client-package-contract.d.ts.map +1 -0
- package/dist/files/client-package-proof.d.ts +38 -0
- package/dist/files/client-package-proof.d.ts.map +1 -0
- package/dist/files/client-package.d.ts +17 -0
- package/dist/files/client-package.d.ts.map +1 -0
- package/dist/files/declaration-specifiers.d.ts +30 -0
- package/dist/files/declaration-specifiers.d.ts.map +1 -0
- package/dist/{index-v759mzed.js → index-02r5sq9p.js} +36 -23
- package/dist/{index-0r15pkjq.js → index-0k1ba0ss.js} +1 -1
- package/dist/{index-znd1b57f.js → index-1dn2wjq6.js} +5 -4
- package/dist/{index-p06z7g7w.js → index-1p8q0yrt.js} +6 -5
- package/dist/{index-wa6h4tz6.js → index-1qwd54n3.js} +6 -5
- package/dist/index-2dzc7mv9.js +174 -0
- package/dist/index-2mz8hj58.js +155 -0
- package/dist/{index-17qgm6xe.js → index-34k82crg.js} +2 -2
- package/dist/index-3mcbr8sx.js +349 -0
- package/dist/{index-ybdq8kk2.js → index-3y2tzhr8.js} +3 -3
- package/dist/{index-fgahdc7s.js → index-5n3a8hd8.js} +5 -3
- package/dist/{index-jb4m241t.js → index-6918kxbf.js} +45 -1
- package/dist/{index-n3bm7zqq.js → index-6kmjcm81.js} +4 -4
- package/dist/{index-akf0xkrm.js → index-78da4g74.js} +1 -1
- package/dist/{index-9pv126eh.js → index-7fjbdga8.js} +7 -1
- package/dist/{index-zhshhxew.js → index-8jf4bt7v.js} +1 -1
- package/dist/{index-p16q492v.js → index-8t9dr41h.js} +18 -5
- package/dist/{index-xq4s9mka.js → index-8yt3rwe7.js} +1 -1
- package/dist/{index-39c2hj6h.js → index-9c76vfxf.js} +7 -3
- package/dist/index-9ft4n9j1.js +432 -0
- package/dist/{index-sd4e5x5j.js → index-9wdrwx3b.js} +8 -7
- package/dist/{index-z114ax5e.js → index-an7vcmwf.js} +49 -2
- package/dist/{index-pzhqydxb.js → index-d04w81fz.js} +1 -1
- package/dist/index-d2drhb9c.js +219 -0
- package/dist/{index-8gmmdz7k.js → index-dacxr7nf.js} +1 -1
- package/dist/{index-dnzxxf8a.js → index-dm6nxkn1.js} +1 -1
- package/dist/index-dxft2mnm.js +42 -0
- package/dist/{index-rxh3qy4x.js → index-fzd477xk.js} +1 -1
- package/dist/{index-xgae0bn7.js → index-g4gstmp1.js} +2 -2
- package/dist/{index-athc412x.js → index-g5fgeb6v.js} +1 -1
- package/dist/{index-z9d74jmb.js → index-gbhj370g.js} +3 -3
- package/dist/{index-3fym4j8n.js → index-gtaaxe9d.js} +1 -1
- package/dist/{index-v59pxmf1.js → index-jpecjm30.js} +2 -2
- package/dist/index-k9g061ma.js +164 -0
- package/dist/{index-669374qc.js → index-ma26mfnt.js} +84 -315
- package/dist/{index-ryxb427v.js → index-msxf2r8x.js} +16 -3
- package/dist/{index-rbd2rq3z.js → index-nr4fhfn4.js} +1 -1
- package/dist/{index-qa2jjb65.js → index-pbekeqzm.js} +1 -1
- package/dist/{index-mkfhpk11.js → index-pq6g1k9t.js} +2 -2
- package/dist/{index-gya4hwh3.js → index-pws5c3x6.js} +21 -1
- package/dist/{index-x2fb37t0.js → index-q427q23r.js} +3 -2
- package/dist/{index-jcrj0b8z.js → index-qggqqja2.js} +39 -2
- package/dist/{index-jxtg307y.js → index-rkjfzs0a.js} +1 -1
- package/dist/{index-5tdc0q43.js → index-rw8ze745.js} +5 -3
- package/dist/index-s43tr4my.js +129 -0
- package/dist/{index-f9p62ean.js → index-stpy56r3.js} +175 -249
- package/dist/index-t5g5rm9n.js +213 -0
- package/dist/{index-z20pdxeb.js → index-tmv3ez1h.js} +3 -3
- package/dist/{index-dcsxj68j.js → index-tqjamnax.js} +1 -1
- package/dist/{index-j15dhkda.js → index-wddcfbng.js} +1 -325
- package/dist/{index-9sfhje6y.js → index-wh70tmpd.js} +24 -234
- package/dist/index-wxjv4sqx.js +82 -0
- package/dist/{index-qhjmmsm2.js → index-x46y9z26.js} +2 -2
- package/dist/{index-nk0cy9g1.js → index-y53cqwke.js} +1 -1
- package/dist/{index-sv5svtq7.js → index-y68gavb5.js} +1 -1
- package/dist/{index-5y7j383h.js → index-yrhw10ef.js} +1 -1
- package/dist/process/bootstrap.d.ts +12 -0
- package/dist/process/bootstrap.d.ts.map +1 -0
- package/dist/process/owner-loss-guard.d.ts +2 -9
- package/dist/process/owner-loss-guard.d.ts.map +1 -1
- package/dist/process/work-root.d.ts +20 -0
- package/dist/process/work-root.d.ts.map +1 -0
- package/dist/server/contract-identity.d.ts.map +1 -1
- package/dist/server/contract-method.d.ts +12 -0
- package/dist/server/contract-method.d.ts.map +1 -1
- package/dist/server/implement.d.ts.map +1 -1
- package/dist/server/openapi.d.ts.map +1 -1
- package/dist/server/types.d.ts +10 -9
- package/dist/server/types.d.ts.map +1 -1
- package/dist/service-host/host-adapter.d.ts +2 -0
- package/dist/service-host/host-adapter.d.ts.map +1 -1
- package/dist/service-host/work/command.d.ts +72 -0
- package/dist/service-host/work/command.d.ts.map +1 -0
- package/dist/service-host/work/errors.d.ts +29 -0
- package/dist/service-host/work/errors.d.ts.map +1 -0
- package/dist/service-host/work/host.d.ts +38 -0
- package/dist/service-host/work/host.d.ts.map +1 -0
- package/dist/service-host/work/launch.d.ts +51 -0
- package/dist/service-host/work/launch.d.ts.map +1 -0
- package/dist/service-host/work/membership.d.ts +51 -0
- package/dist/service-host/work/membership.d.ts.map +1 -0
- package/dist/service-host/work/origin.d.ts +79 -0
- package/dist/service-host/work/origin.d.ts.map +1 -0
- package/dist/service-host/work/owner.d.ts +45 -0
- package/dist/service-host/work/owner.d.ts.map +1 -0
- package/dist/service-host/work/placement.d.ts +55 -0
- package/dist/service-host/work/placement.d.ts.map +1 -0
- package/dist/service-host/work/probe.d.ts +24 -0
- package/dist/service-host/work/probe.d.ts.map +1 -0
- package/dist/service-host/work/scope-command.d.ts +68 -0
- package/dist/service-host/work/scope-command.d.ts.map +1 -0
- package/dist/sync/session.d.ts +4 -1
- package/dist/sync/session.d.ts.map +1 -1
- package/dist/testing/surface-manifest-digest.d.ts +2 -0
- package/dist/testing/surface-manifest-digest.d.ts.map +1 -1
- package/dist/testing/surface-manifest.d.ts +32 -3
- package/dist/testing/surface-manifest.d.ts.map +1 -1
- package/dist/tools/agent.d.ts +2 -0
- package/dist/tools/agent.d.ts.map +1 -1
- package/dist/tools/cli/stream-surface.d.ts.map +1 -1
- package/dist/tools/internal/mcp-projection.d.ts +58 -0
- package/dist/tools/internal/mcp-projection.d.ts.map +1 -0
- package/dist/tools/internal/surface-projector.d.ts +3 -47
- package/dist/tools/internal/surface-projector.d.ts.map +1 -1
- package/dist/tools/invoker.d.ts +2 -0
- package/dist/tools/invoker.d.ts.map +1 -1
- package/dist/tools/manifest.d.ts +2 -0
- package/dist/tools/manifest.d.ts.map +1 -1
- package/dist/tools/mcp/handler.d.ts.map +1 -1
- package/dist/tools/mcp/lazy-discovery.d.ts.map +1 -1
- package/dist/tools/mcp/mount.d.ts +4 -0
- package/dist/tools/mcp/mount.d.ts.map +1 -1
- package/dist/tools/mcp/prepare.d.ts +5 -2
- package/dist/tools/mcp/prepare.d.ts.map +1 -1
- package/dist/tools/mount.d.ts +2 -0
- package/dist/tools/mount.d.ts.map +1 -1
- package/dist/tools/remote.d.ts.map +1 -1
- package/dist/tools/schema/nesting-limit.d.ts +8 -0
- package/dist/tools/schema/nesting-limit.d.ts.map +1 -0
- package/dist/tools/schema/presentation.d.ts +7 -0
- package/dist/tools/schema/presentation.d.ts.map +1 -1
- package/dist/tools/surface.d.ts.map +1 -1
- package/llms/agent-executor-acp.txt +3 -3
- package/llms/agent-executor-claude-sdk.txt +1 -1
- package/llms/agent-executor-claude.txt +1 -1
- package/llms/agent-executor-codex.txt +1 -1
- package/llms/agent-executor-testing-claude-sdk.txt +28 -0
- package/llms/agent-executor-testing.txt +7 -8
- package/llms/agent-executor.txt +27 -4
- package/llms/agent-runtime.txt +1 -1
- package/llms/contract.txt +8 -2
- package/llms/files-packaging.txt +11 -6
- package/llms/process-bootstrap.txt +18 -0
- package/llms/process.2.txt +215 -18
- package/llms/process.txt +130 -92
- package/llms/server.4.txt +49 -1
- package/llms/service-host-work.txt +34 -0
- package/llms/stitchkit.2.txt +31 -0
- package/llms/stitchkit.txt +78 -75
- package/llms/sync.txt +5 -2
- package/llms/testing.txt +1 -0
- package/llms/tools.2.txt +747 -775
- package/llms/tools.3.txt +846 -210
- package/llms/tools.4.txt +226 -0
- package/llms/tools.txt +3 -790
- package/llms/{upgrading-0.128.0-0.132.0.txt → upgrading-0.128.0-0.133.0.txt} +194 -6
- package/llms/upgrading.txt +1 -1
- package/llms-full.txt +746 -135
- package/llms.txt +18 -16
- package/package.json +12 -4
- package/dist/entrypoints/process/owner-loss.d.ts +0 -3
- package/dist/entrypoints/process/owner-loss.d.ts.map +0 -1
- package/dist/entrypoints/process/owner-loss.js +0 -7
- package/llms/process-owner-loss.txt +0 -18
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import"../../index-2rf33y2h.js";
|
|
2
2
|
import {
|
|
3
3
|
ExecutorThreadDispositionSchema2,
|
|
4
|
-
ExecutorErrorKindSchema2
|
|
4
|
+
ExecutorErrorKindSchema2
|
|
5
|
+
} from "../../index-s43tr4my.js";
|
|
6
|
+
import {
|
|
5
7
|
InteractionReplySchema2,
|
|
6
8
|
engineProfile,
|
|
7
9
|
engineEnvironment2,
|
|
@@ -9,17 +11,19 @@ import {
|
|
|
9
11
|
createTurnDeltaChannel,
|
|
10
12
|
offerTurnDelta,
|
|
11
13
|
sessionAbort,
|
|
14
|
+
sessionLiveness,
|
|
12
15
|
stopConnection,
|
|
13
16
|
withEphemeralConnection,
|
|
14
17
|
safeJsonValue,
|
|
15
|
-
|
|
18
|
+
reportObserverError,
|
|
19
|
+
invokeObserver,
|
|
16
20
|
emitStartupPhase
|
|
17
|
-
} from "../../index-
|
|
21
|
+
} from "../../index-stpy56r3.js";
|
|
18
22
|
import"../../index-09f7w2qq.js";
|
|
19
23
|
import {
|
|
20
24
|
NativeCommandError2
|
|
21
|
-
} from "../../index-
|
|
22
|
-
import"../../index-
|
|
25
|
+
} from "../../index-jpecjm30.js";
|
|
26
|
+
import"../../index-pbekeqzm.js";
|
|
23
27
|
import"../../index-6kec3b14.js";
|
|
24
28
|
import {
|
|
25
29
|
JsonRpcError2,
|
|
@@ -30,20 +34,23 @@ import {
|
|
|
30
34
|
DEFAULT_MAX_IMAGE_BYTES,
|
|
31
35
|
validateImageOptions,
|
|
32
36
|
bytesToBase64,
|
|
33
|
-
resolveImageBytes
|
|
37
|
+
resolveImageBytes,
|
|
38
|
+
guardedTurnStarter
|
|
34
39
|
} from "../../index-y0a4gt1s.js";
|
|
35
40
|
import {
|
|
36
41
|
holdEngineRequest,
|
|
37
|
-
answerEngineRequest,
|
|
38
|
-
drainEngineRequests,
|
|
39
42
|
endEngineTurn,
|
|
40
|
-
loseEngineTurn
|
|
41
|
-
|
|
43
|
+
loseEngineTurn,
|
|
44
|
+
abandonEngineTurn,
|
|
45
|
+
leaveEngineRequestUnanswered,
|
|
46
|
+
interruptEngineTurn,
|
|
47
|
+
respondToEngineRequest
|
|
48
|
+
} from "../../index-qggqqja2.js";
|
|
42
49
|
import {
|
|
43
50
|
spawnEngineProcess2
|
|
44
|
-
} from "../../index-
|
|
45
|
-
import"../../index-
|
|
46
|
-
import"../../index-
|
|
51
|
+
} from "../../index-fzd477xk.js";
|
|
52
|
+
import"../../index-gtaaxe9d.js";
|
|
53
|
+
import"../../index-d04w81fz.js";
|
|
47
54
|
import {
|
|
48
55
|
assertPositiveSafeInteger
|
|
49
56
|
} from "../../index-gr0kxymw.js";
|
|
@@ -52,7 +59,8 @@ import {
|
|
|
52
59
|
withSignalDeadline
|
|
53
60
|
} from "../../index-agy5fqgf.js";
|
|
54
61
|
import {
|
|
55
|
-
abortReason
|
|
62
|
+
abortReason,
|
|
63
|
+
linkAbortSignals
|
|
56
64
|
} from "../../index-rptj3qnc.js";
|
|
57
65
|
|
|
58
66
|
// src/agent-executor/acp/scenarios.ts
|
|
@@ -436,6 +444,15 @@ function assertAcpDriverOptions(config) {
|
|
|
436
444
|
validateSessionMetaObject(config.sessionMeta);
|
|
437
445
|
}
|
|
438
446
|
}
|
|
447
|
+
function keepsStdoutLine(filter, line) {
|
|
448
|
+
if (filter === undefined)
|
|
449
|
+
return true;
|
|
450
|
+
try {
|
|
451
|
+
return filter(line);
|
|
452
|
+
} catch (error) {
|
|
453
|
+
throw new Error(`The ACP stdoutLineFilter threw: ${error instanceof Error ? error.message : String(error)}`, { cause: error });
|
|
454
|
+
}
|
|
455
|
+
}
|
|
439
456
|
async function connectAcp(config, profile, cwd, signal, handlers = {}) {
|
|
440
457
|
assertAcpDriverOptions(config);
|
|
441
458
|
const env = engineEnvironment2(profile, config.ambient ?? process.env);
|
|
@@ -446,7 +463,7 @@ async function connectAcp(config, profile, cwd, signal, handlers = {}) {
|
|
|
446
463
|
...handlers.onRequest && { onRequest: handlers.onRequest },
|
|
447
464
|
...handlers.onNotification && { onNotification: handlers.onNotification }
|
|
448
465
|
});
|
|
449
|
-
emitStartupPhase(handlers.onStartupPhase, "spawning");
|
|
466
|
+
emitStartupPhase(handlers.onStartupPhase, "spawning", config.onObserverError);
|
|
450
467
|
const engine = spawnEngineProcess2({
|
|
451
468
|
executable: config.executable,
|
|
452
469
|
args: [...config.args ?? []],
|
|
@@ -458,15 +475,14 @@ async function connectAcp(config, profile, cwd, signal, handlers = {}) {
|
|
|
458
475
|
if (handlers.onProviderPid !== undefined && engine.pidReady !== undefined) {
|
|
459
476
|
engine.pidReady.then((pid) => {
|
|
460
477
|
if (pid !== undefined)
|
|
461
|
-
|
|
478
|
+
invokeObserver(config.onObserverError, "onProviderPid", () => handlers.onProviderPid?.(pid));
|
|
462
479
|
});
|
|
463
480
|
}
|
|
464
481
|
const reading = (async () => {
|
|
465
482
|
try {
|
|
466
483
|
for await (const line of engine.lines) {
|
|
467
|
-
if (config.stdoutLineFilter
|
|
484
|
+
if (!keepsStdoutLine(config.stdoutLineFilter, line))
|
|
468
485
|
continue;
|
|
469
|
-
}
|
|
470
486
|
peer.receive(line);
|
|
471
487
|
}
|
|
472
488
|
const ended = new Error(`The ACP agent ${config.executable} exited: ${engine.stderrTail().slice(-2000)}`);
|
|
@@ -484,7 +500,7 @@ async function connectAcp(config, profile, cwd, signal, handlers = {}) {
|
|
|
484
500
|
}
|
|
485
501
|
})();
|
|
486
502
|
try {
|
|
487
|
-
emitStartupPhase(handlers.onStartupPhase, "initializing");
|
|
503
|
+
emitStartupPhase(handlers.onStartupPhase, "initializing", config.onObserverError);
|
|
488
504
|
const clientInfo = config.clientInfo !== undefined ? AcpClientInfoSchema.parse(config.clientInfo) : undefined;
|
|
489
505
|
const rawInitialized = await peer.request("initialize", {
|
|
490
506
|
protocolVersion: ACP_PROTOCOL_VERSION,
|
|
@@ -791,17 +807,13 @@ function buildAcpPermissionAnswer(detail, rawReply) {
|
|
|
791
807
|
throw new TypeError("The agent offered no reject option");
|
|
792
808
|
return { outcome: { outcome: "selected", optionId: option.optionId } };
|
|
793
809
|
}
|
|
794
|
-
function answerActiveAcpTurnRequest(turn, interactionId, rawReply) {
|
|
795
|
-
|
|
796
|
-
if (waiting === undefined) {
|
|
797
|
-
throw new TypeError(`Unknown interaction ${interactionId} for this turn`);
|
|
798
|
-
}
|
|
799
|
-
const answer = buildAcpPermissionAnswer(waiting.detail, rawReply);
|
|
800
|
-
answerEngineRequest(turn, interactionId, answer);
|
|
810
|
+
function answerActiveAcpTurnRequest(turn, liveness, interactionId, rawReply) {
|
|
811
|
+
respondToEngineRequest(turn, liveness, interactionId, (detail) => buildAcpPermissionAnswer(detail, rawReply));
|
|
801
812
|
}
|
|
802
813
|
function answerAcpSessionRequest(input) {
|
|
814
|
+
input.liveness.ensureAlive();
|
|
803
815
|
if (input.turn?.pending.has(input.interactionId)) {
|
|
804
|
-
answerActiveAcpTurnRequest(input.turn, input.interactionId, input.reply);
|
|
816
|
+
answerActiveAcpTurnRequest(input.turn, input.liveness, input.interactionId, input.reply);
|
|
805
817
|
return;
|
|
806
818
|
}
|
|
807
819
|
const external = input.externalPending.get(input.interactionId);
|
|
@@ -816,14 +828,6 @@ function answerAcpSessionRequest(input) {
|
|
|
816
828
|
// src/agent-executor/acp/v1-handlers.ts
|
|
817
829
|
var JSON_RPC_INTERNAL_ERROR = -32603;
|
|
818
830
|
var MAX_EXTERNAL_PENDING_REQUESTS = 256;
|
|
819
|
-
function isHandlersAlive(state) {
|
|
820
|
-
try {
|
|
821
|
-
state.ensureAlive();
|
|
822
|
-
return true;
|
|
823
|
-
} catch {
|
|
824
|
-
return false;
|
|
825
|
-
}
|
|
826
|
-
}
|
|
827
831
|
function normalizeTransformedUpdates(raw, transform) {
|
|
828
832
|
if (transform === undefined)
|
|
829
833
|
return [raw];
|
|
@@ -870,7 +874,8 @@ function handleAcpNotification(state, externalState, method, params) {
|
|
|
870
874
|
try {
|
|
871
875
|
updates = normalizeTransformedUpdates(parsed.data.update, state.transformUpdate);
|
|
872
876
|
} catch (error) {
|
|
873
|
-
|
|
877
|
+
reportObserverError(state.onObserverError, "transformUpdate", error);
|
|
878
|
+
if (!state.liveness.isAlive())
|
|
874
879
|
return;
|
|
875
880
|
if (turn !== undefined) {
|
|
876
881
|
turn.chunk += 1;
|
|
@@ -887,7 +892,7 @@ function handleAcpNotification(state, externalState, method, params) {
|
|
|
887
892
|
}
|
|
888
893
|
const opened = state.isOpened();
|
|
889
894
|
for (const update of updates) {
|
|
890
|
-
if (!
|
|
895
|
+
if (!state.liveness.isAlive())
|
|
891
896
|
return;
|
|
892
897
|
state.onSessionMeta({
|
|
893
898
|
...update.configOptions !== undefined && { configOptions: update.configOptions },
|
|
@@ -913,7 +918,7 @@ function handleAcpNotification(state, externalState, method, params) {
|
|
|
913
918
|
duringActiveTurn: turn !== undefined,
|
|
914
919
|
deltas
|
|
915
920
|
};
|
|
916
|
-
|
|
921
|
+
invokeObserver(state.onObserverError, "onUpdate", () => state.onUpdate?.(event));
|
|
917
922
|
}
|
|
918
923
|
}
|
|
919
924
|
}
|
|
@@ -954,17 +959,16 @@ function handleAcpRequest(state, method, params, id) {
|
|
|
954
959
|
resolve
|
|
955
960
|
});
|
|
956
961
|
});
|
|
957
|
-
if (state.permissionRequestDelivery === "all" && state.onPermissionRequest !== undefined && turn.pending.has(interactionId) &&
|
|
962
|
+
if (state.permissionRequestDelivery === "all" && state.onPermissionRequest !== undefined && turn.pending.has(interactionId) && state.liveness.isAlive()) {
|
|
958
963
|
const observer = state.onPermissionRequest;
|
|
959
|
-
|
|
964
|
+
invokeObserver(state.onObserverError, "onPermissionRequest", () => observer({
|
|
960
965
|
interactionId,
|
|
961
966
|
sessionId: asked.sessionId,
|
|
962
967
|
request: asked,
|
|
963
968
|
duringActiveTurn: true,
|
|
964
969
|
delta,
|
|
965
970
|
async respond(reply) {
|
|
966
|
-
state.
|
|
967
|
-
answerActiveAcpTurnRequest(turn, interactionId, reply);
|
|
971
|
+
answerActiveAcpTurnRequest(turn, state.liveness, interactionId, reply);
|
|
968
972
|
}
|
|
969
973
|
}));
|
|
970
974
|
}
|
|
@@ -993,11 +997,16 @@ function handleAcpRequest(state, method, params, id) {
|
|
|
993
997
|
return new Promise((resolve, reject) => {
|
|
994
998
|
const entry = { detail: { options: asked.options }, resolve };
|
|
995
999
|
state.externalPending.set(interactionId, entry);
|
|
996
|
-
const
|
|
1000
|
+
const report = (error) => {
|
|
1001
|
+
if (!(error instanceof JsonRpcError2))
|
|
1002
|
+
reportObserverError(state.onObserverError, "onPermissionRequest", error);
|
|
1003
|
+
};
|
|
1004
|
+
const onObserverFailure = (error) => {
|
|
1005
|
+
report(error);
|
|
997
1006
|
if (state.externalPending.get(interactionId) !== entry)
|
|
998
1007
|
return;
|
|
999
1008
|
state.externalPending.delete(interactionId);
|
|
1000
|
-
if (!
|
|
1009
|
+
if (!state.liveness.isAlive())
|
|
1001
1010
|
return;
|
|
1002
1011
|
if (error instanceof JsonRpcError2)
|
|
1003
1012
|
reject(error);
|
|
@@ -1012,8 +1021,8 @@ function handleAcpRequest(state, method, params, id) {
|
|
|
1012
1021
|
duringActiveTurn: false,
|
|
1013
1022
|
delta,
|
|
1014
1023
|
async respond(reply) {
|
|
1015
|
-
state.ensureAlive();
|
|
1016
1024
|
answerAcpSessionRequest({
|
|
1025
|
+
liveness: state.liveness,
|
|
1017
1026
|
turn: undefined,
|
|
1018
1027
|
externalPending: state.externalPending,
|
|
1019
1028
|
expectedEntry: entry,
|
|
@@ -1023,25 +1032,23 @@ function handleAcpRequest(state, method, params, id) {
|
|
|
1023
1032
|
}
|
|
1024
1033
|
});
|
|
1025
1034
|
const thenable = typeof outcome === "object" && outcome !== null && "then" in outcome && typeof outcome.then === "function";
|
|
1026
|
-
if (!
|
|
1035
|
+
if (!state.liveness.isAlive()) {
|
|
1027
1036
|
if (state.externalPending.get(interactionId) === entry) {
|
|
1028
1037
|
state.externalPending.delete(interactionId);
|
|
1029
1038
|
}
|
|
1030
1039
|
if (thenable)
|
|
1031
|
-
Promise.resolve(outcome).catch(
|
|
1032
|
-
return;
|
|
1033
|
-
});
|
|
1040
|
+
Promise.resolve(outcome).catch(report);
|
|
1034
1041
|
return;
|
|
1035
1042
|
}
|
|
1036
1043
|
if (thenable) {
|
|
1037
1044
|
Promise.resolve(outcome).then(() => {
|
|
1038
|
-
if (!
|
|
1045
|
+
if (!state.liveness.isAlive() && state.externalPending.get(interactionId) === entry) {
|
|
1039
1046
|
state.externalPending.delete(interactionId);
|
|
1040
1047
|
}
|
|
1041
|
-
},
|
|
1048
|
+
}, onObserverFailure);
|
|
1042
1049
|
}
|
|
1043
1050
|
} catch (error) {
|
|
1044
|
-
|
|
1051
|
+
onObserverFailure(error);
|
|
1045
1052
|
}
|
|
1046
1053
|
});
|
|
1047
1054
|
}
|
|
@@ -1050,18 +1057,22 @@ function createAcpHandlers(state) {
|
|
|
1050
1057
|
chunk: 0,
|
|
1051
1058
|
track: { segment: 0, toolNames: new Map }
|
|
1052
1059
|
};
|
|
1053
|
-
const
|
|
1054
|
-
|
|
1055
|
-
|
|
1060
|
+
const answerClosedRequest = (method) => {
|
|
1061
|
+
if (state.closingGracefully?.() !== true)
|
|
1062
|
+
return leaveEngineRequestUnanswered();
|
|
1063
|
+
if (method === "session/request_permission")
|
|
1064
|
+
return Promise.resolve(ACP_CANCELLED);
|
|
1065
|
+
return Promise.reject(new JsonRpcError2(JSON_RPC_METHOD_NOT_FOUND2, `${method} is not handled by this executor`));
|
|
1066
|
+
};
|
|
1056
1067
|
return {
|
|
1057
1068
|
onNotification: (method, params) => {
|
|
1058
|
-
if (!
|
|
1069
|
+
if (!state.liveness.isAlive())
|
|
1059
1070
|
return;
|
|
1060
1071
|
handleAcpNotification(state, externalState, method, params);
|
|
1061
1072
|
},
|
|
1062
1073
|
onRequest: (method, params, id) => {
|
|
1063
|
-
if (!
|
|
1064
|
-
return
|
|
1074
|
+
if (!state.liveness.isAlive())
|
|
1075
|
+
return answerClosedRequest(method);
|
|
1065
1076
|
return handleAcpRequest(state, method, params, id);
|
|
1066
1077
|
},
|
|
1067
1078
|
onEnd: state.onEnd
|
|
@@ -1117,47 +1128,58 @@ async function applyAcpSessionSelections(input) {
|
|
|
1117
1128
|
// src/agent-executor/acp/v1-probe.ts
|
|
1118
1129
|
var DEFAULT_PROBE_TIMEOUT_MS = 30000;
|
|
1119
1130
|
var ProbeSessionId = AcpNewSessionResultSchema.pick({ sessionId: true });
|
|
1120
|
-
async function readProbeSession(config, connection, cwd, signal) {
|
|
1131
|
+
async function readProbeSession(config, connection, cwd, signal, inspect) {
|
|
1121
1132
|
const meta = resolveAcpSessionMeta(config.sessionMeta, connection.initialized);
|
|
1122
1133
|
const reply = await connection.peer.request("session/new", {
|
|
1123
1134
|
cwd,
|
|
1124
1135
|
mcpServers: [],
|
|
1125
1136
|
...meta !== undefined && { _meta: meta }
|
|
1126
1137
|
}, { signal });
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1138
|
+
const identified = ProbeSessionId.safeParse(reply);
|
|
1139
|
+
if (!identified.success) {
|
|
1140
|
+
if (signal?.aborted)
|
|
1141
|
+
throw abortReason(signal);
|
|
1142
|
+
throw identified.error;
|
|
1143
|
+
}
|
|
1144
|
+
const { sessionId } = identified.data;
|
|
1130
1145
|
const parsed = AcpNewSessionResultSchema.safeParse(reply);
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1146
|
+
let inspected;
|
|
1147
|
+
if (inspect !== undefined && parsed.success && signal?.aborted !== true) {
|
|
1148
|
+
try {
|
|
1149
|
+
inspected = { value: await inspect({ sessionId, reply }) };
|
|
1150
|
+
} catch (error) {
|
|
1151
|
+
inspected = { error };
|
|
1152
|
+
}
|
|
1153
|
+
}
|
|
1154
|
+
const cleanupFailures = [];
|
|
1155
|
+
const cleanupOptions = { timeoutMs: closeRequestTimeoutMs(config) };
|
|
1156
|
+
const recordFailure = (method, cause) => cleanupFailures.push(new Error(`${method} failed: ${cause instanceof Error ? cause.message : String(cause)}`, {
|
|
1135
1157
|
cause
|
|
1136
1158
|
}));
|
|
1137
1159
|
if (acpCan(connection, "close")) {
|
|
1138
1160
|
try {
|
|
1139
1161
|
await connection.peer.request("session/close", { sessionId }, cleanupOptions);
|
|
1140
1162
|
} catch (cause) {
|
|
1141
|
-
if (signal?.aborted)
|
|
1142
|
-
throw abortReason(signal);
|
|
1143
1163
|
const canFallBack = cause instanceof JsonRpcError2 && cause.code === JSON_RPC_METHOD_NOT_FOUND2 && acpCan(connection, "delete");
|
|
1144
1164
|
if (!canFallBack)
|
|
1145
1165
|
recordFailure("session/close", cause);
|
|
1146
1166
|
}
|
|
1147
1167
|
}
|
|
1148
|
-
if (signal?.aborted)
|
|
1149
|
-
throw abortReason(signal);
|
|
1150
1168
|
if (acpCan(connection, "delete")) {
|
|
1151
1169
|
try {
|
|
1152
1170
|
await connection.peer.request("session/delete", { sessionId }, cleanupOptions);
|
|
1153
1171
|
} catch (cause) {
|
|
1154
|
-
if (signal?.aborted)
|
|
1155
|
-
throw abortReason(signal);
|
|
1156
1172
|
recordFailure("session/delete", cause);
|
|
1157
1173
|
}
|
|
1158
1174
|
}
|
|
1159
|
-
if (signal?.aborted)
|
|
1160
|
-
|
|
1175
|
+
if (signal?.aborted) {
|
|
1176
|
+
const reason = abortReason(signal);
|
|
1177
|
+
if (cleanupFailures.length === 0)
|
|
1178
|
+
throw reason;
|
|
1179
|
+
const all = [reason, ...cleanupFailures];
|
|
1180
|
+
throw new AggregateError(all, all.map(messageOf).join("; "), { cause: reason });
|
|
1181
|
+
}
|
|
1182
|
+
const failures = [...parsed.success ? [] : [parsed.error], ...cleanupFailures];
|
|
1161
1183
|
if (failures.length > 1) {
|
|
1162
1184
|
throw new AggregateError(failures, failures.map((error) => error.message).join("; "), {
|
|
1163
1185
|
cause: failures[0]
|
|
@@ -1167,7 +1189,24 @@ async function readProbeSession(config, connection, cwd, signal) {
|
|
|
1167
1189
|
throw parsed.error;
|
|
1168
1190
|
if (failures[0] !== undefined)
|
|
1169
1191
|
throw failures[0];
|
|
1170
|
-
|
|
1192
|
+
if (inspected !== undefined && "error" in inspected)
|
|
1193
|
+
throw inspected.error;
|
|
1194
|
+
return { ...parsed.data, inspected: inspected?.value };
|
|
1195
|
+
}
|
|
1196
|
+
function messageOf(error) {
|
|
1197
|
+
return error instanceof Error ? error.message : String(error);
|
|
1198
|
+
}
|
|
1199
|
+
async function readEachModelOptions(connection, sessionId, reply, signal) {
|
|
1200
|
+
let options = AcpNewSessionResultSchema.parse(reply).configOptions ?? [];
|
|
1201
|
+
const model = options.find((option) => option.category === "model");
|
|
1202
|
+
const byModel = {};
|
|
1203
|
+
if (model === undefined)
|
|
1204
|
+
return byModel;
|
|
1205
|
+
for (const value of acpOptionValues(model)) {
|
|
1206
|
+
options = await setAcpConfigOption(connection.peer, sessionId, options, "model", value, signal);
|
|
1207
|
+
byModel[value] = options;
|
|
1208
|
+
}
|
|
1209
|
+
return byModel;
|
|
1171
1210
|
}
|
|
1172
1211
|
function extractProbeModels(configOptions, availableModels) {
|
|
1173
1212
|
const option = configOptions.find((candidate) => candidate.category === "model");
|
|
@@ -1212,7 +1251,8 @@ async function probeAcpCapabilities(config, input) {
|
|
|
1212
1251
|
let configOptions = [];
|
|
1213
1252
|
let sawConfigOptionUpdate = false;
|
|
1214
1253
|
let commands = [];
|
|
1215
|
-
const
|
|
1254
|
+
const startup = linkAbortSignals(deadlineSignal, new AbortController().signal);
|
|
1255
|
+
const connection = await connectAcp(config, profile, input.cwd, startup.signal, {
|
|
1216
1256
|
onNotification: (method, params) => {
|
|
1217
1257
|
applyProbeNotification(config, method, params, (meta) => {
|
|
1218
1258
|
if (meta.configOptions !== undefined) {
|
|
@@ -1224,10 +1264,10 @@ async function probeAcpCapabilities(config, input) {
|
|
|
1224
1264
|
});
|
|
1225
1265
|
},
|
|
1226
1266
|
...input.onStartupPhase !== undefined && { onStartupPhase: input.onStartupPhase }
|
|
1227
|
-
});
|
|
1267
|
+
}).finally(() => startup.release());
|
|
1228
1268
|
let result;
|
|
1229
1269
|
try {
|
|
1230
|
-
const session = await readProbeSession(config, connection, input.cwd, deadlineSignal);
|
|
1270
|
+
const session = await readProbeSession(config, connection, input.cwd, deadlineSignal, input.eachModel === true ? ({ sessionId, reply }) => readEachModelOptions(connection, sessionId, reply, deadlineSignal) : undefined);
|
|
1231
1271
|
configOptions = mergeInitialAcpConfigOptions(configOptions, session.configOptions, sawConfigOptionUpdate);
|
|
1232
1272
|
deadlineSignal.throwIfAborted();
|
|
1233
1273
|
const models = extractProbeModels(configOptions, session.models?.availableModels);
|
|
@@ -1235,7 +1275,8 @@ async function probeAcpCapabilities(config, input) {
|
|
|
1235
1275
|
initialized: connection.initialized,
|
|
1236
1276
|
configOptions,
|
|
1237
1277
|
commands,
|
|
1238
|
-
models
|
|
1278
|
+
models,
|
|
1279
|
+
...session.inspected !== undefined && { optionsByModel: session.inspected }
|
|
1239
1280
|
};
|
|
1240
1281
|
} catch (error) {
|
|
1241
1282
|
await stopConnection(connection, { error });
|
|
@@ -1264,40 +1305,36 @@ function newAcpTurn(turnId) {
|
|
|
1264
1305
|
track: { segment: 0, toolNames: new Map },
|
|
1265
1306
|
promptGeneration: 1,
|
|
1266
1307
|
accumulatedUsage: undefined,
|
|
1267
|
-
settled: false
|
|
1308
|
+
settled: false,
|
|
1309
|
+
openGenerations: new Set,
|
|
1310
|
+
supersededResults: new Map
|
|
1268
1311
|
};
|
|
1269
1312
|
}
|
|
1270
1313
|
function settleAcpTurn(turn, reason, sendCancelled) {
|
|
1271
|
-
if (
|
|
1272
|
-
return;
|
|
1273
|
-
turn.settled = true;
|
|
1274
|
-
if (sendCancelled) {
|
|
1314
|
+
if (sendCancelled)
|
|
1275
1315
|
loseEngineTurn(turn, () => ACP_CANCELLED, reason);
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1316
|
+
else
|
|
1317
|
+
abandonEngineTurn(turn, reason);
|
|
1318
|
+
}
|
|
1319
|
+
function refusedSteer(turn, error, generation, previous) {
|
|
1320
|
+
const kind = classifyAcpRpcRefusal(error) ?? "unhandled";
|
|
1321
|
+
turn.promptGeneration = previous;
|
|
1322
|
+
offerTurnDelta(turn.channel, {
|
|
1323
|
+
type: "error",
|
|
1324
|
+
turnId: turn.state.turnId,
|
|
1325
|
+
itemId: `steer-refused:${generation}`,
|
|
1326
|
+
raw: { source: "acp", type: "session/prompt" },
|
|
1327
|
+
kind,
|
|
1328
|
+
message: `The ACP agent refused the steer prompt: ${error instanceof Error ? error.message : String(error)}`
|
|
1329
|
+
});
|
|
1280
1330
|
}
|
|
1281
1331
|
function runAcpPrompt(input) {
|
|
1282
|
-
const { peer, sessionId, prompt, turn, generation,
|
|
1283
|
-
|
|
1284
|
-
if (turn.settled)
|
|
1285
|
-
return;
|
|
1286
|
-
ensureAlive();
|
|
1287
|
-
const parsed = AcpPromptResultSchema.parse(result);
|
|
1288
|
-
if (parsed.usage !== undefined && parsed.usage !== null) {
|
|
1289
|
-
turn.accumulatedUsage = addAcpTokenUsage(turn.accumulatedUsage, normalizeAcpUsage(parsed.usage, {
|
|
1290
|
-
...input.usageInputIncludesCachedRead !== undefined && {
|
|
1291
|
-
usageInputIncludesCachedRead: input.usageInputIncludesCachedRead
|
|
1292
|
-
}
|
|
1293
|
-
}));
|
|
1294
|
-
}
|
|
1295
|
-
if (generation !== turn.promptGeneration)
|
|
1296
|
-
return;
|
|
1332
|
+
const { peer, sessionId, prompt, turn, generation, liveness, checkOutcome, done } = input;
|
|
1333
|
+
const settle = async (parsed) => {
|
|
1297
1334
|
const rawOverride = !turn.state.interruptRequested && checkOutcome !== undefined ? await checkOutcome(parsed) : undefined;
|
|
1298
1335
|
if (turn.settled || generation !== turn.promptGeneration)
|
|
1299
1336
|
return;
|
|
1300
|
-
ensureAlive();
|
|
1337
|
+
liveness.ensureAlive();
|
|
1301
1338
|
const override = rawOverride !== undefined ? AcpPromptOutcomeOverrideSchema.parse(rawOverride) : undefined;
|
|
1302
1339
|
const outcome = override !== undefined ? "failed" : acpOutcome(parsed.stopReason, turn.state.interruptRequested);
|
|
1303
1340
|
const raw = { source: "acp", type: `session/prompt/${parsed.stopReason}` };
|
|
@@ -1340,26 +1377,29 @@ function runAcpPrompt(input) {
|
|
|
1340
1377
|
threadDisposition: override.threadDisposition
|
|
1341
1378
|
}
|
|
1342
1379
|
});
|
|
1343
|
-
turn.settled = true;
|
|
1344
1380
|
endEngineTurn(turn, () => ACP_CANCELLED, last);
|
|
1345
1381
|
done();
|
|
1346
|
-
}
|
|
1382
|
+
};
|
|
1383
|
+
const fail = (error) => {
|
|
1384
|
+
turn.openGenerations.delete(generation);
|
|
1347
1385
|
if (turn.settled || generation !== turn.promptGeneration)
|
|
1348
1386
|
return;
|
|
1349
|
-
turn.
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1387
|
+
const earlier = [...turn.openGenerations, ...turn.supersededResults.keys()].filter((other) => other < generation);
|
|
1388
|
+
if (earlier.length > 0) {
|
|
1389
|
+
const previous = Math.max(...earlier);
|
|
1390
|
+
refusedSteer(turn, error, generation, previous);
|
|
1391
|
+
const ended = turn.supersededResults.get(previous);
|
|
1392
|
+
turn.supersededResults.delete(previous);
|
|
1393
|
+
ended?.();
|
|
1394
|
+
return;
|
|
1357
1395
|
}
|
|
1358
|
-
|
|
1359
|
-
|
|
1396
|
+
const stop = liveness.stopped();
|
|
1397
|
+
if (stop !== undefined) {
|
|
1398
|
+
abandonEngineTurn(turn, stop.reason);
|
|
1360
1399
|
done();
|
|
1361
1400
|
return;
|
|
1362
1401
|
}
|
|
1402
|
+
const failure = error;
|
|
1363
1403
|
const kind = classifyAcpRpcRefusal(failure);
|
|
1364
1404
|
if (kind !== undefined && failure instanceof Error) {
|
|
1365
1405
|
const raw = { source: "acp", type: "session/prompt" };
|
|
@@ -1384,59 +1424,68 @@ function runAcpPrompt(input) {
|
|
|
1384
1424
|
loseEngineTurn(turn, () => ACP_CANCELLED, failure);
|
|
1385
1425
|
}
|
|
1386
1426
|
done();
|
|
1387
|
-
}
|
|
1427
|
+
};
|
|
1428
|
+
turn.openGenerations.add(generation);
|
|
1429
|
+
peer.request("session/prompt", { sessionId, prompt: [...prompt] }, { timeoutMs: null }).then(async (result) => {
|
|
1430
|
+
turn.openGenerations.delete(generation);
|
|
1431
|
+
if (turn.settled)
|
|
1432
|
+
return;
|
|
1433
|
+
liveness.ensureAlive();
|
|
1434
|
+
const parsed = AcpPromptResultSchema.parse(result);
|
|
1435
|
+
if (parsed.usage !== undefined && parsed.usage !== null) {
|
|
1436
|
+
turn.accumulatedUsage = addAcpTokenUsage(turn.accumulatedUsage, normalizeAcpUsage(parsed.usage, {
|
|
1437
|
+
...input.usageInputIncludesCachedRead !== undefined && {
|
|
1438
|
+
usageInputIncludesCachedRead: input.usageInputIncludesCachedRead
|
|
1439
|
+
}
|
|
1440
|
+
}));
|
|
1441
|
+
}
|
|
1442
|
+
if (generation !== turn.promptGeneration) {
|
|
1443
|
+
turn.supersededResults.set(generation, () => {
|
|
1444
|
+
settle(parsed).catch(fail);
|
|
1445
|
+
});
|
|
1446
|
+
return;
|
|
1447
|
+
}
|
|
1448
|
+
await settle(parsed);
|
|
1449
|
+
}).catch(fail);
|
|
1388
1450
|
}
|
|
1389
|
-
function acpTurnHandle(peer, sessionId, turn,
|
|
1451
|
+
function acpTurnHandle(peer, sessionId, turn, liveness) {
|
|
1390
1452
|
return {
|
|
1391
1453
|
deltas: turn.channel,
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
ensureAlive();
|
|
1397
|
-
} catch {
|
|
1398
|
-
return;
|
|
1399
|
-
}
|
|
1400
|
-
turn.state.interruptRequested = true;
|
|
1401
|
-
peer.notify("session/cancel", { sessionId });
|
|
1402
|
-
drainEngineRequests(turn, () => ACP_CANCELLED);
|
|
1403
|
-
},
|
|
1454
|
+
interrupt: () => interruptEngineTurn(turn, liveness, {
|
|
1455
|
+
refusal: () => ACP_CANCELLED,
|
|
1456
|
+
tell: () => peer.notify("session/cancel", { sessionId })
|
|
1457
|
+
}),
|
|
1404
1458
|
async respond(interactionId, rawReply) {
|
|
1405
|
-
|
|
1406
|
-
answerActiveAcpTurnRequest(turn, interactionId, rawReply);
|
|
1459
|
+
answerActiveAcpTurnRequest(turn, liveness, interactionId, rawReply);
|
|
1407
1460
|
}
|
|
1408
1461
|
};
|
|
1409
1462
|
}
|
|
1410
1463
|
function createAcpTurnControls(input) {
|
|
1411
|
-
let turnOpening = false;
|
|
1412
1464
|
let steering = false;
|
|
1413
1465
|
const releaseTurn = (turn) => {
|
|
1414
1466
|
if (input.getTurn() === turn)
|
|
1415
1467
|
input.setTurn(undefined);
|
|
1416
1468
|
};
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1469
|
+
const { liveness } = input;
|
|
1470
|
+
const startTurn = guardedTurnStarter({
|
|
1471
|
+
busyMessage: "A turn is already running in this ACP session",
|
|
1472
|
+
check() {
|
|
1473
|
+
liveness.ensureAlive();
|
|
1474
|
+
if (input.getTurn() !== undefined) {
|
|
1421
1475
|
throw new Error("A turn is already running in this ACP session");
|
|
1422
1476
|
}
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
input.
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
}
|
|
1436
|
-
} finally {
|
|
1437
|
-
turnOpening = false;
|
|
1438
|
-
}
|
|
1439
|
-
input.ensureAlive();
|
|
1477
|
+
},
|
|
1478
|
+
async inline(turnInput) {
|
|
1479
|
+
const prompt = await acpPromptBlocks(turnInput.input, input.limits);
|
|
1480
|
+
liveness.ensureAlive();
|
|
1481
|
+
const checkOutcome = input.config.watchPromptOutcome !== undefined ? await input.config.watchPromptOutcome({
|
|
1482
|
+
sessionId: input.sessionId,
|
|
1483
|
+
turnId: turnInput.turnId,
|
|
1484
|
+
generation: 1
|
|
1485
|
+
}) : undefined;
|
|
1486
|
+
return { prompt, checkOutcome };
|
|
1487
|
+
},
|
|
1488
|
+
dispatch(turnInput, { prompt, checkOutcome }) {
|
|
1440
1489
|
const turn = newAcpTurn(turnInput.turnId);
|
|
1441
1490
|
input.setTurn(turn);
|
|
1442
1491
|
runAcpPrompt({
|
|
@@ -1445,20 +1494,23 @@ function createAcpTurnControls(input) {
|
|
|
1445
1494
|
prompt,
|
|
1446
1495
|
turn,
|
|
1447
1496
|
generation: 1,
|
|
1448
|
-
|
|
1497
|
+
liveness,
|
|
1449
1498
|
...input.config.usageInputIncludesCachedRead !== undefined && {
|
|
1450
1499
|
usageInputIncludesCachedRead: input.config.usageInputIncludesCachedRead
|
|
1451
1500
|
},
|
|
1452
1501
|
...checkOutcome !== undefined && { checkOutcome },
|
|
1453
1502
|
done: () => releaseTurn(turn)
|
|
1454
1503
|
});
|
|
1455
|
-
return acpTurnHandle(input.peer, input.sessionId, turn,
|
|
1456
|
-
}
|
|
1504
|
+
return acpTurnHandle(input.peer, input.sessionId, turn, liveness);
|
|
1505
|
+
}
|
|
1506
|
+
});
|
|
1507
|
+
return {
|
|
1508
|
+
startTurn,
|
|
1457
1509
|
async steerTurn(steerInput) {
|
|
1458
1510
|
if ((input.config.steerMode ?? "none") !== "prompt") {
|
|
1459
1511
|
throw new TypeError('The ACP driver does not support steering unless steerMode is "prompt"');
|
|
1460
1512
|
}
|
|
1461
|
-
|
|
1513
|
+
liveness.ensureAlive();
|
|
1462
1514
|
const turn = input.getTurn();
|
|
1463
1515
|
if (turn === undefined || turn.settled) {
|
|
1464
1516
|
throw new Error("Cannot steer turn: no ACP turn is currently running");
|
|
@@ -1475,7 +1527,7 @@ function createAcpTurnControls(input) {
|
|
|
1475
1527
|
let nextGeneration;
|
|
1476
1528
|
try {
|
|
1477
1529
|
prompt = await acpPromptBlocks(steerInput.input, input.limits);
|
|
1478
|
-
|
|
1530
|
+
liveness.ensureAlive();
|
|
1479
1531
|
if (input.getTurn() !== turn || turn.settled || turn.state.interruptRequested) {
|
|
1480
1532
|
throw new Error("Cannot steer turn: the active ACP turn ended before steering was sent");
|
|
1481
1533
|
}
|
|
@@ -1487,7 +1539,7 @@ function createAcpTurnControls(input) {
|
|
|
1487
1539
|
generation: nextGeneration
|
|
1488
1540
|
});
|
|
1489
1541
|
}
|
|
1490
|
-
|
|
1542
|
+
liveness.ensureAlive();
|
|
1491
1543
|
if (input.getTurn() !== turn || turn.settled || turn.state.interruptRequested) {
|
|
1492
1544
|
throw new Error("Cannot steer turn: the active ACP turn ended before steering was sent");
|
|
1493
1545
|
}
|
|
@@ -1501,7 +1553,7 @@ function createAcpTurnControls(input) {
|
|
|
1501
1553
|
prompt,
|
|
1502
1554
|
turn,
|
|
1503
1555
|
generation: nextGeneration,
|
|
1504
|
-
|
|
1556
|
+
liveness,
|
|
1505
1557
|
...input.config.usageInputIncludesCachedRead !== undefined && {
|
|
1506
1558
|
usageInputIncludesCachedRead: input.config.usageInputIncludesCachedRead
|
|
1507
1559
|
},
|
|
@@ -1515,15 +1567,16 @@ function createAcpTurnControls(input) {
|
|
|
1515
1567
|
|
|
1516
1568
|
// src/agent-executor/acp/v1-session.ts
|
|
1517
1569
|
function createAcpSessionClose(input) {
|
|
1518
|
-
const { state, linked, externalPending } = input;
|
|
1570
|
+
const { state, liveness, linked, externalPending } = input;
|
|
1519
1571
|
let closePromise;
|
|
1520
1572
|
return () => {
|
|
1521
1573
|
if (closePromise !== undefined)
|
|
1522
1574
|
return closePromise;
|
|
1523
1575
|
closePromise = (async () => {
|
|
1524
|
-
const
|
|
1525
|
-
const
|
|
1526
|
-
|
|
1576
|
+
const terminated = liveness.terminated();
|
|
1577
|
+
const alreadyTerminated = terminated !== undefined;
|
|
1578
|
+
const closeReason = terminated === undefined ? new Error("The ACP session is closing") : terminated.reason;
|
|
1579
|
+
liveness.markClosing();
|
|
1527
1580
|
const turn = state.current;
|
|
1528
1581
|
state.current = undefined;
|
|
1529
1582
|
settleAcpTurn(turn, closeReason, !alreadyTerminated);
|
|
@@ -1569,7 +1622,7 @@ async function openOrReopenAcpSession(input) {
|
|
|
1569
1622
|
};
|
|
1570
1623
|
}
|
|
1571
1624
|
function buildAcpSession(input) {
|
|
1572
|
-
const { config, connected, sessionId, linked, externalPending, state,
|
|
1625
|
+
const { config, connected, sessionId, liveness, linked, externalPending, state, stop } = input;
|
|
1573
1626
|
const { peer, initialized } = connected;
|
|
1574
1627
|
const limits = {
|
|
1575
1628
|
images: initialized.agentCapabilities?.promptCapabilities?.image === true,
|
|
@@ -1581,7 +1634,7 @@ function buildAcpSession(input) {
|
|
|
1581
1634
|
peer,
|
|
1582
1635
|
sessionId,
|
|
1583
1636
|
limits,
|
|
1584
|
-
|
|
1637
|
+
liveness,
|
|
1585
1638
|
getTurn: () => state.current,
|
|
1586
1639
|
setTurn: (turn) => {
|
|
1587
1640
|
state.current = turn;
|
|
@@ -1591,19 +1644,21 @@ function buildAcpSession(input) {
|
|
|
1591
1644
|
config,
|
|
1592
1645
|
connected,
|
|
1593
1646
|
sessionId,
|
|
1647
|
+
liveness,
|
|
1594
1648
|
linked,
|
|
1595
1649
|
externalPending,
|
|
1596
1650
|
state,
|
|
1597
1651
|
stop
|
|
1598
1652
|
});
|
|
1599
|
-
ensureAlive();
|
|
1653
|
+
liveness.ensureAlive();
|
|
1600
1654
|
state.opened = true;
|
|
1601
1655
|
return {
|
|
1602
1656
|
nativeThreadId: sessionId,
|
|
1603
1657
|
get providerPid() {
|
|
1604
|
-
return
|
|
1658
|
+
return liveness.isAlive() ? state.livePid : undefined;
|
|
1605
1659
|
},
|
|
1606
1660
|
approvalEnforcement: "agent-initiated",
|
|
1661
|
+
initialized,
|
|
1607
1662
|
get configOptions() {
|
|
1608
1663
|
return state.configOptions;
|
|
1609
1664
|
},
|
|
@@ -1614,13 +1669,18 @@ function buildAcpSession(input) {
|
|
|
1614
1669
|
return state.commands;
|
|
1615
1670
|
},
|
|
1616
1671
|
async setConfigOption(configId, value) {
|
|
1617
|
-
ensureAlive();
|
|
1672
|
+
liveness.ensureAlive();
|
|
1618
1673
|
state.configOptions = await setAcpConfigOption(peer, sessionId, state.configOptions, configId, value, linked.signal);
|
|
1619
1674
|
return state.configOptions;
|
|
1620
1675
|
},
|
|
1621
1676
|
async respond(interactionId, reply) {
|
|
1622
|
-
|
|
1623
|
-
|
|
1677
|
+
answerAcpSessionRequest({
|
|
1678
|
+
liveness,
|
|
1679
|
+
turn: state.current,
|
|
1680
|
+
externalPending,
|
|
1681
|
+
interactionId,
|
|
1682
|
+
reply
|
|
1683
|
+
});
|
|
1624
1684
|
},
|
|
1625
1685
|
...turnControls,
|
|
1626
1686
|
close
|
|
@@ -1634,8 +1694,6 @@ async function openAcpSession(config, input) {
|
|
|
1634
1694
|
const state = {
|
|
1635
1695
|
current: undefined,
|
|
1636
1696
|
opened: false,
|
|
1637
|
-
closing: false,
|
|
1638
|
-
dead: undefined,
|
|
1639
1697
|
livePid: undefined,
|
|
1640
1698
|
pidNotified: false,
|
|
1641
1699
|
configOptions: [],
|
|
@@ -1644,29 +1702,25 @@ async function openAcpSession(config, input) {
|
|
|
1644
1702
|
commands: []
|
|
1645
1703
|
};
|
|
1646
1704
|
let connected;
|
|
1647
|
-
const
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
if (linked.signal.aborted)
|
|
1653
|
-
throw abortReason(linked.signal);
|
|
1654
|
-
};
|
|
1705
|
+
const liveness = sessionLiveness({
|
|
1706
|
+
closedMessage: "The ACP session is closing",
|
|
1707
|
+
caller: input.signal,
|
|
1708
|
+
linked: linked.signal
|
|
1709
|
+
});
|
|
1655
1710
|
const recordPid = (pid) => {
|
|
1656
|
-
if (pid === undefined ||
|
|
1711
|
+
if (pid === undefined || !liveness.isAlive())
|
|
1657
1712
|
return;
|
|
1658
|
-
}
|
|
1659
1713
|
state.livePid = pid;
|
|
1660
1714
|
if (!state.pidNotified && config.onProviderPid !== undefined) {
|
|
1661
1715
|
state.pidNotified = true;
|
|
1662
|
-
|
|
1716
|
+
invokeObserver(config.onObserverError, "onProviderPid", () => config.onProviderPid?.(pid));
|
|
1663
1717
|
}
|
|
1664
1718
|
};
|
|
1665
1719
|
try {
|
|
1666
1720
|
connected = await connectAcp(config, input.profile, input.cwd, linked.signal, {
|
|
1667
1721
|
...createAcpHandlers({
|
|
1668
1722
|
externalPending,
|
|
1669
|
-
|
|
1723
|
+
liveness,
|
|
1670
1724
|
isOpened: () => state.opened,
|
|
1671
1725
|
getTurn: () => state.current,
|
|
1672
1726
|
onSessionMeta(meta) {
|
|
@@ -1689,25 +1743,29 @@ async function openAcpSession(config, input) {
|
|
|
1689
1743
|
...config.permissionRequestDelivery !== undefined && {
|
|
1690
1744
|
permissionRequestDelivery: config.permissionRequestDelivery
|
|
1691
1745
|
},
|
|
1746
|
+
...config.onObserverError !== undefined && {
|
|
1747
|
+
onObserverError: config.onObserverError
|
|
1748
|
+
},
|
|
1749
|
+
closingGracefully: () => liveness.closingGracefully,
|
|
1692
1750
|
onEnd(error) {
|
|
1693
|
-
const abortedByCaller =
|
|
1694
|
-
const shouldNotify = state.opened && !
|
|
1695
|
-
if (!
|
|
1696
|
-
|
|
1751
|
+
const { abortedByCaller } = liveness;
|
|
1752
|
+
const shouldNotify = state.opened && !liveness.closing && !abortedByCaller;
|
|
1753
|
+
if (!liveness.closing && !abortedByCaller)
|
|
1754
|
+
liveness.markLost(error);
|
|
1697
1755
|
state.livePid = undefined;
|
|
1698
1756
|
const turn = state.current;
|
|
1699
1757
|
state.current = undefined;
|
|
1700
1758
|
externalPending.clear();
|
|
1701
|
-
settleAcpTurn(turn, abortedByCaller ? abortReason(
|
|
1759
|
+
settleAcpTurn(turn, abortedByCaller && input.signal !== undefined ? abortReason(input.signal) : error, !abortedByCaller);
|
|
1702
1760
|
linked.abort();
|
|
1703
1761
|
if (shouldNotify)
|
|
1704
|
-
|
|
1762
|
+
invokeObserver(config.onObserverError, "onDisconnect", () => config.onDisconnect?.(error));
|
|
1705
1763
|
}
|
|
1706
1764
|
}),
|
|
1707
1765
|
onProviderPid: recordPid,
|
|
1708
1766
|
...input.onStartupPhase !== undefined && { onStartupPhase: input.onStartupPhase }
|
|
1709
1767
|
});
|
|
1710
|
-
if (state.livePid === undefined &&
|
|
1768
|
+
if (state.livePid === undefined && liveness.isAlive()) {
|
|
1711
1769
|
recordPid(await connected.engine.pidReady ?? connected.engine.pid);
|
|
1712
1770
|
}
|
|
1713
1771
|
} catch (error) {
|
|
@@ -1716,8 +1774,8 @@ async function openAcpSession(config, input) {
|
|
|
1716
1774
|
}
|
|
1717
1775
|
const { peer, initialized } = connected;
|
|
1718
1776
|
const stop = async (primary) => {
|
|
1719
|
-
const terminated =
|
|
1720
|
-
|
|
1777
|
+
const terminated = liveness.terminated() !== undefined;
|
|
1778
|
+
liveness.markClosing();
|
|
1721
1779
|
state.livePid = undefined;
|
|
1722
1780
|
if (terminated)
|
|
1723
1781
|
externalPending.clear();
|
|
@@ -1759,10 +1817,10 @@ async function openAcpSession(config, input) {
|
|
|
1759
1817
|
config,
|
|
1760
1818
|
connected,
|
|
1761
1819
|
sessionId,
|
|
1820
|
+
liveness,
|
|
1762
1821
|
linked,
|
|
1763
1822
|
externalPending,
|
|
1764
1823
|
state,
|
|
1765
|
-
ensureAlive,
|
|
1766
1824
|
stop
|
|
1767
1825
|
});
|
|
1768
1826
|
} catch (error) {
|