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
|
@@ -0,0 +1,432 @@
|
|
|
1
|
+
import {
|
|
2
|
+
computeSha256Hex,
|
|
3
|
+
isAbsoluteNormalPath,
|
|
4
|
+
sameHostPath,
|
|
5
|
+
createBaseServiceHostAdapter
|
|
6
|
+
} from "./index-d2drhb9c.js";
|
|
7
|
+
import {
|
|
8
|
+
errnoOf
|
|
9
|
+
} from "./index-jj9228tt.js";
|
|
10
|
+
|
|
11
|
+
// src/service-host/systemd-inspect.ts
|
|
12
|
+
import { readdir } from "node:fs/promises";
|
|
13
|
+
import { dirname, join, posix } from "node:path";
|
|
14
|
+
|
|
15
|
+
// src/service-host/systemd-render-shared.ts
|
|
16
|
+
import { z } from "zod";
|
|
17
|
+
var SystemdScopeSchema2 = z.enum(["system", "user"]);
|
|
18
|
+
|
|
19
|
+
class SystemdUnitError2 extends Error {
|
|
20
|
+
code;
|
|
21
|
+
rolledBack;
|
|
22
|
+
rollbackError;
|
|
23
|
+
foreignDropIns;
|
|
24
|
+
constructor(code, message, options) {
|
|
25
|
+
super(message, options);
|
|
26
|
+
this.name = "SystemdUnitError";
|
|
27
|
+
this.code = code;
|
|
28
|
+
this.rolledBack = options?.rolledBack ?? false;
|
|
29
|
+
this.rollbackError = options?.rollbackError;
|
|
30
|
+
this.foreignDropIns = options?.foreignDropIns;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
var OCTAL_MODE_PATTERN = /^[0-7]{3,4}$/;
|
|
34
|
+
var ENV_KEY_PATTERN = /^[A-Za-z_][A-Za-z0-9_]*$/;
|
|
35
|
+
var EXEC_PREFIX = /^[-@:+!]/;
|
|
36
|
+
var EXEC_PREFIX_MESSAGE = "the executable must not start with one of systemd's prefixes (-, @, :, +, !): quoting does not disarm them";
|
|
37
|
+
var SYSTEMD_TIMESPAN_UNIT = "(?:usec|us|msec|ms|seconds|second|sec|s|minutes|minute|min|m|hours|hour|hr|h|days|day|d|weeks|week|w|months|month|M|years|year|y)";
|
|
38
|
+
var SYSTEMD_TIMESPAN_PATTERN = new RegExp(`^\\d+(?:\\.\\d+)?${SYSTEMD_TIMESPAN_UNIT}?(?:\\s+\\d+(?:\\.\\d+)?${SYSTEMD_TIMESPAN_UNIT}?)*$`);
|
|
39
|
+
var SYSTEMD_SIGNAL_PATTERN = /^(?:SIG)?(?:HUP|INT|QUIT|ILL|TRAP|ABRT|BUS|FPE|KILL|USR1|SEGV|USR2|PIPE|ALRM|TERM|CHLD|CONT|STOP|TSTP|TTIN|TTOU|URG|XCPU|XFSZ|VTALRM|PROF|WINCH|IO|PWR|SYS)$/;
|
|
40
|
+
var MAX_SYSTEMD_INTERVAL_SECONDS = 18446744073708;
|
|
41
|
+
var SystemdIntervalSecondsSchema = z.number().finite().nonnegative().max(MAX_SYSTEMD_INTERVAL_SECONDS);
|
|
42
|
+
var SystemdTimespanSchema = z.union([
|
|
43
|
+
SystemdIntervalSecondsSchema,
|
|
44
|
+
z.string().regex(SYSTEMD_TIMESPAN_PATTERN, "must be a valid systemd timespan")
|
|
45
|
+
]);
|
|
46
|
+
var SystemdTimeoutSchema = z.union([
|
|
47
|
+
SystemdIntervalSecondsSchema,
|
|
48
|
+
z.literal("infinity"),
|
|
49
|
+
z.string().regex(SYSTEMD_TIMESPAN_PATTERN, 'must be a valid systemd timespan or "infinity"')
|
|
50
|
+
]);
|
|
51
|
+
var SystemdBindReadOnlyPathSchema = z.union([
|
|
52
|
+
z.string().min(1),
|
|
53
|
+
z.strictObject({
|
|
54
|
+
source: z.string().min(1),
|
|
55
|
+
target: z.string().min(1).optional(),
|
|
56
|
+
ignoreMissing: z.boolean().optional()
|
|
57
|
+
})
|
|
58
|
+
]);
|
|
59
|
+
var SystemdSuccessExitStatusItemSchema = z.union([
|
|
60
|
+
z.number().int().min(0).max(255),
|
|
61
|
+
z.string().regex(SYSTEMD_SIGNAL_PATTERN, "must be an exit code 0..255 or POSIX signal name")
|
|
62
|
+
]);
|
|
63
|
+
var SystemdAddressFamilySchema = z.union([
|
|
64
|
+
z.literal("none"),
|
|
65
|
+
z.string().regex(/^AF_[A-Z0-9_]+$/, 'must be "none" or an AF_* address family')
|
|
66
|
+
]);
|
|
67
|
+
function hasLineBreakOrNul(value) {
|
|
68
|
+
return value.includes(`
|
|
69
|
+
`) || value.includes("\r") || value.includes("\x00");
|
|
70
|
+
}
|
|
71
|
+
function assertCleanValue(field, value) {
|
|
72
|
+
if (hasLineBreakOrNul(value)) {
|
|
73
|
+
throw new SystemdUnitError2("INVALID_CONFIG", `Systemd field '${field}' must not contain newline, carriage return, or NUL characters`);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
function assertNoWhitespace(field, value) {
|
|
77
|
+
if (/\s/.test(value)) {
|
|
78
|
+
throw new SystemdUnitError2("INVALID_CONFIG", `Systemd field '${field}' must not contain whitespace: ${JSON.stringify(value)}`);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
function escapeSystemdSpecifiers(value, allowHomeSpecifier) {
|
|
82
|
+
if (!allowHomeSpecifier)
|
|
83
|
+
return value.replaceAll("%", "%%");
|
|
84
|
+
let result = "";
|
|
85
|
+
for (let index = 0;index < value.length; index += 1) {
|
|
86
|
+
const ch = value[index];
|
|
87
|
+
if (ch === "%") {
|
|
88
|
+
const next = value[index + 1];
|
|
89
|
+
if (next === "%") {
|
|
90
|
+
result += "%%%%";
|
|
91
|
+
index += 1;
|
|
92
|
+
} else if (next === "h") {
|
|
93
|
+
result += "%h";
|
|
94
|
+
index += 1;
|
|
95
|
+
} else {
|
|
96
|
+
result += "%%";
|
|
97
|
+
}
|
|
98
|
+
} else {
|
|
99
|
+
result += ch;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
return result;
|
|
103
|
+
}
|
|
104
|
+
function formatSystemdExecToken(field, token, allowHomeSpecifier) {
|
|
105
|
+
assertCleanValue(field, token);
|
|
106
|
+
const specEscaped = escapeSystemdSpecifiers(token, allowHomeSpecifier);
|
|
107
|
+
const safeDollar = specEscaped.replaceAll("$", "$$$$");
|
|
108
|
+
const needsQuotes = token.length === 0 || /[\s"'\\;]/.test(token);
|
|
109
|
+
if (!needsQuotes)
|
|
110
|
+
return safeDollar;
|
|
111
|
+
const quoted = safeDollar.replaceAll("\\", "\\\\").replaceAll('"', "\\\"");
|
|
112
|
+
return `"${quoted}"`;
|
|
113
|
+
}
|
|
114
|
+
function formatSystemdExecLine(field, argv, allowHomeSpecifier) {
|
|
115
|
+
return argv.map((token, index) => formatSystemdExecToken(`${field}[${index}]`, token, allowHomeSpecifier)).join(" ");
|
|
116
|
+
}
|
|
117
|
+
function formatSystemdEnvironmentLine(key, value, allowHomeSpecifier) {
|
|
118
|
+
if (!ENV_KEY_PATTERN.test(key)) {
|
|
119
|
+
throw new SystemdUnitError2("INVALID_CONFIG", `Invalid systemd environment variable name: ${JSON.stringify(key)}`);
|
|
120
|
+
}
|
|
121
|
+
assertCleanValue(`environment.${key}`, value);
|
|
122
|
+
const specEscaped = escapeSystemdSpecifiers(value, allowHomeSpecifier);
|
|
123
|
+
const quoted = specEscaped.replaceAll("\\", "\\\\").replaceAll('"', "\\\"");
|
|
124
|
+
return `Environment="${key}=${quoted}"`;
|
|
125
|
+
}
|
|
126
|
+
function formatSystemdScalar(field, value, allowHomeSpecifier, forbidWhitespace = false) {
|
|
127
|
+
assertCleanValue(field, value);
|
|
128
|
+
if (value.endsWith("\\")) {
|
|
129
|
+
throw new SystemdUnitError2("INVALID_CONFIG", `Systemd field '${field}' must not end with a trailing backslash (line continuation)`);
|
|
130
|
+
}
|
|
131
|
+
if (forbidWhitespace)
|
|
132
|
+
assertNoWhitespace(field, value);
|
|
133
|
+
return escapeSystemdSpecifiers(value, allowHomeSpecifier);
|
|
134
|
+
}
|
|
135
|
+
function formatSystemdNumber(value) {
|
|
136
|
+
if (Number.isInteger(value))
|
|
137
|
+
return String(value);
|
|
138
|
+
if (value > 0 && value < 0.000001) {
|
|
139
|
+
throw new SystemdUnitError2("INVALID_CONFIG", `Systemd numeric duration ${value} is below microsecond precision and would round to 0`);
|
|
140
|
+
}
|
|
141
|
+
return value.toFixed(6).replace(/\.?0+$/, "");
|
|
142
|
+
}
|
|
143
|
+
function formatSystemdDuration(field, value, forbidWhitespace = false) {
|
|
144
|
+
if (typeof value === "number")
|
|
145
|
+
return formatSystemdNumber(value);
|
|
146
|
+
return formatSystemdScalar(field, value, false, forbidWhitespace);
|
|
147
|
+
}
|
|
148
|
+
function toStringList(value) {
|
|
149
|
+
if (value === undefined)
|
|
150
|
+
return [];
|
|
151
|
+
return typeof value === "string" ? [value] : value;
|
|
152
|
+
}
|
|
153
|
+
function formatRelativeManagedDirectory(field, value) {
|
|
154
|
+
assertCleanValue(field, value);
|
|
155
|
+
assertNoWhitespace(field, value);
|
|
156
|
+
if (value.startsWith("/") || value.endsWith("\\") || value.includes(":") || value.includes("\\") || value.split("/").some((seg) => seg === "" || seg === "." || seg === "..")) {
|
|
157
|
+
throw new SystemdUnitError2("INVALID_CONFIG", `Systemd field '${field}' must be a relative normal directory name without ':', whitespace, or '..': ${JSON.stringify(value)}`);
|
|
158
|
+
}
|
|
159
|
+
return escapeSystemdSpecifiers(value, false);
|
|
160
|
+
}
|
|
161
|
+
var BIND_FORBIDDEN_CHARS = /[\s:"'\\]/;
|
|
162
|
+
function assertBindPathSegment(field, path) {
|
|
163
|
+
assertCleanValue(field, path);
|
|
164
|
+
if (!isAbsoluteNormalPath(path) || BIND_FORBIDDEN_CHARS.test(path)) {
|
|
165
|
+
throw new SystemdUnitError2("INVALID_CONFIG", `Systemd field '${field}' must be an absolute normal path without whitespace, ':', quotes, or backslashes: ${JSON.stringify(path)}`);
|
|
166
|
+
}
|
|
167
|
+
return escapeSystemdSpecifiers(path, false);
|
|
168
|
+
}
|
|
169
|
+
function formatBindReadOnlyPath(field, entry) {
|
|
170
|
+
if (typeof entry === "string") {
|
|
171
|
+
return assertBindPathSegment(field, entry);
|
|
172
|
+
}
|
|
173
|
+
const source = assertBindPathSegment(`${field}.source`, entry.source);
|
|
174
|
+
const target = entry.target !== undefined ? `:${assertBindPathSegment(`${field}.target`, entry.target)}` : "";
|
|
175
|
+
return `${entry.ignoreMissing ? "-" : ""}${source}${target}`;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
// src/service-host/systemd-inspect.ts
|
|
179
|
+
var DEFAULT_SYSTEMD_UNIT_MODE = 420;
|
|
180
|
+
var SYSTEMCTL_PATH = "/usr/bin/systemctl";
|
|
181
|
+
var SHOW_PROPERTIES = "LoadState,FragmentPath,DropInPaths,ActiveState,SubState,MainPID,UnitFileState,NeedDaemonReload";
|
|
182
|
+
var SHA256_HEX_PATTERN = /^[0-9a-f]{64}$/;
|
|
183
|
+
function createDefaultSystemdHostAdapter2() {
|
|
184
|
+
return {
|
|
185
|
+
...createBaseServiceHostAdapter({
|
|
186
|
+
defaultFileMode: DEFAULT_SYSTEMD_UNIT_MODE,
|
|
187
|
+
nullOnNonRegularFile: true
|
|
188
|
+
}),
|
|
189
|
+
async listDir(path) {
|
|
190
|
+
try {
|
|
191
|
+
return await readdir(path);
|
|
192
|
+
} catch (cause) {
|
|
193
|
+
if (errnoOf(cause) === "ENOENT")
|
|
194
|
+
return null;
|
|
195
|
+
throw cause;
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
function hasAsciiControlChar(value) {
|
|
201
|
+
for (let index = 0;index < value.length; index += 1) {
|
|
202
|
+
const code = value.charCodeAt(index);
|
|
203
|
+
if (code <= 31 || code === 127)
|
|
204
|
+
return true;
|
|
205
|
+
}
|
|
206
|
+
return false;
|
|
207
|
+
}
|
|
208
|
+
function assertValidSystemdUnitName(unitName) {
|
|
209
|
+
if (unitName.length === 0 || unitName === "." || unitName.startsWith("-") || unitName.includes("/") || unitName.includes("\\") || unitName.includes("..") || /\s/.test(unitName) || hasAsciiControlChar(unitName)) {
|
|
210
|
+
throw new SystemdUnitError2("INVALID_CONFIG", `Invalid systemd unit name: ${JSON.stringify(unitName)}`);
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
function assertSystemdUnitPath(unitPath) {
|
|
214
|
+
if (!isAbsoluteNormalPath(unitPath)) {
|
|
215
|
+
throw new SystemdUnitError2("INVALID_CONFIG", `Unit path must be an absolute, normal path without NUL bytes: ${JSON.stringify(unitPath)}`);
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
function systemdScopeArgs(scope, args) {
|
|
219
|
+
const parsed = SystemdScopeSchema2.parse(scope);
|
|
220
|
+
return parsed === "user" ? ["--user", ...args] : [...args];
|
|
221
|
+
}
|
|
222
|
+
function parseSystemdProperties(stdout) {
|
|
223
|
+
const map = new Map;
|
|
224
|
+
for (const rawLine of stdout.split(`
|
|
225
|
+
`)) {
|
|
226
|
+
const line = rawLine.trimEnd();
|
|
227
|
+
const eq = line.indexOf("=");
|
|
228
|
+
if (eq <= 0)
|
|
229
|
+
continue;
|
|
230
|
+
map.set(line.slice(0, eq), line.slice(eq + 1));
|
|
231
|
+
}
|
|
232
|
+
return map;
|
|
233
|
+
}
|
|
234
|
+
function parseMainPid(raw) {
|
|
235
|
+
if (!raw)
|
|
236
|
+
return null;
|
|
237
|
+
const trimmed = raw.trim();
|
|
238
|
+
if (!/^\d+$/.test(trimmed))
|
|
239
|
+
return null;
|
|
240
|
+
const pid = Number(trimmed);
|
|
241
|
+
return Number.isSafeInteger(pid) && pid > 0 ? pid : null;
|
|
242
|
+
}
|
|
243
|
+
function parseUnitPathDirs(stdout) {
|
|
244
|
+
const trimmed = stdout.trim();
|
|
245
|
+
if (trimmed.length === 0)
|
|
246
|
+
return [];
|
|
247
|
+
const raw = trimmed.startsWith("UnitPath=") ? trimmed.slice("UnitPath=".length) : trimmed;
|
|
248
|
+
return raw.split(/\s+/).map((entry) => entry.trim()).filter((entry) => entry.startsWith("/"));
|
|
249
|
+
}
|
|
250
|
+
function normalizePosixDir(dir) {
|
|
251
|
+
const normalized = posix.normalize(dir);
|
|
252
|
+
return normalized.length > 1 && normalized.endsWith("/") ? normalized.slice(0, -1) : normalized;
|
|
253
|
+
}
|
|
254
|
+
function isAllowedHostServiceDropIn(unitName, dropInPath, trustedSearchDirs) {
|
|
255
|
+
if (!unitName.endsWith(".service"))
|
|
256
|
+
return false;
|
|
257
|
+
if (!dropInPath.startsWith("/"))
|
|
258
|
+
return false;
|
|
259
|
+
if (dropInPath.includes(".."))
|
|
260
|
+
return false;
|
|
261
|
+
if (posix.normalize(dropInPath) !== dropInPath)
|
|
262
|
+
return false;
|
|
263
|
+
if (!dropInPath.endsWith(".conf"))
|
|
264
|
+
return false;
|
|
265
|
+
const parentDir = posix.dirname(dropInPath);
|
|
266
|
+
if (posix.basename(parentDir) !== "service.d")
|
|
267
|
+
return false;
|
|
268
|
+
const grandParentDir = posix.dirname(parentDir);
|
|
269
|
+
return trustedSearchDirs.has(grandParentDir);
|
|
270
|
+
}
|
|
271
|
+
function templateUnitNameOf(unitName) {
|
|
272
|
+
const atIndex = unitName.indexOf("@");
|
|
273
|
+
if (atIndex <= 0)
|
|
274
|
+
return null;
|
|
275
|
+
const dotIndex = unitName.lastIndexOf(".");
|
|
276
|
+
if (dotIndex <= atIndex + 1)
|
|
277
|
+
return null;
|
|
278
|
+
return `${unitName.slice(0, atIndex + 1)}${unitName.slice(dotIndex)}`;
|
|
279
|
+
}
|
|
280
|
+
async function resolveUnitSearchDirs(unitPath, scope, extraSearchDirs, adapter) {
|
|
281
|
+
const searchDirs = new Set([
|
|
282
|
+
dirname(unitPath),
|
|
283
|
+
dirname(await adapter.canonicalPath(unitPath))
|
|
284
|
+
]);
|
|
285
|
+
const unitPathResult = await adapter.runCommand(SYSTEMCTL_PATH, systemdScopeArgs(scope, ["show", "--no-pager", "--property=UnitPath", "--value"]));
|
|
286
|
+
if (unitPathResult.exitCode !== 0) {
|
|
287
|
+
throw new SystemdUnitError2("COMMAND_FAILED", `systemctl show --property=UnitPath failed (exit ${unitPathResult.exitCode}): ${unitPathResult.stderr.trim()}`);
|
|
288
|
+
}
|
|
289
|
+
const managerDirs = parseUnitPathDirs(unitPathResult.stdout);
|
|
290
|
+
if (managerDirs.length > 0) {
|
|
291
|
+
for (const dir of managerDirs)
|
|
292
|
+
searchDirs.add(dir);
|
|
293
|
+
} else if (scope === "system") {
|
|
294
|
+
searchDirs.add("/etc/systemd/system");
|
|
295
|
+
searchDirs.add("/run/systemd/system");
|
|
296
|
+
}
|
|
297
|
+
for (const dir of extraSearchDirs ?? [])
|
|
298
|
+
searchDirs.add(dir);
|
|
299
|
+
return [...searchDirs];
|
|
300
|
+
}
|
|
301
|
+
async function collectForeignDropIns(unitName, unitPath, scope, dropInPathsProp, extraSearchDirs, adapter) {
|
|
302
|
+
const searchDirs = await resolveUnitSearchDirs(unitPath, scope, extraSearchDirs, adapter);
|
|
303
|
+
const trustedSearchDirs = new Set(searchDirs.map(normalizePosixDir));
|
|
304
|
+
const found = new Set;
|
|
305
|
+
if (dropInPathsProp) {
|
|
306
|
+
for (const token of dropInPathsProp.trim().split(/\s+/)) {
|
|
307
|
+
if (token.length === 0)
|
|
308
|
+
continue;
|
|
309
|
+
if (isAllowedHostServiceDropIn(unitName, token, trustedSearchDirs))
|
|
310
|
+
continue;
|
|
311
|
+
found.add(token);
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
const templateUnitName = templateUnitNameOf(unitName);
|
|
315
|
+
const dropInDirNames = templateUnitName !== null ? [`${unitName}.d`, `${templateUnitName}.d`] : [`${unitName}.d`];
|
|
316
|
+
for (const dir of searchDirs) {
|
|
317
|
+
for (const dropInDirName of dropInDirNames) {
|
|
318
|
+
const dropInDir = join(dir, dropInDirName);
|
|
319
|
+
const entries = await adapter.listDir(dropInDir);
|
|
320
|
+
if (!entries)
|
|
321
|
+
continue;
|
|
322
|
+
for (const entry of entries) {
|
|
323
|
+
if (entry.endsWith(".conf"))
|
|
324
|
+
found.add(join(dropInDir, entry));
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
return [...found].sort();
|
|
329
|
+
}
|
|
330
|
+
function foreignUnitSource(check, unitPath) {
|
|
331
|
+
if (check.loadState === "masked")
|
|
332
|
+
return "the unit is masked";
|
|
333
|
+
if (check.loadState === "not-found" || check.fragmentIsUnitPath)
|
|
334
|
+
return;
|
|
335
|
+
if (check.loadState === null)
|
|
336
|
+
return "systemctl show reported no LoadState";
|
|
337
|
+
if (check.fragmentPath === null) {
|
|
338
|
+
return `systemd has it ${check.loadState} with no unit file`;
|
|
339
|
+
}
|
|
340
|
+
return `systemd loads it from ${check.fragmentPath}, not ${unitPath}`;
|
|
341
|
+
}
|
|
342
|
+
function resolveExpectedDigest(options) {
|
|
343
|
+
const hasContent = options.expectedContent !== undefined;
|
|
344
|
+
const hasDigest = options.expectedDigest !== undefined;
|
|
345
|
+
if (hasContent === hasDigest) {
|
|
346
|
+
throw new SystemdUnitError2("INVALID_CONFIG", "checkSystemdUnit requires exactly one of expectedContent or expectedDigest");
|
|
347
|
+
}
|
|
348
|
+
if (options.expectedDigest !== undefined) {
|
|
349
|
+
if (!SHA256_HEX_PATTERN.test(options.expectedDigest)) {
|
|
350
|
+
throw new SystemdUnitError2("INVALID_CONFIG", `Invalid expectedDigest: expected 64 lowercase hex characters, got ${JSON.stringify(options.expectedDigest)}`);
|
|
351
|
+
}
|
|
352
|
+
return options.expectedDigest;
|
|
353
|
+
}
|
|
354
|
+
return computeSha256Hex(options.expectedContent ?? "");
|
|
355
|
+
}
|
|
356
|
+
async function checkSystemdUnit2(options) {
|
|
357
|
+
assertValidSystemdUnitName(options.unitName);
|
|
358
|
+
assertSystemdUnitPath(options.unitPath);
|
|
359
|
+
const expectedDigest = resolveExpectedDigest(options);
|
|
360
|
+
const adapter = options.adapter ?? createDefaultSystemdHostAdapter2();
|
|
361
|
+
const existingBytes = await adapter.readFile(options.unitPath);
|
|
362
|
+
const actualDigest = existingBytes === null ? null : computeSha256Hex(existingBytes);
|
|
363
|
+
const showResult = await adapter.runCommand(SYSTEMCTL_PATH, systemdScopeArgs(options.scope, [
|
|
364
|
+
"show",
|
|
365
|
+
"--no-pager",
|
|
366
|
+
`--property=${SHOW_PROPERTIES}`,
|
|
367
|
+
"--",
|
|
368
|
+
options.unitName
|
|
369
|
+
]));
|
|
370
|
+
if (showResult.exitCode !== 0) {
|
|
371
|
+
throw new SystemdUnitError2("COMMAND_FAILED", `systemctl show failed for ${options.unitName} (exit ${showResult.exitCode}): ${showResult.stderr.trim()}`);
|
|
372
|
+
}
|
|
373
|
+
const props = parseSystemdProperties(showResult.stdout);
|
|
374
|
+
const loadState = props.get("LoadState") || null;
|
|
375
|
+
const fragmentPath = props.get("FragmentPath") || null;
|
|
376
|
+
const fragmentIsUnitPath = fragmentPath !== null && await sameHostPath(adapter, fragmentPath, options.unitPath);
|
|
377
|
+
const activeState = props.get("ActiveState") || null;
|
|
378
|
+
const mainPid = parseMainPid(props.get("MainPID"));
|
|
379
|
+
const unitFileState = props.get("UnitFileState") || null;
|
|
380
|
+
const needsReload = props.get("NeedDaemonReload") === "yes";
|
|
381
|
+
const foreignDropIns = await collectForeignDropIns(options.unitName, options.unitPath, options.scope, props.get("DropInPaths"), options.unitSearchDirs, adapter);
|
|
382
|
+
let status;
|
|
383
|
+
if (foreignDropIns.length > 0)
|
|
384
|
+
status = "foreign-drop-in";
|
|
385
|
+
else if (loadState === "masked")
|
|
386
|
+
status = "fragment-mismatch";
|
|
387
|
+
else if (actualDigest === null) {
|
|
388
|
+
status = foreignUnitSource({ loadState, fragmentPath, fragmentIsUnitPath }, options.unitPath) === undefined ? "missing" : "fragment-mismatch";
|
|
389
|
+
} else if (actualDigest !== expectedDigest)
|
|
390
|
+
status = "digest-mismatch";
|
|
391
|
+
else if (loadState !== "loaded" || !fragmentIsUnitPath) {
|
|
392
|
+
status = "fragment-mismatch";
|
|
393
|
+
} else
|
|
394
|
+
status = "matches";
|
|
395
|
+
return {
|
|
396
|
+
ok: status === "matches",
|
|
397
|
+
status,
|
|
398
|
+
expectedDigest,
|
|
399
|
+
actualDigest,
|
|
400
|
+
loadState,
|
|
401
|
+
fragmentPath,
|
|
402
|
+
fragmentIsUnitPath,
|
|
403
|
+
foreignDropIns,
|
|
404
|
+
activeState,
|
|
405
|
+
mainPid,
|
|
406
|
+
unitFileState,
|
|
407
|
+
needsReload
|
|
408
|
+
};
|
|
409
|
+
}
|
|
410
|
+
async function systemdUnitActive2(options) {
|
|
411
|
+
assertValidSystemdUnitName(options.unitName);
|
|
412
|
+
const adapter = options.adapter ?? createDefaultSystemdHostAdapter2();
|
|
413
|
+
const result = await adapter.runCommand(SYSTEMCTL_PATH, systemdScopeArgs(options.scope, ["is-active", "--", options.unitName]));
|
|
414
|
+
return result.exitCode === 0 && result.stdout.trim() === "active";
|
|
415
|
+
}
|
|
416
|
+
async function systemdMainPid2(options) {
|
|
417
|
+
assertValidSystemdUnitName(options.unitName);
|
|
418
|
+
const adapter = options.adapter ?? createDefaultSystemdHostAdapter2();
|
|
419
|
+
const result = await adapter.runCommand(SYSTEMCTL_PATH, systemdScopeArgs(options.scope, [
|
|
420
|
+
"show",
|
|
421
|
+
"--no-pager",
|
|
422
|
+
"--property=MainPID",
|
|
423
|
+
"--value",
|
|
424
|
+
"--",
|
|
425
|
+
options.unitName
|
|
426
|
+
]));
|
|
427
|
+
if (result.exitCode !== 0)
|
|
428
|
+
return null;
|
|
429
|
+
return parseMainPid(result.stdout);
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
export { SystemdScopeSchema2, SystemdUnitError2, OCTAL_MODE_PATTERN, EXEC_PREFIX, EXEC_PREFIX_MESSAGE, SystemdTimespanSchema, SystemdTimeoutSchema, SystemdBindReadOnlyPathSchema, SystemdSuccessExitStatusItemSchema, SystemdAddressFamilySchema, assertCleanValue, formatSystemdExecLine, formatSystemdEnvironmentLine, formatSystemdScalar, formatSystemdDuration, toStringList, formatRelativeManagedDirectory, formatBindReadOnlyPath, DEFAULT_SYSTEMD_UNIT_MODE, SYSTEMCTL_PATH, createDefaultSystemdHostAdapter2, assertValidSystemdUnitName, assertSystemdUnitPath, systemdScopeArgs, resolveUnitSearchDirs, foreignUnitSource, checkSystemdUnit2, systemdUnitActive2, systemdMainPid2 };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
validateDeclaredOutput
|
|
3
|
-
} from "./index-
|
|
3
|
+
} from "./index-78da4g74.js";
|
|
4
4
|
import {
|
|
5
5
|
HELP_SHOWN_KEYWORDS,
|
|
6
6
|
STANDARD_STRING_FORMATS
|
|
@@ -15,7 +15,7 @@ import {
|
|
|
15
15
|
assertUniqueToolName,
|
|
16
16
|
buildToolPresentationSchema,
|
|
17
17
|
projectedContractToolName
|
|
18
|
-
} from "./index-
|
|
18
|
+
} from "./index-ma26mfnt.js";
|
|
19
19
|
import {
|
|
20
20
|
unwrapZodWrappers,
|
|
21
21
|
objectShapeKeys,
|
|
@@ -34,11 +34,11 @@ import {
|
|
|
34
34
|
toolResultFromError,
|
|
35
35
|
toolErrorFromResult,
|
|
36
36
|
toolCauseFromResult
|
|
37
|
-
} from "./index-
|
|
37
|
+
} from "./index-6kmjcm81.js";
|
|
38
38
|
import {
|
|
39
39
|
createToolRunner,
|
|
40
40
|
formatToolError
|
|
41
|
-
} from "./index-
|
|
41
|
+
} from "./index-5n3a8hd8.js";
|
|
42
42
|
import {
|
|
43
43
|
isRepeatableRead
|
|
44
44
|
} from "./index-0x4mnwg5.js";
|
|
@@ -50,7 +50,7 @@ import {
|
|
|
50
50
|
import {
|
|
51
51
|
readContractStreamItems,
|
|
52
52
|
contractStreamLifetimeExceeded
|
|
53
|
-
} from "./index-
|
|
53
|
+
} from "./index-yrhw10ef.js";
|
|
54
54
|
import {
|
|
55
55
|
writeContainedFile
|
|
56
56
|
} from "./index-rjs94dny.js";
|
|
@@ -74,7 +74,7 @@ import {
|
|
|
74
74
|
} from "./index-n20tybgk.js";
|
|
75
75
|
import {
|
|
76
76
|
collectToolSurface
|
|
77
|
-
} from "./index-
|
|
77
|
+
} from "./index-q427q23r.js";
|
|
78
78
|
import {
|
|
79
79
|
assertNoLegacyTransports
|
|
80
80
|
} from "./index-akfgymyr.js";
|
|
@@ -95,7 +95,7 @@ import {
|
|
|
95
95
|
import {
|
|
96
96
|
AppError2,
|
|
97
97
|
STITCH_ERROR_STATUS2
|
|
98
|
-
} from "./index-
|
|
98
|
+
} from "./index-7fjbdga8.js";
|
|
99
99
|
import {
|
|
100
100
|
assertPositiveSafeInteger
|
|
101
101
|
} from "./index-gr0kxymw.js";
|
|
@@ -1434,6 +1434,7 @@ function collectCliStreams(services) {
|
|
|
1434
1434
|
paramsSchema: method.paramsSchema,
|
|
1435
1435
|
inputSchema: method.inputSchema,
|
|
1436
1436
|
inputRecursionDepth: method.inputRecursionDepth,
|
|
1437
|
+
inputNestingDepth: method.inputNestingDepth,
|
|
1437
1438
|
unrepresentable: "any"
|
|
1438
1439
|
}),
|
|
1439
1440
|
shouldExtend: false
|
|
@@ -6,12 +6,19 @@ import {
|
|
|
6
6
|
nonEmptyString,
|
|
7
7
|
clampPlanName,
|
|
8
8
|
epochSecondsToIso,
|
|
9
|
+
offerTurnDelta,
|
|
9
10
|
safeJsonValue,
|
|
10
11
|
clampUniqueWindowName
|
|
11
|
-
} from "./index-
|
|
12
|
+
} from "./index-stpy56r3.js";
|
|
12
13
|
import {
|
|
13
14
|
isSupportedImageMediaType
|
|
14
15
|
} from "./index-y0a4gt1s.js";
|
|
16
|
+
import {
|
|
17
|
+
endEngineTurn
|
|
18
|
+
} from "./index-qggqqja2.js";
|
|
19
|
+
import {
|
|
20
|
+
mergeRateLimitEvent2
|
|
21
|
+
} from "./index-g5fgeb6v.js";
|
|
15
22
|
import {
|
|
16
23
|
errnoOf
|
|
17
24
|
} from "./index-jj9228tt.js";
|
|
@@ -1171,6 +1178,46 @@ function claudePlanWindows2(info) {
|
|
|
1171
1178
|
return [];
|
|
1172
1179
|
}
|
|
1173
1180
|
|
|
1181
|
+
// src/agent-executor/claude/record-router.ts
|
|
1182
|
+
function routeClaudeRecord(record, route) {
|
|
1183
|
+
const { turn } = route;
|
|
1184
|
+
const verdict = classifyClaudeRecord(record, turn?.state ?? newClaudeTurnState("between-turns"));
|
|
1185
|
+
switch (verdict.kind) {
|
|
1186
|
+
case "limits":
|
|
1187
|
+
route.limits.set(route.profileId, mergeRateLimitEvent2({
|
|
1188
|
+
previous: route.limits.get(route.profileId),
|
|
1189
|
+
windows: claudePlanWindows2(verdict.info),
|
|
1190
|
+
now: new Date
|
|
1191
|
+
}));
|
|
1192
|
+
return;
|
|
1193
|
+
case "deltas":
|
|
1194
|
+
for (const delta of verdict.deltas)
|
|
1195
|
+
offerTurnDelta(turn?.channel, delta);
|
|
1196
|
+
return;
|
|
1197
|
+
case "request":
|
|
1198
|
+
route.onRequest?.(turn, verdict);
|
|
1199
|
+
return;
|
|
1200
|
+
case "unhandled":
|
|
1201
|
+
offerTurnDelta(turn?.channel, verdict.delta);
|
|
1202
|
+
if (verdict.refuse !== undefined)
|
|
1203
|
+
route.onRefuse?.(verdict.refuse);
|
|
1204
|
+
return;
|
|
1205
|
+
case "end":
|
|
1206
|
+
route.onEnd?.(turn, verdict);
|
|
1207
|
+
endEngineTurn(turn, route.ended, verdict.deltas);
|
|
1208
|
+
route.clearTurn(turn);
|
|
1209
|
+
return;
|
|
1210
|
+
case "event":
|
|
1211
|
+
route.onEvent?.(verdict.event);
|
|
1212
|
+
return;
|
|
1213
|
+
case "session":
|
|
1214
|
+
route.onSession?.(verdict);
|
|
1215
|
+
return;
|
|
1216
|
+
case "ignore":
|
|
1217
|
+
return;
|
|
1218
|
+
}
|
|
1219
|
+
}
|
|
1220
|
+
|
|
1174
1221
|
// src/agent-executor/claude/transcript.ts
|
|
1175
1222
|
import { realpathSync } from "node:fs";
|
|
1176
1223
|
import { open } from "node:fs/promises";
|
|
@@ -1333,4 +1380,4 @@ async function findTranscriptInput2(engine, input, ambient) {
|
|
|
1333
1380
|
}), input.clientId);
|
|
1334
1381
|
}
|
|
1335
1382
|
|
|
1336
|
-
export { ClaudeTaskUsageSchema2, ClaudeRuntimeEventSchema2, claudeUserContent, claudeUserMessage, resolveClaudePermissionReply, claudePermissionResponse, claudeControlError, claudeInterrupt, newClaudeTurnState,
|
|
1383
|
+
export { ClaudeTaskUsageSchema2, ClaudeRuntimeEventSchema2, claudeUserContent, claudeUserMessage, resolveClaudePermissionReply, claudePermissionResponse, claudeControlError, claudeInterrupt, newClaudeTurnState, claudeUsagePlanLimits2, claudePlanWindows2, routeClaudeRecord, claudeTranscriptPath2, claudeTranscriptHasUuid2, claudeTranscriptExists, findTranscriptInput2 };
|