stitchkit 0.94.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 (346) hide show
  1. package/CHANGELOG.md +64 -0
  2. package/dist/agent-runtime/coding-shell-process.d.ts.map +1 -1
  3. package/dist/agent-runtime/coding-tool-listing.d.ts.map +1 -1
  4. package/dist/agent-runtime/coding-tool-search-patch.d.ts.map +1 -1
  5. package/dist/agent-runtime/contained-darwin.d.ts +38 -0
  6. package/dist/agent-runtime/contained-darwin.d.ts.map +1 -0
  7. package/dist/agent-runtime/contained-files.d.ts +11 -26
  8. package/dist/agent-runtime/contained-files.d.ts.map +1 -1
  9. package/dist/agent-runtime/contained-scan.d.ts +21 -0
  10. package/dist/agent-runtime/contained-scan.d.ts.map +1 -0
  11. package/dist/agent-runtime/contained-write.d.ts +9 -0
  12. package/dist/agent-runtime/contained-write.d.ts.map +1 -0
  13. package/dist/agent-runtime/deferred-tool-types.d.ts +3 -2
  14. package/dist/agent-runtime/deferred-tool-types.d.ts.map +1 -1
  15. package/dist/agent-runtime/harness-control.d.ts +0 -1
  16. package/dist/agent-runtime/harness-control.d.ts.map +1 -1
  17. package/dist/agent-runtime/harness.d.ts +0 -5
  18. package/dist/agent-runtime/harness.d.ts.map +1 -1
  19. package/dist/agent-runtime/managed-tools.d.ts +3 -2
  20. package/dist/agent-runtime/managed-tools.d.ts.map +1 -1
  21. package/dist/agent-runtime/runtime.d.ts +1 -1
  22. package/dist/agent-runtime/runtime.d.ts.map +1 -1
  23. package/dist/agent-runtime/schedule-records.d.ts +34 -0
  24. package/dist/agent-runtime/schedule-records.d.ts.map +1 -0
  25. package/dist/agent-runtime/schedules.d.ts +34 -0
  26. package/dist/agent-runtime/schedules.d.ts.map +1 -1
  27. package/dist/agent-runtime/store-conformance-lifecycle.d.ts +434 -0
  28. package/dist/agent-runtime/store-conformance-lifecycle.d.ts.map +1 -0
  29. package/dist/agent-runtime/store-conformance-ordering.d.ts +18 -0
  30. package/dist/agent-runtime/store-conformance-ordering.d.ts.map +1 -0
  31. package/dist/agent-runtime/store-conformance-support.d.ts +130 -0
  32. package/dist/agent-runtime/store-conformance-support.d.ts.map +1 -0
  33. package/dist/agent-runtime/store-conformance-terminal.d.ts +12 -0
  34. package/dist/agent-runtime/store-conformance-terminal.d.ts.map +1 -0
  35. package/dist/agent-runtime/store-conformance.d.ts.map +1 -1
  36. package/dist/application/admission-rate.d.ts +21 -0
  37. package/dist/application/admission-rate.d.ts.map +1 -0
  38. package/dist/application/admission-run.d.ts +8 -0
  39. package/dist/application/admission-run.d.ts.map +1 -0
  40. package/dist/application/admission.d.ts.map +1 -1
  41. package/dist/application/diagnostic-journal-lock.d.ts +9 -34
  42. package/dist/application/diagnostic-journal-lock.d.ts.map +1 -1
  43. package/dist/application/diagnostic-journal-manager.d.ts.map +1 -1
  44. package/dist/application/diagnostic-journal-storage.d.ts.map +1 -1
  45. package/dist/application/kernel-resource-context.d.ts.map +1 -1
  46. package/dist/application/notification-outbox.d.ts.map +1 -1
  47. package/dist/application/schedule.d.ts +0 -1
  48. package/dist/application/schedule.d.ts.map +1 -1
  49. package/dist/application/watch-hub-core.d.ts +122 -0
  50. package/dist/application/watch-hub-core.d.ts.map +1 -0
  51. package/dist/application/watch-hub.d.ts +2 -2
  52. package/dist/application/watch-hub.d.ts.map +1 -1
  53. package/dist/browser/client-executors.d.ts +14 -0
  54. package/dist/browser/client-executors.d.ts.map +1 -0
  55. package/dist/browser/client-multipart.d.ts +1 -1
  56. package/dist/browser/client-multipart.d.ts.map +1 -1
  57. package/dist/browser/client.d.ts +3 -2
  58. package/dist/browser/client.d.ts.map +1 -1
  59. package/dist/browser/http-fetch.d.ts +22 -0
  60. package/dist/browser/http-fetch.d.ts.map +1 -0
  61. package/dist/browser/http.d.ts +1 -3
  62. package/dist/browser/http.d.ts.map +1 -1
  63. package/dist/browser/live-state-core.d.ts +63 -0
  64. package/dist/browser/live-state-core.d.ts.map +1 -0
  65. package/dist/browser/live-state.d.ts.map +1 -1
  66. package/dist/browser/realtime-client.d.ts +26 -0
  67. package/dist/browser/realtime-client.d.ts.map +1 -0
  68. package/dist/browser/socket-io-connection.d.ts +82 -0
  69. package/dist/browser/socket-io-connection.d.ts.map +1 -0
  70. package/dist/browser/socket-io-peer.d.ts +20 -0
  71. package/dist/browser/socket-io-peer.d.ts.map +1 -0
  72. package/dist/browser/socket-io-trace.d.ts +31 -0
  73. package/dist/browser/socket-io-trace.d.ts.map +1 -0
  74. package/dist/browser/socket-io.d.ts +2 -18
  75. package/dist/browser/socket-io.d.ts.map +1 -1
  76. package/dist/contract/client-types.d.ts +134 -0
  77. package/dist/contract/client-types.d.ts.map +1 -0
  78. package/dist/contract/define-validation.d.ts +30 -0
  79. package/dist/contract/define-validation.d.ts.map +1 -0
  80. package/dist/contract/define.d.ts +3 -357
  81. package/dist/contract/define.d.ts.map +1 -1
  82. package/dist/contract/runtime-context.d.ts +131 -0
  83. package/dist/contract/runtime-context.d.ts.map +1 -0
  84. package/dist/contract/tool-options.d.ts +105 -0
  85. package/dist/contract/tool-options.d.ts.map +1 -0
  86. package/dist/contract/tool-view.d.ts +15 -2
  87. package/dist/contract/tool-view.d.ts.map +1 -1
  88. package/dist/durability/contract.d.ts +83 -0
  89. package/dist/durability/contract.d.ts.map +1 -1
  90. package/dist/durability/effect.d.ts +24 -0
  91. package/dist/durability/effect.d.ts.map +1 -0
  92. package/dist/durability/engine.d.ts +2 -2
  93. package/dist/durability/engine.d.ts.map +1 -1
  94. package/dist/durability/events.d.ts +2 -0
  95. package/dist/durability/events.d.ts.map +1 -1
  96. package/dist/durability/ledger.d.ts +11 -0
  97. package/dist/durability/ledger.d.ts.map +1 -1
  98. package/dist/durability/parks.d.ts +22 -0
  99. package/dist/durability/parks.d.ts.map +1 -0
  100. package/dist/durability/scheduler.d.ts +1 -0
  101. package/dist/durability/scheduler.d.ts.map +1 -1
  102. package/dist/entrypoints/agent-runtime/coding-tools.js +4 -4
  103. package/dist/entrypoints/agent-runtime/harness.js +127 -116
  104. package/dist/entrypoints/agent-runtime/sandbox.js +4 -4
  105. package/dist/entrypoints/agent-runtime/sqlite/bun.js +3 -3
  106. package/dist/entrypoints/agent-runtime/sqlite/node.js +3 -3
  107. package/dist/entrypoints/agent-runtime/testing.js +246 -214
  108. package/dist/entrypoints/agent-runtime.js +224 -203
  109. package/dist/entrypoints/application/diagnostic-journal.js +63 -203
  110. package/dist/entrypoints/application/opentelemetry.js +1 -1
  111. package/dist/entrypoints/application.js +361 -324
  112. package/dist/entrypoints/cli.d.ts +4 -1
  113. package/dist/entrypoints/cli.d.ts.map +1 -1
  114. package/dist/entrypoints/cli.js +57 -35
  115. package/dist/entrypoints/contract.d.ts +5 -2
  116. package/dist/entrypoints/contract.d.ts.map +1 -1
  117. package/dist/entrypoints/contract.js +3 -2
  118. package/dist/entrypoints/files.d.ts +2 -0
  119. package/dist/entrypoints/files.d.ts.map +1 -1
  120. package/dist/entrypoints/files.js +98 -2
  121. package/dist/entrypoints/index.d.ts +4 -2
  122. package/dist/entrypoints/index.d.ts.map +1 -1
  123. package/dist/entrypoints/index.js +348 -282
  124. package/dist/entrypoints/live.js +89 -71
  125. package/dist/entrypoints/node.d.ts +2 -1
  126. package/dist/entrypoints/node.d.ts.map +1 -1
  127. package/dist/entrypoints/node.js +13 -12
  128. package/dist/entrypoints/react.js +1 -1
  129. package/dist/entrypoints/remote.js +4 -4
  130. package/dist/entrypoints/server.d.ts +4 -2
  131. package/dist/entrypoints/server.d.ts.map +1 -1
  132. package/dist/entrypoints/server.js +293 -79
  133. package/dist/entrypoints/testing.d.ts +2 -1
  134. package/dist/entrypoints/testing.d.ts.map +1 -1
  135. package/dist/entrypoints/testing.js +288 -281
  136. package/dist/entrypoints/tools/connections.js +2 -2
  137. package/dist/entrypoints/tools/invoker.js +4 -4
  138. package/dist/entrypoints/tools.d.ts +6 -3
  139. package/dist/entrypoints/tools.d.ts.map +1 -1
  140. package/dist/entrypoints/tools.js +245 -202
  141. package/dist/entrypoints/tracking.js +325 -274
  142. package/dist/files/boundary.d.ts.map +1 -1
  143. package/dist/files/file-io.d.ts +14 -0
  144. package/dist/files/file-io.d.ts.map +1 -0
  145. package/dist/index-1j8pm5t0.js +412 -0
  146. package/dist/{index-kvj7f4hq.js → index-2bxbyab0.js} +10 -2
  147. package/dist/{index-xnj9bgxe.js → index-2gxzjvyr.js} +2 -162
  148. package/dist/index-4gcnakhx.js +82 -0
  149. package/dist/{index-j05z5gn4.js → index-55hkhm67.js} +136 -119
  150. package/dist/{index-cq4qfycf.js → index-79z7m7dt.js} +227 -59
  151. package/dist/{index-97ac4gph.js → index-7f68ghdn.js} +3 -3
  152. package/dist/{index-r7nmqpsg.js → index-7p1f0vp2.js} +1 -1
  153. package/dist/{index-dcpdvjsc.js → index-863ea9jb.js} +4 -4
  154. package/dist/index-8p52kd5p.js +242 -0
  155. package/dist/{index-2qzskm8h.js → index-dce5wxcq.js} +1 -1
  156. package/dist/index-e01r054k.js +105 -0
  157. package/dist/{index-sees8yf8.js → index-ensd0r74.js} +118 -111
  158. package/dist/{index-1nd48tm9.js → index-gxrt5h6v.js} +2 -1
  159. package/dist/{index-e87kakm4.js → index-ham5sz8m.js} +112 -110
  160. package/dist/{index-kj2wbeta.js → index-het2he5g.js} +280 -196
  161. package/dist/{index-vcvkq30w.js → index-hmp4800j.js} +3 -3
  162. package/dist/{index-gyr48nzg.js → index-k30h66yd.js} +71 -151
  163. package/dist/{index-2cr1cqhn.js → index-khtgb21r.js} +2 -2
  164. package/dist/{index-x4799c19.js → index-ndddxtyx.js} +11 -11
  165. package/dist/{index-dydjcp8z.js → index-np4m8hd3.js} +38 -36
  166. package/dist/{index-p81267c2.js → index-p3vsv1fb.js} +621 -357
  167. package/dist/{index-mp5sn43f.js → index-p9e0w8hs.js} +2 -2
  168. package/dist/{index-rewkc2hj.js → index-p9sh0xx4.js} +3 -3
  169. package/dist/{index-70yj2ebz.js → index-paz6sgdp.js} +107 -103
  170. package/dist/{index-bn2cjajt.js → index-px2gm2jp.js} +26 -102
  171. package/dist/index-s812ycat.js +65 -0
  172. package/dist/{index-xsqjkha9.js → index-sp1tzwnb.js} +2 -2
  173. package/dist/{index-n6hxg8as.js → index-t9rhjr9f.js} +615 -566
  174. package/dist/{index-zeemqhqx.js → index-v260df89.js} +88 -80
  175. package/dist/{index-fdp6hdxn.js → index-w906953s.js} +5 -1
  176. package/dist/{index-mdzh02yc.js → index-wdkt63w3.js} +1 -1
  177. package/dist/{index-58k4fp34.js → index-wsm5w4ee.js} +1 -1
  178. package/dist/{index-v38qyerb.js → index-xw3s75nj.js} +1 -1
  179. package/dist/internal/atomic-file.d.ts +23 -2
  180. package/dist/internal/atomic-file.d.ts.map +1 -1
  181. package/dist/internal/exclusive-lock.d.ts +51 -0
  182. package/dist/internal/exclusive-lock.d.ts.map +1 -0
  183. package/dist/internal/process-identity.d.ts +47 -0
  184. package/dist/internal/process-identity.d.ts.map +1 -0
  185. package/dist/internal/with-exclusive-lock.d.ts +67 -0
  186. package/dist/internal/with-exclusive-lock.d.ts.map +1 -0
  187. package/dist/live/watch-client.d.ts.map +1 -1
  188. package/dist/observability/audit.d.ts +2 -2
  189. package/dist/observability/audit.d.ts.map +1 -1
  190. package/dist/observability/event.d.ts +2 -1
  191. package/dist/observability/event.d.ts.map +1 -1
  192. package/dist/primitives/export-operation.d.ts +1 -1
  193. package/dist/primitives/export-operation.d.ts.map +1 -1
  194. package/dist/realtime/registry.d.ts +0 -5
  195. package/dist/realtime/registry.d.ts.map +1 -1
  196. package/dist/server/bun.d.ts +0 -1
  197. package/dist/server/bun.d.ts.map +1 -1
  198. package/dist/server/context-contribution.d.ts +1 -1
  199. package/dist/server/context-contribution.d.ts.map +1 -1
  200. package/dist/server/context.d.ts +1 -1
  201. package/dist/server/context.d.ts.map +1 -1
  202. package/dist/server/endpoint-response.d.ts +2 -1
  203. package/dist/server/endpoint-response.d.ts.map +1 -1
  204. package/dist/server/error-dispatch.d.ts +1 -1
  205. package/dist/server/error-dispatch.d.ts.map +1 -1
  206. package/dist/server/error-hook.d.ts +1 -1
  207. package/dist/server/error-hook.d.ts.map +1 -1
  208. package/dist/server/handler-state.d.ts +1 -1
  209. package/dist/server/handler-state.d.ts.map +1 -1
  210. package/dist/server/implement-registry.d.ts +54 -0
  211. package/dist/server/implement-registry.d.ts.map +1 -0
  212. package/dist/server/implement.d.ts +9 -55
  213. package/dist/server/implement.d.ts.map +1 -1
  214. package/dist/server/middleware/auth.d.ts +1 -31
  215. package/dist/server/middleware/auth.d.ts.map +1 -1
  216. package/dist/server/middleware/jwt.d.ts +31 -0
  217. package/dist/server/middleware/jwt.d.ts.map +1 -0
  218. package/dist/server/multipart-reader.d.ts +22 -0
  219. package/dist/server/multipart-reader.d.ts.map +1 -0
  220. package/dist/server/multipart.d.ts +1 -1
  221. package/dist/server/multipart.d.ts.map +1 -1
  222. package/dist/server/oauth/cimd.d.ts +88 -0
  223. package/dist/server/oauth/cimd.d.ts.map +1 -0
  224. package/dist/server/oauth/endpoints.d.ts +39 -0
  225. package/dist/server/oauth/endpoints.d.ts.map +1 -0
  226. package/dist/server/oauth/provider.d.ts +1 -68
  227. package/dist/server/oauth/provider.d.ts.map +1 -1
  228. package/dist/server/streaming-pump.d.ts +66 -0
  229. package/dist/server/streaming-pump.d.ts.map +1 -0
  230. package/dist/server/streaming-route.d.ts +12 -5
  231. package/dist/server/streaming-route.d.ts.map +1 -1
  232. package/dist/server/types.d.ts +4 -1
  233. package/dist/server/types.d.ts.map +1 -1
  234. package/dist/server/unix-client-bun.d.ts.map +1 -1
  235. package/dist/server/unix-client-http1.d.ts +76 -0
  236. package/dist/server/unix-client-http1.d.ts.map +1 -0
  237. package/dist/server/unix-client.d.ts.map +1 -1
  238. package/dist/testing/handler-clients.d.ts +2 -1
  239. package/dist/testing/handler-clients.d.ts.map +1 -1
  240. package/dist/testing/realtime-probe.d.ts +33 -0
  241. package/dist/testing/realtime-probe.d.ts.map +1 -0
  242. package/dist/testing/surface-conformance.d.ts +0 -31
  243. package/dist/testing/surface-conformance.d.ts.map +1 -1
  244. package/dist/testing/surface-manifest-digest.d.ts +44 -0
  245. package/dist/testing/surface-manifest-digest.d.ts.map +1 -0
  246. package/dist/testing/surface-manifest.d.ts.map +1 -1
  247. package/dist/tools/agent.d.ts +1 -1
  248. package/dist/tools/agent.d.ts.map +1 -1
  249. package/dist/tools/cli/args-fields.d.ts +31 -0
  250. package/dist/tools/cli/args-fields.d.ts.map +1 -0
  251. package/dist/tools/cli/args-route.d.ts +42 -0
  252. package/dist/tools/cli/args-route.d.ts.map +1 -0
  253. package/dist/tools/cli/args-view.d.ts +32 -0
  254. package/dist/tools/cli/args-view.d.ts.map +1 -0
  255. package/dist/tools/cli/args.d.ts +2 -65
  256. package/dist/tools/cli/args.d.ts.map +1 -1
  257. package/dist/tools/cli/argument-error.d.ts +5 -0
  258. package/dist/tools/cli/argument-error.d.ts.map +1 -0
  259. package/dist/tools/cli/checkpoint.d.ts.map +1 -1
  260. package/dist/tools/cli/command.d.ts +1 -1
  261. package/dist/tools/cli/command.d.ts.map +1 -1
  262. package/dist/tools/cli/config.d.ts +1 -1
  263. package/dist/tools/cli/config.d.ts.map +1 -1
  264. package/dist/tools/cli/format.d.ts +2 -1
  265. package/dist/tools/cli/format.d.ts.map +1 -1
  266. package/dist/tools/cli/invoke.d.ts +2 -1
  267. package/dist/tools/cli/invoke.d.ts.map +1 -1
  268. package/dist/tools/cli/managed-surface.d.ts +1 -1
  269. package/dist/tools/cli/managed-surface.d.ts.map +1 -1
  270. package/dist/tools/cli/policy.d.ts +1 -1
  271. package/dist/tools/cli/policy.d.ts.map +1 -1
  272. package/dist/tools/cli/prepare.d.ts.map +1 -1
  273. package/dist/tools/cli/run-managed.d.ts.map +1 -1
  274. package/dist/tools/cli/session.d.ts +1 -1
  275. package/dist/tools/cli/session.d.ts.map +1 -1
  276. package/dist/tools/cli/update.d.ts +19 -0
  277. package/dist/tools/cli/update.d.ts.map +1 -1
  278. package/dist/tools/cli/view.d.ts +1 -1
  279. package/dist/tools/cli/view.d.ts.map +1 -1
  280. package/dist/tools/cli/wait.d.ts +1 -1
  281. package/dist/tools/cli/wait.d.ts.map +1 -1
  282. package/dist/tools/connections/runtime.d.ts +1 -1
  283. package/dist/tools/connections/runtime.d.ts.map +1 -1
  284. package/dist/tools/execute-args.d.ts +23 -0
  285. package/dist/tools/execute-args.d.ts.map +1 -0
  286. package/dist/tools/execute-hooks.d.ts +146 -0
  287. package/dist/tools/execute-hooks.d.ts.map +1 -0
  288. package/dist/tools/execute-result.d.ts +40 -0
  289. package/dist/tools/execute-result.d.ts.map +1 -0
  290. package/dist/tools/execute.d.ts +4 -193
  291. package/dist/tools/execute.d.ts.map +1 -1
  292. package/dist/tools/internal/surface-projector.d.ts +2 -1
  293. package/dist/tools/internal/surface-projector.d.ts.map +1 -1
  294. package/dist/tools/invoker.d.ts +2 -1
  295. package/dist/tools/invoker.d.ts.map +1 -1
  296. package/dist/tools/lifecycle.d.ts +1 -1
  297. package/dist/tools/lifecycle.d.ts.map +1 -1
  298. package/dist/tools/mcp/mount.d.ts +1 -1
  299. package/dist/tools/mcp/mount.d.ts.map +1 -1
  300. package/dist/tools/mcp/prepare.d.ts +2 -1
  301. package/dist/tools/mcp/prepare.d.ts.map +1 -1
  302. package/dist/tools/mcp/progress.d.ts +1 -1
  303. package/dist/tools/mcp/progress.d.ts.map +1 -1
  304. package/dist/tools/mcp/register.d.ts +3 -2
  305. package/dist/tools/mcp/register.d.ts.map +1 -1
  306. package/dist/tools/mcp/round-context.d.ts +38 -0
  307. package/dist/tools/mcp/round-context.d.ts.map +1 -0
  308. package/dist/tools/mcp/round-policy.d.ts +1 -1
  309. package/dist/tools/mcp/round-policy.d.ts.map +1 -1
  310. package/dist/tools/mcp/round.d.ts +3 -11
  311. package/dist/tools/mcp/round.d.ts.map +1 -1
  312. package/dist/tools/mcp/runtime-tools.d.ts +2 -1
  313. package/dist/tools/mcp/runtime-tools.d.ts.map +1 -1
  314. package/dist/tools/mount.d.ts +3 -1
  315. package/dist/tools/mount.d.ts.map +1 -1
  316. package/dist/tools/native-definition.d.ts +2 -1
  317. package/dist/tools/native-definition.d.ts.map +1 -1
  318. package/dist/tools/operations/async-operation-runtime-tools.d.ts +2 -1
  319. package/dist/tools/operations/async-operation-runtime-tools.d.ts.map +1 -1
  320. package/dist/tools/operations/async-operation-runtime-types.d.ts +2 -1
  321. package/dist/tools/operations/async-operation-runtime-types.d.ts.map +1 -1
  322. package/dist/tools/remote.d.ts.map +1 -1
  323. package/dist/tools/runtime-tool.d.ts +3 -1
  324. package/dist/tools/runtime-tool.d.ts.map +1 -1
  325. package/dist/tools/tool-logger.d.ts +1 -1
  326. package/dist/tools/tool-logger.d.ts.map +1 -1
  327. package/dist/tracking/client-listeners.d.ts +30 -0
  328. package/dist/tracking/client-listeners.d.ts.map +1 -0
  329. package/dist/tracking/client-visit.d.ts +61 -0
  330. package/dist/tracking/client-visit.d.ts.map +1 -0
  331. package/dist/tracking/client.d.ts +3 -2
  332. package/dist/tracking/client.d.ts.map +1 -1
  333. package/llms/application.2.txt +266 -2
  334. package/llms/application.txt +8 -266
  335. package/llms/cli.2.txt +80 -0
  336. package/llms/cli.txt +45 -74
  337. package/llms/contract.txt +3 -3
  338. package/llms/files.txt +3 -0
  339. package/llms/tools.2.txt +88 -279
  340. package/llms/tools.3.txt +288 -0
  341. package/llms/tools.txt +27 -65
  342. package/llms-full.txt +108 -12
  343. package/llms.txt +5 -5
  344. package/package.json +1 -1
  345. package/dist/index-e2z3ahw9.js +0 -325
  346. package/dist/index-mkm15s49.js +0 -394
