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
@@ -3,39 +3,149 @@ import {
3
3
  } from "./index-sbdmyz75.js";
4
4
  import {
5
5
  collectToolSurface
6
- } from "./index-2c2bjw3s.js";
6
+ } from "./index-vcvkq30w.js";
7
7
  import {
8
8
  createToolRunner,
9
9
  formatToolError
10
- } from "./index-mzvgxp0n.js";
10
+ } from "./index-2cr1cqhn.js";
11
11
  import {
12
12
  toolErrorFromResult,
13
13
  toolResultFromError
14
- } from "./index-yn8remb1.js";
15
- import {
16
- formatZodError,
17
- validateDeclaredOutput
18
- } from "./index-e0znv5gn.js";
14
+ } from "./index-j05z5gn4.js";
19
15
  import {
20
16
  coerceJsonArgs
21
- } from "./index-7zbps32p.js";
17
+ } from "./index-1zbbzgfh.js";
22
18
  import {
23
19
  assertUniqueToolName,
24
20
  buildToolPresentationSchema,
25
21
  objectShapeKeys
26
- } from "./index-h9etkkyk.js";
22
+ } from "./index-dydjcp8z.js";
27
23
  import {
28
24
  jsonSchemaFields
29
- } from "./index-cby4ar3v.js";
25
+ } from "./index-eqqvgdb3.js";
26
+ import {
27
+ validateDeclaredOutput
28
+ } from "./index-znfs20ss.js";
29
+ import {
30
+ formatZodError
31
+ } from "./index-p5r7qpdd.js";
30
32
  import {
31
33
  isUnsafeKey,
32
34
  safeJsonParse
33
35
  } from "./index-kzfs85xp.js";
34
36
  import {
35
37
  isRecord
36
- } from "./index-77fekveh.js";
38
+ } from "./index-hffjpmq9.js";
39
+
40
+ // src/tools/cli/command.ts
41
+ function defineCliCommand(definition) {
42
+ return definition;
43
+ }
44
+ function cliCommandReturnsResult(definition) {
45
+ return definition.output !== undefined;
46
+ }
47
+ function cliCommandSuccessExitCode(definition, data) {
48
+ const successExitCode = definition.exitCode?.(data) ?? 0;
49
+ if (!Number.isSafeInteger(successExitCode) || successExitCode < 0 || successExitCode > 255) {
50
+ throw new Error("CLI success exit code must be an integer from 0 to 255");
51
+ }
52
+ return successExitCode;
53
+ }
54
+ function prepareCliCommandEmission(definition, result, options) {
55
+ if (!result.ok || definition.output === undefined) {
56
+ return { result, successExitCode: 0 };
57
+ }
58
+ try {
59
+ const successExitCode = cliCommandSuccessExitCode(definition, result.data);
60
+ const presentation = definition.present?.({ result: result.data, options });
61
+ if (presentation !== undefined && typeof presentation !== "string") {
62
+ throw new Error("CLI result presenter must return a string");
63
+ }
64
+ return { result, presentation, successExitCode };
65
+ } catch (error) {
66
+ return {
67
+ result: toolResultFromError(new Error("CLI result policy failed", { cause: error })),
68
+ successExitCode: 0
69
+ };
70
+ }
71
+ }
72
+ function cliCommandPresentationSchema(definition) {
73
+ return buildToolPresentationSchema({
74
+ inputSchema: definition.input,
75
+ unrepresentable: "any"
76
+ });
77
+ }
78
+ async function executeCliCommand(definition, rawArgs, options, writers, coerceJson, globals = {}) {
79
+ let parsed;
80
+ try {
81
+ parsed = definition.input.safeParse(coerceJson ? coerceJsonArgs(rawArgs, definition.input) : rawArgs);
82
+ } catch (error) {
83
+ return toolResultFromError(error);
84
+ }
85
+ if (!parsed.success) {
86
+ return {
87
+ ok: false,
88
+ code: "VALIDATION_ERROR",
89
+ details: { message: `Invalid input: ${formatZodError(parsed.error)}` }
90
+ };
91
+ }
92
+ try {
93
+ const data = await definition.handler({
94
+ input: parsed.data,
95
+ options,
96
+ globals,
97
+ ...writers
98
+ });
99
+ const checked = validateDeclaredOutput(definition.output, data);
100
+ if (!checked.ok) {
101
+ return {
102
+ ok: false,
103
+ code: "INTERNAL_SERVER_ERROR",
104
+ details: { message: checked.message }
105
+ };
106
+ }
107
+ return { ok: true, data: checked.data };
108
+ } catch (error) {
109
+ return toolResultFromError(error);
110
+ }
111
+ }
112
+
113
+ // src/tools/cli/format.ts
114
+ var DEFAULT_EXIT_CODES = {
115
+ VALIDATION_ERROR: 1,
116
+ BAD_REQUEST: 1,
117
+ UNAUTHORIZED: 2,
118
+ FORBIDDEN: 3,
119
+ NOT_FOUND: 4,
120
+ CONFLICT: 5,
121
+ RATE_LIMITED: 6,
122
+ TIMEOUT: 7,
123
+ WAIT_FAILED: 1,
124
+ INTERNAL_SERVER_ERROR: 1
125
+ };
126
+ function cliExitCode(result, exitCodes) {
127
+ if (result.ok)
128
+ return 0;
129
+ const codes = { ...DEFAULT_EXIT_CODES, ...exitCodes };
130
+ return Object.hasOwn(codes, result.code) ? codes[result.code] ?? 1 : 1;
131
+ }
132
+ function emitResult(result, writers, opts) {
133
+ if (result.ok) {
134
+ if (result.data === undefined)
135
+ return 0;
136
+ const text2 = opts.json ? JSON.stringify(result.data) : JSON.stringify(result.data, null, 2);
137
+ writers.stdout(`${text2}
138
+ `);
139
+ return 0;
140
+ }
141
+ const error = formatToolError(result, opts.toolName, opts.errorHint);
142
+ const text = opts.json ? JSON.stringify(error) : JSON.stringify(error, null, 2);
143
+ writers.stderr(`${text}
144
+ `);
145
+ return cliExitCode(result, opts.exitCodes);
146
+ }
37
147
 
38
- // src/tools/cli-args.ts
148
+ // src/tools/cli/args.ts
39
149
  import { z } from "zod";
40
150
  var NUMERIC_VALUE = /^-(\d+\.?\d*|\.\d+)$/;
41
151
  var BOOL_OPTIONS = new Set(["json", "wait", "quiet", "dry-run", "help", "ascending"]);
@@ -665,108 +775,7 @@ function resolveCliView(flags, ascending) {
665
775
  throw new CliArgumentError("--top needs --sort, --by, --count-by or --sum to rank");
666
776
  }
