stitchkit 0.136.7 → 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.
Files changed (358) hide show
  1. package/CHANGELOG.md +68 -0
  2. package/dist/agent-runtime/stores/branch-observations.d.ts +19 -19
  3. package/dist/agent-runtime/stores/schedule-contract.d.ts.map +1 -1
  4. package/dist/agent-runtime/stores/schedule-records.d.ts.map +1 -1
  5. package/dist/agent-runtime/stores/schedule-tools.d.ts.map +1 -1
  6. package/dist/agent-runtime/stores/sql-rows.d.ts +36 -36
  7. package/dist/agent-runtime/terminal-commit.d.ts +5 -5
  8. package/dist/agent-runtime/testing/store-conformance-lifecycle.d.ts +52 -52
  9. package/dist/agent-runtime/testing/store-conformance-support.d.ts +26 -26
  10. package/dist/browser/client-executors.d.ts +2 -3
  11. package/dist/browser/client-executors.d.ts.map +1 -1
  12. package/dist/browser/realtime-client.d.ts +6 -1
  13. package/dist/browser/realtime-client.d.ts.map +1 -1
  14. package/dist/browser/socket-io-client.d.ts.map +1 -1
  15. package/dist/browser/socket-io-contract.d.ts +2 -0
  16. package/dist/browser/socket-io-contract.d.ts.map +1 -1
  17. package/dist/contract/define-validation.d.ts +6 -0
  18. package/dist/contract/define-validation.d.ts.map +1 -1
  19. package/dist/contract/define.d.ts +1 -1
  20. package/dist/contract/define.d.ts.map +1 -1
  21. package/dist/contract/error-mapping.d.ts +71 -0
  22. package/dist/contract/error-mapping.d.ts.map +1 -0
  23. package/dist/contract/errors.d.ts +8 -0
  24. package/dist/contract/errors.d.ts.map +1 -1
  25. package/dist/contract/factory.d.ts +8 -0
  26. package/dist/contract/factory.d.ts.map +1 -1
  27. package/dist/contract/fragments.d.ts +45 -0
  28. package/dist/contract/fragments.d.ts.map +1 -0
  29. package/dist/contract/normalize.d.ts +6 -3
  30. package/dist/contract/normalize.d.ts.map +1 -1
  31. package/dist/contract/operation-read.d.ts +38 -0
  32. package/dist/contract/operation-read.d.ts.map +1 -0
  33. package/dist/contract/stream.d.ts.map +1 -1
  34. package/dist/contract/time-zone.d.ts +31 -0
  35. package/dist/contract/time-zone.d.ts.map +1 -0
  36. package/dist/contract/tool-options.d.ts +1 -1
  37. package/dist/contract/tool-options.d.ts.map +1 -1
  38. package/dist/device-relay/hub.d.ts +1 -1
  39. package/dist/device-relay/hub.d.ts.map +1 -1
  40. package/dist/entrypoints/agent-executor/acp.js +9 -9
  41. package/dist/entrypoints/agent-executor/claude-sdk.js +11 -11
  42. package/dist/entrypoints/agent-executor/claude.js +8 -8
  43. package/dist/entrypoints/agent-executor/codex.js +15 -15
  44. package/dist/entrypoints/agent-executor/testing.js +11 -11
  45. package/dist/entrypoints/agent-executor.js +14 -13
  46. package/dist/entrypoints/agent-runtime/ai-sdk.js +5 -5
  47. package/dist/entrypoints/agent-runtime/anthropic.js +1 -1
  48. package/dist/entrypoints/agent-runtime/browser.js +5 -5
  49. package/dist/entrypoints/agent-runtime/coding-tools.js +3 -3
  50. package/dist/entrypoints/agent-runtime/harness.js +14 -15
  51. package/dist/entrypoints/agent-runtime/openai.js +1 -1
  52. package/dist/entrypoints/agent-runtime/openrouter.js +7 -7
  53. package/dist/entrypoints/agent-runtime/postgres.js +5 -5
  54. package/dist/entrypoints/agent-runtime/realtime.js +8 -8
  55. package/dist/entrypoints/agent-runtime/sandbox.js +7 -7
  56. package/dist/entrypoints/agent-runtime/sqlite/bun.js +6 -6
  57. package/dist/entrypoints/agent-runtime/sqlite/node.js +6 -6
  58. package/dist/entrypoints/agent-runtime/testing.js +5 -5
  59. package/dist/entrypoints/agent-runtime.js +33 -29
  60. package/dist/entrypoints/application/diagnostic-journal.js +3 -3
  61. package/dist/entrypoints/application/directory-inbox.js +1 -1
  62. package/dist/entrypoints/application/grammy.js +1 -1
  63. package/dist/entrypoints/application/opentelemetry.js +2 -2
  64. package/dist/entrypoints/application.js +10 -10
  65. package/dist/entrypoints/cli/publish.d.ts +4 -4
  66. package/dist/entrypoints/cli/publish.d.ts.map +1 -1
  67. package/dist/entrypoints/cli/publish.js +160 -52
  68. package/dist/entrypoints/cli.d.ts +3 -1
  69. package/dist/entrypoints/cli.d.ts.map +1 -1
  70. package/dist/entrypoints/cli.js +520 -59
  71. package/dist/entrypoints/contract.d.ts +5 -1
  72. package/dist/entrypoints/contract.d.ts.map +1 -1
  73. package/dist/entrypoints/contract.js +25 -7
  74. package/dist/entrypoints/device-relay.js +20 -10
  75. package/dist/entrypoints/files/packaging.js +2 -2
  76. package/dist/entrypoints/files.js +10 -10
  77. package/dist/entrypoints/handler.d.ts +1 -1
  78. package/dist/entrypoints/handler.d.ts.map +1 -1
  79. package/dist/entrypoints/handler.js +12 -12
  80. package/dist/entrypoints/http.js +13 -12
  81. package/dist/entrypoints/index.js +36 -18
  82. package/dist/entrypoints/live.d.ts +2 -1
  83. package/dist/entrypoints/live.d.ts.map +1 -1
  84. package/dist/entrypoints/live.js +630 -1
  85. package/dist/entrypoints/node.d.ts +5 -0
  86. package/dist/entrypoints/node.d.ts.map +1 -1
  87. package/dist/entrypoints/node.js +36 -16
  88. package/dist/entrypoints/observability.js +25 -10
  89. package/dist/entrypoints/postgres.d.ts +4 -1
  90. package/dist/entrypoints/postgres.d.ts.map +1 -1
  91. package/dist/entrypoints/postgres.js +312 -0
  92. package/dist/entrypoints/primitives.js +11 -4
  93. package/dist/entrypoints/process.js +7 -7
  94. package/dist/entrypoints/react.js +1 -1
  95. package/dist/entrypoints/realtime.js +3 -3
  96. package/dist/entrypoints/remote.js +6 -29
  97. package/dist/entrypoints/server.d.ts +6 -1
  98. package/dist/entrypoints/server.d.ts.map +1 -1
  99. package/dist/entrypoints/server.js +93 -32
  100. package/dist/entrypoints/service-host/macos.js +6 -6
  101. package/dist/entrypoints/service-host/work.js +6 -6
  102. package/dist/entrypoints/service-host.js +10 -10
  103. package/dist/entrypoints/spend.js +2 -1
  104. package/dist/entrypoints/sync.js +5 -5
  105. package/dist/entrypoints/telegram.js +8 -8
  106. package/dist/entrypoints/testing.d.ts +1 -0
  107. package/dist/entrypoints/testing.d.ts.map +1 -1
  108. package/dist/entrypoints/testing.js +1501 -13
  109. package/dist/entrypoints/tools/agent.js +6 -7
  110. package/dist/entrypoints/tools/connections.js +9 -11
  111. package/dist/entrypoints/tools/contract.js +1 -2
  112. package/dist/entrypoints/tools/invoker.js +4 -5
  113. package/dist/entrypoints/tools/mcp.js +10 -11
  114. package/dist/entrypoints/tools/toolkit.d.ts +1 -1
  115. package/dist/entrypoints/tools/toolkit.d.ts.map +1 -1
  116. package/dist/entrypoints/tools/toolkit.js +29 -24
  117. package/dist/entrypoints/tools.js +28 -30
  118. package/dist/entrypoints/tracking/contract.js +2 -1
  119. package/dist/entrypoints/xlsx.js +5 -8
  120. package/dist/{index-033tyx59.js → index-0zw0hcyg.js} +4 -1
  121. package/dist/{index-zcq3dby3.js → index-1bjwfnnj.js} +1 -1
  122. package/dist/{index-f103md2v.js → index-1cfacbe2.js} +88 -23
  123. package/dist/{index-gj4wdts6.js → index-1ckh9qx1.js} +1 -1
  124. package/dist/index-1pvwmbxp.js +1435 -0
  125. package/dist/{index-0s75mjh7.js → index-2e4hdh32.js} +1 -1
  126. package/dist/{index-3shdhzt6.js → index-2j0pqxkn.js} +12 -6
  127. package/dist/index-3k8w02se.js +28 -0
  128. package/dist/{index-7fjbdga8.js → index-3pb4ccj2.js} +8 -0
  129. package/dist/{index-w7e402wx.js → index-48kb4gqq.js} +46 -7
  130. package/dist/{index-cv9b7fz2.js → index-6rws2xf5.js} +8 -0
  131. package/dist/{index-bbpygynk.js → index-77w5vx0g.js} +1 -1
  132. package/dist/index-7dz1ngaf.js +35 -0
  133. package/dist/{index-y68gavb5.js → index-7n4atsm4.js} +1 -1
  134. package/dist/index-8ef1bfea.js +71 -0
  135. package/dist/{index-0x4mnwg5.js → index-8k3y9nd4.js} +6 -9
  136. package/dist/{index-ezwsqyad.js → index-8rkdkefj.js} +40 -23
  137. package/dist/{index-3cwq5byx.js → index-9nax7tkn.js} +2 -2
  138. package/dist/{index-dz6tstcp.js → index-9r6emjwz.js} +1 -1
  139. package/dist/{index-32ew02z1.js → index-c4b7d6ej.js} +5 -5
  140. package/dist/index-ceshyndf.js +284 -0
  141. package/dist/{index-w161azza.js → index-d13rw31w.js} +6 -6
  142. package/dist/{index-1h0dtfz3.js → index-dmm7vs3f.js} +1 -1
  143. package/dist/{index-ypm85xwe.js → index-dp8j2e77.js} +1 -1
  144. package/dist/{index-qqd979f7.js → index-edycjvrv.js} +9 -9
  145. package/dist/{index-18qdpbcq.js → index-egpf9dv0.js} +200 -1479
  146. package/dist/{index-fatke81t.js → index-ezgvsj9w.js} +2 -2
  147. package/dist/{index-chapre0y.js → index-f3e7tj1g.js} +1 -1
  148. package/dist/{index-df5xr2f9.js → index-frsd2a94.js} +16 -1
  149. package/dist/index-fy9mmek1.js +95 -0
  150. package/dist/{index-2331y2tf.js → index-g0gvfzrx.js} +12 -12
  151. package/dist/index-gpe8d1ka.js +19 -0
  152. package/dist/{index-4p2zx593.js → index-gyw4qd0m.js} +1 -1
  153. package/dist/index-gzqy81tw.js +172 -0
  154. package/dist/{index-yrhw10ef.js → index-h34c510q.js} +8 -4
  155. package/dist/{index-rr94xcj6.js → index-h527p1yj.js} +10 -4
  156. package/dist/{index-qj0sq69b.js → index-hgf1tbgz.js} +76 -16
  157. package/dist/{index-smvmnz5y.js → index-hvpan32x.js} +1 -1
  158. package/dist/{index-4gbybjg6.js → index-hxawqrb6.js} +2 -2
  159. package/dist/{index-0k1ba0ss.js → index-j91jffhv.js} +1 -1
  160. package/dist/{index-d01akj5n.js → index-jr4kwetx.js} +8 -8
  161. package/dist/{index-xqppqn97.js → index-ka6z48zc.js} +315 -69
  162. package/dist/{index-by8w2461.js → index-kw0segzt.js} +104 -3
  163. package/dist/{index-6f4fjygr.js → index-m5t4dr7h.js} +29 -7
  164. package/dist/{index-afaq0nc4.js → index-n0egp1ke.js} +1 -1
  165. package/dist/{index-9fzjgg86.js → index-n74rb1dq.js} +2 -2
  166. package/dist/{index-dwq6a6sq.js → index-pt25vmhc.js} +33 -16
  167. package/dist/{index-vwg0n3e6.js → index-pyazb8q4.js} +23 -14
  168. package/dist/{index-5md04mwc.js → index-qpjjbkc5.js} +4 -4
  169. package/dist/{index-08a3qfr8.js → index-r1qt6zgj.js} +1 -1
  170. package/dist/{index-ctaxjpa4.js → index-r709pqed.js} +1 -1
  171. package/dist/{index-2zrx0nzv.js → index-rzc40z6e.js} +3 -5
  172. package/dist/{index-gq35s3bm.js → index-s5axtd56.js} +2 -2
  173. package/dist/{index-edpkm3k7.js → index-scpcps66.js} +669 -16
  174. package/dist/{index-ry8m2mhg.js → index-sf2mt6wj.js} +1 -1
  175. package/dist/{index-tjhhsnjv.js → index-t1213r0t.js} +1 -1
  176. package/dist/{index-gvgtmt7a.js → index-t7efje30.js} +2 -2
  177. package/dist/{index-w3s79kcb.js → index-tzyk36dy.js} +1 -1
  178. package/dist/{index-8tn10tp6.js → index-v64bvwjr.js} +1 -1
  179. package/dist/{index-1fhbe4e4.js → index-vksbsqpb.js} +1 -1
  180. package/dist/{index-dxft2mnm.js → index-wdg7bswj.js} +1 -1
  181. package/dist/{index-ppy23bd2.js → index-wjx1zs2r.js} +7 -578
  182. package/dist/{index-efbzm2se.js → index-x2r0ma9t.js} +1 -1
  183. package/dist/{index-kd48gk7d.js → index-x8py72a3.js} +1 -1
  184. package/dist/index-xvydbxmk.js +1404 -0
  185. package/dist/index-xwaphv0d.js +31 -0
  186. package/dist/{index-a09r9ff0.js → index-y44j39yk.js} +1 -1
  187. package/dist/{index-7mjsb7zv.js → index-ybrrxjhb.js} +1 -1
  188. package/dist/{index-xsrma0jd.js → index-ysthxsa8.js} +6 -6
  189. package/dist/{index-6p5pshcd.js → index-yyh3ey4b.js} +1 -1
  190. package/dist/{index-mr3njw67.js → index-z6hq9j8j.js} +1 -1
  191. package/dist/{index-67mzzkdv.js → index-z72agxdn.js} +2 -2
  192. package/dist/{index-e4w0sfm1.js → index-z78mtc16.js} +1 -1
  193. package/dist/{index-7csn6pva.js → index-ze94h4ph.js} +5 -0
  194. package/dist/internal/json-stringify.d.ts +12 -0
  195. package/dist/internal/json-stringify.d.ts.map +1 -1
  196. package/dist/internal/unix-client-error.d.ts +4 -0
  197. package/dist/internal/unix-client-error.d.ts.map +1 -1
  198. package/dist/live/watch-contract.d.ts +4 -0
  199. package/dist/live/watch-contract.d.ts.map +1 -1
  200. package/dist/live/watch-fanout-frame.d.ts +81 -0
  201. package/dist/live/watch-fanout-frame.d.ts.map +1 -0
  202. package/dist/live/watch-fanout.d.ts +57 -0
  203. package/dist/live/watch-fanout.d.ts.map +1 -0
  204. package/dist/observability/audit.d.ts.map +1 -1
  205. package/dist/observability/spool-core.d.ts +1 -0
  206. package/dist/observability/spool-core.d.ts.map +1 -1
  207. package/dist/observability/spool-drain.d.ts +48 -0
  208. package/dist/observability/spool-drain.d.ts.map +1 -0
  209. package/dist/observability/spool.d.ts +12 -6
  210. package/dist/observability/spool.d.ts.map +1 -1
  211. package/dist/postgres/connection-config.d.ts +54 -0
  212. package/dist/postgres/connection-config.d.ts.map +1 -0
  213. package/dist/postgres/rollback-transaction.d.ts +61 -0
  214. package/dist/postgres/rollback-transaction.d.ts.map +1 -0
  215. package/dist/primitives/deadline.d.ts +4 -4
  216. package/dist/primitives/deadline.d.ts.map +1 -1
  217. package/dist/server/error-hook.d.ts +3 -32
  218. package/dist/server/error-hook.d.ts.map +1 -1
  219. package/dist/server/local-consent-key.d.ts +104 -0
  220. package/dist/server/local-consent-key.d.ts.map +1 -0
  221. package/dist/server/local-control-journal.d.ts +51 -0
  222. package/dist/server/local-control-journal.d.ts.map +1 -0
  223. package/dist/server/local-control-reporter.d.ts +32 -0
  224. package/dist/server/local-control-reporter.d.ts.map +1 -0
  225. package/dist/server/local-control.d.ts +48 -0
  226. package/dist/server/local-control.d.ts.map +1 -0
  227. package/dist/server/local-host-clients.d.ts +105 -0
  228. package/dist/server/local-host-clients.d.ts.map +1 -0
  229. package/dist/server/middleware/trust-fence.d.ts +20 -0
  230. package/dist/server/middleware/trust-fence.d.ts.map +1 -1
  231. package/dist/spend/receipt-spool.d.ts +9 -4
  232. package/dist/spend/receipt-spool.d.ts.map +1 -1
  233. package/dist/testing/tool-surface-checks.d.ts +89 -0
  234. package/dist/testing/tool-surface-checks.d.ts.map +1 -0
  235. package/dist/testing/tool-surface-cli-callable.d.ts +63 -0
  236. package/dist/testing/tool-surface-cli-callable.d.ts.map +1 -0
  237. package/dist/testing/tool-surface-dead-refs.d.ts +32 -0
  238. package/dist/testing/tool-surface-dead-refs.d.ts.map +1 -0
  239. package/dist/testing/tool-surface-gates.d.ts +72 -0
  240. package/dist/testing/tool-surface-gates.d.ts.map +1 -0
  241. package/dist/testing/tool-surface-parity-drivers.d.ts +56 -0
  242. package/dist/testing/tool-surface-parity-drivers.d.ts.map +1 -0
  243. package/dist/testing/tool-surface-parity.d.ts +28 -0
  244. package/dist/testing/tool-surface-parity.d.ts.map +1 -0
  245. package/dist/testing/tool-surface-ratchet.d.ts +71 -0
  246. package/dist/testing/tool-surface-ratchet.d.ts.map +1 -0
  247. package/dist/tools/agent-tools.d.ts +3 -0
  248. package/dist/tools/agent-tools.d.ts.map +1 -1
  249. package/dist/tools/cli/command.d.ts +3 -0
  250. package/dist/tools/cli/command.d.ts.map +1 -1
  251. package/dist/tools/cli/create-cli.d.ts.map +1 -1
  252. package/dist/tools/cli/distribution-config.d.ts +39 -1
  253. package/dist/tools/cli/distribution-config.d.ts.map +1 -1
  254. package/dist/tools/cli/distribution-routes.d.ts +4 -2
  255. package/dist/tools/cli/distribution-routes.d.ts.map +1 -1
  256. package/dist/tools/cli/format.d.ts +3 -6
  257. package/dist/tools/cli/format.d.ts.map +1 -1
  258. package/dist/tools/cli/invoke.d.ts +4 -0
  259. package/dist/tools/cli/invoke.d.ts.map +1 -1
  260. package/dist/tools/cli/local-key-command.d.ts +53 -0
  261. package/dist/tools/cli/local-key-command.d.ts.map +1 -0
  262. package/dist/tools/cli/managed-surface.d.ts.map +1 -1
  263. package/dist/tools/cli/publication-contract.d.ts +9 -2
  264. package/dist/tools/cli/publication-contract.d.ts.map +1 -1
  265. package/dist/tools/cli/publication.d.ts.map +1 -1
  266. package/dist/tools/cli/run-managed.d.ts.map +1 -1
  267. package/dist/tools/cli/run-stream.d.ts.map +1 -1
  268. package/dist/tools/cli/runner.d.ts +8 -3
  269. package/dist/tools/cli/runner.d.ts.map +1 -1
  270. package/dist/tools/cli/secret.d.ts +55 -0
  271. package/dist/tools/cli/secret.d.ts.map +1 -0
  272. package/dist/tools/cli/session.d.ts +2 -2
  273. package/dist/tools/cli/session.d.ts.map +1 -1
  274. package/dist/tools/cli/signature.d.ts +23 -9
  275. package/dist/tools/cli/signature.d.ts.map +1 -1
  276. package/dist/tools/cli/stream.d.ts.map +1 -1
  277. package/dist/tools/cli/unix-outcome.d.ts +6 -0
  278. package/dist/tools/cli/unix-outcome.d.ts.map +1 -1
  279. package/dist/tools/cli/update.d.ts +6 -1
  280. package/dist/tools/cli/update.d.ts.map +1 -1
  281. package/dist/tools/execute-result.d.ts +20 -0
  282. package/dist/tools/execute-result.d.ts.map +1 -1
  283. package/dist/tools/execute.d.ts +3 -0
  284. package/dist/tools/execute.d.ts.map +1 -1
  285. package/dist/tools/internal/json-projection.d.ts +13 -9
  286. package/dist/tools/internal/json-projection.d.ts.map +1 -1
  287. package/dist/tools/internal/remote-error.d.ts +15 -0
  288. package/dist/tools/internal/remote-error.d.ts.map +1 -0
  289. package/dist/tools/internal/surface-projector.d.ts +2 -0
  290. package/dist/tools/internal/surface-projector.d.ts.map +1 -1
  291. package/dist/tools/invoker.d.ts +3 -0
  292. package/dist/tools/invoker.d.ts.map +1 -1
  293. package/dist/tools/mcp/handler.d.ts.map +1 -1
  294. package/dist/tools/mcp/lazy-discovery.d.ts +2 -0
  295. package/dist/tools/mcp/lazy-discovery.d.ts.map +1 -1
  296. package/dist/tools/mcp/mount.d.ts +5 -0
  297. package/dist/tools/mcp/mount.d.ts.map +1 -1
  298. package/dist/tools/mcp/register.d.ts +2 -0
  299. package/dist/tools/mcp/register.d.ts.map +1 -1
  300. package/dist/tools/mcp/runtime-tools.d.ts +2 -0
  301. package/dist/tools/mcp/runtime-tools.d.ts.map +1 -1
  302. package/dist/tools/mcp/stdio.d.ts.map +1 -1
  303. package/dist/tools/mount.d.ts +3 -0
  304. package/dist/tools/mount.d.ts.map +1 -1
  305. package/dist/tools/read-operation.d.ts +2 -6
  306. package/dist/tools/read-operation.d.ts.map +1 -1
  307. package/dist/tools/remote.d.ts.map +1 -1
  308. package/dist/tools/runtime-tool.d.ts.map +1 -1
  309. package/dist/tools/toolkit.d.ts +10 -3
  310. package/dist/tools/toolkit.d.ts.map +1 -1
  311. package/dist/xlsx/schema.d.ts.map +1 -1
  312. package/llms/cli-publish.txt +4 -1
  313. package/llms/cli.2.txt +42 -51
  314. package/llms/cli.3.txt +34 -1
  315. package/llms/cli.txt +18 -3
  316. package/llms/contract.txt +47 -5
  317. package/llms/handler.txt +1 -1
  318. package/llms/live.txt +82 -0
  319. package/llms/node.txt +5 -0
  320. package/llms/observability.2.txt +1 -1
  321. package/llms/observability.txt +6 -0
  322. package/llms/postgres.txt +14 -3
  323. package/llms/server.2.txt +206 -240
  324. package/llms/server.3.txt +242 -202
  325. package/llms/server.4.txt +202 -1025
  326. package/llms/server.5.txt +1053 -255
  327. package/llms/server.6.txt +274 -0
  328. package/llms/server.txt +32 -116
  329. package/llms/spend.txt +8 -7
  330. package/llms/stitchkit.2.txt +13 -35
  331. package/llms/stitchkit.3.txt +27 -0
  332. package/llms/stitchkit.txt +82 -82
  333. package/llms/testing.txt +40 -0
  334. package/llms/tools-toolkit.txt +2 -2
  335. package/llms/tools.2.txt +29 -20
  336. package/llms/{upgrading-0.128.0-0.129.0.txt → upgrading-0.128.0-0.131.0.txt} +101 -3
  337. package/llms/{upgrading-0.130.0-0.136.0.txt → upgrading-0.132.0-0.137.0.txt} +62 -101
  338. package/llms/upgrading.txt +2 -2
  339. package/llms-full.txt +641 -189
  340. package/llms.txt +14 -14
  341. package/package.json +3 -3
  342. package/dist/index-9118dw8d.js +0 -603
  343. package/dist/index-9vj869rx.js +0 -19
  344. package/dist/index-a1rjr381.js +0 -114
  345. package/dist/index-dacxr7nf.js +0 -17
  346. package/dist/index-dm50x3by.js +0 -63
  347. package/dist/index-dmrx8xma.js +0 -163
  348. package/dist/index-ednf2cxs.js +0 -37
  349. package/dist/{index-e4zt2x70.js → index-3czppvrr.js} +3 -3
  350. package/dist/{index-42n9jycn.js → index-3f79t32b.js} +3 -3
  351. package/dist/{index-mfe9a266.js → index-84n49vam.js} +0 -0
  352. package/dist/{index-f16b7rze.js → index-er1tp8de.js} +3 -3
  353. package/dist/{index-k137ezb6.js → index-f5d0fdcf.js} +3 -3
  354. package/dist/{index-65p8v81y.js → index-psz8qrz0.js} +3 -3
  355. package/dist/{index-kadgaw1s.js → index-r8cq86h1.js} +0 -0
  356. package/dist/{index-1yky29qg.js → index-tyyvbarf.js} +0 -0
  357. package/dist/{index-tjakdpf2.js → index-wq71v08n.js} +3 -3
  358. package/dist/{index-7an2fs5h.js → index-wswcpbm4.js} +3 -3