@@ -1 +1 @@
1
- {"version":3,"file":"boundary.d.ts","sourceRoot":"","sources":["../../src/files/boundary.ts"],"names":[],"mappings":"AAIA,OAAO,EAEL,KAAK,cAAc,EAEpB,MAAM,sBAAsB,CAAC;AAqB9B,MAAM,MAAM,oBAAoB,GAC5B,mBAAmB,GACnB,gBAAgB,GAChB,kBAAkB,GAClB,mBAAm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AU,GAAG,cAAc,CAAC,UAAU,CAAC,EAC/C,OAAO,CAAC,EAAE,uBAAuB,GAChC,OAAO,CAAC,cAAc,CAAC,CAAC;CAC5B;AA2GD;;;;GAIG;AACH,wBAAsB,yBAAyB,CAC7C,MAAM,EAAE,yBAAyB,GAChC,OAAO,CAAC,mBAAmB,CAAC,CAyJ9B"}
@@ -0,0 +1,14 @@
1
+ import type { open } from 'node:fs/promises';
2
+ import { type ManagedFileRef } from '../contract/file-ref.js';
3
+ import { type ManagedFileInspection, type ManagedFileInspectionInput, type ManagedFileInspector } from './boundary.js';
4
+ export declare function inspectFile(inspector: ManagedFileInspector | undefined, input: Omit<ManagedFileInspectionInput, 'signal'>, timeoutMs: number, outerSignal?: AbortSignal): Promise<ManagedFileInspection>;
5
+ export declare function inspectedRef(path: string, size: number, inspection: ManagedFileInspection, fallback?: {
6
+ mediaType?: string;
7
+ name?: string;
8
+ }): ManagedFileRef;
9
+ export declare function readHandle(handle: Awaited<ReturnType<typeof open>>, maxBytes: number, signal?: AbortSignal): Promise<Uint8Array>;
10
+ export declare function writeSource(handle: Awaited<ReturnType<typeof open>>, source: Uint8Array | ReadableStream<Uint8Array>, maxBytes: number, inspectionBytes: number, signal?: AbortSignal): Promise<{
11
+ size: number;
12
+ prefix: Uint8Array;
13
+ }>;
14
+ //# sourceMappingURL=file-io.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"file-io.d.ts","sourceRoot":"","sources":["../../src/files/file-io.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,KAAK,cAAc,EAAwB,MAAM,sBAAsB,CAAC;AACjF,OAAO,EAEL,KAAK,qBAAqB,EAC1B,KAAK,0BAA0B,EAC/B,KAAK,oBAAoB,EAC1B,MAAM,YAAY,CAAC;AA+BpB,wBAAsB,WAAW,CAC/B,SAAS,EAAE,oBAAoB,GAAG,SAAS,EAC3C,KAAK,EAAE,IAAI,CAAC,0BAA0B,EAAE,QAAQ,CAAC,EACjD,SAAS,EAAE,MAAM,EACjB,WAAW,CAAC,EAAE,WAAW,GACxB,OAAO,CAAC,qBAAqB,CAAC,CAmBhC;AAED,wBAAgB,YAAY,CAC1B,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,UAAU,EAAE,qBAAqB,EACjC,QAAQ,GAAE;IAAE,SAAS,CAAC,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAO,GACnD,cAAc,CAiBhB;AAED,wBAAsB,UAAU,CAC9B,MAAM,EAAE,OAAO,CAAC,UAAU,CAAC,OAAO,IAAI,CAAC,CAAC,EACxC,QAAQ,EAAE,MAAM,EAChB,MAAM,CAAC,EAAE,WAAW,GACnB,OAAO,CAAC,UAAU,CAAC,CAyBrB;AAcD,wBAAsB,WAAW,CAC/B,MAAM,EAAE,OAAO,CAAC,UAAU,CAAC,OAAO,IAAI,CAAC,CAAC,EACxC,MAAM,EAAE,UAAU,GAAG,cAAc,CAAC,UAAU,CAAC,EAC/C,QAAQ,EAAE,MAAM,EAChB,eAAe,EAAE,MAAM,EACvB,MAAM,CAAC,EAAE,WAAW,GACnB,OAAO,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,UAAU,CAAA;CAAE,CAAC,CA2C/C"}
@@ -0,0 +1,412 @@
1
+ import {
2
+ createBoundedChannel
3
+ } from "./index-d9pk3td4.js";
4
+
5
+ // src/browser/live-state.ts
6
+ import { z as z2 } from "zod";
7
+
8
+ // src/browser/live-state-core.ts
9
+ import { z } from "zod";
10
+ var PositiveSafeIntegerSchema = z.number().int().positive().safe();
11
+ function isPromiseLike(value) {
12
+ return (typeof value === "object" || typeof value === "function") && value !== null && "then" in value && typeof value.then === "function";
13
+ }
14
+
15
+ class LiveStateCore {
16
+ config;
17
+ maxBufferedEvents;
18
+ maxBufferedBytes;
19
+ subscribers = new Set;
20
+ phase = "idle";
21
+ reason;
22
+ generation = 0;
23
+ stored = { hasValue: false };
24
+ receivedEvents = 0;
25
+ appliedEvents = 0;
26
+ duplicateEvents = 0;
27
+ gapEvents = 0;
28
+ refusedEvents = 0;
29
+ current;
30
+ opening;
31
+ unsettledSourceOpens = 0;
32
+ unsettledSourceCloses = 0;
33
+ publishDepth = 0;
34
+ controllerErrorObserverEnabled = true;
35
+ subscriberErrorObserverEnabled = true;
36
+ published;
37
+ abortFromConfig = () => {
38
+ this.close();
39
+ };
40
+ constructor(config) {
41
+ this.config = config;
42
+ this.maxBufferedEvents = PositiveSafeIntegerSchema.parse(config.maxBufferedEvents);
43
+ this.maxBufferedBytes = PositiveSafeIntegerSchema.parse(config.maxBufferedBytes);
44
+ if (config.signal?.aborted)
45
+ this.phase = "closed";
46
+ else
47
+ config.signal?.addEventListener("abort", this.abortFromConfig, { once: true });
48
+ this.published = this.buildSnapshot();
49
+ }
50
+ start() {
51
+ if (this.phase === "idle")
52
+ return this.begin(false);
53
+ return this.opening ?? Promise.resolve(this.published);
54
+ }
55
+ resync() {
56
+ if (this.phase === "closed")
57
+ return Promise.resolve(this.published);
58
+ const active = this.current;
59
+ if (active?.startedByResync && !active.sourceOpenStarted && this.phase === "opening" && this.publishDepth > 0) {
60
+ return this.opening ?? Promise.resolve(this.published);
61
+ }
62
+ if (active) {
63
+ this.retire(active);
64
+ if (this.unsettledSourceOpens + this.unsettledSourceCloses >= 2) {
65
+ this.phase = "unavailable";
66
+ this.reason = "controller-capacity";
67
+ return Promise.resolve(this.publish());
68
+ }
69
+ }
70
+ return this.begin(true);
71
+ }
72
+ status() {
73
+ const buffered = this.current?.buffer.getSnapshot();
74
+ return LiveStateControllerStatusSchema.parse({
75
+ phase: this.phase,
76
+ generation: this.generation,
77
+ hasValue: this.stored.hasValue,
78
+ bufferedEvents: buffered?.queuedItems ?? 0,
79
+ bufferedBytes: buffered?.queuedBytes ?? 0,
80
+ receivedEvents: this.receivedEvents,
81
+ appliedEvents: this.appliedEvents,
82
+ duplicateEvents: this.duplicateEvents,
83
+ gapEvents: this.gapEvents,
84
+ refusedEvents: this.refusedEvents,
85
+ ...this.reason && { reason: this.reason }
86
+ });
87
+ }
88
+ buildSnapshot() {
89
+ const metadata = this.status();
90
+ return this.stored.hasValue ? Object.freeze({ ...metadata, value: this.stored.value }) : metadata;
91
+ }
92
+ reportControllerError(error, at, atGeneration) {
93
+ if (!this.config.onControllerError || !this.controllerErrorObserverEnabled)
94
+ return;
95
+ try {
96
+ const returned = this.config.onControllerError({
97
+ error,
98
+ generation: atGeneration,
99
+ phase: at
100
+ });
101
+ if (isPromiseLike(returned)) {
102
+ this.controllerErrorObserverEnabled = false;
103
+ Promise.resolve(returned).catch(() => {
104
+ return;
105
+ });
106
+ }
107
+ } catch {}
108
+ }
109
+ reportSubscriberError(error, snapshot) {
110
+ if (!this.config.onSubscriberError || !this.subscriberErrorObserverEnabled)
111
+ return;
112
+ try {
113
+ const returned = this.config.onSubscriberError({ error, snapshot });
114
+ if (isPromiseLike(returned)) {
115
+ this.subscriberErrorObserverEnabled = false;
116
+ Promise.resolve(returned).catch(() => {
117
+ return;
118
+ });
119
+ }
120
+ } catch {}
121
+ }
122
+ publish() {
123
+ const snapshot = this.buildSnapshot();
124
+ this.published = snapshot;
125
+ this.publishDepth += 1;
126
+ try {
127
+ for (const listener of this.subscribers) {
128
+ try {
129
+ const returned = listener(snapshot);
130
+ if (isPromiseLike(returned)) {
131
+ this.subscribers.delete(listener);
132
+ this.reportSubscriberError(new TypeError("Live-state subscribers must settle synchronously"), snapshot);
133
+ Promise.resolve(returned).catch(() => {
134
+ return;
135
+ });
136
+ }
137
+ } catch (error) {
138
+ this.reportSubscriberError(error, snapshot);
139
+ }
140
+ }
141
+ } finally {
142
+ this.publishDepth -= 1;
143
+ }
144
+ return this.published;
145
+ }
146
+ publishAvailableCapacity() {
147
+ if (this.phase !== "unavailable" || this.reason !== "controller-capacity" || this.unsettledSourceOpens + this.unsettledSourceCloses >= 2)
148
+ return;
149
+ this.phase = "resync-required";
150
+ this.publish();
151
+ }
152
+ closeSource(active) {
153
+ if (active.closePromise)
154
+ return active.closePromise;
155
+ if (!active.closeSource)
156
+ return Promise.resolve();
157
+ const at = this.phase;
158
+ this.unsettledSourceCloses += 1;
159
+ active.closePromise = Promise.resolve().then(() => active.closeSource?.()).then(() => {
160
+ return;
161
+ }).catch((error) => {
162
+ this.reportControllerError(error, at, active.id);
163
+ }).finally(() => {
164
+ this.unsettledSourceCloses -= 1;
165
+ this.publishAvailableCapacity();
166
+ });
167
+ return active.closePromise;
168
+ }
169
+ retire(active) {
170
+ if (!active.retired) {
171
+ active.retired = true;
172
+ active.settleRetired();
173
+ active.abort.abort();
174
+ active.buffer.close({ mode: "discard" });
175
+ }
176
+ return this.closeSource(active);
177
+ }
178
+ stopGeneration(active, nextPhase, nextReason) {
179
+ if (this.current !== active || active.retired || this.phase === "closed")
180
+ return;
181
+ this.phase = nextPhase;
182
+ this.reason = nextReason;
183
+ this.retire(active);
184
+ this.publish();
185
+ }
186
+ apply(active, event) {
187
+ if (this.current !== active || active.retired || !this.stored.hasValue || this.phase !== "opening" && this.phase !== "live")
188
+ return;
189
+ let decision;
190
+ try {
191
+ decision = this.config.applyEvent(this.stored.value, event);
192
+ } catch (error) {
193
+ this.reportControllerError(error, this.phase, active.id);
194
+ this.stopGeneration(active, "unavailable", "controller-error");
195
+ return;
196
+ }
197
+ if (this.current !== active || active.retired || this.phase !== "opening" && this.phase !== "live")
198
+ return;
199
+ if (!decision || !["applied", "duplicate", "gap"].includes(decision.outcome) || decision.outcome === "applied" && !("state" in decision)) {
200
+ this.reportControllerError(new Error("applyEvent returned an invalid decision"), this.phase, active.id);
201
+ this.stopGeneration(active, "unavailable", "controller-error");
202
+ return;
203
+ }
204
+ if (decision.outcome === "duplicate") {
205
+ this.duplicateEvents += 1;
206
+ this.publish();
207
+ return;
208
+ }
209
+ if (decision.outcome === "gap") {
210
+ this.gapEvents += 1;
211
+ this.stopGeneration(active, "resync-required", "gap");
212
+ return;
213
+ }
214
+ this.stored = { hasValue: true, value: decision.state };
215
+ this.appliedEvents += 1;
216
+ this.publish();
217
+ }
218
+ onEvent(active, event) {
219
+ if (this.current !== active || active.retired || this.phase === "closed")
220
+ return;
221
+ this.receivedEvents += 1;
222
+ if (this.phase === "opening") {
223
+ try {
224
+ const offered = active.buffer.offer(event);
225
+ if (offered.outcome === "refused") {
226
+ this.refusedEvents += 1;
227
+ this.stopGeneration(active, "resync-required", "buffer-overflow");
228
+ } else {
229
+ this.publish();
230
+ }
231
+ } catch (error) {
232
+ this.refusedEvents += 1;
233
+ this.reportControllerError(error, this.phase, active.id);
234
+ this.stopGeneration(active, "unavailable", "controller-error");
235
+ }
236
+ return;
237
+ }
238
+ if (this.phase === "live")
239
+ this.apply(active, event);
240
+ }
241
+ async openGeneration(active) {
242
+ try {
243
+ if (active.retired || this.current !== active || this.phase === "closed")
244
+ return this.published;
245
+ this.unsettledSourceOpens += 1;
246
+ let sourceOpening;
247
+ try {
248
+ sourceOpening = this.config.source.open({
249
+ signal: active.abort.signal,
250
+ onEvent: (event) => this.onEvent(active, event),
251
+ onUnavailable: () => this.stopGeneration(active, "unavailable", "source-unavailable")
252
+ });
253
+ } catch (error) {
254
+ this.unsettledSourceOpens -= 1;
255
+ this.publishAvailableCapacity();
256
+ throw error;
257
+ }
258
+ sourceOpening = sourceOpening.then((opened2) => {
259
+ active.closeSource = () => opened2.close();
260
+ this.unsettledSourceOpens -= 1;
261
+ if (active.retired || this.current !== active || this.phase === "closed") {
262
+ this.closeSource(active);
263
+ }
264
+ this.publishAvailableCapacity();
265
+ return opened2;
266
+ }, (error) => {
267
+ this.unsettledSourceOpens -= 1;
268
+ this.publishAvailableCapacity();
269
+ throw error;
270
+ });
271
+ const outcome = await Promise.race([
272
+ sourceOpening.then((opened2) => ({ outcome: "opened", opened: opened2 })),
273
+ active.retiredPromise.then(() => ({ outcome: "retired" }))
274
+ ]);
275
+ if (outcome.outcome === "retired") {
276
+ return this.published;
277
+ }
278
+ const { opened } = outcome;
279
+ if (this.current !== active || active.retired || this.phase !== "opening") {
280
+ this.closeSource(active);
281
+ return this.published;
282
+ }
283
+ this.stored = { hasValue: true, value: opened.snapshot };
284
+ this.publish();
285
+ while (this.current === active && !active.retired && this.phase === "opening") {
286
+ if (active.buffer.getSnapshot().queuedItems === 0) {
287
+ active.buffer.close({ mode: "discard" });
288
+ this.phase = "live";
289
+ this.reason = undefined;
290
+ return this.publish();
291
+ }
292
+ const next = await active.buffer.next();
293
+ if (next.done)
294
+ break;
295
+ this.apply(active, next.value);
296
+ }
297
+ if (this.current && this.current !== active && this.opening)
298
+ return this.opening;
299
+ return this.published;
300
+ } catch (error) {
301
+ if (this.current === active && !active.retired && this.phase !== "closed") {
302
+ this.reportControllerError(error, this.phase, active.id);
303
+ this.stopGeneration(active, "unavailable", "source-error");
304
+ }
305
+ this.publishAvailableCapacity();
306
+ return this.published;
307
+ }
308
+ }
309
+ begin(startedByResync) {
310
+ this.generation += 1;
311
+ this.phase = "opening";
312
+ this.reason = undefined;
313
+ let settleRetired = () => {
314
+ return;
315
+ };
316
+ const retiredPromise = new Promise((resolve) => {
317
+ settleRetired = resolve;
318
+ });
319
+ const active = {
320
+ id: this.generation,
321
+ startedByResync,
322
+ abort: new AbortController,
323
+ buffer: createBoundedChannel({
324
+ policy: "ordered",
325
+ maxItems: this.maxBufferedEvents,
326
+ maxBytes: this.maxBufferedBytes,
327
+ sizeOf: this.config.sizeOfEvent
328
+ }),
329
+ retiredPromise,
330
+ settleRetired,
331
+ retired: false,
332
+ sourceOpenStarted: false
333
+ };
334
+ this.current = active;
335
+ this.publish();
336
+ if (this.current !== active || active.retired || this.phase !== "opening") {
337
+ return this.opening ?? Promise.resolve(this.published);
338
+ }
339
+ active.sourceOpenStarted = true;
340
+ const operation = this.openGeneration(active);
341
+ this.opening = operation;
342
+ operation.finally(() => {
343
+ if (this.opening === operation)
344
+ this.opening = undefined;
345
+ });
346
+ return operation;
347
+ }
348
+ close() {
349
+ if (this.phase === "closed")
350
+ return Promise.resolve(this.published);
351
+ const active = this.current;
352
+ this.current = undefined;
353
+ this.phase = "closed";
354
+ this.reason = undefined;
355
+ const snapshot = this.publish();
356
+ if (active)
357
+ this.retire(active);
358
+ this.config.signal?.removeEventListener("abort", this.abortFromConfig);
359
+ this.subscribers.clear();
360
+ return Promise.resolve(snapshot);
361
+ }
362
+ }
363
+
364
+ // src/browser/live-state.ts
365
+ var LiveStatePhaseSchema = z2.enum([
366
+ "idle",
367
+ "opening",
368
+ "live",
369
+ "resync-required",
370
+ "unavailable",
371
+ "closed"
372
+ ]);
373
+ var LiveStateStopReasonSchema = z2.enum([
374
+ "gap",
375
+ "buffer-overflow",
376
+ "source-unavailable",
377
+ "source-error",
378
+ "controller-error",
379
+ "controller-capacity"
380
+ ]);
381
+ var LiveStateControllerStatusSchema = z2.object({
382
+ phase: LiveStatePhaseSchema,
383
+ generation: z2.number().int().nonnegative(),
384
+ hasValue: z2.boolean(),
385
+ bufferedEvents: z2.number().int().nonnegative(),
386
+ bufferedBytes: z2.number().int().nonnegative(),
387
+ receivedEvents: z2.number().int().nonnegative(),
388
+ appliedEvents: z2.number().int().nonnegative(),
389
+ duplicateEvents: z2.number().int().nonnegative(),
390
+ gapEvents: z2.number().int().nonnegative(),
391
+ refusedEvents: z2.number().int().nonnegative(),
392
+ reason: LiveStateStopReasonSchema.optional()
393
+ }).strict().readonly();
394
+ function createLiveStateController(config) {
395
+ const core = new LiveStateCore(config);
396
+ return {
397
+ start: () => core.start(),
398
+ resync: () => core.resync(),
399
+ getSnapshot: () => core.published,
400
+ subscribe(listener) {
401
+ if (core.phase === "closed")
402
+ return () => {
403
+ return;
404
+ };
405
+ core.subscribers.add(listener);
406
+ return () => core.subscribers.delete(listener);
407
+ },
408
+ close: () => core.close()
409
+ };
410
+ }
411
+
412
+ export { LiveStatePhaseSchema, LiveStateStopReasonSchema, LiveStateControllerStatusSchema, createLiveStateController };
@@ -1,7 +1,15 @@
1
1
  import {
2
- mergeMeta,
3
2
  resolveRouteParamsSchema
4
- } from "./index-gyr48nzg.js";
3
+ } from "./index-4gcnakhx.js";
4
+
5
+ // src/contract/runtime-context.ts
6
+ function mergeMeta(contractMeta, endpointMeta) {
7
+ if (!contractMeta)
8
+ return endpointMeta;
9
+ if (!endpointMeta)
10
+ return { ...contractMeta };
11
+ return { ...contractMeta, ...endpointMeta };
12
+ }
5
13
 