667
777
 
668
- // src/tools/cli-command.ts
669
- function defineCliCommand(definition) {
670
- return definition;
671
- }
672
- function prepareCliCommandEmission(definition, result, options) {
673
- if (!result.ok || definition.output === undefined) {
674
- return { result, successExitCode: 0 };
675
- }
676
- try {
677
- const successExitCode = definition.exitCode?.(result.data) ?? 0;
678
- if (!Number.isSafeInteger(successExitCode) || successExitCode < 0 || successExitCode > 255) {
679
- throw new Error("CLI success exit code must be an integer from 0 to 255");
680
- }
681
- const presentation = definition.present?.({ result: result.data, options });
682
- if (presentation !== undefined && typeof presentation !== "string") {
683
- throw new Error("CLI result presenter must return a string");
684
- }
685
- return { result, presentation, successExitCode };
686
- } catch (error) {
687
- return {
688
- result: toolResultFromError(new Error("CLI result policy failed", { cause: error })),
689
- successExitCode: 0
690
- };
691
- }
692
- }
693
- function cliCommandPresentationSchema(definition) {
694
- return buildToolPresentationSchema({
695
- inputSchema: definition.input,
696
- unrepresentable: "any"
697
- });
698
- }
699
- async function executeCliCommand(definition, rawArgs, options, writers, coerceJson, globals = {}) {
700
- let parsed;
701
- try {
702
- parsed = definition.input.safeParse(coerceJson ? coerceJsonArgs(rawArgs, definition.input) : rawArgs);
703
- } catch (error) {
704
- return toolResultFromError(error);
705
- }
706
- if (!parsed.success) {
707
- return {
708
- ok: false,
709
- code: "VALIDATION_ERROR",
710
- details: { message: `Invalid input: ${formatZodError(parsed.error)}` }
711
- };
712
- }
713
- try {
714
- const data = await definition.handler({
715
- input: parsed.data,
716
- options,
717
- globals,
718
- ...writers
719
- });
720
- const checked = validateDeclaredOutput(definition.output, data);
721
- if (!checked.ok) {
722
- return {
723
- ok: false,
724
- code: "INTERNAL_SERVER_ERROR",
725
- details: { message: checked.message }
726
- };
727
- }
728
- return { ok: true, data: checked.data };
729
- } catch (error) {
730
- return toolResultFromError(error);
731
- }
732
- }
733
-
734
- // src/tools/cli-format.ts
735
- var DEFAULT_EXIT_CODES = {
736
- VALIDATION_ERROR: 1,
737
- BAD_REQUEST: 1,
738
- UNAUTHORIZED: 2,
739
- FORBIDDEN: 3,
740
- NOT_FOUND: 4,
741
- CONFLICT: 5,
742
- RATE_LIMITED: 6,
743
- TIMEOUT: 7,
744
- WAIT_FAILED: 1,
745
- INTERNAL_SERVER_ERROR: 1
746
- };
747
- function cliExitCode(result, exitCodes) {
748
- if (result.ok)
749
- return 0;
750
- const codes = { ...DEFAULT_EXIT_CODES, ...exitCodes };
751
- return Object.hasOwn(codes, result.code) ? codes[result.code] ?? 1 : 1;
752
- }
753
- function emitResult(result, writers, opts) {
754
- if (result.ok) {
755
- if (result.data === undefined)
756
- return 0;
757
- const text2 = opts.json ? JSON.stringify(result.data) : JSON.stringify(result.data, null, 2);
758
- writers.stdout(`${text2}
759
- `);
760
- return 0;
761
- }
762
- const error = formatToolError(result, opts.toolName, opts.errorHint);
763
- const text = opts.json ? JSON.stringify(error) : JSON.stringify(error, null, 2);
764
- writers.stderr(`${text}
765
- `);
766
- return cliExitCode(result, opts.exitCodes);
767
- }
768
-
769
- // src/tools/cli-policy.ts
778
+ // src/tools/cli/policy.ts
770
779
  var SHORT_ALIAS = /^[A-Za-z]$/;
771
780
  var RESERVED_SHORT_OPTIONS = new Set(["h"]);
772
781
  function fieldMap(descriptor) {
@@ -846,7 +855,7 @@ function assertCliPoliciesResolved(commands, config) {
846
855
  }
847
856
  }
848
857
 
