stitchkit 0.93.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 (791) hide show
  1. package/CHANGELOG.md +134 -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} +30 -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} +80 -919
  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-3bmnp41g.js → index-n6hxg8as.js} +507 -419
  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/stable-digest.d.ts +0 -43
  349. package/dist/internal/stable-digest.d.ts.map +1 -1
  350. package/dist/internal/typed.d.ts +0 -8
  351. package/dist/internal/typed.d.ts.map +1 -1
  352. package/dist/internal/zod-issues.d.ts +38 -0
  353. package/dist/internal/zod-issues.d.ts.map +1 -0
  354. package/dist/{tools/json-schema-dialect.d.ts → json-schema/dialect.d.ts} +1 -1
  355. package/dist/json-schema/dialect.d.ts.map +1 -0
  356. package/dist/json-schema/json-schema.d.ts.map +1 -0
  357. package/dist/live/watch-delta.d.ts.map +1 -1
  358. package/dist/{oauth.d.ts → oauth/authorization-code.d.ts} +1 -1
  359. package/dist/oauth/authorization-code.d.ts.map +1 -0
  360. package/dist/observability/audit.d.ts +2 -2
  361. package/dist/observability/audit.d.ts.map +1 -1
  362. package/dist/observability/bounded-logger.d.ts +1 -1
  363. package/dist/observability/bounded-logger.d.ts.map +1 -1
  364. package/dist/{internal/observability-sink.d.ts → observability/bounded-sink.d.ts} +2 -2
  365. package/dist/observability/bounded-sink.d.ts.map +1 -0
  366. package/dist/observability/context.d.ts +1 -1
  367. package/dist/observability/context.d.ts.map +1 -1
  368. package/dist/observability/event.d.ts +1 -1
  369. package/dist/observability/event.d.ts.map +1 -1
  370. package/dist/observability/work.d.ts +1 -1
  371. package/dist/observability/work.d.ts.map +1 -1
  372. package/dist/primitives/audit.d.ts +1 -1
  373. package/dist/primitives/audit.d.ts.map +1 -1
  374. package/dist/primitives/export-operation.d.ts +4 -2
  375. package/dist/primitives/export-operation.d.ts.map +1 -1
  376. package/dist/realtime/socket.d.ts +1 -1
  377. package/dist/realtime/socket.d.ts.map +1 -1
  378. package/dist/server/context-contribution.d.ts +1 -1
  379. package/dist/server/context-contribution.d.ts.map +1 -1
  380. package/dist/server/context.d.ts +2 -2
  381. package/dist/server/context.d.ts.map +1 -1
  382. package/dist/server/contract-method.d.ts +15 -0
  383. package/dist/server/contract-method.d.ts.map +1 -0
  384. package/dist/server/contract-stream.d.ts +1 -1
  385. package/dist/server/contract-stream.d.ts.map +1 -1
  386. package/dist/server/create.d.ts +8 -0
  387. package/dist/server/create.d.ts.map +1 -1
  388. package/dist/server/endpoint-dispatch.d.ts +10 -0
  389. package/dist/server/endpoint-dispatch.d.ts.map +1 -0
  390. package/dist/server/endpoint-response.d.ts +18 -0
  391. package/dist/server/endpoint-response.d.ts.map +1 -0
  392. package/dist/server/error-dispatch.d.ts +17 -1
  393. package/dist/server/error-dispatch.d.ts.map +1 -1
  394. package/dist/server/error-hook.d.ts +2 -2
  395. package/dist/server/error-hook.d.ts.map +1 -1
  396. package/dist/server/handler-state.d.ts +44 -0
  397. package/dist/server/handler-state.d.ts.map +1 -0
  398. package/dist/server/implement.d.ts +1 -1
  399. package/dist/server/implement.d.ts.map +1 -1
  400. package/dist/server/middleware/auth.d.ts +1 -1
  401. package/dist/server/middleware/auth.d.ts.map +1 -1
  402. package/dist/server/middleware/cors.d.ts +17 -0
  403. package/dist/server/middleware/cors.d.ts.map +1 -1
  404. package/dist/server/middleware/trust-fence.d.ts +1 -1
  405. package/dist/server/middleware/trust-fence.d.ts.map +1 -1
  406. package/dist/server/multipart.d.ts +1 -1
  407. package/dist/server/multipart.d.ts.map +1 -1
  408. package/dist/{tools/oauth-metadata.d.ts → server/oauth/metadata.d.ts} +2 -2
  409. package/dist/server/oauth/metadata.d.ts.map +1 -0
  410. package/dist/{tools/oauth-provider.d.ts → server/oauth/provider.d.ts} +2 -2
  411. package/dist/server/oauth/provider.d.ts.map +1 -0
  412. package/dist/server/realtime.d.ts +1 -1
  413. package/dist/server/realtime.d.ts.map +1 -1
  414. package/dist/server/request-completion.d.ts +16 -0
  415. package/dist/server/request-completion.d.ts.map +1 -0
  416. package/dist/server/response-metadata.d.ts +1 -1
  417. package/dist/server/response-metadata.d.ts.map +1 -1
  418. package/dist/server/route-table.d.ts +9 -0
  419. package/dist/server/route-table.d.ts.map +1 -0
  420. package/dist/server/stream.d.ts +0 -13
  421. package/dist/server/stream.d.ts.map +1 -1
  422. package/dist/server/types.d.ts +7 -4
  423. package/dist/server/types.d.ts.map +1 -1
  424. package/dist/testing/handler-clients.d.ts +31 -0
  425. package/dist/testing/handler-clients.d.ts.map +1 -0
  426. package/dist/testing/managed-resource-conformance-scenarios.d.ts.map +1 -1
  427. package/dist/testing/surface-conformance.d.ts +2 -1
  428. package/dist/testing/surface-conformance.d.ts.map +1 -1
  429. package/dist/testing/surface-manifest.d.ts +30 -4
  430. package/dist/testing/surface-manifest.d.ts.map +1 -1
  431. package/dist/tools/{cli-args.d.ts → cli/args.d.ts} +1 -1
  432. package/dist/tools/cli/args.d.ts.map +1 -0
  433. package/dist/tools/{cli-checkpoint.d.ts → cli/checkpoint.d.ts} +1 -1
  434. package/dist/tools/cli/checkpoint.d.ts.map +1 -0
  435. package/dist/tools/{cli-command.d.ts → cli/command.d.ts} +4 -4
  436. package/dist/tools/cli/command.d.ts.map +1 -0
  437. package/dist/tools/{cli.d.ts → cli/config.d.ts} +5 -9
  438. package/dist/tools/cli/config.d.ts.map +1 -0
  439. package/dist/tools/cli/create-cli.d.ts +36 -0
  440. package/dist/tools/cli/create-cli.d.ts.map +1 -0
  441. package/dist/tools/cli/download.d.ts +8 -0
  442. package/dist/tools/cli/download.d.ts.map +1 -0
  443. package/dist/tools/{cli-format.d.ts → cli/format.d.ts} +2 -2
  444. package/dist/tools/cli/format.d.ts.map +1 -0
  445. package/dist/tools/cli/help.d.ts +24 -0
  446. package/dist/tools/cli/help.d.ts.map +1 -0
  447. package/dist/tools/{cli-installer.d.ts → cli/installer.d.ts} +2 -2
  448. package/dist/tools/cli/installer.d.ts.map +1 -0
  449. package/dist/tools/{cli-invoke.d.ts → cli/invoke.d.ts} +8 -8
  450. package/dist/tools/cli/invoke.d.ts.map +1 -0
  451. package/dist/tools/cli/io.d.ts +10 -0
  452. package/dist/tools/cli/io.d.ts.map +1 -0
  453. package/dist/tools/cli/managed-surface.d.ts +30 -0
  454. package/dist/tools/cli/managed-surface.d.ts.map +1 -0
  455. package/dist/tools/{cli-manifest.d.ts → cli/manifest.d.ts} +1 -1
  456. package/dist/tools/cli/manifest.d.ts.map +1 -0
  457. package/dist/tools/{cli-policy.d.ts → cli/policy.d.ts} +2 -2
  458. package/dist/tools/cli/policy.d.ts.map +1 -0
  459. package/dist/tools/cli/prepare.d.ts +14 -0
  460. package/dist/tools/cli/prepare.d.ts.map +1 -0
  461. package/dist/tools/{cli-profile.d.ts → cli/profile.d.ts} +2 -2
  462. package/dist/tools/cli/profile.d.ts.map +1 -0
  463. package/dist/tools/cli/run-managed.d.ts +5 -0
  464. package/dist/tools/cli/run-managed.d.ts.map +1 -0
  465. package/dist/tools/cli/run-native.d.ts +9 -0
  466. package/dist/tools/cli/run-native.d.ts.map +1 -0
  467. package/dist/tools/cli/session.d.ts +40 -0
  468. package/dist/tools/cli/session.d.ts.map +1 -0
  469. package/dist/tools/{cli-signature.d.ts → cli/signature.d.ts} +2 -2
  470. package/dist/tools/cli/signature.d.ts.map +1 -0
  471. package/dist/tools/{cli-stream.d.ts → cli/stream.d.ts} +4 -4
  472. package/dist/tools/cli/stream.d.ts.map +1 -0
  473. package/dist/tools/{cli-update.d.ts → cli/update.d.ts} +3 -3
  474. package/dist/tools/cli/update.d.ts.map +1 -0
  475. package/dist/tools/{cli-view.d.ts → cli/view.d.ts} +2 -2
  476. package/dist/tools/cli/view.d.ts.map +1 -0
  477. package/dist/tools/{cli-wait.d.ts → cli/wait.d.ts} +2 -2
  478. package/dist/tools/cli/wait.d.ts.map +1 -0
  479. package/dist/tools/connections/runtime.d.ts +1 -1
  480. package/dist/tools/connections/runtime.d.ts.map +1 -1
  481. package/dist/tools/connections/types.d.ts +3 -3
  482. package/dist/tools/connections/types.d.ts.map +1 -1
  483. package/dist/tools/durability-context.d.ts +1 -1
  484. package/dist/tools/durability-context.d.ts.map +1 -1
  485. package/dist/tools/execute.d.ts +30 -3
  486. package/dist/tools/execute.d.ts.map +1 -1
  487. package/dist/tools/internal/surface-projector.d.ts +8 -6
  488. package/dist/tools/internal/surface-projector.d.ts.map +1 -1
  489. package/dist/tools/internal/tool-view.d.ts +41 -0
  490. package/dist/tools/internal/tool-view.d.ts.map +1 -0
  491. package/dist/tools/invoker.d.ts +11 -3
  492. package/dist/tools/invoker.d.ts.map +1 -1
  493. package/dist/tools/list-names.d.ts +3 -3
  494. package/dist/tools/list-names.d.ts.map +1 -1
  495. package/dist/tools/manifest.d.ts +2 -2
  496. package/dist/tools/manifest.d.ts.map +1 -1
  497. package/dist/tools/{mcp-app.d.ts → mcp/app.d.ts} +1 -1
  498. package/dist/tools/mcp/app.d.ts.map +1 -0
  499. package/dist/tools/{mcp-catalog.d.ts → mcp/catalog.d.ts} +2 -2
  500. package/dist/tools/mcp/catalog.d.ts.map +1 -0
  501. package/dist/tools/{mcp-handler.d.ts → mcp/handler.d.ts} +5 -5
  502. package/dist/tools/mcp/handler.d.ts.map +1 -0
  503. package/dist/tools/{mcp.d.ts → mcp/mount.d.ts} +9 -9
  504. package/dist/tools/mcp/mount.d.ts.map +1 -0
  505. package/dist/tools/{mcp-prepare.d.ts → mcp/prepare.d.ts} +9 -9
  506. package/dist/tools/mcp/prepare.d.ts.map +1 -0
  507. package/dist/tools/{mcp-progress.d.ts → mcp/progress.d.ts} +2 -2
  508. package/dist/tools/mcp/progress.d.ts.map +1 -0
  509. package/dist/tools/mcp/register.d.ts +35 -0
  510. package/dist/tools/mcp/register.d.ts.map +1 -0
  511. package/dist/tools/{mcp-round-policy.d.ts → mcp/round-policy.d.ts} +2 -2
  512. package/dist/tools/mcp/round-policy.d.ts.map +1 -0
  513. package/dist/tools/{mcp-round.d.ts → mcp/round.d.ts} +4 -4
  514. package/dist/tools/mcp/round.d.ts.map +1 -0
  515. package/dist/tools/mcp/runtime-tools.d.ts +24 -0
  516. package/dist/tools/mcp/runtime-tools.d.ts.map +1 -0
  517. package/dist/tools/{mcp-stdio-signals.d.ts → mcp/stdio-signals.d.ts} +3 -3
  518. package/dist/tools/mcp/stdio-signals.d.ts.map +1 -0
  519. package/dist/tools/{mcp-stdio.d.ts → mcp/stdio.d.ts} +4 -4
  520. package/dist/tools/mcp/stdio.d.ts.map +1 -0
  521. package/dist/tools/{mcp-trace.d.ts → mcp/trace.d.ts} +1 -1
  522. package/dist/tools/mcp/trace.d.ts.map +1 -0
  523. package/dist/tools/mount.d.ts +12 -7
  524. package/dist/tools/mount.d.ts.map +1 -1
  525. package/dist/tools/native-definition.d.ts +3 -3
  526. package/dist/tools/native-definition.d.ts.map +1 -1
  527. package/dist/tools/operations/async-operation-binding-types.d.ts +127 -0
  528. package/dist/tools/operations/async-operation-binding-types.d.ts.map +1 -0
  529. package/dist/tools/operations/async-operation-binding.d.ts +28 -0
  530. package/dist/tools/operations/async-operation-binding.d.ts.map +1 -0
  531. package/dist/tools/operations/async-operation-canonical-types.d.ts +110 -0
  532. package/dist/tools/operations/async-operation-canonical-types.d.ts.map +1 -0
  533. package/dist/tools/operations/async-operation-canonical.d.ts +7 -0
  534. package/dist/tools/operations/async-operation-canonical.d.ts.map +1 -0
  535. package/dist/tools/operations/async-operation-contract.d.ts.map +1 -0
  536. package/dist/tools/operations/async-operation-id.d.ts +23 -0
  537. package/dist/tools/operations/async-operation-id.d.ts.map +1 -0
  538. package/dist/tools/operations/async-operation-runtime-tools.d.ts +40 -0
  539. package/dist/tools/operations/async-operation-runtime-tools.d.ts.map +1 -0
  540. package/dist/tools/operations/async-operation-runtime-types.d.ts +68 -0
  541. package/dist/tools/operations/async-operation-runtime-types.d.ts.map +1 -0
  542. package/dist/tools/operations/async-operation-runtime.d.ts +5 -0
  543. package/dist/tools/operations/async-operation-runtime.d.ts.map +1 -0
  544. package/dist/tools/{define-wait-tool.d.ts → operations/define-wait-tool.d.ts} +2 -2
  545. package/dist/tools/operations/define-wait-tool.d.ts.map +1 -0
  546. package/dist/tools/operations/mount-wait.d.ts.map +1 -0
  547. package/dist/tools/operations/wait-core.d.ts.map +1 -0
  548. package/dist/tools/remote.d.ts +1 -1
  549. package/dist/tools/remote.d.ts.map +1 -1
  550. package/dist/tools/runtime-tool.d.ts +11 -4
  551. package/dist/tools/runtime-tool.d.ts.map +1 -1
  552. package/dist/tools/schema/coerce.d.ts.map +1 -0
  553. package/dist/tools/schema/flatten-join.d.ts.map +1 -0
  554. package/dist/tools/schema/flatten.d.ts.map +1 -0
  555. package/dist/tools/schema/portable-formats.d.ts.map +1 -0
  556. package/dist/tools/{presentation.d.ts → schema/presentation.d.ts} +2 -0
  557. package/dist/tools/schema/presentation.d.ts.map +1 -0
  558. package/dist/tools/schema/schema.d.ts.map +1 -0
  559. package/dist/tools/schema/untyped-properties.d.ts.map +1 -0
  560. package/dist/tools/surface.d.ts +2 -3
  561. package/dist/tools/surface.d.ts.map +1 -1
  562. package/dist/tools/toolkit.d.ts +4 -4
  563. package/dist/tools/toolkit.d.ts.map +1 -1
  564. package/dist/tools/{define-download-tool.d.ts → transfer/define-download-tool.d.ts} +4 -4
  565. package/dist/tools/transfer/define-download-tool.d.ts.map +1 -0
  566. package/dist/tools/{define-upload-tool.d.ts → transfer/define-upload-tool.d.ts} +3 -3
  567. package/dist/tools/transfer/define-upload-tool.d.ts.map +1 -0
  568. package/dist/tools/{define-view-file-tool.d.ts → transfer/define-view-file-tool.d.ts} +2 -2
  569. package/dist/tools/transfer/define-view-file-tool.d.ts.map +1 -0
  570. package/dist/tools/{download-core.d.ts → transfer/download-core.d.ts} +2 -2
  571. package/dist/tools/transfer/download-core.d.ts.map +1 -0
  572. package/dist/tools/{managed-file-error.d.ts → transfer/managed-file-error.d.ts} +1 -1
  573. package/dist/tools/transfer/managed-file-error.d.ts.map +1 -0
  574. package/dist/tools/{mount-download.d.ts → transfer/mount-download.d.ts} +1 -1
  575. package/dist/tools/transfer/mount-download.d.ts.map +1 -0
  576. package/dist/tools/{mount-upload.d.ts → transfer/mount-upload.d.ts} +1 -1
  577. package/dist/tools/transfer/mount-upload.d.ts.map +1 -0
  578. package/dist/tools/transfer/native-result.d.ts.map +1 -0
  579. package/dist/tools/{upload-core.d.ts → transfer/upload-core.d.ts} +1 -1
  580. package/dist/tools/transfer/upload-core.d.ts.map +1 -0
  581. package/dist/tools/transfer/view-file-contract.d.ts.map +1 -0
  582. package/dist/tools/{view-file.d.ts → transfer/view-file.d.ts} +1 -1
  583. package/dist/tools/transfer/view-file.d.ts.map +1 -0
  584. package/dist/tools/transports.d.ts +1 -1
  585. package/dist/tools/transports.d.ts.map +1 -1
  586. package/dist/tracking/contract.d.ts +1 -1
  587. package/dist/tracking/contract.d.ts.map +1 -1
  588. package/llms/agent-runtime-browser.txt +33 -0
  589. package/llms/agent-runtime-coding-tools.txt +58 -0
  590. package/llms/agent-runtime-harness.txt +45 -0
  591. package/llms/agent-runtime-openrouter.txt +22 -0
  592. package/llms/agent-runtime-sandbox.txt +159 -0
  593. package/llms/agent-runtime-sqlite-bun.txt +29 -0
  594. package/llms/agent-runtime-sqlite-node.txt +26 -0
  595. package/llms/agent-runtime-testing.txt +30 -0
  596. package/llms/agent-runtime.2.txt +550 -0
  597. package/llms/agent-runtime.3.txt +311 -0
  598. package/llms/agent-runtime.txt +893 -0
  599. package/llms/application-diagnostic-journal.txt +30 -0
  600. package/llms/application-grammy.txt +27 -0
  601. package/llms/application-opentelemetry.txt +27 -0
  602. package/llms/application-schemas.txt +42 -0
  603. package/llms/application.2.txt +223 -0
  604. package/llms/application.txt +1144 -0
  605. package/llms/cli.txt +977 -0
  606. package/llms/contract.txt +606 -0
  607. package/llms/declaration.txt +286 -0
  608. package/llms/files.txt +30 -0
  609. package/llms/geo.txt +114 -0
  610. package/llms/google.txt +27 -0
  611. package/llms/live.txt +471 -0
  612. package/llms/node.txt +43 -0
  613. package/llms/oauth.txt +136 -0
  614. package/llms/observability.txt +893 -0
  615. package/llms/primitives.txt +158 -0
  616. package/llms/react.txt +184 -0
  617. package/llms/release.txt +176 -0
  618. package/llms/remote.txt +25 -0
  619. package/llms/server.2.txt +361 -0
  620. package/llms/server.3.txt +1031 -0
  621. package/llms/server.4.txt +905 -0
  622. package/llms/server.5.txt +250 -0
  623. package/llms/server.txt +996 -0
  624. package/llms/stitchkit.2.txt +836 -0
  625. package/llms/stitchkit.3.txt +147 -0
  626. package/llms/stitchkit.txt +260 -0
  627. package/llms/telegram.txt +30 -0
  628. package/llms/testing.txt +676 -0
  629. package/llms/tools-connections.txt +45 -0
  630. package/llms/tools-contract.txt +9 -0
  631. package/llms/tools-invoker.txt +9 -0
  632. package/llms/tools.2.txt +838 -0
  633. package/llms/tools.txt +1004 -0
  634. package/llms/tracking-server.txt +32 -0
  635. package/llms/tracking.txt +263 -0
  636. package/llms/upgrading-0.37.0-0.50.0.txt +947 -0
  637. package/llms/upgrading-0.53.0-0.67.0.txt +1174 -0
  638. package/llms/upgrading-0.68.0-0.94.0.txt +1159 -0
  639. package/llms/upgrading.txt +215 -0
  640. package/llms-full.txt +214 -75
  641. package/llms.txt +54 -5
  642. package/package.json +84 -83
  643. package/dist/agent-runtime/durability-contract.d.ts.map +0 -1
  644. package/dist/agent-runtime/durability-json.d.ts.map +0 -1
  645. package/dist/agent-runtime/durability-ledger.d.ts.map +0 -1
  646. package/dist/agent-runtime/durability-scheduler.d.ts.map +0 -1
  647. package/dist/agent-runtime/durability.d.ts.map +0 -1
  648. package/dist/agent-runtime/store-driver.d.ts.map +0 -1
  649. package/dist/agent-runtime-browser.d.ts +0 -5
  650. package/dist/agent-runtime-browser.d.ts.map +0 -1
  651. package/dist/agent-runtime-coding-tools.d.ts.map +0 -1
  652. package/dist/agent-runtime-coding-tools.js +0 -23
  653. package/dist/agent-runtime-harness.d.ts.map +0 -1
  654. package/dist/agent-runtime-openrouter.d.ts.map +0 -1
  655. package/dist/agent-runtime-sandbox.d.ts.map +0 -1
  656. package/dist/agent-runtime-sqlite-bun.d.ts.map +0 -1
  657. package/dist/agent-runtime-sqlite-node.d.ts.map +0 -1
  658. package/dist/agent-runtime-testing.d.ts +0 -3
  659. package/dist/agent-runtime-testing.d.ts.map +0 -1
  660. package/dist/agent-runtime-testing.js +0 -156
  661. package/dist/agent-runtime.d.ts.map +0 -1
  662. package/dist/application/channel.d.ts.map +0 -1
  663. package/dist/application-diagnostic-journal.d.ts.map +0 -1
  664. package/dist/application-grammy.d.ts.map +0 -1
  665. package/dist/application-opentelemetry.d.ts.map +0 -1
  666. package/dist/application-schemas.d.ts.map +0 -1
  667. package/dist/application.d.ts.map +0 -1
  668. package/dist/cli.d.ts.map +0 -1
  669. package/dist/contract/index.d.ts +0 -8
  670. package/dist/contract/index.d.ts.map +0 -1
  671. package/dist/declaration.d.ts.map +0 -1
  672. package/dist/files.d.ts.map +0 -1
  673. package/dist/geo.d.ts.map +0 -1
  674. package/dist/google.d.ts.map +0 -1
  675. package/dist/index-0j3vcp5m.js +0 -28
  676. package/dist/index-a11g2kry.js +0 -866
  677. package/dist/index-cnyk6te3.js +0 -77
  678. package/dist/index-fadnxwna.js +0 -1046
  679. package/dist/index-hrbajay7.js +0 -1196
  680. package/dist/index-s8cnx02s.js +0 -90
  681. package/dist/index-v5573g1k.js +0 -142
  682. package/dist/index-vk3kq9sb.js +0 -3344
  683. package/dist/index.d.ts.map +0 -1
  684. package/dist/internal/errors.d.ts.map +0 -1
  685. package/dist/internal/observability-sink.d.ts.map +0 -1
  686. package/dist/live.d.ts.map +0 -1
  687. package/dist/logger.d.ts.map +0 -1
  688. package/dist/node.d.ts.map +0 -1
  689. package/dist/oauth.d.ts.map +0 -1
  690. package/dist/observability/index.d.ts.map +0 -1
  691. package/dist/primitives.d.ts +0 -3
  692. package/dist/primitives.d.ts.map +0 -1
  693. package/dist/react.d.ts.map +0 -1
  694. package/dist/release.d.ts.map +0 -1
  695. package/dist/remote.d.ts.map +0 -1
  696. package/dist/remote.js +0 -88
  697. package/dist/retained.d.ts.map +0 -1
  698. package/dist/server/file-state-store.d.ts.map +0 -1
  699. package/dist/server/index.d.ts.map +0 -1
  700. package/dist/server/request.d.ts.map +0 -1
  701. package/dist/telegram.d.ts.map +0 -1
  702. package/dist/testing/agent-store-conformance.d.ts.map +0 -1
  703. package/dist/testing.d.ts +0 -39
  704. package/dist/testing.d.ts.map +0 -1
  705. package/dist/tool-invoker.d.ts.map +0 -1
  706. package/dist/tool-invoker.js +0 -21
  707. package/dist/tools/async-operation-contract.d.ts.map +0 -1
  708. package/dist/tools/async-operation.d.ts +0 -332
  709. package/dist/tools/async-operation.d.ts.map +0 -1
  710. package/dist/tools/cli-args.d.ts.map +0 -1
  711. package/dist/tools/cli-checkpoint.d.ts.map +0 -1
  712. package/dist/tools/cli-command.d.ts.map +0 -1
  713. package/dist/tools/cli-format.d.ts.map +0 -1
  714. package/dist/tools/cli-installer.d.ts.map +0 -1
  715. package/dist/tools/cli-invoke.d.ts.map +0 -1
  716. package/dist/tools/cli-manifest.d.ts.map +0 -1
  717. package/dist/tools/cli-policy.d.ts.map +0 -1
  718. package/dist/tools/cli-profile.d.ts.map +0 -1
  719. package/dist/tools/cli-signature.d.ts.map +0 -1
  720. package/dist/tools/cli-stream.d.ts.map +0 -1
  721. package/dist/tools/cli-update.d.ts.map +0 -1
  722. package/dist/tools/cli-view.d.ts.map +0 -1
  723. package/dist/tools/cli-wait.d.ts.map +0 -1
  724. package/dist/tools/cli.d.ts.map +0 -1
  725. package/dist/tools/coerce.d.ts.map +0 -1
  726. package/dist/tools/connections/index.d.ts.map +0 -1
  727. package/dist/tools/define-download-tool.d.ts.map +0 -1
  728. package/dist/tools/define-upload-tool.d.ts.map +0 -1
  729. package/dist/tools/define-view-file-tool.d.ts.map +0 -1
  730. package/dist/tools/define-wait-tool.d.ts.map +0 -1
  731. package/dist/tools/download-core.d.ts.map +0 -1
  732. package/dist/tools/flatten-join.d.ts.map +0 -1
  733. package/dist/tools/flatten.d.ts.map +0 -1
  734. package/dist/tools/json-schema-dialect.d.ts.map +0 -1
  735. package/dist/tools/json-schema.d.ts.map +0 -1
  736. package/dist/tools/managed-file-error.d.ts.map +0 -1
  737. package/dist/tools/mcp-app.d.ts.map +0 -1
  738. package/dist/tools/mcp-catalog.d.ts.map +0 -1
  739. package/dist/tools/mcp-handler.d.ts.map +0 -1
  740. package/dist/tools/mcp-prepare.d.ts.map +0 -1
  741. package/dist/tools/mcp-progress.d.ts.map +0 -1
  742. package/dist/tools/mcp-round-policy.d.ts.map +0 -1
  743. package/dist/tools/mcp-round.d.ts.map +0 -1
  744. package/dist/tools/mcp-stdio-signals.d.ts.map +0 -1
  745. package/dist/tools/mcp-stdio.d.ts.map +0 -1
  746. package/dist/tools/mcp-trace.d.ts.map +0 -1
  747. package/dist/tools/mcp.d.ts.map +0 -1
  748. package/dist/tools/mount-download.d.ts.map +0 -1
  749. package/dist/tools/mount-upload.d.ts.map +0 -1
  750. package/dist/tools/mount-wait.d.ts.map +0 -1
  751. package/dist/tools/native-mcp.d.ts +0 -20
  752. package/dist/tools/native-mcp.d.ts.map +0 -1
  753. package/dist/tools/native-result.d.ts.map +0 -1
  754. package/dist/tools/oauth-metadata.d.ts.map +0 -1
  755. package/dist/tools/oauth-provider.d.ts.map +0 -1
  756. package/dist/tools/portable-formats.d.ts.map +0 -1
  757. package/dist/tools/presentation.d.ts.map +0 -1
  758. package/dist/tools/schema.d.ts.map +0 -1
  759. package/dist/tools/untyped-properties.d.ts.map +0 -1
  760. package/dist/tools/upload-core.d.ts.map +0 -1
  761. package/dist/tools/view-file-contract.d.ts.map +0 -1
  762. package/dist/tools/view-file.d.ts.map +0 -1
  763. package/dist/tools/wait-core.d.ts.map +0 -1
  764. package/dist/tools-contract.d.ts.map +0 -1
  765. package/dist/tools.d.ts +0 -50
  766. package/dist/tools.d.ts.map +0 -1
  767. package/dist/tracking-server.d.ts.map +0 -1
  768. package/dist/tracking.d.ts.map +0 -1
  769. package/dist/upgrade-cli.d.ts.map +0 -1
  770. package/dist/{retained.d.ts → browser/retained.d.ts} +0 -0
  771. package/dist/{declaration.d.ts → declaration/declaration.d.ts} +0 -0
  772. package/dist/{upgrade-cli.d.ts → entrypoints/bin/upgrade-cli.d.ts} +0 -0
  773. package/dist/{tracking-server.js → entrypoints/tracking/server.js} +0 -0
  774. package/dist/{google.d.ts → google/google.d.ts} +0 -0
  775. package/dist/{index-pq95qkbf.js → index-5jm36zv1.js} +0 -0
  776. package/dist/{index-actkayzn.js → index-70yj2ebz.js} +3 -3
  777. /package/dist/{application → internal}/channel.d.ts +0 -0
  778. /package/dist/{logger.d.ts → internal/logger.d.ts} +0 -0
  779. /package/dist/{server → internal}/request.d.ts +0 -0
  780. /package/dist/{tools → json-schema}/json-schema.d.ts +0 -0
  781. /package/dist/tools/{async-operation-contract.d.ts → operations/async-operation-contract.d.ts} +0 -0
  782. /package/dist/tools/{mount-wait.d.ts → operations/mount-wait.d.ts} +0 -0
  783. /package/dist/tools/{wait-core.d.ts → operations/wait-core.d.ts} +0 -0
  784. /package/dist/tools/{coerce.d.ts → schema/coerce.d.ts} +0 -0
  785. /package/dist/tools/{flatten-join.d.ts → schema/flatten-join.d.ts} +0 -0
  786. /package/dist/tools/{flatten.d.ts → schema/flatten.d.ts} +0 -0
  787. /package/dist/tools/{portable-formats.d.ts → schema/portable-formats.d.ts} +0 -0
  788. /package/dist/tools/{schema.d.ts → schema/schema.d.ts} +0 -0
  789. /package/dist/tools/{untyped-properties.d.ts → schema/untyped-properties.d.ts} +0 -0
  790. /package/dist/tools/{native-result.d.ts → transfer/native-result.d.ts} +0 -0
  791. /package/dist/tools/{view-file-contract.d.ts → transfer/view-file-contract.d.ts} +0 -0