6
14
  // src/server/contract-method.ts
7
15
  var HTTP_ONLY = Object.freeze(["HTTP"]);
@@ -1,16 +1,11 @@
1
1
  import {
2
2
  contractMethodFields
3
- } from "./index-kvj7f4hq.js";
3
+ } from "./index-2bxbyab0.js";
4
4
  import {
5
5
  AppError
6
6
  } from "./index-2vtcmrj9.js";
7
- import {
8
- isUnsafeKey
9
- } from "./index-kzfs85xp.js";
10
7
  import {
11
8
  callRuntimeHandler,
12
- isRecord,
13
- transportResult,
14
9
  typedEntries
15
10
  } from "./index-hffjpmq9.js";
16
11
 
@@ -233,161 +228,6 @@ function createScopedImplement() {
233
228
  const declare = (_contract) => (handlers) => handlers;
234
229
  return Object.assign(implementScoped, { stream, declare });
235
230
  }
236
- function createScopedImplementRegistry() {
237
- return (contracts, handlers, options) => transportResult(bindRegistry(contracts, handlers, options));
238
- }
239
- function isImplementationContract(value) {
240
- return isRecord(value) && isRecord(value.meta) && typeof value.meta.prefix === "string" && isRecord(value.endpoints);
241
- }
242
- function bindRegistry(contracts, handlers, options) {
243
- const contractKeys = Object.keys(contracts);
244
- const handlerKeys = Object.keys(handlers);
245
- const missing = contractKeys.filter((key) => !Object.hasOwn(handlers, key));
246
- const extra = handlerKeys.filter((key) => !Object.hasOwn(contracts, key));
247
- if (missing.length > 0 || extra.length > 0) {
248
- if (options?.onMissingHandler !== "stub") {
249
- throw new Error(`[stitchkit] implementRegistry: registry mismatch (missing: ${missing.join(", ") || "none"}; extra: ${extra.join(", ") || "none"})`);
250
- }
251
- console.warn(`[stitchkit] implementRegistry: registry mismatch (missing: ${missing.join(", ") || "none"}; extra: ${extra.join(", ") || "none"}) — missing contracts are mounted as 501 stubs and extra handlers are ignored`);
252
- }
253
- const prefixes = new Map;
254
- const services = [];
255
- const byKey = {};
256
- for (const [key, candidate] of Object.entries(contracts)) {
257
- if (!isImplementationContract(candidate)) {
258
- throw new TypeError(`[stitchkit] implementRegistry: registry entry "${key}" must be one contract; composed arrays and namespaces are not supported`);
259
- }
260
- const contract = candidate;
261
- const groupScope = contract.meta.scope ?? "public";
262
- const identity = `${groupScope}\x00${contract.meta.prefix}`;
263
- const previousKey = prefixes.get(identity);
264
- if (previousKey !== undefined) {
265
- throw new Error(`[stitchkit] implementRegistry: duplicate contract prefix "${contract.meta.prefix}" in scope "${groupScope}" at "${previousKey}" and "${key}"`);
266
- }
267
- prefixes.set(identity, key);
268
- const entryHandlers = handlers[key] === undefined && options?.onMissingHandler === "stub" ? {} : handlers[key];
269
- if (!isRecord(entryHandlers)) {
270
- throw new TypeError(`[stitchkit] implementRegistry: handlers for "${key}" must be an object`);
271
- }
272
- const endpointKeys = Object.keys(contract.endpoints);
273
- const handlerEntryKeys = Object.keys(entryHandlers);
274
- const missingEndpoints = endpointKeys.filter((endpointKey) => !Object.hasOwn(entryHandlers, endpointKey));
275
- const extraEndpoints = handlerEntryKeys.filter((endpointKey) => !Object.hasOwn(contract.endpoints, endpointKey));
276
- if (missingEndpoints.length > 0 || extraEndpoints.length > 0) {
277
- const detail = `handlers for "${key}" mismatch (missing: ${missingEndpoints.join(", ") || "none"}; extra: ${extraEndpoints.join(", ") || "none"})`;
278
- if (options?.onMissingHandler !== "stub") {
279
- throw new Error(`[stitchkit] implementRegistry: ${detail}`);
280
- }
281
- console.warn(`[stitchkit] implementRegistry: ${detail} — missing endpoints are mounted as 501 stubs and extra handlers are ignored`);
282
- }
283
- const service = bindContract(contract, entryHandlers, options);
284
- services.push(service);
285
- byKey[key] = service;
286
- }
287
- Object.defineProperty(services, "byKey", { value: byKey, enumerable: false });
288
- return transportResult(services);
289
- }
290
- function implementRegistry(contracts, handlers, options) {
291
- return transportResult(bindRegistry(contracts, handlers, options));
292
- }
293
- function createImplementRegistry() {
294
- return (contracts, handlers, options) => transportResult(bindRegistry(contracts, handlers, options));
295
- }
296
-
297
- // src/server/context-contribution.ts
298
- var RUNTIME_CONTEXT_RESERVED_KEYS = new Set([
299
- "params",
300
- "input",
301
- "files",
302
- "rawBody",
303
- "source",
304
- "req",
305
- "url",
306
- "headers",
307
- "traceId",
308
- "spanId",
309
- "ipAddress",
310
- "userAgent",
311
- "signal",
312
- "mcp",
313
- "reportProgress"
314
- ]);
315
- function contributionError(scope, reason) {
316
- return new TypeError(`[stitchkit] auth: invalid context contribution for scope ${JSON.stringify(scope)}: ${reason}`);
317
- }
318
- function descriptorsEqual(left, right) {
319
- if (!left || !right)
320
- return left === right;
321
- if (left.enumerable !== right.enumerable || left.configurable !== right.configurable || left.writable !== right.writable) {
322
- return false;
323
- }
324
- if ("value" in left || "value" in right) {
325
- return "value" in left && "value" in right && Object.is(left.value, right.value);
326
- }
327
- return left.get === right.get && left.set === right.set;
328
- }
329
- function contextContributionDelta(original, shadow, scope) {
330
- if (Object.getPrototypeOf(shadow) !== Object.getPrototypeOf(original)) {
331
- throw contributionError(scope, "context prototype changes are not supported");
332
- }
333
- const originalKeys = Reflect.ownKeys(original);
334
- const shadowKeys = Reflect.ownKeys(shadow);
335
- const shadowKeySet = new Set(shadowKeys);
336
- for (const key of originalKeys) {
337
- if (!shadowKeySet.has(key)) {
338
- const printable = typeof key === "string" ? JSON.stringify(key) : "a symbol key";
339
- throw contributionError(scope, `context key ${printable} may not be deleted`);
340
- }
341
- }
342
- const contribution = Object.create(null);
343
- for (const key of shadowKeys) {
344
- const originalDescriptor = Object.getOwnPropertyDescriptor(original, key);
345
- const shadowDescriptor = Object.getOwnPropertyDescriptor(shadow, key);
346
- if (!shadowDescriptor || descriptorsEqual(originalDescriptor, shadowDescriptor))
347
- continue;
348
- Object.defineProperty(contribution, key, shadowDescriptor);
349
- }
350
- return contribution;
351
- }
352
- function prepareContextContribution(value, scope) {
353
- if (typeof value !== "object" || value === null || Array.isArray(value)) {
354
- throw contributionError(scope, "expected a plain record");
355
- }
356
- let prototype;
357
- let descriptors;
358
- let keys;
359
- try {
360
- prototype = Object.getPrototypeOf(value);
361
- descriptors = Object.getOwnPropertyDescriptors(value);
362
- keys = Reflect.ownKeys(value);
363
- } catch {
364
- throw contributionError(scope, "record inspection failed");
365
- }
366
- if (prototype !== Object.prototype && prototype !== null) {
367
- throw contributionError(scope, "expected Object.prototype or null prototype");
368
- }
369
- const prepared = Object.create(null);
370
- for (const key of keys) {
371
- if (typeof key !== "string") {
372
- throw contributionError(scope, "symbol keys are not supported");
373
- }
374
- if (isUnsafeKey(key)) {
375
- throw contributionError(scope, `unsafe key ${JSON.stringify(key)}`);
376
- }
377
- if (RUNTIME_CONTEXT_RESERVED_KEYS.has(key)) {
378
- throw contributionError(scope, `reserved key ${JSON.stringify(key)}`);
379
- }
380
- const descriptor = descriptors[key];
381
- if (!descriptor?.enumerable || !("value" in descriptor)) {
382
- throw contributionError(scope, `key ${JSON.stringify(key)} must be enumerable data`);
383
- }
384
- prepared[key] = descriptor.value;
385
- }
386
- return prepared;
387
- }
388
- function mergeContextContribution(ctx, value, scope) {
389
- Object.assign(ctx, prepareContextContribution(value, scope));
390
- }
391
231
 