@@ -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-qj0sq69b.js";
6
+ } from "../index-hgf1tbgz.js";
8
7
  import {
9
8
  CliArgumentError2,
10
9
  DEFAULT_EXIT_CODES2,
@@ -13,28 +12,40 @@ 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-18qdpbcq.js";
27
- import"../index-edpkm3k7.js";
28
- import"../index-9118dw8d.js";
29
- import"../index-yt1gg11x.js";
30
- import"../index-werjqesf.js";
31
- import"../index-0x4mnwg5.js";
32
- import"../index-6kec3b14.js";
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,
48
+ CliTrustRootSchema2,
38
49
  cliManifestSigningPayload2,
39
50
  signCliManifest2,
40
51
  verifyCliManifest2,
@@ -51,9 +62,16 @@ import {
51
62
  checkCliUpdate2,
52
63
  applyCliUpdate2,
53
64
  rollbackCliUpdate2
54
- } from "../index-f103md2v.js";
55
- import"../index-673drwkn.js";
56
- import"../index-2qnqvq11.js";
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";
57
75
  import"../index-zhngww7q.js";
58
76
  import"../index-rnhp7je8.js";
59
77
  import {
@@ -63,21 +81,33 @@ import"../index-rjs94dny.js";
63
81
  import"../index-xrgn784x.js";
64
82
  import {
65
83
  stringifyJsonSafe
66
- } from "../index-9vj869rx.js";
67
- import"../index-2zrx0nzv.js";
68
- import"../index-7csn6pva.js";
84
+ } from "../index-gzqy81tw.js";
85
+ import"../index-rzc40z6e.js";
86
+ import"../index-ze94h4ph.js";
69
87
  import {
70
88
  safeJsonParse
71
89
  } from "../index-zsarb5xp.js";
90
+ import {
91
+ errnoOf
92
+ } from "../index-jj9228tt.js";
72
93
  import {
73
94
  AppError2
74
- } from "../index-7fjbdga8.js";
95
+ } from "../index-3pb4ccj2.js";
96
+ import {
97
+ argumentsDigest
98
+ } from "../index-3dq8466w.js";
75
99
  import {
76
100
  setOwnMember
77
101
  } from "../index-3tb82xr7.js";
