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,942 @@
1
+ import {
2
+ ApplicationIdSchema,
3
+ ApplicationShutdownResultSchema,
4
+ ApplicationSnapshotSchema
5
+ } from "./index-3gye9wzb.js";
6
+ import {
7
+ managedResourceDependencyId
8
+ } from "./index-2k4yrqkc.js";
9
+ import {
10
+ ShutdownOptionsSchema
11
+ } from "./index-3z73fh2c.js";
12
+ import {
13
+ AppError
14
+ } from "./index-2vtcmrj9.js";
15
+
16
+ // src/application/kernel-contract.ts
17
+ import { z } from "zod";
18
+ var ApplicationShutdownOptionsSchema = ShutdownOptionsSchema.pick({
19
+ gracePeriodMs: true,
20
+ forceTimeoutMs: true,
21
+ signal: true
22
+ });
23
+ var ApplicationShutdownBudgetSchema = ShutdownOptionsSchema.pick({
24
+ gracePeriodMs: true,
25
+ forceTimeoutMs: true
26
+ });
27
+ var ApplicationRestartInputSchema = z.object({
28
+ resourceId: z.string().min(1),
29
+ gracePeriodMs: z.number().int().nonnegative().optional(),
30
+ forceTimeoutMs: z.number().int().nonnegative().optional()
31
+ }).strict().readonly();
32
+ var ApplicationRestartOutcomeSchema = z.enum(["restarted", "failed", "refused"]);
33
+ var ApplicationRestartResultSchema = z.object({
34
+ resourceId: z.string(),
35
+ affected: z.array(z.string()).readonly(),
36
+ outcome: ApplicationRestartOutcomeSchema,
37
+ reason: z.string().optional(),
38
+ durationMs: z.number().int().nonnegative()
39
+ }).strict().readonly();
40
+
41
+ class ApplicationAdmissionError extends AppError {
42
+ constructor() {
43
+ super("APPLICATION_NOT_ACCEPTING", "Application is not accepting new operations", 503);
44
+ this.name = "ApplicationAdmissionError";
45
+ }
46
+ }
47
+
48
+ // src/application/graph.ts
49
+ function resolveResourceGraph(resources) {
50
+ const entries = resources.map((resource, declarationIndex) => ({
51
+ resource,
52
+ id: ApplicationIdSchema.parse(resource.id),
53
+ dependsOn: [...resource.dependsOn ?? []].map((dependency) => ApplicationIdSchema.parse(managedResourceDependencyId(dependency))),
54
+ required: resource.required ?? true,
55
+ declarationIndex
56
+ }));
57
+ const byId = new Map;
58
+ for (const entry of entries) {
59
+ if (byId.has(entry.id)) {
60
+ throw new Error(`[stitchkit] createApplication: duplicate resource id "${entry.id}"`);
61
+ }
62
+ byId.set(entry.id, entry);
63
+ }
64
+ for (const entry of entries) {
65
+ for (const dependencyId of entry.dependsOn) {
66
+ const dependency = byId.get(dependencyId);
67
+ if (!dependency) {
68
+ throw new Error(`[stitchkit] createApplication: resource "${entry.id}" depends on missing resource "${dependencyId}"`);
69
+ }
70
+ if (entry.required && !dependency.required) {
71
+ throw new Error(`[stitchkit] createApplication: required resource "${entry.id}" cannot depend on optional resource "${dependencyId}"`);
72
+ }
73
+ }
74
+ }
75
+ const pending = new Map(entries.map((entry) => [entry.id, entry]));
76
+ const resolved = new Set;
77
+ const ordered = [];
78
+ while (pending.size > 0) {
79
+ const ready = [...pending.values()].filter((entry) => entry.dependsOn.every((id) => resolved.has(id))).sort((left, right) => left.declarationIndex - right.declarationIndex);
80
+ if (ready.length === 0) {
81
+ throw new Error(`[stitchkit] createApplication: resource dependency cycle: ${[...pending.keys()].join(", ")}`);
82
+ }
83
+ for (const entry of ready) {
84
+ pending.delete(entry.id);
85
+ resolved.add(entry.id);
86
+ ordered.push(entry);
87
+ }
88
+ }
89
+ return ordered;
90
+ }
91
+
92
+ // src/application/kernel-state.ts
93
+ class ResourceCompletionBeforeReadyError extends Error {
94
+ constructor(resourceId, cause) {
95
+ super(`[stitchkit] resource "${resourceId}" completed before reaching readiness`, {
96
+ ...cause !== undefined && { cause }
97
+ });
98
+ this.name = "ResourceCompletionBeforeReadyError";
99
+ }
100
+ }
101
+
102
+ class ApplicationStartupInterruptedError extends Error {
103
+ constructor() {
104
+ super("[stitchkit] application startup interrupted by shutdown");
105
+ this.name = "ApplicationStartupInterruptedError";
106
+ }
107
+ }
108
+ function isStartResult(value) {
109
+ return typeof value === "object" && value !== null;
110
+ }
111
+ function waitForAbort(signal) {
112
+ if (signal.aborted)
113
+ return Promise.resolve();
114
+ return new Promise((resolve) => signal.addEventListener("abort", () => resolve(), { once: true }));
115
+ }
116
+ async function untilDeadline(work, signal) {
117
+ const result = await Promise.race([
118
+ work.then((value) => ({ settled: true, value }), (error) => ({ settled: true, error })),
119
+ waitForAbort(signal).then(() => ({ settled: false }))
120
+ ]);
121
+ return result;
122
+ }
123
+ function createKernelState(config) {
124
+ const id = ApplicationIdSchema.parse(config.id);
125
+ const ordered = resolveResourceGraph(config.resources ?? []);
126
+ const shutdownBudget = ApplicationShutdownBudgetSchema.parse(config.shutdown ?? {});
127
+ const reverse = [...ordered].reverse();
128
+ const records = new Map;
129
+ for (const entry of ordered) {
130
+ records.set(entry.id, {
131
+ entry,
132
+ state: "registered",
133
+ health: "unknown",
134
+ healthReported: false,
135
+ everHealthy: false,
136
+ attempted: false,
137
+ activated: false,
138
+ closeInvoked: false,
139
+ closed: false,
140
+ failures: []
141
+ });
142
+ }
143
+ return {
144
+ id,
145
+ config,
146
+ ordered,
147
+ reverse,
148
+ shutdownBudget,
149
+ published: new Map,
150
+ records,
151
+ epoch: crypto.randomUUID(),
152
+ listeners: new Set,
153
+ lifetimeAbort: new AbortController,
154
+ startupAbort: new AbortController,
155
+ lifecycle: "created",
156
+ revision: 0,
157
+ changedAt: new Date().toISOString(),
158
+ accepting: false,
159
+ accepted: 0,
160
+ completed: 0,
161
+ pending: 0,
162
+ startPromise: undefined,
163
+ shutdownPromise: undefined,
164
+ shutdownRequested: false,
165
+ activationComplete: false,
166
+ pendingWaiters: new Set,
167
+ restartingIds: [],
168
+ restarting: Promise.resolve()
169
+ };
170
+ }
171
+ function recordOf(state, resourceId) {
172
+ const record = state.records.get(resourceId);
173
+ if (!record)
174
+ throw new Error("Managed resource record disappeared");
175
+ return record;
176
+ }
177
+ function reportFailure(state, resourceId, phase, error) {
178
+ const config = state.config;
179
+ if (!config.onResourceFailure)
180
+ return;
181
+ try {
182
+ Promise.resolve(config.onResourceFailure({ resourceId, phase, error })).catch(() => {
183
+ return;
184
+ });
185
+ } catch {}
186
+ }
187
+ function aggregateHealth(state) {
188
+ if (state.lifecycle === "created" || state.lifecycle === "starting")
189
+ return "unknown";
190
+ let optionalUnhealthy = false;
191
+ for (const record of state.records.values()) {
192
+ if (record.entry.required && (record.state !== "ready" || record.health !== "healthy")) {
193
+ return "unhealthy";
194
+ }
195
+ if (!record.entry.required && (record.state !== "ready" || record.health !== "healthy")) {
196
+ optionalUnhealthy = true;
197
+ }
198
+ }
199
+ return optionalUnhealthy ? "degraded" : "healthy";
200
+ }
201
+ function isReady(state) {
202
+ return state.lifecycle === "ready" && [...state.records.values()].every((record) => !record.entry.required || record.state === "ready" && record.health === "healthy");
203
+ }
204
+ function snapshot(state) {
205
+ return ApplicationSnapshotSchema.parse({
206
+ id: state.id,
207
+ epoch: state.epoch,
208
+ revision: state.revision,
209
+ lifecycle: state.lifecycle,
210
+ health: aggregateHealth(state),
211
+ ready: isReady(state),
212
+ capturedAt: new Date().toISOString(),
213
+ changedAt: state.changedAt,
214
+ admission: {
215
+ accepting: state.accepting,
216
+ accepted: state.accepted,
217
+ completed: state.completed,
218
+ pending: state.pending
219
+ },
220
+ restarting: [...state.restartingIds],
221
+ resources: state.ordered.map((entry) => {
222
+ const record = recordOf(state, entry.id);
223
+ return {
224
+ id: entry.id,
225
+ required: entry.required,
226
+ dependsOn: entry.dependsOn,
227
+ state: record.state,
228
+ health: record.health,
229
+ ready: record.state === "ready" && record.health === "healthy"
230
+ };
231
+ })
232
+ });
233
+ }
234
+ function publish(state) {
235
+ state.revision += 1;
236
+ state.changedAt = new Date().toISOString();
237
+ const value = snapshot(state);
238
+ for (const listener of state.listeners) {
239
+ try {
240
+ listener(value);
241
+ } catch {}
242
+ }
243
+ const config = state.config;
244
+ if (config.onSnapshot) {
245
+ Promise.resolve().then(() => config.onSnapshot?.(value)).catch(() => {});
246
+ }
247
+ }
248
+
249
+ // src/application/kernel-admission.ts
250
+ function acquire(state) {
251
+ if (!state.accepting || !isReady(state))
252
+ return null;
253
+ state.accepted += 1;
254
+ state.pending += 1;
255
+ publish(state);
256
+ let released = false;
257
+ return {
258
+ get released() {
259
+ return released;
260
+ },
261
+ release() {
262
+ if (released)
263
+ return;
264
+ released = true;
265
+ state.pending -= 1;
266
+ state.completed += 1;
267
+ if (state.pending === 0) {
268
+ for (const waiter of state.pendingWaiters)
269
+ waiter();
270
+ state.pendingWaiters.clear();
271
+ }
272
+ publish(state);
273
+ }
274
+ };
275
+ }
276
+ async function run(state, work) {
277
+ const lease = acquire(state);
278
+ if (!lease)
279
+ throw new ApplicationAdmissionError;
280
+ try {
281
+ return await work();
282
+ } finally {
283
+ lease.release();
284
+ }
285
+ }
286
+ function waitForPending(state) {
287
+ if (state.pending === 0)
288
+ return Promise.resolve();
289
+ return new Promise((resolve) => state.pendingWaiters.add(resolve));
290
+ }
291
+
292
+ // src/application/kernel-resource-context.ts
293
+ function contextFor(state, record, options = {}) {
294
+ return {
295
+ applicationId: state.id,
296
+ signal: options.signal ?? state.lifetimeAbort.signal,
297
+ ...options.deadlineAt !== undefined && { deadlineAt: options.deadlineAt },
298
+ ...options.forceDeadlineAt !== undefined && {
299
+ forceDeadlineAt: options.forceDeadlineAt
300
+ },
301
+ now: () => performance.now(),
302
+ use(resource) {
303
+ const dependencyId = resource?.id;
304
+ if (typeof dependencyId !== "string" || dependencyId.length === 0) {
305
+ throw new Error(`[stitchkit] resource "${record.entry.id}": use() takes a managed resource, and this one has no id`);
306
+ }
307
+ if (!record.entry.dependsOn.includes(dependencyId)) {
308
+ throw new Error(`[stitchkit] resource "${record.entry.id}" used "${dependencyId}" without declaring it in dependsOn`);
309
+ }
310
+ if (!state.published.has(dependencyId)) {
311
+ throw new Error(`[stitchkit] resource "${record.entry.id}" used "${dependencyId}", which published no value from start()`);
312
+ }
313
+ return state.published.get(dependencyId);
314
+ },
315
+ reportHealth(health) {
316
+ if (record.state === "stopped")
317
+ return;
318
+ record.health = health;
319
+ record.healthReported = true;
320
+ if (health === "healthy")
321
+ record.everHealthy = true;
322
+ state.accepting = state.activationComplete && !state.shutdownRequested && isReady(state);
323
+ publish(state);
324
+ }
325
+ };
326
+ }
327
+ function markLateCompletion(state, record, failure) {
328
+ if (state.shutdownRequested || record.state === "stopping" || record.state === "stopped") {
329
+ return;
330
+ }
331
+ if (failure) {
332
+ record.failures.push("completion");
333
+ reportFailure(state, record.entry.id, "completion", failure.error);
334
+ }
335
+ record.state = "failed";
336
+ record.health = "unhealthy";
337
+ state.accepting = state.activationComplete && isReady(state);
338
+ publish(state);
339
+ }
340
+
341
+ // src/application/kernel-rollback.ts
342
+ async function closeAttempted(state) {
343
+ const errors = [];
344
+ const rollbackStartedAt = performance.now();
345
+ const rollbackDeadlineAt = rollbackStartedAt + state.shutdownBudget.gracePeriodMs;
346
+ const rollbackForceDeadlineAt = rollbackDeadlineAt + state.shutdownBudget.forceTimeoutMs;
347
+ const rollbackAbort = new AbortController;
348
+ const rollbackTimer = setTimeout(() => rollbackAbort.abort(), Math.max(0, rollbackForceDeadlineAt - performance.now()));
349
+ try {
350
+ await closeEachAttempted(state, rollbackAbort.signal, errors, {
351
+ deadlineAt: rollbackDeadlineAt,
352
+ forceDeadlineAt: rollbackForceDeadlineAt
353
+ });
354
+ } finally {
355
+ clearTimeout(rollbackTimer);
356
+ }
357
+ return errors;
358
+ }
359
+ async function closeEachAttempted(state, bound, errors, deadlines) {
360
+ for (const entry of state.reverse) {
361
+ const record = state.records.get(entry.id);
362
+ if (!record?.attempted || record.closed)
363
+ continue;
364
+ record.state = "stopping";
365
+ try {
366
+ record.closeInvoked = true;
367
+ const settled = await untilDeadline(Promise.resolve(entry.resource.close?.(contextFor(state, record, { signal: state.startupAbort.signal, ...deadlines }))), bound);
368
+ if (!settled.settled) {
369
+ record.failures.push("close");
370
+ record.state = "failed";
371
+ const timedOut = new Error(`[stitchkit] resource "${entry.id}" did not finish closing during rollback`);
372
+ reportFailure(state, entry.id, "close", timedOut);
373
+ errors.push(timedOut);
374
+ publish(state);
375
+ break;
376
+ }
377
+ if (settled.error !== undefined)
378
+ throw settled.error;
379
+ record.closed = true;
380
+ record.state = "stopped";
381
+ } catch (error) {
382
+ record.failures.push("close");
383
+ record.state = "failed";
384
+ reportFailure(state, entry.id, "close", error);
385
+ errors.push(error);
386
+ }
387
+ publish(state);
388
+ }
389
+ }
390
+
391
+ // src/application/kernel-start.ts
392
+ async function startEach(state, entries, signal) {
393
+ for (const entry of entries) {
394
+ if (state.shutdownRequested || signal.aborted) {
395
+ throw new ApplicationStartupInterruptedError;
396
+ }
397
+ const record = recordOf(state, entry.id);
398
+ const dependencyFailed = entry.dependsOn.some((dependencyId) => state.records.get(dependencyId)?.state !== "ready");
399
+ if (dependencyFailed) {
400
+ record.state = "failed";
401
+ record.health = "unhealthy";
402
+ record.failures.push("start");
403
+ publish(state);
404
+ if (entry.required) {
405
+ throw new Error(`[stitchkit] required resource "${entry.id}" has an unavailable dependency`);
406
+ }
407
+ continue;
408
+ }
409
+ record.attempted = true;
410
+ record.state = "starting";
411
+ publish(state);
412
+ try {
413
+ const started = await entry.resource.start(contextFor(state, record, { signal }));
414
+ if (state.shutdownRequested || signal.aborted) {
415
+ throw new ApplicationStartupInterruptedError;
416
+ }
417
+ if (isStartResult(started)) {
418
+ record.runtime = started;
419
+ if (started.value !== undefined)
420
+ state.published.set(entry.id, started.value);
421
+ let resourceReady = started.ready === undefined;
422
+ let completionSettled = false;
423
+ let completionFailure;
424
+ const completion = started.completion?.then(() => {
425
+ completionSettled = true;
426
+ if (resourceReady)
427
+ markLateCompletion(state, record);
428
+ }, (error) => {
429
+ completionSettled = true;
430
+ completionFailure = error;
431
+ if (resourceReady)
432
+ markLateCompletion(state, record, { error });
433
+ });
434
+ if (started.ready && completion) {
435
+ const readiness = started.ready.then(() => "ready");
436
+ const completionBeforeReady = completion.then(() => "completion");
437
+ const first = await Promise.race([readiness, completionBeforeReady]);
438
+ if (first === "completion") {
439
+ throw new ResourceCompletionBeforeReadyError(entry.id, completionFailure);
440
+ }
441
+ resourceReady = true;
442
+ if (completionSettled) {
443
+ throw new ResourceCompletionBeforeReadyError(entry.id, completionFailure);
444
+ }
445
+ } else if (started.ready) {
446
+ await started.ready;
447
+ resourceReady = true;
448
+ } else if (completion) {}
449
+ }
450
+ if (state.shutdownRequested || signal.aborted) {
451
+ throw new ApplicationStartupInterruptedError;
452
+ }
453
+ record.state = "ready";
454
+ if (!record.healthReported) {
455
+ record.health = "healthy";
456
+ record.everHealthy = true;
457
+ }
458
+ publish(state);
459
+ } catch (error) {
460
+ const interrupted = state.shutdownRequested || signal.aborted;
461
+ if (!(error instanceof ApplicationStartupInterruptedError)) {
462
+ record.failures.push(error instanceof ResourceCompletionBeforeReadyError ? "completion" : record.runtime?.ready ? "ready" : "start");
463
+ record.state = "failed";
464
+ record.health = "unhealthy";
465
+ reportFailure(state, entry.id, record.failures[record.failures.length - 1] ?? "start", error);
466
+ publish(state);
467
+ }
468
+ if (interrupted || entry.required)
469
+ throw error;
470
+ }
471
+ }
472
+ }
473
+ async function activateEach(state, entries, signal) {
474
+ for (const entry of entries) {
475
+ if (state.shutdownRequested || signal.aborted) {
476
+ throw new ApplicationStartupInterruptedError;
477
+ }
478
+ const record = state.records.get(entry.id);
479
+ if (record?.state !== "ready")
480
+ continue;
481
+ const dependencyUnavailable = entry.dependsOn.some((dependencyId) => {
482
+ const dependency = state.records.get(dependencyId);
483
+ return dependency?.state !== "ready" || !dependency.activated;
484
+ });
485
+ if (dependencyUnavailable) {
486
+ record.failures.push("start");
487
+ record.state = "failed";
488
+ record.health = "unhealthy";
489
+ publish(state);
490
+ if (entry.required) {
491
+ throw new Error(`[stitchkit] required resource "${entry.id}" has an unavailable activation dependency`);
492
+ }
493
+ continue;
494
+ }
495
+ try {
496
+ await entry.resource.activate?.(contextFor(state, record));
497
+ if (state.shutdownRequested || signal.aborted) {
498
+ throw new ApplicationStartupInterruptedError;
499
+ }
500
+ record.activated = true;
501
+ if (entry.required && (record.state !== "ready" || record.health !== "healthy")) {
502
+ const observed = `${record.state}/${record.health}`;
503
+ throw new Error(record.everHealthy ? `[stitchkit] required resource "${entry.id}" lost readiness during activation (${observed})` : `[stitchkit] required resource "${entry.id}" is not healthy (${observed}). A required resource must be healthy for the application to be ready; a resource that is expected to start degraded belongs behind \`required: false\`.`);
504
+ }
505
+ } catch (error) {
506
+ const interrupted = state.shutdownRequested || signal.aborted;
507
+ if (!(error instanceof ApplicationStartupInterruptedError)) {
508
+ record.failures.push("start");
509
+ record.state = "failed";
510
+ record.health = "unhealthy";
511
+ reportFailure(state, entry.id, "start", error);
512
+ publish(state);
513
+ }
514
+ if (interrupted || entry.required)
515
+ throw error;
516
+ }
517
+ }
518
+ }
519
+ function notReadyAfterStartup(state) {
520
+ const blocking = [...state.records.values()].filter((record) => record.entry.required && (record.state !== "ready" || record.health !== "healthy")).map((record) => `${record.entry.id} (${record.state}/${record.health})`);
521
+ if (blocking.length === 0)
522
+ blocking.push("(none identified)");
523
+ const chosen = [...state.records.values()].some((record) => record.entry.required && record.health !== "healthy" && !record.everHealthy);
524
+ return new Error(`[stitchkit] the application is not ready after startup — required ${blocking.length === 1 ? "resource" : "resources"} ${blocking.join(", ")}. A required resource must be healthy for the application to be ready; ${chosen ? "a resource that is expected to start degraded belongs behind `required: false`." : "this one was healthy and stopped being so — read `onResourceFailure` for the cause."}`);
525
+ }
526
+ async function runStart(state) {
527
+ state.lifecycle = "starting";
528
+ publish(state);
529
+ let startFailure;
530
+ try {
531
+ await startEach(state, state.ordered, state.startupAbort.signal);
532
+ state.lifecycle = "ready";
533
+ publish(state);
534
+ await activateEach(state, state.ordered, state.startupAbort.signal);
535
+ if (state.shutdownRequested) {
536
+ throw new ApplicationStartupInterruptedError;
537
+ }
538
+ if (!isReady(state)) {
539
+ throw notReadyAfterStartup(state);
540
+ }
541
+ state.activationComplete = true;
542
+ state.accepting = isReady(state);
543
+ publish(state);
544
+ return snapshot(state);
545
+ } catch (error) {
546
+ startFailure = error;
547
+ }
548
+ if (!state.shutdownRequested) {
549
+ const rollbackErrors = await closeAttempted(state);
550
+ state.lifecycle = "failed";
551
+ state.accepting = false;
552
+ publish(state);
553
+ if (rollbackErrors.length > 0) {
554
+ throw new AggregateError([startFailure, ...rollbackErrors], "[stitchkit] application startup and rollback failed", { cause: startFailure });
555
+ }
556
+ }
557
+ throw startFailure;
558
+ }
559
+ function start(state) {
560
+ if (state.startPromise)
561
+ return state.startPromise;
562
+ if (state.lifecycle !== "created") {
563
+ return Promise.reject(new Error(`[stitchkit] application cannot start from lifecycle "${state.lifecycle}"`));
564
+ }
565
+ const started = runStart(state);
566
+ state.startPromise = started;
567
+ started.catch(() => {
568
+ return;
569
+ });
570
+ return started;
571
+ }
572
+
573
+ // src/application/kernel-restart.ts
574
+ function subtreeOf(state, resourceId) {
575
+ const affected = new Set([resourceId]);
576
+ for (const entry of state.ordered) {
577
+ if (entry.dependsOn.some((dependencyId) => affected.has(dependencyId))) {
578
+ affected.add(entry.id);
579
+ }
580
+ }
581
+ return state.ordered.filter((entry) => affected.has(entry.id));
582
+ }
583
+ async function closeOne(state, entry, record, signal, deadlines) {
584
+ const context = () => contextFor(state, record, { ...deadlines, signal });
585
+ if (record.attempted && !record.closed) {
586
+ const phase = async (work, what) => {
587
+ const settled = await untilDeadline(Promise.resolve(work), signal);
588
+ if (!settled.settled) {
589
+ throw new Error(`[stitchkit] resource "${entry.id}" did not ${what} within the restart budget`);
590
+ }
591
+ if (settled.error !== undefined)
592
+ throw settled.error;
593
+ };
594
+ await phase(entry.resource.stopAdmission?.(context()), "stop admitting");
595
+ await phase(entry.resource.drain?.(context()), "drain");
596
+ record.closeInvoked = true;
597
+ await phase(entry.resource.close?.(context()), "close");
598
+ }
599
+ record.closed = false;
600
+ record.closeInvoked = false;
601
+ record.attempted = false;
602
+ record.activated = false;
603
+ record.state = "registered";
604
+ record.health = "unknown";
605
+ record.healthReported = false;
606
+ record.runtime = undefined;
607
+ state.published.delete(entry.id);
608
+ }
609
+ async function runRestart(state, input) {
610
+ const startedAt = Date.now();
611
+ const parsed = ApplicationRestartInputSchema.parse(input);
612
+ const affected = subtreeOf(state, parsed.resourceId);
613
+ const affectedIds = affected.map((entry) => entry.id);
614
+ const refuse = (reason) => ({
615
+ resourceId: parsed.resourceId,
616
+ affected: affectedIds,
617
+ outcome: "refused",
618
+ reason,
619
+ durationMs: Date.now() - startedAt
620
+ });
621
+ if (!state.records.has(parsed.resourceId)) {
622
+ return refuse(`no resource is registered as "${parsed.resourceId}"`);
623
+ }
624
+ if (state.shutdownRequested) {
625
+ return refuse("the application is shutting down");
626
+ }
627
+ if (state.lifecycle !== "ready") {
628
+ return refuse(`the application is ${state.lifecycle}, not ready`);
629
+ }
630
+ const budget = {
631
+ gracePeriodMs: parsed.gracePeriodMs ?? state.shutdownBudget.gracePeriodMs,
632
+ forceTimeoutMs: parsed.forceTimeoutMs ?? state.shutdownBudget.forceTimeoutMs
633
+ };
634
+ const closeDeadlineAt = performance.now() + budget.gracePeriodMs;
635
+ const deadlines = {
636
+ deadlineAt: closeDeadlineAt,
637
+ forceDeadlineAt: closeDeadlineAt + budget.forceTimeoutMs
638
+ };
639
+ state.restartingIds = affectedIds;
640
+ const restartAbort = new AbortController;
641
+ const closeTimer = setTimeout(() => restartAbort.abort(), Math.max(0, deadlines.forceDeadlineAt - performance.now()));
642
+ const stillFailed = () => affectedIds.filter((id) => state.records.get(id)?.state === "failed");
643
+ try {
644
+ for (const entry of [...affected].reverse()) {
645
+ const record = state.records.get(entry.id);
646
+ if (record)
647
+ await closeOne(state, entry, record, restartAbort.signal, deadlines);
648
+ }
649
+ publish(state);
650
+ await startEach(state, affected, restartAbort.signal);
651
+ await activateEach(state, affected, restartAbort.signal);
652
+ publish(state);
653
+ const failed = stillFailed();
654
+ if (failed.length > 0) {
655
+ return {
656
+ resourceId: parsed.resourceId,
657
+ affected: affectedIds,
658
+ outcome: "failed",
659
+ reason: `did not come back: ${failed.join(", ")}`,
660
+ durationMs: Date.now() - startedAt
661
+ };
662
+ }
663
+ return {
664
+ resourceId: parsed.resourceId,
665
+ affected: affectedIds,
666
+ outcome: "restarted",
667
+ durationMs: Date.now() - startedAt
668
+ };
669
+ } catch (error) {
670
+ restartAbort.abort();
671
+ publish(state);
672
+ return {
673
+ resourceId: parsed.resourceId,
674
+ affected: affectedIds,
675
+ outcome: "failed",
676
+ reason: error instanceof Error ? error.message : String(error),
677
+ durationMs: Date.now() - startedAt
678
+ };
679
+ } finally {
680
+ state.restartingIds = [];
681
+ clearTimeout(closeTimer);
682
+ publish(state);
683
+ }
684
+ }
685
+ function restart(state, input) {
686
+ const queued = state.restarting.then(() => runRestart(state, input));
687
+ state.restarting = queued.then(() => {
688
+ return;
689
+ }, () => {
690
+ return;
691
+ });
692
+ return queued;
693
+ }
694
+
695
+ // src/application/kernel-shutdown.ts
696
+ function force(shutdown, reason) {
697
+ if (shutdown.forcedReason)
698
+ return;
699
+ shutdown.forcedReason = reason;
700
+ shutdown.gracefulAbort.abort();
701
+ shutdown.state.lifetimeAbort.abort();
702
+ }
703
+ function gracefulContext(shutdown, record) {
704
+ return contextFor(shutdown.state, record, {
705
+ signal: shutdown.gracefulAbort.signal,
706
+ deadlineAt: shutdown.graceDeadlineAt,
707
+ forceDeadlineAt: shutdown.forceDeadlineAt
708
+ });
709
+ }
710
+ async function stopAdmissionSweep(shutdown) {
711
+ const { state } = shutdown;
712
+ for (const entry of state.reverse) {
713
+ if (shutdown.gracefulAbort.signal.aborted)
714
+ break;
715
+ const record = state.records.get(entry.id);
716
+ if (!record?.attempted || record.closed)
717
+ continue;
718
+ try {
719
+ const result = await untilDeadline(Promise.resolve(entry.resource.stopAdmission?.(gracefulContext(shutdown, record))), shutdown.gracefulAbort.signal);
720
+ if (!result.settled)
721
+ break;
722
+ if (result.error !== undefined)
723
+ throw result.error;
724
+ } catch (error) {
725
+ record.failures.push("admission");
726
+ reportFailure(state, entry.id, "admission", error);
727
+ shutdown.gracefulFailed = true;
728
+ state.lifetimeAbort.abort();
729
+ }
730
+ }
731
+ }
732
+ async function drainSweep(shutdown) {
733
+ const { state } = shutdown;
734
+ for (const entry of state.reverse) {
735
+ if (shutdown.gracefulAbort.signal.aborted || shutdown.gracefulFailed)
736
+ break;
737
+ const record = state.records.get(entry.id);
738
+ if (!record?.attempted || record.closed)
739
+ continue;
740
+ record.state = "stopping";
741
+ publish(state);
742
+ try {
743
+ const drained = await untilDeadline(Promise.resolve(entry.resource.drain?.(gracefulContext(shutdown, record))), shutdown.gracefulAbort.signal);
744
+ if (!drained.settled) {
745
+ force(shutdown, "deadline");
746
+ break;
747
+ }
748
+ if (drained.error !== undefined)
749
+ throw drained.error;
750
+ } catch (error) {
751
+ record.failures.push("drain");
752
+ reportFailure(state, entry.id, "drain", error);
753
+ shutdown.gracefulFailed = true;
754
+ state.lifetimeAbort.abort();
755
+ break;
756
+ }
757
+ }
758
+ }
759
+ async function closeSweep(shutdown) {
760
+ const { state } = shutdown;
761
+ for (const entry of state.reverse) {
762
+ if (shutdown.gracefulAbort.signal.aborted || shutdown.gracefulFailed)
763
+ break;
764
+ const record = state.records.get(entry.id);
765
+ if (!record?.attempted || record.closed || record.closeInvoked)
766
+ continue;
767
+ try {
768
+ record.closeInvoked = true;
769
+ const closed = await untilDeadline(Promise.resolve(entry.resource.close?.(gracefulContext(shutdown, record))), shutdown.gracefulAbort.signal);
770
+ if (!closed.settled) {
771
+ force(shutdown, "deadline");
772
+ break;
773
+ }
774
+ if (closed.error !== undefined)
775
+ throw closed.error;
776
+ record.closed = true;
777
+ record.state = "stopped";
778
+ publish(state);
779
+ } catch (error) {
780
+ record.failures.push("close");
781
+ reportFailure(state, entry.id, "close", error);
782
+ record.state = "failed";
783
+ shutdown.gracefulFailed = true;
784
+ state.lifetimeAbort.abort();
785
+ publish(state);
786
+ break;
787
+ }
788
+ }
789
+ }
790
+ async function forceOne(shutdown, entry, forceSignal) {
791
+ const { state } = shutdown;
792
+ const record = state.records.get(entry.id);
793
+ if (!record?.attempted || record.closed)
794
+ return;
795
+ try {
796
+ let cleanup;
797
+ if (entry.resource.force) {
798
+ cleanup = Promise.resolve(entry.resource.force(contextFor(state, record, {
799
+ signal: forceSignal,
800
+ deadlineAt: shutdown.graceDeadlineAt,
801
+ forceDeadlineAt: shutdown.forceDeadlineAt
802
+ })));
803
+ } else if (entry.resource.close && !record.closeInvoked) {
804
+ record.closeInvoked = true;
805
+ cleanup = Promise.resolve(entry.resource.close(contextFor(state, record, {
806
+ signal: forceSignal,
807
+ deadlineAt: shutdown.graceDeadlineAt,
808
+ forceDeadlineAt: shutdown.forceDeadlineAt
809
+ })));
810
+ } else if (entry.resource.close) {
811
+ record.failures.push("force");
812
+ reportFailure(state, entry.id, "force", new Error(`[stitchkit] resource "${entry.id}" was already closing and did not settle before the force deadline`));
813
+ return;
814
+ }
815
+ const forced = await untilDeadline(cleanup ?? Promise.resolve(), forceSignal);
816
+ if (!forced.settled || forced.error !== undefined) {
817
+ record.failures.push("force");
818
+ reportFailure(state, entry.id, "force", forced.settled ? forced.error : new Error("[stitchkit] forced cleanup did not settle in time"));
819
+ return;
820
+ }
821
+ record.closed = true;
822
+ record.state = "stopped";
823
+ } catch (error) {
824
+ record.failures.push("force");
825
+ reportFailure(state, entry.id, "force", error);
826
+ }
827
+ }
828
+ async function forceSweep(shutdown) {
829
+ shutdown.state.lifetimeAbort.abort();
830
+ const forceAbort = new AbortController;
831
+ const forceTimer = setTimeout(() => forceAbort.abort(), Math.max(0, shutdown.forceDeadlineAt - performance.now()));
832
+ await Promise.all(shutdown.state.reverse.map((entry) => forceOne(shutdown, entry, forceAbort.signal)));
833
+ clearTimeout(forceTimer);
834
+ }
835
+ function shutdownResult(shutdown, mustForce, pendingOperationsAtForce) {
836
+ const { state } = shutdown;
837
+ const cleanupComplete = [...state.records.values()].every((record) => !record.attempted || record.closed);
838
+ state.lifecycle = cleanupComplete ? "stopped" : "failed";
839
+ publish(state);
840
+ return ApplicationShutdownResultSchema.parse({
841
+ outcome: mustForce ? "forced" : "clean",
842
+ ...shutdown.forcedReason && { reason: shutdown.forcedReason },
843
+ cleanupComplete,
844
+ acceptedOperations: state.accepted,
845
+ completedOperations: state.completed,
846
+ pendingOperations: state.pending,
847
+ pendingOperationsAtForce,
848
+ resources: state.ordered.map((entry) => {
849
+ const record = recordOf(state, entry.id);
850
+ return {
851
+ id: entry.id,
852
+ state: !record.attempted ? "not-started" : record.closed ? "closed" : "force-failed",
853
+ failures: record.failures
854
+ };
855
+ }),
856
+ durationMs: performance.now() - shutdown.startedAt
857
+ });
858
+ }
859
+ async function runShutdown(state, parsed, startedAt) {
860
+ const graceDeadlineAt = startedAt + parsed.gracePeriodMs;
861
+ const shutdown = {
862
+ state,
863
+ startedAt,
864
+ graceDeadlineAt,
865
+ forceDeadlineAt: graceDeadlineAt + parsed.forceTimeoutMs,
866
+ gracefulAbort: new AbortController,
867
+ forcedReason: undefined,
868
+ gracefulFailed: [...state.records.values()].some((record) => record.attempted && record.closeInvoked && !record.closed)
869
+ };
870
+ const graceTimer = setTimeout(() => force(shutdown, "deadline"), Math.max(0, graceDeadlineAt - performance.now()));
871
+ const onExternalAbort = () => force(shutdown, "signal");
872
+ parsed.signal?.addEventListener("abort", onExternalAbort, { once: true });
873
+ if (parsed.signal?.aborted)
874
+ force(shutdown, "signal");
875
+ if (state.startPromise) {
876
+ await untilDeadline(state.startPromise.catch(() => {
877
+ return;
878
+ }), shutdown.gracefulAbort.signal);
879
+ }
880
+ await stopAdmissionSweep(shutdown);
881
+ if (!shutdown.gracefulAbort.signal.aborted && !shutdown.gracefulFailed) {
882
+ const result = await untilDeadline(waitForPending(state), shutdown.gracefulAbort.signal);
883
+ if (!result.settled)
884
+ force(shutdown, "deadline");
885
+ }
886
+ await drainSweep(shutdown);
887
+ state.lifecycle = "stopping";
888
+ publish(state);
889
+ await closeSweep(shutdown);
890
+ clearTimeout(graceTimer);
891
+ parsed.signal?.removeEventListener("abort", onExternalAbort);
892
+ const mustForce = shutdown.forcedReason !== undefined || shutdown.gracefulFailed;
893
+ const pendingOperationsAtForce = mustForce ? state.pending : 0;
894
+ if (mustForce)
895
+ await forceSweep(shutdown);
896
+ return shutdownResult(shutdown, mustForce, pendingOperationsAtForce);
897
+ }
898
+ function shutdown(state, options) {
899
+ if (state.shutdownPromise)
900
+ return state.shutdownPromise;
901
+ const requested = options ?? {};
902
+ const parsed = ApplicationShutdownOptionsSchema.parse({
903
+ gracePeriodMs: requested.gracePeriodMs ?? state.shutdownBudget.gracePeriodMs,
904
+ forceTimeoutMs: requested.forceTimeoutMs ?? state.shutdownBudget.forceTimeoutMs,
905
+ ...requested.signal !== undefined && { signal: requested.signal }
906
+ });
907
+ const startedAt = performance.now();
908
+ state.shutdownRequested = true;
909
+ state.accepting = false;
910
+ state.startupAbort.abort();
911
+ state.lifecycle = state.lifecycle === "created" ? "stopping" : "draining";
912
+ publish(state);
913
+ const stopping = runShutdown(state, parsed, startedAt);
914
+ state.shutdownPromise = stopping;
915
+ stopping.catch(() => {
916
+ return;
917
+ });
918
+ return stopping;
919
+ }
920
+
921
+ // src/application/kernel.ts
922
+ function createApplication(config) {
923
+ const state = createKernelState(config);
924
+ return {
925
+ id: state.id,
926
+ admission: {
927
+ acquire: () => acquire(state),
928
+ run: (work) => run(state, work)
929
+ },
930
+ start: () => start(state),
931
+ getSnapshot: () => snapshot(state),
932
+ subscribe(listener) {
933
+ state.listeners.add(listener);
934
+ listener(snapshot(state));
935
+ return () => state.listeners.delete(listener);
936
+ },
937
+ shutdown: (options) => shutdown(state, options),
938
+ restart: (input) => restart(state, input)
939
+ };
940
+ }
941
+
942
+ export { ApplicationShutdownOptionsSchema, ApplicationShutdownBudgetSchema, ApplicationRestartInputSchema, ApplicationRestartOutcomeSchema, ApplicationRestartResultSchema, ApplicationAdmissionError, createApplication };