392
232
  // src/server/process-signal-common.ts
393
233
  var DEFAULT_PROCESS_SIGNALS = ["SIGINT", "SIGTERM"];
@@ -423,4 +263,4 @@ function mediaTypeEssence(contentType) {
423
263
  return (contentType ?? "").split(";", 1)[0]?.trim().toLowerCase() ?? "";
424
264
  }
425
265
 
426
- export { DEFAULT_CORS_ALLOW_HEADERS, DEFAULT_CORS_EXPOSE_HEADERS, assertCorsConfig, isOriginAllowed, corsHeaders, corsPreflightResponse, requestCorsHeaders, applyCors, RUNTIME_CONTEXT_RESERVED_KEYS, contextContributionDelta, prepareContextContribution, mergeContextContribution, defineMultipartStream, createMultipartStream, contractOnlyService, implement, createImplement, createScopedImplement, createScopedImplementRegistry, implementRegistry, createImplementRegistry, DEFAULT_PROCESS_SIGNALS, defaultSignalSource, reportSignalError, guardSignalCallback, mediaTypeEssence };
266
+ export { DEFAULT_CORS_ALLOW_HEADERS, DEFAULT_CORS_EXPOSE_HEADERS, assertCorsConfig, isOriginAllowed, corsHeaders, corsPreflightResponse, requestCorsHeaders, applyCors, defineMultipartStream, createMultipartStream, contractOnlyService, bindContract, implement, createImplement, createScopedImplement, DEFAULT_PROCESS_SIGNALS, defaultSignalSource, reportSignalError, guardSignalCallback, mediaTypeEssence };