78
102
  import {
79
- argumentsDigest
80
- } from "../index-3dq8466w.js";
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";
81
111
  import {
82
112
  isRecord
83
113
  } from "../index-ps3djm8d.js";
@@ -168,6 +198,55 @@ function writeCliCheckpoint(path, checkpoint) {
168
198
  mode: 384
169
199
  });
170
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
+ }
171
250
  // src/tools/cli/profile.ts
172
251
  import {
173
252
  chmodSync,
@@ -264,18 +343,404 @@ function missingMessage(name, path, config) {
264
343
  const hint = config.createHint ? ` — ${config.createHint(name, path)}` : "";
265
344
  return `profile "${name}" is not configured; expected ${path}${hint}`;
266
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
+ }
267
732
  // src/tools/cli/stream.ts
268
- import { z } from "zod";
269
- var RecordedAnswerSchema = z.object({
270
- ok: z.literal(true),
271
- exitCode: z.number(),
272
- data: z.unknown().optional(),
273
- written: z.object({ stdout: z.string().optional(), stderr: z.string().optional() }).optional()
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()
274
739
  });
275
- var LineSchema = z.object({
276
- id: z.string().min(1),
277
- command: z.string().min(1),
278
- args: z.record(z.string(), z.unknown()).default({})
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({})
279
744
  });
280
745
  async function* readStdinLines(source = process.stdin) {
281
746
  const decoder = new TextDecoder;
@@ -295,12 +760,12 @@ async function* readStdinLines(source = process.stdin) {
295
760
  if (pending !== "")
296
761
  yield pending.endsWith("\r") ? pending.slice(0, -1) : pending;
297
762
  }
298
- function parseLine(line) {
763
+ function parseLine(line, errors) {
299
764
  let parsed;
300
765
  try {
301
766
  parsed = safeJsonParse(line);
302
767
  } catch {
303
- return { ok: false, answer: malformed("the line is not JSON") };
768
+ return { ok: false, answer: malformed("the line is not JSON", errors) };
304
769
  }
305
770
  const result = LineSchema.safeParse(parsed);
306
771
  if (!result.success) {
@@ -308,26 +773,32 @@ function parseLine(line) {
308
773
  return {
309
774
  ok: false,
310
775
  answer: {
311
- ...malformed("the line needs `id` and `command`"),
776
+ ...malformed("the line needs `id` and `command`", errors),
312
777
  ...id !== undefined && { id }
313
778
  }
314
779
  };
315
780
  }
316
781
  return { ok: true, value: result.data };
317
782
  }
318
- function malformed(message) {
783
+ function streamFailureAnswer(id, code, message, errors) {
784
+ const mapped = applyToolErrorMapping({ ok: false, code, details: { message } }, errors);
785
+ const normalized = toolErrorFromResult(mapped);
319
786
  return {
320
- id: "",
787
+ id,
321
788
  ok: false,
322
789
  exitCode: 2,
323
- error: { code: "BAD_REQUEST", message }
790
+ error: { code: mapped.code, message: normalized.message }
324
791
  };
325
792
  }
793
+ function malformed(message, errors) {
794
+ return streamFailureAnswer("", "BAD_REQUEST", message, errors);
795
+ }
326
796
  async function runCliStream(invoker, lines, onAnswer, hooks = {}) {
797
+ const errors = cliInvokerErrorMapping(invoker);
327
798
  for await (const line of lines) {
328
799
  if (line.trim() === "")
329
800
  continue;
330
- const parsed = parseLine(line);
801
+ const parsed = parseLine(line, errors);
331
802
  if (!parsed.ok) {
332
803
  onAnswer(parsed.answer);
333
804
  continue;
@@ -347,7 +818,7 @@ function defineCliStreamCommand(config) {
347
818
  return defineCliCommand2({
348
819
  name: config.name ?? "stream",
349
820
  description: config.description ?? "Run one operation per JSON line of stdin, answering each",
350
- input: z.object({}),
821
+ input: z2.object({}),
351
822
  handler: async (context) => {
352
823
  const invoker = typeof config.invoker === "function" ? await config.invoker() : config.invoker;
353
824
  await runCliStream(invoker, (config.readLines ?? readStdinLines)(), (answer) => {
@@ -361,11 +832,12 @@ function defineCliBatchCommand(config) {
361
832
  return defineCliCommand2({
362
833
  name: config.name ?? "batch",
363
834
  description: config.description ?? "Run one operation per JSON line of stdin, resuming from a checkpoint",
364
- input: z.object({
365
- checkpoint: z.string().optional()
835
+ input: z2.object({
836
+ checkpoint: z2.string().optional()
366
837
  }),
367
838
  handler: async (context) => {
368
839
  const invoker = typeof config.invoker === "function" ? await config.invoker() : config.invoker;
840
+ const errors = cliInvokerErrorMapping(invoker);
369
841
  const path = context.input.checkpoint ?? config.checkpointPath ?? ".stitchkit-batch.json";
370
842
  const checkpoint = readCliCheckpoint(path);
371
843
  await runCliStream(invoker, (config.readLines ?? readStdinLines)(), (answer) => {
@@ -380,27 +852,11 @@ function defineCliBatchCommand(config) {
380
852
  if (!recorded)
381
853
  return;
382
854
  if (recorded.digest !== digest) {
383
- return {
384
- id,
385
- ok: false,
386
- exitCode: 2,
387
- error: {
388
- code: "CONFLICT",
389
- message: "this id was already run with different content — change the id or start a new checkpoint"
390
- }
391
- };
855
+ return streamFailureAnswer(id, "CONFLICT", "this id was already run with different content — change the id or start a new checkpoint", errors);
392
856
  }
393
857
  const replay = RecordedAnswerSchema.safeParse(recorded.answer);
394
858
  if (!replay.success) {
395
- return {
396
- id,
397
- ok: false,
398
- exitCode: 2,
399
- error: {
400
- code: "CONFLICT",
401
- message: "this id is recorded as done but its recorded answer is unreadable — change the id or start a new checkpoint"
402
- }
403
- };
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);
404
860
  }
405
861
  return { ...replay.data, id, replayed: true };
406
862
  },
@@ -422,7 +878,9 @@ export {
422
878
  CliBuildStampSchema2 as CliBuildStampSchema,
423
879
  CliBuildTargetSchema2 as CliBuildTargetSchema,
424
880
  CliProfileError,
881
+ CliTrustRootSchema2 as CliTrustRootSchema,
425
882
  DEFAULT_EXIT_CODES2 as DEFAULT_EXIT_CODES,
883
+ LocalKeyInitOutputSchema,
426
884
  applyCliUpdate2 as applyCliUpdate,
427
885
  assertCliPublishable2 as assertCliPublishable,
428
886
  checkCliUpdate2 as checkCliUpdate,
@@ -440,12 +898,15 @@ export {
440
898
  defineCliCommand2 as defineCliCommand,
441
899
  defineCliResult2 as defineCliResult,
442
900
  defineCliStreamCommand,
901
+ defineLocalKeyInitCommand,
443
902
  emitResult2 as emitResult,
444
903
  extractCliGlobalOptions2 as extractCliGlobalOptions,
445
904
  formatCliBuildStamp2 as formatCliBuildStamp,
446
905
  parseCliArgs2 as parseCliArgs,
447
906
  pollUntilDone2 as pollUntilDone,
448
907
  readCliCheckpoint,
908
+ readSecret,
909
+ readSecretFile,
449
910
  renderCliInstaller2 as renderCliInstaller,
450
911
  renderCliView2 as renderCliView,
451
912
  rollbackCliUpdate2 as rollbackCliUpdate,