stitchkit 0.92.0 → 0.94.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 (793) hide show
  1. package/CHANGELOG.md +191 -0
  2. package/README.md +5 -2
  3. package/dist/agent-runtime/children-control.d.ts +6 -0
  4. package/dist/agent-runtime/children-control.d.ts.map +1 -0
  5. package/dist/agent-runtime/children-spawn.d.ts +6 -0
  6. package/dist/agent-runtime/children-spawn.d.ts.map +1 -0
  7. package/dist/agent-runtime/children-state.d.ts +46 -0
  8. package/dist/agent-runtime/children-state.d.ts.map +1 -0
  9. package/dist/agent-runtime/children-usage.d.ts +8 -0
  10. package/dist/agent-runtime/children-usage.d.ts.map +1 -0
  11. package/dist/agent-runtime/children.d.ts +11 -14
  12. package/dist/agent-runtime/children.d.ts.map +1 -1
  13. package/dist/agent-runtime/coding-tool-contract.d.ts +2 -1
  14. package/dist/agent-runtime/coding-tool-contract.d.ts.map +1 -1
  15. package/dist/agent-runtime/deferred-tool-types.d.ts +2 -2
  16. package/dist/agent-runtime/deferred-tool-types.d.ts.map +1 -1
  17. package/dist/agent-runtime/events.d.ts +1 -1
  18. package/dist/agent-runtime/events.d.ts.map +1 -1
  19. package/dist/agent-runtime/managed-tools.d.ts +1 -1
  20. package/dist/agent-runtime/managed-tools.d.ts.map +1 -1
  21. package/dist/agent-runtime/observability.d.ts +1 -1
  22. package/dist/agent-runtime/observability.d.ts.map +1 -1
  23. package/dist/{agent-runtime-openrouter.d.ts → agent-runtime/openrouter.d.ts} +3 -3
  24. package/dist/agent-runtime/openrouter.d.ts.map +1 -0
  25. package/dist/agent-runtime/projections.d.ts +1 -1
  26. package/dist/agent-runtime/projections.d.ts.map +1 -1
  27. package/dist/agent-runtime/run-acquisition.d.ts +17 -0
  28. package/dist/agent-runtime/run-acquisition.d.ts.map +1 -0
  29. package/dist/agent-runtime/run-execution-state.d.ts +133 -0
  30. package/dist/agent-runtime/run-execution-state.d.ts.map +1 -0
  31. package/dist/agent-runtime/run-execution.d.ts +17 -33
  32. package/dist/agent-runtime/run-execution.d.ts.map +1 -1
  33. package/dist/agent-runtime/run-failure.d.ts +18 -0
  34. package/dist/agent-runtime/run-failure.d.ts.map +1 -0
  35. package/dist/agent-runtime/run-model-attempts.d.ts +6 -0
  36. package/dist/agent-runtime/run-model-attempts.d.ts.map +1 -0
  37. package/dist/agent-runtime/run-prompt-history.d.ts +58 -0
  38. package/dist/agent-runtime/run-prompt-history.d.ts.map +1 -0
  39. package/dist/agent-runtime/run-provider-ledger.d.ts +26 -0
  40. package/dist/agent-runtime/run-provider-ledger.d.ts.map +1 -0
  41. package/dist/agent-runtime/run-stream-parts.d.ts +17 -0
  42. package/dist/agent-runtime/run-stream-parts.d.ts.map +1 -0
  43. package/dist/agent-runtime/run-terminal.d.ts +11 -0
  44. package/dist/agent-runtime/run-terminal.d.ts.map +1 -0
  45. package/dist/agent-runtime/run-turn-preparation.d.ts +22 -0
  46. package/dist/agent-runtime/run-turn-preparation.d.ts.map +1 -0
  47. package/dist/agent-runtime/runtime-admission-gate.d.ts +29 -0
  48. package/dist/agent-runtime/runtime-admission-gate.d.ts.map +1 -0
  49. package/dist/agent-runtime/runtime-control.d.ts +9 -0
  50. package/dist/agent-runtime/runtime-control.d.ts.map +1 -0
  51. package/dist/agent-runtime/runtime-recovery.d.ts +10 -0
  52. package/dist/agent-runtime/runtime-recovery.d.ts.map +1 -0
  53. package/dist/agent-runtime/runtime-state.d.ts +36 -0
  54. package/dist/agent-runtime/runtime-state.d.ts.map +1 -0
  55. package/dist/agent-runtime/runtime-submit.d.ts +5 -0
  56. package/dist/agent-runtime/runtime-submit.d.ts.map +1 -0
  57. package/dist/agent-runtime/runtime.d.ts +9 -4
  58. package/dist/agent-runtime/runtime.d.ts.map +1 -1
  59. package/dist/{agent-runtime-sqlite-bun.d.ts → agent-runtime/sqlite-bun.d.ts} +5 -4
  60. package/dist/agent-runtime/sqlite-bun.d.ts.map +1 -0
  61. package/dist/agent-runtime/sqlite-events.d.ts +5 -0
  62. package/dist/agent-runtime/sqlite-events.d.ts.map +1 -0
  63. package/dist/agent-runtime/sqlite-history.d.ts +7 -0
  64. package/dist/agent-runtime/sqlite-history.d.ts.map +1 -0
  65. package/dist/agent-runtime/sqlite-ledger.d.ts +7 -0
  66. package/dist/agent-runtime/sqlite-ledger.d.ts.map +1 -0
  67. package/dist/{agent-runtime-sqlite-node.d.ts → agent-runtime/sqlite-node.d.ts} +5 -4
  68. package/dist/agent-runtime/sqlite-node.d.ts.map +1 -0
  69. package/dist/agent-runtime/sqlite-reads.d.ts +14 -0
  70. package/dist/agent-runtime/sqlite-reads.d.ts.map +1 -0
  71. package/dist/agent-runtime/sqlite-rows.d.ts +178 -0
  72. package/dist/agent-runtime/sqlite-rows.d.ts.map +1 -0
  73. package/dist/agent-runtime/sqlite-schema.d.ts +7 -0
  74. package/dist/agent-runtime/sqlite-schema.d.ts.map +1 -0
  75. package/dist/agent-runtime/sqlite-transactions.d.ts +25 -0
  76. package/dist/agent-runtime/sqlite-transactions.d.ts.map +1 -0
  77. package/dist/agent-runtime/sqlite.d.ts +10 -6
  78. package/dist/agent-runtime/sqlite.d.ts.map +1 -1
  79. package/dist/agent-runtime/store-archive.d.ts +16 -0
  80. package/dist/agent-runtime/store-archive.d.ts.map +1 -0
  81. package/dist/{testing/agent-store-conformance.d.ts → agent-runtime/store-conformance.d.ts} +2 -2
  82. package/dist/agent-runtime/store-conformance.d.ts.map +1 -0
  83. package/dist/agent-runtime/store-create.d.ts +11 -0
  84. package/dist/agent-runtime/store-create.d.ts.map +1 -0
  85. package/dist/agent-runtime/{store-driver.d.ts → store-driver-contract.d.ts} +7 -7
  86. package/dist/agent-runtime/store-driver-contract.d.ts.map +1 -0
  87. package/dist/agent-runtime/store-events.d.ts +7 -89
  88. package/dist/agent-runtime/store-events.d.ts.map +1 -1
  89. package/dist/agent-runtime/store-memory.d.ts +4 -0
  90. package/dist/agent-runtime/store-memory.d.ts.map +1 -0
  91. package/dist/agent-runtime/store-mutate.d.ts +13 -0
  92. package/dist/agent-runtime/store-mutate.d.ts.map +1 -0
  93. package/dist/agent-runtime/store-purge.d.ts +1 -1
  94. package/dist/agent-runtime/store-purge.d.ts.map +1 -1
  95. package/dist/agent-runtime/store-reads.d.ts +29 -0
  96. package/dist/agent-runtime/store-reads.d.ts.map +1 -0
  97. package/dist/agent-runtime/store-reduce-history.d.ts +10 -0
  98. package/dist/agent-runtime/store-reduce-history.d.ts.map +1 -0
  99. package/dist/agent-runtime/store-reduce-run.d.ts +14 -0
  100. package/dist/agent-runtime/store-reduce-run.d.ts.map +1 -0
  101. package/dist/agent-runtime/store-reduce-shared.d.ts +76 -0
  102. package/dist/agent-runtime/store-reduce-shared.d.ts.map +1 -0
  103. package/dist/agent-runtime/store-reduce-terminal.d.ts +6 -0
  104. package/dist/agent-runtime/store-reduce-terminal.d.ts.map +1 -0
  105. package/dist/agent-runtime/store-reducer.d.ts +24 -0
  106. package/dist/agent-runtime/store-reducer.d.ts.map +1 -0
  107. package/dist/agent-runtime/store-snapshot.d.ts +19 -0
  108. package/dist/agent-runtime/store-snapshot.d.ts.map +1 -0
  109. package/dist/agent-runtime/store.d.ts +1 -1
  110. package/dist/agent-runtime/store.d.ts.map +1 -1
  111. package/dist/application/admission.d.ts +1 -1
  112. package/dist/application/admission.d.ts.map +1 -1
  113. package/dist/application/events.d.ts +1 -1
  114. package/dist/application/events.d.ts.map +1 -1
  115. package/dist/{server → application}/file-state-store.d.ts +1 -1
  116. package/dist/application/file-state-store.d.ts.map +1 -0
  117. package/dist/application/health.d.ts +1 -1
  118. package/dist/application/health.d.ts.map +1 -1
  119. package/dist/application/kernel-admission.d.ts +8 -0
  120. package/dist/application/kernel-admission.d.ts.map +1 -0
  121. package/dist/application/kernel-contract.d.ts +142 -0
  122. package/dist/application/kernel-contract.d.ts.map +1 -0
  123. package/dist/application/kernel-resource-context.d.ts +24 -0
  124. package/dist/application/kernel-resource-context.d.ts.map +1 -0
  125. package/dist/application/kernel-restart.d.ts +5 -0
  126. package/dist/application/kernel-restart.d.ts.map +1 -0
  127. package/dist/application/kernel-rollback.d.ts +4 -0
  128. package/dist/application/kernel-rollback.d.ts.map +1 -0
  129. package/dist/application/kernel-shutdown.d.ts +6 -0
  130. package/dist/application/kernel-shutdown.d.ts.map +1 -0
  131. package/dist/application/kernel-start.d.ts +20 -0
  132. package/dist/application/kernel-start.d.ts.map +1 -0
  133. package/dist/application/kernel-state.d.ts +116 -0
  134. package/dist/application/kernel-state.d.ts.map +1 -0
  135. package/dist/application/kernel.d.ts +9 -140
  136. package/dist/application/kernel.d.ts.map +1 -1
  137. package/dist/application/latest-sink.d.ts +1 -1
  138. package/dist/application/latest-sink.d.ts.map +1 -1
  139. package/dist/application/opentelemetry.d.ts +1 -1
  140. package/dist/application/opentelemetry.d.ts.map +1 -1
  141. package/dist/application/watch-hub.d.ts +2 -2
  142. package/dist/application/watch-hub.d.ts.map +1 -1
  143. package/dist/browser/client-multipart.d.ts +1 -1
  144. package/dist/browser/client-multipart.d.ts.map +1 -1
  145. package/dist/browser/client-url.d.ts +1 -1
  146. package/dist/browser/client-url.d.ts.map +1 -1
  147. package/dist/browser/client.d.ts +1 -1
  148. package/dist/browser/client.d.ts.map +1 -1
  149. package/dist/browser/contract-stream.d.ts +1 -1
  150. package/dist/browser/contract-stream.d.ts.map +1 -1
  151. package/dist/browser/http.d.ts +1 -1
  152. package/dist/browser/http.d.ts.map +1 -1
  153. package/dist/browser/resumable.d.ts +1 -28
  154. package/dist/browser/resumable.d.ts.map +1 -1
  155. package/dist/browser/retained.d.ts.map +1 -0
  156. package/dist/browser/socket-io.d.ts +23 -1
  157. package/dist/browser/socket-io.d.ts.map +1 -1
  158. package/dist/browser/stream.d.ts +14 -2
  159. package/dist/browser/stream.d.ts.map +1 -1
  160. package/dist/contract/define.d.ts +72 -65
  161. package/dist/contract/define.d.ts.map +1 -1
  162. package/dist/{internal/errors.d.ts → contract/normalize.d.ts} +3 -39
  163. package/dist/contract/normalize.d.ts.map +1 -0
  164. package/dist/contract/tool-view.d.ts +135 -0
  165. package/dist/contract/tool-view.d.ts.map +1 -0
  166. package/dist/declaration/declaration.d.ts.map +1 -0
  167. package/dist/{agent-runtime/durability-contract.d.ts → durability/contract.d.ts} +2 -2
  168. package/dist/durability/contract.d.ts.map +1 -0
  169. package/dist/{agent-runtime/durability.d.ts → durability/engine.d.ts} +4 -4
  170. package/dist/durability/engine.d.ts.map +1 -0
  171. package/dist/durability/events.d.ts +101 -0
  172. package/dist/durability/events.d.ts.map +1 -0
  173. package/dist/{agent-runtime/durability-json.d.ts → durability/json.d.ts} +1 -1
  174. package/dist/durability/json.d.ts.map +1 -0
  175. package/dist/{agent-runtime/durability-ledger.d.ts → durability/ledger.d.ts} +2 -2
  176. package/dist/durability/ledger.d.ts.map +1 -0
  177. package/dist/{agent-runtime/durability-scheduler.d.ts → durability/scheduler.d.ts} +2 -2
  178. package/dist/durability/scheduler.d.ts.map +1 -0
  179. package/dist/entrypoints/agent-runtime/browser.d.ts +5 -0
  180. package/dist/entrypoints/agent-runtime/browser.d.ts.map +1 -0
  181. package/dist/{agent-runtime-browser.js → entrypoints/agent-runtime/browser.js} +3 -3
  182. package/dist/{agent-runtime-coding-tools.d.ts → entrypoints/agent-runtime/coding-tools.d.ts} +2 -2
  183. package/dist/entrypoints/agent-runtime/coding-tools.d.ts.map +1 -0
  184. package/dist/entrypoints/agent-runtime/coding-tools.js +22 -0
  185. package/dist/{agent-runtime-harness.d.ts → entrypoints/agent-runtime/harness.d.ts} +2 -2
  186. package/dist/entrypoints/agent-runtime/harness.d.ts.map +1 -0
  187. package/dist/{agent-runtime-harness.js → entrypoints/agent-runtime/harness.js} +24 -25
  188. package/dist/entrypoints/agent-runtime/openrouter.d.ts +2 -0
  189. package/dist/entrypoints/agent-runtime/openrouter.d.ts.map +1 -0
  190. package/dist/{agent-runtime-openrouter.js → entrypoints/agent-runtime/openrouter.js} +3 -3
  191. package/dist/{agent-runtime-sandbox.d.ts → entrypoints/agent-runtime/sandbox.d.ts} +5 -5
  192. package/dist/entrypoints/agent-runtime/sandbox.d.ts.map +1 -0
  193. package/dist/{agent-runtime-sandbox.js → entrypoints/agent-runtime/sandbox.js} +11 -12
  194. package/dist/entrypoints/agent-runtime/sqlite/bun.d.ts +2 -0
  195. package/dist/entrypoints/agent-runtime/sqlite/bun.d.ts.map +1 -0
  196. package/dist/{agent-runtime-sqlite-bun.js → entrypoints/agent-runtime/sqlite/bun.js} +8 -6
  197. package/dist/entrypoints/agent-runtime/sqlite/node.d.ts +2 -0
  198. package/dist/entrypoints/agent-runtime/sqlite/node.d.ts.map +1 -0
  199. package/dist/{agent-runtime-sqlite-node.js → entrypoints/agent-runtime/sqlite/node.js} +8 -6
  200. package/dist/entrypoints/agent-runtime/testing.d.ts +4 -0
  201. package/dist/entrypoints/agent-runtime/testing.d.ts.map +1 -0
  202. package/dist/entrypoints/agent-runtime/testing.js +1084 -0
  203. package/dist/{agent-runtime.d.ts → entrypoints/agent-runtime.d.ts} +41 -37
  204. package/dist/entrypoints/agent-runtime.d.ts.map +1 -0
  205. package/dist/{agent-runtime.js → entrypoints/agent-runtime.js} +408 -366
  206. package/dist/{application-diagnostic-journal.d.ts → entrypoints/application/diagnostic-journal.d.ts} +2 -2
  207. package/dist/entrypoints/application/diagnostic-journal.d.ts.map +1 -0
  208. package/dist/{application-diagnostic-journal.js → entrypoints/application/diagnostic-journal.js} +3 -3
  209. package/dist/{application-grammy.d.ts → entrypoints/application/grammy.d.ts} +2 -2
  210. package/dist/entrypoints/application/grammy.d.ts.map +1 -0
  211. package/dist/{application-grammy.js → entrypoints/application/grammy.js} +2 -2
  212. package/dist/{application-opentelemetry.d.ts → entrypoints/application/opentelemetry.d.ts} +2 -2
  213. package/dist/entrypoints/application/opentelemetry.d.ts.map +1 -0
  214. package/dist/{application-opentelemetry.js → entrypoints/application/opentelemetry.js} +4 -4
  215. package/dist/{application-schemas.d.ts → entrypoints/application/schemas.d.ts} +2 -2
  216. package/dist/entrypoints/application/schemas.d.ts.map +1 -0
  217. package/dist/{application-schemas.js → entrypoints/application/schemas.js} +2 -2
  218. package/dist/{application.d.ts → entrypoints/application.d.ts} +22 -21
  219. package/dist/entrypoints/application.d.ts.map +1 -0
  220. package/dist/{application.js → entrypoints/application.js} +24 -22
  221. package/dist/entrypoints/bin/upgrade-cli.d.ts.map +1 -0
  222. package/dist/{upgrade-cli.js → entrypoints/bin/upgrade-cli.js} +3 -3
  223. package/dist/{cli.d.ts → entrypoints/cli.d.ts} +15 -15
  224. package/dist/entrypoints/cli.d.ts.map +1 -0
  225. package/dist/{cli.js → entrypoints/cli.js} +37 -32
  226. package/dist/entrypoints/contract.d.ts +9 -0
  227. package/dist/entrypoints/contract.d.ts.map +1 -0
  228. package/dist/{contract/index.js → entrypoints/contract.js} +14 -6
  229. package/dist/entrypoints/declaration.d.ts +2 -0
  230. package/dist/entrypoints/declaration.d.ts.map +1 -0
  231. package/dist/{declaration.js → entrypoints/declaration.js} +1 -1
  232. package/dist/{files.d.ts → entrypoints/files.d.ts} +2 -2
  233. package/dist/entrypoints/files.d.ts.map +1 -0
  234. package/dist/{files.js → entrypoints/files.js} +3 -3
  235. package/dist/{geo.d.ts → entrypoints/geo.d.ts} +1 -1
  236. package/dist/entrypoints/geo.d.ts.map +1 -0
  237. package/dist/{geo.js → entrypoints/geo.js} +4 -4
  238. package/dist/entrypoints/google.d.ts +2 -0
  239. package/dist/entrypoints/google.d.ts.map +1 -0
  240. package/dist/{google.js → entrypoints/google.js} +1 -1
  241. package/dist/{index.d.ts → entrypoints/index.d.ts} +14 -13
  242. package/dist/entrypoints/index.d.ts.map +1 -0
  243. package/dist/{index.js → entrypoints/index.js} +99 -33
  244. package/dist/{live.d.ts → entrypoints/live.d.ts} +4 -4
  245. package/dist/entrypoints/live.d.ts.map +1 -0
  246. package/dist/{live.js → entrypoints/live.js} +6 -4
  247. package/dist/{node.d.ts → entrypoints/node.d.ts} +11 -11
  248. package/dist/entrypoints/node.d.ts.map +1 -0
  249. package/dist/{node.js → entrypoints/node.js} +20 -16
  250. package/dist/entrypoints/oauth.d.ts +2 -0
  251. package/dist/entrypoints/oauth.d.ts.map +1 -0
  252. package/dist/{oauth.js → entrypoints/oauth.js} +3 -3
  253. package/dist/{observability/index.d.ts → entrypoints/observability.d.ts} +11 -11
  254. package/dist/entrypoints/observability.d.ts.map +1 -0
  255. package/dist/{observability/index.js → entrypoints/observability.js} +9 -11
  256. package/dist/entrypoints/primitives.d.ts +3 -0
  257. package/dist/entrypoints/primitives.d.ts.map +1 -0
  258. package/dist/{primitives.js → entrypoints/primitives.js} +1 -6
  259. package/dist/{react.d.ts → entrypoints/react.d.ts} +4 -4
  260. package/dist/entrypoints/react.d.ts.map +1 -0
  261. package/dist/{react.js → entrypoints/react.js} +3 -3
  262. package/dist/{release.d.ts → entrypoints/release.d.ts} +4 -4
  263. package/dist/entrypoints/release.d.ts.map +1 -0
  264. package/dist/{release.js → entrypoints/release.js} +1 -1
  265. package/dist/{remote.d.ts → entrypoints/remote.d.ts} +1 -1
  266. package/dist/entrypoints/remote.d.ts.map +1 -0
  267. package/dist/entrypoints/remote.js +66 -0
  268. package/dist/{server/index.d.ts → entrypoints/server.d.ts} +35 -34
  269. package/dist/entrypoints/server.d.ts.map +1 -0
  270. package/dist/{server/index.js → entrypoints/server.js} +294 -244
  271. package/dist/{telegram.d.ts → entrypoints/telegram.d.ts} +2 -2
  272. package/dist/entrypoints/telegram.d.ts.map +1 -0
  273. package/dist/{telegram.js → entrypoints/telegram.js} +1 -1
  274. package/dist/entrypoints/testing.d.ts +9 -0
  275. package/dist/entrypoints/testing.d.ts.map +1 -0
  276. package/dist/{testing.js → entrypoints/testing.js} +107 -926
  277. package/dist/{tools/connections/index.d.ts → entrypoints/tools/connections.d.ts} +6 -7
  278. package/dist/entrypoints/tools/connections.d.ts.map +1 -0
  279. package/dist/{tools/connections/index.js → entrypoints/tools/connections.js} +7 -4
  280. package/dist/{tools-contract.d.ts → entrypoints/tools/contract.d.ts} +5 -5
  281. package/dist/entrypoints/tools/contract.d.ts.map +1 -0
  282. package/dist/{tools-contract.js → entrypoints/tools/contract.js} +4 -4
  283. package/dist/{tool-invoker.d.ts → entrypoints/tools/invoker.d.ts} +2 -2
  284. package/dist/entrypoints/tools/invoker.d.ts.map +1 -0
  285. package/dist/entrypoints/tools/invoker.js +20 -0
  286. package/dist/entrypoints/tools.d.ts +51 -0
  287. package/dist/entrypoints/tools.d.ts.map +1 -0
  288. package/dist/{tools.js → entrypoints/tools.js} +1787 -1751
  289. package/dist/{tracking-server.d.ts → entrypoints/tracking/server.d.ts} +8 -8
  290. package/dist/entrypoints/tracking/server.d.ts.map +1 -0
  291. package/dist/{tracking.d.ts → entrypoints/tracking.d.ts} +15 -15
  292. package/dist/entrypoints/tracking.d.ts.map +1 -0
  293. package/dist/{tracking.js → entrypoints/tracking.js} +5 -8
  294. package/dist/google/google.d.ts.map +1 -0
  295. package/dist/{index-a916km3r.js → index-0b1ess5e.js} +6 -13
  296. package/dist/{index-zwkgfq1s.js → index-1nd48tm9.js} +113 -118
  297. package/dist/{index-7zbps32p.js → index-1zbbzgfh.js} +2 -2
  298. package/dist/{index-mzvgxp0n.js → index-2cr1cqhn.js} +16 -4
  299. package/dist/{index-f9mb610r.js → index-35mh5bhj.js} +2 -2
  300. package/dist/index-48ffdxgk.js +6 -0
  301. package/dist/index-58k4fp34.js +1023 -0
  302. package/dist/{index-p13mwz16.js → index-83bdg97s.js} +1 -1
  303. package/dist/index-97ac4gph.js +3618 -0
  304. package/dist/{index-kw9t5ayn.js → index-cq4qfycf.js} +5 -5
  305. package/dist/{index-7gnkny4z.js → index-d9pk3td4.js} +1 -1
  306. package/dist/{index-e42wzzz5.js → index-dcpdvjsc.js} +7 -7
  307. package/dist/{index-h9etkkyk.js → index-dydjcp8z.js} +102 -25
  308. package/dist/{index-sr93cwf9.js → index-e2z3ahw9.js} +2 -2
  309. package/dist/{index-yewwh1w4.js → index-e87kakm4.js} +96 -11
  310. package/dist/{index-cby4ar3v.js → index-eqqvgdb3.js} +1 -1
  311. package/dist/index-fdp6hdxn.js +942 -0
  312. package/dist/{index-0a349c33.js → index-gyr48nzg.js} +125 -198
  313. package/dist/{index-wnfk50r0.js → index-h6eeys1v.js} +1 -1
  314. package/dist/{index-77fekveh.js → index-hffjpmq9.js} +1 -15
  315. package/dist/{index-yn8remb1.js → index-j05z5gn4.js} +50 -14
  316. package/dist/index-k5hsfc3j.js +31 -0
  317. package/dist/{index-fq77yfzc.js → index-kj2wbeta.js} +1 -1
  318. package/dist/index-kvj7f4hq.js +39 -0
  319. package/dist/{index-4fpa9dy2.js → index-m9zn6cpq.js} +2 -2
  320. package/dist/{index-2na0qrfn.js → index-mdzh02yc.js} +7 -7
  321. package/dist/{index-ywd0y6m1.js → index-mkm15s49.js} +1 -1
  322. package/dist/index-mp5sn43f.js +1084 -0
  323. package/dist/{index-7n145nbe.js → index-n6hxg8as.js} +530 -387
  324. package/dist/index-ngfhvfpd.js +30 -0
  325. package/dist/{index-e0znv5gn.js → index-p5r7qpdd.js} +2 -93
  326. package/dist/{index-n0f51dfn.js → index-p81267c2.js} +608 -549
  327. package/dist/{index-wc4x00bn.js → index-qwhynv6x.js} +1 -1
  328. package/dist/index-r7nmqpsg.js +154 -0
  329. package/dist/{index-bx75zwt7.js → index-rewkc2hj.js} +5 -4
  330. package/dist/{index-9f8ztey6.js → index-sees8yf8.js} +2 -2
  331. package/dist/{index-vjpvjqpn.js → index-v38qyerb.js} +16 -2
  332. package/dist/{index-2c2bjw3s.js → index-vcvkq30w.js} +3 -3
  333. package/dist/index-wqgjfstn.js +18 -0
  334. package/dist/{index-f477k430.js → index-x4799c19.js} +1 -1
  335. package/dist/{index-cxqhvq21.js → index-xnj9bgxe.js} +142 -129
  336. package/dist/index-xsqjkha9.js +281 -0
  337. package/dist/{index-6kyksz9y.js → index-yw4fzmdz.js} +1 -1
  338. package/dist/{index-3xwxfj4z.js → index-zeemqhqx.js} +1 -1
  339. package/dist/{index-tmwcrptx.js → index-zfrhfn82.js} +1 -1
  340. package/dist/index-znfs20ss.js +98 -0
  341. package/dist/internal/backoff.d.ts +29 -0
  342. package/dist/internal/backoff.d.ts.map +1 -0
  343. package/dist/internal/canonical-json.d.ts +21 -11
  344. package/dist/internal/canonical-json.d.ts.map +1 -1
  345. package/dist/internal/channel.d.ts.map +1 -0
  346. package/dist/internal/logger.d.ts.map +1 -0
  347. package/dist/internal/request.d.ts.map +1 -0
  348. package/dist/internal/secure-fetch.d.ts +12 -0
  349. package/dist/internal/secure-fetch.d.ts.map +1 -1
  350. package/dist/internal/stable-digest.d.ts +0 -43
  351. package/dist/internal/stable-digest.d.ts.map +1 -1
  352. package/dist/internal/typed.d.ts +0 -8
  353. package/dist/internal/typed.d.ts.map +1 -1
  354. package/dist/internal/zod-issues.d.ts +38 -0
  355. package/dist/internal/zod-issues.d.ts.map +1 -0
  356. package/dist/{tools/json-schema-dialect.d.ts → json-schema/dialect.d.ts} +1 -1
  357. package/dist/json-schema/dialect.d.ts.map +1 -0
  358. package/dist/json-schema/json-schema.d.ts.map +1 -0
  359. package/dist/live/watch-delta.d.ts.map +1 -1
  360. package/dist/{oauth.d.ts → oauth/authorization-code.d.ts} +1 -1
  361. package/dist/oauth/authorization-code.d.ts.map +1 -0
  362. package/dist/observability/audit.d.ts +2 -2
  363. package/dist/observability/audit.d.ts.map +1 -1
  364. package/dist/observability/bounded-logger.d.ts +1 -1
  365. package/dist/observability/bounded-logger.d.ts.map +1 -1
  366. package/dist/{internal/observability-sink.d.ts → observability/bounded-sink.d.ts} +2 -2
  367. package/dist/observability/bounded-sink.d.ts.map +1 -0
  368. package/dist/observability/context.d.ts +1 -1
  369. package/dist/observability/context.d.ts.map +1 -1
  370. package/dist/observability/event.d.ts +1 -1
  371. package/dist/observability/event.d.ts.map +1 -1
  372. package/dist/observability/work.d.ts +1 -1
  373. package/dist/observability/work.d.ts.map +1 -1
  374. package/dist/primitives/audit.d.ts +1 -1
  375. package/dist/primitives/audit.d.ts.map +1 -1
  376. package/dist/primitives/export-operation.d.ts +4 -2
  377. package/dist/primitives/export-operation.d.ts.map +1 -1
  378. package/dist/realtime/socket.d.ts +1 -1
  379. package/dist/realtime/socket.d.ts.map +1 -1
  380. package/dist/server/context-contribution.d.ts +1 -1
  381. package/dist/server/context-contribution.d.ts.map +1 -1
  382. package/dist/server/context.d.ts +2 -2
  383. package/dist/server/context.d.ts.map +1 -1
  384. package/dist/server/contract-method.d.ts +15 -0
  385. package/dist/server/contract-method.d.ts.map +1 -0
  386. package/dist/server/contract-stream.d.ts +1 -1
  387. package/dist/server/contract-stream.d.ts.map +1 -1
  388. package/dist/server/create.d.ts +8 -0
  389. package/dist/server/create.d.ts.map +1 -1
  390. package/dist/server/endpoint-dispatch.d.ts +10 -0
  391. package/dist/server/endpoint-dispatch.d.ts.map +1 -0
  392. package/dist/server/endpoint-response.d.ts +18 -0
  393. package/dist/server/endpoint-response.d.ts.map +1 -0
  394. package/dist/server/error-dispatch.d.ts +17 -1
  395. package/dist/server/error-dispatch.d.ts.map +1 -1
  396. package/dist/server/error-hook.d.ts +2 -2
  397. package/dist/server/error-hook.d.ts.map +1 -1
  398. package/dist/server/handler-state.d.ts +44 -0
  399. package/dist/server/handler-state.d.ts.map +1 -0
  400. package/dist/server/implement.d.ts +1 -1
  401. package/dist/server/implement.d.ts.map +1 -1
  402. package/dist/server/middleware/auth.d.ts +1 -1
  403. package/dist/server/middleware/auth.d.ts.map +1 -1
  404. package/dist/server/middleware/cors.d.ts +17 -0
  405. package/dist/server/middleware/cors.d.ts.map +1 -1
  406. package/dist/server/middleware/trust-fence.d.ts +1 -1
  407. package/dist/server/middleware/trust-fence.d.ts.map +1 -1
  408. package/dist/server/multipart.d.ts +1 -1
  409. package/dist/server/multipart.d.ts.map +1 -1
  410. package/dist/{tools/oauth-metadata.d.ts → server/oauth/metadata.d.ts} +2 -2
  411. package/dist/server/oauth/metadata.d.ts.map +1 -0
  412. package/dist/{tools/oauth-provider.d.ts → server/oauth/provider.d.ts} +2 -2
  413. package/dist/server/oauth/provider.d.ts.map +1 -0
  414. package/dist/server/realtime.d.ts +1 -1
  415. package/dist/server/realtime.d.ts.map +1 -1
  416. package/dist/server/request-completion.d.ts +16 -0
  417. package/dist/server/request-completion.d.ts.map +1 -0
  418. package/dist/server/response-metadata.d.ts +1 -1
  419. package/dist/server/response-metadata.d.ts.map +1 -1
  420. package/dist/server/route-table.d.ts +9 -0
  421. package/dist/server/route-table.d.ts.map +1 -0
  422. package/dist/server/stream.d.ts +0 -13
  423. package/dist/server/stream.d.ts.map +1 -1
  424. package/dist/server/types.d.ts +7 -4
  425. package/dist/server/types.d.ts.map +1 -1
  426. package/dist/testing/handler-clients.d.ts +31 -0
  427. package/dist/testing/handler-clients.d.ts.map +1 -0
  428. package/dist/testing/managed-resource-conformance-scenarios.d.ts.map +1 -1
  429. package/dist/testing/surface-conformance.d.ts +2 -1
  430. package/dist/testing/surface-conformance.d.ts.map +1 -1
  431. package/dist/testing/surface-manifest.d.ts +64 -5
  432. package/dist/testing/surface-manifest.d.ts.map +1 -1
  433. package/dist/tools/{cli-args.d.ts → cli/args.d.ts} +1 -1
  434. package/dist/tools/cli/args.d.ts.map +1 -0
  435. package/dist/tools/{cli-checkpoint.d.ts → cli/checkpoint.d.ts} +1 -1
  436. package/dist/tools/cli/checkpoint.d.ts.map +1 -0
  437. package/dist/tools/{cli-command.d.ts → cli/command.d.ts} +22 -4
  438. package/dist/tools/cli/command.d.ts.map +1 -0
  439. package/dist/tools/{cli.d.ts → cli/config.d.ts} +5 -12
  440. package/dist/tools/cli/config.d.ts.map +1 -0
  441. package/dist/tools/cli/create-cli.d.ts +36 -0
  442. package/dist/tools/cli/create-cli.d.ts.map +1 -0
  443. package/dist/tools/cli/download.d.ts +8 -0
  444. package/dist/tools/cli/download.d.ts.map +1 -0
  445. package/dist/tools/{cli-format.d.ts → cli/format.d.ts} +2 -2
  446. package/dist/tools/cli/format.d.ts.map +1 -0
  447. package/dist/tools/cli/help.d.ts +24 -0
  448. package/dist/tools/cli/help.d.ts.map +1 -0
  449. package/dist/tools/{cli-installer.d.ts → cli/installer.d.ts} +2 -2
  450. package/dist/tools/cli/installer.d.ts.map +1 -0
  451. package/dist/tools/{cli-invoke.d.ts → cli/invoke.d.ts} +35 -10
  452. package/dist/tools/cli/invoke.d.ts.map +1 -0
  453. package/dist/tools/cli/io.d.ts +10 -0
  454. package/dist/tools/cli/io.d.ts.map +1 -0
  455. package/dist/tools/cli/managed-surface.d.ts +30 -0
  456. package/dist/tools/cli/managed-surface.d.ts.map +1 -0
  457. package/dist/tools/{cli-manifest.d.ts → cli/manifest.d.ts} +1 -1
  458. package/dist/tools/cli/manifest.d.ts.map +1 -0
  459. package/dist/tools/{cli-policy.d.ts → cli/policy.d.ts} +2 -2
  460. package/dist/tools/cli/policy.d.ts.map +1 -0
  461. package/dist/tools/cli/prepare.d.ts +14 -0
  462. package/dist/tools/cli/prepare.d.ts.map +1 -0
  463. package/dist/tools/{cli-profile.d.ts → cli/profile.d.ts} +2 -2
  464. package/dist/tools/cli/profile.d.ts.map +1 -0
  465. package/dist/tools/cli/run-managed.d.ts +5 -0
  466. package/dist/tools/cli/run-managed.d.ts.map +1 -0
  467. package/dist/tools/cli/run-native.d.ts +9 -0
  468. package/dist/tools/cli/run-native.d.ts.map +1 -0
  469. package/dist/tools/cli/session.d.ts +40 -0
  470. package/dist/tools/cli/session.d.ts.map +1 -0
  471. package/dist/tools/{cli-signature.d.ts → cli/signature.d.ts} +2 -2
  472. package/dist/tools/cli/signature.d.ts.map +1 -0
  473. package/dist/tools/{cli-stream.d.ts → cli/stream.d.ts} +4 -4
  474. package/dist/tools/cli/stream.d.ts.map +1 -0
  475. package/dist/tools/{cli-update.d.ts → cli/update.d.ts} +3 -3
  476. package/dist/tools/cli/update.d.ts.map +1 -0
  477. package/dist/tools/{cli-view.d.ts → cli/view.d.ts} +2 -2
  478. package/dist/tools/cli/view.d.ts.map +1 -0
  479. package/dist/tools/{cli-wait.d.ts → cli/wait.d.ts} +2 -2
  480. package/dist/tools/cli/wait.d.ts.map +1 -0
  481. package/dist/tools/connections/runtime.d.ts +1 -1
  482. package/dist/tools/connections/runtime.d.ts.map +1 -1
  483. package/dist/tools/connections/types.d.ts +3 -3
  484. package/dist/tools/connections/types.d.ts.map +1 -1
  485. package/dist/tools/durability-context.d.ts +1 -1
  486. package/dist/tools/durability-context.d.ts.map +1 -1
  487. package/dist/tools/execute.d.ts +30 -3
  488. package/dist/tools/execute.d.ts.map +1 -1
  489. package/dist/tools/internal/surface-projector.d.ts +8 -6
  490. package/dist/tools/internal/surface-projector.d.ts.map +1 -1
  491. package/dist/tools/internal/tool-view.d.ts +41 -0
  492. package/dist/tools/internal/tool-view.d.ts.map +1 -0
  493. package/dist/tools/invoker.d.ts +11 -3
  494. package/dist/tools/invoker.d.ts.map +1 -1
  495. package/dist/tools/list-names.d.ts +3 -3
  496. package/dist/tools/list-names.d.ts.map +1 -1
  497. package/dist/tools/manifest.d.ts +2 -2
  498. package/dist/tools/manifest.d.ts.map +1 -1
  499. package/dist/tools/{mcp-app.d.ts → mcp/app.d.ts} +1 -1
  500. package/dist/tools/mcp/app.d.ts.map +1 -0
  501. package/dist/tools/{mcp-catalog.d.ts → mcp/catalog.d.ts} +2 -2
  502. package/dist/tools/mcp/catalog.d.ts.map +1 -0
  503. package/dist/tools/{mcp-handler.d.ts → mcp/handler.d.ts} +5 -5
  504. package/dist/tools/mcp/handler.d.ts.map +1 -0
  505. package/dist/tools/{mcp.d.ts → mcp/mount.d.ts} +9 -9
  506. package/dist/tools/mcp/mount.d.ts.map +1 -0
  507. package/dist/tools/{mcp-prepare.d.ts → mcp/prepare.d.ts} +9 -9
  508. package/dist/tools/mcp/prepare.d.ts.map +1 -0
  509. package/dist/tools/{mcp-progress.d.ts → mcp/progress.d.ts} +2 -2
  510. package/dist/tools/mcp/progress.d.ts.map +1 -0
  511. package/dist/tools/mcp/register.d.ts +35 -0
  512. package/dist/tools/mcp/register.d.ts.map +1 -0
  513. package/dist/tools/{mcp-round-policy.d.ts → mcp/round-policy.d.ts} +2 -2
  514. package/dist/tools/mcp/round-policy.d.ts.map +1 -0
  515. package/dist/tools/{mcp-round.d.ts → mcp/round.d.ts} +4 -4
  516. package/dist/tools/mcp/round.d.ts.map +1 -0
  517. package/dist/tools/mcp/runtime-tools.d.ts +24 -0
  518. package/dist/tools/mcp/runtime-tools.d.ts.map +1 -0
  519. package/dist/tools/{mcp-stdio-signals.d.ts → mcp/stdio-signals.d.ts} +3 -3
  520. package/dist/tools/mcp/stdio-signals.d.ts.map +1 -0
  521. package/dist/tools/{mcp-stdio.d.ts → mcp/stdio.d.ts} +4 -4
  522. package/dist/tools/mcp/stdio.d.ts.map +1 -0
  523. package/dist/tools/{mcp-trace.d.ts → mcp/trace.d.ts} +1 -1
  524. package/dist/tools/mcp/trace.d.ts.map +1 -0
  525. package/dist/tools/mount.d.ts +12 -7
  526. package/dist/tools/mount.d.ts.map +1 -1
  527. package/dist/tools/native-definition.d.ts +3 -3
  528. package/dist/tools/native-definition.d.ts.map +1 -1
  529. package/dist/tools/operations/async-operation-binding-types.d.ts +127 -0
  530. package/dist/tools/operations/async-operation-binding-types.d.ts.map +1 -0
  531. package/dist/tools/operations/async-operation-binding.d.ts +28 -0
  532. package/dist/tools/operations/async-operation-binding.d.ts.map +1 -0
  533. package/dist/tools/operations/async-operation-canonical-types.d.ts +110 -0
  534. package/dist/tools/operations/async-operation-canonical-types.d.ts.map +1 -0
  535. package/dist/tools/operations/async-operation-canonical.d.ts +7 -0
  536. package/dist/tools/operations/async-operation-canonical.d.ts.map +1 -0
  537. package/dist/tools/operations/async-operation-contract.d.ts.map +1 -0
  538. package/dist/tools/operations/async-operation-id.d.ts +23 -0
  539. package/dist/tools/operations/async-operation-id.d.ts.map +1 -0
  540. package/dist/tools/operations/async-operation-runtime-tools.d.ts +40 -0
  541. package/dist/tools/operations/async-operation-runtime-tools.d.ts.map +1 -0
  542. package/dist/tools/operations/async-operation-runtime-types.d.ts +68 -0
  543. package/dist/tools/operations/async-operation-runtime-types.d.ts.map +1 -0
  544. package/dist/tools/operations/async-operation-runtime.d.ts +5 -0
  545. package/dist/tools/operations/async-operation-runtime.d.ts.map +1 -0
  546. package/dist/tools/{define-wait-tool.d.ts → operations/define-wait-tool.d.ts} +2 -2
  547. package/dist/tools/operations/define-wait-tool.d.ts.map +1 -0
  548. package/dist/tools/operations/mount-wait.d.ts.map +1 -0
  549. package/dist/tools/operations/wait-core.d.ts.map +1 -0
  550. package/dist/tools/remote.d.ts +1 -1
  551. package/dist/tools/remote.d.ts.map +1 -1
  552. package/dist/tools/runtime-tool.d.ts +11 -4
  553. package/dist/tools/runtime-tool.d.ts.map +1 -1
  554. package/dist/tools/schema/coerce.d.ts.map +1 -0
  555. package/dist/tools/schema/flatten-join.d.ts.map +1 -0
  556. package/dist/tools/schema/flatten.d.ts.map +1 -0
  557. package/dist/tools/schema/portable-formats.d.ts.map +1 -0
  558. package/dist/tools/{presentation.d.ts → schema/presentation.d.ts} +2 -0
  559. package/dist/tools/schema/presentation.d.ts.map +1 -0
  560. package/dist/tools/schema/schema.d.ts.map +1 -0
  561. package/dist/tools/schema/untyped-properties.d.ts.map +1 -0
  562. package/dist/tools/surface.d.ts +2 -3
  563. package/dist/tools/surface.d.ts.map +1 -1
  564. package/dist/tools/toolkit.d.ts +4 -4
  565. package/dist/tools/toolkit.d.ts.map +1 -1
  566. package/dist/tools/{define-download-tool.d.ts → transfer/define-download-tool.d.ts} +4 -4
  567. package/dist/tools/transfer/define-download-tool.d.ts.map +1 -0
  568. package/dist/tools/{define-upload-tool.d.ts → transfer/define-upload-tool.d.ts} +3 -3
  569. package/dist/tools/transfer/define-upload-tool.d.ts.map +1 -0
  570. package/dist/tools/{define-view-file-tool.d.ts → transfer/define-view-file-tool.d.ts} +2 -2
  571. package/dist/tools/transfer/define-view-file-tool.d.ts.map +1 -0
  572. package/dist/tools/{download-core.d.ts → transfer/download-core.d.ts} +2 -2
  573. package/dist/tools/transfer/download-core.d.ts.map +1 -0
  574. package/dist/tools/{managed-file-error.d.ts → transfer/managed-file-error.d.ts} +1 -1
  575. package/dist/tools/transfer/managed-file-error.d.ts.map +1 -0
  576. package/dist/tools/{mount-download.d.ts → transfer/mount-download.d.ts} +1 -1
  577. package/dist/tools/transfer/mount-download.d.ts.map +1 -0
  578. package/dist/tools/{mount-upload.d.ts → transfer/mount-upload.d.ts} +1 -1
  579. package/dist/tools/transfer/mount-upload.d.ts.map +1 -0
  580. package/dist/tools/transfer/native-result.d.ts.map +1 -0
  581. package/dist/tools/{upload-core.d.ts → transfer/upload-core.d.ts} +1 -1
  582. package/dist/tools/transfer/upload-core.d.ts.map +1 -0
  583. package/dist/tools/transfer/view-file-contract.d.ts.map +1 -0
  584. package/dist/tools/{view-file.d.ts → transfer/view-file.d.ts} +1 -1
  585. package/dist/tools/transfer/view-file.d.ts.map +1 -0
  586. package/dist/tools/transports.d.ts +1 -1
  587. package/dist/tools/transports.d.ts.map +1 -1
  588. package/dist/tracking/contract.d.ts +1 -1
  589. package/dist/tracking/contract.d.ts.map +1 -1
  590. package/llms/agent-runtime-browser.txt +33 -0
  591. package/llms/agent-runtime-coding-tools.txt +58 -0
  592. package/llms/agent-runtime-harness.txt +45 -0
  593. package/llms/agent-runtime-openrouter.txt +22 -0
  594. package/llms/agent-runtime-sandbox.txt +159 -0
  595. package/llms/agent-runtime-sqlite-bun.txt +29 -0
  596. package/llms/agent-runtime-sqlite-node.txt +26 -0
  597. package/llms/agent-runtime-testing.txt +30 -0
  598. package/llms/agent-runtime.2.txt +550 -0
  599. package/llms/agent-runtime.3.txt +311 -0
  600. package/llms/agent-runtime.txt +893 -0
  601. package/llms/application-diagnostic-journal.txt +30 -0
  602. package/llms/application-grammy.txt +27 -0
  603. package/llms/application-opentelemetry.txt +27 -0
  604. package/llms/application-schemas.txt +42 -0
  605. package/llms/application.2.txt +223 -0
  606. package/llms/application.txt +1144 -0
  607. package/llms/cli.txt +977 -0
  608. package/llms/contract.txt +606 -0
  609. package/llms/declaration.txt +286 -0
  610. package/llms/files.txt +30 -0
  611. package/llms/geo.txt +114 -0
  612. package/llms/google.txt +27 -0
  613. package/llms/live.txt +471 -0
  614. package/llms/node.txt +43 -0
  615. package/llms/oauth.txt +136 -0
  616. package/llms/observability.txt +893 -0
  617. package/llms/primitives.txt +158 -0
  618. package/llms/react.txt +184 -0
  619. package/llms/release.txt +176 -0
  620. package/llms/remote.txt +25 -0
  621. package/llms/server.2.txt +361 -0
  622. package/llms/server.3.txt +1031 -0
  623. package/llms/server.4.txt +905 -0
  624. package/llms/server.5.txt +250 -0
  625. package/llms/server.txt +996 -0
  626. package/llms/stitchkit.2.txt +836 -0
  627. package/llms/stitchkit.3.txt +147 -0
  628. package/llms/stitchkit.txt +260 -0
  629. package/llms/telegram.txt +30 -0
  630. package/llms/testing.txt +676 -0
  631. package/llms/tools-connections.txt +45 -0
  632. package/llms/tools-contract.txt +9 -0
  633. package/llms/tools-invoker.txt +9 -0
  634. package/llms/tools.2.txt +838 -0
  635. package/llms/tools.txt +1004 -0
  636. package/llms/tracking-server.txt +32 -0
  637. package/llms/tracking.txt +263 -0
  638. package/llms/upgrading-0.37.0-0.50.0.txt +947 -0
  639. package/llms/upgrading-0.53.0-0.67.0.txt +1174 -0
  640. package/llms/upgrading-0.68.0-0.94.0.txt +1159 -0
  641. package/llms/upgrading.txt +215 -0
  642. package/llms-full.txt +305 -75
  643. package/llms.txt +54 -5
  644. package/package.json +84 -83
  645. package/dist/agent-runtime/durability-contract.d.ts.map +0 -1
  646. package/dist/agent-runtime/durability-json.d.ts.map +0 -1
  647. package/dist/agent-runtime/durability-ledger.d.ts.map +0 -1
  648. package/dist/agent-runtime/durability-scheduler.d.ts.map +0 -1
  649. package/dist/agent-runtime/durability.d.ts.map +0 -1
  650. package/dist/agent-runtime/store-driver.d.ts.map +0 -1
  651. package/dist/agent-runtime-browser.d.ts +0 -5
  652. package/dist/agent-runtime-browser.d.ts.map +0 -1
  653. package/dist/agent-runtime-coding-tools.d.ts.map +0 -1
  654. package/dist/agent-runtime-coding-tools.js +0 -23
  655. package/dist/agent-runtime-harness.d.ts.map +0 -1
  656. package/dist/agent-runtime-openrouter.d.ts.map +0 -1
  657. package/dist/agent-runtime-sandbox.d.ts.map +0 -1
  658. package/dist/agent-runtime-sqlite-bun.d.ts.map +0 -1
  659. package/dist/agent-runtime-sqlite-node.d.ts.map +0 -1
  660. package/dist/agent-runtime-testing.d.ts +0 -3
  661. package/dist/agent-runtime-testing.d.ts.map +0 -1
  662. package/dist/agent-runtime-testing.js +0 -156
  663. package/dist/agent-runtime.d.ts.map +0 -1
  664. package/dist/application/channel.d.ts.map +0 -1
  665. package/dist/application-diagnostic-journal.d.ts.map +0 -1
  666. package/dist/application-grammy.d.ts.map +0 -1
  667. package/dist/application-opentelemetry.d.ts.map +0 -1
  668. package/dist/application-schemas.d.ts.map +0 -1
  669. package/dist/application.d.ts.map +0 -1
  670. package/dist/cli.d.ts.map +0 -1
  671. package/dist/contract/index.d.ts +0 -8
  672. package/dist/contract/index.d.ts.map +0 -1
  673. package/dist/declaration.d.ts.map +0 -1
  674. package/dist/files.d.ts.map +0 -1
  675. package/dist/geo.d.ts.map +0 -1
  676. package/dist/google.d.ts.map +0 -1
  677. package/dist/index-0j3vcp5m.js +0 -28
  678. package/dist/index-a11g2kry.js +0 -866
  679. package/dist/index-cnyk6te3.js +0 -77
  680. package/dist/index-fadnxwna.js +0 -1046
  681. package/dist/index-hrbajay7.js +0 -1196
  682. package/dist/index-s8cnx02s.js +0 -90
  683. package/dist/index-v5573g1k.js +0 -142
  684. package/dist/index-vk3kq9sb.js +0 -3344
  685. package/dist/index.d.ts.map +0 -1
  686. package/dist/internal/errors.d.ts.map +0 -1
  687. package/dist/internal/observability-sink.d.ts.map +0 -1
  688. package/dist/live.d.ts.map +0 -1
  689. package/dist/logger.d.ts.map +0 -1
  690. package/dist/node.d.ts.map +0 -1
  691. package/dist/oauth.d.ts.map +0 -1
  692. package/dist/observability/index.d.ts.map +0 -1
  693. package/dist/primitives.d.ts +0 -3
  694. package/dist/primitives.d.ts.map +0 -1
  695. package/dist/react.d.ts.map +0 -1
  696. package/dist/release.d.ts.map +0 -1
  697. package/dist/remote.d.ts.map +0 -1
  698. package/dist/remote.js +0 -88
  699. package/dist/retained.d.ts.map +0 -1
  700. package/dist/server/file-state-store.d.ts.map +0 -1
  701. package/dist/server/index.d.ts.map +0 -1
  702. package/dist/server/request.d.ts.map +0 -1
  703. package/dist/telegram.d.ts.map +0 -1
  704. package/dist/testing/agent-store-conformance.d.ts.map +0 -1
  705. package/dist/testing.d.ts +0 -39
  706. package/dist/testing.d.ts.map +0 -1
  707. package/dist/tool-invoker.d.ts.map +0 -1
  708. package/dist/tool-invoker.js +0 -21
  709. package/dist/tools/async-operation-contract.d.ts.map +0 -1
  710. package/dist/tools/async-operation.d.ts +0 -332
  711. package/dist/tools/async-operation.d.ts.map +0 -1
  712. package/dist/tools/cli-args.d.ts.map +0 -1
  713. package/dist/tools/cli-checkpoint.d.ts.map +0 -1
  714. package/dist/tools/cli-command.d.ts.map +0 -1
  715. package/dist/tools/cli-format.d.ts.map +0 -1
  716. package/dist/tools/cli-installer.d.ts.map +0 -1
  717. package/dist/tools/cli-invoke.d.ts.map +0 -1
  718. package/dist/tools/cli-manifest.d.ts.map +0 -1
  719. package/dist/tools/cli-policy.d.ts.map +0 -1
  720. package/dist/tools/cli-profile.d.ts.map +0 -1
  721. package/dist/tools/cli-signature.d.ts.map +0 -1
  722. package/dist/tools/cli-stream.d.ts.map +0 -1
  723. package/dist/tools/cli-update.d.ts.map +0 -1
  724. package/dist/tools/cli-view.d.ts.map +0 -1
  725. package/dist/tools/cli-wait.d.ts.map +0 -1
  726. package/dist/tools/cli.d.ts.map +0 -1
  727. package/dist/tools/coerce.d.ts.map +0 -1
  728. package/dist/tools/connections/index.d.ts.map +0 -1
  729. package/dist/tools/define-download-tool.d.ts.map +0 -1
  730. package/dist/tools/define-upload-tool.d.ts.map +0 -1
  731. package/dist/tools/define-view-file-tool.d.ts.map +0 -1
  732. package/dist/tools/define-wait-tool.d.ts.map +0 -1
  733. package/dist/tools/download-core.d.ts.map +0 -1
  734. package/dist/tools/flatten-join.d.ts.map +0 -1
  735. package/dist/tools/flatten.d.ts.map +0 -1
  736. package/dist/tools/json-schema-dialect.d.ts.map +0 -1
  737. package/dist/tools/json-schema.d.ts.map +0 -1
  738. package/dist/tools/managed-file-error.d.ts.map +0 -1
  739. package/dist/tools/mcp-app.d.ts.map +0 -1
  740. package/dist/tools/mcp-catalog.d.ts.map +0 -1
  741. package/dist/tools/mcp-handler.d.ts.map +0 -1
  742. package/dist/tools/mcp-prepare.d.ts.map +0 -1
  743. package/dist/tools/mcp-progress.d.ts.map +0 -1
  744. package/dist/tools/mcp-round-policy.d.ts.map +0 -1
  745. package/dist/tools/mcp-round.d.ts.map +0 -1
  746. package/dist/tools/mcp-stdio-signals.d.ts.map +0 -1
  747. package/dist/tools/mcp-stdio.d.ts.map +0 -1
  748. package/dist/tools/mcp-trace.d.ts.map +0 -1
  749. package/dist/tools/mcp.d.ts.map +0 -1
  750. package/dist/tools/mount-download.d.ts.map +0 -1
  751. package/dist/tools/mount-upload.d.ts.map +0 -1
  752. package/dist/tools/mount-wait.d.ts.map +0 -1
  753. package/dist/tools/native-mcp.d.ts +0 -20
  754. package/dist/tools/native-mcp.d.ts.map +0 -1
  755. package/dist/tools/native-result.d.ts.map +0 -1
  756. package/dist/tools/oauth-metadata.d.ts.map +0 -1
  757. package/dist/tools/oauth-provider.d.ts.map +0 -1
  758. package/dist/tools/portable-formats.d.ts.map +0 -1
  759. package/dist/tools/presentation.d.ts.map +0 -1
  760. package/dist/tools/schema.d.ts.map +0 -1
  761. package/dist/tools/untyped-properties.d.ts.map +0 -1
  762. package/dist/tools/upload-core.d.ts.map +0 -1
  763. package/dist/tools/view-file-contract.d.ts.map +0 -1
  764. package/dist/tools/view-file.d.ts.map +0 -1
  765. package/dist/tools/wait-core.d.ts.map +0 -1
  766. package/dist/tools-contract.d.ts.map +0 -1
  767. package/dist/tools.d.ts +0 -50
  768. package/dist/tools.d.ts.map +0 -1
  769. package/dist/tracking-server.d.ts.map +0 -1
  770. package/dist/tracking.d.ts.map +0 -1
  771. package/dist/upgrade-cli.d.ts.map +0 -1
  772. package/dist/{retained.d.ts → browser/retained.d.ts} +0 -0
  773. package/dist/{declaration.d.ts → declaration/declaration.d.ts} +0 -0
  774. package/dist/{upgrade-cli.d.ts → entrypoints/bin/upgrade-cli.d.ts} +0 -0
  775. package/dist/{tracking-server.js → entrypoints/tracking/server.js} +0 -0
  776. package/dist/{google.d.ts → google/google.d.ts} +0 -0
  777. package/dist/{index-pq95qkbf.js → index-5jm36zv1.js} +0 -0
  778. package/dist/{index-actkayzn.js → index-70yj2ebz.js} +3 -3
  779. /package/dist/{application → internal}/channel.d.ts +0 -0
  780. /package/dist/{logger.d.ts → internal/logger.d.ts} +0 -0
  781. /package/dist/{server → internal}/request.d.ts +0 -0
  782. /package/dist/{tools → json-schema}/json-schema.d.ts +0 -0
  783. /package/dist/tools/{async-operation-contract.d.ts → operations/async-operation-contract.d.ts} +0 -0
  784. /package/dist/tools/{mount-wait.d.ts → operations/mount-wait.d.ts} +0 -0
  785. /package/dist/tools/{wait-core.d.ts → operations/wait-core.d.ts} +0 -0
  786. /package/dist/tools/{coerce.d.ts → schema/coerce.d.ts} +0 -0
  787. /package/dist/tools/{flatten-join.d.ts → schema/flatten-join.d.ts} +0 -0
  788. /package/dist/tools/{flatten.d.ts → schema/flatten.d.ts} +0 -0
  789. /package/dist/tools/{portable-formats.d.ts → schema/portable-formats.d.ts} +0 -0
  790. /package/dist/tools/{schema.d.ts → schema/schema.d.ts} +0 -0
  791. /package/dist/tools/{untyped-properties.d.ts → schema/untyped-properties.d.ts} +0 -0
  792. /package/dist/tools/{native-result.d.ts → transfer/native-result.d.ts} +0 -0
  793. /package/dist/tools/{view-file-contract.d.ts → transfer/view-file-contract.d.ts} +0 -0
