stitchkit 0.93.0 → 0.94.1

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 (1082) hide show
  1. package/CHANGELOG.md +198 -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-shell-process.d.ts.map +1 -1
  14. package/dist/agent-runtime/coding-tool-contract.d.ts +2 -1
  15. package/dist/agent-runtime/coding-tool-contract.d.ts.map +1 -1
  16. package/dist/agent-runtime/coding-tool-listing.d.ts.map +1 -1
  17. package/dist/agent-runtime/coding-tool-search-patch.d.ts.map +1 -1
  18. package/dist/agent-runtime/contained-darwin.d.ts +38 -0
  19. package/dist/agent-runtime/contained-darwin.d.ts.map +1 -0
  20. package/dist/agent-runtime/contained-files.d.ts +11 -26
  21. package/dist/agent-runtime/contained-files.d.ts.map +1 -1
  22. package/dist/agent-runtime/contained-scan.d.ts +21 -0
  23. package/dist/agent-runtime/contained-scan.d.ts.map +1 -0
  24. package/dist/agent-runtime/contained-write.d.ts +9 -0
  25. package/dist/agent-runtime/contained-write.d.ts.map +1 -0
  26. package/dist/agent-runtime/deferred-tool-types.d.ts +4 -3
  27. package/dist/agent-runtime/deferred-tool-types.d.ts.map +1 -1
  28. package/dist/agent-runtime/events.d.ts +1 -1
  29. package/dist/agent-runtime/events.d.ts.map +1 -1
  30. package/dist/agent-runtime/harness-control.d.ts +0 -1
  31. package/dist/agent-runtime/harness-control.d.ts.map +1 -1
  32. package/dist/agent-runtime/harness.d.ts +0 -5
  33. package/dist/agent-runtime/harness.d.ts.map +1 -1
  34. package/dist/agent-runtime/managed-tools.d.ts +3 -2
  35. package/dist/agent-runtime/managed-tools.d.ts.map +1 -1
  36. package/dist/agent-runtime/observability.d.ts +1 -1
  37. package/dist/agent-runtime/observability.d.ts.map +1 -1
  38. package/dist/agent-runtime/openrouter.d.ts +29 -0
  39. package/dist/agent-runtime/openrouter.d.ts.map +1 -0
  40. package/dist/agent-runtime/projections.d.ts +1 -1
  41. package/dist/agent-runtime/projections.d.ts.map +1 -1
  42. package/dist/agent-runtime/run-acquisition.d.ts +17 -0
  43. package/dist/agent-runtime/run-acquisition.d.ts.map +1 -0
  44. package/dist/agent-runtime/run-execution-state.d.ts +133 -0
  45. package/dist/agent-runtime/run-execution-state.d.ts.map +1 -0
  46. package/dist/agent-runtime/run-execution.d.ts +17 -33
  47. package/dist/agent-runtime/run-execution.d.ts.map +1 -1
  48. package/dist/agent-runtime/run-failure.d.ts +18 -0
  49. package/dist/agent-runtime/run-failure.d.ts.map +1 -0
  50. package/dist/agent-runtime/run-model-attempts.d.ts +6 -0
  51. package/dist/agent-runtime/run-model-attempts.d.ts.map +1 -0
  52. package/dist/agent-runtime/run-prompt-history.d.ts +58 -0
  53. package/dist/agent-runtime/run-prompt-history.d.ts.map +1 -0
  54. package/dist/agent-runtime/run-provider-ledger.d.ts +26 -0
  55. package/dist/agent-runtime/run-provider-ledger.d.ts.map +1 -0
  56. package/dist/agent-runtime/run-stream-parts.d.ts +17 -0
  57. package/dist/agent-runtime/run-stream-parts.d.ts.map +1 -0
  58. package/dist/agent-runtime/run-terminal.d.ts +11 -0
  59. package/dist/agent-runtime/run-terminal.d.ts.map +1 -0
  60. package/dist/agent-runtime/run-turn-preparation.d.ts +22 -0
  61. package/dist/agent-runtime/run-turn-preparation.d.ts.map +1 -0
  62. package/dist/agent-runtime/runtime-admission-gate.d.ts +29 -0
  63. package/dist/agent-runtime/runtime-admission-gate.d.ts.map +1 -0
  64. package/dist/agent-runtime/runtime-control.d.ts +9 -0
  65. package/dist/agent-runtime/runtime-control.d.ts.map +1 -0
  66. package/dist/agent-runtime/runtime-recovery.d.ts +10 -0
  67. package/dist/agent-runtime/runtime-recovery.d.ts.map +1 -0
  68. package/dist/agent-runtime/runtime-state.d.ts +36 -0
  69. package/dist/agent-runtime/runtime-state.d.ts.map +1 -0
  70. package/dist/agent-runtime/runtime-submit.d.ts +5 -0
  71. package/dist/agent-runtime/runtime-submit.d.ts.map +1 -0
  72. package/dist/agent-runtime/runtime.d.ts +10 -5
  73. package/dist/agent-runtime/runtime.d.ts.map +1 -1
  74. package/dist/agent-runtime/schedule-records.d.ts +34 -0
  75. package/dist/agent-runtime/schedule-records.d.ts.map +1 -0
  76. package/dist/agent-runtime/schedules.d.ts +34 -0
  77. package/dist/agent-runtime/schedules.d.ts.map +1 -1
  78. package/dist/agent-runtime/sqlite-bun.d.ts +12 -0
  79. package/dist/agent-runtime/sqlite-bun.d.ts.map +1 -0
  80. package/dist/agent-runtime/sqlite-events.d.ts +5 -0
  81. package/dist/agent-runtime/sqlite-events.d.ts.map +1 -0
  82. package/dist/agent-runtime/sqlite-history.d.ts +7 -0
  83. package/dist/agent-runtime/sqlite-history.d.ts.map +1 -0
  84. package/dist/agent-runtime/sqlite-ledger.d.ts +7 -0
  85. package/dist/agent-runtime/sqlite-ledger.d.ts.map +1 -0
  86. package/dist/agent-runtime/sqlite-node.d.ts +12 -0
  87. package/dist/agent-runtime/sqlite-node.d.ts.map +1 -0
  88. package/dist/agent-runtime/sqlite-reads.d.ts +14 -0
  89. package/dist/agent-runtime/sqlite-reads.d.ts.map +1 -0
  90. package/dist/agent-runtime/sqlite-rows.d.ts +178 -0
  91. package/dist/agent-runtime/sqlite-rows.d.ts.map +1 -0
  92. package/dist/agent-runtime/sqlite-schema.d.ts +7 -0
  93. package/dist/agent-runtime/sqlite-schema.d.ts.map +1 -0
  94. package/dist/agent-runtime/sqlite-transactions.d.ts +25 -0
  95. package/dist/agent-runtime/sqlite-transactions.d.ts.map +1 -0
  96. package/dist/agent-runtime/sqlite.d.ts +10 -6
  97. package/dist/agent-runtime/sqlite.d.ts.map +1 -1
  98. package/dist/agent-runtime/store-archive.d.ts +16 -0
  99. package/dist/agent-runtime/store-archive.d.ts.map +1 -0
  100. package/dist/agent-runtime/store-conformance-lifecycle.d.ts +434 -0
  101. package/dist/agent-runtime/store-conformance-lifecycle.d.ts.map +1 -0
  102. package/dist/agent-runtime/store-conformance-ordering.d.ts +18 -0
  103. package/dist/agent-runtime/store-conformance-ordering.d.ts.map +1 -0
  104. package/dist/agent-runtime/store-conformance-support.d.ts +130 -0
  105. package/dist/agent-runtime/store-conformance-support.d.ts.map +1 -0
  106. package/dist/agent-runtime/store-conformance-terminal.d.ts +12 -0
  107. package/dist/agent-runtime/store-conformance-terminal.d.ts.map +1 -0
  108. package/dist/agent-runtime/store-conformance.d.ts +40 -0
  109. package/dist/agent-runtime/store-conformance.d.ts.map +1 -0
  110. package/dist/agent-runtime/store-create.d.ts +11 -0
  111. package/dist/agent-runtime/store-create.d.ts.map +1 -0
  112. package/dist/agent-runtime/store-driver-contract.d.ts +814 -0
  113. package/dist/agent-runtime/store-driver-contract.d.ts.map +1 -0
  114. package/dist/agent-runtime/store-events.d.ts +7 -89
  115. package/dist/agent-runtime/store-events.d.ts.map +1 -1
  116. package/dist/agent-runtime/store-memory.d.ts +4 -0
  117. package/dist/agent-runtime/store-memory.d.ts.map +1 -0
  118. package/dist/agent-runtime/store-mutate.d.ts +13 -0
  119. package/dist/agent-runtime/store-mutate.d.ts.map +1 -0
  120. package/dist/agent-runtime/store-purge.d.ts +1 -1
  121. package/dist/agent-runtime/store-purge.d.ts.map +1 -1
  122. package/dist/agent-runtime/store-reads.d.ts +29 -0
  123. package/dist/agent-runtime/store-reads.d.ts.map +1 -0
  124. package/dist/agent-runtime/store-reduce-history.d.ts +10 -0
  125. package/dist/agent-runtime/store-reduce-history.d.ts.map +1 -0
  126. package/dist/agent-runtime/store-reduce-run.d.ts +14 -0
  127. package/dist/agent-runtime/store-reduce-run.d.ts.map +1 -0
  128. package/dist/agent-runtime/store-reduce-shared.d.ts +76 -0
  129. package/dist/agent-runtime/store-reduce-shared.d.ts.map +1 -0
  130. package/dist/agent-runtime/store-reduce-terminal.d.ts +6 -0
  131. package/dist/agent-runtime/store-reduce-terminal.d.ts.map +1 -0
  132. package/dist/agent-runtime/store-reducer.d.ts +24 -0
  133. package/dist/agent-runtime/store-reducer.d.ts.map +1 -0
  134. package/dist/agent-runtime/store-snapshot.d.ts +19 -0
  135. package/dist/agent-runtime/store-snapshot.d.ts.map +1 -0
  136. package/dist/agent-runtime/store.d.ts +1 -1
  137. package/dist/agent-runtime/store.d.ts.map +1 -1
  138. package/dist/application/admission-rate.d.ts +21 -0
  139. package/dist/application/admission-rate.d.ts.map +1 -0
  140. package/dist/application/admission-run.d.ts +8 -0
  141. package/dist/application/admission-run.d.ts.map +1 -0
  142. package/dist/application/admission.d.ts +1 -1
  143. package/dist/application/admission.d.ts.map +1 -1
  144. package/dist/application/diagnostic-journal-lock.d.ts +9 -34
  145. package/dist/application/diagnostic-journal-lock.d.ts.map +1 -1
  146. package/dist/application/diagnostic-journal-manager.d.ts.map +1 -1
  147. package/dist/application/diagnostic-journal-storage.d.ts.map +1 -1
  148. package/dist/application/events.d.ts +1 -1
  149. package/dist/application/events.d.ts.map +1 -1
  150. package/dist/application/file-state-store.d.ts +23 -0
  151. package/dist/application/file-state-store.d.ts.map +1 -0
  152. package/dist/application/health.d.ts +1 -1
  153. package/dist/application/health.d.ts.map +1 -1
  154. package/dist/application/kernel-admission.d.ts +8 -0
  155. package/dist/application/kernel-admission.d.ts.map +1 -0
  156. package/dist/application/kernel-contract.d.ts +142 -0
  157. package/dist/application/kernel-contract.d.ts.map +1 -0
  158. package/dist/application/kernel-resource-context.d.ts +24 -0
  159. package/dist/application/kernel-resource-context.d.ts.map +1 -0
  160. package/dist/application/kernel-restart.d.ts +5 -0
  161. package/dist/application/kernel-restart.d.ts.map +1 -0
  162. package/dist/application/kernel-rollback.d.ts +4 -0
  163. package/dist/application/kernel-rollback.d.ts.map +1 -0
  164. package/dist/application/kernel-shutdown.d.ts +6 -0
  165. package/dist/application/kernel-shutdown.d.ts.map +1 -0
  166. package/dist/application/kernel-start.d.ts +20 -0
  167. package/dist/application/kernel-start.d.ts.map +1 -0
  168. package/dist/application/kernel-state.d.ts +116 -0
  169. package/dist/application/kernel-state.d.ts.map +1 -0
  170. package/dist/application/kernel.d.ts +9 -140
  171. package/dist/application/kernel.d.ts.map +1 -1
  172. package/dist/application/latest-sink.d.ts +1 -1
  173. package/dist/application/latest-sink.d.ts.map +1 -1
  174. package/dist/application/notification-outbox.d.ts.map +1 -1
  175. package/dist/application/opentelemetry.d.ts +1 -1
  176. package/dist/application/opentelemetry.d.ts.map +1 -1
  177. package/dist/application/schedule.d.ts +0 -1
  178. package/dist/application/schedule.d.ts.map +1 -1
  179. package/dist/application/watch-hub-core.d.ts +122 -0
  180. package/dist/application/watch-hub-core.d.ts.map +1 -0
  181. package/dist/application/watch-hub.d.ts +3 -3
  182. package/dist/application/watch-hub.d.ts.map +1 -1
  183. package/dist/browser/client-executors.d.ts +14 -0
  184. package/dist/browser/client-executors.d.ts.map +1 -0
  185. package/dist/browser/client-multipart.d.ts +1 -1
  186. package/dist/browser/client-multipart.d.ts.map +1 -1
  187. package/dist/browser/client-url.d.ts +1 -1
  188. package/dist/browser/client-url.d.ts.map +1 -1
  189. package/dist/browser/client.d.ts +3 -2
  190. package/dist/browser/client.d.ts.map +1 -1
  191. package/dist/browser/contract-stream.d.ts +1 -1
  192. package/dist/browser/contract-stream.d.ts.map +1 -1
  193. package/dist/browser/http-fetch.d.ts +22 -0
  194. package/dist/browser/http-fetch.d.ts.map +1 -0
  195. package/dist/browser/http.d.ts +2 -4
  196. package/dist/browser/http.d.ts.map +1 -1
  197. package/dist/browser/live-state-core.d.ts +63 -0
  198. package/dist/browser/live-state-core.d.ts.map +1 -0
  199. package/dist/browser/live-state.d.ts.map +1 -1
  200. package/dist/browser/realtime-client.d.ts +26 -0
  201. package/dist/browser/realtime-client.d.ts.map +1 -0
  202. package/dist/browser/resumable.d.ts +1 -28
  203. package/dist/browser/resumable.d.ts.map +1 -1
  204. package/dist/browser/retained.d.ts.map +1 -0
  205. package/dist/browser/socket-io-connection.d.ts +82 -0
  206. package/dist/browser/socket-io-connection.d.ts.map +1 -0
  207. package/dist/browser/socket-io-peer.d.ts +20 -0
  208. package/dist/browser/socket-io-peer.d.ts.map +1 -0
  209. package/dist/browser/socket-io-trace.d.ts +31 -0
  210. package/dist/browser/socket-io-trace.d.ts.map +1 -0
  211. package/dist/browser/socket-io.d.ts +24 -18
  212. package/dist/browser/socket-io.d.ts.map +1 -1
  213. package/dist/browser/stream.d.ts +14 -2
  214. package/dist/browser/stream.d.ts.map +1 -1
  215. package/dist/contract/client-types.d.ts +134 -0
  216. package/dist/contract/client-types.d.ts.map +1 -0
  217. package/dist/contract/define-validation.d.ts +30 -0
  218. package/dist/contract/define-validation.d.ts.map +1 -0
  219. package/dist/contract/define.d.ts +47 -394
  220. package/dist/contract/define.d.ts.map +1 -1
  221. package/dist/contract/normalize.d.ts +56 -0
  222. package/dist/contract/normalize.d.ts.map +1 -0
  223. package/dist/contract/runtime-context.d.ts +131 -0
  224. package/dist/contract/runtime-context.d.ts.map +1 -0
  225. package/dist/contract/tool-options.d.ts +105 -0
  226. package/dist/contract/tool-options.d.ts.map +1 -0
  227. package/dist/contract/tool-view.d.ts +148 -0
  228. package/dist/contract/tool-view.d.ts.map +1 -0
  229. package/dist/declaration/declaration.d.ts.map +1 -0
  230. package/dist/durability/contract.d.ts +259 -0
  231. package/dist/durability/contract.d.ts.map +1 -0
  232. package/dist/durability/effect.d.ts +24 -0
  233. package/dist/durability/effect.d.ts.map +1 -0
  234. package/dist/durability/engine.d.ts +14 -0
  235. package/dist/durability/engine.d.ts.map +1 -0
  236. package/dist/durability/events.d.ts +103 -0
  237. package/dist/durability/events.d.ts.map +1 -0
  238. package/dist/durability/json.d.ts +3 -0
  239. package/dist/durability/json.d.ts.map +1 -0
  240. package/dist/durability/ledger.d.ts +27 -0
  241. package/dist/durability/ledger.d.ts.map +1 -0
  242. package/dist/durability/parks.d.ts +22 -0
  243. package/dist/durability/parks.d.ts.map +1 -0
  244. package/dist/durability/scheduler.d.ts +30 -0
  245. package/dist/durability/scheduler.d.ts.map +1 -0
  246. package/dist/entrypoints/agent-runtime/browser.d.ts +5 -0
  247. package/dist/entrypoints/agent-runtime/browser.d.ts.map +1 -0
  248. package/dist/entrypoints/agent-runtime/browser.js +124 -0
  249. package/dist/entrypoints/agent-runtime/coding-tools.d.ts +2 -0
  250. package/dist/entrypoints/agent-runtime/coding-tools.d.ts.map +1 -0
  251. package/dist/entrypoints/agent-runtime/coding-tools.js +22 -0
  252. package/dist/entrypoints/agent-runtime/harness.d.ts +2 -0
  253. package/dist/entrypoints/agent-runtime/harness.d.ts.map +1 -0
  254. package/dist/entrypoints/agent-runtime/harness.js +739 -0
  255. package/dist/entrypoints/agent-runtime/openrouter.d.ts +2 -0
  256. package/dist/entrypoints/agent-runtime/openrouter.d.ts.map +1 -0
  257. package/dist/entrypoints/agent-runtime/openrouter.js +270 -0
  258. package/dist/entrypoints/agent-runtime/sandbox.d.ts +5 -0
  259. package/dist/entrypoints/agent-runtime/sandbox.d.ts.map +1 -0
  260. package/dist/entrypoints/agent-runtime/sandbox.js +797 -0
  261. package/dist/entrypoints/agent-runtime/sqlite/bun.d.ts +2 -0
  262. package/dist/entrypoints/agent-runtime/sqlite/bun.d.ts.map +1 -0
  263. package/dist/entrypoints/agent-runtime/sqlite/bun.js +44 -0
  264. package/dist/entrypoints/agent-runtime/sqlite/node.d.ts +2 -0
  265. package/dist/entrypoints/agent-runtime/sqlite/node.d.ts.map +1 -0
  266. package/dist/entrypoints/agent-runtime/sqlite/node.js +46 -0
  267. package/dist/entrypoints/agent-runtime/testing.d.ts +4 -0
  268. package/dist/entrypoints/agent-runtime/testing.d.ts.map +1 -0
  269. package/dist/entrypoints/agent-runtime/testing.js +1116 -0
  270. package/dist/entrypoints/agent-runtime.d.ts +42 -0
  271. package/dist/entrypoints/agent-runtime.d.ts.map +1 -0
  272. package/dist/entrypoints/agent-runtime.js +2670 -0
  273. package/dist/entrypoints/application/diagnostic-journal.d.ts +21 -0
  274. package/dist/entrypoints/application/diagnostic-journal.d.ts.map +1 -0
  275. package/dist/entrypoints/application/diagnostic-journal.js +492 -0
  276. package/dist/entrypoints/application/grammy.d.ts +2 -0
  277. package/dist/entrypoints/application/grammy.d.ts.map +1 -0
  278. package/dist/entrypoints/application/grammy.js +169 -0
  279. package/dist/entrypoints/application/opentelemetry.d.ts +2 -0
  280. package/dist/entrypoints/application/opentelemetry.d.ts.map +1 -0
  281. package/dist/entrypoints/application/opentelemetry.js +250 -0
  282. package/dist/entrypoints/application/schemas.d.ts +15 -0
  283. package/dist/entrypoints/application/schemas.d.ts.map +1 -0
  284. package/dist/entrypoints/application/schemas.js +27 -0
  285. package/dist/entrypoints/application.d.ts +23 -0
  286. package/dist/entrypoints/application.d.ts.map +1 -0
  287. package/dist/entrypoints/application.js +2016 -0
  288. package/dist/entrypoints/bin/upgrade-cli.d.ts.map +1 -0
  289. package/dist/entrypoints/bin/upgrade-cli.js +177 -0
  290. package/dist/entrypoints/cli.d.ts +44 -0
  291. package/dist/entrypoints/cli.d.ts.map +1 -0
  292. package/dist/entrypoints/cli.js +773 -0
  293. package/dist/entrypoints/contract.d.ts +12 -0
  294. package/dist/entrypoints/contract.d.ts.map +1 -0
  295. package/dist/entrypoints/contract.js +64 -0
  296. package/dist/entrypoints/declaration.d.ts +2 -0
  297. package/dist/entrypoints/declaration.d.ts.map +1 -0
  298. package/dist/entrypoints/declaration.js +183 -0
  299. package/dist/entrypoints/files.d.ts +5 -0
  300. package/dist/entrypoints/files.d.ts.map +1 -0
  301. package/dist/entrypoints/files.js +111 -0
  302. package/dist/entrypoints/geo.d.ts +3 -0
  303. package/dist/entrypoints/geo.d.ts.map +1 -0
  304. package/dist/entrypoints/geo.js +245 -0
  305. package/dist/entrypoints/google.d.ts +2 -0
  306. package/dist/entrypoints/google.d.ts.map +1 -0
  307. package/dist/entrypoints/google.js +175 -0
  308. package/dist/entrypoints/index.d.ts +17 -0
  309. package/dist/entrypoints/index.d.ts.map +1 -0
  310. package/dist/entrypoints/index.js +764 -0
  311. package/dist/entrypoints/live.d.ts +19 -0
  312. package/dist/entrypoints/live.d.ts.map +1 -0
  313. package/dist/entrypoints/live.js +302 -0
  314. package/dist/entrypoints/node.d.ts +19 -0
  315. package/dist/entrypoints/node.d.ts.map +1 -0
  316. package/dist/entrypoints/node.js +308 -0
  317. package/dist/entrypoints/oauth.d.ts +2 -0
  318. package/dist/entrypoints/oauth.d.ts.map +1 -0
  319. package/dist/entrypoints/oauth.js +170 -0
  320. package/dist/entrypoints/observability.d.ts +19 -0
  321. package/dist/entrypoints/observability.d.ts.map +1 -0
  322. package/dist/entrypoints/observability.js +567 -0
  323. package/dist/entrypoints/primitives.d.ts +3 -0
  324. package/dist/entrypoints/primitives.d.ts.map +1 -0
  325. package/dist/entrypoints/primitives.js +749 -0
  326. package/dist/entrypoints/react.d.ts +5 -0
  327. package/dist/entrypoints/react.d.ts.map +1 -0
  328. package/dist/entrypoints/react.js +403 -0
  329. package/dist/entrypoints/release.d.ts +15 -0
  330. package/dist/entrypoints/release.d.ts.map +1 -0
  331. package/dist/entrypoints/release.js +196 -0
  332. package/dist/entrypoints/remote.d.ts +9 -0
  333. package/dist/entrypoints/remote.d.ts.map +1 -0
  334. package/dist/entrypoints/remote.js +66 -0
  335. package/dist/entrypoints/server.d.ts +39 -0
  336. package/dist/entrypoints/server.d.ts.map +1 -0
  337. package/dist/entrypoints/server.js +2009 -0
  338. package/dist/entrypoints/telegram.d.ts +3 -0
  339. package/dist/entrypoints/telegram.d.ts.map +1 -0
  340. package/dist/entrypoints/telegram.js +224 -0
  341. package/dist/entrypoints/testing.d.ts +10 -0
  342. package/dist/entrypoints/testing.d.ts.map +1 -0
  343. package/dist/entrypoints/testing.js +1377 -0
  344. package/dist/entrypoints/tools/connections.d.ts +19 -0
  345. package/dist/entrypoints/tools/connections.d.ts.map +1 -0
  346. package/dist/entrypoints/tools/connections.js +1110 -0
  347. package/dist/entrypoints/tools/contract.d.ts +29 -0
  348. package/dist/entrypoints/tools/contract.d.ts.map +1 -0
  349. package/dist/entrypoints/tools/contract.js +24 -0
  350. package/dist/entrypoints/tools/invoker.d.ts +9 -0
  351. package/dist/entrypoints/tools/invoker.d.ts.map +1 -0
  352. package/dist/entrypoints/tools/invoker.js +20 -0
  353. package/dist/entrypoints/tools.d.ts +54 -0
  354. package/dist/entrypoints/tools.d.ts.map +1 -0
  355. package/dist/entrypoints/tools.js +3009 -0
  356. package/dist/entrypoints/tracking/server.d.ts +15 -0
  357. package/dist/entrypoints/tracking/server.d.ts.map +1 -0
  358. package/dist/entrypoints/tracking.d.ts +24 -0
  359. package/dist/entrypoints/tracking.d.ts.map +1 -0
  360. package/dist/entrypoints/tracking.js +1140 -0
  361. package/dist/files/boundary.d.ts.map +1 -1
  362. package/dist/files/file-io.d.ts +14 -0
  363. package/dist/files/file-io.d.ts.map +1 -0
  364. package/dist/google/google.d.ts.map +1 -0
  365. package/dist/index-0b1ess5e.js +38 -0
  366. package/dist/index-1j8pm5t0.js +412 -0
  367. package/dist/index-1zbbzgfh.js +89 -0
  368. package/dist/index-2bxbyab0.js +47 -0
  369. package/dist/index-2gxzjvyr.js +266 -0
  370. package/dist/index-35mh5bhj.js +177 -0
  371. package/dist/index-48ffdxgk.js +6 -0
  372. package/dist/index-4gcnakhx.js +82 -0
  373. package/dist/index-55hkhm67.js +343 -0
  374. package/dist/index-79z7m7dt.js +675 -0
  375. package/dist/index-7f68ghdn.js +3618 -0
  376. package/dist/index-7p1f0vp2.js +154 -0
  377. package/dist/index-83bdg97s.js +16 -0
  378. package/dist/index-863ea9jb.js +154 -0
  379. package/dist/index-8p52kd5p.js +242 -0
  380. package/dist/index-d9pk3td4.js +326 -0
  381. package/dist/index-dce5wxcq.js +63 -0
  382. package/dist/index-e01r054k.js +105 -0
  383. package/dist/index-ensd0r74.js +595 -0
  384. package/dist/index-eqqvgdb3.js +46 -0
  385. package/dist/index-gxrt5h6v.js +341 -0
  386. package/dist/index-h6eeys1v.js +211 -0
  387. package/dist/index-ham5sz8m.js +734 -0
  388. package/dist/index-het2he5g.js +1387 -0
  389. package/dist/index-hffjpmq9.js +30 -0
  390. package/dist/index-hmp4800j.js +51 -0
  391. package/dist/index-k30h66yd.js +317 -0
  392. package/dist/index-k5hsfc3j.js +31 -0
  393. package/dist/index-khtgb21r.js +92 -0
  394. package/dist/index-m9zn6cpq.js +51 -0
  395. package/dist/index-ndddxtyx.js +324 -0
  396. package/dist/index-ngfhvfpd.js +30 -0
  397. package/dist/index-np4m8hd3.js +1205 -0
  398. package/dist/index-p3vsv1fb.js +3493 -0
  399. package/dist/index-p5r7qpdd.js +85 -0
  400. package/dist/index-p9e0w8hs.js +1084 -0
  401. package/dist/index-p9sh0xx4.js +64 -0
  402. package/dist/index-paz6sgdp.js +371 -0
  403. package/dist/index-px2gm2jp.js +448 -0
  404. package/dist/index-qwhynv6x.js +103 -0
  405. package/dist/index-s812ycat.js +65 -0
  406. package/dist/index-sp1tzwnb.js +281 -0
  407. package/dist/index-t9rhjr9f.js +2306 -0
  408. package/dist/index-v260df89.js +342 -0
  409. package/dist/index-w906953s.js +946 -0
  410. package/dist/index-wdkt63w3.js +214 -0
  411. package/dist/index-wqgjfstn.js +18 -0
  412. package/dist/index-wsm5w4ee.js +1023 -0
  413. package/dist/index-xw3s75nj.js +100 -0
  414. package/dist/index-yw4fzmdz.js +268 -0
  415. package/dist/index-zfrhfn82.js +85 -0
  416. package/dist/index-znfs20ss.js +98 -0
  417. package/dist/internal/atomic-file.d.ts +23 -2
  418. package/dist/internal/atomic-file.d.ts.map +1 -1
  419. package/dist/internal/backoff.d.ts +29 -0
  420. package/dist/internal/backoff.d.ts.map +1 -0
  421. package/dist/internal/canonical-json.d.ts +21 -11
  422. package/dist/internal/canonical-json.d.ts.map +1 -1
  423. package/dist/internal/channel.d.ts.map +1 -0
  424. package/dist/internal/exclusive-lock.d.ts +51 -0
  425. package/dist/internal/exclusive-lock.d.ts.map +1 -0
  426. package/dist/internal/logger.d.ts.map +1 -0
  427. package/dist/internal/process-identity.d.ts +47 -0
  428. package/dist/internal/process-identity.d.ts.map +1 -0
  429. package/dist/internal/request.d.ts.map +1 -0
  430. package/dist/internal/stable-digest.d.ts +0 -43
  431. package/dist/internal/stable-digest.d.ts.map +1 -1
  432. package/dist/internal/typed.d.ts +0 -8
  433. package/dist/internal/typed.d.ts.map +1 -1
  434. package/dist/internal/with-exclusive-lock.d.ts +67 -0
  435. package/dist/internal/with-exclusive-lock.d.ts.map +1 -0
  436. package/dist/internal/zod-issues.d.ts +38 -0
  437. package/dist/internal/zod-issues.d.ts.map +1 -0
  438. package/dist/json-schema/dialect.d.ts +17 -0
  439. package/dist/json-schema/dialect.d.ts.map +1 -0
  440. package/dist/json-schema/json-schema.d.ts.map +1 -0
  441. package/dist/live/watch-client.d.ts.map +1 -1
  442. package/dist/live/watch-delta.d.ts.map +1 -1
  443. package/dist/oauth/authorization-code.d.ts +57 -0
  444. package/dist/oauth/authorization-code.d.ts.map +1 -0
  445. package/dist/observability/audit.d.ts +3 -3
  446. package/dist/observability/audit.d.ts.map +1 -1
  447. package/dist/observability/bounded-logger.d.ts +1 -1
  448. package/dist/observability/bounded-logger.d.ts.map +1 -1
  449. package/dist/observability/bounded-sink.d.ts +81 -0
  450. package/dist/observability/bounded-sink.d.ts.map +1 -0
  451. package/dist/observability/context.d.ts +1 -1
  452. package/dist/observability/context.d.ts.map +1 -1
  453. package/dist/observability/event.d.ts +2 -1
  454. package/dist/observability/event.d.ts.map +1 -1
  455. package/dist/observability/work.d.ts +1 -1
  456. package/dist/observability/work.d.ts.map +1 -1
  457. package/dist/primitives/audit.d.ts +1 -1
  458. package/dist/primitives/audit.d.ts.map +1 -1
  459. package/dist/primitives/export-operation.d.ts +4 -2
  460. package/dist/primitives/export-operation.d.ts.map +1 -1
  461. package/dist/realtime/registry.d.ts +0 -5
  462. package/dist/realtime/registry.d.ts.map +1 -1
  463. package/dist/realtime/socket.d.ts +1 -1
  464. package/dist/realtime/socket.d.ts.map +1 -1
  465. package/dist/server/bun.d.ts +0 -1
  466. package/dist/server/bun.d.ts.map +1 -1
  467. package/dist/server/context-contribution.d.ts +1 -1
  468. package/dist/server/context-contribution.d.ts.map +1 -1
  469. package/dist/server/context.d.ts +2 -2
  470. package/dist/server/context.d.ts.map +1 -1
  471. package/dist/server/contract-method.d.ts +15 -0
  472. package/dist/server/contract-method.d.ts.map +1 -0
  473. package/dist/server/contract-stream.d.ts +1 -1
  474. package/dist/server/contract-stream.d.ts.map +1 -1
  475. package/dist/server/create.d.ts +8 -0
  476. package/dist/server/create.d.ts.map +1 -1
  477. package/dist/server/endpoint-dispatch.d.ts +10 -0
  478. package/dist/server/endpoint-dispatch.d.ts.map +1 -0
  479. package/dist/server/endpoint-response.d.ts +19 -0
  480. package/dist/server/endpoint-response.d.ts.map +1 -0
  481. package/dist/server/error-dispatch.d.ts +17 -1
  482. package/dist/server/error-dispatch.d.ts.map +1 -1
  483. package/dist/server/error-hook.d.ts +2 -2
  484. package/dist/server/error-hook.d.ts.map +1 -1
  485. package/dist/server/handler-state.d.ts +44 -0
  486. package/dist/server/handler-state.d.ts.map +1 -0
  487. package/dist/server/implement-registry.d.ts +54 -0
  488. package/dist/server/implement-registry.d.ts.map +1 -0
  489. package/dist/server/implement.d.ts +9 -55
  490. package/dist/server/implement.d.ts.map +1 -1
  491. package/dist/server/middleware/auth.d.ts +1 -31
  492. package/dist/server/middleware/auth.d.ts.map +1 -1
  493. package/dist/server/middleware/cors.d.ts +17 -0
  494. package/dist/server/middleware/cors.d.ts.map +1 -1
  495. package/dist/server/middleware/jwt.d.ts +31 -0
  496. package/dist/server/middleware/jwt.d.ts.map +1 -0
  497. package/dist/server/middleware/trust-fence.d.ts +1 -1
  498. package/dist/server/middleware/trust-fence.d.ts.map +1 -1
  499. package/dist/server/multipart-reader.d.ts +22 -0
  500. package/dist/server/multipart-reader.d.ts.map +1 -0
  501. package/dist/server/multipart.d.ts +1 -1
  502. package/dist/server/multipart.d.ts.map +1 -1
  503. package/dist/server/oauth/cimd.d.ts +88 -0
  504. package/dist/server/oauth/cimd.d.ts.map +1 -0
  505. package/dist/server/oauth/endpoints.d.ts +39 -0
  506. package/dist/server/oauth/endpoints.d.ts.map +1 -0
  507. package/dist/server/oauth/metadata.d.ts +28 -0
  508. package/dist/server/oauth/metadata.d.ts.map +1 -0
  509. package/dist/server/oauth/provider.d.ts +117 -0
  510. package/dist/server/oauth/provider.d.ts.map +1 -0
  511. package/dist/server/realtime.d.ts +1 -1
  512. package/dist/server/realtime.d.ts.map +1 -1
  513. package/dist/server/request-completion.d.ts +16 -0
  514. package/dist/server/request-completion.d.ts.map +1 -0
  515. package/dist/server/response-metadata.d.ts +1 -1
  516. package/dist/server/response-metadata.d.ts.map +1 -1
  517. package/dist/server/route-table.d.ts +9 -0
  518. package/dist/server/route-table.d.ts.map +1 -0
  519. package/dist/server/stream.d.ts +0 -13
  520. package/dist/server/stream.d.ts.map +1 -1
  521. package/dist/server/streaming-pump.d.ts +66 -0
  522. package/dist/server/streaming-pump.d.ts.map +1 -0
  523. package/dist/server/streaming-route.d.ts +12 -5
  524. package/dist/server/streaming-route.d.ts.map +1 -1
  525. package/dist/server/types.d.ts +10 -4
  526. package/dist/server/types.d.ts.map +1 -1
  527. package/dist/server/unix-client-bun.d.ts.map +1 -1
  528. package/dist/server/unix-client-http1.d.ts +76 -0
  529. package/dist/server/unix-client-http1.d.ts.map +1 -0
  530. package/dist/server/unix-client.d.ts.map +1 -1
  531. package/dist/testing/handler-clients.d.ts +32 -0
  532. package/dist/testing/handler-clients.d.ts.map +1 -0
  533. package/dist/testing/managed-resource-conformance-scenarios.d.ts.map +1 -1
  534. package/dist/testing/realtime-probe.d.ts +33 -0
  535. package/dist/testing/realtime-probe.d.ts.map +1 -0
  536. package/dist/testing/surface-conformance.d.ts +2 -32
  537. package/dist/testing/surface-conformance.d.ts.map +1 -1
  538. package/dist/testing/surface-manifest-digest.d.ts +44 -0
  539. package/dist/testing/surface-manifest-digest.d.ts.map +1 -0
  540. package/dist/testing/surface-manifest.d.ts +30 -4
  541. package/dist/testing/surface-manifest.d.ts.map +1 -1
  542. package/dist/tools/agent.d.ts +1 -1
  543. package/dist/tools/agent.d.ts.map +1 -1
  544. package/dist/tools/cli/args-fields.d.ts +31 -0
  545. package/dist/tools/cli/args-fields.d.ts.map +1 -0
  546. package/dist/tools/cli/args-route.d.ts +42 -0
  547. package/dist/tools/cli/args-route.d.ts.map +1 -0
  548. package/dist/tools/cli/args-view.d.ts +32 -0
  549. package/dist/tools/cli/args-view.d.ts.map +1 -0
  550. package/dist/tools/cli/args.d.ts +80 -0
  551. package/dist/tools/cli/args.d.ts.map +1 -0
  552. package/dist/tools/cli/argument-error.d.ts +5 -0
  553. package/dist/tools/cli/argument-error.d.ts.map +1 -0
  554. package/dist/tools/cli/checkpoint.d.ts +24 -0
  555. package/dist/tools/cli/checkpoint.d.ts.map +1 -0
  556. package/dist/tools/cli/command.d.ts +70 -0
  557. package/dist/tools/cli/command.d.ts.map +1 -0
  558. package/dist/tools/cli/config.d.ts +90 -0
  559. package/dist/tools/cli/config.d.ts.map +1 -0
  560. package/dist/tools/cli/create-cli.d.ts +36 -0
  561. package/dist/tools/cli/create-cli.d.ts.map +1 -0
  562. package/dist/tools/cli/download.d.ts +8 -0
  563. package/dist/tools/cli/download.d.ts.map +1 -0
  564. package/dist/tools/cli/format.d.ts +50 -0
  565. package/dist/tools/cli/format.d.ts.map +1 -0
  566. package/dist/tools/cli/help.d.ts +24 -0
  567. package/dist/tools/cli/help.d.ts.map +1 -0
  568. package/dist/tools/cli/installer.d.ts +34 -0
  569. package/dist/tools/cli/installer.d.ts.map +1 -0
  570. package/dist/tools/cli/invoke.d.ts +144 -0
  571. package/dist/tools/cli/invoke.d.ts.map +1 -0
  572. package/dist/tools/cli/io.d.ts +10 -0
  573. package/dist/tools/cli/io.d.ts.map +1 -0
  574. package/dist/tools/cli/managed-surface.d.ts +30 -0
  575. package/dist/tools/cli/managed-surface.d.ts.map +1 -0
  576. package/dist/tools/cli/manifest.d.ts +80 -0
  577. package/dist/tools/cli/manifest.d.ts.map +1 -0
  578. package/dist/tools/cli/policy.d.ts +27 -0
  579. package/dist/tools/cli/policy.d.ts.map +1 -0
  580. package/dist/tools/cli/prepare.d.ts +14 -0
  581. package/dist/tools/cli/prepare.d.ts.map +1 -0
  582. package/dist/tools/cli/profile.d.ts +40 -0
  583. package/dist/tools/cli/profile.d.ts.map +1 -0
  584. package/dist/tools/cli/run-managed.d.ts +5 -0
  585. package/dist/tools/cli/run-managed.d.ts.map +1 -0
  586. package/dist/tools/cli/run-native.d.ts +9 -0
  587. package/dist/tools/cli/run-native.d.ts.map +1 -0
  588. package/dist/tools/cli/session.d.ts +40 -0
  589. package/dist/tools/cli/session.d.ts.map +1 -0
  590. package/dist/tools/cli/signature.d.ts +81 -0
  591. package/dist/tools/cli/signature.d.ts.map +1 -0
  592. package/dist/tools/cli/stream.d.ts +93 -0
  593. package/dist/tools/cli/stream.d.ts.map +1 -0
  594. package/dist/tools/cli/update.d.ts +145 -0
  595. package/dist/tools/cli/update.d.ts.map +1 -0
  596. package/dist/tools/cli/view.d.ts +12 -0
  597. package/dist/tools/cli/view.d.ts.map +1 -0
  598. package/dist/tools/cli/wait.d.ts +54 -0
  599. package/dist/tools/cli/wait.d.ts.map +1 -0
  600. package/dist/tools/connections/runtime.d.ts +1 -1
  601. package/dist/tools/connections/runtime.d.ts.map +1 -1
  602. package/dist/tools/connections/types.d.ts +3 -3
  603. package/dist/tools/connections/types.d.ts.map +1 -1
  604. package/dist/tools/durability-context.d.ts +1 -1
  605. package/dist/tools/durability-context.d.ts.map +1 -1
  606. package/dist/tools/execute-args.d.ts +23 -0
  607. package/dist/tools/execute-args.d.ts.map +1 -0
  608. package/dist/tools/execute-hooks.d.ts +146 -0
  609. package/dist/tools/execute-hooks.d.ts.map +1 -0
  610. package/dist/tools/execute-result.d.ts +40 -0
  611. package/dist/tools/execute-result.d.ts.map +1 -0
  612. package/dist/tools/execute.d.ts +31 -193
  613. package/dist/tools/execute.d.ts.map +1 -1
  614. package/dist/tools/internal/surface-projector.d.ts +9 -6
  615. package/dist/tools/internal/surface-projector.d.ts.map +1 -1
  616. package/dist/tools/internal/tool-view.d.ts +41 -0
  617. package/dist/tools/internal/tool-view.d.ts.map +1 -0
  618. package/dist/tools/invoker.d.ts +13 -4
  619. package/dist/tools/invoker.d.ts.map +1 -1
  620. package/dist/tools/lifecycle.d.ts +1 -1
  621. package/dist/tools/lifecycle.d.ts.map +1 -1
  622. package/dist/tools/list-names.d.ts +3 -3
  623. package/dist/tools/list-names.d.ts.map +1 -1
  624. package/dist/tools/manifest.d.ts +2 -2
  625. package/dist/tools/manifest.d.ts.map +1 -1
  626. package/dist/tools/mcp/app.d.ts +62 -0
  627. package/dist/tools/mcp/app.d.ts.map +1 -0
  628. package/dist/tools/mcp/catalog.d.ts +68 -0
  629. package/dist/tools/mcp/catalog.d.ts.map +1 -0
  630. package/dist/tools/mcp/handler.d.ts +46 -0
  631. package/dist/tools/mcp/handler.d.ts.map +1 -0
  632. package/dist/tools/mcp/mount.d.ts +152 -0
  633. package/dist/tools/mcp/mount.d.ts.map +1 -0
  634. package/dist/tools/mcp/prepare.d.ts +76 -0
  635. package/dist/tools/mcp/prepare.d.ts.map +1 -0
  636. package/dist/tools/mcp/progress.d.ts +46 -0
  637. package/dist/tools/mcp/progress.d.ts.map +1 -0
  638. package/dist/tools/mcp/register.d.ts +36 -0
  639. package/dist/tools/mcp/register.d.ts.map +1 -0
  640. package/dist/tools/mcp/round-context.d.ts +38 -0
  641. package/dist/tools/mcp/round-context.d.ts.map +1 -0
  642. package/dist/tools/mcp/round-policy.d.ts +33 -0
  643. package/dist/tools/mcp/round-policy.d.ts.map +1 -0
  644. package/dist/tools/mcp/round.d.ts +53 -0
  645. package/dist/tools/mcp/round.d.ts.map +1 -0
  646. package/dist/tools/mcp/runtime-tools.d.ts +25 -0
  647. package/dist/tools/mcp/runtime-tools.d.ts.map +1 -0
  648. package/dist/tools/mcp/stdio-signals.d.ts +33 -0
  649. package/dist/tools/mcp/stdio-signals.d.ts.map +1 -0
  650. package/dist/tools/mcp/stdio.d.ts +20 -0
  651. package/dist/tools/mcp/stdio.d.ts.map +1 -0
  652. package/dist/tools/mcp/trace.d.ts +12 -0
  653. package/dist/tools/mcp/trace.d.ts.map +1 -0
  654. package/dist/tools/mount.d.ts +14 -7
  655. package/dist/tools/mount.d.ts.map +1 -1
  656. package/dist/tools/native-definition.d.ts +4 -3
  657. package/dist/tools/native-definition.d.ts.map +1 -1
  658. package/dist/tools/operations/async-operation-binding-types.d.ts +127 -0
  659. package/dist/tools/operations/async-operation-binding-types.d.ts.map +1 -0
  660. package/dist/tools/operations/async-operation-binding.d.ts +28 -0
  661. package/dist/tools/operations/async-operation-binding.d.ts.map +1 -0
  662. package/dist/tools/operations/async-operation-canonical-types.d.ts +110 -0
  663. package/dist/tools/operations/async-operation-canonical-types.d.ts.map +1 -0
  664. package/dist/tools/operations/async-operation-canonical.d.ts +7 -0
  665. package/dist/tools/operations/async-operation-canonical.d.ts.map +1 -0
  666. package/dist/tools/operations/async-operation-contract.d.ts.map +1 -0
  667. package/dist/tools/operations/async-operation-id.d.ts +23 -0
  668. package/dist/tools/operations/async-operation-id.d.ts.map +1 -0
  669. package/dist/tools/operations/async-operation-runtime-tools.d.ts +41 -0
  670. package/dist/tools/operations/async-operation-runtime-tools.d.ts.map +1 -0
  671. package/dist/tools/operations/async-operation-runtime-types.d.ts +69 -0
  672. package/dist/tools/operations/async-operation-runtime-types.d.ts.map +1 -0
  673. package/dist/tools/operations/async-operation-runtime.d.ts +5 -0
  674. package/dist/tools/operations/async-operation-runtime.d.ts.map +1 -0
  675. package/dist/tools/operations/define-wait-tool.d.ts +22 -0
  676. package/dist/tools/operations/define-wait-tool.d.ts.map +1 -0
  677. package/dist/tools/operations/mount-wait.d.ts.map +1 -0
  678. package/dist/tools/operations/wait-core.d.ts.map +1 -0
  679. package/dist/tools/remote.d.ts +1 -1
  680. package/dist/tools/remote.d.ts.map +1 -1
  681. package/dist/tools/runtime-tool.d.ts +13 -4
  682. package/dist/tools/runtime-tool.d.ts.map +1 -1
  683. package/dist/tools/schema/coerce.d.ts.map +1 -0
  684. package/dist/tools/schema/flatten-join.d.ts.map +1 -0
  685. package/dist/tools/schema/flatten.d.ts.map +1 -0
  686. package/dist/tools/schema/portable-formats.d.ts.map +1 -0
  687. package/dist/tools/schema/presentation.d.ts +24 -0
  688. package/dist/tools/schema/presentation.d.ts.map +1 -0
  689. package/dist/tools/schema/schema.d.ts.map +1 -0
  690. package/dist/tools/schema/untyped-properties.d.ts.map +1 -0
  691. package/dist/tools/surface.d.ts +2 -3
  692. package/dist/tools/surface.d.ts.map +1 -1
  693. package/dist/tools/tool-logger.d.ts +1 -1
  694. package/dist/tools/tool-logger.d.ts.map +1 -1
  695. package/dist/tools/toolkit.d.ts +4 -4
  696. package/dist/tools/toolkit.d.ts.map +1 -1
  697. package/dist/tools/transfer/define-download-tool.d.ts +18 -0
  698. package/dist/tools/transfer/define-download-tool.d.ts.map +1 -0
  699. package/dist/tools/transfer/define-upload-tool.d.ts +16 -0
  700. package/dist/tools/transfer/define-upload-tool.d.ts.map +1 -0
  701. package/dist/tools/transfer/define-view-file-tool.d.ts +10 -0
  702. package/dist/tools/transfer/define-view-file-tool.d.ts.map +1 -0
  703. package/dist/tools/transfer/download-core.d.ts +20 -0
  704. package/dist/tools/transfer/download-core.d.ts.map +1 -0
  705. package/dist/tools/transfer/managed-file-error.d.ts +6 -0
  706. package/dist/tools/transfer/managed-file-error.d.ts.map +1 -0
  707. package/dist/tools/transfer/mount-download.d.ts +41 -0
  708. package/dist/tools/transfer/mount-download.d.ts.map +1 -0
  709. package/dist/tools/transfer/mount-upload.d.ts +21 -0
  710. package/dist/tools/transfer/mount-upload.d.ts.map +1 -0
  711. package/dist/tools/transfer/native-result.d.ts.map +1 -0
  712. package/dist/tools/transfer/upload-core.d.ts +4 -0
  713. package/dist/tools/transfer/upload-core.d.ts.map +1 -0
  714. package/dist/tools/transfer/view-file-contract.d.ts.map +1 -0
  715. package/dist/tools/transfer/view-file.d.ts +62 -0
  716. package/dist/tools/transfer/view-file.d.ts.map +1 -0
  717. package/dist/tools/transports.d.ts +1 -1
  718. package/dist/tools/transports.d.ts.map +1 -1
  719. package/dist/tracking/client-listeners.d.ts +30 -0
  720. package/dist/tracking/client-listeners.d.ts.map +1 -0
  721. package/dist/tracking/client-visit.d.ts +61 -0
  722. package/dist/tracking/client-visit.d.ts.map +1 -0
  723. package/dist/tracking/client.d.ts +3 -2
  724. package/dist/tracking/client.d.ts.map +1 -1
  725. package/dist/tracking/contract.d.ts +1 -1
  726. package/dist/tracking/contract.d.ts.map +1 -1
  727. package/llms/agent-runtime-browser.txt +33 -0
  728. package/llms/agent-runtime-coding-tools.txt +58 -0
  729. package/llms/agent-runtime-harness.txt +45 -0
  730. package/llms/agent-runtime-openrouter.txt +22 -0
  731. package/llms/agent-runtime-sandbox.txt +159 -0
  732. package/llms/agent-runtime-sqlite-bun.txt +29 -0
  733. package/llms/agent-runtime-sqlite-node.txt +26 -0
  734. package/llms/agent-runtime-testing.txt +30 -0
  735. package/llms/agent-runtime.2.txt +550 -0
  736. package/llms/agent-runtime.3.txt +311 -0
  737. package/llms/agent-runtime.txt +893 -0
  738. package/llms/application-diagnostic-journal.txt +30 -0
  739. package/llms/application-grammy.txt +27 -0
  740. package/llms/application-opentelemetry.txt +27 -0
  741. package/llms/application-schemas.txt +42 -0
  742. package/llms/application.2.txt +487 -0
  743. package/llms/application.txt +886 -0
  744. package/llms/cli.2.txt +80 -0
  745. package/llms/cli.txt +948 -0
  746. package/llms/contract.txt +606 -0
  747. package/llms/declaration.txt +286 -0
  748. package/llms/files.txt +33 -0
  749. package/llms/geo.txt +114 -0
  750. package/llms/google.txt +27 -0
  751. package/llms/live.txt +471 -0
  752. package/llms/node.txt +43 -0
  753. package/llms/oauth.txt +136 -0
  754. package/llms/observability.txt +893 -0
  755. package/llms/primitives.txt +158 -0
  756. package/llms/react.txt +184 -0
  757. package/llms/release.txt +176 -0
  758. package/llms/remote.txt +25 -0
  759. package/llms/server.2.txt +361 -0
  760. package/llms/server.3.txt +1031 -0
  761. package/llms/server.4.txt +905 -0
  762. package/llms/server.5.txt +250 -0
  763. package/llms/server.txt +996 -0
  764. package/llms/stitchkit.2.txt +836 -0
  765. package/llms/stitchkit.3.txt +147 -0
  766. package/llms/stitchkit.txt +260 -0
  767. package/llms/telegram.txt +30 -0
  768. package/llms/testing.txt +676 -0
  769. package/llms/tools-connections.txt +45 -0
  770. package/llms/tools-contract.txt +9 -0
  771. package/llms/tools-invoker.txt +9 -0
  772. package/llms/tools.2.txt +647 -0
  773. package/llms/tools.3.txt +288 -0
  774. package/llms/tools.txt +966 -0
  775. package/llms/tracking-server.txt +32 -0
  776. package/llms/tracking.txt +263 -0
  777. package/llms/upgrading-0.37.0-0.50.0.txt +947 -0
  778. package/llms/upgrading-0.53.0-0.67.0.txt +1174 -0
  779. package/llms/upgrading-0.68.0-0.94.0.txt +1159 -0
  780. package/llms/upgrading.txt +215 -0
  781. package/llms-full.txt +312 -77
  782. package/llms.txt +54 -5
  783. package/package.json +84 -83
  784. package/dist/agent-runtime/durability-contract.d.ts +0 -176
  785. package/dist/agent-runtime/durability-contract.d.ts.map +0 -1
  786. package/dist/agent-runtime/durability-json.d.ts +0 -3
  787. package/dist/agent-runtime/durability-json.d.ts.map +0 -1
  788. package/dist/agent-runtime/durability-ledger.d.ts +0 -16
  789. package/dist/agent-runtime/durability-ledger.d.ts.map +0 -1
  790. package/dist/agent-runtime/durability-scheduler.d.ts +0 -29
  791. package/dist/agent-runtime/durability-scheduler.d.ts.map +0 -1
  792. package/dist/agent-runtime/durability.d.ts +0 -14
  793. package/dist/agent-runtime/durability.d.ts.map +0 -1
  794. package/dist/agent-runtime/store-driver.d.ts +0 -814
  795. package/dist/agent-runtime/store-driver.d.ts.map +0 -1
  796. package/dist/agent-runtime-browser.d.ts +0 -5
  797. package/dist/agent-runtime-browser.d.ts.map +0 -1
  798. package/dist/agent-runtime-browser.js +0 -124
  799. package/dist/agent-runtime-coding-tools.d.ts +0 -2
  800. package/dist/agent-runtime-coding-tools.d.ts.map +0 -1
  801. package/dist/agent-runtime-coding-tools.js +0 -23
  802. package/dist/agent-runtime-harness.d.ts +0 -2
  803. package/dist/agent-runtime-harness.d.ts.map +0 -1
  804. package/dist/agent-runtime-harness.js +0 -729
  805. package/dist/agent-runtime-openrouter.d.ts +0 -29
  806. package/dist/agent-runtime-openrouter.d.ts.map +0 -1
  807. package/dist/agent-runtime-openrouter.js +0 -270
  808. package/dist/agent-runtime-sandbox.d.ts +0 -5
  809. package/dist/agent-runtime-sandbox.d.ts.map +0 -1
  810. package/dist/agent-runtime-sandbox.js +0 -798
  811. package/dist/agent-runtime-sqlite-bun.d.ts +0 -11
  812. package/dist/agent-runtime-sqlite-bun.d.ts.map +0 -1
  813. package/dist/agent-runtime-sqlite-bun.js +0 -42
  814. package/dist/agent-runtime-sqlite-node.d.ts +0 -11
  815. package/dist/agent-runtime-sqlite-node.d.ts.map +0 -1
  816. package/dist/agent-runtime-sqlite-node.js +0 -44
  817. package/dist/agent-runtime-testing.d.ts +0 -3
  818. package/dist/agent-runtime-testing.d.ts.map +0 -1
  819. package/dist/agent-runtime-testing.js +0 -156
  820. package/dist/agent-runtime.d.ts +0 -38
  821. package/dist/agent-runtime.d.ts.map +0 -1
  822. package/dist/agent-runtime.js +0 -2607
  823. package/dist/application/channel.d.ts.map +0 -1
  824. package/dist/application-diagnostic-journal.d.ts +0 -21
  825. package/dist/application-diagnostic-journal.d.ts.map +0 -1
  826. package/dist/application-diagnostic-journal.js +0 -632
  827. package/dist/application-grammy.d.ts +0 -2
  828. package/dist/application-grammy.d.ts.map +0 -1
  829. package/dist/application-grammy.js +0 -169
  830. package/dist/application-opentelemetry.d.ts +0 -2
  831. package/dist/application-opentelemetry.d.ts.map +0 -1
  832. package/dist/application-opentelemetry.js +0 -250
  833. package/dist/application-schemas.d.ts +0 -15
  834. package/dist/application-schemas.d.ts.map +0 -1
  835. package/dist/application-schemas.js +0 -27
  836. package/dist/application.d.ts +0 -22
  837. package/dist/application.d.ts.map +0 -1
  838. package/dist/application.js +0 -1977
  839. package/dist/cli.d.ts +0 -41
  840. package/dist/cli.d.ts.map +0 -1
  841. package/dist/cli.js +0 -753
  842. package/dist/contract/index.d.ts +0 -8
  843. package/dist/contract/index.d.ts.map +0 -1
  844. package/dist/contract/index.js +0 -55
  845. package/dist/declaration.d.ts.map +0 -1
  846. package/dist/declaration.js +0 -183
  847. package/dist/files.d.ts +0 -3
  848. package/dist/files.d.ts.map +0 -1
  849. package/dist/files.js +0 -15
  850. package/dist/geo.d.ts +0 -3
  851. package/dist/geo.d.ts.map +0 -1
  852. package/dist/geo.js +0 -245
  853. package/dist/google.d.ts.map +0 -1
  854. package/dist/google.js +0 -175
  855. package/dist/index-0a349c33.js +0 -470
  856. package/dist/index-0j3vcp5m.js +0 -28
  857. package/dist/index-2c2bjw3s.js +0 -51
  858. package/dist/index-2na0qrfn.js +0 -214
  859. package/dist/index-2qzskm8h.js +0 -63
  860. package/dist/index-3bmnp41g.js +0 -2169
  861. package/dist/index-3xwxfj4z.js +0 -334
  862. package/dist/index-4fpa9dy2.js +0 -51
  863. package/dist/index-6kyksz9y.js +0 -268
  864. package/dist/index-77fekveh.js +0 -44
  865. package/dist/index-7gnkny4z.js +0 -326
  866. package/dist/index-7zbps32p.js +0 -89
  867. package/dist/index-9f8ztey6.js +0 -588
  868. package/dist/index-a11g2kry.js +0 -866
  869. package/dist/index-a916km3r.js +0 -45
  870. package/dist/index-actkayzn.js +0 -367
  871. package/dist/index-bn2cjajt.js +0 -524
  872. package/dist/index-bx75zwt7.js +0 -63
  873. package/dist/index-cby4ar3v.js +0 -46
  874. package/dist/index-cnyk6te3.js +0 -77
  875. package/dist/index-cxqhvq21.js +0 -413
  876. package/dist/index-e0znv5gn.js +0 -176
  877. package/dist/index-e42wzzz5.js +0 -154
  878. package/dist/index-f477k430.js +0 -324
  879. package/dist/index-f9mb610r.js +0 -177
  880. package/dist/index-fadnxwna.js +0 -1046
  881. package/dist/index-fq77yfzc.js +0 -1303
  882. package/dist/index-h9etkkyk.js +0 -1126
  883. package/dist/index-hrbajay7.js +0 -1196
  884. package/dist/index-kw9t5ayn.js +0 -507
  885. package/dist/index-mzvgxp0n.js +0 -80
  886. package/dist/index-n0f51dfn.js +0 -3170
  887. package/dist/index-p13mwz16.js +0 -16
  888. package/dist/index-s8cnx02s.js +0 -90
  889. package/dist/index-sr93cwf9.js +0 -325
  890. package/dist/index-tmwcrptx.js +0 -85
  891. package/dist/index-v5573g1k.js +0 -142
  892. package/dist/index-vjpvjqpn.js +0 -86
  893. package/dist/index-vk3kq9sb.js +0 -3344
  894. package/dist/index-wc4x00bn.js +0 -103
  895. package/dist/index-wnfk50r0.js +0 -211
  896. package/dist/index-yewwh1w4.js +0 -647
  897. package/dist/index-yn8remb1.js +0 -290
  898. package/dist/index-ywd0y6m1.js +0 -394
  899. package/dist/index-zwkgfq1s.js +0 -345
  900. package/dist/index.d.ts +0 -14
  901. package/dist/index.d.ts.map +0 -1
  902. package/dist/index.js +0 -632
  903. package/dist/internal/errors.d.ts +0 -92
  904. package/dist/internal/errors.d.ts.map +0 -1
  905. package/dist/internal/observability-sink.d.ts +0 -81
  906. package/dist/internal/observability-sink.d.ts.map +0 -1
  907. package/dist/live.d.ts +0 -19
  908. package/dist/live.d.ts.map +0 -1
  909. package/dist/live.js +0 -282
  910. package/dist/logger.d.ts.map +0 -1
  911. package/dist/node.d.ts +0 -18
  912. package/dist/node.d.ts.map +0 -1
  913. package/dist/node.js +0 -303
  914. package/dist/oauth.d.ts +0 -57
  915. package/dist/oauth.d.ts.map +0 -1
  916. package/dist/oauth.js +0 -170
  917. package/dist/observability/index.d.ts +0 -19
  918. package/dist/observability/index.d.ts.map +0 -1
  919. package/dist/observability/index.js +0 -569
  920. package/dist/primitives.d.ts +0 -3
  921. package/dist/primitives.d.ts.map +0 -1
  922. package/dist/primitives.js +0 -754
  923. package/dist/react.d.ts +0 -5
  924. package/dist/react.d.ts.map +0 -1
  925. package/dist/react.js +0 -403
  926. package/dist/release.d.ts +0 -15
  927. package/dist/release.d.ts.map +0 -1
  928. package/dist/release.js +0 -196
  929. package/dist/remote.d.ts +0 -9
  930. package/dist/remote.d.ts.map +0 -1
  931. package/dist/remote.js +0 -88
  932. package/dist/retained.d.ts.map +0 -1
  933. package/dist/server/file-state-store.d.ts +0 -23
  934. package/dist/server/file-state-store.d.ts.map +0 -1
  935. package/dist/server/index.d.ts +0 -36
  936. package/dist/server/index.d.ts.map +0 -1
  937. package/dist/server/index.js +0 -1745
  938. package/dist/server/request.d.ts.map +0 -1
  939. package/dist/telegram.d.ts +0 -3
  940. package/dist/telegram.d.ts.map +0 -1
  941. package/dist/telegram.js +0 -224
  942. package/dist/testing/agent-store-conformance.d.ts +0 -40
  943. package/dist/testing/agent-store-conformance.d.ts.map +0 -1
  944. package/dist/testing.d.ts +0 -39
  945. package/dist/testing.d.ts.map +0 -1
  946. package/dist/testing.js +0 -2209
  947. package/dist/tool-invoker.d.ts +0 -9
  948. package/dist/tool-invoker.d.ts.map +0 -1
  949. package/dist/tool-invoker.js +0 -21
  950. package/dist/tools/async-operation-contract.d.ts.map +0 -1
  951. package/dist/tools/async-operation.d.ts +0 -332
  952. package/dist/tools/async-operation.d.ts.map +0 -1
  953. package/dist/tools/cli-args.d.ts +0 -143
  954. package/dist/tools/cli-args.d.ts.map +0 -1
  955. package/dist/tools/cli-checkpoint.d.ts +0 -24
  956. package/dist/tools/cli-checkpoint.d.ts.map +0 -1
  957. package/dist/tools/cli-command.d.ts +0 -70
  958. package/dist/tools/cli-command.d.ts.map +0 -1
  959. package/dist/tools/cli-format.d.ts +0 -49
  960. package/dist/tools/cli-format.d.ts.map +0 -1
  961. package/dist/tools/cli-installer.d.ts +0 -34
  962. package/dist/tools/cli-installer.d.ts.map +0 -1
  963. package/dist/tools/cli-invoke.d.ts +0 -143
  964. package/dist/tools/cli-invoke.d.ts.map +0 -1
  965. package/dist/tools/cli-manifest.d.ts +0 -80
  966. package/dist/tools/cli-manifest.d.ts.map +0 -1
  967. package/dist/tools/cli-policy.d.ts +0 -27
  968. package/dist/tools/cli-policy.d.ts.map +0 -1
  969. package/dist/tools/cli-profile.d.ts +0 -40
  970. package/dist/tools/cli-profile.d.ts.map +0 -1
  971. package/dist/tools/cli-signature.d.ts +0 -81
  972. package/dist/tools/cli-signature.d.ts.map +0 -1
  973. package/dist/tools/cli-stream.d.ts +0 -93
  974. package/dist/tools/cli-stream.d.ts.map +0 -1
  975. package/dist/tools/cli-update.d.ts +0 -126
  976. package/dist/tools/cli-update.d.ts.map +0 -1
  977. package/dist/tools/cli-view.d.ts +0 -12
  978. package/dist/tools/cli-view.d.ts.map +0 -1
  979. package/dist/tools/cli-wait.d.ts +0 -54
  980. package/dist/tools/cli-wait.d.ts.map +0 -1
  981. package/dist/tools/cli.d.ts +0 -94
  982. package/dist/tools/cli.d.ts.map +0 -1
  983. package/dist/tools/coerce.d.ts.map +0 -1
  984. package/dist/tools/connections/index.d.ts +0 -20
  985. package/dist/tools/connections/index.d.ts.map +0 -1
  986. package/dist/tools/connections/index.js +0 -1107
  987. package/dist/tools/define-download-tool.d.ts +0 -18
  988. package/dist/tools/define-download-tool.d.ts.map +0 -1
  989. package/dist/tools/define-upload-tool.d.ts +0 -16
  990. package/dist/tools/define-upload-tool.d.ts.map +0 -1
  991. package/dist/tools/define-view-file-tool.d.ts +0 -10
  992. package/dist/tools/define-view-file-tool.d.ts.map +0 -1
  993. package/dist/tools/define-wait-tool.d.ts +0 -22
  994. package/dist/tools/define-wait-tool.d.ts.map +0 -1
  995. package/dist/tools/download-core.d.ts +0 -20
  996. package/dist/tools/download-core.d.ts.map +0 -1
  997. package/dist/tools/flatten-join.d.ts.map +0 -1
  998. package/dist/tools/flatten.d.ts.map +0 -1
  999. package/dist/tools/json-schema-dialect.d.ts +0 -17
  1000. package/dist/tools/json-schema-dialect.d.ts.map +0 -1
  1001. package/dist/tools/json-schema.d.ts.map +0 -1
  1002. package/dist/tools/managed-file-error.d.ts +0 -6
  1003. package/dist/tools/managed-file-error.d.ts.map +0 -1
  1004. package/dist/tools/mcp-app.d.ts +0 -62
  1005. package/dist/tools/mcp-app.d.ts.map +0 -1
  1006. package/dist/tools/mcp-catalog.d.ts +0 -68
  1007. package/dist/tools/mcp-catalog.d.ts.map +0 -1
  1008. package/dist/tools/mcp-handler.d.ts +0 -46
  1009. package/dist/tools/mcp-handler.d.ts.map +0 -1
  1010. package/dist/tools/mcp-prepare.d.ts +0 -75
  1011. package/dist/tools/mcp-prepare.d.ts.map +0 -1
  1012. package/dist/tools/mcp-progress.d.ts +0 -46
  1013. package/dist/tools/mcp-progress.d.ts.map +0 -1
  1014. package/dist/tools/mcp-round-policy.d.ts +0 -33
  1015. package/dist/tools/mcp-round-policy.d.ts.map +0 -1
  1016. package/dist/tools/mcp-round.d.ts +0 -61
  1017. package/dist/tools/mcp-round.d.ts.map +0 -1
  1018. package/dist/tools/mcp-stdio-signals.d.ts +0 -33
  1019. package/dist/tools/mcp-stdio-signals.d.ts.map +0 -1
  1020. package/dist/tools/mcp-stdio.d.ts +0 -20
  1021. package/dist/tools/mcp-stdio.d.ts.map +0 -1
  1022. package/dist/tools/mcp-trace.d.ts +0 -12
  1023. package/dist/tools/mcp-trace.d.ts.map +0 -1
  1024. package/dist/tools/mcp.d.ts +0 -152
  1025. package/dist/tools/mcp.d.ts.map +0 -1
  1026. package/dist/tools/mount-download.d.ts +0 -41
  1027. package/dist/tools/mount-download.d.ts.map +0 -1
  1028. package/dist/tools/mount-upload.d.ts +0 -21
  1029. package/dist/tools/mount-upload.d.ts.map +0 -1
  1030. package/dist/tools/mount-wait.d.ts.map +0 -1
  1031. package/dist/tools/native-mcp.d.ts +0 -20
  1032. package/dist/tools/native-mcp.d.ts.map +0 -1
  1033. package/dist/tools/native-result.d.ts.map +0 -1
  1034. package/dist/tools/oauth-metadata.d.ts +0 -28
  1035. package/dist/tools/oauth-metadata.d.ts.map +0 -1
  1036. package/dist/tools/oauth-provider.d.ts +0 -184
  1037. package/dist/tools/oauth-provider.d.ts.map +0 -1
  1038. package/dist/tools/portable-formats.d.ts.map +0 -1
  1039. package/dist/tools/presentation.d.ts +0 -22
  1040. package/dist/tools/presentation.d.ts.map +0 -1
  1041. package/dist/tools/schema.d.ts.map +0 -1
  1042. package/dist/tools/untyped-properties.d.ts.map +0 -1
  1043. package/dist/tools/upload-core.d.ts +0 -4
  1044. package/dist/tools/upload-core.d.ts.map +0 -1
  1045. package/dist/tools/view-file-contract.d.ts.map +0 -1
  1046. package/dist/tools/view-file.d.ts +0 -62
  1047. package/dist/tools/view-file.d.ts.map +0 -1
  1048. package/dist/tools/wait-core.d.ts.map +0 -1
  1049. package/dist/tools-contract.d.ts +0 -29
  1050. package/dist/tools-contract.d.ts.map +0 -1
  1051. package/dist/tools-contract.js +0 -24
  1052. package/dist/tools.d.ts +0 -50
  1053. package/dist/tools.d.ts.map +0 -1
  1054. package/dist/tools.js +0 -2930
  1055. package/dist/tracking-server.d.ts +0 -15
  1056. package/dist/tracking-server.d.ts.map +0 -1
  1057. package/dist/tracking.d.ts +0 -24
  1058. package/dist/tracking.d.ts.map +0 -1
  1059. package/dist/tracking.js +0 -1092
  1060. package/dist/upgrade-cli.d.ts.map +0 -1
  1061. package/dist/upgrade-cli.js +0 -177
  1062. /package/dist/{retained.d.ts → browser/retained.d.ts} +0 -0
  1063. /package/dist/{declaration.d.ts → declaration/declaration.d.ts} +0 -0
  1064. /package/dist/{upgrade-cli.d.ts → entrypoints/bin/upgrade-cli.d.ts} +0 -0
  1065. /package/dist/{tracking-server.js → entrypoints/tracking/server.js} +0 -0
  1066. /package/dist/{google.d.ts → google/google.d.ts} +0 -0
  1067. /package/dist/{index-pq95qkbf.js → index-5jm36zv1.js} +0 -0
  1068. /package/dist/{application → internal}/channel.d.ts +0 -0
  1069. /package/dist/{logger.d.ts → internal/logger.d.ts} +0 -0
  1070. /package/dist/{server → internal}/request.d.ts +0 -0
  1071. /package/dist/{tools → json-schema}/json-schema.d.ts +0 -0
  1072. /package/dist/tools/{async-operation-contract.d.ts → operations/async-operation-contract.d.ts} +0 -0
  1073. /package/dist/tools/{mount-wait.d.ts → operations/mount-wait.d.ts} +0 -0
  1074. /package/dist/tools/{wait-core.d.ts → operations/wait-core.d.ts} +0 -0
  1075. /package/dist/tools/{coerce.d.ts → schema/coerce.d.ts} +0 -0
  1076. /package/dist/tools/{flatten-join.d.ts → schema/flatten-join.d.ts} +0 -0
  1077. /package/dist/tools/{flatten.d.ts → schema/flatten.d.ts} +0 -0
  1078. /package/dist/tools/{portable-formats.d.ts → schema/portable-formats.d.ts} +0 -0
  1079. /package/dist/tools/{schema.d.ts → schema/schema.d.ts} +0 -0
  1080. /package/dist/tools/{untyped-properties.d.ts → schema/untyped-properties.d.ts} +0 -0
  1081. /package/dist/tools/{native-result.d.ts → transfer/native-result.d.ts} +0 -0
  1082. /package/dist/tools/{view-file-contract.d.ts → transfer/view-file-contract.d.ts} +0 -0
