stitchkit 0.136.8 → 0.137.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 +53 -0
- package/dist/agent-runtime/stores/branch-observations.d.ts +19 -19
- package/dist/agent-runtime/stores/schedule-contract.d.ts.map +1 -1
- package/dist/agent-runtime/stores/schedule-records.d.ts.map +1 -1
- package/dist/agent-runtime/stores/schedule-tools.d.ts.map +1 -1
- package/dist/agent-runtime/stores/sql-rows.d.ts +36 -36
- package/dist/agent-runtime/terminal-commit.d.ts +5 -5
- package/dist/agent-runtime/testing/store-conformance-lifecycle.d.ts +52 -52
- package/dist/agent-runtime/testing/store-conformance-support.d.ts +26 -26
- package/dist/browser/client-executors.d.ts +2 -3
- package/dist/browser/client-executors.d.ts.map +1 -1
- package/dist/browser/realtime-client.d.ts +6 -1
- package/dist/browser/realtime-client.d.ts.map +1 -1
- package/dist/browser/socket-io-client.d.ts.map +1 -1
- package/dist/browser/socket-io-contract.d.ts +2 -0
- package/dist/browser/socket-io-contract.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 +1 -1
- package/dist/contract/define.d.ts.map +1 -1
- package/dist/contract/error-mapping.d.ts +71 -0
- package/dist/contract/error-mapping.d.ts.map +1 -0
- package/dist/contract/errors.d.ts +8 -0
- package/dist/contract/errors.d.ts.map +1 -1
- package/dist/contract/factory.d.ts +8 -0
- package/dist/contract/factory.d.ts.map +1 -1
- package/dist/contract/fragments.d.ts +45 -0
- package/dist/contract/fragments.d.ts.map +1 -0
- package/dist/contract/normalize.d.ts +6 -3
- package/dist/contract/normalize.d.ts.map +1 -1
- package/dist/contract/operation-read.d.ts +38 -0
- package/dist/contract/operation-read.d.ts.map +1 -0
- package/dist/contract/stream.d.ts.map +1 -1
- package/dist/contract/time-zone.d.ts +31 -0
- package/dist/contract/time-zone.d.ts.map +1 -0
- package/dist/contract/tool-options.d.ts +1 -1
- package/dist/contract/tool-options.d.ts.map +1 -1
- package/dist/device-relay/hub.d.ts +1 -1
- package/dist/device-relay/hub.d.ts.map +1 -1
- package/dist/entrypoints/agent-executor/acp.js +9 -9
- package/dist/entrypoints/agent-executor/claude-sdk.js +11 -11
- package/dist/entrypoints/agent-executor/claude.js +8 -8
- package/dist/entrypoints/agent-executor/codex.js +15 -15
- package/dist/entrypoints/agent-executor/testing.js +11 -11
- package/dist/entrypoints/agent-executor.js +14 -13
- package/dist/entrypoints/agent-runtime/ai-sdk.js +5 -5
- package/dist/entrypoints/agent-runtime/anthropic.js +1 -1
- package/dist/entrypoints/agent-runtime/browser.js +5 -5
- package/dist/entrypoints/agent-runtime/coding-tools.js +3 -3
- package/dist/entrypoints/agent-runtime/harness.js +14 -15
- package/dist/entrypoints/agent-runtime/openai.js +1 -1
- package/dist/entrypoints/agent-runtime/openrouter.js +7 -7
- package/dist/entrypoints/agent-runtime/postgres.js +5 -5
- package/dist/entrypoints/agent-runtime/realtime.js +8 -8
- package/dist/entrypoints/agent-runtime/sandbox.js +7 -7
- 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 +33 -29
- package/dist/entrypoints/application/diagnostic-journal.js +3 -3
- package/dist/entrypoints/application/directory-inbox.js +1 -1
- package/dist/entrypoints/application/grammy.js +1 -1
- package/dist/entrypoints/application/opentelemetry.js +2 -2
- package/dist/entrypoints/application.js +10 -10
- package/dist/entrypoints/cli/publish.js +8 -8
- package/dist/entrypoints/cli.d.ts +2 -0
- package/dist/entrypoints/cli.d.ts.map +1 -1
- package/dist/entrypoints/cli.js +518 -59
- package/dist/entrypoints/contract.d.ts +5 -1
- package/dist/entrypoints/contract.d.ts.map +1 -1
- package/dist/entrypoints/contract.js +25 -7
- package/dist/entrypoints/device-relay.js +20 -10
- package/dist/entrypoints/files/packaging.js +2 -2
- package/dist/entrypoints/files.js +10 -10
- package/dist/entrypoints/handler.d.ts +1 -1
- package/dist/entrypoints/handler.d.ts.map +1 -1
- package/dist/entrypoints/handler.js +12 -12
- package/dist/entrypoints/http.js +13 -12
- package/dist/entrypoints/index.js +36 -18
- package/dist/entrypoints/live.d.ts +2 -1
- package/dist/entrypoints/live.d.ts.map +1 -1
- package/dist/entrypoints/live.js +630 -1
- package/dist/entrypoints/node.d.ts +5 -0
- package/dist/entrypoints/node.d.ts.map +1 -1
- package/dist/entrypoints/node.js +36 -16
- package/dist/entrypoints/observability.js +25 -10
- package/dist/entrypoints/postgres.d.ts +1 -0
- package/dist/entrypoints/postgres.d.ts.map +1 -1
- package/dist/entrypoints/postgres.js +66 -0
- package/dist/entrypoints/primitives.js +11 -4
- package/dist/entrypoints/process.js +7 -7
- package/dist/entrypoints/react.js +1 -1
- package/dist/entrypoints/realtime.js +3 -3
- package/dist/entrypoints/remote.js +6 -29
- package/dist/entrypoints/server.d.ts +6 -1
- package/dist/entrypoints/server.d.ts.map +1 -1
- package/dist/entrypoints/server.js +93 -32
- package/dist/entrypoints/service-host/macos.js +6 -6
- package/dist/entrypoints/service-host/work.js +6 -6
- package/dist/entrypoints/service-host.js +10 -10
- package/dist/entrypoints/spend.js +2 -1
- package/dist/entrypoints/sync.js +5 -5
- package/dist/entrypoints/telegram.js +8 -8
- package/dist/entrypoints/testing.d.ts +1 -0
- package/dist/entrypoints/testing.d.ts.map +1 -1
- package/dist/entrypoints/testing.js +1501 -13
- package/dist/entrypoints/tools/agent.js +6 -7
- package/dist/entrypoints/tools/connections.js +9 -11
- package/dist/entrypoints/tools/contract.js +1 -2
- package/dist/entrypoints/tools/invoker.js +4 -5
- package/dist/entrypoints/tools/mcp.js +10 -11
- package/dist/entrypoints/tools/toolkit.d.ts +1 -1
- package/dist/entrypoints/tools/toolkit.d.ts.map +1 -1
- package/dist/entrypoints/tools/toolkit.js +29 -24
- package/dist/entrypoints/tools.js +28 -30
- package/dist/entrypoints/tracking/contract.js +2 -1
- package/dist/entrypoints/xlsx.js +5 -8
- package/dist/{index-033tyx59.js → index-0zw0hcyg.js} +4 -1
- package/dist/{index-zcq3dby3.js → index-1bjwfnnj.js} +1 -1
- package/dist/{index-3zt0r4y0.js → index-1cfacbe2.js} +4 -4
- package/dist/{index-gj4wdts6.js → index-1ckh9qx1.js} +1 -1
- package/dist/index-1pvwmbxp.js +1435 -0
- package/dist/{index-0s75mjh7.js → index-2e4hdh32.js} +1 -1
- package/dist/{index-3shdhzt6.js → index-2j0pqxkn.js} +12 -6
- package/dist/index-3k8w02se.js +28 -0
- package/dist/{index-7fjbdga8.js → index-3pb4ccj2.js} +8 -0
- package/dist/{index-w7e402wx.js → index-48kb4gqq.js} +46 -7
- package/dist/{index-cv9b7fz2.js → index-6rws2xf5.js} +8 -0
- package/dist/{index-bbpygynk.js → index-77w5vx0g.js} +1 -1
- package/dist/index-7dz1ngaf.js +35 -0
- package/dist/{index-y68gavb5.js → index-7n4atsm4.js} +1 -1
- package/dist/index-8ef1bfea.js +71 -0
- package/dist/{index-0x4mnwg5.js → index-8k3y9nd4.js} +6 -9
- package/dist/{index-ezwsqyad.js → index-8rkdkefj.js} +40 -23
- package/dist/{index-3cwq5byx.js → index-9nax7tkn.js} +2 -2
- package/dist/{index-dz6tstcp.js → index-9r6emjwz.js} +1 -1
- package/dist/{index-32ew02z1.js → index-c4b7d6ej.js} +5 -5
- package/dist/index-ceshyndf.js +284 -0
- package/dist/{index-w161azza.js → index-d13rw31w.js} +6 -6
- package/dist/{index-1h0dtfz3.js → index-dmm7vs3f.js} +1 -1
- package/dist/{index-ypm85xwe.js → index-dp8j2e77.js} +1 -1
- package/dist/{index-qqd979f7.js → index-edycjvrv.js} +9 -9
- package/dist/{index-18qdpbcq.js → index-egpf9dv0.js} +200 -1479
- package/dist/{index-fatke81t.js → index-ezgvsj9w.js} +2 -2
- package/dist/{index-chapre0y.js → index-f3e7tj1g.js} +1 -1
- package/dist/{index-df5xr2f9.js → index-frsd2a94.js} +16 -1
- package/dist/index-fy9mmek1.js +95 -0
- package/dist/{index-2331y2tf.js → index-g0gvfzrx.js} +12 -12
- package/dist/index-gpe8d1ka.js +19 -0
- package/dist/{index-4p2zx593.js → index-gyw4qd0m.js} +1 -1
- package/dist/index-gzqy81tw.js +172 -0
- package/dist/{index-yrhw10ef.js → index-h34c510q.js} +8 -4
- package/dist/{index-rr94xcj6.js → index-h527p1yj.js} +10 -4
- package/dist/{index-qj0sq69b.js → index-hgf1tbgz.js} +76 -16
- package/dist/{index-smvmnz5y.js → index-hvpan32x.js} +1 -1
- package/dist/{index-4gbybjg6.js → index-hxawqrb6.js} +2 -2
- package/dist/{index-0k1ba0ss.js → index-j91jffhv.js} +1 -1
- package/dist/{index-d01akj5n.js → index-jr4kwetx.js} +8 -8
- package/dist/{index-xqppqn97.js → index-ka6z48zc.js} +315 -69
- package/dist/{index-by8w2461.js → index-kw0segzt.js} +104 -3
- package/dist/{index-6f4fjygr.js → index-m5t4dr7h.js} +29 -7
- package/dist/{index-afaq0nc4.js → index-n0egp1ke.js} +1 -1
- package/dist/{index-9fzjgg86.js → index-n74rb1dq.js} +2 -2
- package/dist/{index-dwq6a6sq.js → index-pt25vmhc.js} +33 -16
- package/dist/{index-vwg0n3e6.js → index-pyazb8q4.js} +23 -14
- package/dist/{index-5md04mwc.js → index-qpjjbkc5.js} +4 -4
- package/dist/{index-08a3qfr8.js → index-r1qt6zgj.js} +1 -1
- package/dist/{index-ctaxjpa4.js → index-r709pqed.js} +1 -1
- package/dist/{index-2zrx0nzv.js → index-rzc40z6e.js} +3 -5
- package/dist/{index-gq35s3bm.js → index-s5axtd56.js} +2 -2
- package/dist/{index-edpkm3k7.js → index-scpcps66.js} +669 -16
- package/dist/{index-ry8m2mhg.js → index-sf2mt6wj.js} +1 -1
- package/dist/{index-tjhhsnjv.js → index-t1213r0t.js} +1 -1
- package/dist/{index-gvgtmt7a.js → index-t7efje30.js} +2 -2
- package/dist/{index-w3s79kcb.js → index-tzyk36dy.js} +1 -1
- package/dist/{index-8tn10tp6.js → index-v64bvwjr.js} +1 -1
- package/dist/{index-1fhbe4e4.js → index-vksbsqpb.js} +1 -1
- package/dist/{index-dxft2mnm.js → index-wdg7bswj.js} +1 -1
- package/dist/{index-ppy23bd2.js → index-wjx1zs2r.js} +7 -578
- package/dist/{index-efbzm2se.js → index-x2r0ma9t.js} +1 -1
- package/dist/{index-kd48gk7d.js → index-x8py72a3.js} +1 -1
- package/dist/index-xvydbxmk.js +1404 -0
- package/dist/index-xwaphv0d.js +31 -0
- package/dist/{index-a09r9ff0.js → index-y44j39yk.js} +1 -1
- package/dist/{index-7mjsb7zv.js → index-ybrrxjhb.js} +1 -1
- package/dist/{index-xsrma0jd.js → index-ysthxsa8.js} +6 -6
- package/dist/{index-6p5pshcd.js → index-yyh3ey4b.js} +1 -1
- package/dist/{index-mr3njw67.js → index-z6hq9j8j.js} +1 -1
- package/dist/{index-67mzzkdv.js → index-z72agxdn.js} +2 -2
- package/dist/{index-e4w0sfm1.js → index-z78mtc16.js} +1 -1
- package/dist/{index-7csn6pva.js → index-ze94h4ph.js} +5 -0
- package/dist/internal/json-stringify.d.ts +12 -0
- package/dist/internal/json-stringify.d.ts.map +1 -1
- package/dist/internal/unix-client-error.d.ts +4 -0
- package/dist/internal/unix-client-error.d.ts.map +1 -1
- package/dist/live/watch-contract.d.ts +4 -0
- package/dist/live/watch-contract.d.ts.map +1 -1
- package/dist/live/watch-fanout-frame.d.ts +81 -0
- package/dist/live/watch-fanout-frame.d.ts.map +1 -0
- package/dist/live/watch-fanout.d.ts +57 -0
- package/dist/live/watch-fanout.d.ts.map +1 -0
- package/dist/observability/audit.d.ts.map +1 -1
- package/dist/observability/spool-core.d.ts +1 -0
- package/dist/observability/spool-core.d.ts.map +1 -1
- package/dist/observability/spool-drain.d.ts +48 -0
- package/dist/observability/spool-drain.d.ts.map +1 -0
- package/dist/observability/spool.d.ts +12 -6
- package/dist/observability/spool.d.ts.map +1 -1
- package/dist/postgres/rollback-transaction.d.ts +61 -0
- package/dist/postgres/rollback-transaction.d.ts.map +1 -0
- package/dist/primitives/deadline.d.ts +4 -4
- package/dist/primitives/deadline.d.ts.map +1 -1
- package/dist/server/error-hook.d.ts +3 -32
- package/dist/server/error-hook.d.ts.map +1 -1
- package/dist/server/local-consent-key.d.ts +104 -0
- package/dist/server/local-consent-key.d.ts.map +1 -0
- package/dist/server/local-control-journal.d.ts +51 -0
- package/dist/server/local-control-journal.d.ts.map +1 -0
- package/dist/server/local-control-reporter.d.ts +32 -0
- package/dist/server/local-control-reporter.d.ts.map +1 -0
- package/dist/server/local-control.d.ts +48 -0
- package/dist/server/local-control.d.ts.map +1 -0
- package/dist/server/local-host-clients.d.ts +105 -0
- package/dist/server/local-host-clients.d.ts.map +1 -0
- package/dist/server/middleware/trust-fence.d.ts +20 -0
- package/dist/server/middleware/trust-fence.d.ts.map +1 -1
- package/dist/spend/receipt-spool.d.ts +9 -4
- package/dist/spend/receipt-spool.d.ts.map +1 -1
- package/dist/testing/tool-surface-checks.d.ts +89 -0
- package/dist/testing/tool-surface-checks.d.ts.map +1 -0
- package/dist/testing/tool-surface-cli-callable.d.ts +63 -0
- package/dist/testing/tool-surface-cli-callable.d.ts.map +1 -0
- package/dist/testing/tool-surface-dead-refs.d.ts +32 -0
- package/dist/testing/tool-surface-dead-refs.d.ts.map +1 -0
- package/dist/testing/tool-surface-gates.d.ts +72 -0
- package/dist/testing/tool-surface-gates.d.ts.map +1 -0
- package/dist/testing/tool-surface-parity-drivers.d.ts +56 -0
- package/dist/testing/tool-surface-parity-drivers.d.ts.map +1 -0
- package/dist/testing/tool-surface-parity.d.ts +28 -0
- package/dist/testing/tool-surface-parity.d.ts.map +1 -0
- package/dist/testing/tool-surface-ratchet.d.ts +71 -0
- package/dist/testing/tool-surface-ratchet.d.ts.map +1 -0
- package/dist/tools/agent-tools.d.ts +3 -0
- package/dist/tools/agent-tools.d.ts.map +1 -1
- package/dist/tools/cli/command.d.ts +3 -0
- package/dist/tools/cli/command.d.ts.map +1 -1
- package/dist/tools/cli/create-cli.d.ts.map +1 -1
- package/dist/tools/cli/format.d.ts +3 -6
- package/dist/tools/cli/format.d.ts.map +1 -1
- package/dist/tools/cli/invoke.d.ts +4 -0
- package/dist/tools/cli/invoke.d.ts.map +1 -1
- package/dist/tools/cli/local-key-command.d.ts +53 -0
- package/dist/tools/cli/local-key-command.d.ts.map +1 -0
- package/dist/tools/cli/managed-surface.d.ts.map +1 -1
- package/dist/tools/cli/run-managed.d.ts.map +1 -1
- package/dist/tools/cli/run-stream.d.ts.map +1 -1
- package/dist/tools/cli/runner.d.ts +8 -3
- package/dist/tools/cli/runner.d.ts.map +1 -1
- package/dist/tools/cli/secret.d.ts +55 -0
- package/dist/tools/cli/secret.d.ts.map +1 -0
- package/dist/tools/cli/session.d.ts +2 -2
- package/dist/tools/cli/session.d.ts.map +1 -1
- package/dist/tools/cli/stream.d.ts.map +1 -1
- package/dist/tools/cli/unix-outcome.d.ts +6 -0
- package/dist/tools/cli/unix-outcome.d.ts.map +1 -1
- package/dist/tools/execute-result.d.ts +20 -0
- package/dist/tools/execute-result.d.ts.map +1 -1
- package/dist/tools/execute.d.ts +3 -0
- package/dist/tools/execute.d.ts.map +1 -1
- package/dist/tools/internal/json-projection.d.ts +13 -9
- package/dist/tools/internal/json-projection.d.ts.map +1 -1
- package/dist/tools/internal/remote-error.d.ts +15 -0
- package/dist/tools/internal/remote-error.d.ts.map +1 -0
- package/dist/tools/internal/surface-projector.d.ts +2 -0
- package/dist/tools/internal/surface-projector.d.ts.map +1 -1
- package/dist/tools/invoker.d.ts +3 -0
- package/dist/tools/invoker.d.ts.map +1 -1
- package/dist/tools/mcp/handler.d.ts.map +1 -1
- package/dist/tools/mcp/lazy-discovery.d.ts +2 -0
- package/dist/tools/mcp/lazy-discovery.d.ts.map +1 -1
- package/dist/tools/mcp/mount.d.ts +5 -0
- package/dist/tools/mcp/mount.d.ts.map +1 -1
- package/dist/tools/mcp/register.d.ts +2 -0
- package/dist/tools/mcp/register.d.ts.map +1 -1
- package/dist/tools/mcp/runtime-tools.d.ts +2 -0
- package/dist/tools/mcp/runtime-tools.d.ts.map +1 -1
- package/dist/tools/mcp/stdio.d.ts.map +1 -1
- package/dist/tools/mount.d.ts +3 -0
- package/dist/tools/mount.d.ts.map +1 -1
- package/dist/tools/read-operation.d.ts +2 -6
- package/dist/tools/read-operation.d.ts.map +1 -1
- package/dist/tools/remote.d.ts.map +1 -1
- package/dist/tools/runtime-tool.d.ts.map +1 -1
- package/dist/tools/toolkit.d.ts +10 -3
- package/dist/tools/toolkit.d.ts.map +1 -1
- package/dist/xlsx/schema.d.ts.map +1 -1
- package/llms/cli.2.txt +10 -8
- package/llms/cli.3.txt +2 -0
- package/llms/cli.txt +18 -3
- package/llms/contract.txt +47 -5
- package/llms/handler.txt +1 -1
- package/llms/live.txt +82 -0
- package/llms/node.txt +5 -0
- package/llms/observability.2.txt +1 -1
- package/llms/observability.txt +6 -0
- package/llms/postgres.txt +1 -0
- package/llms/server.2.txt +206 -240
- package/llms/server.3.txt +242 -202
- package/llms/server.4.txt +202 -1025
- package/llms/server.5.txt +1053 -255
- package/llms/server.6.txt +274 -0
- package/llms/server.txt +32 -116
- package/llms/spend.txt +8 -7
- package/llms/stitchkit.2.txt +13 -35
- package/llms/stitchkit.3.txt +27 -0
- package/llms/stitchkit.txt +81 -81
- package/llms/testing.txt +40 -0
- package/llms/tools-toolkit.txt +2 -2
- package/llms/tools.2.txt +29 -20
- package/llms/{upgrading-0.128.0-0.129.0.txt → upgrading-0.128.0-0.131.0.txt} +101 -3
- package/llms/{upgrading-0.130.0-0.136.0.txt → upgrading-0.132.0-0.137.0.txt} +62 -101
- package/llms/upgrading.txt +2 -2
- package/llms-full.txt +590 -171
- package/llms.txt +13 -13
- package/package.json +1 -1
- package/dist/index-9118dw8d.js +0 -603
- package/dist/index-9vj869rx.js +0 -19
- package/dist/index-a1rjr381.js +0 -114
- package/dist/index-dacxr7nf.js +0 -17
- package/dist/index-dm50x3by.js +0 -63
- package/dist/index-dmrx8xma.js +0 -163
- package/dist/index-ednf2cxs.js +0 -37
- package/dist/{index-e4zt2x70.js → index-3czppvrr.js} +3 -3
- package/dist/{index-42n9jycn.js → index-3f79t32b.js} +3 -3
- package/dist/{index-mfe9a266.js → index-84n49vam.js} +0 -0
- package/dist/{index-f16b7rze.js → index-er1tp8de.js} +3 -3
- package/dist/{index-k137ezb6.js → index-f5d0fdcf.js} +3 -3
- package/dist/{index-65p8v81y.js → index-psz8qrz0.js} +3 -3
- package/dist/{index-kadgaw1s.js → index-r8cq86h1.js} +0 -0
- package/dist/{index-1yky29qg.js → index-tyyvbarf.js} +0 -0
- package/dist/{index-tjakdpf2.js → index-wq71v08n.js} +3 -3
- package/dist/{index-7an2fs5h.js → index-wswcpbm4.js} +3 -3
package/dist/entrypoints/cli.js
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import"../index-dsa676h8.js";
|
|
2
2
|
import"../index-ha1tv70k.js";
|
|
3
3
|
import"../index-d1pdv8qc.js";
|
|
4
|
-
import"../index-dm50x3by.js";
|
|
5
4
|
import {
|
|
6
5
|
coerceJsonArgs2
|
|
7
|
-
} from "../index-
|
|
6
|
+
} from "../index-hgf1tbgz.js";
|
|
8
7
|
import {
|
|
9
8
|
CliArgumentError2,
|
|
10
9
|
DEFAULT_EXIT_CODES2,
|
|
@@ -13,25 +12,36 @@ import {
|
|
|
13
12
|
renderCliView2,
|
|
14
13
|
defineCliResult2,
|
|
15
14
|
defineCliCommand2,
|
|
15
|
+
cliInvokerErrorMapping,
|
|
16
16
|
cliInvocationResult2,
|
|
17
17
|
createCliInvoker2,
|
|
18
18
|
scanCliArgv,
|
|
19
19
|
answersBeforeArguments,
|
|
20
|
-
scanCliInvocation2
|
|
20
|
+
scanCliInvocation2
|
|
21
|
+
} from "../index-egpf9dv0.js";
|
|
22
|
+
import"../index-yt1gg11x.js";
|
|
23
|
+
import"../index-kw0segzt.js";
|
|
24
|
+
import {
|
|
25
|
+
applyToolErrorMapping,
|
|
26
|
+
toolErrorFromResult
|
|
27
|
+
} from "../index-scpcps66.js";
|
|
28
|
+
import"../index-werjqesf.js";
|
|
29
|
+
import"../index-8k3y9nd4.js";
|
|
30
|
+
import"../index-6kec3b14.js";
|
|
31
|
+
import"../index-gy9x38a2.js";
|
|
32
|
+
import {
|
|
21
33
|
writeCliNotice,
|
|
22
34
|
parseCliArgs2,
|
|
23
35
|
extractCliGlobalOptions2,
|
|
24
36
|
pollUntilDone2,
|
|
25
37
|
createCli2
|
|
26
|
-
} from "../index-
|
|
27
|
-
import"../index-
|
|
28
|
-
import
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
import"../index-
|
|
32
|
-
import"../index-
|
|
33
|
-
import"../index-gy9x38a2.js";
|
|
34
|
-
import"../index-yrhw10ef.js";
|
|
38
|
+
} from "../index-xvydbxmk.js";
|
|
39
|
+
import"../index-h34c510q.js";
|
|
40
|
+
import {
|
|
41
|
+
createHttpClient2
|
|
42
|
+
} from "../index-jr4kwetx.js";
|
|
43
|
+
import"../index-673drwkn.js";
|
|
44
|
+
import"../index-2qnqvq11.js";
|
|
35
45
|
import {
|
|
36
46
|
renderCliInstaller2,
|
|
37
47
|
CliBuildSignatureSchema2,
|
|
@@ -52,9 +62,16 @@ import {
|
|
|
52
62
|
checkCliUpdate2,
|
|
53
63
|
applyCliUpdate2,
|
|
54
64
|
rollbackCliUpdate2
|
|
55
|
-
} from "../index-
|
|
56
|
-
import
|
|
57
|
-
|
|
65
|
+
} from "../index-1cfacbe2.js";
|
|
66
|
+
import {
|
|
67
|
+
RegularFileError2,
|
|
68
|
+
decodeUtf8Strict,
|
|
69
|
+
readRegularFileSync2
|
|
70
|
+
} from "../index-r709pqed.js";
|
|
71
|
+
import {
|
|
72
|
+
createUnixClientTransport2
|
|
73
|
+
} from "../index-wjx1zs2r.js";
|
|
74
|
+
import"../index-x8py72a3.js";
|
|
58
75
|
import"../index-zhngww7q.js";
|
|
59
76
|
import"../index-rnhp7je8.js";
|
|
60
77
|
import {
|
|
@@ -64,21 +81,33 @@ import"../index-rjs94dny.js";
|
|
|
64
81
|
import"../index-xrgn784x.js";
|
|
65
82
|
import {
|
|
66
83
|
stringifyJsonSafe
|
|
67
|
-
} from "../index-
|
|
68
|
-
import"../index-
|
|
69
|
-
import"../index-
|
|
84
|
+
} from "../index-gzqy81tw.js";
|
|
85
|
+
import"../index-rzc40z6e.js";
|
|
86
|
+
import"../index-ze94h4ph.js";
|
|
70
87
|
import {
|
|
71
88
|
safeJsonParse
|
|
72
89
|
} from "../index-zsarb5xp.js";
|
|
90
|
+
import {
|
|
91
|
+
errnoOf
|
|
92
|
+
} from "../index-jj9228tt.js";
|
|
73
93
|
import {
|
|
74
94
|
AppError2
|
|
75
|
-
} from "../index-
|
|
95
|
+
} from "../index-3pb4ccj2.js";
|
|
96
|
+
import {
|
|
97
|
+
argumentsDigest
|
|
98
|
+
} from "../index-3dq8466w.js";
|
|
76
99
|
import {
|
|
77
100
|
setOwnMember
|
|
78
101
|
} from "../index-3tb82xr7.js";
|
|
79
102
|
import {
|
|
80
|
-
|
|
81
|
-
} from "../index-
|
|
103
|
+
utf8ByteLength
|
|
104
|
+
} from "../index-er1tp8de.js";
|
|
105
|
+
import {
|
|
106
|
+
assertTimerMs
|
|
107
|
+
} from "../index-e1y74yra.js";
|
|
108
|
+
import {
|
|
109
|
+
assertPositiveSafeInteger
|
|
110
|
+
} from "../index-gr0kxymw.js";
|
|
82
111
|
import {
|
|
83
112
|
isRecord
|
|
84
113
|
} from "../index-ps3djm8d.js";
|
|
@@ -169,6 +198,55 @@ function writeCliCheckpoint(path, checkpoint) {
|
|
|
169
198
|
mode: 384
|
|
170
199
|
});
|
|
171
200
|
}
|
|
201
|
+
// src/tools/cli/local-key-command.ts
|
|
202
|
+
import { z } from "zod";
|
|
203
|
+
var DEFAULT_COMMAND_NAME = "init-key";
|
|
204
|
+
var DEFAULT_INIT_KEY_PATH = "/v1/init-key";
|
|
205
|
+
var DEFAULT_CLIENT_TIMEOUT_MS = 90000;
|
|
206
|
+
var LocalKeyInitOutputSchema = z.strictObject({
|
|
207
|
+
profile: z.string().min(1),
|
|
208
|
+
path: z.string().min(1)
|
|
209
|
+
});
|
|
210
|
+
function defineLocalKeyInitCommand(config) {
|
|
211
|
+
assertTimerMs("defineLocalKeyInitCommand timeoutMs", config.timeoutMs);
|
|
212
|
+
const endpointPath = config.path ?? DEFAULT_INIT_KEY_PATH;
|
|
213
|
+
if (typeof endpointPath !== "string" || !endpointPath.startsWith("/")) {
|
|
214
|
+
throw new TypeError('[stitchkit] defineLocalKeyInitCommand: path must start with "/"');
|
|
215
|
+
}
|
|
216
|
+
const timeoutMs = config.timeoutMs ?? DEFAULT_CLIENT_TIMEOUT_MS;
|
|
217
|
+
const defaultProfile = config.defaultProfileName ?? "default";
|
|
218
|
+
return defineCliCommand2({
|
|
219
|
+
name: config.name ?? DEFAULT_COMMAND_NAME,
|
|
220
|
+
description: config.description ?? "Request a scoped key from the local desktop application with native consent and store it in a 0600 profile",
|
|
221
|
+
input: config.input,
|
|
222
|
+
output: LocalKeyInitOutputSchema,
|
|
223
|
+
handler: async (context) => {
|
|
224
|
+
const socketPath = typeof config.socketPath === "function" ? config.socketPath(context) : config.socketPath;
|
|
225
|
+
const headers = typeof config.reporterHeaders === "function" ? config.reporterHeaders(context) : config.reporterHeaders;
|
|
226
|
+
const body = config.buildRequest(context);
|
|
227
|
+
const profileName = config.profileName?.(context) ?? defaultProfile;
|
|
228
|
+
const transport = createUnixClientTransport2({
|
|
229
|
+
socketPath,
|
|
230
|
+
headersTimeoutMs: timeoutMs
|
|
231
|
+
});
|
|
232
|
+
try {
|
|
233
|
+
const http = createHttpClient2({
|
|
234
|
+
baseUrl: "http://localhost",
|
|
235
|
+
fetch: transport.fetch,
|
|
236
|
+
timeout: timeoutMs,
|
|
237
|
+
retry: { limit: 0 },
|
|
238
|
+
...headers !== undefined && { headers }
|
|
239
|
+
});
|
|
240
|
+
const response = await http.post(endpointPath, body);
|
|
241
|
+
const profileValue = config.extractProfile(response, context);
|
|
242
|
+
const writtenPath = config.profileStore.write(profileName, profileValue);
|
|
243
|
+
return { profile: profileName, path: writtenPath };
|
|
244
|
+
} finally {
|
|
245
|
+
await transport.close();
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
});
|
|
249
|
+
}
|
|
172
250
|
// src/tools/cli/profile.ts
|
|
173
251
|
import {
|
|
174
252
|
chmodSync,
|
|
@@ -265,18 +343,404 @@ function missingMessage(name, path, config) {
|
|
|
265
343
|
const hint = config.createHint ? ` — ${config.createHint(name, path)}` : "";
|
|
266
344
|
return `profile "${name}" is not configured; expected ${path}${hint}`;
|
|
267
345
|
}
|
|
346
|
+
// src/tools/cli/secret.ts
|
|
347
|
+
var DEFAULT_MAX_SECRET_BYTES = 4096;
|
|
348
|
+
var utf8Encoder = new TextEncoder;
|
|
349
|
+
function concatBytes(chunks, totalBytes) {
|
|
350
|
+
const merged = new Uint8Array(totalBytes);
|
|
351
|
+
let offset = 0;
|
|
352
|
+
for (const chunk of chunks) {
|
|
353
|
+
merged.set(chunk, offset);
|
|
354
|
+
offset += chunk.byteLength;
|
|
355
|
+
}
|
|
356
|
+
return merged;
|
|
357
|
+
}
|
|
358
|
+
function abortedSecretError(message) {
|
|
359
|
+
return new AppError2("REQUEST_ABORTED", {
|
|
360
|
+
status: 499,
|
|
361
|
+
message,
|
|
362
|
+
retryable: false
|
|
363
|
+
});
|
|
364
|
+
}
|
|
365
|
+
function validationSecretError(message) {
|
|
366
|
+
return new AppError2("VALIDATION_ERROR", {
|
|
367
|
+
status: 400,
|
|
368
|
+
message,
|
|
369
|
+
retryable: false
|
|
370
|
+
});
|
|
371
|
+
}
|
|
372
|
+
function stripSingleTrailingNewline(value) {
|
|
373
|
+
if (value.endsWith(`\r
|
|
374
|
+
`))
|
|
375
|
+
return value.slice(0, -2);
|
|
376
|
+
if (value.endsWith(`
|
|
377
|
+
`) || value.endsWith("\r"))
|
|
378
|
+
return value.slice(0, -1);
|
|
379
|
+
return value;
|
|
380
|
+
}
|
|
381
|
+
function readSecretFromTty(input, output, prompt, maxBytes, signal) {
|
|
382
|
+
const setRawMode = input.setRawMode;
|
|
383
|
+
if (typeof setRawMode !== "function") {
|
|
384
|
+
return Promise.reject(new AppError2("BAD_REQUEST", {
|
|
385
|
+
status: 400,
|
|
386
|
+
message: "Interactive terminal does not support raw mode without echo",
|
|
387
|
+
retryable: false
|
|
388
|
+
}));
|
|
389
|
+
}
|
|
390
|
+
return new Promise((resolve, reject) => {
|
|
391
|
+
const wasRaw = Boolean(input.isRaw);
|
|
392
|
+
const decoder = new TextDecoder("utf-8", { fatal: true });
|
|
393
|
+
const chars = [];
|
|
394
|
+
let byteCount = 0;
|
|
395
|
+
let escapeState = "none";
|
|
396
|
+
let finished = false;
|
|
397
|
+
let rawModeActive = false;
|
|
398
|
+
const safeWrite = (text) => {
|
|
399
|
+
try {
|
|
400
|
+
output(text);
|
|
401
|
+
} catch {}
|
|
402
|
+
};
|
|
403
|
+
const restoreRaw = () => {
|
|
404
|
+
if (!rawModeActive)
|
|
405
|
+
return;
|
|
406
|
+
rawModeActive = false;
|
|
407
|
+
try {
|
|
408
|
+
input.setRawMode?.(wasRaw);
|
|
409
|
+
} catch {}
|
|
410
|
+
};
|
|
411
|
+
const cleanup = () => {
|
|
412
|
+
input.off("data", onData);
|
|
413
|
+
input.off("end", onEnd);
|
|
414
|
+
input.off("close", onClose);
|
|
415
|
+
input.off("error", onError);
|
|
416
|
+
signal?.removeEventListener("abort", onAbort);
|
|
417
|
+
process.off("exit", restoreRaw);
|
|
418
|
+
restoreRaw();
|
|
419
|
+
input.pause();
|
|
420
|
+
};
|
|
421
|
+
const fail = (error, writeNewline = false) => {
|
|
422
|
+
if (finished)
|
|
423
|
+
return;
|
|
424
|
+
finished = true;
|
|
425
|
+
cleanup();
|
|
426
|
+
if (writeNewline)
|
|
427
|
+
safeWrite(`
|
|
428
|
+
`);
|
|
429
|
+
reject(error);
|
|
430
|
+
};
|
|
431
|
+
const complete = () => {
|
|
432
|
+
if (finished)
|
|
433
|
+
return;
|
|
434
|
+
finished = true;
|
|
435
|
+
let tail = "";
|
|
436
|
+
try {
|
|
437
|
+
tail = decoder.decode();
|
|
438
|
+
} catch {
|
|
439
|
+
cleanup();
|
|
440
|
+
safeWrite(`
|
|
441
|
+
`);
|
|
442
|
+
reject(validationSecretError("Secret input must be valid UTF-8"));
|
|
443
|
+
return;
|
|
444
|
+
}
|
|
445
|
+
if (tail.length > 0) {
|
|
446
|
+
const tailBytes = utf8ByteLength(tail);
|
|
447
|
+
if (byteCount + tailBytes > maxBytes) {
|
|
448
|
+
cleanup();
|
|
449
|
+
safeWrite(`
|
|
450
|
+
`);
|
|
451
|
+
reject(validationSecretError(`Secret exceeds ${maxBytes}-byte limit`));
|
|
452
|
+
return;
|
|
453
|
+
}
|
|
454
|
+
chars.push(...tail);
|
|
455
|
+
byteCount += tailBytes;
|
|
456
|
+
}
|
|
457
|
+
cleanup();
|
|
458
|
+
safeWrite(`
|
|
459
|
+
`);
|
|
460
|
+
const secret = chars.join("");
|
|
461
|
+
if (secret.length === 0) {
|
|
462
|
+
reject(validationSecretError("Secret cannot be empty"));
|
|
463
|
+
return;
|
|
464
|
+
}
|
|
465
|
+
resolve(secret);
|
|
466
|
+
};
|
|
467
|
+
const onAbort = () => fail(abortedSecretError("Secret input aborted"), true);
|
|
468
|
+
const onError = (error) => fail(error, true);
|
|
469
|
+
const onEnd = () => complete();
|
|
470
|
+
const onClose = () => {
|
|
471
|
+
if (chars.length > 0)
|
|
472
|
+
complete();
|
|
473
|
+
else
|
|
474
|
+
fail(abortedSecretError("Secret input stream closed"), true);
|
|
475
|
+
};
|
|
476
|
+
const onData = (chunk) => {
|
|
477
|
+
if (finished)
|
|
478
|
+
return;
|
|
479
|
+
let text;
|
|
480
|
+
try {
|
|
481
|
+
text = typeof chunk === "string" ? chunk : decoder.decode(chunk, { stream: true });
|
|
482
|
+
} catch {
|
|
483
|
+
fail(validationSecretError("Secret input must be valid UTF-8"), true);
|
|
484
|
+
return;
|
|
485
|
+
}
|
|
486
|
+
for (const ch of text) {
|
|
487
|
+
const code = ch.codePointAt(0) ?? 0;
|
|
488
|
+
if (code === 3) {
|
|
489
|
+
fail(abortedSecretError("Secret input cancelled"), true);
|
|
490
|
+
return;
|
|
491
|
+
}
|
|
492
|
+
if (escapeState === "osc-esc") {
|
|
493
|
+
escapeState = ch === "\\" || code === 7 ? "none" : "osc";
|
|
494
|
+
continue;
|
|
495
|
+
}
|
|
496
|
+
if (escapeState === "osc") {
|
|
497
|
+
if (code === 7)
|
|
498
|
+
escapeState = "none";
|
|
499
|
+
else if (code === 27)
|
|
500
|
+
escapeState = "osc-esc";
|
|
501
|
+
continue;
|
|
502
|
+
}
|
|
503
|
+
if (escapeState === "ss3") {
|
|
504
|
+
escapeState = "none";
|
|
505
|
+
if (code !== 4 && ch !== "\r" && ch !== `
|
|
506
|
+
`)
|
|
507
|
+
continue;
|
|
508
|
+
}
|
|
509
|
+
if (escapeState === "esc") {
|
|
510
|
+
if (ch === "[") {
|
|
511
|
+
escapeState = "csi";
|
|
512
|
+
continue;
|
|
513
|
+
}
|
|
514
|
+
if (ch === "O") {
|
|
515
|
+
escapeState = "ss3";
|
|
516
|
+
continue;
|
|
517
|
+
}
|
|
518
|
+
if (ch === "]") {
|
|
519
|
+
escapeState = "osc";
|
|
520
|
+
continue;
|
|
521
|
+
}
|
|
522
|
+
escapeState = "none";
|
|
523
|
+
if (code !== 4 && ch !== "\r" && ch !== `
|
|
524
|
+
`)
|
|
525
|
+
continue;
|
|
526
|
+
}
|
|
527
|
+
if (escapeState === "csi") {
|
|
528
|
+
if (code >= 32 && code <= 63)
|
|
529
|
+
continue;
|
|
530
|
+
escapeState = "none";
|
|
531
|
+
if (code >= 64 && code <= 126)
|
|
532
|
+
continue;
|
|
533
|
+
}
|
|
534
|
+
if (code === 27) {
|
|
535
|
+
escapeState = "esc";
|
|
536
|
+
continue;
|
|
537
|
+
}
|
|
538
|
+
if (code === 4 || ch === "\r" || ch === `
|
|
539
|
+
`) {
|
|
540
|
+
complete();
|
|
541
|
+
return;
|
|
542
|
+
}
|
|
543
|
+
if (code === 127 || code === 8) {
|
|
544
|
+
const popped = chars.pop();
|
|
545
|
+
if (popped !== undefined)
|
|
546
|
+
byteCount -= utf8ByteLength(popped);
|
|
547
|
+
continue;
|
|
548
|
+
}
|
|
549
|
+
if (code < 32 && ch !== "\t")
|
|
550
|
+
continue;
|
|
551
|
+
const added = utf8ByteLength(ch);
|
|
552
|
+
if (byteCount + added > maxBytes) {
|
|
553
|
+
fail(validationSecretError(`Secret exceeds ${maxBytes}-byte limit`), true);
|
|
554
|
+
return;
|
|
555
|
+
}
|
|
556
|
+
chars.push(ch);
|
|
557
|
+
byteCount += added;
|
|
558
|
+
}
|
|
559
|
+
};
|
|
560
|
+
try {
|
|
561
|
+
setRawMode.call(input, true);
|
|
562
|
+
rawModeActive = true;
|
|
563
|
+
} catch (error) {
|
|
564
|
+
fail(error);
|
|
565
|
+
return;
|
|
566
|
+
}
|
|
567
|
+
process.once("exit", restoreRaw);
|
|
568
|
+
signal?.addEventListener("abort", onAbort, { once: true });
|
|
569
|
+
input.on("data", onData);
|
|
570
|
+
input.on("end", onEnd);
|
|
571
|
+
input.on("close", onClose);
|
|
572
|
+
input.on("error", onError);
|
|
573
|
+
input.resume();
|
|
574
|
+
if (prompt !== undefined && prompt.length > 0)
|
|
575
|
+
safeWrite(prompt);
|
|
576
|
+
});
|
|
577
|
+
}
|
|
578
|
+
function readSecretFromPipe(input, maxBytes, signal) {
|
|
579
|
+
return new Promise((resolve, reject) => {
|
|
580
|
+
const chunks = [];
|
|
581
|
+
let totalBytes = 0;
|
|
582
|
+
const wireLimit = maxBytes + 2;
|
|
583
|
+
let finished = false;
|
|
584
|
+
const cleanup = () => {
|
|
585
|
+
input.off("data", onData);
|
|
586
|
+
input.off("end", onEnd);
|
|
587
|
+
input.off("close", onClose);
|
|
588
|
+
input.off("error", onError);
|
|
589
|
+
signal?.removeEventListener("abort", onAbort);
|
|
590
|
+
input.pause();
|
|
591
|
+
};
|
|
592
|
+
const fail = (error) => {
|
|
593
|
+
if (finished)
|
|
594
|
+
return;
|
|
595
|
+
finished = true;
|
|
596
|
+
cleanup();
|
|
597
|
+
reject(error);
|
|
598
|
+
};
|
|
599
|
+
const onAbort = () => fail(abortedSecretError("Secret input aborted"));
|
|
600
|
+
const onError = (error) => fail(error);
|
|
601
|
+
const onClose = () => {
|
|
602
|
+
if (totalBytes > 0)
|
|
603
|
+
onEnd();
|
|
604
|
+
else
|
|
605
|
+
fail(abortedSecretError("Secret input stream closed"));
|
|
606
|
+
};
|
|
607
|
+
const onData = (chunk) => {
|
|
608
|
+
if (finished)
|
|
609
|
+
return;
|
|
610
|
+
const buf = typeof chunk === "string" ? utf8Encoder.encode(chunk) : chunk;
|
|
611
|
+
totalBytes += buf.byteLength;
|
|
612
|
+
if (totalBytes > wireLimit) {
|
|
613
|
+
fail(validationSecretError(`Secret exceeds ${maxBytes}-byte limit`));
|
|
614
|
+
return;
|
|
615
|
+
}
|
|
616
|
+
chunks.push(buf);
|
|
617
|
+
};
|
|
618
|
+
const onEnd = () => {
|
|
619
|
+
if (finished)
|
|
620
|
+
return;
|
|
621
|
+
finished = true;
|
|
622
|
+
cleanup();
|
|
623
|
+
let text;
|
|
624
|
+
try {
|
|
625
|
+
text = decodeUtf8Strict(concatBytes(chunks, totalBytes));
|
|
626
|
+
} catch {
|
|
627
|
+
reject(validationSecretError("Secret input must be valid UTF-8"));
|
|
628
|
+
return;
|
|
629
|
+
}
|
|
630
|
+
const secret = stripSingleTrailingNewline(text);
|
|
631
|
+
if (utf8ByteLength(secret) > maxBytes) {
|
|
632
|
+
reject(validationSecretError(`Secret exceeds ${maxBytes}-byte limit`));
|
|
633
|
+
return;
|
|
634
|
+
}
|
|
635
|
+
if (secret.length === 0) {
|
|
636
|
+
reject(validationSecretError("Secret cannot be empty"));
|
|
637
|
+
return;
|
|
638
|
+
}
|
|
639
|
+
resolve(secret);
|
|
640
|
+
};
|
|
641
|
+
signal?.addEventListener("abort", onAbort, { once: true });
|
|
642
|
+
input.on("data", onData);
|
|
643
|
+
input.on("end", onEnd);
|
|
644
|
+
input.on("close", onClose);
|
|
645
|
+
input.on("error", onError);
|
|
646
|
+
input.resume();
|
|
647
|
+
});
|
|
648
|
+
}
|
|
649
|
+
async function readSecret(options = {}) {
|
|
650
|
+
assertPositiveSafeInteger("readSecret maxBytes", options.maxBytes);
|
|
651
|
+
const maxBytes = options.maxBytes ?? DEFAULT_MAX_SECRET_BYTES;
|
|
652
|
+
if (options.signal?.aborted) {
|
|
653
|
+
throw abortedSecretError("Secret input aborted");
|
|
654
|
+
}
|
|
655
|
+
const input = options.input ?? process.stdin;
|
|
656
|
+
const output = options.output ?? ((text) => {
|
|
657
|
+
process.stderr.write(text);
|
|
658
|
+
});
|
|
659
|
+
if (input.isTTY === true) {
|
|
660
|
+
return readSecretFromTty(input, output, options.prompt, maxBytes, options.signal);
|
|
661
|
+
}
|
|
662
|
+
return readSecretFromPipe(input, maxBytes, options.signal);
|
|
663
|
+
}
|
|
664
|
+
function readSecretFile(path, options = {}) {
|
|
665
|
+
assertPositiveSafeInteger("readSecretFile maxBytes", options.maxBytes);
|
|
666
|
+
const maxBytes = options.maxBytes ?? DEFAULT_MAX_SECRET_BYTES;
|
|
667
|
+
let bytes;
|
|
668
|
+
try {
|
|
669
|
+
bytes = readRegularFileSync2(path, {
|
|
670
|
+
limit: maxBytes + 2,
|
|
671
|
+
noFollow: true,
|
|
672
|
+
accept: (info) => (Number(info.mode) & 63) === 0
|
|
673
|
+
});
|
|
674
|
+
} catch (error) {
|
|
675
|
+
if (errnoOf(error) === "ENOENT") {
|
|
676
|
+
throw new AppError2("NOT_FOUND", {
|
|
677
|
+
status: 404,
|
|
678
|
+
message: `Secret file not found: ${path}`,
|
|
679
|
+
retryable: false,
|
|
680
|
+
cause: error
|
|
681
|
+
});
|
|
682
|
+
}
|
|
683
|
+
if (error instanceof RegularFileError2) {
|
|
684
|
+
if (error.reason === "rejected") {
|
|
685
|
+
throw new AppError2("FORBIDDEN", {
|
|
686
|
+
status: 403,
|
|
687
|
+
message: `Secret file "${path}" is accessible to group or others`,
|
|
688
|
+
hint: `Run "chmod 600 ${path}" and try again.`,
|
|
689
|
+
retryable: false,
|
|
690
|
+
cause: error
|
|
691
|
+
});
|
|
692
|
+
}
|
|
693
|
+
if (error.reason === "symbolic-link" || error.reason === "not-regular") {
|
|
694
|
+
throw new AppError2("FILE_NOT_REGULAR", {
|
|
695
|
+
status: 422,
|
|
696
|
+
message: error.message,
|
|
697
|
+
retryable: false,
|
|
698
|
+
cause: error
|
|
699
|
+
});
|
|
700
|
+
}
|
|
701
|
+
if (error.reason === "too-large") {
|
|
702
|
+
throw new AppError2("VALIDATION_ERROR", {
|
|
703
|
+
status: 400,
|
|
704
|
+
message: `Secret exceeds ${maxBytes}-byte limit`,
|
|
705
|
+
retryable: false,
|
|
706
|
+
cause: error
|
|
707
|
+
});
|
|
708
|
+
}
|
|
709
|
+
}
|
|
710
|
+
throw error;
|
|
711
|
+
}
|
|
712
|
+
let decoded;
|
|
713
|
+
try {
|
|
714
|
+
decoded = decodeUtf8Strict(bytes);
|
|
715
|
+
} catch (error) {
|
|
716
|
+
throw new AppError2("VALIDATION_ERROR", {
|
|
717
|
+
status: 400,
|
|
718
|
+
message: "Secret file must be valid UTF-8",
|
|
719
|
+
retryable: false,
|
|
720
|
+
cause: error
|
|
721
|
+
});
|
|
722
|
+
}
|
|
723
|
+
const secret = stripSingleTrailingNewline(decoded);
|
|
724
|
+
if (utf8ByteLength(secret) > maxBytes) {
|
|
725
|
+
throw validationSecretError(`Secret exceeds ${maxBytes}-byte limit`);
|
|
726
|
+
}
|
|
727
|
+
if (secret.length === 0) {
|
|
728
|
+
throw validationSecretError("Secret file is empty");
|
|
729
|
+
}
|
|
730
|
+
return secret;
|
|
731
|
+
}
|
|
268
732
|
// src/tools/cli/stream.ts
|
|
269
|
-
import { z } from "zod";
|
|
270
|
-
var RecordedAnswerSchema =
|
|
271
|
-
ok:
|
|
272
|
-
exitCode:
|
|
273
|
-
data:
|
|
274
|
-
written:
|
|
733
|
+
import { z as z2 } from "zod";
|
|
734
|
+
var RecordedAnswerSchema = z2.object({
|
|
735
|
+
ok: z2.literal(true),
|
|
736
|
+
exitCode: z2.number(),
|
|
737
|
+
data: z2.unknown().optional(),
|
|
738
|
+
written: z2.object({ stdout: z2.string().optional(), stderr: z2.string().optional() }).optional()
|
|
275
739
|
});
|
|
276
|
-
var LineSchema =
|
|
277
|
-
id:
|
|
278
|
-
command:
|
|
279
|
-
args:
|
|
740
|
+
var LineSchema = z2.object({
|
|
741
|
+
id: z2.string().min(1),
|
|
742
|
+
command: z2.string().min(1),
|
|
743
|
+
args: z2.record(z2.string(), z2.unknown()).default({})
|
|
280
744
|
});
|
|
281
745
|
async function* readStdinLines(source = process.stdin) {
|
|
282
746
|
const decoder = new TextDecoder;
|
|
@@ -296,12 +760,12 @@ async function* readStdinLines(source = process.stdin) {
|
|
|
296
760
|
if (pending !== "")
|
|
297
761
|
yield pending.endsWith("\r") ? pending.slice(0, -1) : pending;
|
|
298
762
|
}
|
|
299
|
-
function parseLine(line) {
|
|
763
|
+
function parseLine(line, errors) {
|
|
300
764
|
let parsed;
|
|
301
765
|
try {
|
|
302
766
|
parsed = safeJsonParse(line);
|
|
303
767
|
} catch {
|
|
304
|
-
return { ok: false, answer: malformed("the line is not JSON") };
|
|
768
|
+
return { ok: false, answer: malformed("the line is not JSON", errors) };
|
|
305
769
|
}
|
|
306
770
|
const result = LineSchema.safeParse(parsed);
|
|
307
771
|
if (!result.success) {
|
|
@@ -309,26 +773,32 @@ function parseLine(line) {
|
|
|
309
773
|
return {
|
|
310
774
|
ok: false,
|
|
311
775
|
answer: {
|
|
312
|
-
...malformed("the line needs `id` and `command`"),
|
|
776
|
+
...malformed("the line needs `id` and `command`", errors),
|
|
313
777
|
...id !== undefined && { id }
|
|
314
778
|
}
|
|
315
779
|
};
|
|
316
780
|
}
|
|
317
781
|
return { ok: true, value: result.data };
|
|
318
782
|
}
|
|
319
|
-
function
|
|
783
|
+
function streamFailureAnswer(id, code, message, errors) {
|
|
784
|
+
const mapped = applyToolErrorMapping({ ok: false, code, details: { message } }, errors);
|
|
785
|
+
const normalized = toolErrorFromResult(mapped);
|
|
320
786
|
return {
|
|
321
|
-
id
|
|
787
|
+
id,
|
|
322
788
|
ok: false,
|
|
323
789
|
exitCode: 2,
|
|
324
|
-
error: { code:
|
|
790
|
+
error: { code: mapped.code, message: normalized.message }
|
|
325
791
|
};
|
|
326
792
|
}
|
|
793
|
+
function malformed(message, errors) {
|
|
794
|
+
return streamFailureAnswer("", "BAD_REQUEST", message, errors);
|
|
795
|
+
}
|
|
327
796
|
async function runCliStream(invoker, lines, onAnswer, hooks = {}) {
|
|
797
|
+
const errors = cliInvokerErrorMapping(invoker);
|
|
328
798
|
for await (const line of lines) {
|
|
329
799
|
if (line.trim() === "")
|
|
330
800
|
continue;
|
|
331
|
-
const parsed = parseLine(line);
|
|
801
|
+
const parsed = parseLine(line, errors);
|
|
332
802
|
if (!parsed.ok) {
|
|
333
803
|
onAnswer(parsed.answer);
|
|
334
804
|
continue;
|
|
@@ -348,7 +818,7 @@ function defineCliStreamCommand(config) {
|
|
|
348
818
|
return defineCliCommand2({
|
|
349
819
|
name: config.name ?? "stream",
|
|
350
820
|
description: config.description ?? "Run one operation per JSON line of stdin, answering each",
|
|
351
|
-
input:
|
|
821
|
+
input: z2.object({}),
|
|
352
822
|
handler: async (context) => {
|
|
353
823
|
const invoker = typeof config.invoker === "function" ? await config.invoker() : config.invoker;
|
|
354
824
|
await runCliStream(invoker, (config.readLines ?? readStdinLines)(), (answer) => {
|
|
@@ -362,11 +832,12 @@ function defineCliBatchCommand(config) {
|
|
|
362
832
|
return defineCliCommand2({
|
|
363
833
|
name: config.name ?? "batch",
|
|
364
834
|
description: config.description ?? "Run one operation per JSON line of stdin, resuming from a checkpoint",
|
|
365
|
-
input:
|
|
366
|
-
checkpoint:
|
|
835
|
+
input: z2.object({
|
|
836
|
+
checkpoint: z2.string().optional()
|
|
367
837
|
}),
|
|
368
838
|
handler: async (context) => {
|
|
369
839
|
const invoker = typeof config.invoker === "function" ? await config.invoker() : config.invoker;
|
|
840
|
+
const errors = cliInvokerErrorMapping(invoker);
|
|
370
841
|
const path = context.input.checkpoint ?? config.checkpointPath ?? ".stitchkit-batch.json";
|
|
371
842
|
const checkpoint = readCliCheckpoint(path);
|
|
372
843
|
await runCliStream(invoker, (config.readLines ?? readStdinLines)(), (answer) => {
|
|
@@ -381,27 +852,11 @@ function defineCliBatchCommand(config) {
|
|
|
381
852
|
if (!recorded)
|
|
382
853
|
return;
|
|
383
854
|
if (recorded.digest !== digest) {
|
|
384
|
-
return
|
|
385
|
-
id,
|
|
386
|
-
ok: false,
|
|
387
|
-
exitCode: 2,
|
|
388
|
-
error: {
|
|
389
|
-
code: "CONFLICT",
|
|
390
|
-
message: "this id was already run with different content — change the id or start a new checkpoint"
|
|
391
|
-
}
|
|
392
|
-
};
|
|
855
|
+
return streamFailureAnswer(id, "CONFLICT", "this id was already run with different content — change the id or start a new checkpoint", errors);
|
|
393
856
|
}
|
|
394
857
|
const replay = RecordedAnswerSchema.safeParse(recorded.answer);
|
|
395
858
|
if (!replay.success) {
|
|
396
|
-
return
|
|
397
|
-
id,
|
|
398
|
-
ok: false,
|
|
399
|
-
exitCode: 2,
|
|
400
|
-
error: {
|
|
401
|
-
code: "CONFLICT",
|
|
402
|
-
message: "this id is recorded as done but its recorded answer is unreadable — change the id or start a new checkpoint"
|
|
403
|
-
}
|
|
404
|
-
};
|
|
859
|
+
return streamFailureAnswer(id, "CONFLICT", "this id is recorded as done but its recorded answer is unreadable — change the id or start a new checkpoint", errors);
|
|
405
860
|
}
|
|
406
861
|
return { ...replay.data, id, replayed: true };
|
|
407
862
|
},
|
|
@@ -425,6 +880,7 @@ export {
|
|
|
425
880
|
CliProfileError,
|
|
426
881
|
CliTrustRootSchema2 as CliTrustRootSchema,
|
|
427
882
|
DEFAULT_EXIT_CODES2 as DEFAULT_EXIT_CODES,
|
|
883
|
+
LocalKeyInitOutputSchema,
|
|
428
884
|
applyCliUpdate2 as applyCliUpdate,
|
|
429
885
|
assertCliPublishable2 as assertCliPublishable,
|
|
430
886
|
checkCliUpdate2 as checkCliUpdate,
|
|
@@ -442,12 +898,15 @@ export {
|
|
|
442
898
|
defineCliCommand2 as defineCliCommand,
|
|
443
899
|
defineCliResult2 as defineCliResult,
|
|
444
900
|
defineCliStreamCommand,
|
|
901
|
+
defineLocalKeyInitCommand,
|
|
445
902
|
emitResult2 as emitResult,
|
|
446
903
|
extractCliGlobalOptions2 as extractCliGlobalOptions,
|
|
447
904
|
formatCliBuildStamp2 as formatCliBuildStamp,
|
|
448
905
|
parseCliArgs2 as parseCliArgs,
|
|
449
906
|
pollUntilDone2 as pollUntilDone,
|
|
450
907
|
readCliCheckpoint,
|
|
908
|
+
readSecret,
|
|
909
|
+
readSecretFile,
|
|
451
910
|
renderCliInstaller2 as renderCliInstaller,
|
|
452
911
|
renderCliView2 as renderCliView,
|
|
453
912
|
rollbackCliUpdate2 as rollbackCliUpdate,
|