package/llms/cli.txt ADDED
@@ -0,0 +1,977 @@
1
+ # stitchkit/cli — 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: Guide: CLI (docs/guide/cli.md) · API reference: `stitchkit/cli` (docs/api/reference.md)
7
+
8
+ ==============================================================================
9
+ # Guide: CLI (docs/guide/cli.md)
10
+ ==============================================================================
11
+
12
+ # CLI
13
+
14
+ The same contract and managed runtime tools that drive HTTP, MCP and agent
15
+ surfaces can also drive a command-line program. `createCli` composes their
16
+ commands with explicitly local binary commands in one router and help tree.
17
+ Managed commands — `myapp generate "a fox" --wait`,
18
+ `myapp models list --json | jq …` — run through the same validation, auth gate
19
+ and error model as every other managed surface (HTTP ≡ MCP ≡ agent ≡ CLI,
20
+ [ADR 0014](../decisions/0014-tool-http-parity.md)).
21
+
22
+ It exists for what the other three surfaces cannot do: a generation kicked off
23
+ with `Bash(run_in_background)` that notifies on exit, a `SKILL.md` that shells
24
+ out in one line, a pipeable terminal command.
25
+
26
+ ## Exposure is opt-in
27
+
28
+ Unlike MCP and agent — where an endpoint with no `expose` is a tool by default —
29
+ **a method becomes a CLI command only when its `expose` lists `'CLI'`.** Adding
30
+ the CLI never silently turns your existing API tools into shell commands.
31
+
32
+ ```ts
33
+ { method: 'POST', path: '/', desc: 'Generate media', tool: { name: 'generate' },
34
+ expose: ['CLI', 'MCP', 'AGENT'], input: GenerateInput, output: Generation } // CLI + MCP + agent
35
+ { method: 'GET', path: '/models', desc: 'List models', tool: { name: 'list_models' },
36
+ expose: ['CLI'] } // CLI only
37
+ { method: 'GET', path: '/search', desc: 'Search' } // HTTP + MCP + AGENT — NOT CLI
38
+ ```
39
+
40
+ A fresh contract shows **zero** CLI commands until methods opt in — that is the
41
+ design, not a bug. A pathless runtime definition follows the same rule: it must
42
+ explicitly include `'CLI'` in `transports`; the undefined default remains
43
+ `['MCP', 'AGENT']`. The command name is the tool name — `tool.name` if set, else
44
+ a verb-aware name from the method + prefix (`list` → `list_widgets`, `get` →
45
+ `get_widget`), not a literal `prefix_key`.
46
+
47
+ ## A minimal CLI
48
+
49
+ stitchkit ships no binary — you write the executable and point your app's `bin`
50
+ at it:
51
+
52
+ ```ts
53
+ #!/usr/bin/env node
54
+ // src/cli.ts
55
+ import { createCli } from 'stitchkit/cli'
56
+ import { catalogService, generateService } from './services'
57
+
58
+ await createCli({
59
+ name: 'myapp',
60
+ version: '1.0.0',
61
+ services: [catalogService, generateService],
62
+ resolveAuth: () => resolveToken(process.env.MYAPP_TOKEN), // lazy, at most once
63
+ })
64
+ ```
65
+
66
+ `createCli({ signal })` and its wait loop honor an explicit caller
67
+ `AbortSignal`. Stitchkit does not install a process-global SIGINT handler for
68
+ ordinary CLI programs: if desired, the application binds SIGINT to an
69
+ `AbortController` and passes its signal. Aborting wait stops polling only; it
70
+ does not cancel the underlying job.
71
+
72
+ ```json
73
+ // package.json
74
+ { "bin": { "myapp": "./dist/cli.js" } }
75
+ ```
76
+
77
+ `stitchkit/cli` pulls in neither the MCP SDK nor `ai`, so a CLI binary needs no
78
+ MCP/agent peer dependencies.
79
+
80
+ ## Pathless managed commands
81
+
82
+ Use `runtimeTools` when an application operation has no HTTP path but must keep
83
+ the canonical operation identity, context, lifecycle/RBAC, hooks and
84
+ introspection. It can share one definition with MCP and Agent while opting into
85
+ CLI explicitly:
86
+
87
+ ```ts
88
+ import { createCli } from 'stitchkit/cli'
89
+ import { defineUploadTool } from 'stitchkit/tools'
90
+ import { z } from 'zod'
91
+
92
+ const uploadInput = defineUploadTool({
93
+ name: 'upload_input',
94
+ description: 'Upload one local input file',
95
+ identity: { serviceName: 'jobs', action: 'uploadInput', scope: 'user' },
96
+ output: z.object({ url: z.url() }),
97
+ transports: ['MCP', 'AGENT', 'CLI'],
98
+ upload: (path, context) => uploadFile(path, context.signal),
99
+ })
100
+
101
+ await createCli({
102
+ name: 'myapp',
103
+ version: '1.0.0',
104
+ runtimeTools: [uploadInput],
105
+ })
106
+ ```
107
+
108
+ `services` and `runtimeTools` may each be static arrays or factories receiving
109
+ the resolved identity. A runtime-only CLI is valid; `stitchkit/cli` still pulls
110
+ in neither MCP nor AI peers. Contract/runtime name collisions and reserved
111
+ option fields fail through the same checks before managed dispatch.
112
+
113
+ ## Native binary commands
114
+
115
+ Login, self-update, diagnostics, integration setup and shell completion belong
116
+ to the executable, not to HTTP/MCP/Agent. Define them with `defineCliCommand`:
117
+
118
+ ```ts
119
+ import { createCli, defineCliCommand } from 'stitchkit/cli'
120
+ import { z } from 'zod'
121
+
122
+ const login = defineCliCommand({
123
+ name: 'login',
124
+ description: 'Store credentials for later managed commands',
125
+ input: z.object({ token: z.string() }),
126
+ output: z.object({ configured: z.boolean() }),
127
+ handler: async ({ input }) => {
128
+ await saveToken(input.token)
129
+ return { configured: true }
130
+ },
131
+ })
132
+
133
+ await createCli({
134
+ name: 'myapp',
135
+ version: '1.0.0',
136
+ commands: [login],
137
+ resolveAuth: loadStoredIdentity,
138
+ services: (identity) => createRemoteServices(identity),
139
+ })
140
+ ```
141
+
142
+ Native commands receive only typed `input`, parsed global `options` and the
143
+ configured stdout/stderr writers. They reuse help, argv/stdin parsing,
144
+ validation, dry-run, error envelopes and exit mapping, but deliberately have no
145
+ fake service/action/scope/method identity, lifecycle or tool hooks and never
146
+ appear in MCP/Agent manifests.
147
+
148
+ A native command with a declared output may also own its final terminal
149
+ presentation and successful process status. Both callbacks receive the exact
150
+ Zod output type and run only after output validation; help, dry-run and failed
151
+ validation never invoke them:
152
+
153
+ ```ts
154
+ const doctor = defineCliCommand({
155
+ name: 'doctor',
156
+ description: 'Inspect local health',
157
+ input: z.object({}),
158
+ output: z.object({ status: z.enum(['ok', 'degraded']) }),
159
+ handler: () => ({ status: 'degraded' }),
160
+ present: ({ result, options }) =>
161
+ options.json ? `${JSON.stringify(result)}\n` : `STATUS ${result.status}\n`,
162
+ exitCode: (result) => result.status === 'degraded' ? 1 : 0,
163
+ })
164
+ ```
165
+
166
+ `present` returns the exact stdout bytes, which Stitchkit writes once. Without
167
+ it the canonical JSON output is unchanged. `exitCode` classifies a successfully
168
+ validated result and must return an integer in `0..255`; failed `ToolResult`
169
+ envelopes and the application-wide `exitCodes` mapping remain authoritative for
170
+ failures. A throwing callback, invalid status or non-string presenter becomes a
171
+ normalized `INTERNAL_SERVER_ERROR`, never partial success output. Void native
172
+ commands cannot declare either callback.
173
+
174
+ `--version`, a selected native command and its command help run before
175
+ `resolveAuth`, services, context or runtime-tool factories. Top-level help is
176
+ also credential-free when managed surfaces are static. A dynamic factory must
177
+ resolve identity to discover its command names; its collisions are checked at
178
+ that resolution boundary. If eager global collision proof matters, keep the
179
+ surface static.
180
+
181
+ ## Calling commands
182
+
183
+ ```
184
+ <app> <command> [positional] [--flags]
185
+ ```
186
+
187
+ Arguments are coerced to the contract schema's types — every argv token is a
188
+ string, the schema says what it should be:
189
+
190
+ | Zod field | CLI |
191
+ | -------------------- | ---------------------------------------------- |
192
+ | `z.string()` | `--name "box"` or a positional |
193
+ | `z.number()` | `--count 3` → `3` |
194
+ | `z.boolean()` | `--active` (presence) / `--no-active` |
195
+ | `z.enum([...])` | `--size large` |
196
+ | `z.array(z.string())`| `--tag a --tag b` → `["a","b"]` |
197
+ | `z.object({...})` | `--opts '{"k":"v"}'` (JSON) or `--opts.k v` |
198
+ | `.optional()` / `.default()` | not required |
199
+
200
+ Without presentation configuration, positional arguments fill non-boolean
201
+ fields in declaration order, so `myapp generate "a fox"` is
202
+ `--prompt "a fox"`. A piped value fills the first required unset field:
203
+ `echo "a fox" | myapp generate`.
204
+
205
+ For a stable shell grammar, declare the default command, short aliases and the
206
+ exact positional fields on `createCli`:
207
+
208
+ ```ts
209
+ await createCli({
210
+ name: 'myapp',
211
+ version: '1.0.0',
212
+ services,
213
+ commands: [doctor],
214
+ defaultCommand: 'logs',
215
+ optionAliases: {
216
+ logs: { f: 'follow', n: 'lines' },
217
+ },
218
+ positionals: {
219
+ logs: ['target'], // `lines` is option-only
220
+ doctor: [], // no argv positionals
221
+ },
222
+ })
223
+ ```
224
+
225
+ Now `myapp`, `myapp --json` and `myapp logs --json` select `logs`;
226
+ `myapp -f -n 100 --target api` maps to
227
+ `logs --follow --lines 100 --target api`. A leading non-option token remains an
228
+ explicit command so typos stay loud rather than becoming ambiguous default
229
+ positionals; use an explicit `myapp logs api` when passing positionals. Leading
230
+ framework globals may precede that explicit command. Top-level `--help`, `-h`
231
+ and `--version` never execute the default, and top-level help marks it.
232
+
233
+ Aliases are command-local, one ASCII letter and validated against the resolved
234
+ command schema. `-f` / `-f=false` are boolean forms; values accept `-n 100` and
235
+ `-n=100`. Arrays accumulate across short and long forms. `-h` is reserved,
236
+ bundles such as `-fn`, attached values such as `-n100`, `--no-f` and unknown
237
+ short flags are rejected. Canonical `--no-follow` remains available.
238
+
239
+ ### A trailing list
240
+
241
+ When the LAST declared positional is an array field, it takes every remaining
242
+ token, each coerced by the array's element type:
243
+
244
+ ```ts
245
+ positionals: { handoff: ['to', 'files'] } // files: z.array(z.string())
246
+ ```
247
+
248
+ ```
249
+ myapp handoff proj a.md b.md → { to: 'proj', files: ['a.md', 'b.md'] }
250
+ myapp handoff proj a.md → { to: 'proj', files: ['a.md'] }
251
+ ```
252
+
253
+ One token is a one-element list, not a scalar, so the parsed shape never depends
254
+ on how many a caller happened to pass. Command help marks it:
255
+ `Usage: myapp handoff <to> <files...>`. The flag form still works
256
+ (`--files '["a.md","b.md"]'`, or a repeated `--files`) — but passing both forms
257
+ in one call is an argument error rather than a silent merge.
258
+
259
+ Only the trailing position is variadic. An array declared anywhere else in the
260
+ list keeps taking exactly one token (a JSON array), and its help stays `<tags>`,
261
+ so the usage line always says which field is the list.
262
+
263
+ `positionals` replaces automatic schema-order selection only for the named
264
+ command. An empty array disables argv positionals. Fields remain available as
265
+ long/short options and stdin still fills the first required unset field with the
266
+ same schema-aware coercion. Unknown, duplicate or boolean targets and a required
267
+ positional after an optional/default positional fail when that command surface
268
+ resolves. Native dispatch retains its lazy credential-free boundary; dynamic
269
+ managed policies validate when their identity-dependent surface resolves.
270
+
271
+ The advertised schema is never mutated — a CLI call validates against the exact
272
+ same Zod schema an HTTP or MCP call does.
273
+
274
+ ## Global flags
275
+
276
+ | Flag | Effect |
277
+ | --------------------- | ---------------------------------------------------------- |
278
+ | `--json` | Compact success/error JSON records for scripts |
279
+ | `--wait` | Block-poll an async result to a terminal state |
280
+ | `--wait-timeout <s>` | Override the `--wait` timeout |
281
+ | `--output-dir <dir>` | Download result media into a directory |
282
+ | `--quiet` | Suppress non-essential stderr output |
283
+ | `--dry-run` | Print the resolved call without executing |
284
+ | `--help`, `-h` | Usage — top-level or per-command flag table |
285
+ | `--help <text>` | List only the commands matching a substring |
286
+ | `--count-by <field>` | Count records per distinct value — see [Aggregate views](#aggregate-views) |
287
+ | `--sum <f> [--by <g>]`| Total a numeric field, optionally grouped |
288
+ | `--sort <field>` | Order records by a field, largest first |
289
+ | `--ascending` | Flip `--sort` to smallest first |
290
+ | `--top <n>` | Keep the n leading entries of the view asked for |
291
+ | `--table <a,b>` | Render named fields as an aligned table |
292
+
293
+ stdout carries the result; structured errors and progress go to stderr. With
294
+ `--json`, a success or structured failure is exactly one compact,
295
+ newline-terminated JSON record on its respective stream; progress and CLI usage
296
+ diagnostics remain ordinary stderr text. This keeps stdout pipeable and
297
+ `2>/dev/null` clean. The process exit code carries the error class (`0` ok,
298
+ `VALIDATION_ERROR → 1`, `UNAUTHORIZED → 2`, `FORBIDDEN → 3`, `NOT_FOUND → 4`,
299
+ …) — override per app with `exitCodes`.
300
+
301
+ ### A narrower question than "all of them"
302
+
303
+ On a discovered surface `--help` is the only way to learn what exists, and that
304
+ can be two hundred commands. At that size the list stops being an answer: it
305
+ scrolls past a person and costs an agent the same context an unfiltered result
306
+ would. So there is a question between "one command" and "all of them":
307
+
308
+ ```bash
309
+ myapp --help broadcast # also: -h broadcast · help broadcast · --help=broadcast
310
+ ```
311
+
312
+ ```
313
+ Commands matching "broadcast" (3 of 205):
314
+ broadcast_send Send a broadcast to every subscriber
315
+ broadcast_cancel Stop a running broadcast
316
+ announce_publish Publish an announcement as a broadcast
317
+ ```
318
+
319
+ The description is searched as well as the name, because the word someone knows
320
+ is often in the sentence rather than the name — `announce_publish` above is
321
+ matched that way. The count says what was left out.
322
+
323
+ **No match is an exit code**, not an empty success: `0` over an empty list reads
324
+ as "there are none", which is a different statement from "none of these". It
325
+ exits with whatever `NOT_FOUND` maps to (`4` by default). Bare `--help` is
326
+ unchanged, and `--help=false` still means what it always did — the reserved
327
+ boolean's negation — so one value never carries two meanings.
328
+
329
+ ## Application global options
330
+
331
+ `--json` and friends above are the framework's. An application usually has
332
+ globals of its own — which identity key to use, which checkout a call speaks
333
+ for, which profile — and they belong to no single operation:
334
+
335
+ ```ts
336
+ await createCli({
337
+ name: 'myapp',
338
+ version: '1.0.0',
339
+ globalOptions: z.object({
340
+ caller: z.string().optional().describe('Identity key file'),
341
+ root: z.string().optional().describe('Checkout the call speaks for'),
342
+ }),
343
+ resolveAuth: (globals) => loadIdentity(globals.caller),
344
+ context: (auth, globals) => ({ auth, root: globals.root }),
345
+ runtimeTools: (auth) => catalogFor(auth),
346
+ })
347
+ ```
348
+
349
+ ```
350
+ myapp --root /srv/app handoff_read --handoffId u
351
+ myapp handoff_read --root /srv/app --handoffId u # the same call
352
+ ```
353
+
354
+ These flags are lifted out of argv wherever they stand — before or after the
355
+ command name — validated against the declared schema, and kept out of every
356
+ operation's arguments: `handoff_read` above receives `{ handoffId: 'u' }` and
357
+ nothing else. The values reach `resolveAuth(globals)`, `context(auth, globals)`
358
+ and a native command's `globals`. An invalid value is an argument error naming
359
+ the flag; a name that collides with a framework option, or with a field of any
360
+ command, is refused at startup rather than shadowing it silently. Past a bare
361
+ `--` every token is a literal, so a positional value that reads like a global
362
+ survives intact.
363
+
364
+ Both help levels list them under `Application options:`.
365
+
366
+ ## When the managed surface cannot resolve
367
+
368
+ A CLI whose commands come from a running server declares them with a factory,
369
+ and that factory needs an identity. When `resolveAuth` fails — the server is
370
+ down, the key file is missing — the commands it would have named are unknown to
371
+ the CLI, but the native ones are not:
372
+
373
+ ```
374
+ $ myapp --help
375
+ myapp 1.0.0
376
+ ...
377
+ Commands:
378
+ serve Run the server
379
+
380
+ Managed commands are unavailable: UNREACHABLE: socket closed
381
+ ```
382
+
383
+ Help still lists what does not depend on identity and says, in one line, why the
384
+ rest is missing. Calling a name the CLI cannot resolve answers with that same
385
+ refusal and the exit code its error class declares through `exitCodes` — never
386
+ `Unknown command`, which would claim the name does not exist when the truth is
387
+ that it could not be looked up. A native command and its help still run: they
388
+ never needed an identity. Identity is still resolved at most once per
389
+ invocation, failure included.
390
+
391
+ Per-command help derives the positional form from the same resolved policy as
392
+ the argv parser. For example, a required `action` and optional `profile` render as
393
+ `Usage: myapp skill <action> [profile] [--flags]`; the argument table also shows
394
+ `<action> | --action` and `[profile] | --profile`. Boolean fields remain flags.
395
+ Declared aliases render beside their canonical options, for example
396
+ `-n, --lines`.
397
+
398
+ ## `--wait` — background-friendly generation
399
+
400
+ `--wait` polls an async result until it is done. It is generic — the core knows
401
+ nothing about "generations": you say how to read the poll target, which command
402
+ to re-call and when it is done.
403
+
404
+ ```ts
405
+ await createCli({
406
+ name: 'myapp',
407
+ version: '1.0.0',
408
+ services,
409
+ wait: {
410
+ generate: {
411
+ tool: 'get_generation',
412
+ poll: (r) => (isRecord(r) && typeof r.id === 'string' ? { id: r.id } : null),
413
+ done: (r) => isRecord(r) && ['COMPLETED', 'FAILED'].includes(String(r.status)),
414
+ failed: (r) => isRecord(r) && r.status === 'FAILED',
415
+ },
416
+ },
417
+ })
418
+ ```
419
+
420
+ `failed` is optional. When it matches either the initial result or a later poll,
421
+ polling stops and the CLI emits `WAIT_FAILED` on stderr with a non-zero exit;
422
+ the terminal payload is retained under `details.result`. `failed` is checked
423
+ before `done`, so overlapping predicates fail closed. A failed poll tool call
424
+ keeps its own error code, and an elapsed deadline remains `TIMEOUT`.
425
+
426
+ ```bash
427
+ # foreground
428
+ myapp generate "a fox" --wait --output-dir ./out
429
+
430
+ # background — frees the agent; a notification fires on exit
431
+ myapp generate "a fox" --wait --json > result.json &
432
+ ```
433
+
434
+ ## Aggregate views
435
+
436
+ The CLI's audience is agents, scripts and `jq`, so output is JSON. That settles
437
+ the *encoding*; it does not settle whether the answer to "how many items per
438
+ status" should be every item. Measured on a live server, one ordinary question:
439
+
440
+ | call | characters returned |
441
+ |---|---|
442
+ | the listing (98 records) | 34 750 |
443
+ | `--count-by status` | ~90 |
444
+
445
+ An agent pays for every one of those characters in its context window, and `|
446
+ jq` does not help: the bytes have been read into the conversation by the time
447
+ `jq` sees them. So the aggregate is computed on the result, before anything is
448
+ written.
449
+
450
+ ```bash
451
+ myapp item_list --count-by status # { "active": 33, "idle": 33, "stopped": 32 }
452
+ myapp item_list --count-by status --top 2 # the two largest groups
453
+ myapp item_list --sum messages # 4753
454
+ myapp item_list --sum messages --by status # one total per status
455
+ myapp item_list --top 5 --by status # same view, written the other way round
456
+ myapp item_list --table id,status # the one human-facing shape
457
+ ```
458
+
459
+ Two words, one each: **`--by` groups, `--sort` orders.** That leaves `--top` a
460
+ single meaning everywhere — *the n leading entries of the view you asked for* —
461
+ so the question a CLI actually gets asked composes out of the parts:
462
+
463
+ ```bash
464
+ myapp item_list --top 5 --sort messages --table id,messages # the five biggest, as a table
465
+ myapp item_list --sort messages --top 5 --json # the same five, as records
466
+ myapp item_list --sort name --ascending # ordered the other way
467
+ ```
468
+
469
+ Groups come back largest first for the same reason. A record that carries no
470
+ value for the sort field sorts **last in both directions**: it is not the
471
+ smallest, it is not on the scale at all, and letting it lead an ascending list
472
+ would answer a question nobody asked.
473
+
474
+ Three rules worth knowing before you rely on them:
475
+
476
+ - **A field the result does not carry is an argument error.** A group of zero
477
+ over a misspelled field is indistinguishable from a true empty answer, and the
478
+ caller reads it as data. The message names the fields that *are* there.
479
+ - **An aggregate needs a collection** — the result itself when it is an array,
480
+ or the single array field of a result object. An aggregate over a scalar, or
481
+ over an object with two array fields, is refused rather than guessed.
482
+ - **Without a view flag the output is byte-for-byte what it was.** The flags are
483
+ reserved CLI behaviour like `--json`; they never reach a tool argument.
484
+ - **Ordering and grouping do not mix.** `--sort` with `--by`, `--count-by` or
485
+ `--sum` is refused rather than given a second meaning.
486
+
487
+ A failed call still reports its own error and exit code. An aggregate over an
488
+ error is not an answer to the question that was asked.
489
+
490
+ ## Named profiles
491
+
492
+ A CLI that talks to a deployed server needs an address and a credential per
493
+ environment, and the way a person picks one is a name: `--profile prod`.
494
+ `globalOptions` gives the flag a home and `resolveAuth(globals)` gives it a
495
+ resolution point. The rule that makes the mechanism safe is easy to write the
496
+ wrong way round, because the unsafe version reads as kindness:
497
+
498
+ > the named profile does not exist, but exactly one profile is configured — use it.
499
+
500
+ That is correct exactly while a single profile exists. The day a second appears
501
+ it is a command run against the wrong deployment, with nothing in the output to
502
+ say so. **A profile named explicitly and not found is a refusal, never a
503
+ substitution.** Substitution survives only where it cannot be wrong: no name was
504
+ given at all and exactly one profile exists — and even then it is announced on
505
+ stderr. The distinction has to be drawn at resolution; one step later, "prod" and
506
+ "prod by default" are the same string.
507
+
508
+ `createCliProfileStore` is that rule, plus the twenty lines every consumer of
509
+ this shape writes:
510
+
511
+ ```ts
512
+ import { createCliProfileStore } from 'stitchkit/cli'
513
+ import { homedir } from 'node:os'
514
+ import { join } from 'node:path'
515
+ import { z } from 'zod'
516
+
517
+ const profiles = createCliProfileStore({
518
+ directory: join(homedir(), '.config/myapp/profiles'),
519
+ schema: z.object({ url: z.url(), token: z.string().min(1) }),
520
+ createHint: (name, path) => `write ${path} with {"url","token"} for "${name}"`,
521
+ })
522
+
523
+ await createCli({
524
+ name: 'myapp',
525
+ version,
526
+ globalOptions: z.object({ profile: z.string().optional() }),
527
+ resolveAuth: (globals) => profiles.resolve(globals.profile).value,
528
+ services,
529
+ })
530
+ ```
531
+
532
+ Files are written `0600` in a `0700` directory — and a profile file other users
533
+ can read is refused with the `chmod` that fixes it, because it holds a
534
+ credential.
535
+
536
+ ## Distribution and self-update
537
+
538
+ `createCli` ships no executable, and that is right — but the step after the
539
+ executable is not application logic either. It is the same problem for every
540
+ consumer, with the same three traps:
541
+
542
+ 1. **The installer cannot parse the manifest.** A `curl … | sh` runs on a
543
+ machine where nothing is installed yet, including `jq`. So the installer is
544
+ generated *from* the manifest, server-side, with the URL and digest already
545
+ substituted — it parses no JSON at all.
546
+ 2. **Replacing a running binary is a rename, not a write.** Anything else can
547
+ leave a half-written executable on someone's PATH when the connection drops.
548
+ 3. **The digest covers the decompressed bytes** — the file that will actually be
549
+ executed, not the archive that was transferred.
550
+
551
+ The framework owns the manifest shape, the installer generation and the update
552
+ primitive. The application owns where the assets live, which platforms it
553
+ publishes and who may download them.
554
+
555
+ ```ts
556
+ import {
557
+ CliBuildManifestSchema, assertCliPublishable, renderCliInstaller,
558
+ selectCliBuildAsset, checkCliUpdate, applyCliUpdate,
559
+ } from 'stitchkit/cli'
560
+
561
+ // Publishing: refuse to republish one version from a different commit —
562
+ // otherwise everyone who already installed it never receives the fix.
563
+ assertCliPublishable(previous, next)
564
+
565
+ // Serving: omit `asset` and one script covers every published target, selecting
566
+ // by uname at run time — otherwise that dispatch is the last hand-written piece
567
+ // of the install path, and every publisher writes the same x86_64 → x64 table.
568
+ renderCliInstaller({ manifest, binaryName: 'myapp' })
569
+ // Or pin one target explicitly:
570
+ renderCliInstaller({ manifest, asset: selectCliBuildAsset(manifest, target), binaryName: 'myapp' })
571
+
572
+ // Checking: bounded, at most once per interval, silent on any failure.
573
+ const check = await checkCliUpdate({ manifestUrl, currentVersion, lastCheckedAt })
574
+ if (check.status === 'outdated' && check.asset) {
575
+ // Replacing is always an explicit command, never a side effect of a check.
576
+ await applyCliUpdate({ asset: check.asset })
577
+ }
578
+ ```
579
+
580
+ `checkCliUpdate` has **four** answers, not three: `skipped`, `current`,
581
+ `outdated` and `unknown`. "Could not ask" is not "up to date" — collapsing them
582
+ is how a tool goes quiet about its own staleness for months. It never throws,
583
+ and a command still exits with the code it earned.
584
+
585
+ Carry the build stamp inside the binary (`CliBuildStampSchema`,
586
+ `formatCliBuildStamp`) so the tool can say what it is rather than leaving the
587
+ reader to infer it from behaviour.
588
+
589
+ #### A manifest inside your own network
590
+
591
+ The check goes through the same SSRF boundary every outbound fetch does, so a
592
+ manifest served from `10.x`, `localhost` or a `.internal` name is refused and
593
+ the answer is `unknown`. For a self-hosted deployment that is a wrong answer
594
+ dressed as a careful one, and the refusal says so — it names the field that
595
+ lifts it rather than reading like a timeout:
596
+
597
+ ```text
598
+ refusing to fetch an internal host — the manifest endpoint is not public.
599
+ Set `allowPrivateHosts` if it is your own deployment; the download keeps its
600
+ own setting, because an asset URL comes from the document.
601
+ ```
602
+
603
+ ```ts
604
+ const check = await checkCliUpdate({ manifestUrl, currentVersion, allowPrivateHosts: true })
605
+ ```
606
+
607
+ Set it from whether **your** endpoint is private, not as a blanket switch, and
608
+ leave `applyCliUpdate` at its default. The two are not the same decision: the
609
+ manifest URL is configuration you wrote, while an asset URL arrives inside a
610
+ document the endpoint served, and a document is exactly what an SSRF boundary
611
+ exists to distrust.
612
+
613
+ ### Proving who built it — signing the manifest
614
+
615
+ The asset digest proves the bytes that arrived are the bytes the manifest named.
616
+ It proves nothing about who named them: the manifest and the assets come from
617
+ one origin, so whoever can replace one can replace the other. Authorship needs a
618
+ key the build carries and the server never holds.
619
+
620
+ ```ts
621
+ // Publishing — the only side that holds a private key.
622
+ const signature = signCliManifest(manifest, { keyId: 'release-2026', privateKey })
623
+ publish({ ...manifest, signature })
624
+
625
+ // Installing — the trust root is compiled into the binary. One fetched at run
626
+ // time from the same origin as the manifest would prove nothing.
627
+ const trust = { keys: { 'release-2026': PUBLISHED_KEY } }
628
+ const check = await checkCliUpdate({ manifestUrl, currentVersion, trust })
629
+ if (check.status === 'outdated' && check.asset) {
630
+ await applyCliUpdate({ asset: check.asset, manifest: check.manifest, trust, backupPath })
631
+ }
632
+ ```
633
+
634
+ The signature covers `{name, version, commit, builtAt, assets[]}` with **every
635
+ asset's digest**, so the chain closes on the file that will execute rather than
636
+ on the document describing it; moving an asset to a new URL does not invalidate
637
+ it, changing what an asset contains does.
638
+
639
+ Five verdicts, and `unenforced` is the one that earns its keep: a build with no
640
+ pinned key keeps updating, and the fact that nothing was checked is *visible*
641
+ rather than assumed. `missing`, `unknown-key` and `invalid` are distinguished
642
+ because they need different answers — a key you forgot to pin is not a forged
643
+ signature.
644
+
645
+ A bad verdict does not produce a fifth status. `outdated` is an instruction to
646
+ install, and a manifest that failed its signature has not established that there
647
+ is a newer build worth installing — only that a document claims one. The check
648
+ answers `unknown` with the verdict in its reason, so it is never mistaken for a
649
+ network failure. `applyCliUpdate` checks again and refuses **before** the
650
+ download: a signature verified after the bytes are on the machine produces a
651
+ cleanup problem rather than a refusal.
652
+
653
+ ### A way back — `backupPath` and `rollbackCliUpdate`
654
+
655
+ Rolling back is a property of updating, not of the application:
656
+
657
+ ```ts
658
+ const applied = await applyCliUpdate({ asset, targetPath, backupPath })
659
+ // …the new build turns out to be wrong. `backupSha256` is absent when there was
660
+ // nothing to keep — a first install — and that is the case with nothing to roll
661
+ // back to:
662
+ if (applied.backupSha256) {
663
+ rollbackCliUpdate({ targetPath, backupPath, expectedSha256: applied.backupSha256 })
664
+ }
665
+ ```
666
+
667
+ The copy is taken between "the new bytes verified" and the replacement — earlier
668
+ would preserve a binary about to be replaced by a download that then failed its
669
+ digest, later has nothing left to copy — and it carries the target's file mode,
670
+ because a backup that cannot be executed is not a way back. A first install has
671
+ nothing to keep, which is not a failure.
672
+
673
+ `expectedSha256` is required, not optional. A rollback that installs whatever
674
+ happens to be at the backup path is a second install of an unverified binary,
675
+ and the day it is used is the day nobody is in a position to check.
676
+
677
+ ### Two release tracks
678
+
679
+ `assertCliPublishable` takes one manifest **or every manifest already
680
+ published**:
681
+
682
+ ```ts
683
+ assertCliPublishable([stableManifest, betaManifest], next)
684
+ ```
685
+
686
+ With a single argument and two tracks the check is silently useless: `1.2.3`
687
+ goes to beta from one commit and to stable from another, the function is called
688
+ with the track being published and sees no conflict, and the person who
689
+ installed the beta is told they are current forever. Nothing on their machine
690
+ looks wrong.
691
+
692
+ **The channel itself is not an argument of the framework, and will not become
693
+ one.** The framework has no model of how your URLs are built and should not: an
694
+ asset's address comes from the manifest, and the manifest's address belongs to
695
+ your server. A channel is two documents at two addresses — which of them a build
696
+ consults is your decision, and `assertCliPublishable` is told about all of them
697
+ rather than taught the shape of any.
698
+
699
+ ## One operation per line — `createCliInvoker`
700
+
701
+ The most common way an agent drives a CLI is not one command: it is a stream —
702
+ a JSON line per operation, an answer per line — and a resumable batch of the
703
+ same. The mechanics contain nothing product-specific, and until now the
704
+ framework left the one piece that cannot be written outside it: running an
705
+ already-parsed call.
706
+
707
+ ```ts
708
+ import { createCliInvoker, defineCliStreamCommand, defineCliBatchCommand } from 'stitchkit/cli'
709
+
710
+ const invoker = await createCliInvoker({ name: 'myapp', services })
711
+
712
+ const outcome = await invoker.invoke('create_item', { title: 'hello', tags: ['a'] })
713
+ // { ok: true, exitCode: 0, data: { … } } — nothing written, nothing exited
714
+ ```
715
+
716
+ `invoke` runs the same pipeline a typed command runs — the same validation, the
717
+ same `lifecycle` gate, the same hooks — and returns the handler's validated
718
+ output with **the exit code the printed path would give**, from the same table.
719
+ `data` is typed `unknown`: the surface is resolved at run time from services and
720
+ runtime tools, so there is no compile-time name to key a result type on. Narrow
721
+ it with the contract's own output schema. That table used to
722
+ live inside the function that prints, so the only way to learn a code was to
723
+ print it.
724
+
725
+ Without this, a stream loop had to re-spawn the binary per line: arguments
726
+ serialised back into `--flag value` strings, nested objects pushed through
727
+ `JSON.stringify` into one argv slot and parsed again on the other side, the
728
+ result read back out of stdout text. Three conversions of data the framework was
729
+ already holding, plus a process start measured at 0.15 s — thirty seconds for a
730
+ two-hundred-line manifest before any work begins. The ban on nesting one stream
731
+ inside another was a consequence of that child process, not a rule anyone wanted.
732
+
733
+ ### Native commands in the stream
734
+
735
+ A native command is in the invoker's surface when — and only when — it declares
736
+ `output`:
737
+
738
+ ```ts
739
+ const describe = defineCliCommand({
740
+ name: 'describe', description: 'Describe the catalogue',
741
+ input: z.object({ model: z.string() }),
742
+ output: z.object({ model: z.string(), ratios: z.array(z.string()) }),
743
+ handler: ({ input }) => ({ model: input.model, ratios: ['1:1', '16:9'] }),
744
+ })
745
+
746
+ await createCliInvoker({ name: 'myapp', services, commands: [describe] })
747
+ // invoke('describe', { model: 'flux' }) → { ok: true, exitCode: 0, data: { … } }
748
+ ```
749
+
750
+ A command that declares `output?: never` prints itself and returns nothing, so
751
+ there is no result to hand back; it answers `NOT_FOUND` and stays on the command
752
+ line, where stdout exists. Your stream command is one of these, which is why a
753
+ stream still cannot invoke itself.
754
+
755
+ On this path `present` is not called — it is stdout formatting, and there is no
756
+ stdout — while `exitCode` is applied through the same function the command line
757
+ uses, so a script branching on the code sees one answer from both. Anything the
758
+ handler writes comes back as `written` rather than interleaving with your own
759
+ output:
760
+
761
+ ```ts
762
+ const outcome = await invoker.invoke('describe', { model: 'flux' })
763
+ outcome.written // { stderr: 'warming the cache\n' } — absent when nothing was written
764
+ ```
765
+
766
+ ### Mounting the loop
767
+
768
+ ```ts
769
+ await createCli({
770
+ name: 'myapp', version, services,
771
+ commands: [
772
+ defineCliStreamCommand({ name: 'jsonl', invoker }),
773
+ defineCliBatchCommand({ name: 'batch', invoker, checkpointPath: '.myapp-batch.json' }),
774
+ ],
775
+ })
776
+ ```
777
+
778
+ They are factories, not framework-owned names. Reserving `jsonl` and `batch`
779
+ would take two names out of a namespace that belongs to the application — one
780
+ that already has a `batch` command would either fail at startup or find its own
781
+ command silently shadowed — so you mount them under whatever you call them, like
782
+ any other command of yours.
783
+
784
+ Each line is `{ id, command, args }`; each answer is the invocation result plus
785
+ that `id`. A line that is not JSON, or has no `id`, is **answered** and the
786
+ stream continues: a stream that goes quiet on one line leaves its consumer
787
+ unable to tell which request it lost. Answers go to stdout, one object per line,
788
+ and nothing else does.
789
+
790
+ ### Resuming a batch
791
+
792
+ The checkpoint records, per id, a digest of the line that produced the recorded
793
+ answer, and is written after **every** line by atomic rename — a checkpoint that
794
+ only survives a clean finish protects against exactly the case that does not
795
+ happen.
796
+
797
+ A re-run replays what already ran. A line whose content changed under the same
798
+ id is **refused**: replaying it would report success for an operation nobody
799
+ ran, and re-running it would repeat a paid call. Both answer a question nobody
800
+ asked.
801
+
802
+ What stays yours: what makes a repeat safe (an idempotency key derived from the
803
+ line id), which operations a batch may contain, and how much of it runs at once.
804
+ That is product knowledge, and the framework has no business guessing it.
805
+
806
+ ## Commands discovered from a running server
807
+
808
+ A CLI compiled from contracts carries the surface of the build it was compiled
809
+ from. One built from discovery carries the surface the server has *right now* —
810
+ which matters, because a long-lived MCP client freezes schemas at connect time
811
+ and then refuses the server's own newer fields:
812
+
813
+ ```ts
814
+ const discovered = await mountConnections([
815
+ defineMcpClientConnection({
816
+ name: 'api',
817
+ transport: { url },
818
+ token: () => key,
819
+ transports: ['CLI'], // the opt-in: this server's tools are commands
820
+ }),
821
+ ])
822
+ await createCli({ name: 'myapp', version, runtimeTools: discovered, commands: [...] })
823
+ ```
824
+
825
+ `transports` is where the opt-in belongs: a whole server becomes a set of
826
+ commands, and a connection without it still contributes nothing to the CLI —
827
+ exposure stays explicit, as it is everywhere else in the framework.
828
+
829
+ One unconvertible schema no longer takes the connection down with it. The tool
830
+ is skipped and **named** (`onSkippedTool`, or a stderr line by default), so a
831
+ surface of two hundred tools is not lost to one.
832
+
833
+ **A remote refusal keeps its code.** A failed `tools/call` used to become a
834
+ one-sentence `Error` with the result discarded, which cost three things at once:
835
+ the code (so `exitCodes` had nothing to map and every remote failure exited `1`),
836
+ the message the operator needed, and the error's own class — a plain `Error` is
837
+ an *unexpected* error to the runner, so it printed a code frame of the framework
838
+ bundle before the JSON failure and was then scrubbed to `INTERNAL_SERVER_ERROR`.
839
+ A structured `{ error, details }` body is now relayed as the contract error it
840
+ is, on every transport; anything else fails as `UPSTREAM_TOOL_ERROR` carrying
841
+ what the server did send. Not `INTERNAL_SERVER_ERROR`, because nothing of ours
842
+ broke.
843
+
844
+ **On the CLI a discovered command prints the answer, not the envelope.**
845
+ `tools/call` returns `{ content: [...], structuredContent? }`, and an agent mount
846
+ needs exactly that — the parts are what a model is shown. The CLI is different in
847
+ kind, because the handler's value is what gets printed, piped and aggregated:
848
+ handed the envelope, `--count-by status` groups the *content parts* and answers
849
+ `no record carries the field "status" — available: text, type`. So the CLI
850
+ transport unwraps, and only it: `structuredContent` when the server sent one, a
851
+ lone text part when it parses as JSON, its text when it does not. Several parts,
852
+ an image or audio pass through whole — picking one of many would be inventing an
853
+ answer.
854
+
855
+
856
+ ## Auth parity
857
+
858
+ A scoped command is guarded by the same `createAuthHook` your HTTP server uses —
859
+ pass it as `lifecycle`, and inject the identity through `context` so
860
+ `resolveFromContext` can read it:
861
+
862
+ ```ts
863
+ const authHook = createAuthHook({ /* resolve, resolveFromContext, rules */ })
864
+
865
+ await createCli({
866
+ name: 'myapp',
867
+ version: '1.0.0',
868
+ resolveAuth: () => resolveIdentityFromToken(process.env.MYAPP_TOKEN),
869
+ context: (identity) => ({ user: identity }), // resolveFromContext reads this
870
+ lifecycle: { beforeHandle: authHook }, // same policy; HTTP wires it as authorize
871
+ services,
872
+ })
873
+ ```
874
+
875
+ Without `lifecycle`, a scoped command runs **unguarded** — the scope check lives
876
+ entirely inside the `createAuthHook` result, so with no hook wired in there is
877
+ nothing to enforce a method's `scope`. This matches the MCP / agent surfaces
878
+ exactly ([ADR 0014](../decisions/0014-tool-http-parity.md)): on every tool
879
+ transport the auth gate is opt-in, so a contract with scoped methods **must** be
880
+ given a `lifecycle` (and `context` identity) to be protected. The gate only
881
+ *fails closed* once the hook **is** present but `resolveFromContext` is missing —
882
+ then a scoped call has no identity and is rejected.
883
+
884
+ ## Typed context
885
+
886
+ Use `createToolkit<AppContext>()` to type the injected `context` against your
887
+ app's context shape — the tool-side mirror of `createImplement`
888
+ ([ADR 0017](../decisions/0017-typed-tool-context.md)):
889
+
890
+ ```ts
891
+ const tools = createToolkit<{ user: User }>()
892
+ await tools.createCli({
893
+ name: 'myapp',
894
+ version: '1.0.0',
895
+ services,
896
+ context: (identity) => ({ user: identity }), // checked against { user: User }
897
+ })
898
+ ```
899
+
900
+ ## Remaining boundary
901
+
902
+ File-upload (`multipart`) contract endpoints remain CLI-invisible, the same as
903
+ on MCP/Agent: their wire body is not a JSON tool form. Model file-oriented
904
+ application behavior as a managed pathless command, or binary-only behavior as
905
+ a native command. Streaming (SSE) output is not yet piped to stdout.
906
+
907
+ ==============================================================================
908
+ # API reference: `stitchkit/cli` (docs/api/reference.md)
909
+ ==============================================================================
910
+
911
+ ## `stitchkit/cli`
912
+
913
+ Server-only. Composes contract/runtime managed operations and CLI-only native
914
+ commands into one command-line program. Light by design: needs neither the MCP
915
+ SDK nor the `ai` peer.
916
+
917
+ | Export | Kind | Summary |
918
+ |--------|------|---------|
919
+ | `createCli` | function | build and run a CLI from contracts — [guide](../guide/cli.md) |
920
+ | `defineCliCommand` | function | define one Zod-typed CLI-only executable command with optional validated-result presentation/exit policy |
921
+ | `parseCliArgs` | function | argv → typed tool args against a schema (advanced) |
922
+ | `routeCliArgv` | function | select the command out of argv without duplicating the global-option grammar (advanced) |
923
+ | `extractCliGlobalOptions` | function | lift the application's own global options out of argv before routing (advanced) |
924
+ | `coerceJsonArgs` | function | the second half of `parseCliArgs` — parse array/object values a consumer sends itself, without the `stitchkit/tools` barrel |
925
+ | `CliArgumentError` | class | the refusal `parseCliArgs` and the view flags raise; a CLI reports it and exits `2` |
926
+ | `renderCliView` | function | compute an aggregate over a result (`--count-by`, `--sum`, `--top`, `--table`) — [guide](../guide/cli.md#aggregate-views) |
927
+ | `createCliProfileStore` | function | named `0600` credential profiles resolved by name, with the never-substitute rule built in — [guide](../guide/cli.md#named-profiles) |
928
+ | `CliProfileError` | class | an `AppError` refusing a named profile that is missing, unreadable or shared between users |
929
+ | `renderCliInstaller` | function | generate the one-line installer from a build manifest, with the URL and digest substituted — [guide](../guide/cli.md#distribution-and-self-update) |
930
+ | `checkCliUpdate` | function | bounded, interval-limited, never-throwing check for a newer published build |
931
+ | `applyCliUpdate` | function | download, verify the decompressed digest and replace the binary by rename |
932
+ | `assertCliPublishable` | function | refuse republishing one version from a different commit — takes one manifest or every manifest already published, because the promise a version makes does not stop at a channel boundary |
933
+ | `rollbackCliUpdate` / `CliRollbackConfig` / `RolledBackCliUpdate` | function / _types_ | put the kept previous build back, digest-checked first and written by the same atomic rename the update uses |
934
+ | `signCliManifest` / `verifyCliManifest` / `cliManifestSigningPayload` | function | Ed25519 over `{name, version, commit, builtAt, assets[]}` — every asset's digest included, so the chain closes on the file that executes |
935
+ | `cliSignatureAccepted` / `CliSignatureVerdict` | function / _type_ | `valid` \| `unenforced` \| `missing` \| `unknown-key` \| `invalid`; `unenforced` keeps an unpinned build updating while making the absence of a check visible |
936
+ | `CliTrustRoot` / `CliSigningKey` / `CliBuildSignature` / `CliBuildSignatureSchema` | _types_ / schema | the keys a build trusts, by id, and the detached signature a manifest carries |
937
+ | `selectCliBuildAsset` | function | the asset for one target, or `undefined` |
938
+ | `currentCliBuildTarget` | function | `{ platform, arch }` of the running process |
939
+ | `formatCliBuildStamp` | function | one line saying what the running build is |
940
+ | `compareCliVersions` | function | compare two versions, or `undefined` when they are not comparable |
941
+ | `CliBuildManifestSchema` / `CliBuildManifest` | schema / _type_ | name, version, commit, build time and assets |
942
+ | `CliBuildAssetSchema` / `CliBuildAsset` | schema / _type_ | one download; `size` and `sha256` describe the **decompressed** bytes |
943
+ | `CliBuildTargetSchema` / `CliBuildTarget` | schema / _type_ | `{ platform, arch }` |
944
+ | `CliBuildStampSchema` / `CliBuildStamp` | schema / _type_ | the version/commit/build time carried inside a binary |
945
+ | `CliInstallerConfig` | _type_ | manifest, binary name, default install directory, and an optional `asset` — omit it for one script that selects the target by `uname` |
946
+ | `CliUpdateCheckConfig` / `CliUpdateCheck` | _type_ | check inputs, and its four answers — `skipped`, `current`, `outdated`, `unknown` |
947
+ | `CliUpdateApplyConfig` / `AppliedCliUpdate` | _type_ | apply inputs and the replaced path, byte count and digest |
948
+ | `CliProfileStore` / `CliProfileStoreConfig` / `ResolvedCliProfile` | _type_ | the profile store, its directory/schema/hint config, and one resolution |
949
+ | `CliResultView` | _type_ | the requested view — `count`, `sum`, or `records` (ordered and/or table-rendered) |
950
+ | `CliViewOutput` | _type_ | a JSON value, or the one human-facing text shape |
951
+ | `CliGlobalOptionsParse` | _type_ | `{ argv, globals }` returned by `extractCliGlobalOptions` |
952
+ | `CliArgvRoute` | _type_ | `{ command, commandArgv, topLevelHelp, version, error? }` returned by `routeCliArgv` |
953
+ | `pollUntilDone` | function | the generic `--wait` poller (advanced) |
954
+ | `emitResult` | function | write a pretty or compact `ToolResult` record to stdout/stderr + exit code (advanced) |
955
+ | `cliExitCode` | function | the exit code a result earns, from the same table, without writing anything — so an in-process run and the printed path cannot disagree |
956
+ | `createCliInvoker` / `CliInvoker` / `CliInvokerConfig` / `CliInvocationResult` / `CliInvokerCommand` / `cliInvocationResult` | function / _types_ | compile the managed surface once and run parsed calls against it in process — no argv round-trip, no child process, no writing |
957
+ | `defineCliStreamCommand` / `CliStreamCommandConfig` / `CliStreamAnswer` / `CliStreamHooks` / `runCliStream` | function / _types_ | one operation per JSON line of stdin, answered with the same `id`; a bad line answers and the stream continues |
958
+ | `defineCliBatchCommand` / `CliBatchCommandConfig` | function / _type_ | the same loop, resumable: a recorded line replays, a line whose content changed under the same id is refused |
959
+ | `readCliCheckpoint` / `writeCliCheckpoint` / `CliCheckpoint` / `CliCheckpointEntry` | function / _types_ | the batch's record — id plus a digest of the line, written by atomic rename after every line |
960
+ | `DEFAULT_EXIT_CODES` | const | the default `ToolResult.code` → exit-code map |
961
+ | `CliConfig` | _type_ | config for `createCli`; `defaultCommand`, `globalOptions`, `optionAliases` and `positionals` define the shared command presentation policy |
962
+ | `CliPresentationPolicyConfig` | _type_ | shared command presentation-policy subset of `CliConfig` |
963
+ | `CliSurfaceSource` | _type_ | static service/runtime array or identity-dependent factory |
964
+ | `CliCommandDefinition` | _type_ | native command definition union |
965
+ | `CliCommandDefinitionBase` | _type_ | native command name, description and input schema |
966
+ | `CliCommandDefinitionWithOutput` | _type_ | native command with validated declared output and typed optional `present` / successful `exitCode` callbacks |
967
+ | `CliCommandDefinitionWithoutOutput` | _type_ | native void command without an output contract |
968
+ | `CliCommandContext` | _type_ | parsed input, framework run options, the application's `globals` and stdout/stderr writers |
969
+ | `CliRunOptions` | _type_ | parsed global flags (`--json` compacts success/error records, `--wait`, …) |
970
+ | `ParsedCliArgs` | _type_ | result of `parseCliArgs` |
971
+ | `CliWaitConfig` | _type_ | per-command `--wait` polling config; optional `failed(result)` maps a terminal domain failure to `WAIT_FAILED` and a non-zero exit |
972
+ | `ExitCodeMap` | _type_ | `ToolResult.code` → process exit code |
973
+ | `PollParams` | _type_ | params for `pollUntilDone` |
974
+ | `CliWriters` | _type_ | stdout/stderr sinks for `emitResult` |
975
+ | `EmitOptions` | _type_ | options for `emitResult` |
976
+
977
+ ---