@@ -0,0 +1,2016 @@
1
+ import {
2
+ ActivityIdSchema,
3
+ ActivityLiveStateSchema,
4
+ ActivitySnapshotSchema,
5
+ ActivityStageIdSchema,
6
+ ActivityStageSnapshotSchema,
7
+ ActivityTokenBrand,
8
+ ApplicationSnapshotSinkStatusSchema,
9
+ ManagedScheduleDescriptorSchema,
10
+ ManagedScheduleErrorPolicySchema,
11
+ ManagedScheduleOverlapSchema,
12
+ ManagedScheduleStatusSchema,
13
+ createActivityProjection,
14
+ createApplicationSnapshotSink,
15
+ createManagedSchedule
16
+ } from "../index-ensd0r74.js";
17
+ import {
18
+ DiagnosticJournalCloseResultSchema,
19
+ DiagnosticJournalFailurePhaseSchema,
20
+ DiagnosticJournalFrameSchema,
21
+ DiagnosticJournalLimitsSchema,
22
+ DiagnosticJournalLockPolicySchema,
23
+ DiagnosticJournalRefusalReasonSchema,
24
+ DiagnosticJournalStateSchema,
25
+ DiagnosticJournalStatusSchema,
26
+ DiagnosticJournalSubmitResultSchema,
27
+ DiagnosticJournalWaitResultSchema,
28
+ readDiagnosticJournalLockDiagnosis
29
+ } from "../index-qwhynv6x.js";
30
+ import"../index-5jm36zv1.js";
31
+ import {
32
+ ApplicationAdmissionError,
33
+ ApplicationRestartInputSchema,
34
+ ApplicationRestartOutcomeSchema,
35
+ ApplicationRestartResultSchema,
36
+ ApplicationShutdownBudgetSchema,
37
+ ApplicationShutdownOptionsSchema,
38
+ createApplication
39
+ } from "../index-w906953s.js";
40
+ import {
41
+ ApplicationAdmissionSnapshotSchema,
42
+ ApplicationHealthSchema,
43
+ ApplicationIdSchema,
44
+ ApplicationLifecycleSchema,
45
+ ApplicationResourceShutdownSchema,
46
+ ApplicationShutdownResultSchema,
47
+ ApplicationSnapshotSchema,
48
+ ApplicationStatusProjectionSchema,
49
+ ManagedResourceSnapshotSchema,
50
+ ManagedResourceStateSchema,
51
+ projectApplicationStatus
52
+ } from "../index-3gye9wzb.js";
53
+ import {
54
+ defineManagedResource,
55
+ managedResourceDependencyId
56
+ } from "../index-2k4yrqkc.js";
57
+ import {
58
+ withDeadline
59
+ } from "../index-b9aefrqd.js";
60
+ import"../index-3z73fh2c.js";
61
+ import {
62
+ createBoundedSinkManager
63
+ } from "../index-h6eeys1v.js";
64
+ import {
65
+ backoffDelay,
66
+ createBackoff
67
+ } from "../index-ngfhvfpd.js";
68
+ import {
69
+ deltaWins,
70
+ diff,
71
+ watchKeyString
72
+ } from "../index-wdkt63w3.js";
73
+ import"../index-1j8pm5t0.js";
74
+ import {
75
+ BoundedChannelPolicySchema,
76
+ BoundedChannelReaderError,
77
+ BoundedChannelSnapshotSchema,
78
+ BoundedChannelStateSchema,
79
+ CreditWindowSnapshotSchema,
80
+ createBoundedChannel,
81
+ createCreditWindow
82
+ } from "../index-d9pk3td4.js";
83
+ import {
84
+ measureSize
85
+ } from "../index-yw4fzmdz.js";
86
+ import {
87
+ argumentsDigest
88
+ } from "../index-0b1ess5e.js";
89
+ import"../index-2vtcmrj9.js";
90
+ import {
91
+ serializeCanonicalJson
92
+ } from "../index-k5hsfc3j.js";
93
+ import"../index-kzfs85xp.js";
94
+ import"../index-hffjpmq9.js";
95
+ // src/application/admission.ts
96
+ import { z } from "zod";
97
+
98
+ // src/application/admission-rate.ts
99
+ function pruneRate(samples, intervalMs, at) {
100
+ let expired = 0;
101
+ while (expired < samples.length && at - (samples[expired]?.at ?? at) >= intervalMs) {
102
+ expired += 1;
103
+ }
104
+ if (expired > 0)
105
+ samples.splice(0, expired);
106
+ }
107
+ function pruneExpired(policy, globalRate, keys, at) {
108
+ if (policy.global.rate)
109
+ pruneRate(globalRate, policy.global.rate.intervalMs, at);
110
+ for (const [key, record] of keys) {
111
+ if (record.limits?.rate)
112
+ pruneRate(record.rate, record.limits.rate.intervalMs, at);
113
+ if (record.active === 0 && record.rate.length === 0)
114
+ keys.delete(key);
115
+ }
116
+ }
117
+ function retryAfter(samples, budget, at) {
118
+ return Math.max(1, Math.ceil(budget.intervalMs - (at - (samples[0]?.at ?? at))));
119
+ }
120
+ function removeSample(samples, sample) {
121
+ if (!sample)
122
+ return;
123
+ const index = samples.indexOf(sample);
124
+ if (index >= 0)
125
+ samples.splice(index, 1);
126
+ }
127
+
128
+ // src/application/admission-run.ts
129
+ async function runAdmitted(acquire, key, work, options) {
130
+ if (options.timeoutMs !== undefined) {
131
+ if (!Number.isSafeInteger(options.timeoutMs) || options.timeoutMs < 0) {
132
+ throw new TypeError("run timeoutMs must be a non-negative safe integer");
133
+ }
134
+ }
135
+ if (options.signal?.aborted)
136
+ throw new BoundedOperationWaitError("cancelled");
137
+ const admission = acquire(key);
138
+ if (admission.outcome === "refused") {
139
+ throw new BoundedAdmissionRefusalError(admission.reason, admission.retryAfterMs);
140
+ }
141
+ const workAbort = new AbortController;
142
+ const abortWork = () => workAbort.abort(options.signal?.reason);
143
+ options.signal?.addEventListener("abort", abortWork, { once: true });
144
+ let timer;
145
+ let timedOut = false;
146
+ if (options.timeoutMs !== undefined) {
147
+ timer = setTimeout(() => {
148
+ timedOut = true;
149
+ workAbort.abort(new DOMException("Operation wait timed out", "TimeoutError"));
150
+ }, options.timeoutMs);
151
+ }
152
+ const outcome = Promise.resolve().then(() => work({ signal: workAbort.signal })).then((value) => ({ kind: "value", value }), (error) => ({ kind: "error", error })).finally(() => admission.lease.release());
153
+ const callerDone = new Promise((resolve) => {
154
+ const settle = () => resolve({ kind: "caller" });
155
+ if (workAbort.signal.aborted)
156
+ settle();
157
+ else
158
+ workAbort.signal.addEventListener("abort", settle, { once: true });
159
+ });
160
+ try {
161
+ const settled = await Promise.race([outcome, callerDone]);
162
+ if (settled.kind === "caller") {
163
+ throw new BoundedOperationWaitError(timedOut ? "timed-out" : "cancelled");
164
+ }
165
+ if (settled.kind === "error")
166
+ throw settled.error;
167
+ return settled.value;
168
+ } finally {
169
+ if (timer !== undefined)
170
+ clearTimeout(timer);
171
+ options.signal?.removeEventListener("abort", abortWork);
172
+ }
173
+ }
174
+
175
+ // src/application/admission.ts
176
+ var PositiveSafeIntegerSchema = z.number().int().positive().safe();
177
+ var BoundedRateBudgetSchema = z.object({
178
+ limit: PositiveSafeIntegerSchema,
179
+ intervalMs: PositiveSafeIntegerSchema
180
+ }).strict().readonly();
181
+ var BoundedAdmissionPerKeyLimitsSchema = z.object({
182
+ maxConcurrent: PositiveSafeIntegerSchema,
183
+ rate: BoundedRateBudgetSchema.optional()
184
+ }).strict().readonly();
185
+ var PerKeyLimitResolverSchema = z.custom((value) => typeof value === "function", { message: "perKey.limits must be a function of the key" });
186
+ var BoundedAdmissionPolicySchema = z.object({
187
+ global: z.object({
188
+ maxConcurrent: PositiveSafeIntegerSchema,
189
+ rate: BoundedRateBudgetSchema.optional()
190
+ }).strict(),
191
+ perKey: z.union([
192
+ z.object({
193
+ maxConcurrent: PositiveSafeIntegerSchema,
194
+ maxKeys: PositiveSafeIntegerSchema,
195
+ rate: BoundedRateBudgetSchema.optional(),
196
+ limits: z.never().optional()
197
+ }).strict(),
198
+ z.object({
199
+ maxKeys: PositiveSafeIntegerSchema,
200
+ limits: PerKeyLimitResolverSchema,
201
+ maxConcurrent: z.never().optional(),
202
+ rate: z.never().optional()
203
+ }).strict()
204
+ ]).optional()
205
+ }).strict().readonly();
206
+ var BoundedAdmissionStateSchema = z.enum(["accepting", "draining", "closed"]);
207
+ var BoundedAdmissionRefusalReasonSchema = z.enum([
208
+ "not-accepting",
209
+ "global-concurrency",
210
+ "key-required",
211
+ "key-capacity",
212
+ "key-concurrency",
213
+ "global-rate",
214
+ "key-rate",
215
+ "upstream"
216
+ ]);
217
+ var RefusalCountersSchema = z.object({
218
+ "not-accepting": z.number().int().nonnegative(),
219
+ "global-concurrency": z.number().int().nonnegative(),
220
+ "key-required": z.number().int().nonnegative(),
221
+ "key-capacity": z.number().int().nonnegative(),
222
+ "key-concurrency": z.number().int().nonnegative(),
223
+ "global-rate": z.number().int().nonnegative(),
224
+ "key-rate": z.number().int().nonnegative(),
225
+ upstream: z.number().int().nonnegative()
226
+ }).strict().readonly();
227
+ var BoundedAdmissionSnapshotSchema = z.object({
228
+ state: BoundedAdmissionStateSchema,
229
+ active: z.number().int().nonnegative(),
230
+ accepted: z.number().int().nonnegative(),
231
+ released: z.number().int().nonnegative(),
232
+ refused: z.number().int().nonnegative(),
233
+ keys: z.number().int().nonnegative(),
234
+ globalRateSamples: z.number().int().nonnegative(),
235
+ keyRateSamples: z.number().int().nonnegative(),
236
+ refusals: RefusalCountersSchema
237
+ }).strict().readonly();
238
+
239
+ class BoundedAdmissionRefusalError extends Error {
240
+ reason;
241
+ retryAfterMs;
242
+ constructor(reason, retryAfterMs) {
243
+ super(`Bounded admission refused: ${reason}`);
244
+ this.reason = reason;
245
+ this.retryAfterMs = retryAfterMs;
246
+ this.name = "BoundedAdmissionRefusalError";
247
+ }
248
+ }
249
+
250
+ class BoundedOperationWaitError extends Error {
251
+ reason;
252
+ constructor(reason) {
253
+ super(reason === "cancelled" ? "Operation wait was cancelled" : "Operation wait timed out");
254
+ this.reason = reason;
255
+ this.name = "BoundedOperationWaitError";
256
+ }
257
+ }
258
+ var NO_REFUSALS = {
259
+ "not-accepting": 0,
260
+ "global-concurrency": 0,
261
+ "key-required": 0,
262
+ "key-capacity": 0,
263
+ "key-concurrency": 0,
264
+ "global-rate": 0,
265
+ "key-rate": 0,
266
+ upstream: 0
267
+ };
268
+ async function waitForDrain(drainWaiters, options) {
269
+ const controller = new AbortController;
270
+ let timer;
271
+ const abort = () => controller.abort();
272
+ if (options.signal?.aborted)
273
+ abort();
274
+ else
275
+ options.signal?.addEventListener("abort", abort, { once: true });
276
+ if (options.timeoutMs !== undefined) {
277
+ if (!Number.isSafeInteger(options.timeoutMs) || options.timeoutMs < 0) {
278
+ throw new TypeError("drain timeoutMs must be a non-negative safe integer");
279
+ }
280
+ timer = setTimeout(abort, options.timeoutMs);
281
+ }
282
+ let resolveDrained;
283
+ try {
284
+ await Promise.race([
285
+ new Promise((resolve) => {
286
+ resolveDrained = resolve;
287
+ drainWaiters.add(resolve);
288
+ }),
289
+ new Promise((resolve) => {
290
+ if (controller.signal.aborted)
291
+ resolve();
292
+ else
293
+ controller.signal.addEventListener("abort", () => resolve(), { once: true });
294
+ })
295
+ ]);
296
+ } finally {
297
+ if (timer !== undefined)
298
+ clearTimeout(timer);
299
+ options.signal?.removeEventListener("abort", abort);
300
+ if (resolveDrained)
301
+ drainWaiters.delete(resolveDrained);
302
+ }
303
+ }
304
+ function createBoundedAdmission(config) {
305
+ const policy = BoundedAdmissionPolicySchema.parse(config.policy);
306
+ const clock = config.clock ?? { now: () => performance.now() };
307
+ const keys = new Map;
308
+ const globalRate = [];
309
+ const drainWaiters = new Set;
310
+ const refusals = { ...NO_REFUSALS };
311
+ let state = "accepting";
312
+ let active = 0;
313
+ let accepted = 0;
314
+ let released = 0;
315
+ let refused = 0;
316
+ let lastNow = Number.NEGATIVE_INFINITY;
317
+ const now = () => {
318
+ const value = clock.now();
319
+ if (!Number.isFinite(value))
320
+ throw new TypeError("Bounded admission clock must be finite");
321
+ if (value < lastNow)
322
+ throw new Error("Bounded admission clock moved backwards");
323
+ lastNow = value;
324
+ return value;
325
+ };
326
+ const resolveKeyLimits = (key) => {
327
+ const perKey = policy.perKey;
328
+ if (!perKey)
329
+ return;
330
+ const resolver = perKey.limits;
331
+ if (resolver)
332
+ return BoundedAdmissionPerKeyLimitsSchema.parse(resolver(key));
333
+ return BoundedAdmissionPerKeyLimitsSchema.parse({
334
+ maxConcurrent: perKey.maxConcurrent,
335
+ ...perKey.rate && { rate: perKey.rate }
336
+ });
337
+ };
338
+ const prune = (at) => pruneExpired(policy, globalRate, keys, at);
339
+ const refuse = (reason, retryAfterMs) => {
340
+ refused += 1;
341
+ refusals[reason] += 1;
342
+ return {
343
+ outcome: "refused",
344
+ reason,
345
+ ...retryAfterMs !== undefined && { retryAfterMs }
346
+ };
347
+ };
348
+ const closeIfDrained = () => {
349
+ if (state !== "draining" || active !== 0)
350
+ return;
351
+ state = "closed";
352
+ for (const resolve of drainWaiters)
353
+ resolve();
354
+ drainWaiters.clear();
355
+ };
356
+ const rollbackReservation = (key, keyRecord, globalSample, keySample) => {
357
+ active -= 1;
358
+ if (keyRecord)
359
+ keyRecord.active -= 1;
360
+ removeSample(globalRate, globalSample);
361
+ if (keyRecord)
362
+ removeSample(keyRecord.rate, keySample);
363
+ if (key !== undefined && keyRecord?.active === 0 && keyRecord.rate.length === 0) {
364
+ keys.delete(key);
365
+ }
366
+ };
367
+ const acquire = (key) => {
368
+ const at = now();
369
+ prune(at);
370
+ if (state !== "accepting")
371
+ return refuse("not-accepting");
372
+ if (active >= policy.global.maxConcurrent)
373
+ return refuse("global-concurrency");
374
+ if (policy.perKey && key === undefined)
375
+ return refuse("key-required");
376
+ let keyRecord = key === undefined ? undefined : keys.get(key);
377
+ if (policy.perKey && key !== undefined) {
378
+ if (!keyRecord && keys.size >= policy.perKey.maxKeys)
379
+ return refuse("key-capacity");
380
+ if (keyRecord?.limits && keyRecord.active >= keyRecord.limits.maxConcurrent) {
381
+ return refuse("key-concurrency");
382
+ }
383
+ }
384
+ if (policy.global.rate && globalRate.length >= policy.global.rate.limit) {
385
+ return refuse("global-rate", retryAfter(globalRate, policy.global.rate, at));
386
+ }
387
+ const keyRate = keyRecord?.limits?.rate;
388
+ if (keyRate && keyRecord && keyRecord.rate.length >= keyRate.limit) {
389
+ return refuse("key-rate", retryAfter(keyRecord.rate, keyRate, at));
390
+ }
391
+ if (key !== undefined && !keyRecord) {
392
+ keyRecord = { active: 0, rate: [], limits: resolveKeyLimits(key) };
393
+ keys.set(key, keyRecord);
394
+ }
395
+ const globalSample = policy.global.rate ? { at } : undefined;
396
+ const keySample = keyRecord?.limits?.rate ? { at } : undefined;
397
+ active += 1;
398
+ if (keyRecord)
399
+ keyRecord.active += 1;
400
+ if (globalSample)
401
+ globalRate.push(globalSample);
402
+ if (keySample && keyRecord)
403
+ keyRecord.rate.push(keySample);
404
+ const upstreamLease = config.upstream?.acquire();
405
+ if (config.upstream && !upstreamLease) {
406
+ rollbackReservation(key, keyRecord, globalSample, keySample);
407
+ return refuse("upstream");
408
+ }
409
+ accepted += 1;
410
+ let leaseReleased = false;
411
+ const lease = {
412
+ ...key !== undefined && { key },
413
+ get released() {
414
+ return leaseReleased;
415
+ },
416
+ release() {
417
+ if (leaseReleased)
418
+ return;
419
+ leaseReleased = true;
420
+ active -= 1;
421
+ if (keyRecord)
422
+ keyRecord.active -= 1;
423
+ released += 1;
424
+ if (key !== undefined && keyRecord?.active === 0 && keyRecord.rate.length === 0) {
425
+ keys.delete(key);
426
+ }
427
+ upstreamLease?.release();
428
+ closeIfDrained();
429
+ }
430
+ };
431
+ return { outcome: "leased", lease };
432
+ };
433
+ const getSnapshot = () => {
434
+ const at = now();
435
+ prune(at);
436
+ let keyRateSamples = 0;
437
+ for (const record of keys.values())
438
+ keyRateSamples += record.rate.length;
439
+ return BoundedAdmissionSnapshotSchema.parse({
440
+ state,
441
+ active,
442
+ accepted,
443
+ released,
444
+ refused,
445
+ keys: keys.size,
446
+ globalRateSamples: globalRate.length,
447
+ keyRateSamples,
448
+ refusals
449
+ });
450
+ };
451
+ const stopAdmission = () => {
452
+ if (state === "accepting")
453
+ state = "draining";
454
+ closeIfDrained();
455
+ return getSnapshot();
456
+ };
457
+ const drain = async (options = {}) => {
458
+ stopAdmission();
459
+ if (active === 0)
460
+ return { drained: true, remaining: 0 };
461
+ await waitForDrain(drainWaiters, options);
462
+ return { drained: active === 0, remaining: active };
463
+ };
464
+ const run = (key, work, options = {}) => runAdmitted(acquire, key, work, options);
465
+ return {
466
+ acquire,
467
+ run,
468
+ stopAdmission,
469
+ drain,
470
+ force() {
471
+ if (state === "accepting")
472
+ state = "draining";
473
+ state = "closed";
474
+ for (const resolve of drainWaiters)
475
+ resolve();
476
+ drainWaiters.clear();
477
+ return { remaining: active };
478
+ },
479
+ getSnapshot
480
+ };
481
+ }
482
+ // src/internal/decision.ts
483
+ import { z as z2 } from "zod";
484
+ var PolicyDecisionSchema = z2.discriminatedUnion("outcome", [
485
+ z2.object({ outcome: z2.literal("allow") }).strict(),
486
+ z2.object({ outcome: z2.literal("deny"), reason: z2.string().min(1) }).strict(),
487
+ z2.object({ outcome: z2.literal("defer") }).strict()
488
+ ]);
489
+
490
+ // src/application/decisions.ts
491
+ class DecisionUndecidedError extends Error {
492
+ trace;
493
+ constructor(trace) {
494
+ const ran = trace.length === 0 ? "no policy ran" : trace.map((e) => e.id).join(" → ");
495
+ super(`Decision pipeline reached its end with no terminal verdict (${ran}). A pipeline needs a policy that answers allow or deny.`);
496
+ this.name = "DecisionUndecidedError";
497
+ this.trace = trace;
498
+ }
499
+ }
500
+
501
+ class DecisionPolicyError extends Error {
502
+ policyId;
503
+ trace;
504
+ constructor(policyId, detail, trace = []) {
505
+ super(`Policy "${policyId}" did not answer (${detail}). A policy returns { outcome: "allow" | "deny" | "defer" } within its deadline, and a deny carries a reason.`);
506
+ this.name = "DecisionPolicyError";
507
+ this.policyId = policyId;
508
+ this.trace = trace;
509
+ }
510
+ }
511
+ function createDecisionPipeline(policies, config) {
512
+ const { policyTimeoutMs } = config;
513
+ if (!Number.isInteger(policyTimeoutMs) || policyTimeoutMs <= 0) {
514
+ throw new Error("[stitchkit] decision pipeline: policyTimeoutMs must be a positive integer number of milliseconds.");
515
+ }
516
+ const seen = new Set;
517
+ for (const policy of policies) {
518
+ if (policy.id.trim() === "") {
519
+ throw new Error("[stitchkit] decision pipeline: a policy needs a non-empty id.");
520
+ }
521
+ if (seen.has(policy.id)) {
522
+ throw new Error(`[stitchkit] decision pipeline: two policies share the id "${policy.id}". The trace names policies by id, and a duplicate makes it ambiguous exactly when it is read to explain a refusal.`);
523
+ }
524
+ seen.add(policy.id);
525
+ }
526
+ return {
527
+ policyIds: policies.map((policy) => policy.id),
528
+ async decide(input) {
529
+ const trace = [];
530
+ for (const policy of policies) {
531
+ let answer;
532
+ try {
533
+ const outcome = await withDeadline(policy.decide(input), policyTimeoutMs);
534
+ if (!outcome.settled) {
535
+ throw new DecisionPolicyError(policy.id, `did not answer within ${policyTimeoutMs}ms`, trace);
536
+ }
537
+ answer = outcome.value;
538
+ } catch (error) {
539
+ if (error instanceof DecisionPolicyError)
540
+ throw error;
541
+ throw new DecisionPolicyError(policy.id, error instanceof Error ? `threw: ${error.message}` : "threw", trace);
542
+ }
543
+ const parsed = PolicyDecisionSchema.safeParse(answer);
544
+ if (!parsed.success) {
545
+ throw new DecisionPolicyError(policy.id, parsed.error.issues[0]?.message ?? "invalid", trace);
546
+ }
547
+ const decision = parsed.data;
548
+ trace.push(decision.outcome === "deny" ? { id: policy.id, outcome: "deny", reason: decision.reason } : { id: policy.id, outcome: decision.outcome });
549
+ if (decision.outcome === "deny") {
550
+ return { outcome: "deny", reason: decision.reason, trace };
551
+ }
552
+ if (decision.outcome === "allow") {
553
+ return { outcome: "allow", trace };
554
+ }
555
+ }
556
+ throw new DecisionUndecidedError(trace);
557
+ }
558
+ };
559
+ }
560
+ // src/application/events.ts
561
+ import { z as z3 } from "zod";
562
+ var ApplicationLifecycleEventSchema = z3.object({
563
+ type: z3.literal("application-state"),
564
+ applicationId: ApplicationIdSchema,
565
+ epoch: z3.string().uuid(),
566
+ revision: z3.number().int().nonnegative(),
567
+ lifecycle: ApplicationLifecycleSchema,
568
+ health: ApplicationHealthSchema,
569
+ ready: z3.boolean(),
570
+ capturedAt: z3.string().datetime({ offset: true }),
571
+ resources: z3.array(ManagedResourceSnapshotSchema).readonly()
572
+ }).strict().readonly();
573
+ function applicationLifecycleEvent(snapshot) {
574
+ return ApplicationLifecycleEventSchema.parse({
575
+ type: "application-state",
576
+ applicationId: snapshot.id,
577
+ epoch: snapshot.epoch,
578
+ revision: snapshot.revision,
579
+ lifecycle: snapshot.lifecycle,
580
+ health: snapshot.health,
581
+ ready: snapshot.ready,
582
+ capturedAt: snapshot.capturedAt,
583
+ resources: snapshot.resources
584
+ });
585
+ }
586
+ function createApplicationEventSink(config) {
587
+ const manager = createBoundedSinkManager({
588
+ write: config.write,
589
+ ...config.maxPending !== undefined && { maxPending: config.maxPending },
590
+ ...config.onSinkError && { onSinkError: config.onSinkError }
591
+ });
592
+ return {
593
+ publish(snapshot) {
594
+ manager.submit(() => applicationLifecycleEvent(snapshot));
595
+ },
596
+ flush: (bound) => manager.flush(bound),
597
+ getStatus: () => manager.getStatus(),
598
+ close: (bound) => manager.close(bound)
599
+ };
600
+ }
601
+ // src/application/health.ts
602
+ import { z as z4 } from "zod";
603
+ var ApplicationHealthHandlerOptionsSchema = z4.object({
604
+ kind: z4.enum(["liveness", "readiness"]),
605
+ retryAfterSeconds: z4.number().int().nonnegative().default(5)
606
+ });
607
+ var ApplicationOperationalHandlersOptionsSchema = z4.object({
608
+ retryAfterSeconds: z4.number().int().nonnegative().default(5)
609
+ });
610
+ function createApplicationHealthHandler(application, options) {
611
+ const parsed = ApplicationHealthHandlerOptionsSchema.parse(options);
612
+ return () => {
613
+ const snapshot = application.getSnapshot();
614
+ const healthy = parsed.kind === "readiness" ? snapshot.ready : snapshot.lifecycle !== "failed" && snapshot.lifecycle !== "stopped";
615
+ return Response.json(projectApplicationStatus(snapshot), {
616
+ status: healthy ? 200 : 503,
617
+ ...healthy ? {} : { headers: { "Retry-After": String(parsed.retryAfterSeconds) } }
618
+ });
619
+ };
620
+ }
621
+ function createApplicationOperationalHandlers(application, options = {}) {
622
+ const parsed = ApplicationOperationalHandlersOptionsSchema.parse(options);
623
+ return {
624
+ status: () => Response.json(projectApplicationStatus(application.getSnapshot())),
625
+ readiness: createApplicationHealthHandler(application, {
626
+ kind: "readiness",
627
+ retryAfterSeconds: parsed.retryAfterSeconds
628
+ }),
629
+ liveness: createApplicationHealthHandler(application, {
630
+ kind: "liveness",
631
+ retryAfterSeconds: parsed.retryAfterSeconds
632
+ })
633
+ };
634
+ }
635
+ // src/application/keyspace.ts
636
+ function defineKeyspace(name, declaration) {
637
+ if (name.trim() === "") {
638
+ throw new Error("[stitchkit] defineKeyspace: a keyspace needs a name.");
639
+ }
640
+ return { name, schema: declaration.schema, key: declaration.key };
641
+ }
642
+ async function openKeyspace(declaration, config) {
643
+ const machine = keyspaceMachine(declaration, config);
644
+ await machine.load();
645
+ return {
646
+ keyspace: machine.keyspace,
647
+ stopAdmission: machine.stopAdmission,
648
+ drain: machine.drain,
649
+ close: machine.close
650
+ };
651
+ }
652
+ function keyspaceResource(declaration, config) {
653
+ const machine = keyspaceMachine(declaration, config);
654
+ return {
655
+ id: config.id ?? `keyspace:${declaration.name}`,
656
+ ...config.dependsOn && { dependsOn: config.dependsOn },
657
+ async start(_context) {
658
+ await machine.open();
659
+ return { value: machine.keyspace };
660
+ },
661
+ stopAdmission: machine.stopAdmission,
662
+ drain: machine.drain,
663
+ close: machine.close,
664
+ force: machine.force
665
+ };
666
+ }
667
+ function keyspaceMachine(declaration, config) {
668
+ const maxPending = config.maxPendingWrites ?? 1024;
669
+ const records = new Map;
670
+ let admitting = true;
671
+ let backend;
672
+ const currentBackend = () => {
673
+ backend ??= typeof config.backend === "function" ? config.backend() : config.backend;
674
+ return backend;
675
+ };
676
+ let pending = 0;
677
+ let chain = Promise.resolve();
678
+ function run(work) {
679
+ if (!admitting) {
680
+ return Promise.reject(new Error(`[stitchkit] keyspace "${declaration.name}" is shutting down and is not accepting writes.`));
681
+ }
682
+ if (pending >= maxPending) {
683
+ return Promise.reject(new Error(`[stitchkit] keyspace "${declaration.name}": ${pending} writes are already waiting for the backend (limit ${maxPending}). The backend is not keeping up; queueing this one would trade a visible refusal for an invisible leak.`));
684
+ }
685
+ pending += 1;
686
+ const queued = chain.then(work, work);
687
+ chain = queued.then(() => {
688
+ return;
689
+ }, () => {
690
+ return;
691
+ });
692
+ return queued.finally(() => {
693
+ pending -= 1;
694
+ });
695
+ }
696
+ const keyspace = {
697
+ get: (key) => records.get(key),
698
+ list: () => [...records.values()],
699
+ get size() {
700
+ return records.size;
701
+ },
702
+ put(value) {
703
+ const parsed = declaration.schema.parse(value);
704
+ const key = declaration.key(parsed);
705
+ return run(async () => {
706
+ await currentBackend().put(key, parsed);
707
+ records.set(key, parsed);
708
+ config.onChanged?.({
709
+ keyspace: declaration.name,
710
+ key,
711
+ value: parsed,
712
+ change: "put"
713
+ });
714
+ });
715
+ },
716
+ delete(key) {
717
+ return run(async () => {
718
+ await currentBackend().delete(key);
719
+ records.delete(key);
720
+ config.onChanged?.({ keyspace: declaration.name, key, change: "delete" });
721
+ });
722
+ },
723
+ pendingWrites: () => pending
724
+ };
725
+ function reportUnwritten() {
726
+ if (pending > 0)
727
+ config.onUnwritten?.(pending);
728
+ }
729
+ return {
730
+ keyspace,
731
+ async load() {
732
+ for (const stored of await currentBackend().load()) {
733
+ const value = declaration.schema.parse(stored);
734
+ records.set(declaration.key(value), value);
735
+ }
736
+ },
737
+ async open() {
738
+ backend = undefined;
739
+ records.clear();
740
+ chain = Promise.resolve();
741
+ pending = 0;
742
+ admitting = true;
743
+ await this.load();
744
+ },
745
+ stopAdmission() {
746
+ admitting = false;
747
+ },
748
+ async drain() {
749
+ await chain;
750
+ },
751
+ async close() {
752
+ reportUnwritten();
753
+ await backend?.close?.();
754
+ },
755
+ force() {
756
+ reportUnwritten();
757
+ }
758
+ };
759
+ }
760
+ function memoryKeyspaceBackend() {
761
+ const stored = new Map;
762
+ return {
763
+ load: async () => [...stored.values()],
764
+ put: async (key, value) => {
765
+ stored.set(key, value);
766
+ },
767
+ delete: async (key) => {
768
+ stored.delete(key);
769
+ }
770
+ };
771
+ }
772
+ // src/application/keyspace-sqlite.ts
773
+ var IDENTIFIER = /^[A-Za-z_][A-Za-z0-9_]*$/;
774
+ function sqliteKeyspaceBackend(declaration, config) {
775
+ const table = config.table ?? `stitchkit_keyspace_${declaration.name}`;
776
+ if (!IDENTIFIER.test(table)) {
777
+ throw new Error(`[stitchkit] sqliteKeyspaceBackend: "${table}" is not a bare SQL identifier. A table name cannot be a bound parameter, so it is checked here rather than interpolated on trust. Pass \`table\` explicitly when the keyspace name is not identifier-shaped.`);
778
+ }
779
+ const database = config.database;
780
+ if (config.initialize !== false) {
781
+ database.exec(`CREATE TABLE IF NOT EXISTS ${table} (key TEXT PRIMARY KEY, payload TEXT NOT NULL)`);
782
+ }
783
+ return {
784
+ async load() {
785
+ const rows = database.prepare(`SELECT payload FROM ${table}`).all();
786
+ return rows.map((row) => {
787
+ const payload = Reflect.get(Object(row), "payload");
788
+ if (typeof payload !== "string") {
789
+ throw new Error(`[stitchkit] keyspace "${declaration.name}": a row in ${table} has no text payload.`);
790
+ }
791
+ return JSON.parse(payload);
792
+ });
793
+ },
794
+ async put(key, value) {
795
+ database.prepare(`INSERT INTO ${table} (key, payload) VALUES (?, ?)
796
+ ON CONFLICT(key) DO UPDATE SET payload = excluded.payload`).run(key, JSON.stringify(value));
797
+ },
798
+ async delete(key) {
799
+ database.prepare(`DELETE FROM ${table} WHERE key = ?`).run(key);
800
+ }
801
+ };
802
+ }
803
+ // src/application/notification-outbox.ts
804
+ import { z as z5 } from "zod";
805
+ function notificationOutboxStateSchema(payload) {
806
+ return z5.object({
807
+ schemaVersion: z5.literal(1),
808
+ queue: z5.array(z5.object({
809
+ key: z5.string().min(1).max(512),
810
+ payload,
811
+ createdAt: z5.string().datetime({ offset: true }),
812
+ attempts: z5.number().int().nonnegative(),
813
+ nextAttemptAt: z5.string().datetime({ offset: true }),
814
+ leaseOwner: z5.string().min(1).max(128).nullable(),
815
+ leaseId: z5.string().min(1).max(128).nullable(),
816
+ leaseUntil: z5.string().datetime({ offset: true }).nullable()
817
+ }).strict()),
818
+ receipts: z5.array(z5.object({
819
+ key: z5.string().min(1).max(512),
820
+ completedAt: z5.string().datetime({ offset: true })
821
+ }).strict())
822
+ }).strict();
823
+ }
824
+ var emptyOutboxState = () => ({
825
+ schemaVersion: 1,
826
+ queue: [],
827
+ receipts: []
828
+ });
829
+ var sizeOf = (value) => measureSize(value).responseBytes;
830
+ var DEFAULT_OUTBOX_BACKOFF = { minDelayMs: 1000, maxDelayMs: 60000, jitter: 0 };
831
+ function resolveOutboxLimits(config) {
832
+ const pollIntervalMs = z5.number().int().min(10).parse(config.pollIntervalMs ?? 1000);
833
+ const leaseMs = z5.number().int().min(100).parse(config.leaseMs ?? 30000);
834
+ const maxAttempts = z5.number().int().min(1).max(1e4).parse(config.maxAttempts ?? 100);
835
+ const maxQueue = z5.number().int().min(1).max(1e5).parse(config.maxQueue ?? 1000);
836
+ const maxStateBytes = z5.number().int().min(1024).parse(config.maxStateBytes ?? 1024 * 1024);
837
+ const retainReceipts = z5.number().int().min(0).max(1e5).parse(config.retainReceipts ?? 1000);
838
+ return { pollIntervalMs, leaseMs, maxAttempts, maxQueue, maxStateBytes, retainReceipts };
839
+ }
840
+ function boundedOutboxState(parsed, maxQueue, retainReceipts, maxStateBytes) {
841
+ if (parsed.queue.length > maxQueue) {
842
+ throw new Error(`[stitchkit] notification outbox queue limit (${maxQueue}) exceeded`);
843
+ }
844
+ let receipts = parsed.receipts.slice(0, retainReceipts);
845
+ let next = { ...parsed, receipts };
846
+ while (sizeOf(next) > maxStateBytes && receipts.length > 0) {
847
+ receipts = receipts.slice(0, -1);
848
+ next = { ...parsed, receipts };
849
+ }
850
+ if (sizeOf(next) > maxStateBytes) {
851
+ throw new Error(`[stitchkit] notification outbox state limit (${maxStateBytes} bytes) exceeded`);
852
+ }
853
+ return next;
854
+ }
855
+ function dropReason(classification, attempts, maxAttempts) {
856
+ if (classification.recipientUnreachable === true)
857
+ return "recipient-unreachable";
858
+ if (!classification.retryable)
859
+ return "terminal";
860
+ return attempts >= maxAttempts ? "attempt-limit" : null;
861
+ }
862
+ var RetryDelaySchema = z5.number().nonnegative().max(24 * 60 * 60 * 1000);
863
+ var NO_LEASE = { leaseOwner: null, leaseId: null, leaseUntil: null };
864
+ function claimDue(queue, now, ownerId, leaseMs) {
865
+ const candidate = [...queue].sort((left, right) => Date.parse(left.createdAt) - Date.parse(right.createdAt)).find((item) => Date.parse(item.nextAttemptAt) <= now.getTime() && (item.leaseUntil === null || Date.parse(item.leaseUntil) <= now.getTime()));
866
+ if (!candidate)
867
+ return null;
868
+ return {
869
+ ...candidate,
870
+ attempts: candidate.attempts + 1,
871
+ leaseOwner: ownerId,
872
+ leaseId: crypto.randomUUID(),
873
+ leaseUntil: new Date(now.getTime() + leaseMs).toISOString()
874
+ };
875
+ }
876
+ async function reportOutboxError(config, error) {
877
+ try {
878
+ await config.onError?.(error);
879
+ } catch {}
880
+ }
881
+ function createNotificationOutbox(config) {
882
+ const schema = notificationOutboxStateSchema(config.payloadSchema);
883
+ const clock = config.clock ?? (() => new Date);
884
+ const ownerId = config.ownerId ?? crypto.randomUUID();
885
+ const { pollIntervalMs, leaseMs, maxAttempts, maxQueue, maxStateBytes, retainReceipts } = resolveOutboxLimits(config);
886
+ const backoffMs = config.backoffMs ?? ((attempt) => backoffDelay(DEFAULT_OUTBOX_BACKOFF, attempt));
887
+ let timer;
888
+ let running = false;
889
+ let interrupted = false;
890
+ let flushTail = Promise.resolve();
891
+ const bounded = (input) => boundedOutboxState(schema.parse(input), maxQueue, retainReceipts, maxStateBytes);
892
+ const parse = (state) => schema.parse(state ?? emptyOutboxState());
893
+ const enqueue = async (input) => {
894
+ const key = z5.string().min(1).max(512).parse(input.key);
895
+ const payload = config.payloadSchema.parse(input.payload);
896
+ const supersedes = new Set(input.supersedes ?? []);
897
+ return config.store.update((current) => {
898
+ const state = parse(current);
899
+ if (state.queue.some((item) => item.key === key) || state.receipts.some((receipt) => receipt.key === key)) {
900
+ return { state, result: false };
901
+ }
902
+ const now = clock().toISOString();
903
+ const fresh = { key, payload, createdAt: now, attempts: 0, nextAttemptAt: now };
904
+ const queue = [
905
+ ...state.queue.filter((item) => !supersedes.has(item.key)),
906
+ { ...fresh, ...NO_LEASE }
907
+ ];
908
+ const next = bounded({ ...state, queue });
909
+ return { state: next, result: true };
910
+ });
911
+ };
912
+ const claimNext = async () => {
913
+ const now = clock();
914
+ return config.store.update((current) => {
915
+ const state = parse(current);
916
+ const claimed = claimDue(state.queue, now, ownerId, leaseMs);
917
+ if (!claimed)
918
+ return { state, result: null };
919
+ return {
920
+ state: bounded({
921
+ ...state,
922
+ queue: state.queue.map((item) => item.key === claimed.key ? claimed : item)
923
+ }),
924
+ result: claimed
925
+ };
926
+ });
927
+ };
928
+ const acknowledge = async (claimed) => {
929
+ await config.store.update((current) => {
930
+ const state = parse(current);
931
+ const owns = state.queue.some((item) => item.key === claimed.key && item.leaseId === claimed.leaseId);
932
+ if (!owns)
933
+ return { state, result: undefined };
934
+ const receipts = [
935
+ { key: claimed.key, completedAt: clock().toISOString() },
936
+ ...state.receipts.filter((receipt) => receipt.key !== claimed.key)
937
+ ].slice(0, retainReceipts);
938
+ return {
939
+ state: bounded({
940
+ ...state,
941
+ queue: state.queue.filter((item) => item.key !== claimed.key),
942
+ receipts
943
+ }),
944
+ result: undefined
945
+ };
946
+ });
947
+ };
948
+ const reject = async (claimed, error) => {
949
+ const classification = await config.classify(error);
950
+ return config.store.update((current) => {
951
+ const state = parse(current);
952
+ const live = state.queue.find((item) => item.key === claimed.key && item.leaseId === claimed.leaseId);
953
+ if (!live)
954
+ return { state, result: null };
955
+ const attempts = live.attempts;
956
+ const reason = dropReason(classification, attempts, maxAttempts);
957
+ if (reason) {
958
+ return {
959
+ state: bounded({
960
+ ...state,
961
+ queue: state.queue.filter((item) => item.key !== live.key)
962
+ }),
963
+ result: { item: { ...live, attempts }, error, reason }
964
+ };
965
+ }
966
+ const wait = RetryDelaySchema.parse(backoffMs(attempts));
967
+ const retry = {
968
+ ...live,
969
+ nextAttemptAt: new Date(clock().getTime() + wait).toISOString(),
970
+ ...NO_LEASE
971
+ };
972
+ return {
973
+ state: bounded({
974
+ ...state,
975
+ queue: state.queue.map((item) => item.key === live.key ? retry : item)
976
+ }),
977
+ result: null
978
+ };
979
+ });
980
+ };
981
+ const flushPass = async () => {
982
+ let delivered = 0;
983
+ while (!interrupted) {
984
+ const claimed = await claimNext();
985
+ if (!claimed)
986
+ return delivered;
987
+ try {
988
+ await config.send({
989
+ key: claimed.key,
990
+ payload: claimed.payload,
991
+ attempt: claimed.attempts
992
+ });
993
+ await acknowledge(claimed);
994
+ delivered += 1;
995
+ } catch (error) {
996
+ const dropped = await reject(claimed, error);
997
+ if (dropped)
998
+ await config.onDropped?.(dropped);
999
+ }
1000
+ }
1001
+ return delivered;
1002
+ };
1003
+ const flush = () => {
1004
+ const result = flushTail.then(flushPass, flushPass);
1005
+ flushTail = result.then(() => {
1006
+ return;
1007
+ }, () => {
1008
+ return;
1009
+ });
1010
+ return result;
1011
+ };
1012
+ const runScheduled = async () => {
1013
+ try {
1014
+ await flush();
1015
+ } catch (error) {
1016
+ await reportOutboxError(config, error);
1017
+ } finally {
1018
+ schedule();
1019
+ }
1020
+ };
1021
+ const schedule = () => {
1022
+ if (!running)
1023
+ return;
1024
+ timer = setTimeout(() => {
1025
+ runScheduled();
1026
+ }, pollIntervalMs);
1027
+ };
1028
+ return {
1029
+ enqueue,
1030
+ flush,
1031
+ start() {
1032
+ if (running)
1033
+ return;
1034
+ running = true;
1035
+ interrupted = false;
1036
+ runScheduled();
1037
+ },
1038
+ async stop() {
1039
+ running = false;
1040
+ interrupted = true;
1041
+ if (timer)
1042
+ clearTimeout(timer);
1043
+ timer = undefined;
1044
+ try {
1045
+ await flushTail;
1046
+ } finally {
1047
+ interrupted = false;
1048
+ }
1049
+ },
1050
+ async state() {
1051
+ return parse(await config.store.read());
1052
+ }
1053
+ };
1054
+ }
1055
+ function notificationOutboxResource(outbox, config = {}) {
1056
+ return defineManagedResource({
1057
+ id: config.id ?? "notification-outbox",
1058
+ start() {
1059
+ outbox.start();
1060
+ return { value: outbox };
1061
+ },
1062
+ async close() {
1063
+ await outbox.stop();
1064
+ },
1065
+ async force() {
1066
+ await outbox.stop();
1067
+ }
1068
+ });
1069
+ }
1070
+ // src/application/process-lifecycle.ts
1071
+ import { z as z6 } from "zod";
1072
+ var LifecycleTerminationSchema = z6.enum([
1073
+ "active",
1074
+ "clean",
1075
+ "forced",
1076
+ "hot-reload",
1077
+ "abnormal"
1078
+ ]);
1079
+ var LifecycleRunSchema = z6.object({
1080
+ runId: z6.string().min(1).max(128),
1081
+ pid: z6.number().int().positive(),
1082
+ version: z6.string().min(1).max(256),
1083
+ startedAt: z6.string().datetime({ offset: true }),
1084
+ readyAt: z6.string().datetime({ offset: true }).nullable(),
1085
+ stoppedAt: z6.string().datetime({ offset: true }).nullable(),
1086
+ termination: LifecycleTerminationSchema
1087
+ }).strict();
1088
+ var LifecycleStateSchema = z6.object({
1089
+ schemaVersion: z6.literal(1),
1090
+ runs: z6.array(LifecycleRunSchema)
1091
+ }).strict();
1092
+ var PreviousExitSchema = z6.enum([
1093
+ "first-boot",
1094
+ "hot-reload",
1095
+ "clean",
1096
+ "forced",
1097
+ "handoff",
1098
+ "abnormal"
1099
+ ]);
1100
+ var emptyState = () => ({ schemaVersion: 1, runs: [] });
1101
+ var epoch = (value) => Date.parse(value);
1102
+ var elapsed = (later, earlier) => Math.max(0, epoch(later) - epoch(earlier));
1103
+ function normalize(state, retain) {
1104
+ const parsed = LifecycleStateSchema.parse(state ?? emptyState());
1105
+ const runs = [...parsed.runs];
1106
+ for (let index = runs.length - 1;runs.length > retain && index >= 0; index -= 1) {
1107
+ if (runs[index]?.termination !== "active")
1108
+ runs.splice(index, 1);
1109
+ }
1110
+ return { schemaVersion: 1, runs: runs.slice(0, retain) };
1111
+ }
1112
+ var UNKNOWN_VERSION = "unknown";
1113
+ function isVersionChange(previous, next) {
1114
+ return previous !== UNKNOWN_VERSION && next !== UNKNOWN_VERSION && previous !== next;
1115
+ }
1116
+ function transitionProcessStart(source, input) {
1117
+ const retain = z6.number().int().min(1).max(1000).parse(input.retain ?? 20);
1118
+ const state = normalize(source, 1000);
1119
+ const run = LifecycleRunSchema.parse({
1120
+ runId: input.runId,
1121
+ pid: input.pid,
1122
+ version: input.version,
1123
+ startedAt: input.now,
1124
+ readyAt: null,
1125
+ stoppedAt: null,
1126
+ termination: "active"
1127
+ });
1128
+ if (state.runs.some((candidate) => candidate.runId === run.runId)) {
1129
+ throw new Error(`[stitchkit] lifecycle run id already exists: ${run.runId}`);
1130
+ }
1131
+ const previous = state.runs[0] ?? null;
1132
+ let previousExit = "first-boot";
1133
+ let downtimeMs = null;
1134
+ if (previous?.stoppedAt) {
1135
+ previousExit = previous.termination === "forced" || previous.termination === "abnormal" || previous.termination === "hot-reload" ? previous.termination : "clean";
1136
+ downtimeMs = elapsed(run.startedAt, previous.stoppedAt);
1137
+ } else if (previous) {
1138
+ if (previous.pid === run.pid)
1139
+ previousExit = "hot-reload";
1140
+ else if (isVersionChange(previous.version, run.version))
1141
+ previousExit = "handoff";
1142
+ else
1143
+ previousExit = input.sameVersionOverlap ?? "abnormal";
1144
+ }
1145
+ const runs = state.runs.map((candidate) => {
1146
+ if (candidate.runId !== previous?.runId || candidate.termination !== "active")
1147
+ return candidate;
1148
+ if (previousExit === "hot-reload") {
1149
+ return { ...candidate, stoppedAt: run.startedAt, termination: "hot-reload" };
1150
+ }
1151
+ if (previousExit === "abnormal") {
1152
+ return { ...candidate, stoppedAt: run.startedAt, termination: "abnormal" };
1153
+ }
1154
+ return candidate;
1155
+ });
1156
+ const next = normalize({ schemaVersion: 1, runs: [run, ...runs] }, retain);
1157
+ return {
1158
+ state: next,
1159
+ fact: {
1160
+ type: "started",
1161
+ runId: run.runId,
1162
+ pid: run.pid,
1163
+ version: run.version,
1164
+ startedAt: run.startedAt,
1165
+ previousExit,
1166
+ previousRunId: previous?.runId ?? null,
1167
+ previousPid: previous?.pid ?? null,
1168
+ previousVersion: previous?.version ?? null,
1169
+ versionChanged: previous !== null && isVersionChange(previous.version, run.version),
1170
+ downtimeMs
1171
+ }
1172
+ };
1173
+ }
1174
+ function transitionProcessReady(source, input) {
1175
+ const retain = input.retain ?? 20;
1176
+ const state = normalize(source, retain);
1177
+ const target = state.runs.find((run) => run.runId === input.runId && run.pid === input.pid && run.termination === "active");
1178
+ if (!target) {
1179
+ return {
1180
+ state,
1181
+ fact: {
1182
+ type: "ready",
1183
+ runId: input.runId,
1184
+ pid: input.pid,
1185
+ readyAt: input.now,
1186
+ startupMs: 0,
1187
+ recorded: false
1188
+ }
1189
+ };
1190
+ }
1191
+ const readyAt = target.readyAt ?? input.now;
1192
+ return {
1193
+ state: {
1194
+ schemaVersion: 1,
1195
+ runs: state.runs.map((run) => run.runId === target.runId && run.readyAt === null ? { ...run, readyAt } : run)
1196
+ },
1197
+ fact: {
1198
+ type: "ready",
1199
+ runId: target.runId,
1200
+ pid: target.pid,
1201
+ readyAt,
1202
+ startupMs: elapsed(readyAt, target.startedAt),
1203
+ recorded: target.readyAt === null
1204
+ }
1205
+ };
1206
+ }
1207
+ function transitionProcessShutdown(source, input) {
1208
+ const state = normalize(source, input.retain ?? 20);
1209
+ const target = state.runs.find((run) => run.runId === input.runId && run.pid === input.pid && run.termination === "active");
1210
+ const termination = input.forced ? "forced" : "clean";
1211
+ if (!target) {
1212
+ return {
1213
+ state,
1214
+ fact: {
1215
+ type: "stopped",
1216
+ runId: input.runId,
1217
+ pid: input.pid,
1218
+ stoppedAt: input.now,
1219
+ uptimeMs: null,
1220
+ termination,
1221
+ recorded: false
1222
+ }
1223
+ };
1224
+ }
1225
+ return {
1226
+ state: {
1227
+ schemaVersion: 1,
1228
+ runs: state.runs.map((run) => run.runId === target.runId ? { ...run, stoppedAt: input.now, termination } : run)
1229
+ },
1230
+ fact: {
1231
+ type: "stopped",
1232
+ runId: target.runId,
1233
+ pid: target.pid,
1234
+ stoppedAt: input.now,
1235
+ uptimeMs: elapsed(input.now, target.startedAt),
1236
+ termination,
1237
+ recorded: true
1238
+ }
1239
+ };
1240
+ }
1241
+ function createProcessLifecycleLedger(config) {
1242
+ const clock = config.clock ?? (() => new Date);
1243
+ const pid = z6.number().int().positive().parse(config.pid ?? process.pid);
1244
+ const retain = z6.number().int().min(1).max(1000).parse(config.retain ?? 20);
1245
+ const configuredRunId = config.runId;
1246
+ const nextRunId = typeof configuredRunId === "function" ? configuredRunId : configuredRunId === undefined ? () => crypto.randomUUID() : () => configuredRunId;
1247
+ let runId = nextRunId();
1248
+ let started = false;
1249
+ const listeners = new Set;
1250
+ const publish = (fact) => {
1251
+ for (const listener of listeners) {
1252
+ Promise.resolve().then(() => listener(fact)).catch((error) => config.onSubscriberError?.(error, fact));
1253
+ }
1254
+ };
1255
+ return {
1256
+ async recordStart({ version }) {
1257
+ if (started)
1258
+ runId = nextRunId();
1259
+ const fact = await config.store.update((state) => {
1260
+ const transition = transitionProcessStart(state, {
1261
+ runId,
1262
+ pid,
1263
+ version,
1264
+ now: clock().toISOString(),
1265
+ retain,
1266
+ sameVersionOverlap: config.sameVersionOverlap
1267
+ });
1268
+ return { state: transition.state, result: transition.fact };
1269
+ });
1270
+ started = true;
1271
+ publish(fact);
1272
+ return fact;
1273
+ },
1274
+ async recordReady() {
1275
+ const fact = await config.store.update((state) => {
1276
+ const transition = transitionProcessReady(state, {
1277
+ runId,
1278
+ pid,
1279
+ now: clock().toISOString(),
1280
+ retain
1281
+ });
1282
+ return { state: transition.state, result: transition.fact };
1283
+ });
1284
+ if (fact.recorded)
1285
+ publish(fact);
1286
+ return fact;
1287
+ },
1288
+ async recordShutdown(input) {
1289
+ const fact = await config.store.update((state) => {
1290
+ const transition = transitionProcessShutdown(state, {
1291
+ runId,
1292
+ pid,
1293
+ now: clock().toISOString(),
1294
+ forced: input?.forced,
1295
+ retain
1296
+ });
1297
+ return { state: transition.state, result: transition.fact };
1298
+ });
1299
+ if (fact.recorded)
1300
+ publish(fact);
1301
+ return fact;
1302
+ },
1303
+ async current() {
1304
+ const state = normalize(await config.store.read(), retain);
1305
+ return state.runs.find((run) => run.runId === runId && run.pid === pid) ?? null;
1306
+ },
1307
+ async runs() {
1308
+ return normalize(await config.store.read(), retain).runs;
1309
+ },
1310
+ subscribe(listener) {
1311
+ listeners.add(listener);
1312
+ return () => listeners.delete(listener);
1313
+ }
1314
+ };
1315
+ }
1316
+ function lifecycleLedgerResource(ledger, config) {
1317
+ let stopped = false;
1318
+ let shutdown;
1319
+ const stop = async (forced) => {
1320
+ if (stopped)
1321
+ return;
1322
+ if (!shutdown)
1323
+ shutdown = ledger.recordShutdown({ forced });
1324
+ try {
1325
+ await shutdown;
1326
+ stopped = true;
1327
+ } finally {
1328
+ if (!stopped)
1329
+ shutdown = undefined;
1330
+ }
1331
+ };
1332
+ return defineManagedResource({
1333
+ id: config.id ?? "lifecycle",
1334
+ async start() {
1335
+ stopped = false;
1336
+ shutdown = undefined;
1337
+ await ledger.recordStart({ version: config.version });
1338
+ return { value: ledger };
1339
+ },
1340
+ async activate() {
1341
+ await ledger.recordReady();
1342
+ },
1343
+ async close() {
1344
+ await stop(false);
1345
+ },
1346
+ async force() {
1347
+ await stop(true);
1348
+ }
1349
+ });
1350
+ }
1351
+ // src/application/revision-signal.ts
1352
+ import { z as z7 } from "zod";
1353
+ var NonNegativeSafeIntegerSchema = z7.number().int().nonnegative().safe();
1354
+ var PositiveSafeIntegerSchema2 = z7.number().int().positive().safe();
1355
+ var TimerDelaySchema = z7.number().int().positive().max(2147483647);
1356
+ var RevisionSignalStateSchema = z7.enum(["open", "closed"]);
1357
+ var RevisionSignalWaitOutcomeSchema = z7.enum([
1358
+ "changed",
1359
+ "timed-out",
1360
+ "aborted",
1361
+ "closed",
1362
+ "capacity"
1363
+ ]);
1364
+ var RevisionSignalWaitResultSchema = z7.object({
1365
+ outcome: RevisionSignalWaitOutcomeSchema,
1366
+ revision: NonNegativeSafeIntegerSchema
1367
+ }).strict().readonly();
1368
+ var RevisionSignalAdvanceResultSchema = z7.object({
1369
+ outcome: z7.enum(["advanced", "closed"]),
1370
+ revision: NonNegativeSafeIntegerSchema
1371
+ }).strict().readonly();
1372
+ var RevisionSignalSnapshotSchema = z7.object({
1373
+ state: RevisionSignalStateSchema,
1374
+ revision: NonNegativeSafeIntegerSchema,
1375
+ pending: NonNegativeSafeIntegerSchema,
1376
+ maxWaiters: PositiveSafeIntegerSchema2,
1377
+ advances: NonNegativeSafeIntegerSchema,
1378
+ refusedAdvances: NonNegativeSafeIntegerSchema,
1379
+ waits: NonNegativeSafeIntegerSchema,
1380
+ changed: NonNegativeSafeIntegerSchema,
1381
+ timedOut: NonNegativeSafeIntegerSchema,
1382
+ aborted: NonNegativeSafeIntegerSchema,
1383
+ closedWaits: NonNegativeSafeIntegerSchema,
1384
+ capacityRefusals: NonNegativeSafeIntegerSchema,
1385
+ clockFailures: NonNegativeSafeIntegerSchema
1386
+ }).strict().readonly();
1387
+ var systemClock = {
1388
+ schedule(callback, delayMs) {
1389
+ const timer = setTimeout(callback, delayMs);
1390
+ return { cancel: () => clearTimeout(timer) };
1391
+ }
1392
+ };
1393
+ function createRevisionSignal(config) {
1394
+ const maxWaiters = PositiveSafeIntegerSchema2.parse(config.maxWaiters);
1395
+ const clock = config.clock ?? systemClock;
1396
+ const waiters = new Set;
1397
+ let state = "open";
1398
+ let revision = 0;
1399
+ let advances = 0;
1400
+ let refusedAdvances = 0;
1401
+ let waits = 0;
1402
+ let changed = 0;
1403
+ let timedOut = 0;
1404
+ let aborted = 0;
1405
+ let closedWaits = 0;
1406
+ let capacityRefusals = 0;
1407
+ let clockFailures = 0;
1408
+ const result = (outcome) => {
1409
+ if (outcome === "changed")
1410
+ changed += 1;
1411
+ else if (outcome === "timed-out")
1412
+ timedOut += 1;
1413
+ else if (outcome === "aborted")
1414
+ aborted += 1;
1415
+ else if (outcome === "closed")
1416
+ closedWaits += 1;
1417
+ else
1418
+ capacityRefusals += 1;
1419
+ return RevisionSignalWaitResultSchema.parse({ outcome, revision });
1420
+ };
1421
+ const snapshot = () => RevisionSignalSnapshotSchema.parse({
1422
+ state,
1423
+ revision,
1424
+ pending: waiters.size,
1425
+ maxWaiters,
1426
+ advances,
1427
+ refusedAdvances,
1428
+ waits,
1429
+ changed,
1430
+ timedOut,
1431
+ aborted,
1432
+ closedWaits,
1433
+ capacityRefusals,
1434
+ clockFailures
1435
+ });
1436
+ return {
1437
+ advance() {
1438
+ if (state === "closed") {
1439
+ refusedAdvances += 1;
1440
+ return RevisionSignalAdvanceResultSchema.parse({ outcome: "closed", revision });
1441
+ }
1442
+ if (revision === Number.MAX_SAFE_INTEGER) {
1443
+ throw new RangeError("Revision signal exhausted the safe-integer revision range");
1444
+ }
1445
+ revision += 1;
1446
+ advances += 1;
1447
+ for (const waiter of [...waiters])
1448
+ waiter.settle("changed");
1449
+ return RevisionSignalAdvanceResultSchema.parse({ outcome: "advanced", revision });
1450
+ },
1451
+ wait(after, options = {}) {
1452
+ const parsedAfter = NonNegativeSafeIntegerSchema.parse(after);
1453
+ const timeoutMs = options.timeoutMs === undefined ? undefined : TimerDelaySchema.parse(options.timeoutMs);
1454
+ if (parsedAfter > revision) {
1455
+ throw new RangeError(`Revision signal cannot wait after future revision ${parsedAfter}; current revision is ${revision}`);
1456
+ }
1457
+ waits += 1;
1458
+ if (state === "closed")
1459
+ return Promise.resolve(result("closed"));
1460
+ if (parsedAfter < revision)
1461
+ return Promise.resolve(result("changed"));
1462
+ if (options.signal?.aborted)
1463
+ return Promise.resolve(result("aborted"));
1464
+ if (waiters.size >= maxWaiters)
1465
+ return Promise.resolve(result("capacity"));
1466
+ return new Promise((resolve) => {
1467
+ let settled = false;
1468
+ let timer;
1469
+ const waiter = {
1470
+ settle(outcome) {
1471
+ if (settled)
1472
+ return;
1473
+ settled = true;
1474
+ timer?.cancel();
1475
+ options.signal?.removeEventListener("abort", onAbort);
1476
+ waiters.delete(waiter);
1477
+ resolve(result(outcome));
1478
+ }
1479
+ };
1480
+ function onAbort() {
1481
+ waiter.settle("aborted");
1482
+ }
1483
+ waiters.add(waiter);
1484
+ options.signal?.addEventListener("abort", onAbort, { once: true });
1485
+ if (timeoutMs !== undefined) {
1486
+ try {
1487
+ const scheduled = clock.schedule(() => waiter.settle("timed-out"), timeoutMs);
1488
+ timer = scheduled;
1489
+ if (settled)
1490
+ scheduled.cancel();
1491
+ } catch (error) {
1492
+ settled = true;
1493
+ options.signal?.removeEventListener("abort", onAbort);
1494
+ waiters.delete(waiter);
1495
+ clockFailures += 1;
1496
+ throw error;
1497
+ }
1498
+ }
1499
+ });
1500
+ },
1501
+ close() {
1502
+ if (state === "closed")
1503
+ return snapshot();
1504
+ state = "closed";
1505
+ for (const waiter of [...waiters])
1506
+ waiter.settle("closed");
1507
+ return snapshot();
1508
+ },
1509
+ getSnapshot: snapshot
1510
+ };
1511
+ }
1512
+ // src/application/server-resource.ts
1513
+ function managedServerResource(config) {
1514
+ let shutdownPromise;
1515
+ let started;
1516
+ let startAttempted = false;
1517
+ const resolveServer = (context) => typeof config.server === "function" ? config.server(context) : config.server;
1518
+ const isHandle = (value) => ("shutdown" in value);
1519
+ const whole = (milliseconds, round) => Number.isFinite(milliseconds) ? Math.max(0, round(milliseconds)) : milliseconds;
1520
+ const grace = (milliseconds) => whole(milliseconds, Math.floor);
1521
+ const force = (milliseconds) => whole(milliseconds, Math.ceil);
1522
+ const ensureShutdown = (context, phase = "graceful") => {
1523
+ if (shutdownPromise)
1524
+ return shutdownPromise;
1525
+ const now = context.now();
1526
+ const gracePeriodMs = phase === "force" ? 0 : context.deadlineAt === undefined ? undefined : grace(context.deadlineAt - now);
1527
+ const forceTimeoutMs = context.forceDeadlineAt === undefined ? undefined : phase === "force" ? force(context.forceDeadlineAt - now) : force(context.forceDeadlineAt - (context.deadlineAt ?? now));
1528
+ const server = started ?? (startAttempted ? undefined : resolveServer(context));
1529
+ if (server === undefined) {
1530
+ shutdownPromise = Promise.resolve(undefined);
1531
+ return shutdownPromise;
1532
+ }
1533
+ const options = {
1534
+ ...gracePeriodMs !== undefined && { gracePeriodMs },
1535
+ ...forceTimeoutMs !== undefined && { forceTimeoutMs },
1536
+ retryAfterSeconds: grace(config.retryAfterSeconds ?? 5),
1537
+ ...config.realtimeCloseTimeoutMs !== undefined && {
1538
+ realtimeCloseTimeoutMs: grace(config.realtimeCloseTimeoutMs)
1539
+ },
1540
+ signal: context.signal
1541
+ };
1542
+ shutdownPromise = isHandle(server) ? server.shutdown(options) : server.then((handle) => handle.shutdown(options));
1543
+ shutdownPromise.catch(() => {
1544
+ return;
1545
+ });
1546
+ return shutdownPromise;
1547
+ };
1548
+ return defineManagedResource({
1549
+ id: config.id,
1550
+ ...config.dependsOn && { dependsOn: config.dependsOn },
1551
+ ...config.required !== undefined && { required: config.required },
1552
+ async start(context) {
1553
+ if (startAttempted && typeof config.server !== "function") {
1554
+ throw new Error(`[stitchkit] managed server "${config.id}" cannot be restarted: it was given a server instance, and that one has been shut down. Pass a factory — \`server: (context) => …\` — so each generation gets its own.`);
1555
+ }
1556
+ shutdownPromise = undefined;
1557
+ started = undefined;
1558
+ startAttempted = true;
1559
+ started = await resolveServer(context);
1560
+ return { value: started };
1561
+ },
1562
+ stopAdmission(context) {
1563
+ ensureShutdown(context);
1564
+ },
1565
+ async drain() {
1566
+ await shutdownPromise;
1567
+ },
1568
+ async close(context) {
1569
+ await ensureShutdown(context);
1570
+ },
1571
+ async force(context) {
1572
+ await ensureShutdown(context, "force");
1573
+ }
1574
+ });
1575
+ }
1576
+ // src/application/watch-hub-core.ts
1577
+ var DEFAULT_BACKOFF = { minDelayMs: 250, maxDelayMs: 30000, jitter: 0.2 };
1578
+
1579
+ class WatchHubCore {
1580
+ config;
1581
+ sources = new Map;
1582
+ held = new Map;
1583
+ maxWatches;
1584
+ holdMs;
1585
+ deltaMemoryBytes;
1586
+ same;
1587
+ reads = 0;
1588
+ closed = false;
1589
+ constructor(config) {
1590
+ this.config = config;
1591
+ this.maxWatches = config.maxWatchesPerSubscriber ?? 64;
1592
+ this.holdMs = config.holdMs ?? 0;
1593
+ this.deltaMemoryBytes = config.deltaMemoryBytes ?? 262144;
1594
+ this.same = config.same ?? ((previous, next) => serializeCanonicalJson(previous) === serializeCanonicalJson(next));
1595
+ }
1596
+ tell(key, send) {
1597
+ try {
1598
+ send();
1599
+ return true;
1600
+ } catch (error) {
1601
+ this.config.logger?.warn?.("[stitchkit] watch subscriber threw", {
1602
+ key: watchKeyString(key),
1603
+ error: error instanceof Error ? error.message : String(error)
1604
+ });
1605
+ return false;
1606
+ }
1607
+ }
1608
+ announceState(source, state) {
1609
+ source.state = state;
1610
+ for (const subscriber of source.subscribers) {
1611
+ this.tell(source.key, () => subscriber.state(state));
1612
+ }
1613
+ }
1614
+ remember(source, revision, value, fingerprint) {
1615
+ if (this.deltaMemoryBytes === 0)
1616
+ return;
1617
+ const bytes = (JSON.stringify(value) ?? "null").length;
1618
+ if (bytes > this.deltaMemoryBytes)
1619
+ return;
1620
+ source.history.set(revision, { value, fingerprint, bytes });
1621
+ source.historyBytes += bytes;
1622
+ for (const [oldest, entry] of source.history) {
1623
+ if (source.historyBytes <= this.deltaMemoryBytes)
1624
+ break;
1625
+ source.history.delete(oldest);
1626
+ source.historyBytes -= entry.bytes;
1627
+ }
1628
+ }
1629
+ frameFor(source, subscriber) {
1630
+ const value = source.value;
1631
+ const fingerprint = source.fingerprint ?? valueFingerprint(value);
1632
+ const full = {
1633
+ kind: "full",
1634
+ key: source.key,
1635
+ revision: source.revision,
1636
+ fingerprint,
1637
+ value
1638
+ };
1639
+ const base = source.baselines.get(subscriber);
1640
+ if (base === undefined)
1641
+ return full;
1642
+ if (base === source.revision) {
1643
+ return { kind: "unchanged", key: source.key, revision: source.revision, fingerprint };
1644
+ }
1645
+ const held = source.history.get(base);
1646
+ if (!held)
1647
+ return full;
1648
+ const delta = diff(held.value, value);
1649
+ if (delta === undefined || !deltaWins(delta, value))
1650
+ return full;
1651
+ return {
1652
+ kind: "delta",
1653
+ key: source.key,
1654
+ revision: source.revision,
1655
+ fingerprint,
1656
+ base,
1657
+ delta
1658
+ };
1659
+ }
1660
+ adoptBaseline(source, subscriber, have) {
1661
+ if (source.fingerprint === have.fingerprint) {
1662
+ source.baselines.set(subscriber, source.revision);
1663
+ return;
1664
+ }
1665
+ const named = source.history.get(have.revision);
1666
+ if (named?.fingerprint === have.fingerprint) {
1667
+ source.baselines.set(subscriber, have.revision);
1668
+ return;
1669
+ }
1670
+ for (const [revision, entry] of source.history) {
1671
+ if (entry.fingerprint !== have.fingerprint)
1672
+ continue;
1673
+ source.baselines.set(subscriber, revision);
1674
+ return;
1675
+ }
1676
+ }
1677
+ deliver(source, subscriber) {
1678
+ const frame = this.frameFor(source, subscriber);
1679
+ const delivered = this.tell(source.key, () => subscriber.value(frame));
1680
+ if (delivered)
1681
+ source.baselines.set(subscriber, source.revision);
1682
+ return delivered;
1683
+ }
1684
+ publish(source, value, fingerprint) {
1685
+ if (source.fingerprint !== undefined) {
1686
+ this.remember(source, source.revision, source.value, source.fingerprint);
1687
+ }
1688
+ source.revision += 1;
1689
+ source.value = value;
1690
+ source.fingerprint = fingerprint;
1691
+ for (const subscriber of source.subscribers)
1692
+ this.deliver(source, subscriber);
1693
+ }
1694
+ async pump(source) {
1695
+ if (source.reading || this.closed)
1696
+ return;
1697
+ source.reading = true;
1698
+ try {
1699
+ while (source.dirty && !this.closed) {
1700
+ source.dirty = false;
1701
+ this.reads += 1;
1702
+ try {
1703
+ const value = await this.config.read(source.operation, source.args);
1704
+ source.backoff.reset();
1705
+ const signature = serializeCanonicalJson(value);
1706
+ const unchanged = source.signature !== undefined && this.same(source.value, value);
1707
+ source.signature = signature;
1708
+ if (!unchanged)
1709
+ this.publish(source, value, valueFingerprint(value));
1710
+ if (source.state.phase !== "live") {
1711
+ this.announceState(source, { key: source.key, phase: "live" });
1712
+ }
1713
+ } catch (error) {
1714
+ const code = readErrorCode(error);
1715
+ this.announceState(source, {
1716
+ key: source.key,
1717
+ phase: "unavailable",
1718
+ reason: "source-error",
1719
+ ...code !== undefined && { code },
1720
+ message: error instanceof Error ? error.message : String(error)
1721
+ });
1722
+ this.config.logger?.warn?.("[stitchkit] watched read failed", {
1723
+ key: watchKeyString(source.key),
1724
+ error
1725
+ });
1726
+ this.scheduleRetry(source);
1727
+ return;
1728
+ }
1729
+ }
1730
+ } finally {
1731
+ source.reading = false;
1732
+ }
1733
+ }
1734
+ scheduleRetry(source) {
1735
+ if (this.closed || source.subscribers.size === 0)
1736
+ return;
1737
+ clearTimeout(source.retry);
1738
+ source.retry = setTimeout(() => {
1739
+ source.dirty = true;
1740
+ this.pump(source);
1741
+ }, source.backoff.next());
1742
+ source.retry.unref?.();
1743
+ }
1744
+ acquire(operation, key, args) {
1745
+ const id = watchKeyString(key);
1746
+ const existing = this.sources.get(id);
1747
+ if (existing) {
1748
+ clearTimeout(existing.release);
1749
+ existing.release = undefined;
1750
+ return existing;
1751
+ }
1752
+ const source = {
1753
+ key,
1754
+ operation,
1755
+ args,
1756
+ subscribers: new Set,
1757
+ unsubscribes: [],
1758
+ revision: 0,
1759
+ history: new Map,
1760
+ historyBytes: 0,
1761
+ baselines: new Map,
1762
+ reading: false,
1763
+ dirty: true,
1764
+ state: { key, phase: "opening" },
1765
+ backoff: createBackoff(this.config.backoff ?? DEFAULT_BACKOFF)
1766
+ };
1767
+ for (const topic of this.config.invalidatedBy(operation, args)) {
1768
+ source.unsubscribes.push(this.config.subscribe(topic, () => {
1769
+ source.dirty = true;
1770
+ this.pump(source);
1771
+ }));
1772
+ }
1773
+ this.sources.set(id, source);
1774
+ return source;
1775
+ }
1776
+ release(source) {
1777
+ if (source.subscribers.size > 0)
1778
+ return;
1779
+ clearTimeout(source.retry);
1780
+ source.retry = undefined;
1781
+ const drop = () => {
1782
+ if (source.reading) {
1783
+ source.release = setTimeout(drop, 10);
1784
+ source.release.unref?.();
1785
+ return;
1786
+ }
1787
+ for (const unsubscribe of source.unsubscribes)
1788
+ unsubscribe();
1789
+ this.sources.delete(watchKeyString(source.key));
1790
+ };
1791
+ if (this.holdMs === 0) {
1792
+ drop();
1793
+ return;
1794
+ }
1795
+ source.release = setTimeout(drop, this.holdMs);
1796
+ source.release.unref?.();
1797
+ }
1798
+ attach(subscriber) {
1799
+ const keys = new Set;
1800
+ this.held.set(subscriber, keys);
1801
+ return {
1802
+ open: (key, args, have) => {
1803
+ if (this.closed)
1804
+ return { accepted: false, reason: "the watch hub is closed" };
1805
+ const operation = { service: key.service, action: key.action };
1806
+ if (!this.config.watchable(operation)) {
1807
+ return {
1808
+ accepted: false,
1809
+ reason: `${key.service}.${key.action} is not watchable`
1810
+ };
1811
+ }
1812
+ const id = watchKeyString(key);
1813
+ if (keys.has(id))
1814
+ return { accepted: true };
1815
+ if (keys.size >= this.maxWatches) {
1816
+ return {
1817
+ accepted: false,
1818
+ reason: `this connection is already watching ${keys.size} reads (limit ${this.maxWatches})`
1819
+ };
1820
+ }
1821
+ const source = this.acquire(operation, key, args);
1822
+ source.subscribers.add(subscriber);
1823
+ keys.add(id);
1824
+ if (have)
1825
+ this.adoptBaseline(source, subscriber, have);
1826
+ try {
1827
+ if (source.signature !== undefined) {
1828
+ const frame = this.frameFor(source, subscriber);
1829
+ subscriber.value(frame);
1830
+ source.baselines.set(subscriber, source.revision);
1831
+ }
1832
+ subscriber.state(source.state);
1833
+ } catch (error) {
1834
+ source.subscribers.delete(subscriber);
1835
+ source.baselines.delete(subscriber);
1836
+ keys.delete(id);
1837
+ this.release(source);
1838
+ return {
1839
+ accepted: false,
1840
+ reason: error instanceof Error ? error.message : String(error)
1841
+ };
1842
+ }
1843
+ this.pump(source);
1844
+ return { accepted: true };
1845
+ },
1846
+ close: (key) => {
1847
+ const id = watchKeyString(key);
1848
+ if (!keys.delete(id))
1849
+ return;
1850
+ const source = this.sources.get(id);
1851
+ if (!source)
1852
+ return;
1853
+ source.subscribers.delete(subscriber);
1854
+ source.baselines.delete(subscriber);
1855
+ this.release(source);
1856
+ },
1857
+ detach: () => {
1858
+ for (const id of keys) {
1859
+ const source = this.sources.get(id);
1860
+ if (!source)
1861
+ continue;
1862
+ source.subscribers.delete(subscriber);
1863
+ source.baselines.delete(subscriber);
1864
+ this.release(source);
1865
+ }
1866
+ keys.clear();
1867
+ this.held.delete(subscriber);
1868
+ }
1869
+ };
1870
+ }
1871
+ close() {
1872
+ this.closed = true;
1873
+ const teardown = [...this.sources.values()];
1874
+ this.sources.clear();
1875
+ this.held.clear();
1876
+ for (const source of teardown) {
1877
+ clearTimeout(source.retry);
1878
+ clearTimeout(source.release);
1879
+ this.announceState(source, {
1880
+ key: source.key,
1881
+ phase: "unavailable",
1882
+ reason: "source-unavailable"
1883
+ });
1884
+ for (const unsubscribe of source.unsubscribes)
1885
+ unsubscribe();
1886
+ }
1887
+ }
1888
+ }
1889
+ function valueFingerprint(value) {
1890
+ return argumentsDigest({ value });
1891
+ }
1892
+ function readErrorCode(error) {
1893
+ if (typeof error !== "object" || error === null)
1894
+ return;
1895
+ const code = Reflect.get(error, "code");
1896
+ return typeof code === "string" ? code : undefined;
1897
+ }
1898
+
1899
+ // src/application/watch-hub.ts
1900
+ function watchKey(operation, args) {
1901
+ const record = typeof args === "object" && args !== null && !Array.isArray(args) ? args : { value: args };
1902
+ return {
1903
+ service: operation.service,
1904
+ action: operation.action,
1905
+ digest: argumentsDigest(record)
1906
+ };
1907
+ }
1908
+ function createWatchHub(config) {
1909
+ const hub = new WatchHubCore(config);
1910
+ return {
1911
+ attach: (subscriber) => hub.attach(subscriber),
1912
+ readCount: () => hub.reads,
1913
+ size: () => hub.sources.size,
1914
+ close: () => hub.close()
1915
+ };
1916
+ }
1917
+ export {
1918
+ watchKey,
1919
+ transitionProcessStart,
1920
+ transitionProcessShutdown,
1921
+ transitionProcessReady,
1922
+ sqliteKeyspaceBackend,
1923
+ readDiagnosticJournalLockDiagnosis,
1924
+ projectApplicationStatus,
1925
+ openKeyspace,
1926
+ notificationOutboxStateSchema,
1927
+ notificationOutboxResource,
1928
+ memoryKeyspaceBackend,
1929
+ managedServerResource,
1930
+ managedResourceDependencyId,
1931
+ lifecycleLedgerResource,
1932
+ keyspaceResource,
1933
+ defineManagedResource,
1934
+ defineKeyspace,
1935
+ createWatchHub,
1936
+ createRevisionSignal,
1937
+ createProcessLifecycleLedger,
1938
+ createNotificationOutbox,
1939
+ createManagedSchedule,
1940
+ createDecisionPipeline,
1941
+ createCreditWindow,
1942
+ createBoundedChannel,
1943
+ createBoundedAdmission,
1944
+ createApplicationSnapshotSink,
1945
+ createApplicationOperationalHandlers,
1946
+ createApplicationHealthHandler,
1947
+ createApplicationEventSink,
1948
+ createApplication,
1949
+ createActivityProjection,
1950
+ applicationLifecycleEvent,
1951
+ RevisionSignalWaitResultSchema,
1952
+ RevisionSignalWaitOutcomeSchema,
1953
+ RevisionSignalStateSchema,
1954
+ RevisionSignalSnapshotSchema,
1955
+ RevisionSignalAdvanceResultSchema,
1956
+ PreviousExitSchema,
1957
+ PolicyDecisionSchema,
1958
+ ManagedScheduleStatusSchema,
1959
+ ManagedScheduleOverlapSchema,
1960
+ ManagedScheduleErrorPolicySchema,
1961
+ ManagedScheduleDescriptorSchema,
1962
+ ManagedResourceStateSchema,
1963
+ ManagedResourceSnapshotSchema,
1964
+ LifecycleTerminationSchema,
1965
+ LifecycleStateSchema,
1966
+ LifecycleRunSchema,
1967
+ DiagnosticJournalWaitResultSchema,
1968
+ DiagnosticJournalSubmitResultSchema,
1969
+ DiagnosticJournalStatusSchema,
1970
+ DiagnosticJournalStateSchema,
1971
+ DiagnosticJournalRefusalReasonSchema,
1972
+ DiagnosticJournalLockPolicySchema,
1973
+ DiagnosticJournalLimitsSchema,
1974
+ DiagnosticJournalFrameSchema,
1975
+ DiagnosticJournalFailurePhaseSchema,
1976
+ DiagnosticJournalCloseResultSchema,
1977
+ DecisionUndecidedError,
1978
+ DecisionPolicyError,
1979
+ CreditWindowSnapshotSchema,
1980
+ BoundedRateBudgetSchema,
1981
+ BoundedOperationWaitError,
1982
+ BoundedChannelStateSchema,
1983
+ BoundedChannelSnapshotSchema,
1984
+ BoundedChannelReaderError,
1985
+ BoundedChannelPolicySchema,
1986
+ BoundedAdmissionStateSchema,
1987
+ BoundedAdmissionSnapshotSchema,
1988
+ BoundedAdmissionRefusalReasonSchema,
1989
+ BoundedAdmissionRefusalError,
1990
+ BoundedAdmissionPolicySchema,
1991
+ BoundedAdmissionPerKeyLimitsSchema,
1992
+ ApplicationStatusProjectionSchema,
1993
+ ApplicationSnapshotSinkStatusSchema,
1994
+ ApplicationSnapshotSchema,
1995
+ ApplicationShutdownResultSchema,
1996
+ ApplicationShutdownOptionsSchema,
1997
+ ApplicationShutdownBudgetSchema,
1998
+ ApplicationRestartResultSchema,
1999
+ ApplicationRestartOutcomeSchema,
2000
+ ApplicationRestartInputSchema,
2001
+ ApplicationResourceShutdownSchema,
2002
+ ApplicationOperationalHandlersOptionsSchema,
2003
+ ApplicationLifecycleSchema,
2004
+ ApplicationLifecycleEventSchema,
2005
+ ApplicationIdSchema,
2006
+ ApplicationHealthSchema,
2007
+ ApplicationHealthHandlerOptionsSchema,
2008
+ ApplicationAdmissionSnapshotSchema,
2009
+ ApplicationAdmissionError,
2010
+ ActivityTokenBrand,
2011
+ ActivityStageSnapshotSchema,
2012
+ ActivityStageIdSchema,
2013
+ ActivitySnapshotSchema,
2014
+ ActivityLiveStateSchema,
2015
+ ActivityIdSchema
2016
+ };