849
- // src/tools/cli-invoke.ts
858
+ // src/tools/cli/invoke.ts
850
859
  function parseCliGlobals(schema, globals) {
851
860
  if (!schema)
852
861
  return globals ?? {};
@@ -877,21 +886,29 @@ function cliInvocationResult(result, toolName, config) {
877
886
  async function createCliInvoker(config, globals) {
878
887
  const typedGlobals = parseCliGlobals(config.globalOptions, globals);
879
888
  const auth = await (config.resolveAuth ? config.resolveAuth(typedGlobals) : config.auth);
889
+ const natives = new Map((config.commands ?? []).filter(cliCommandReturnsResult).map((definition) => [definition.name, definition]));
890
+ const nativeHelp = new Map([...natives].map(([name, definition]) => [
891
+ name,
892
+ { description: definition.description, argumentSchema: {}, presentationSchema: {} }
893
+ ]));
880
894
  const { tools, help } = buildCliSurface(config, auth, new Map, new Set);
881
895
  const runTool = createToolRunner({
882
896
  source: "cli",
897
+ toolSurface: true,
883
898
  context: { ...config.context?.(auth, typedGlobals), signal: config.signal },
884
899
  hooks: config.hooks,
885
900
  lifecycle: config.lifecycle,
886
- errorHint: config.errorHint,
887
901
  coerceJsonArgs: config.coerceJsonArgs
888
902
  });
889
903
  return {
890
- commands: [...help].map(([name, presentation]) => ({
904
+ commands: [...nativeHelp, ...help].map(([name, presentation]) => ({
891
905
  name,
892
906
  description: presentation.description
893
907
  })),
894
908
  invoke: async (command, args) => {
909
+ const native = natives.get(command);
910
+ if (native)
911
+ return runNativeCommand(native, args, config, typedGlobals);
895
912
  const tool = tools.get(command);
896
913
  if (!tool) {
897
914
  return cliInvocationResult({
@@ -910,6 +927,42 @@ async function createCliInvoker(config, globals) {
910
927
  }
911
928
  };
912
929
  }
930
+ var IN_PROCESS_RUN_OPTIONS = Object.freeze({
931
+ json: false,
932
+ wait: false,
933
+ quiet: true,
934
+ dryRun: false,
935
+ help: false
936
+ });
937
+ async function runNativeCommand(definition, args, config, globals) {
938
+ let out = "";
939
+ let err = "";
940
+ const result = await executeCliCommand(definition, args, IN_PROCESS_RUN_OPTIONS, {
941
+ stdout: (text) => {
942
+ out += text;
943
+ },
944
+ stderr: (text) => {
945
+ err += text;
946
+ }
947
+ }, config.coerceJsonArgs ?? true, globals);
948
+ let invocation = cliInvocationResult(result, definition.name, config);
949
+ if (invocation.ok) {
950
+ try {
951
+ invocation = {
952
+ ...invocation,
953
+ exitCode: cliCommandSuccessExitCode(definition, result.ok ? result.data : undefined)
954
+ };
955
+ } catch (error) {
956
+ invocation = cliInvocationResult(toolResultFromError(error), definition.name, config);
957
+ }
958
+ }
959
+ if (out === "" && err === "")
960
+ return invocation;
961
+ return {
962
+ ...invocation,
963
+ written: { ...out !== "" && { stdout: out }, ...err !== "" && { stderr: err } }
964
+ };
965
+ }
913
966
  function buildCliSurface(config, auth, nativeHelp, applicationGlobalNames, assertShape) {
914
967
  const services = typeof config.services === "function" ? config.services(auth) : config.services ?? [];
915
968
  const runtimeTools = typeof config.runtimeTools === "function" ? config.runtimeTools(auth) : config.runtimeTools ?? [];
@@ -935,7 +988,7 @@ function managedCliDescriptor(tool) {
935
988
  };
936
989
  }
937
990
 
938
- // src/tools/cli-view.ts
991
+ // src/tools/cli/view.ts
939
992
  var ABSENT = "(absent)";
940
993
  function selectRecords(data) {
941
994
  if (Array.isArray(data))
@@ -1082,7 +1135,7 @@ function renderCliView(data, view) {
1082
1135
  return { kind: "json", data: ordered(totals, view.top) };
1083
1136
  }
1084
1137
 
1085
- // src/tools/wait-core.ts
1138
+ // src/tools/operations/wait-core.ts
1086
1139
  var DEFAULT_BACKOFF = [2, 3, 5, 5, 8, 10];
1087
1140
  var DEFAULT_TIMEOUT = 600;
1088
1141
 
@@ -1178,7 +1231,7 @@ function runWaitOperation(params) {
1178
1231
  });
1179
1232
  }
1180
1233
 
1181
- // src/tools/cli-wait.ts
1234
+ // src/tools/cli/wait.ts
1182
1235
  var DEFAULT_TIMEOUT2 = 600;
1183
1236
  function waitFailure(tool, result) {
1184
1237
  return {
@@ -1232,8 +1285,58 @@ async function pollUntilDone(params) {
1232
1285
  return state;
1233
1286
  }
1234
1287
 
1235
- // src/tools/cli.ts
1288
+ // src/tools/cli/io.ts
1236
1289
  import { writeSync } from "node:fs";
1290
+ async function readPipedStdin() {
1291
+ if (process.stdin.isTTY)
1292
+ return null;
1293
+ const chunks = [];
1294
+ for await (const chunk of process.stdin) {
1295
+ chunks.push(typeof chunk === "string" ? Buffer.from(chunk) : chunk);
1296
+ }
1297
+ const text = Buffer.concat(chunks).toString("utf8").trim();
1298
+ return text.length > 0 ? text : null;
1299
+ }
1300
+ function createCliIo(config) {
1301
+ let pendingWrite;
1302
+ let writeFailed = false;
1303
+ const writeFd = (fd, text) => {
1304
+ const bytes = Buffer.from(text, "utf8");
1305
+ let offset = 0;
1306
+ while (offset < bytes.length) {
1307
+ try {
1308
+ offset += writeSync(fd, bytes, offset, bytes.length - offset);
1309
+ } catch (error) {
1310
+ if (isRecord(error) && error.code === "EAGAIN") {
1311
+ Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, 1);
1312
+ continue;
1313
+ }
1314
+ const stream = fd === 1 ? process.stdout : process.stderr;
1315
+ const rest = bytes.subarray(offset);
1316
+ pendingWrite = new Promise((resolve) => {
1317
+ stream.write(rest, (failure) => {
1318
+ if (failure)
1319
+ writeFailed = true;
1320
+ resolve();
1321
+ });
1322
+ });
1323
+ return;
1324
+ }
1325
+ }
1326
+ };
1327
+ const stdout = config.stdout ?? ((text) => writeFd(1, text));
1328
+ const stderr = config.stderr ?? ((text) => writeFd(2, text));
1329
+ const exit = config.exit ?? ((code) => {
1330
+ if (pendingWrite === undefined)
1331
+ process.exit(code);
1332
+ else
1333
+ pendingWrite.then(() => process.exit(writeFailed ? 1 : code));
1334
+ });
1335
+ const readStdin = config.stdin ?? readPipedStdin;
1336
+ return { stdout, stderr, exit, readStdin };
1337
+ }
1338
+
1339
+ // src/tools/cli/download.ts
1237
1340
  import { basename, resolve } from "node:path";
1238
1341
 
1239
1342
  // src/internal/secure-fetch.ts
@@ -1398,6 +1501,10 @@ async function fetchGuarded(start, allowPrivate, options = {}) {
1398
1501
  clearTimeout(headerTimer);
1399
1502
  }
1400
1503
  }
1504
+
1505
+ class PrivateAddressRefusal extends Error {
1506
+ name = "PrivateAddressRefusal";
1507
+ }
1401
1508
  async function resolvePublicAddress(url, signal) {
1402
1509
  assertHttpUrl(url);
1403
1510
  const host = url.hostname.replace(/^\[|\]$/g, "");
@@ -1406,20 +1513,20 @@ async function resolvePublicAddress(url, signal) {
1406
1513
  const ipFamily = isIP(host);
1407
1514
  if (ipFamily) {
1408
1515
  if (isPrivateIp(host))
1409
- throw new Error("refusing to fetch a private address");
1516
+ throw new PrivateAddressRefusal("refusing to fetch a private address");
1410
1517
  return { address: host, family: ipFamily === 6 ? 6 : 4 };
1411
1518
  }
1412
1519
  if (NUMERIC_HOST.test(host)) {
1413
- throw new Error("refusing to fetch a non-canonical numeric host");
1520
+ throw new PrivateAddressRefusal("refusing to fetch a non-canonical numeric host");
1414
1521
  }
1415
1522
  if (host === "localhost" || host.endsWith(".local") || host.endsWith(".internal")) {
1416
- throw new Error("refusing to fetch an internal host");
1523
+ throw new PrivateAddressRefusal("refusing to fetch an internal host");
1417
1524
  }
1418
1525
  const pending = lookup(host, { all: true });
1419
1526
  const records = signal ? await raceWithAbort(pending, signal) : await pending;
1420
1527
  for (const record2 of records) {
1421
1528
  if (isPrivateIp(record2.address)) {
1422
- throw new Error("refusing to fetch a host that resolves to a private address");
1529
+ throw new PrivateAddressRefusal("refusing to fetch a host that resolves to a private address");
1423
1530
  }
1424
1531
  }
1425
1532
  const record = records[0];
@@ -1542,7 +1649,34 @@ async function writeDownload(root, target, data) {
1542
1649
  await writeFile(target, data);
1543
1650
  }
1544
1651
 
1545
- // src/tools/cli.ts
1652
+ // src/tools/cli/download.ts
1653
+ var DEFAULT_DOWNLOAD_MAX_BYTES = 100 * 1024 * 1024;
1654
+ async function downloadResults(files, dir, stderr, quiet, allowPrivate, maxBytes, timeoutMs) {
1655
+ const root = resolve(dir);
1656
+ let succeeded = true;
1657
+ for (const file of files) {
1658
+ try {
1659
+ const res = await fetchGuarded(new URL(file.url), allowPrivate, { timeoutMs });
1660
+ if (!res.ok)
1661
+ throw new Error(`HTTP ${res.status}`);
1662
+ const buffer = await readCapped(res, maxBytes);
1663
+ if (!buffer)
1664
+ throw new Error(`file exceeds the ${maxBytes}-byte cap`);
1665
+ const target = resolve(root, basename(file.name));
1666
+ await writeDownload(root, target, buffer);
1667
+ if (!quiet)
1668
+ stderr(`saved ${target} (${(buffer.length / 1024).toFixed(0)}KB)
1669
+ `);
1670
+ } catch (err) {
1671
+ succeeded = false;
1672
+ stderr(`failed to download ${file.url}: ${err instanceof Error ? err.message : String(err)}
1673
+ `);
1674
+ }
1675
+ }
1676
+ return succeeded;
1677
+ }
1678
+
1679
+ // src/tools/cli/help.ts
1546
1680
  var GLOBAL_OPTIONS = [
1547
1681
  ["--json", "Emit compact success/error JSON records (for scripts)"],
1548
1682
  ["--wait", "Block-poll an async result to a terminal state"],
@@ -1559,16 +1693,6 @@ var GLOBAL_OPTIONS = [
1559
1693
  ["--top <n>", "Keep the n leading entries of the view asked for"],
1560
1694
  ["--table <a,b>", "Render the named fields as an aligned table"]
1561
1695
  ];
1562
- async function readPipedStdin() {
1563
- if (process.stdin.isTTY)
1564
- return null;
1565
- const chunks = [];
1566
- for await (const chunk of process.stdin) {
1567
- chunks.push(typeof chunk === "string" ? Buffer.from(chunk) : chunk);
1568
- }
1569
- const text = Buffer.concat(chunks).toString("utf8").trim();
1570
- return text.length > 0 ? text : null;
1571
- }
1572
1696
  function typeLabel(schema) {
1573
1697
  if (Array.isArray(schema.enum))
1574
1698
  return schema.enum.join("|");
@@ -1588,44 +1712,6 @@ function summarize(desc) {
1588
1712
  const max = 72;
1589
1713
  return firstSentence.length > max ? `${firstSentence.slice(0, max - 1).trimEnd()}…` : firstSentence;
1590
1714
  }
1591
- function looseCoerceValue(value) {
1592
- if (Array.isArray(value))
1593
- return value.map(looseCoerceValue);
1594
- if (typeof value !== "string")
1595
- return value;
1596
- if (value === "true")
1597
- return true;
1598
- if (value === "false")
1599
- return false;
1600
- const n = Number(value);
1601
- return value.trim() !== "" && !Number.isNaN(n) ? n : value;
1602
- }
1603
- function passthroughBase(value) {
1604
- if (isRecord(value))
1605
- return value;
1606
- if (typeof value === "string") {
1607
- try {
1608
- const parsed = safeJsonParse(value);
1609
- if (isRecord(parsed))
1610
- return parsed;
1611
- } catch {}
1612
- }
1613
- return;
1614
- }
1615
- function collectPassthrough(toolArgs, field, knownKeys) {
1616
- const known = new Set(knownKeys);
1617
- const bag = {};
1618
- for (const key of Object.keys(toolArgs)) {
1619
- if (key === field || known.has(key))
1620
- continue;
1621
- bag[key] = looseCoerceValue(toolArgs[key]);
1622
- delete toolArgs[key];
1623
- }
1624
- if (Object.keys(bag).length === 0)
1625
- return;
1626
- const base = passthroughBase(toolArgs[field]);
1627
- toolArgs[field] = base ? { ...base, ...bag } : bag;
1628
- }
1629
1715
  function applicationOptionLines(fields) {
1630
1716
  if (fields.length === 0)
1631
1717
  return [];
@@ -1720,6 +1806,8 @@ function renderCommandHelp(name, command, descriptor, applicationOptions = []) {
1720
1806
  `)}
1721
1807
  `;
1722
1808
  }
1809
+
1810
+ // src/tools/cli/session.ts
1723
1811
  function nativeDescriptor(definition) {
1724
1812
  return {
1725
1813
  description: definition.description,
@@ -1745,101 +1833,7 @@ function assertCommandShape(name, descriptor, exists, passthroughField, applicat
1745
1833
  throw new Error(`[stitchkit] CLI command "${name}" cannot alias passthrough field "${passthroughField}"`);
1746
1834
  }
1747
1835
  }
1748
- async function prepareInvocation(command, commandArgv, descriptor, config, readStdin) {
1749
- let parsed;
1750
- try {
1751
- parsed = parseCliArgs(commandArgv, descriptor.argumentSchema, {
1752
- allowUnknown: config.passthrough?.[command] !== undefined,
1753
- knownFields: jsonSchemaFields(descriptor.presentationSchema).map((field) => field.name),
1754
- optionAliases: new Map([...descriptor.aliases].map(([field, alias]) => [alias, field])),
1755
- positionals: descriptor.positionals
1756
- });
1757
- } catch (error) {
1758
- if (!(error instanceof CliArgumentError))
1759
- throw error;
1760
- return { ok: false, message: error.message };
1761
- }
1762
- const { toolArgs, options } = parsed;
1763
- const firstUnset = jsonSchemaFields(descriptor.presentationSchema).find((field) => field.required && !(field.name in toolArgs) && field.schema.type !== "boolean");
1764
- if (firstUnset) {
1765
- const piped = await readStdin();
1766
- if (piped !== null) {
1767
- if (descriptor.positionals === undefined) {
1768
- toolArgs[firstUnset.name] = piped;
1769
- } else {
1770
- const stdinArgs = parseCliArgs([`--${firstUnset.name}`, piped], descriptor.argumentSchema);
1771
- toolArgs[firstUnset.name] = stdinArgs.toolArgs[firstUnset.name];
1772
- }
1773
- }
1774
- }
1775
- const passthroughField = config.passthrough?.[command];
1776
- if (passthroughField) {
1777
- collectPassthrough(toolArgs, passthroughField, objectShapeKeys(descriptor.argumentSchema));
1778
- }
1779
- return { ok: true, toolArgs, options };
1780
- }
1781
- var DEFAULT_DOWNLOAD_MAX_BYTES = 100 * 1024 * 1024;
1782
- async function downloadResults(files, dir, stderr, quiet, allowPrivate, maxBytes, timeoutMs) {
1783
- const root = resolve(dir);
1784
- let succeeded = true;
1785
- for (const file of files) {
1786
- try {
1787
- const res = await fetchGuarded(new URL(file.url), allowPrivate, { timeoutMs });
1788
- if (!res.ok)
1789
- throw new Error(`HTTP ${res.status}`);
1790
- const buffer = await readCapped(res, maxBytes);
1791
- if (!buffer)
1792
- throw new Error(`file exceeds the ${maxBytes}-byte cap`);
1793
- const target = resolve(root, basename(file.name));
1794
- await writeDownload(root, target, buffer);
1795
- if (!quiet)
1796
- stderr(`saved ${target} (${(buffer.length / 1024).toFixed(0)}KB)
1797
- `);
1798
- } catch (err) {
1799
- succeeded = false;
1800
- stderr(`failed to download ${file.url}: ${err instanceof Error ? err.message : String(err)}
1801
- `);
1802
- }
1803
- }
1804
- return succeeded;
1805
- }
1806
- async function createCli(config) {
1807
- let pendingWrite;
1808
- let writeFailed = false;
1809
- const writeFd = (fd, text) => {
1810
- const bytes = Buffer.from(text, "utf8");
1811
- let offset = 0;
1812
- while (offset < bytes.length) {
1813
- try {
1814
- offset += writeSync(fd, bytes, offset, bytes.length - offset);
1815
- } catch (error) {
1816
- if (isRecord(error) && error.code === "EAGAIN") {
1817
- Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, 1);
1818
- continue;
1819
- }
1820
- const stream = fd === 1 ? process.stdout : process.stderr;
1821
- const rest = bytes.subarray(offset);
1822
- pendingWrite = new Promise((resolve2) => {
1823
- stream.write(rest, (failure) => {
1824
- if (failure)
1825
- writeFailed = true;
1826
- resolve2();
1827
- });
1828
- });
1829
- return;
1830
- }
1831
- }
1832
- };
1833
- const stdout = config.stdout ?? ((text) => writeFd(1, text));
1834
- const stderr = config.stderr ?? ((text) => writeFd(2, text));
1835
- const exit = config.exit ?? ((code) => {
1836
- if (pendingWrite === undefined)
1837
- process.exit(code);
1838
- else
1839
- pendingWrite.then(() => process.exit(writeFailed ? 1 : code));
1840
- });
1841
- const argv = config.argv ?? process.argv.slice(2);
1842
- const readStdin = config.stdin ?? readPipedStdin;
1836
+ function createCliSession(config, io) {
1843
1837
  if (config.auth !== undefined && config.resolveAuth !== undefined) {
1844
1838
  throw new Error("[stitchkit] createCli: use either auth or resolveAuth, not both");
1845
1839
  }
@@ -1856,11 +1850,23 @@ async function createCli(config) {
1856
1850
  const nativeCommands = new Map;
1857
1851
  const nativeHelp = new Map;
1858
1852
  for (const definition of config.commands ?? []) {
1859
- const descriptor2 = applyCliPresentationPolicy(definition.name, nativeDescriptor(definition), config);
1860
- assertCommandShape(definition.name, descriptor2, nativeCommands.has(definition.name), config.passthrough?.[definition.name], applicationGlobalNames);
1853
+ const descriptor = applyCliPresentationPolicy(definition.name, nativeDescriptor(definition), config);
1854
+ assertCommandShape(definition.name, descriptor, nativeCommands.has(definition.name), config.passthrough?.[definition.name], applicationGlobalNames);
1861
1855
  nativeCommands.set(definition.name, definition);
1862
- nativeHelp.set(definition.name, descriptor2);
1856
+ nativeHelp.set(definition.name, descriptor);
1863
1857
  }
1858
+ return {
1859
+ config,
1860
+ io,
1861
+ applicationOptions,
1862
+ applicationGlobalNames,
1863
+ nativeCommands,
1864
+ nativeHelp
1865
+ };
1866
+ }
1867
+ function resolveCliRoute(session, argv) {
1868
+ const { config } = session;
1869
+ const { stdout, stderr, exit } = session.io;
1864
1870
  let globals;
1865
1871
  let routableArgv;
1866
1872
  try {
@@ -1872,135 +1878,188 @@ async function createCli(config) {
1872
1878
  throw error;
1873
1879
  stderr(`${error.message}
1874
1880
  `);
1875
- return exit(2);
1881
+ exit(2);
1882
+ return;
1876
1883
  }
1877
1884
  const typedGlobals = globals;
1878
1885
  const route = routeCliArgv(routableArgv, config.defaultCommand);
1879
1886
  if (route.error) {
1880
1887
  stderr(`${route.error}
1881
1888
  `);
1882
- return exit(2);
1889
+ exit(2);
1890
+ return;
1883
1891
  }
1884
1892
  const { command, commandArgv } = route;
1885
1893
  if (route.version || command === "--version" || command === "version") {
1886
1894
  stdout(`${config.name} ${config.version}
1887
1895
  `);
1888
- return exit(0);
1896
+ exit(0);
1897
+ return;
1889
1898
  }
1890
1899
  const beforeSeparator = commandArgv.indexOf("--") === -1 ? commandArgv : commandArgv.slice(0, commandArgv.indexOf("--"));
1891
1900
  const helpRequested = beforeSeparator.includes("--help") || beforeSeparator.includes("-h");
1892
- const native = command === undefined ? undefined : nativeCommands.get(command);
1893
- if (native && command !== undefined) {
1894
- const descriptor2 = nativeHelp.get(command);
1895
- if (!descriptor2)
1896
- throw new Error("[stitchkit] native CLI descriptor invariant failed");
1897
- if (helpRequested) {
1898
- stdout(renderCommandHelp(config.name, command, descriptor2, applicationOptions));
1899
- return exit(0);
1900
- }
1901
- const prepared2 = await prepareInvocation(command, commandArgv, descriptor2, config, readStdin);
1902
- if (!prepared2.ok) {
1903
- stderr(`${prepared2.message}
1904
- `);
1905
- return exit(2);
1906
- }
1907
- const { toolArgs: toolArgs2, options: options2 } = prepared2;
1908
- if (options2.help) {
1909
- stdout(renderCommandHelp(config.name, command, descriptor2, applicationOptions));
1910
- return exit(0);
1911
- }
1912
- if (options2.wait) {
1913
- stderr(`--wait is not configured for native command "${command}"
1914
- `);
1915
- return exit(2);
1916
- }
1917
- if (options2.waitTimeout !== undefined) {
1918
- stderr(`--wait-timeout requires --wait
1919
- `);
1920
- return exit(2);
1921
- }
1922
- if (options2.outputDir !== undefined) {
1923
- stderr(`--output-dir is not configured for native commands
1924
- `);
1925
- return exit(2);
1926
- }
1927
- if (options2.dryRun) {
1928
- stdout(`${JSON.stringify({ command, args: toolArgs2 }, null, 2)}
1929
- `);
1930
- return exit(0);
1931
- }
1932
- const result2 = await executeCliCommand(native, toolArgs2, options2, { stdout, stderr }, config.coerceJsonArgs ?? true, globals);
1933
- const emission = prepareCliCommandEmission(native, result2, options2);
1934
- let emittedExitCode;
1935
- if (emission.result.ok && emission.presentation !== undefined) {
1936
- stdout(emission.presentation);
1937
- emittedExitCode = 0;
1938
- } else {
1939
- emittedExitCode = emitResult(emission.result, { stdout, stderr }, {
1940
- json: options2.json,
1941
- toolName: command,
1942
- errorHint: config.errorHint,
1943
- exitCodes: { ...DEFAULT_EXIT_CODES, ...config.exitCodes }
1944
- });
1945
- }
1946
- return exit(emission.result.ok ? emission.successExitCode : emittedExitCode);
1947
- }
1901
+ return {
1902
+ globals,
1903
+ typedGlobals,
1904
+ route,
1905
+ command,
1906
+ commandArgv,
1907
+ beforeSeparator,
1908
+ helpRequested
1909
+ };
1910
+ }
1911
+ function emitOptionsFor(config, json, toolName) {
1912
+ return {
1913
+ json,
1914
+ toolName,
1915
+ errorHint: config.errorHint,
1916
+ exitCodes: { ...DEFAULT_EXIT_CODES, ...config.exitCodes }
1917
+ };
1918
+ }
1919
+
1920
+ // src/tools/cli/managed-surface.ts
1921
+ async function buildManagedSurface(session, typedGlobals, forExecution) {
1922
+ const { config, nativeHelp, applicationGlobalNames } = session;
1948
1923
  let authPromise;
1949
1924
  const resolveIdentity = () => {
1950
1925
  authPromise ??= (async () => config.resolveAuth ? await config.resolveAuth(typedGlobals) : await config.auth)();
1951
1926
  return authPromise;
1952
1927
  };
1953
1928
  const dynamicSurface = typeof config.services === "function" || typeof config.runtimeTools === "function";
1954
- const buildManagedSurface = async (forExecution) => {
1955
- let auth;
1956
- if (dynamicSurface || forExecution) {
1957
- try {
1958
- auth = await resolveIdentity();
1959
- } catch (error) {
1960
- const failure = toolResultFromError(error);
1961
- const normalized = toolErrorFromResult(failure);
1962
- return {
1963
- resolved: false,
1964
- failure,
1965
- reason: `${normalized.code}: ${normalized.message}`,
1966
- help: new Map(nativeHelp)
1967
- };
1929
+ let auth;
1930
+ if (dynamicSurface || forExecution) {
1931
+ try {
1932
+ auth = await resolveIdentity();
1933
+ } catch (error) {
1934
+ const failure = toolResultFromError(error);
1935
+ const normalized = toolErrorFromResult(failure);
1936
+ return {
1937
+ resolved: false,
1938
+ failure,
1939
+ reason: `${normalized.code}: ${normalized.message}`,
1940
+ help: new Map(nativeHelp)
1941
+ };
1942
+ }
1943
+ }
1944
+ const { tools, help } = buildCliSurface(config, auth, nativeHelp, applicationGlobalNames, assertCommandShape);
1945
+ return { resolved: true, auth, help, tools };
1946
+ }
1947
+
1948
+ // src/tools/cli/prepare.ts
1949
+ function looseCoerceValue(value) {
1950
+ if (Array.isArray(value))
1951
+ return value.map(looseCoerceValue);
1952
+ if (typeof value !== "string")
1953
+ return value;
1954
+ if (value === "true")
1955
+ return true;
1956
+ if (value === "false")
1957
+ return false;
1958
+ const n = Number(value);
1959
+ return value.trim() !== "" && !Number.isNaN(n) ? n : value;
1960
+ }
1961
+ function passthroughBase(value) {
1962
+ if (isRecord(value))
1963
+ return value;
1964
+ if (typeof value === "string") {
1965
+ try {
1966
+ const parsed = safeJsonParse(value);
1967
+ if (isRecord(parsed))
1968
+ return parsed;
1969
+ } catch {}
1970
+ }
1971
+ return;
1972
+ }
1973
+ function collectPassthrough(toolArgs, field, knownKeys) {
1974
+ const known = new Set(knownKeys);
1975
+ const bag = {};
1976
+ for (const key of Object.keys(toolArgs)) {
1977
+ if (key === field || known.has(key))
1978
+ continue;
1979
+ bag[key] = looseCoerceValue(toolArgs[key]);
1980
+ delete toolArgs[key];
1981
+ }
1982
+ if (Object.keys(bag).length === 0)
1983
+ return;
1984
+ const base = passthroughBase(toolArgs[field]);
1985
+ toolArgs[field] = base ? { ...base, ...bag } : bag;
1986
+ }
1987
+ async function prepareInvocation(command, commandArgv, descriptor, config, readStdin) {
1988
+ let parsed;
1989
+ try {
1990
+ parsed = parseCliArgs(commandArgv, descriptor.argumentSchema, {
1991
+ allowUnknown: config.passthrough?.[command] !== undefined,
1992
+ knownFields: jsonSchemaFields(descriptor.presentationSchema).map((field) => field.name),
1993
+ optionAliases: new Map([...descriptor.aliases].map(([field, alias]) => [alias, field])),
1994
+ positionals: descriptor.positionals
1995
+ });
1996
+ } catch (error) {
1997
+ if (!(error instanceof CliArgumentError))
1998
+ throw error;
1999
+ return { ok: false, message: error.message };
2000
+ }
2001
+ const { toolArgs, options } = parsed;
2002
+ const firstUnset = jsonSchemaFields(descriptor.presentationSchema).find((field) => field.required && !(field.name in toolArgs) && field.schema.type !== "boolean");
2003
+ if (firstUnset) {
2004
+ const piped = await readStdin();
2005
+ if (piped !== null) {
2006
+ if (descriptor.positionals === undefined) {
2007
+ toolArgs[firstUnset.name] = piped;
2008
+ } else {
2009
+ const stdinArgs = parseCliArgs([`--${firstUnset.name}`, piped], descriptor.argumentSchema);
2010
+ toolArgs[firstUnset.name] = stdinArgs.toolArgs[firstUnset.name];
1968
2011
  }
1969
2012
  }
1970
- const { tools, help } = buildCliSurface(config, auth, nativeHelp, applicationGlobalNames, assertCommandShape);
1971
- return { resolved: true, auth, help, tools };
1972
- };
1973
- const topLevelHelp = route.topLevelHelp || command === undefined || command === "help" || command === "--help" || command === "-h" || command.startsWith("--help=") && !isReservedBoolWord(command.slice("--help=".length));
1974
- const managed = await buildManagedSurface(!topLevelHelp && !helpRequested);
1975
- if (topLevelHelp) {
1976
- const helpFilter = route.helpFilter ?? (command !== undefined ? commandArgv[0] : undefined);
1977
- const filter = helpFilter !== undefined && !helpFilter.startsWith("-") ? helpFilter : undefined;
1978
- if (filter !== undefined && filterCommands(managed.help, filter).size === 0) {
1979
- stderr(`no command matches "${filter}" (${managed.help.size} available)
1980
- ` + (managed.resolved ? "" : `Managed commands are unavailable: ${managed.reason}
1981
- `));
1982
- const codes = { ...DEFAULT_EXIT_CODES, ...config.exitCodes };
1983
- return exit(codes.NOT_FOUND ?? 4);
1984
- }
1985
- stdout(renderTopHelp({
1986
- name: config.name,
1987
- version: config.version,
1988
- commands: managed.help,
1989
- defaultCommand: config.defaultCommand,
1990
- applicationOptions,
1991
- ...filter !== undefined && { filter },
1992
- ...managed.resolved ? {} : { unavailable: managed.reason }
1993
- }));
1994
- return exit(0);
1995
2013
  }
2014
+ const passthroughField = config.passthrough?.[command];
2015
+ if (passthroughField) {
2016
+ collectPassthrough(toolArgs, passthroughField, objectShapeKeys(descriptor.argumentSchema));
2017
+ }
2018
+ return { ok: true, toolArgs, options };
2019
+ }
2020
+
2021
+ // src/tools/cli/run-managed.ts
2022
+ async function runManagedInvocation(session, route) {
2023
+ const { config } = session;
2024
+ const { stdout, stderr, exit } = session.io;
2025
+ const { command, helpRequested, beforeSeparator } = route;
2026
+ const topLevelHelp = route.route.topLevelHelp || command === undefined || command === "help" || command === "--help" || command === "-h" || command.startsWith("--help=") && !isReservedBoolWord(command.slice("--help=".length));
2027
+ const managed = await buildManagedSurface(session, route.typedGlobals, !topLevelHelp && !helpRequested);
2028
+ if (topLevelHelp)
2029
+ return respondTopLevelHelp(session, route, managed);
1996
2030
  if (!managed.resolved) {
1997
- return exit(emitResult(managed.failure, { stdout, stderr }, {
1998
- json: beforeSeparator.includes("--json"),
1999
- toolName: command ?? config.name,
2000
- errorHint: config.errorHint,
2001
- exitCodes: { ...DEFAULT_EXIT_CODES, ...config.exitCodes }
2002
- }));
2031
+ return exit(emitResult(managed.failure, { stdout, stderr }, emitOptionsFor(config, beforeSeparator.includes("--json"), command ?? config.name)));
2032
+ }
2033
+ return runManagedCommand(session, route, command, managed);
2034
+ }
2035
+ function respondTopLevelHelp(session, route, managed) {
2036
+ const { config, applicationOptions } = session;
2037
+ const { stdout, stderr, exit } = session.io;
2038
+ const { command, commandArgv } = route;
2039
+ const helpFilter = route.route.helpFilter ?? (command !== undefined ? commandArgv[0] : undefined);
2040
+ const filter = helpFilter !== undefined && !helpFilter.startsWith("-") ? helpFilter : undefined;
2041
+ if (filter !== undefined && filterCommands(managed.help, filter).size === 0) {
2042
+ stderr(`no command matches "${filter}" (${managed.help.size} available)
2043
+ ` + (managed.resolved ? "" : `Managed commands are unavailable: ${managed.reason}
2044
+ `));
2045
+ const codes = { ...DEFAULT_EXIT_CODES, ...config.exitCodes };
2046
+ exit(codes.NOT_FOUND ?? 4);
2047
+ return;
2003
2048
  }
2049
+ stdout(renderTopHelp({
2050
+ name: config.name,
2051
+ version: config.version,
2052
+ commands: managed.help,
2053
+ defaultCommand: config.defaultCommand,
2054
+ applicationOptions,
2055
+ ...filter !== undefined && { filter },
2056
+ ...managed.resolved ? {} : { unavailable: managed.reason }
2057
+ }));
2058
+ exit(0);
2059
+ }
2060
+ async function runManagedCommand(session, route, command, managed) {
2061
+ const { config, applicationOptions } = session;
2062
+ const { stdout, stderr, exit, readStdin } = session.io;
2004
2063
  const tool = managed.tools.get(command);
2005
2064
  if (!tool) {
2006
2065
  stderr(`Unknown command "${command}". Run "${config.name} --help" for the command list.
@@ -2010,11 +2069,11 @@ async function createCli(config) {
2010
2069
  const descriptor = managed.help.get(command);
2011
2070
  if (!descriptor)
2012
2071
  throw new Error("[stitchkit] managed CLI descriptor invariant failed");
2013
- if (helpRequested) {
2072
+ if (route.helpRequested) {
2014
2073
  stdout(renderCommandHelp(config.name, command, descriptor, applicationOptions));
2015
2074
  return exit(0);
2016
2075
  }
2017
- const prepared = await prepareInvocation(command, commandArgv, descriptor, config, readStdin);
2076
+ const prepared = await prepareInvocation(command, route.commandArgv, descriptor, config, readStdin);
2018
2077
  if (!prepared.ok) {
2019
2078
  stderr(`${prepared.message}
2020
2079
  `);
@@ -2045,12 +2104,21 @@ async function createCli(config) {
2045
2104
  `);
2046
2105
  return exit(0);
2047
2106
  }
2107
+ const result = await executeManagedTool(session, route, command, managed, tool, {
2108
+ toolArgs,
2109
+ options
2110
+ });
2111
+ return emitManagedResult(session, command, result, options);
2112
+ }
2113
+ async function executeManagedTool(session, route, command, managed, tool, { toolArgs, options }) {
2114
+ const { config } = session;
2115
+ const { stderr } = session.io;
2048
2116
  const runTool = createToolRunner({
2049
2117
  source: "cli",
2050
- context: { ...config.context?.(managed.auth, typedGlobals), signal: config.signal },
2118
+ toolSurface: true,
2119
+ context: { ...config.context?.(managed.auth, route.typedGlobals), signal: config.signal },
2051
2120
  hooks: config.hooks,
2052
2121
  lifecycle: config.lifecycle,
2053
- errorHint: config.errorHint,
2054
2122
  coerceJsonArgs: config.coerceJsonArgs
2055
2123
  });
2056
2124
  let result;
@@ -2081,6 +2149,12 @@ async function createCli(config) {
2081
2149
  signal: config.signal
2082
2150
  });
2083
2151
  }
2152
+ return result;
2153
+ }
2154
+ async function emitManagedResult(session, command, initial, options) {
2155
+ const { config } = session;
2156
+ const { stdout, stderr, exit } = session.io;
2157
+ let result = initial;
2084
2158
  let downloadsOk = true;
2085
2159
  if (options.outputDir && result.ok && config.download) {
2086
2160
  downloadsOk = await downloadResults(config.download(result.data), options.outputDir, stderr, options.quiet, config.allowPrivateDownloadHosts ?? false, config.maxDownloadBytes ?? DEFAULT_DOWNLOAD_MAX_BYTES, config.downloadTimeoutMs);
@@ -2102,13 +2176,82 @@ async function createCli(config) {
2102
2176
  }
2103
2177
  result = { ...result, data: viewed.data };
2104
2178
  }
2105
- const exitCode = emitResult(result, { stdout, stderr }, {
2106
- json: options.json,
2107
- toolName: command,
2108
- errorHint: config.errorHint,
2109
- exitCodes: { ...DEFAULT_EXIT_CODES, ...config.exitCodes }
2110
- });
2179
+ const exitCode = emitResult(result, { stdout, stderr }, emitOptionsFor(config, options.json, command));
2111
2180
  return exit(downloadsOk ? exitCode : 1);
2112
2181
  }
2113
2182
 
2114
- export { WaitTimeoutError, runWaitOperation, fetchGuarded, fetchPinnedDocument, readCapped, routeCliArgv, CliArgumentError, parseCliArgs, extractCliGlobalOptions, defineCliCommand, DEFAULT_EXIT_CODES, cliExitCode, emitResult, cliInvocationResult, createCliInvoker, renderCliView, pollUntilDone, createCli };
2183
+ // src/tools/cli/run-native.ts
2184
+ async function runNativeCommand2(session, route, command, native) {
2185
+ const { config, applicationOptions, nativeHelp } = session;
2186
+ const { stdout, stderr, exit, readStdin } = session.io;
2187
+ const { commandArgv, helpRequested, globals } = route;
2188
+ const descriptor = nativeHelp.get(command);
2189
+ if (!descriptor)
2190
+ throw new Error("[stitchkit] native CLI descriptor invariant failed");
2191
+ if (helpRequested) {
2192
+ stdout(renderCommandHelp(config.name, command, descriptor, applicationOptions));
2193
+ return exit(0);
2194
+ }
2195
+ const prepared = await prepareInvocation(command, commandArgv, descriptor, config, readStdin);
2196
+ if (!prepared.ok) {
2197
+ stderr(`${prepared.message}
2198
+ `);
2199
+ return exit(2);
2200
+ }
2201
+ const { toolArgs, options } = prepared;
2202
+ if (options.help) {
2203
+ stdout(renderCommandHelp(config.name, command, descriptor, applicationOptions));
2204
+ return exit(0);
2205
+ }
2206
+ if (options.wait) {
2207
+ stderr(`--wait is not configured for native command "${command}"
2208
+ `);
2209
+ return exit(2);
2210
+ }
2211
+ if (options.waitTimeout !== undefined) {
2212
+ stderr(`--wait-timeout requires --wait
2213
+ `);
2214
+ return exit(2);
2215
+ }
2216
+ if (options.outputDir !== undefined) {
2217
+ stderr(`--output-dir is not configured for native commands
2218
+ `);
2219
+ return exit(2);
2220
+ }
2221
+ if (options.dryRun) {
2222
+ stdout(`${JSON.stringify({ command, args: toolArgs }, null, 2)}
2223
+ `);
2224
+ return exit(0);
2225
+ }
2226
+ const result = await executeCliCommand(native, toolArgs, options, { stdout, stderr }, config.coerceJsonArgs ?? true, globals);
2227
+ const emission = prepareCliCommandEmission(native, result, options);
2228
+ let emittedExitCode;
2229
+ if (emission.result.ok && emission.presentation !== undefined) {
2230
+ stdout(emission.presentation);
2231
+ emittedExitCode = 0;
2232
+ } else {
2233
+ emittedExitCode = emitResult(emission.result, { stdout, stderr }, emitOptionsFor(config, options.json, command));
2234
+ }
2235
+ return exit(emission.result.ok ? emission.successExitCode : emittedExitCode);
2236
+ }
2237
+
2238
+ // src/tools/cli/create-cli.ts
2239
+ async function createCli(config) {
2240
+ const io = createCliIo(config);
2241
+ const argv = config.argv ?? process.argv.slice(2);
2242
+ if (config.auth !== undefined && config.resolveAuth !== undefined) {
2243
+ throw new Error("[stitchkit] createCli: use either auth or resolveAuth, not both");
2244
+ }
2245
+ const session = createCliSession(config, io);
2246
+ const route = resolveCliRoute(session, argv);
2247
+ if (route === undefined)
2248
+ return;
2249
+ const { command } = route;
2250
+ const native = command === undefined ? undefined : session.nativeCommands.get(command);
2251
+ if (native && command !== undefined) {
2252
+ return runNativeCommand2(session, route, command, native);
2253
+ }
2254
+ return runManagedInvocation(session, route);
2255
+ }
2256
+
2257
+ export { fetchGuarded, PrivateAddressRefusal, fetchPinnedDocument, readCapped, WaitTimeoutError, runWaitOperation, defineCliCommand, DEFAULT_EXIT_CODES, cliExitCode, emitResult, routeCliArgv, CliArgumentError, parseCliArgs, extractCliGlobalOptions, cliInvocationResult, createCliInvoker, renderCliView, pollUntilDone, createCli };