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
package/llms/process.txt
CHANGED
|
@@ -279,20 +279,21 @@ exit status, deadlines, cancellation and `onLeaderSettled` retain the requested
|
|
|
279
279
|
|
|
280
280
|
An unbundled application already launches the package's own guard module. A single-file bundle
|
|
281
281
|
whose application entry also owns argv routing must load the narrow bootstrap before its dispatcher
|
|
282
|
-
and skip dispatch when it claims
|
|
282
|
+
and skip dispatch when it claims a private package invocation. This is especially relevant when the
|
|
283
283
|
full command runner stays behind a dynamic import:
|
|
284
284
|
|
|
285
285
|
```ts
|
|
286
|
-
import {
|
|
286
|
+
import { bootstrapPackageProcess } from 'stitchkit/process/bootstrap'
|
|
287
287
|
|
|
288
|
-
if (!
|
|
288
|
+
if (!bootstrapPackageProcess()) {
|
|
289
289
|
await dispatch(process.argv.slice(2)) // may lazy-import `stitchkit/process`
|
|
290
290
|
}
|
|
291
291
|
```
|
|
292
292
|
|
|
293
|
-
The bootstrap carries the package-owned
|
|
294
|
-
|
|
295
|
-
|
|
293
|
+
The bootstrap carries the package-owned invocations into the bundle: the owner-loss guard, and the
|
|
294
|
+
process root of [work launched in its own boundary](#work-in-its-own-boundary). It returns `false`
|
|
295
|
+
for application argv and `true` only for a private invocation the package serves, so the
|
|
296
|
+
application does not read a flag or filename. The built file is self-contained; no installed `node_modules`
|
|
296
297
|
is needed beside it.
|
|
297
298
|
|
|
298
299
|
### Stopping a command: the `stop` policy
|
|
@@ -386,6 +387,129 @@ A command in the caller's group (`group: 'caller'`) has no group of its own: `de
|
|
|
386
387
|
refused there and nothing is stopped after its leader exits. A command whose group this package did not create (a structural
|
|
387
388
|
launcher supplied by a host) has no group to stop, and `descendants` has nothing to act on there.
|
|
388
389
|
|
|
390
|
+
## Work in its own boundary
|
|
391
|
+
|
|
392
|
+
A machine that runs many launchers ends up with one service holding a hundred processes and no
|
|
393
|
+
answer to "who started this one". `stitchkit/service-host/work` launches a command in a boundary
|
|
394
|
+
of its own and declares who owns it:
|
|
395
|
+
|
|
396
|
+
```ts
|
|
397
|
+
import { inheritedWork, launchWork } from 'stitchkit/service-host/work'
|
|
398
|
+
|
|
399
|
+
const launch = await launchWork({
|
|
400
|
+
owner: {
|
|
401
|
+
launcher: 'session-host', // your launcher's own name
|
|
402
|
+
id: session.id, // unique among your live work on this machine
|
|
403
|
+
label: session.title,
|
|
404
|
+
project: session.project, // or null
|
|
405
|
+
agent: session.agent, // { harness, model, address } or null
|
|
406
|
+
parent: await inheritedWork(), // the work this process itself runs in, or null
|
|
407
|
+
},
|
|
408
|
+
placement: { kind: 'transient-scope', manager: 'system', slice: 'caller' },
|
|
409
|
+
command: { executable, args, env, stdio: 'inherit', signal: shutdown.signal },
|
|
410
|
+
})
|
|
411
|
+
|
|
412
|
+
launch.unit // { manager: 'system', name: 'session-host-<id>.scope' }
|
|
413
|
+
launch.root // { pid, instance } — the process the work started as
|
|
414
|
+
await launch.stop() // ends the whole boundary
|
|
415
|
+
```
|
|
416
|
+
|
|
417
|
+
The owner record is yours to keep and to serve to whoever asks; the package gives its schema
|
|
418
|
+
(`WorkOwnerSchema`), the launch and the check. Every field of the record is answered: `project`,
|
|
419
|
+
`agent` and `parent` take `null` as a declared "none", and a missing field is refused.
|
|
420
|
+
|
|
421
|
+
### The variable names, the boundary proves
|
|
422
|
+
|
|
423
|
+
The launched command and everything it starts inherit one variable, `STITCHKIT_WORK_ORIGIN`: a
|
|
424
|
+
small JSON value with the work's reference (`launcher`, `id`) and its boundary. A process that
|
|
425
|
+
leaves the boundary keeps the variable, and anyone can set it, so it is only a claim.
|
|
426
|
+
`checkWorkMembership({ pid, boundary })` asks the boundary itself:
|
|
427
|
+
|
|
428
|
+
| answer | meaning |
|
|
429
|
+
|---|---|
|
|
430
|
+
| `{ state: 'member', via }` | the process is in the boundary; `via` names the evidence (`cgroup`, `root`, `process-group`, `ancestry`) |
|
|
431
|
+
| `{ state: 'outside', observed }` | it is not, with the control group or the group and parent chain that was seen instead |
|
|
432
|
+
| `{ state: 'gone' }` | there is no such process |
|
|
433
|
+
| `{ state: 'unavailable', reason, cause }` | the boundary could not be asked; never read this as `outside` |
|
|
434
|
+
|
|
435
|
+
`readWorkOrigin()` parses the variable of the current process (`null` when absent; a value that
|
|
436
|
+
does not parse throws `WorkLaunchError` with reason `origin-unreadable`). `inheritedWork()` returns
|
|
437
|
+
the reference only when the current process is proven to be inside the boundary the variable
|
|
438
|
+
names — that is what a nested launcher declares as `parent`.
|
|
439
|
+
|
|
440
|
+
To find the owner of an arbitrary process on Linux, read its control group, take the `*.scope`
|
|
441
|
+
component and compare it with `workUnitName(record)` of each launcher's records. The unit name is
|
|
442
|
+
`<launcher>-<id>.scope`; it is computed one way and never parsed back, because two different
|
|
443
|
+
owners can spell the same name.
|
|
444
|
+
|
|
445
|
+
### Placement
|
|
446
|
+
|
|
447
|
+
Placement is always written out; a host that cannot make the boundary you asked for throws
|
|
448
|
+
`WorkLaunchError` with a `reason`, and nothing is started as a plain child instead.
|
|
449
|
+
|
|
450
|
+
| placement | boundary | holds |
|
|
451
|
+
|---|---|---|
|
|
452
|
+
| `{ kind: 'transient-scope', manager, slice, limits? }` | a transient systemd scope (Linux, systemd 254 or newer, cgroup v2) | every descendant, including one that called `setsid` |
|
|
453
|
+
| `{ kind: 'process-root' }` | a recorded root process (Linux and macOS) | the root, the process group it leads, and processes whose parent chain reaches the live root |
|
|
454
|
+
|
|
455
|
+
For a scope:
|
|
456
|
+
|
|
457
|
+
- `manager` is `'system'` or `'user'`. The user manager is reached through `XDG_RUNTIME_DIR`, or
|
|
458
|
+
through `/run/user/<uid>` when that directory is the caller's own; otherwise the launch refuses
|
|
459
|
+
with `user-manager-unreachable`. The system manager takes scopes from root only: a non-root
|
|
460
|
+
caller is refused with `manager-unauthorized` before anything starts, because the system
|
|
461
|
+
manager may let it start a unit and then deny stopping it (polkit asks for interactive
|
|
462
|
+
authentication), which would leave work its launcher cannot end. Such a caller uses `'user'`.
|
|
463
|
+
- `slice: 'caller'` keeps the caller's own slice, and so the resource limits that slice carries; a
|
|
464
|
+
caller with no slice under that manager is refused with `slice-unresolvable`. Any other value
|
|
465
|
+
names a slice in full (`'build.slice'`).
|
|
466
|
+
- `limits` become properties of the unit: `memoryMaxMb`, `memorySwapMaxMb`, `cpuQuotaPercent`,
|
|
467
|
+
`cpuWeight` and `runtimeMaxSeconds`.
|
|
468
|
+
- The command's arguments arrive as written. `systemd-run` would otherwise expand `${VAR}` and `$$`
|
|
469
|
+
in them, so the scope is started with `--expand-environment=no`, an option systemd has since
|
|
470
|
+
version 254; an older systemd is refused with `systemd-too-old`.
|
|
471
|
+
- A launcher id that is still running refuses a second launch with `unit-exists`. The name is free
|
|
472
|
+
again once the scope has emptied and the manager has collected it.
|
|
473
|
+
- A scope is not part of its launcher's service: restarting the launcher's service leaves its
|
|
474
|
+
scopes running. Stop them with `launch.stop()` — or `systemctl stop <unit>` — when they must not
|
|
475
|
+
outlive it.
|
|
476
|
+
|
|
477
|
+
`probeWorkBoundary(placement)` answers `{ state: 'available' }` or `{ state: 'unavailable',
|
|
478
|
+
reason, cause }` without launching anything.
|
|
479
|
+
|
|
480
|
+
A process root has one stated limit: a descendant that left the group with `setsid` **and** lost
|
|
481
|
+
its parent is `outside`. A scope would still hold it. Use a process root where there is no
|
|
482
|
+
transient scope — macOS, or a Linux host without systemd — and name it yourself: the package never
|
|
483
|
+
substitutes one boundary for the other. The root is a package-owned entry that measures its own
|
|
484
|
+
process instance, writes it into the variable and replaces itself with your command through
|
|
485
|
+
`process.execve`, so the root pid is your command's pid; the runtime must provide `process.execve`.
|
|
486
|
+
A single-file bundle carries that entry through
|
|
487
|
+
[`bootstrapPackageProcess()`](#commands).
|
|
488
|
+
|
|
489
|
+
### When another program does the spawning
|
|
490
|
+
|
|
491
|
+
A terminal multiplexer, a remote shell or another supervisor starts the command itself. Hand it
|
|
492
|
+
the wrapped command instead:
|
|
493
|
+
|
|
494
|
+
```ts
|
|
495
|
+
import { workCommand } from 'stitchkit/service-host/work'
|
|
496
|
+
|
|
497
|
+
const placed = await workCommand({ owner, placement, executable, args, env })
|
|
498
|
+
// placed.executable, placed.args, placed.env — run exactly these
|
|
499
|
+
```
|
|
500
|
+
|
|
501
|
+
`env` is written out (`{}` for none): the result extends it with `STITCHKIT_WORK_ORIGIN`, and for
|
|
502
|
+
the user manager with `XDG_RUNTIME_DIR`. A bare executable name is found on the `PATH` the command
|
|
503
|
+
is given.
|
|
504
|
+
|
|
505
|
+
### What the launch's own signal stops
|
|
506
|
+
|
|
507
|
+
`command` takes the options of `runNativeCommand` except `group`, `ownerLoss` and
|
|
508
|
+
`onLeaderStarted`. Its `signal`, `timeoutMs` and `stop` policy act on the root's process group, as
|
|
509
|
+
they do for any command; `launch.stop()` ends the whole boundary — for a scope, through the
|
|
510
|
+
manager, which also ends processes that left the group. `launch.result` settles like
|
|
511
|
+
`runNativeCommand`.
|
|
512
|
+
|
|
389
513
|
## A contract operation in a process of its own
|
|
390
514
|
|
|
391
515
|
A handler that reads gigabytes holds the server's event loop while it reads, and every cheap
|
|
@@ -587,89 +711,3 @@ in the same process share the descriptor table, so a hold any of them takes is n
|
|
|
587
711
|
The check counts only when `/dev/fd` lists the descriptor it opens itself; a listing it cannot
|
|
588
712
|
prove complete means "unknown", which never reclaims. A replaced image of another process is
|
|
589
713
|
still judged alive.
|
|
590
|
-
|
|
591
|
-
## Libraries with a Zod-only runtime
|
|
592
|
-
|
|
593
|
-
Public leaves keep optional peers out of their import closure. Installing `stitchkit` still
|
|
594
|
-
installs the complete package and ky; selective imports alone do not avoid that installation.
|
|
595
|
-
A library can use Stitchkit as a build dependency, bundle its selected public native imports,
|
|
596
|
-
keep Zod external, and publish the resulting implementation with its library artifact.
|
|
597
|
-
|
|
598
|
-
```ts
|
|
599
|
-
// The library's build entry; all mechanisms remain owned by Stitchkit.
|
|
600
|
-
export { canonicalJson } from 'stitchkit/primitives';
|
|
601
|
-
export { writeFileAtomic, withExclusiveLock } from 'stitchkit/files';
|
|
602
|
-
export { observeProcessInstance, probeProcessOwner, runNativeCommand } from 'stitchkit/process';
|
|
603
|
-
```
|
|
604
|
-
|
|
605
|
-
Bundle for Node-compatible execution with Zod external. Publish declarations from the same
|
|
606
|
-
version: carry their reachable relative `.d.ts` closure, rather than emitting references to
|
|
607
|
-
`stitchkit` that force clients to install it for types. A library exposing its own DTOs may
|
|
608
|
-
instead emit declarations for only that DTO contract. Keep the library's manifest at runtime
|
|
609
|
-
`dependencies: {}` and `peerDependencies: { zod: ... }` when that is its declared promise.
|
|
610
|
-
|
|
611
|
-
The packaged Darwin loader computes its addon path at run time from its own file
|
|
612
|
-
(`module.filename`), so a bundler never follows it: bundling `stitchkit/server`,
|
|
613
|
-
`stitchkit/files` or `stitchkit/process` yields the same single JS file on every operating
|
|
614
|
-
system, with no `.node` output, `bun build --outfile` works, and no path of the build machine
|
|
615
|
-
becomes a literal of the artifact. A bundle has no installed package beside it, so without the
|
|
616
|
-
packaging plugin it never loads the addon: the first call that needs it reports the Darwin backend
|
|
617
|
-
`unavailable` with stage `packaging`, and the message names `createNativePackaging`. An artifact
|
|
618
|
-
that must carry the Darwin addon uses the packaging plugin of the next section; it is the only way
|
|
619
|
-
a static loader enters a bundle.
|
|
620
|
-
|
|
621
|
-
Only these calls load the addon, and only on macOS: process identity (`observeProcessInstance`
|
|
622
|
-
and `probeProcessOwner`), every exclusive lock (`withExclusiveLock` and what is built on it, such
|
|
623
|
-
as the file state store and the diagnostic journal, and the startup lock of `createServer({ unix })`), the contained file operations of the Agent
|
|
624
|
-
coding tools and `--output-dir` downloads of `stitchkit/cli`. Without the addon a download refuses, and a lock still works, but it cannot record or check its owner's
|
|
625
|
-
identity, so a lock held by a crashed owner is not reclaimed. The managed file boundary
|
|
626
|
-
(`createManagedFileBoundary` and the transfer tools built on it), atomic writes and the chunk
|
|
627
|
-
spool never load it, on any operating system. The package is free of import side effects
|
|
628
|
-
(`sideEffects: false`), so a bundle that imports only those parts carries no Darwin loader at all.
|
|
629
|
-
|
|
630
|
-
Check an artifact by its loader, never by whether it holds `.node` bytes: Bun can copy the addon
|
|
631
|
-
into a compiled executable even without the plugin, and the unpackaged loader does not use it.
|
|
632
|
-
`inspectNativeArtifact(bytes)` from `stitchkit/files/packaging` reads the marker every generated
|
|
633
|
-
loader carries and answers `packaged` (the plugin's static loader is inside), `unpackaged` (the
|
|
634
|
-
default loader is inside, and every call above refuses on macOS) or `no-loader` (nothing in the
|
|
635
|
-
artifact loads the addon). It reads both latin1 and UTF-16LE, because Bun stores source text with
|
|
636
|
-
non-ASCII characters as UTF-16, and it does not mistake the `STITCHKIT_NATIVE_NOT_PACKAGED` error
|
|
637
|
-
code, which every bundle with a lock carries, for a loader. Artifacts built by 0.107.0 or earlier
|
|
638
|
-
carry no marker and read `no-loader`.
|
|
639
|
-
|
|
640
|
-
```ts
|
|
641
|
-
import { inspectNativeArtifact } from 'stitchkit/files/packaging'
|
|
642
|
-
|
|
643
|
-
const loader = inspectNativeArtifact(await Bun.file('dist/cli').bytes())
|
|
644
|
-
if (loader === 'unpackaged') throw new Error('dist/cli was built without native packaging')
|
|
645
|
-
```
|
|
646
|
-
|
|
647
|
-
```sh
|
|
648
|
-
bun build src/native.ts --target=bun --minify --outfile=dist/native.js
|
|
649
|
-
```
|
|
650
|
-
|
|
651
|
-
That plain build serves Linux and the parts that never load the addon. A library whose consumers
|
|
652
|
-
take locks or read process identity on macOS builds each native entry with the companion plugin of
|
|
653
|
-
the next section (one entry per build, `naming.entry` equal to `entryPath`) and ships the addon it
|
|
654
|
-
writes beside the entries.
|
|
655
|
-
|
|
656
|
-
Qualify the complete output outside its build tree and installed dependency graph. Test process
|
|
657
|
-
identity, live-owner refusal, dead-owner recovery and contained file operations in artifacts built
|
|
658
|
-
with the packaging plugin, and check that an unpackaged build reports the backend `unavailable`
|
|
659
|
-
with stage `packaging` rather than certifying a dead owner. Bun and Node package imports retain the same
|
|
660
|
-
lazy loader; importing a portable leaf does not load a Darwin addon on another OS. Test
|
|
661
|
-
declarations too, and check that importing an unbundled Stitchkit leaf fails in a deliberately
|
|
662
|
-
isolated library distribution. A separate schema-only entry must not import the native entry.
|
|
663
|
-
|
|
664
|
-
If the Darwin backend cannot load, `observeProcessInstance` still returns `unavailable`.
|
|
665
|
-
Its backend `Error` preserves the original `cause`; JSON serialization carries only the stable
|
|
666
|
-
`DARWIN_BACKEND_UNAVAILABLE` code, architecture, safe message and failure stage
|
|
667
|
-
(`architecture`, `packaging`, `resolve`, `load` or `surface`), plus a recognized native error code
|
|
668
|
-
when present: `packaging` is a bundle built without the packaging plugin, with native code
|
|
669
|
-
`STITCHKIT_NATIVE_NOT_PACKAGED`.
|
|
670
|
-
It excludes stack, paths and nested cause. This backend diagnosis does not reclassify kernel
|
|
671
|
-
failures or turn unavailable identity into proof that an owner is dead. If a runtime provides
|
|
672
|
-
no recognized native error code, the stage stays `load`; the loader never infers errno from text.
|
|
673
|
-
|
|
674
|
-
This delivery removes a runtime kernel installation; it does not remove the build-time
|
|
675
|
-
Stitchkit installation or create an independent lightweight npm package.
|
package/llms/server.4.txt
CHANGED
|
@@ -600,7 +600,7 @@ core never models them (ADR 0002). But stitchkit itself emits a set of its own:
|
|
|
600
600
|
`WAIT_TIMEOUT`,
|
|
601
601
|
`WAIT_FAILED`, `CLI_COMMAND_UNAVAILABLE`, `CLI_PRESENTATION_FAILED`, `DOWNLOAD_NOT_FOUND`, `VIEW_HTTP_ERROR`,
|
|
602
602
|
`CONNECTION_TIMEOUT`, `CONNECTION_RESPONSE_TOO_LARGE`,
|
|
603
|
-
`CONNECTION_REQUEST_FAILED`, `UPSTREAM_TOOL_ERROR`, `MCP_STRUCTURED_CONTENT_MISSING`,
|
|
603
|
+
`CONNECTION_REQUEST_FAILED`, `HTTP_ERROR`, `UPSTREAM_TOOL_ERROR`, `MCP_STRUCTURED_CONTENT_MISSING`,
|
|
604
604
|
`OPERATION_NOT_SUCCEEDED`, `OPERATION_BUSY`, `OPERATION_RESPONSE_TOO_LARGE`,
|
|
605
605
|
`OPERATION_PROCESS_FAILED`, `STREAM_ITEM_INVALID`, `STREAM_FRAME_TOO_LARGE`,
|
|
606
606
|
`STREAM_TERMINAL_MISSING`, `STREAM_LIFETIME_EXCEEDED`,
|
|
@@ -745,6 +745,54 @@ their established model-facing projection (code/details/hint, without HTTP
|
|
|
745
745
|
status), while `invokeOrThrow` recovers the exact normalized `AppError`. The
|
|
746
746
|
codes and schemas remain application-owned; Stitchkit stays domain-free.
|
|
747
747
|
|
|
748
|
+
### The codes an operation refuses with
|
|
749
|
+
|
|
750
|
+
An endpoint names the domain codes it can refuse with in `refuses`, by listing the
|
|
751
|
+
factories `defineErrors` returned. Every factory carries its `code` and
|
|
752
|
+
`definition`, so the list is the declaration — no second string list to drift:
|
|
753
|
+
|
|
754
|
+
```ts
|
|
755
|
+
const { errors } = defineErrors({
|
|
756
|
+
NOT_IDLE: { status: 409, message: 'Session is busy' },
|
|
757
|
+
MIN_AWAKE: { status: 409, details: z.object({ profile: z.string(), minimum: z.number().int() }) },
|
|
758
|
+
PROFILE_UNAVAILABLE: { status: 503 },
|
|
759
|
+
})
|
|
760
|
+
|
|
761
|
+
export const sessions = defineContract({ prefix: 'session' }, {
|
|
762
|
+
sleep: {
|
|
763
|
+
method: 'POST', path: '/sleep', desc: 'Put a session to sleep',
|
|
764
|
+
input: z.object({ id: z.string() }),
|
|
765
|
+
output: z.object({ ok: z.boolean() }),
|
|
766
|
+
refuses: [errors.NOT_IDLE, errors.MIN_AWAKE],
|
|
767
|
+
},
|
|
768
|
+
})
|
|
769
|
+
```
|
|
770
|
+
|
|
771
|
+
One declaration, three readers:
|
|
772
|
+
|
|
773
|
+
- **The server holds the handler to it.** An `AppError` whose code the operation
|
|
774
|
+
did not declare — and that is no framework code (`NOT_FOUND`, `FORBIDDEN`, …) —
|
|
775
|
+
leaves as `INTERNAL_SERVER_ERROR` (500) with the message `Operation session.sleep
|
|
776
|
+
failed with a code it does not declare`, on HTTP, MCP, the agent surface, the CLI
|
|
777
|
+
and mid-stream alike, exactly as an output that breaks its schema does. The
|
|
778
|
+
original error stays on `cause`, so `onError` and the logs still see it; the
|
|
779
|
+
caller does not. An `implementRemote` proxy is held to the same list even when its
|
|
780
|
+
origin is not. A failure that is no `AppError` keeps its usual handling, and an
|
|
781
|
+
operation without `refuses` runs unchanged.
|
|
782
|
+
- **The typed client reads it.** [`client.sleep.refusal(error)`](client.md#read-a-refusal-the-operation-declared)
|
|
783
|
+
narrows `code` to the declared codes plus the framework and client codes, and
|
|
784
|
+
types `details` by the code's schema.
|
|
785
|
+
- **The descriptor carries it** for a reader without types: `MethodDef.refuses`
|
|
786
|
+
(code, status, retryability, message, details schema), `x-stitchkit-refusals`
|
|
787
|
+
with one response per declared status in OpenAPI, `refusals` in the surface
|
|
788
|
+
manifest, and the contract fingerprint. Each changes only for an operation that
|
|
789
|
+
declares `refuses`.
|
|
790
|
+
|
|
791
|
+
`defineContract` refuses an entry that is not a factory from `defineErrors` (a bare
|
|
792
|
+
code string) and a code listed twice, naming the endpoint and the index.
|
|
793
|
+
Declaring is opt-in per operation: start with the operations whose callers branch
|
|
794
|
+
on a code. → ADR 0330
|
|
795
|
+
|
|
748
796
|
## `createErrorHook`
|
|
749
797
|
|
|
750
798
|
`createErrorHook` is the code-map above, packaged — you supply a `codeMap` and
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# stitchkit/service-host/work — stitchkit docs slice
|
|
2
|
+
|
|
3
|
+
> Generated from the `docs/` tree by `bun run gen:llms`. The index of all slices is
|
|
4
|
+
> `llms.txt` in this package.
|
|
5
|
+
|
|
6
|
+
Contains: API reference: `stitchkit/service-host/work` (docs/api/reference.md)
|
|
7
|
+
|
|
8
|
+
==============================================================================
|
|
9
|
+
# API reference: `stitchkit/service-host/work` (docs/api/reference.md)
|
|
10
|
+
==============================================================================
|
|
11
|
+
|
|
12
|
+
## `stitchkit/service-host/work`
|
|
13
|
+
|
|
14
|
+
Work launched in its own boundary with a declared owner. Guide: [Work in its own boundary](../guide/native-io.md#work-in-its-own-boundary). → ADR 0332
|
|
15
|
+
|
|
16
|
+
| Export | Kind | Summary |
|
|
17
|
+
|--------|------|---------|
|
|
18
|
+
| `launchWork` | function | launches a command in its boundary through the one native-command owner and resolves once its root is observed there; throws `WorkLaunchError` and starts nothing outside the asked boundary |
|
|
19
|
+
| `WorkLaunchInput` / `WorkLaunchCommand` | type | `{ owner, placement, command }`; `command` is `NativeCommandOptions` without `group`, `ownerLoss` and `onLeaderStarted` |
|
|
20
|
+
| `WorkLaunch` | type | `origin` (what the variable holds), `unit` (`{ manager, name }` or `null`), `root` (`{ pid, instance }`), `result` (settles like `runNativeCommand`) and `stop()` (ends the whole boundary) |
|
|
21
|
+
| `workCommand` | function | the same placement as argv and environment for any spawner; a scope gets `STITCHKIT_WORK_ORIGIN` in `env`, a process root writes it itself |
|
|
22
|
+
| `WorkCommandInput` / `WorkCommand` | type | `{ owner, placement, executable, args?, env }` → `{ executable, args, env, work, unit }` |
|
|
23
|
+
| `probeWorkBoundary` / `WorkBoundaryAvailability` | function / type | whether this host can make a placement, without launching: `available`, or `unavailable` with `reason` and `cause` |
|
|
24
|
+
| `checkWorkMembership` / `WorkMembership` / `WorkMembershipUnavailableReason` | function / type / type | asks the boundary whether a pid belongs to it: `member` (`via` `cgroup`, `root`, `process-group` or `ancestry`), `outside` with what was observed, `gone`, or `unavailable` (`platform-unsupported`, `proc-unreadable`, `cgroup-v2-required`, `root-unobservable`, `process-table-failed`) |
|
|
25
|
+
| `inheritedWork` | function | the `WorkRef` the current process is proven to run in, or `null`; throws when the variable is unreadable or the boundary cannot be asked |
|
|
26
|
+
| `readWorkOrigin` / `WORK_ORIGIN_ENV` | function / const | parses `STITCHKIT_WORK_ORIGIN` from an environment: `null` when absent, `WorkLaunchError('origin-unreadable')` when it does not parse or is of another version |
|
|
27
|
+
| `WorkOriginSchema` / `WorkOrigin` | schema / type | `{ v: 1, work, boundary }` — the value of the variable |
|
|
28
|
+
| `WorkBoundarySchema` / `WorkBoundary` | schema / type | `{ kind: 'transient-scope', manager, unit }` or `{ kind: 'process-root', root: { pid, instance } }` |
|
|
29
|
+
| `WorkOwnerSchema` / `WorkOwner` | schema / type | the owner record: `launcher`, `id`, `label`, and `project`, `agent`, `parent` as a value or `null`; no optional field |
|
|
30
|
+
| `WorkRefSchema` / `WorkRef` | schema / type | `{ launcher, id }` — a pointer to one owner record |
|
|
31
|
+
| `WorkAgentSchema` / `WorkAgent` | schema / type | `{ harness, model, address }` of the agent that asked for the work |
|
|
32
|
+
| `WorkPlacement` / `WorkScopePlacement` / `WorkScopeLimits` | type | `{ kind: 'transient-scope', manager: 'system' \| 'user', slice: 'caller' \| '<name>.slice', limits? }` or `{ kind: 'process-root' }`; limits `memoryMaxMb`, `memorySwapMaxMb`, `cpuQuotaPercent`, `cpuWeight`, `runtimeMaxSeconds` become unit properties |
|
|
33
|
+
| `workUnitName` | function | `<launcher>-<id>.scope` for a `WorkRef`; one way only |
|
|
34
|
+
| `WorkLaunchError` / `WorkLaunchErrorReason` | class / type | `reason` is `origin-unreadable`, `platform-unsupported`, `systemd-unavailable`, `systemd-too-old` (older than 254), `manager-unreachable`, `manager-unauthorized` (the system manager for a non-root caller), `user-manager-unreachable`, `slice-unresolvable`, `unit-exists`, `scope-refused`, `root-unobservable`, `root-unobserved`, `membership-unavailable` or `stop-failed`; `cause` holds what the host answered |
|
package/llms/stitchkit.2.txt
CHANGED
|
@@ -614,6 +614,37 @@ seventh constructor argument remains `ErrorOptions`, including `cause`; the opti
|
|
|
614
614
|
retryability argument is eighth. Closed error/frame schemas must accept the new optional
|
|
615
615
|
field before their producer declares it.
|
|
616
616
|
|
|
617
|
+
### Read a refusal the operation declared
|
|
618
|
+
|
|
619
|
+
When an endpoint declares `refuses` ([Auth & errors](./auth-and-errors.md#the-codes-an-operation-refuses-with)),
|
|
620
|
+
every client method carries `refusal(error)`. It returns the rejection as one of
|
|
621
|
+
that operation's refusals — `code` narrowed to the declared codes plus the
|
|
622
|
+
framework codes (`STITCH_ERROR_STATUS`) and the client's own (`CLIENT_ERROR_CODES`),
|
|
623
|
+
`details` typed by the declared code's schema — or `undefined` for anything else:
|
|
624
|
+
|
|
625
|
+
```ts
|
|
626
|
+
try {
|
|
627
|
+
await api.sleep({ id })
|
|
628
|
+
} catch (error) {
|
|
629
|
+
const refusal = api.sleep.refusal(error)
|
|
630
|
+
switch (refusal?.code) {
|
|
631
|
+
case 'NOT_IDLE':
|
|
632
|
+
return showBusy()
|
|
633
|
+
case 'MIN_AWAKE':
|
|
634
|
+
return showMinimum(refusal.details.minimum) // number, from the schema
|
|
635
|
+
case 'REQUEST_TIMEOUT':
|
|
636
|
+
return retryLater()
|
|
637
|
+
}
|
|
638
|
+
throw error
|
|
639
|
+
}
|
|
640
|
+
```
|
|
641
|
+
|
|
642
|
+
`undefined` covers an error that is no `ApiError`, a code the operation did not
|
|
643
|
+
declare (a newer server, another vocabulary) and details its schema refuses — the
|
|
644
|
+
client never hands back a type the value does not have. Comparing with a code the
|
|
645
|
+
operation did not declare does not type-check. An endpoint without `refuses` still
|
|
646
|
+
reads the framework and client codes.
|
|
647
|
+
|
|
617
648
|
## Which contract does the server speak
|
|
618
649
|
|
|
619
650
|
A client is built from one version of a contract and a server from another
|