@@ -0,0 +1,838 @@
1
+ # stitchkit/tools — stitchkit docs slice, part 2 of 2
2
+
3
+ > Generated from the `docs/` tree by `bun run gen:llms`. The index of all slices is
4
+ > `llms.txt` in this package.
5
+
6
+ Parts of this slice:
7
+ - `llms/tools.txt`: Guide: MCP & agents (docs/guide/mcp-and-agents.md)
8
+ - `llms/tools.2.txt`: Guide: MCP & agents (docs/guide/mcp-and-agents.md) · API reference: `stitchkit/tools` (docs/api/reference.md)
9
+
10
+ ==============================================================================
11
+ # Guide: MCP & agents (docs/guide/mcp-and-agents.md) (continued)
12
+ ==============================================================================
13
+
14
+ ## AI agents — `mountAgent`
15
+
16
+ `mountAgent` remains the low-level path when the application owns its own model
17
+ loop and conversation state. For the optional Stitchkit-owned run/history loop,
18
+ see [Agent application runtime](./agent-runtime.md).
19
+
20
+ `mountAgent` turns a service into a Vercel AI SDK `ToolSet`, ready for
21
+ `generateText` / `streamText`:
22
+
23
+ ```ts
24
+ import { mountAgent } from 'stitchkit/tools'
25
+ import { generateText } from 'ai'
26
+
27
+ const tools = mountAgent(usersService, { context: { userId: 'agent-1' } })
28
+
29
+ const result = await generateText({
30
+ model,
31
+ tools,
32
+ prompt: 'Create a user named Max',
33
+ })
34
+ ```
35
+
36
+ Each contract endpoint exposed on `AGENT` becomes a tool whose input schema is
37
+ the merged `params` + `input`. `context` is merged into every tool handler's
38
+ `ctx`, alongside `source: 'agent'`.
39
+
40
+ ### `AgentMountConfig`
41
+
42
+ | Field | Purpose |
43
+ |-------|---------|
44
+ | `context` | values merged into every tool handler's `ctx` |
45
+ | `lifecycle` | `beforeHandle` / `afterHandle` — the tool-side auth gate (see [Guarding tools](#guarding-tools--lifecycle)) |
46
+ | `hooks` | tool-call observability hooks — `afterToolCall` fires on every result |
47
+ | `extend` | add extra args resolved before the handler runs (see below) |
48
+ | `runtimeTools` | framework-managed pathless operations from `defineRuntimeTool` |
49
+
50
+ `lifecycle` works the same as on the MCP server — without it an agent tool call
51
+ bypasses the HTTP `authorize` gate. Pass your `createAuthHook` result.
52
+
53
+ ### Adding tool-only args — `extend`
54
+
55
+ `extend` adds **tool-only** arguments — fields the model fills that are resolved
56
+ into context, then stripped before the contract handler sees them. Use it when a
57
+ tool needs an argument the HTTP endpoint does not — the classic case being a
58
+ **multi-tenant** server reached by one API key, where the model passes `tenantId`
59
+ on every call. It is the same `ToolExtend` shape on `mountMcp`, `createMcpHandler`
60
+ and `mountAgent`:
61
+
62
+ ```ts
63
+ interface ToolExtend {
64
+ /** Extra Zod fields added to every matching tool's input schema. */
65
+ schema: Record<string, z.ZodType>
66
+ /** Turn the extra args into context merged into the handler's ctx. */
67
+ resolve: (args: Record<string, unknown>) => Partial<Ctx> | Promise<Partial<Ctx>>
68
+ /** Limit the extension to specific methods — default: every method. */
69
+ filter?: (service: ServiceDef, method: MethodDef) => boolean
70
+ }
71
+ ```
72
+
73
+ On the MCP server — add `tenantId` to each tool, validate access in `resolve`,
74
+ inject the resolved tenant into `ctx`, and `filter` to the tenant-scoped tools:
75
+
76
+ ```ts
77
+ createMcpHandler({
78
+ serverInfo, auth,
79
+ services: [widgetsService],
80
+ extend: {
81
+ schema: { tenantId: z.string().describe('Tenant to act on') },
82
+ resolve: async ({ tenantId }) => {
83
+ const id = String(tenantId)
84
+ if (!(await tenantExists(id))) throw new Error(`unknown tenant ${id}`)
85
+ return { tenantId: id } // merged into ctx → ctx.tenantId
86
+ },
87
+ filter: (_service, method) => method.scope === 'tenant',
88
+ },
89
+ })
90
+ ```
91
+
92
+ The model calls `widgets_list({ tenantId: 't_123' })`; `resolve` checks access and
93
+ puts `tenantId` on `ctx`; the contract handler reads `ctx.tenantId` (same place
94
+ as the HTTP prefix param — see
95
+ [Route groups → param prefixes](./server.md#param-prefixes-resource-scoped-paths)),
96
+ so one handler serves both surfaces. Pair `extend` with `lifecycle` (your
97
+ `createAuthHook`) so the tool call is still scope-gated.
98
+
99
+ ## Pathless runtime tools and multimodal results
100
+
101
+ Use `defineRuntimeTool` for an operation that has no HTTP path but still needs
102
+ the same validation, isolated per-call context, lifecycle/RBAC and hooks as a
103
+ contract tool. The handler returns one transport-neutral, schema-validated
104
+ result. Optional presentation callbacks map that result to MCP content and AI
105
+ SDK model output without coupling the handler to either SDK:
106
+
107
+ ```ts
108
+ import { createMcpHandler, defineRuntimeTool, mountAgent } from 'stitchkit/tools'
109
+ import { z } from 'zod'
110
+
111
+ const renderPreview = defineRuntimeTool({
112
+ name: 'render_preview',
113
+ description: 'Render and inspect a preview',
114
+ identity: {
115
+ serviceName: 'mediaTools',
116
+ action: 'renderPreview',
117
+ scope: 'admin',
118
+ method: 'POST',
119
+ },
120
+ input: z.object({ prompt: z.string() }),
121
+ output: z.object({ assetId: z.string(), imageBase64: z.string() }),
122
+ handler: async ({ input }) => renderAndSave(input.prompt),
123
+ present: {
124
+ mcp: (output) => ({
125
+ content: [
126
+ { type: 'image', data: output.imageBase64, mimeType: 'image/png' },
127
+ { type: 'text', text: output.assetId },
128
+ ],
129
+ }),
130
+ agent: (output) => ({
131
+ type: 'content',
132
+ value: [{
133
+ type: 'file',
134
+ data: { type: 'data', data: output.imageBase64 },
135
+ mediaType: 'image/png',
136
+ filename: `${output.assetId}.png`,
137
+ }],
138
+ }),
139
+ },
140
+ })
141
+
142
+ const handleMcp = createMcpHandler({
143
+ serverInfo: { name: 'my-app', version: '1.0.0' },
144
+ auth,
145
+ services: [service],
146
+ runtimeTools: [renderPreview],
147
+ lifecycle: { beforeHandle: authHook },
148
+ hooks: audit.toolCall,
149
+ })
150
+
151
+ const agentTools = mountAgent([service], {
152
+ runtimeTools: [renderPreview],
153
+ lifecycle: { beforeHandle: authHook },
154
+ hooks: audit.toolCall,
155
+ })
156
+ ```
157
+
158
+ When several runtime tools share application context and identity, bind both
159
+ once with `createRuntimeToolFactory`. Its Zod context schema is parsed once per
160
+ call inside the same runner; the authored handler receives validated context and
161
+ parsed `input`, while lifecycle, hooks, output validation and presenters remain
162
+ unchanged:
163
+
164
+ ```ts
165
+ const knowledgeTools = createRuntimeToolFactory({
166
+ serviceName: 'agentKnowledge',
167
+ scope: 'user',
168
+ context: z.object({ userId: z.string(), tz: z.string() }),
169
+ })
170
+
171
+ const countRecords = knowledgeTools.define({
172
+ name: 'count_records',
173
+ action: 'countRecords',
174
+ method: 'GET',
175
+ description: 'Count records',
176
+ input: z.object({ kind: z.string() }),
177
+ output: z.object({ count: z.number() }),
178
+ handler: async ({ userId, tz, input }) => countFor(userId, tz, input.kind),
179
+ })
180
+ ```
181
+
182
+ `serviceName` and `scope` cannot be overridden by one definition. Use standalone
183
+ `defineRuntimeTool` when tools do not share a context schema or identity.
184
+
185
+ `transports` defaults to `['MCP', 'AGENT']`; set an explicit subset when an
186
+ operation belongs on only one surface. Include `'CLI'` explicitly to reuse the
187
+ definition through `createCli({ runtimeTools })`; adding CLI support never
188
+ widens existing definitions silently. The configured identity becomes the
189
+ hook/lifecycle `OperationIdentity` and the tool `RequestEvent`
190
+ (`serviceName`, `action`, `httpMethod`). A runtime operation has no HTTP route,
191
+ so no fake `path` is added.
192
+
193
+ When `output` is declared, Stitchkit validates the neutral handler result after
194
+ `afterHandle`. MCP owns `structuredContent` and `isError`: a presenter supplies
195
+ only rich `content`/metadata, while the framework inserts the validated
196
+ structured result and normalises failures. The Agent adapter uses the AI SDK's
197
+ official `toModelOutput` callback, so `execute` and application UI keep the
198
+ neutral output while the model receives text/file content. Presentation
199
+ callbacks require an output schema.
200
+
201
+ The MCP registration uses an identity carrier: the SDK advertises the compiled
202
+ JSON Schema but forwards the raw object into Stitchkit. Input failures therefore
203
+ use the same validation, lifecycle and hook path as contract tools.
204
+
205
+ ### Managed wait, download, upload and view-file
206
+
207
+ The common imperative shapes have typed definition factories. They produce
208
+ ordinary runtime-tool definitions, so one value can enter `runtimeTools` on MCP
209
+ and Agent and receives the same lifecycle, hooks, context, cancellation,
210
+ collision checks and introspection as any `defineRuntimeTool` operation:
211
+
212
+ ```ts
213
+ import {
214
+ defineDownloadTool,
215
+ defineUploadTool,
216
+ defineViewFileTool,
217
+ defineWaitTool,
218
+ } from 'stitchkit/tools'
219
+ import { createManagedFileBoundary } from 'stitchkit/files'
220
+ import { z } from 'zod'
221
+
222
+ const files = await createManagedFileBoundary({
223
+ root: '/srv/job-media',
224
+ createRoot: true, // creates only this final directory; /srv must already be trusted
225
+ inspectionTimeoutMs: 15_000,
226
+ inspect: ({ prefix, name, declaredMediaType, signal }) =>
227
+ inspectFile(prefix, { name, declaredMediaType, signal }),
228
+ })
229
+
230
+ const waitForJob = defineWaitTool({
231
+ name: 'wait_for_job',
232
+ description: 'Wait for a job to finish',
233
+ identity: { serviceName: 'jobs', action: 'waitForJob', scope: 'user' },
234
+ input: z.object({ id: z.string() }),
235
+ state: z.object({ id: z.string(), status: z.enum(['RUNNING', 'DONE']) }),
236
+ poll: ({ id }, context) => getJob(id, context.signal),
237
+ done: (state) => state.status === 'DONE',
238
+ backoff: [2, 3, 5],
239
+ defaultTimeout: 120,
240
+ })
241
+
242
+ const downloadResult = defineDownloadTool({
243
+ name: 'download_result',
244
+ description: 'Download a completed result',
245
+ identity: { serviceName: 'jobs', action: 'downloadResult', scope: 'user' },
246
+ input: z.object({ id: z.string() }),
247
+ resolveUrl: ({ id }) => resolveResultUrl(id),
248
+ files,
249
+ pathFromInput: ({ id }) => `results/${id}.bin`,
250
+ })
251
+
252
+ const uploadInput = defineUploadTool({
253
+ name: 'upload_input',
254
+ description: 'Upload a local input file',
255
+ identity: { serviceName: 'jobs', action: 'uploadInput', scope: 'user' },
256
+ output: z.object({ url: z.url() }),
257
+ files,
258
+ upload: (source, context) => uploadBytes(source.bytes, context.signal),
259
+ })
260
+
261
+ const viewResult = defineViewFileTool({
262
+ name: 'view_result',
263
+ description: 'Inspect generated media',
264
+ identity: { serviceName: 'jobs', action: 'viewResult', scope: 'user' },
265
+ // Local files are disabled when files is omitted. URL fetches retain SSRF
266
+ // protection; use allowPrivateHosts only for an explicitly trusted network.
267
+ files,
268
+ })
269
+
270
+ const runtimeTools = [waitForJob, downloadResult, uploadInput, viewResult]
271
+ ```
272
+
273
+ Managed factories return neutral validated data. Expected failures go through
274
+ the standard failed `ToolResult` path rather than masquerading as a successful
275
+ payload with `isError`. Wait sleep is abort-aware, guarded downloads receive the
276
+ active signal, and upload implementations receive it on their typed context.
277
+ Managed view-file accepts one or several paths/URLs, retains successful
278
+ multimodal content beside structured per-item `errors`, and charges every item
279
+ to one total 20 MB batch budget. Its MCP and Agent presenters are built in;
280
+ remote fetch cancellation follows the active call signal.
281
+
282
+ The older `mountWait`, `mountDownload`, `mountUpload` and `mountViewFile`
283
+ functions remain
284
+ intentional raw MCP adapters with their text-envelope behavior. Use them under
285
+ `rawTools` only when opting out of managed policy is deliberate; they share the
286
+ same neutral mechanics but do not gain lifecycle or hooks. The raw view-file
287
+ adapter preserves its content-only MCP envelope while using the same bounded
288
+ batch operation.
289
+
290
+ ### Async-operation protocol
291
+
292
+ For a complete long-running operation, define the linked runtime-only surface
293
+ once. Stitchkit owns transport names, validation and wait mechanics; the
294
+ application still owns storage, execution, retries and domain states:
295
+
296
+ ```ts
297
+ import {
298
+ createAsyncOperationSnapshotSchema,
299
+ defineAsyncOperation,
300
+ } from 'stitchkit/tools'
301
+
302
+ const id = z.object({ id: z.string() })
303
+ const state = z.object({
304
+ phase: z.enum(['pending', 'running', 'succeeded']),
305
+ value: z.string().optional(),
306
+ })
307
+ const snapshot = createAsyncOperationSnapshotSchema({
308
+ failure: z.object({ code: z.string() }),
309
+ progress: z.object({ current: z.number(), total: z.number() }),
310
+ })
311
+
312
+ const exportOperation = defineAsyncOperation({
313
+ mode: 'runtime-only',
314
+ name: 'export',
315
+ description: 'Export project data',
316
+ identity: { serviceName: 'exports', action: 'export', scope: 'user' },
317
+ startInput: z.object({ projectId: z.string() }),
318
+ id,
319
+ state,
320
+ snapshot,
321
+ start: ({ projectId }) => enqueueExport(projectId),
322
+ authorize: ({ id }, capability, ctx) => authorizeExport(id, capability, ctx),
323
+ inspect: ({ id }, ctx) => readExport(id, ctx.signal),
324
+ classify: (job) => ({ phase: job.phase }),
325
+ result: {
326
+ output: z.object({ value: z.string() }),
327
+ handler: (job) => ({ value: job.value ?? '' }),
328
+ },
329
+ })
330
+
331
+ const runtimeTools = exportOperation.runtimeTools
332
+ ```
333
+
334
+ #### Durable application-owned execution
335
+
336
+ The executable reference
337
+ [`durable-async-operation-harness.ts`](../../packages/core/examples/tools/durable-async-operation-harness.ts)
338
+ shows the complete boundary behind that surface. It composes
339
+ `defineAsyncOperationContract`, `defineAsyncOperation`, `createApplication`,
340
+ `createBoundedAdmission`, managed shutdown and `createAgentToolFenceLifecycle`
341
+ around an injected store and provider.
342
+
343
+ The store transactionally owns the idempotency key **and normalized request
344
+ hash**. Reusing both returns the existing operation; reusing the key with a
345
+ different hash conflicts. Every mutation is an expected-revision CAS. Before an
346
+ external call, the application persists a unique attempt/effect key and marks
347
+ the dispatch `possibly-dispatched`; a lost response is therefore reconciled by
348
+ that key after restart and is never treated as permission to submit the effect
349
+ again. Provider acknowledgement, progress, cancellation intent, result and
350
+ artifact references remain durable application state.
351
+
352
+ Agent tool fencing and operation idempotency are separate guarantees. The fence
353
+ prevents a stale run owner from crossing an effect boundary; the transactional
354
+ idempotency record makes a repeated current call converge on one operation.
355
+ Neither replaces the other.
356
+
357
+ Stitchkit deliberately does **not** own the durable queue, operation database,
358
+ lease renewal, provider retry/reconciliation protocol, asset catalog or domain
359
+ states. The process-local application resource stops admission and drains
360
+ accepted work; unresolved durable records survive shutdown for the next
361
+ recovery pass. The packed consumer lane executes this composition from the
362
+ published package on Bun and Node.
363
+
364
+ Every follow-up repeats `authorize`; an opaque id is never authority. Aborting
365
+ `wait` only stops waiting and never calls optional domain `cancel`.
366
+
367
+ For a new HTTP surface, derive the canonical capability contract once. The
368
+ factory defines schemas and routes only; the application still supplies normal
369
+ handlers to `implement` and owns the job:
370
+
371
+ ```ts
372
+ import { defineAsyncOperationContract } from 'stitchkit/tools'
373
+ import { z } from 'zod'
374
+
375
+ const operationId = z.object({ id: z.string() })
376
+ const operationSnapshot = z.object({
377
+ phase: z.enum(['pending', 'running', 'succeeded', 'failed', 'cancelled']),
378
+ })
379
+
380
+ const operations = defineAsyncOperationContract({
381
+ prefix: 'exports',
382
+ scope: 'user',
383
+ description: 'Export project data',
384
+ startInput: z.object({ projectId: z.string() }),
385
+ id: operationId,
386
+ snapshot: operationSnapshot,
387
+ cancel: true,
388
+ result: z.object({ downloadUrl: z.url() }),
389
+ })
390
+
391
+ // Pass operations.contract and ordinary handlers to implement(...).
392
+ // operations.capabilities/schemas/adapters are the canonical protocol metadata.
393
+ ```
394
+
395
+ If an existing dedicated contract has a different wire shape — for example
396
+ `start` returns a snapshot while follow-ups accept separate envelopes — bind it
397
+ without casts or duplicate endpoints. Inline callbacks are contextually typed;
398
+ every returned id/input is parsed by the destination schema:
399
+
400
+ ```ts
401
+ import { defineContract } from 'stitchkit/contract'
402
+ import { bindContractAsyncOperation } from 'stitchkit/tools'
403
+
404
+ const startOutput = z.object({ operation: operationId, acceptedAt: z.string() })
405
+ const statusInput = z.object({ operationId: z.string() })
406
+ const waitInput = z.object({ lookup: operationId })
407
+
408
+ const existing = defineContract({ prefix: 'exports' }, {
409
+ start: {
410
+ method: 'POST', path: '/', desc: 'Start export',
411
+ input: z.object({ projectId: z.string() }), output: startOutput,
412
+ },
413
+ status: {
414
+ method: 'POST', path: '/status', desc: 'Read export status',
415
+ input: statusInput, output: operationSnapshot,
416
+ },
417
+ wait: {
418
+ method: 'POST', path: '/wait', desc: 'Wait for export',
419
+ input: waitInput, output: operationSnapshot,
420
+ },
421
+ })
422
+
423
+ const operationHandlers = {
424
+ start: () => ({ operation: { id: 'example' }, acceptedAt: new Date().toISOString() }),
425
+ status: (): z.output<typeof operationSnapshot> => ({ phase: 'pending' }),
426
+ wait: (): z.output<typeof operationSnapshot> => ({ phase: 'succeeded' }),
427
+ }
428
+
429
+ const bound = bindContractAsyncOperation({
430
+ mode: 'contract-backed',
431
+ binding: 'adapted',
432
+ contract: existing,
433
+ id: operationId,
434
+ capabilities: { start: 'start', status: 'status', wait: 'wait' },
435
+ adapters: {
436
+ idFromStart: (output) => output.operation,
437
+ inputFor: {
438
+ status: (id) => ({ operationId: id.id }),
439
+ wait: (id) => ({ lookup: id }),
440
+ },
441
+ },
442
+ handlers: operationHandlers,
443
+ })
444
+ ```
445
+
446
+ Direct binding remains the short form when start already returns the id and
447
+ every follow-up reuses that exact schema instance. Its ID schema must be
448
+ wire-stable: input and output types match and parsing has no transform,
449
+ coercion, default or overwrite. This also excludes same-type transforms because
450
+ the direct adapters would parse an already parsed ID again. Use adapted binding
451
+ and explicitly project the parsed ID back into each follow-up input. In both
452
+ modes the binder creates no router;
453
+ it returns the existing contract, handlers and protocol metadata for
454
+ application composition.
455
+
456
+ ### Explicit raw SDK registration
457
+
458
+ `rawTools` is deliberately named as an escape hatch. A tool registered there
459
+ does **not** receive stitchkit schema policy, lifecycle, per-call context or
460
+ hooks. The built-in `mountViewFile`, `mountWait`, `mountDownload` and
461
+ `mountUpload` helpers remain raw for callers that choose that boundary; the
462
+ media helper fetches with SSRF and path-traversal defenses:
463
+
464
+ ```ts
465
+ import { createMcpHandler, mountViewFile } from 'stitchkit/tools'
466
+
467
+ const handleMcp = createMcpHandler({
468
+ serverInfo: { name: 'my-app', version: '1.0.0' },
469
+ auth,
470
+ services: [service],
471
+ rawTools: (server) => mountViewFile(server, { files }),
472
+ })
473
+ ```
474
+
475
+ Use raw registration only when opting out is intentional. For a protected
476
+ `view_file`, use `defineViewFileTool` in `runtimeTools`; it supplies the
477
+ canonical schemas, shared batch budget, structured partial failures and both
478
+ multimodal presenters. `resolveMedia` remains the single-item core for custom
479
+ operations whose contract intentionally differs.
480
+
481
+ ## Introspecting the complete tool surface
482
+
483
+ Deferred tool search, name snapshots and boot diagnostics accept the same
484
+ object-shaped surface as the mounts. Contract operations are followed by
485
+ runtime definitions, matching mount order; exposure filters and collisions are
486
+ resolved by Stitchkit rather than by consumer code:
487
+
488
+ ```ts
489
+ import {
490
+ buildToolManifest,
491
+ listToolNames,
492
+ summarizeTransports,
493
+ } from 'stitchkit/tools'
494
+
495
+ const surface = { services, runtimeTools: [renderPreview] }
496
+
497
+ const manifest = buildToolManifest({
498
+ ...surface,
499
+ transport: 'AGENT',
500
+ flattenUnionInput: true,
501
+ })
502
+
503
+ const names = listToolNames(surface)
504
+ const summary = summarizeTransports(surface)
505
+ ```
506
+
507
+ `buildToolManifest` returns the exact immutable presentation schema shown to
508
+ the selected MCP or Agent transport. It does not execute validation effects and
509
+ fails first on duplicate contract/runtime names. There is no runtime-only
510
+ manifest helper or public mount adapter: the framework owns merging and schema
511
+ projection.
512
+
513
+ Applications using Stitchkit's durable runtime can compose this manifest with
514
+ bounded per-run activation through `createDeferredAgentToolSurface` from
515
+ `stitchkit/agent-runtime`. It keeps selected calls as direct `mountAgent` tools
516
+ rather than routing them through a generic executor. Search receipts live in
517
+ ordinary durable tool-result history, so recovery restores activation and a
518
+ queued successor cannot inherit it. See
519
+ [Bounded deferred tool catalogs](./agent-runtime.md#bounded-deferred-tool-catalogs)
520
+ and ADR 0129. Raw `mountAgent`, `mountMcp` and `buildToolManifest` behavior is
521
+ unchanged.
522
+
523
+ `listToolNames` remains diagnostic and reports `kind: 'contract' | 'runtime'`
524
+ for every identity. `summarizeTransports` returns `contractServices`,
525
+ `runtimeTools`, aggregate `totals`, and a `sources` breakdown. Runtime tools
526
+ contribute only to MCP/Agent according to their `transports`; they never inflate
527
+ HTTP or CLI counts.
528
+
529
+ ## Logging tool calls — `createToolLogger`
530
+
531
+ Every tool mount fires an `afterToolCall` hook. `createToolLogger` is a ready
532
+ preset for it — one line logs each call (ok / failed, duration, which endpoint,
533
+ keyed by the endpoint's stable `serviceName` / `key` identity):
534
+
535
+ ```ts
536
+ import { createToolLogger } from 'stitchkit/tools'
537
+
538
+ mountMcp(server, services, { hooks: createToolLogger() })
539
+ // [tool] ok list_widgets (widgets.list) 12ms
540
+ // [tool] warn get_widget (widgets.get) NOT_FOUND 4ms
541
+ ```
542
+
543
+ By default the line goes to `console.error` — **stderr, never stdout**. That is
544
+ deliberate: in a stdio-MCP server stdout is the JSON-RPC protocol channel, and a
545
+ log line written there corrupts the stream. If you pass your own `log`, keep it
546
+ off stdout for any stdio deployment.
547
+
548
+ Pass `log` to redirect the line, or `onRecord` to feed a metrics sink the
549
+ structured `ToolCallRecord`. That record carries `traceId` whenever an
550
+ observability context is active, so a tool call made inside an HTTP request
551
+ joins that request's log line on one key — see
552
+ [Observability](./observability.md). For a boot-time picture of what is exposed
553
+ where, `summarizeTransports({ services, runtimeTools })` returns the mixed
554
+ per-transport counts for you to log.
555
+
556
+ ## One handler, three callers
557
+
558
+ A contract handler runs the same for an HTTP request, an MCP tool call and an
559
+ agent tool call. `ctx.source` (`'http'` · `'mcp'` · `'agent'`) tells it which —
560
+ the rest of the context (`params`, `input`, anything `context` injects) is
561
+ identical. Write the handler once; it serves every surface.
562
+
563
+ ==============================================================================
564
+ # API reference: `stitchkit/tools` (docs/api/reference.md)
565
+ ==============================================================================
566
+
567
+ ## `stitchkit/tools`
568
+
569
+ Server-only. Turns contracts into MCP and AI-agent tools. MCP server surfaces
570
+ need the `@modelcontextprotocol/server` v2 peer; MCP hosts/tests use the separate
571
+ `@modelcontextprotocol/client` package. Agent surfaces need the `ai` peer.
572
+
573
+ Framework-owned MCP tools advertise the exact declared output schema and return
574
+ the validated value unchanged as `structuredContent`, including arrays, scalars
575
+ and `null`. Tools without an output contract advertise and return no structured
576
+ payload.
577
+
578
+ | Export | Kind | Summary |
579
+ |--------|------|---------|
580
+ | `createMcpHandler` | function | a stateless dual-era Streamable-HTTP MCP handler — [guide](../guide/mcp-and-agents.md#mcp--createmcphandler) |
581
+ | `createMcpHttpRoute` | function | framework-owned `RawRoute` adapter for an MCP HTTP handler |
582
+ | `createStdioMcpServer` | function | a complete stdio MCP server — [guide](../guide/mcp-and-agents.md#mcp-over-stdio--createstdiomcpserver) |
583
+ | `bindStdioProcessSignals` | function | explicitly bind OS signals to one close-only stdio handle — [guide](../guide/testing-and-deployment.md#stdio-process-signals) |
584
+ | `buildMcpServer` | function | build an `McpServer` from contract/runtime surfaces; no-auth configs omit the second argument |
585
+ | `mountMcp` | function | add contract tools to an existing `McpServer` — [guide](../guide/mcp-and-agents.md#mountmcp) |
586
+ | `mountAgent` | function | a Vercel AI SDK `ToolSet` from a service; failed executions reject through the SDK tool-error channel with a safe typed envelope, while successful output is never classified by field name — [guide](../guide/mcp-and-agents.md#ai-agents--mountagent) |
587
+ | `defineRuntimeTool` | function | define one validated pathless operation for explicit MCP, Agent and/or CLI surfaces — [guide](../guide/mcp-and-agents.md#pathless-runtime-tools-and-multimodal-results) |
588
+ | `createRuntimeToolFactory` | function | bind shared identity and Zod-validated per-call context for runtime tools — [guide](../guide/mcp-and-agents.md#pathless-runtime-tools-and-multimodal-results) |
589
+ | `createToolInvoker` | function | compile an exposure-aware in-process dispatcher over the canonical tool runner; use peer-free `stitchkit/tools/invoker`, or the full `stitchkit/tools` adapter barrel — [guide](../guide/mcp-and-agents.md#in-process-calls--createtoolinvoker) |
590
+ | `createToolkit` | function | context-typed tool mounts — [guide](../guide/cli.md#typed-context) |
591
+ | `mountViewFile` | function | a native multimodal "view file" MCP tool |
592
+ | `resolveMedia` | function | resolve a media reference for a tool result |
593
+ | `validateMcpSchemas` | function | object-shaped assertion over the exact advertised schema surface — compatibility, typed properties and portable formats ([guide](../guide/mcp-and-agents.md#mcp-schema-validation-profile)) |
594
+ | `listToolNames` | function | every contract/runtime tool name with origin, identity and transports — for stable snapshots — [guide](../guide/mcp-and-agents.md#pinning-tool-names--listtoolnames) |
595
+ | `listContractToolNames` | function | the same listing straight from contracts — no handlers or stub services needed |
596
+ | `describeToolCatalog` | function | inspect the exact model-facing names, source identities, schema byte sizes and deferred state; an explicit total byte budget fails closed |
597
+ | `ToolCatalogConfig` / `ToolCatalogEntry` | _type_ | catalog source, transport, optional explicit schema budget and one inspectable result row |
598
+ | `McpHandlerConfig` | _type_ | server surface plus stateless HTTP transport config |
599
+ | `McpHttpConfig` | _type_ | HTTP auth, protected-resource, legacy-era and security options |
600
+ | `McpHttpHandler` | _type_ | framework-owned `{ fetch(request), close() }` lifecycle |
601
+ | `McpHttpSecurityConfig` | _type_ | Fetch-boundary Host and Origin allowlists |
602
+ | `McpLegacyPolicy` | _type_ | `'serve' \| 'reject'` protocol-era compatibility policy |
603
+ | `McpStdioHandle` | _type_ | closeable official stdio transport handle |
604
+ | `StdioMcpServerConfig` | _type_ | config for `createStdioMcpServer` |
605
+ | `StdioCloseTarget` | _type_ | minimal close-only target accepted by `bindStdioProcessSignals` |
606
+ | `StdioProcessSignalsOptions` | _type_ | signal source, close callbacks and phased error reporting |
607
+ | `StdioProcessSignalsBinding` | _type_ | close-only signal binding with observed `promise` and listener `close()` |
608
+ | `StdioProcessSignalsErrorPhase` | _type_ | `'prepare' \| 'close' \| 'complete'` reporting phase |
609
+ | `McpServerBuildConfig` | _type_ | shared config for `buildMcpServer` |
610
+ | `McpServerSharedConfig` | _type_ | transport-neutral options shared by direct and finite surface configs |
611
+ | `McpServer` | _type_ | official split-SDK server instance accepted by raw extension points |
612
+ | `DirectMcpSurfaceConfig` | _type_ | static or identity-dynamic `services` / `runtimeTools` source |
613
+ | `FiniteMcpSurfaceConfig` | _type_ | bounded `surfaces` registry plus typed selector |
614
+ | `McpSurfaceDefinition` | _type_ | one immutable `{ services, runtimeTools }` MCP surface |
615
+ | `McpSurfaceRegistry` | _type_ | finite keyed surface registry for eager preparation |
616
+ | `StdioAuthConfig` | _type_ | startup identity composed into `StdioMcpServerConfig` |
617
+ | `McpMountConfig` | _type_ | config for `mountMcp` |
618
+ | `McpSchemaValidationConfig` | _type_ | shared `{ policy, requireTypedProperties, allowUntyped, requirePortableFormats, allowFormats }` profile |
619
+ | `ValidateMcpSchemasConfig` | _type_ | standalone validation profile plus `services`, `extend`, flattening and logger |
620
+ | `RuntimeToolDefinition` | _type_ | transport-neutral pathless operation with identity, schemas, handler and optional presenters |
621
+ | `RuntimeToolDefinitionBase` | _type_ | common name, identity, input, exposure and MCP metadata fields |
622
+ | `RuntimeToolDefinitionWithOutput` | _type_ | runtime definition whose handler and presenters share a validated output type |
623
+ | `RuntimeToolDefinitionWithoutOutput` | _type_ | runtime definition with a void handler and no presentation callbacks |
624
+ | `RuntimeToolFactory` | _type_ | identity/context-bound runtime-tool definition factory |
625
+ | `RuntimeToolFactoryConfig` | _type_ | factory service identity and context schema |
626
+ | `RuntimeToolFactoryDefinitionWithOutput` | _type_ | factory-authored runtime tool with a validated output schema |
627
+ | `RuntimeToolFactoryDefinitionWithoutOutput` | _type_ | factory-authored void runtime tool without presenters |
628
+ | `RuntimeToolFactoryHandlerContext` | _type_ | parsed factory context plus parsed tool input |
629
+ | `RuntimeToolFactoryIdentityFields` | _type_ | per-tool action, semantic method and optional identity metadata |
630
+ | `RuntimeToolIdentity` | _type_ | `{ serviceName, action, scope?, method, meta? }` for runtime lifecycle/audit |
631
+ | `RuntimeToolHandlerContext` | _type_ | runtime context with the definition's parsed input |
632
+ | `RuntimeToolOutput` | _type_ | output inferred from a runtime tool's optional Zod schema |
633
+ | `RuntimeToolPresenters` | _type_ | optional MCP and AI SDK `toModelOutput` presentation callbacks |
634
+ | `RuntimeMcpPresentation` | _type_ | MCP content/metadata result without framework-owned `structuredContent` or `isError` |
635
+ | `RuntimeMcpInput` | _type_ | typed accepted multi-round input for an opted-in runtime tool |
636
+ | `OAuthClientRegistrationConfig` | _type_ | deterministic pre-registered → CIMD → explicit-DCR client resolution |
637
+ | `CimdClientMetadata` | _type_ | validated Client ID Metadata Document |
638
+ | `CimdClientMetadataFetcher` | _type_ | injectable secure network boundary for metadata loading |
639
+ | `CimdFetchResponse` | _type_ | bounded metadata fetch result passed across the injectable network boundary |
640
+ | `CimdFetchPolicy` | _type_ | CIMD timeout, redirect and size limits |
641
+ | `CimdCachePolicy` | _type_ | bounded HTTP-aware cache policy: separate positive/negative pools (`maxEntries`), per-client and server-wide resolution rate limits (`maxResolutionsPerClient` / `maxResolutions` per `resolutionWindowMs`) |
642
+ | `CimdCacheEvent` | _type_ | observable CIMD cache hit, miss, revalidation and eviction event |
643
+ | `createSecureClientMetadataFetcher` | function | production HTTPS, DNS/IP-pinned CIMD fetcher |
644
+ | `RuntimeAgentModelOutput` | _type_ | AI SDK model-facing text/JSON/content output returned by `present.agent` |
645
+ | `AgentMountConfig` | _type_ | config for `mountAgent` |
646
+ | `AgentToolRegistry` / `AgentToolRegistryBuilder` / `AgentToolRegistryInput` | _type_ | the composed runtime surface and its builder: declared defaults, `replace`/`disable` by name, and the exact `{ tools, names }` a mount receives |
647
+ | `defineToolRegistry` | function | compose runtime tools over one declared default set; an unknown `replace`/`disable` name is refused instead of silently leaving the default in place |
648
+ | `AgentContext` | _type_ | the context merged into agent tool handlers |
649
+ | `Toolkit` | _type_ | the context-pinned tool surface from `createToolkit` |
650
+ | `ToolExtend` | _type_ | extra-args extension for `mountMcp` / `mountAgent` |
651
+ | `ToolLifecycle` | _type_ | `beforeHandle` / `afterHandle` gate for tool calls — [guide](../guide/mcp-and-agents.md#guarding-tools--lifecycle) |
652
+ | `ToolExecutionControlReason` | _type_ | internal managed-execution stop reason: stale run or requested interruption |
653
+ | `ToolExecutionControlError` | class | control-flow error used to unwind a superseded managed tool call without presenting it as a model-facing tool failure |
654
+ | `isToolExecutionControlError` | function | narrow an unknown thrown value to the managed execution control error |
655
+ | `ToolOperation` | _type_ | executable path-free operation shape shared by contract and framework-native runners |
656
+ | `ToolCallHooks` | _type_ | object-shaped `beforeToolCall` / `afterToolCall` / `onToolError` observability hooks; the raw thrown value reaches the last two as `error` ([guide](../guide/observability.md#the-cause-behind-a-failed-tool-call)) |
657
+ | `BeforeToolCallOptions` | _type_ | `{ toolName, args, context, endpoint }` passed before execution |
658
+ | `AfterToolCallOptions` | _type_ | completed call options plus `{ result, durationMs, error? }` |
659
+ | `ToolErrorOptions` | _type_ | `{ toolName, error, context, endpoint }` for a thrown handler-path value |
660
+ | `ErrorHintFn` | _type_ | `(toolName, errorCode) => string \| null` — a per-tool recovery hint, shared by every mount |
661
+ | `ToolResult` | _type_ | the result of one tool call |
662
+ | `ToolInvoker` | _type_ | immutable compiled dispatcher (`names`, envelope `invoke`, throwing `invokeOrThrow`) |
663
+ | `ToolInvokerConfig` | _type_ | compile-time exposure, extension and presentation options |
664
+ | `ToolInvocationOptions` | _type_ | per-call source, context, lifecycle, hooks and output-strip reporter |
665
+ | `ToolCallContext` | _type_ | the context every tool hook receives — `{ source, mcp? }` plus whatever the mount's `context` added |
666
+ | `ViewFileOptions` | _type_ | shared URL/managed-file-boundary policy for `defineViewFileTool`, `mountViewFile` and `resolveMedia` |
667
+ | `ViewFileOutput` | _type_ | neutral managed batch result with multimodal `content` and per-item `errors` |
668
+ | `ViewFileInputSchema` | constant | fixed one-or-many media path/URL input schema |
669
+ | `ViewFileOutputSchema` | constant | Zod schema for the neutral managed view-file batch result |
670
+ | `ViewFileErrorSchema` | constant | Zod schema for one structured per-item view failure |
671
+ | `McpAnnotations` | _type_ | MCP annotations on a media result |
672
+ | `McpAnnotationsSchema` | constant | Zod schema for MCP media annotations |
673
+ | `McpMediaContentSchema` | constant | Zod schema for text/image/audio media content |
674
+ | `CollectToolsConfig` | _type_ | options for `collectTools` |
675
+ | `findUntypedProperties` | function | every property in a JSON Schema with no `type`/`enum`/`$ref` — what a model is shown and cannot obey ([guide](../guide/mcp-and-agents.md)) |
676
+ | `UntypedProperty` | _type_ | one such property — `{ path, description? }` |
677
+ | `findNonPortableFormats` | function | deep finder for formats outside the portable MCP/AJV baseline |
678
+ | `NonPortableFormat` | _type_ | one `{ path, format }` portability finding |
679
+ | `PORTABLE_JSON_SCHEMA_FORMATS` | constant | portable-format baseline used by MCP validation |
680
+ | `ToolNameEntry` | _type_ | one `listToolNames` row — `{ kind, name, service, method, transports }` |
681
+ | `IncompatibleSchemaPolicy` | _type_ | `'throw' \| 'skip' \| 'warn'` |
682
+ | `McpMediaContent` | _type_ | a multimodal MCP content item |
683
+
684
+ ### Native tools
685
+
686
+ Generic host-supplied operations — managed definitions for the canonical
687
+ runtime-tool runner, plus deliberate raw MCP adapters over the same mechanics.
688
+
689
+ | Export | Kind | Summary |
690
+ |--------|------|---------|
691
+ | `defineDownloadTool` | function | define a guarded, size-capped managed download for MCP/Agent `runtimeTools` |
692
+ | `defineUploadTool` | function | define a typed managed local-file upload for MCP/Agent `runtimeTools` |
693
+ | `defineWaitTool` | function | define a typed, cancellable managed polling operation for MCP/Agent `runtimeTools` |
694
+ | `defineViewFileTool` | function | define a guarded, batch-capped managed multimodal operation for MCP/Agent `runtimeTools` |
695
+ | `DefineDownloadToolConfig` | _type_ | Zod input, stable identity, URL resolver, storage policy and presenters for `defineDownloadTool` |
696
+ | `DefineUploadToolConfig` | _type_ | stable identity, typed output, upload callback and presenters for `defineUploadTool` |
697
+ | `DefineWaitToolConfig` | _type_ | Zod input/state, identity, poll/done/timeout policy and presenters for `defineWaitTool` |
698
+ | `DefineViewFileToolConfig` | _type_ | identity, media security policy and optional presenters for `defineViewFileTool` |
699
+ | `ManagedNativeToolConfig` | _type_ | shared name, description, identity, exposure and annotations for managed native factories |
700
+ | `NativeToolIdentity` | _type_ | pathless service/action/scope/meta identity; semantic method is factory-owned |
701
+ | `ManagedWaitRender` | _type_ | optional managed wait terminal text and failure classification |
702
+ | `UploadToolInputSchema` | constant | fixed `{ path: string }` input schema for `defineUploadTool` |
703
+ | `defineAsyncOperation` | function | runtime-only start/status/wait plus configured cancel/result/artifacts definitions; see the [durable application-owned recipe](../guide/mcp-and-agents.md#durable-application-owned-execution) |
704
+ | `defineAsyncOperationContract` | function | define one canonical Zod-first HTTP contract for start/status/wait plus optional capabilities; execution and recovery remain application-owned |
705
+ | `bindContractAsyncOperation` | function | bind literal methods from an existing contract without creating another HTTP surface |
706
+ | `createAsyncOperationSnapshotSchema` | function | canonical pending/running/succeeded/failed/cancelled Zod snapshot |
707
+ | `AsyncOperationSnapshotSchema` | _type_ | the snapshot union `createAsyncOperationSnapshotSchema` returns when no `progress` schema is configured |
708
+ | `AsyncOperationSnapshotSchemaWithProgress` | _type_ | the same union with the configured `progress` schema optional on every phase |
709
+ | `AsyncOperationCancelResultSchema` | constant | validated accepted/already_terminal/rejected cancellation result |
710
+ | `AsyncOperationCancelResult` | _type_ | validated cancel capability result |
711
+ | `AsyncOperationCancelCapability` | _type_ | optional typed domain cancellation callback |
712
+ | `AsyncOperationCapability` | _type_ | generated capability-name union |
713
+ | `AsyncOperationStartDefinition` / `AsyncOperationFollowDefinition` | _type_ | generated runtime definition types |
714
+ | `AsyncOperationIdentity` | _type_ | shared service/action/scope/meta identity for an operation |
715
+ | `AsyncOperationOutputCapability` | _type_ | optional result/artifact schema plus handler |
716
+ | `RuntimeAsyncOperationConfig` | _type_ | runtime-only descriptor configuration |
717
+ | `RuntimeAsyncOperation` | _type_ | inferred generated definitions and schemas |
718
+ | `AsyncOperationContractConfig` | _type_ | canonical contract config where start returns the operation id; optional `expose` names the transports per capability, because this contract is built inside the framework and never passes through a consumer's `toolExposure: 'explicit'` factory |
719
+ | `AsyncOperationContractWithStartOutputConfig` | _type_ | canonical contract config with an application start envelope and typed id extractor |
720
+ | `DefinedAsyncOperationContract` | _type_ | generated contract, capability keys, schemas and parsed adapters |
721
+ | `ContractAsyncOperationConfig` | _type_ | literal contract method binding and handlers |
722
+ | `AdaptedContractAsyncOperationConfig` | _type_ | existing-contract binding with explicit id and per-capability input adapters |
723
+ | `BoundAdaptedContractAsyncOperation` | _type_ | inferred adapted binding with parsed id/input projectors |
724
+ | `AdaptedContractAsyncOperationStartKey` | _type_ | existing-contract keys with a declared start output |
725
+ | `AdaptedContractAsyncOperationFollowKey` | _type_ | existing-contract keys with both input and output schemas |
726
+ | `AdaptedContractAsyncOperationWaitKey` | _type_ | adapted follow-up keys whose output matches the selected status snapshot |
727
+ | `ContractAsyncOperationInputAdapters` | _type_ | guaranteed direct-binding status/wait input adapters plus configured optional capabilities |
728
+ | `ContractAsyncOperationKeys` | _type_ | literal method-key union of a bound contract |
729
+ | `ContractAsyncOperationStartKey` | _type_ | direct-binding start keys whose declared ID schema has stable input/output |
730
+ | `ContractAsyncOperationFollowKey` | _type_ | contract keys whose input schema type matches the selected start output |
731
+ | `ContractAsyncOperationWaitKey` | _type_ | follow-up keys whose output schema type also matches the selected status output |
732
+ | `composeToolLifecycle` | function | ordered composition of tool before/after phases |
733
+ | `mountDownload` | function | raw MCP "download a URL to disk" adapter (SSRF-guarded, size-capped) |
734
+ | `mountUpload` | function | raw MCP "upload a local file" adapter |
735
+ | `mountWait` | function | raw MCP generic `--wait`-style polling adapter |
736
+ | `DownloadToolConfig` | _type_ | config for `mountDownload` |
737
+ | `UploadToolConfig` | _type_ | config for `mountUpload` |
738
+ | `WaitToolConfig` | _type_ | config for `mountWait` |
739
+
740
+ ### OAuth 2.1 provider
741
+
742
+ A native remote-connector auth surface for MCP — [guide](../guide/mcp-and-agents.md#oauth-21--a-native-remote-connector).
743
+
744
+ | Export | Kind | Summary |
745
+ |--------|------|---------|
746
+ | `mountOAuthProvider` | function | the OAuth 2.1 provider routes (DCR, PKCE, token) |
747
+ | `oauthProtectedResourceRoute` | function | the RFC 9728 protected-resource-metadata route |
748
+ | `protectedResourceMetadataUrl` | function | build the metadata URL for a resource |
749
+ | `wwwAuthenticateHeader` | function | build the `WWW-Authenticate` challenge header |
750
+ | `PROTECTED_RESOURCE_PATH` | const | the well-known metadata path |
751
+ | `OAuthProviderConfig` | _type_ | config for `mountOAuthProvider` |
752
+ | `ProtectedResourceConfig` | _type_ | config for `oauthProtectedResourceRoute` |
753
+ | `ApplicationType` | _type_ | DCR `application_type` — `'native'` (loopback allowed) \| `'web'` (https only) |
754
+ | `AuthCodeData` | _type_ | a stored authorization-code record |
755
+ | `AuthRequest` | _type_ | a parsed authorization request |
756
+ | `ClientMetadata` | _type_ | dynamic-client-registration metadata |
757
+ | `RefreshData` | _type_ | a stored refresh-token record |
758
+ | `RegisteredClient` | _type_ | a registered OAuth client |
759
+
760
+ ### Durable tool bodies
761
+
762
+ A mounted tool body can be made restartable without adopting `agent-runtime`: declare a
763
+ factory and `step` / `sleep` / `waitFor` appear in the handler context, backed by whatever
764
+ ledger the application already has.
765
+
766
+ ```ts
767
+ mountAgent(services, { durability: (toolCallId) => myLedgerFor(toolCallId) });
768
+ ```
769
+
770
+ | Export | Kind | Summary |
771
+ |--------|------|---------|
772
+ | `ToolDurability` | _type_ | the port a tool body needs: `step`, `sleep`, `waitFor` |
773
+ | `ToolDurabilityFactory` | _type_ | `(toolCallId, signal) => ToolDurability`, called once per call |
774
+ | `DurableJsonValue` | _type_ | what a durable step result may hold — a record is read back in another process, so it must be JSON |
775
+ | `createLocalStepDurability` | function | the durability engine — replay, absolute deadlines, park/deliver — over a two-method ledger the application owns |
776
+ | `StepDurabilityLedger` | _type_ | the two methods an engine needs: `appendEvent`, `readEvents` |
777
+ | `LocalStepDurability` | _type_ | what the engine returns; satisfies `ToolDurability` and adds `deliver` and record introspection for the ledger's owner |
778
+ | `LocalStepDurabilityOptions` | _type_ | `{ store, conversationId, runId, signal?, subscribe?, clock? }` |
779
+ | `AppendAgentStoreEvent` / `ReadAgentStoreEvents` / `AgentStoreEventEnvelope` / `AgentStoreEventPage` | _type_ | the ledger's row shapes, re-exported so a ledger is typed from the entrypoint that consumes it |
780
+ | `AgentToolError` | class | the model-safe envelope a failed agent tool throws |
781
+ | `isAgentToolError` | function | brand check for it — a consumer running its own loop no longer parses the message |
782
+
783
+ ### Catalog stamp
784
+
785
+ Every advertised tool and every tool result carries the fingerprint of the catalog it came
786
+ from, so a long-lived consumer can see that its own copy is stale **without making a
787
+ request for it**. `createMcpHandler` is stateless by construction and therefore has no
788
+ retained session to push `notifications/tools/list_changed` down; the stamp needs none.
789
+
790
+ Store the stamp beside the tools when you list them, compare it against the one on every
791
+ result, and re-list when they differ — including on a refusal, which is exactly when a
792
+ stale catalog is the likeliest explanation and the least visible one. The server side
793
+ needs no wiring: every mount stamps what it advertises.
794
+
795
+ | Export | Kind | Summary |
796
+ |--------|------|---------|
797
+ | `readMcpCatalogStamp` | function | read a peer's stamp out of `_meta`, or `null` when there is none |
798
+ | `mcpCatalogMeta` | function | the `_meta` fragment a stamped tool or result carries |
799
+ | `MCP_CATALOG_META_KEY` | const | the namespaced `_meta` key (`stitchkit/catalog`) |
800
+ | `McpCatalogStamp` | _type_ | `{ digest, tools }` — the catalog fingerprint and its tool count |
801
+
802
+ ### MCP Apps (widgets)
803
+
804
+ Interactive MCP resources — [ADR 0019](../decisions/0019-generic-native-tools.md).
805
+
806
+ | Export | Kind | Summary |
807
+ |--------|------|---------|
808
+ | `mountMcpResource` | function | mount an MCP Apps widget resource |
809
+ | `inlineMcpAppBundle` | function | inline a built widget bundle into a resource |
810
+ | `EXT_APPS_BUNDLE_PLACEHOLDER` | const | the placeholder token `inlineMcpAppBundle` replaces |
811
+ | `RESOURCE_MIME_TYPE` | const | the MCP Apps resource MIME type |
812
+ | `McpResourceDef` | _type_ | an MCP Apps resource definition |
813
+ | `McpAppResourceMeta` | _type_ | resource `_meta` for an MCP App |
814
+ | `McpAppCsp` | _type_ | the widget content-security policy |
815
+
816
+ ### Introspection & internals
817
+
818
+ Advanced building blocks — the shared machinery the mounts are built on.
819
+
820
+ | Export | Kind | Summary |
821
+ |--------|------|---------|
822
+ | `collectTools` | function | resolve a service's methods to mountable tools (the shared resolver) |
823
+ | `createToolLogger` | function | a ready `afterToolCall` that logs every tool call — [guide](../guide/mcp-and-agents.md#logging-tool-calls--createtoollogger) |
824
+ | `summarizeTransports` | function | mixed contract/runtime operation counts and per-source breakdown for a boot-time summary |
825
+ | `buildToolManifest` | function | transport-aware searchable `{ name, description, inputSchema }` rows from a mixed surface |
826
+ | `ToolLoggerConfig` | _type_ | config for `createToolLogger` |
827
+ | `ToolCallRecord` | _type_ | the structured record `createToolLogger` passes to `onRecord` |
828
+ | `TransportSummary` | _type_ | `{ contractServices, runtimeTools, totals, sources }` from `summarizeTransports` |
829
+ | `TransportCounts` | _type_ | per-transport counts (`{ HTTP, MCP, AGENT, CLI }`) |
830
+ | `ToolSurfaceDefinition` | _type_ | shared object-shaped `{ services?, runtimeTools? }` introspection surface |
831
+ | `ToolManifestConfig` | _type_ | mixed surface plus required model-facing `transport` and presentation options |
832
+ | `coerceJsonArgs` | function | coerce JSON-stringified array/object tool arguments |
833
+ | `flattenToolJsonSchema` | function | project structurally identifiable discriminated unions into conservative object joins; divergent fields retain every provable base kind in a deterministic `type` array, and the projection never executes validation |
834
+ | `ToolPresentationSchema` | _type_ | immutable model-facing JSON Schema document shared by tool transports |
835
+ | `MountableTool` | _type_ | one operation with separate executable CLI argument schema and model-facing presentation schema |
836
+ | `ToolManifestEntry` | _type_ | one `buildToolManifest` row |
837
+
838
+ ---