@frontmcp/sdk 1.11.3 → 1.12.0-rc.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 (423) hide show
  1. package/answer/answer-meter.d.ts +2 -0
  2. package/answer/answer-meter.d.ts.map +1 -1
  3. package/app/instances/app.esm.instance.d.ts +4 -2
  4. package/app/instances/app.esm.instance.d.ts.map +1 -1
  5. package/app/instances/app.lazy.instance.d.ts.map +1 -1
  6. package/app/lazy/lazy-app.rules.d.ts +4 -0
  7. package/app/lazy/lazy-app.rules.d.ts.map +1 -1
  8. package/browser/answer/answer-meter.mjs +1 -0
  9. package/browser/app/instances/app.esm.instance.mjs +11 -3
  10. package/browser/app/instances/app.lazy.instance.mjs +7 -3
  11. package/browser/app/lazy/lazy-app.rules.mjs +4 -1
  12. package/browser/channel/channel-notification.service.mjs +20 -8
  13. package/browser/channel/channel.instance.mjs +10 -1
  14. package/browser/channel/channel.utils.mjs +22 -1
  15. package/browser/channel/sources/app-event.source.mjs +5 -2
  16. package/browser/channel/sources/file-watcher.source.mjs +66 -0
  17. package/browser/common/decorators/duty.decorator.mjs +3 -4
  18. package/browser/common/decorators/event.decorator.mjs +49 -0
  19. package/browser/common/decorators/index.mjs +2 -0
  20. package/browser/common/decorators/worker.decorator.mjs +23 -0
  21. package/browser/common/entries/event.entry.mjs +59 -0
  22. package/browser/common/entries/index.mjs +1 -0
  23. package/browser/common/index.mjs +7 -7
  24. package/browser/common/interfaces/event.interface.mjs +17 -0
  25. package/browser/common/interfaces/execution-context.interface.mjs +8 -0
  26. package/browser/common/interfaces/index.mjs +2 -0
  27. package/browser/common/interfaces/worker.interface.mjs +0 -0
  28. package/browser/common/metadata/app.metadata.mjs +2 -0
  29. package/browser/common/metadata/duty.metadata.mjs +28 -13
  30. package/browser/common/metadata/duty.resolved.mjs +13 -0
  31. package/browser/common/metadata/event.metadata.mjs +137 -0
  32. package/browser/common/metadata/front-mcp.metadata.mjs +3 -0
  33. package/browser/common/metadata/index.mjs +5 -1
  34. package/browser/common/metadata/worker.metadata.mjs +44 -0
  35. package/browser/common/metadata/worker.resolved.mjs +13 -0
  36. package/browser/common/metadata/workflow.metadata.mjs +7 -1
  37. package/browser/common/records/event.record.mjs +9 -0
  38. package/browser/common/records/index.mjs +1 -0
  39. package/browser/common/schemas/annotated-class.schema.mjs +10 -0
  40. package/browser/common/schemas/index.mjs +1 -1
  41. package/browser/common/tokens/app.tokens.mjs +1 -0
  42. package/browser/common/tokens/event.tokens.mjs +11 -0
  43. package/browser/common/tokens/front-mcp.tokens.mjs +2 -0
  44. package/browser/common/tokens/index.mjs +1 -0
  45. package/browser/common/tokens/workflow.tokens.mjs +1 -0
  46. package/browser/common/utils/offset-cursor.utils.mjs +23 -0
  47. package/browser/common/utils/principal.utils.mjs +1 -1
  48. package/browser/common/utils/time-zone.utils.mjs +12 -0
  49. package/browser/direct/create.mjs +3 -1
  50. package/browser/direct/direct-client.mjs +16 -2
  51. package/browser/direct/direct-events-transport.mjs +47 -0
  52. package/browser/direct/direct-server.mjs +5 -1
  53. package/browser/duty/cron-schedule.mjs +62 -0
  54. package/browser/duty/describe-thrown.mjs +12 -0
  55. package/browser/duty/duty.lifecycle.mjs +102 -97
  56. package/browser/duty/duty.runner.mjs +117 -115
  57. package/browser/duty/lazy-lease-store.mjs +60 -0
  58. package/browser/duty/lease-holder.mjs +132 -0
  59. package/browser/duty/lease-store.mjs +125 -0
  60. package/browser/elicitation/questions/question-subject.mjs +8 -2
  61. package/browser/errors/duty.errors.mjs +20 -0
  62. package/browser/errors/event.errors.mjs +128 -0
  63. package/browser/errors/index.mjs +36 -1
  64. package/browser/errors/worker.errors.mjs +14 -0
  65. package/browser/event/delivery/event-metrics.mjs +37 -0
  66. package/browser/event/delivery/event-outbox.mjs +251 -0
  67. package/browser/event/event-channel.mjs +30 -0
  68. package/browser/event/event-dialect.mjs +23 -0
  69. package/browser/event/event-gates.mjs +72 -0
  70. package/browser/event/event-outbound.mjs +8 -0
  71. package/browser/event/event-publisher.mjs +55 -0
  72. package/browser/event/event-reauthorization.mjs +48 -0
  73. package/browser/event/event-scope.helper.mjs +266 -0
  74. package/browser/event/event-subscriber.mjs +31 -0
  75. package/browser/event/event.instance.mjs +44 -0
  76. package/browser/event/event.registry.mjs +145 -0
  77. package/browser/event/event.utils.mjs +31 -0
  78. package/browser/event/flows/event-deliver.flow.mjs +175 -0
  79. package/browser/event/flows/event-poll.flow.mjs +308 -0
  80. package/browser/event/flows/event-publish-http.flow.mjs +288 -0
  81. package/browser/event/flows/event-publish.flow.mjs +371 -0
  82. package/browser/event/flows/event-stream.flow.mjs +222 -0
  83. package/browser/event/flows/event-subscribe.flow.mjs +351 -0
  84. package/browser/event/flows/event-unsubscribe.flow.mjs +120 -0
  85. package/browser/event/flows/list-events.flow.mjs +145 -0
  86. package/browser/event/index.mjs +104 -0
  87. package/browser/event/poll/event-buffer.mjs +77 -0
  88. package/browser/event/poll/event-poll-leases.mjs +118 -0
  89. package/browser/event/publish-endpoint/event-publish-endpoint.mjs +75 -0
  90. package/browser/event/publish-endpoint/event-publish-idempotency.mjs +54 -0
  91. package/browser/event/replay/event-replays.mjs +298 -0
  92. package/browser/event/stream/event-stream.mjs +279 -0
  93. package/browser/event/stream/event-streams.mjs +122 -0
  94. package/browser/event/subscription/event-callback-verifier.mjs +165 -0
  95. package/browser/event/subscription/event-subscription-store.factory.mjs +59 -0
  96. package/browser/event/subscription/event-subscription-termination.mjs +34 -0
  97. package/browser/event/subscription/event-subscription.store.mjs +167 -0
  98. package/browser/event/subscription/event-subscriptions.mjs +126 -0
  99. package/browser/event-client/event-client.errors.mjs +50 -0
  100. package/browser/event-client/event-webhook-receiver.mjs +155 -0
  101. package/browser/event-client/events-client.mjs +471 -0
  102. package/browser/event-client/index.mjs +28 -0
  103. package/browser/front-mcp/authorities-rules.check.mjs +15 -1
  104. package/browser/front-mcp/front-mcp.mjs +4 -6
  105. package/browser/index.cjs +23640 -16042
  106. package/browser/index.mjs +37 -2
  107. package/browser/job/execution/job-execution.manager.mjs +39 -5
  108. package/browser/job/job-scope.helper.mjs +21 -0
  109. package/browser/job/store/memory-job-state.store.mjs +5 -0
  110. package/browser/job/store/redis-job-state.store.mjs +11 -0
  111. package/browser/job/store/storage-job-state.store.mjs +18 -2
  112. package/browser/notification/notification.service.mjs +36 -6
  113. package/browser/provider/create-container.mjs +20 -9
  114. package/browser/provider/provider.lifecycle.mjs +4 -0
  115. package/browser/provider/provider.registry.mjs +55 -11
  116. package/browser/scope/event-publisher.providers.mjs +32 -0
  117. package/browser/scope/scope.instance.mjs +34 -21
  118. package/browser/skill/skill-instructions.helper.mjs +12 -6
  119. package/browser/subsystems.mjs +3 -0
  120. package/browser/tool/flows/tools-list.flow.mjs +3 -33
  121. package/browser/transport/adapters/transport.local.adapter.mjs +9 -2
  122. package/browser/transport/build-scoped-server-options.mjs +5 -1
  123. package/browser/transport/flows/handle.mcp-20260728.flow.mjs +76 -3
  124. package/browser/transport/in-memory-server.mjs +3 -0
  125. package/browser/transport/mcp-20260728/discover.mjs +1 -0
  126. package/browser/transport/mcp-20260728/event-stream-response.mjs +44 -0
  127. package/browser/transport/mcp-20260728/index.mjs +2 -1
  128. package/browser/transport/mcp-20260728/protocol-20260728.constants.mjs +8 -1
  129. package/browser/transport/mcp-20260728/request-validation.mjs +9 -5
  130. package/browser/transport/mcp-handlers/events-list-request.handler.mjs +23 -0
  131. package/browser/transport/mcp-handlers/events-poll-request.handler.mjs +23 -0
  132. package/browser/transport/mcp-handlers/events-stream-request.handler.mjs +44 -0
  133. package/browser/transport/mcp-handlers/events-subscribe-request.handler.mjs +23 -0
  134. package/browser/transport/mcp-handlers/events-unsubscribe-request.handler.mjs +25 -0
  135. package/browser/transport/mcp-handlers/index.mjs +13 -0
  136. package/browser/transport/mcp-handlers/initialize-request.handler.mjs +3 -1
  137. package/browser/transport/stdio-revision-router.mjs +29 -2
  138. package/browser/worker/worker.lifecycle.mjs +199 -0
  139. package/browser/worker/worker.supervisor.mjs +111 -0
  140. package/browser/workflow/tools/register-workflow.tool.mjs +3 -3
  141. package/browser/workflow/trigger/workflow-events.mjs +3 -1
  142. package/browser/workflow/trigger/workflow-schedules.mjs +173 -0
  143. package/browser/workflow/trigger/workflow-triggers.mjs +31 -0
  144. package/channel/channel-notification.service.d.ts +5 -2
  145. package/channel/channel-notification.service.d.ts.map +1 -1
  146. package/channel/channel-scope.helper.d.ts +4 -1
  147. package/channel/channel-scope.helper.d.ts.map +1 -1
  148. package/channel/channel.instance.d.ts +7 -1
  149. package/channel/channel.instance.d.ts.map +1 -1
  150. package/channel/channel.utils.d.ts +20 -0
  151. package/channel/channel.utils.d.ts.map +1 -1
  152. package/channel/sources/app-event.source.d.ts +11 -2
  153. package/channel/sources/app-event.source.d.ts.map +1 -1
  154. package/channel/sources/file-watcher.source.d.ts +21 -0
  155. package/channel/sources/file-watcher.source.d.ts.map +1 -0
  156. package/channel/sources/index.d.ts +1 -0
  157. package/channel/sources/index.d.ts.map +1 -1
  158. package/common/decorators/duty.decorator.d.ts +3 -2
  159. package/common/decorators/duty.decorator.d.ts.map +1 -1
  160. package/common/decorators/event.decorator.d.ts +38 -0
  161. package/common/decorators/event.decorator.d.ts.map +1 -0
  162. package/common/decorators/index.d.ts +2 -0
  163. package/common/decorators/index.d.ts.map +1 -1
  164. package/common/decorators/worker.decorator.d.ts +13 -0
  165. package/common/decorators/worker.decorator.d.ts.map +1 -0
  166. package/common/entries/event.entry.d.ts +34 -0
  167. package/common/entries/event.entry.d.ts.map +1 -0
  168. package/common/entries/index.d.ts +1 -0
  169. package/common/entries/index.d.ts.map +1 -1
  170. package/common/entries/scope.entry.d.ts +3 -0
  171. package/common/entries/scope.entry.d.ts.map +1 -1
  172. package/common/interfaces/event.interface.d.ts +124 -0
  173. package/common/interfaces/event.interface.d.ts.map +1 -0
  174. package/common/interfaces/execution-context.interface.d.ts +3 -0
  175. package/common/interfaces/execution-context.interface.d.ts.map +1 -1
  176. package/common/interfaces/index.d.ts +2 -0
  177. package/common/interfaces/index.d.ts.map +1 -1
  178. package/common/interfaces/internal/registry.interface.d.ts +3 -1
  179. package/common/interfaces/internal/registry.interface.d.ts.map +1 -1
  180. package/common/interfaces/worker.interface.d.ts +13 -0
  181. package/common/interfaces/worker.interface.d.ts.map +1 -0
  182. package/common/metadata/agent.metadata.d.ts +1 -1
  183. package/common/metadata/app.metadata.d.ts +4 -1
  184. package/common/metadata/app.metadata.d.ts.map +1 -1
  185. package/common/metadata/channel.metadata.d.ts +40 -8
  186. package/common/metadata/channel.metadata.d.ts.map +1 -1
  187. package/common/metadata/duty.metadata.d.ts +67 -13
  188. package/common/metadata/duty.metadata.d.ts.map +1 -1
  189. package/common/metadata/duty.resolved.d.ts +4 -0
  190. package/common/metadata/duty.resolved.d.ts.map +1 -0
  191. package/common/metadata/event.metadata.d.ts +451 -0
  192. package/common/metadata/event.metadata.d.ts.map +1 -0
  193. package/common/metadata/front-mcp.metadata.d.ts +1652 -16
  194. package/common/metadata/front-mcp.metadata.d.ts.map +1 -1
  195. package/common/metadata/index.d.ts +4 -0
  196. package/common/metadata/index.d.ts.map +1 -1
  197. package/common/metadata/job.metadata.d.ts +1 -1
  198. package/common/metadata/prompt.metadata.d.ts +1 -1
  199. package/common/metadata/resource.metadata.d.ts +2 -2
  200. package/common/metadata/skill.metadata.d.ts +1 -1
  201. package/common/metadata/tool.metadata.d.ts +1 -1
  202. package/common/metadata/worker.metadata.d.ts +69 -0
  203. package/common/metadata/worker.metadata.d.ts.map +1 -0
  204. package/common/metadata/worker.resolved.d.ts +4 -0
  205. package/common/metadata/worker.resolved.d.ts.map +1 -0
  206. package/common/metadata/workflow.metadata.d.ts +31 -3
  207. package/common/metadata/workflow.metadata.d.ts.map +1 -1
  208. package/common/records/event.record.d.ts +21 -0
  209. package/common/records/event.record.d.ts.map +1 -0
  210. package/common/records/index.d.ts +1 -0
  211. package/common/records/index.d.ts.map +1 -1
  212. package/common/schemas/annotated-class.schema.d.ts +1 -0
  213. package/common/schemas/annotated-class.schema.d.ts.map +1 -1
  214. package/common/tokens/app.tokens.d.ts.map +1 -1
  215. package/common/tokens/event.tokens.d.ts +9 -0
  216. package/common/tokens/event.tokens.d.ts.map +1 -0
  217. package/common/tokens/front-mcp.tokens.d.ts.map +1 -1
  218. package/common/tokens/index.d.ts +1 -0
  219. package/common/tokens/index.d.ts.map +1 -1
  220. package/common/tokens/workflow.tokens.d.ts +1 -0
  221. package/common/tokens/workflow.tokens.d.ts.map +1 -1
  222. package/common/utils/offset-cursor.utils.d.ts +5 -0
  223. package/common/utils/offset-cursor.utils.d.ts.map +1 -0
  224. package/common/utils/principal.utils.d.ts +11 -9
  225. package/common/utils/principal.utils.d.ts.map +1 -1
  226. package/common/utils/time-zone.utils.d.ts +3 -0
  227. package/common/utils/time-zone.utils.d.ts.map +1 -0
  228. package/direct/client.types.d.ts +8 -0
  229. package/direct/client.types.d.ts.map +1 -1
  230. package/direct/create.d.ts.map +1 -1
  231. package/direct/create.types.d.ts +3 -1
  232. package/direct/create.types.d.ts.map +1 -1
  233. package/direct/direct-events-transport.d.ts +20 -0
  234. package/direct/direct-events-transport.d.ts.map +1 -0
  235. package/direct/direct-server.d.ts +3 -0
  236. package/direct/direct-server.d.ts.map +1 -1
  237. package/direct/direct.types.d.ts +6 -0
  238. package/direct/direct.types.d.ts.map +1 -1
  239. package/duty/cron-schedule.d.ts +51 -0
  240. package/duty/cron-schedule.d.ts.map +1 -0
  241. package/duty/describe-thrown.d.ts +3 -0
  242. package/duty/describe-thrown.d.ts.map +1 -0
  243. package/duty/duty.lifecycle.d.ts +33 -4
  244. package/duty/duty.lifecycle.d.ts.map +1 -1
  245. package/duty/duty.runner.d.ts +49 -31
  246. package/duty/duty.runner.d.ts.map +1 -1
  247. package/duty/lazy-lease-store.d.ts +29 -0
  248. package/duty/lazy-lease-store.d.ts.map +1 -0
  249. package/duty/lease-holder.d.ts +73 -0
  250. package/duty/lease-holder.d.ts.map +1 -0
  251. package/duty/lease-store.d.ts +40 -0
  252. package/duty/lease-store.d.ts.map +1 -0
  253. package/elicitation/hooks/elicitation.hooks.d.ts +5 -5
  254. package/elicitation/questions/question-subject.d.ts +8 -3
  255. package/elicitation/questions/question-subject.d.ts.map +1 -1
  256. package/errors/duty.errors.d.ts +10 -0
  257. package/errors/duty.errors.d.ts.map +1 -1
  258. package/errors/event.errors.d.ts +73 -0
  259. package/errors/event.errors.d.ts.map +1 -0
  260. package/errors/index.d.ts +4 -1
  261. package/errors/index.d.ts.map +1 -1
  262. package/errors/worker.errors.d.ts +7 -0
  263. package/errors/worker.errors.d.ts.map +1 -0
  264. package/esm/index.mjs +38 -34
  265. package/event/delivery/event-metrics.d.ts +25 -0
  266. package/event/delivery/event-metrics.d.ts.map +1 -0
  267. package/event/delivery/event-outbox.d.ts +129 -0
  268. package/event/delivery/event-outbox.d.ts.map +1 -0
  269. package/event/event-channel.d.ts +21 -0
  270. package/event/event-channel.d.ts.map +1 -0
  271. package/event/event-dialect.d.ts +20 -0
  272. package/event/event-dialect.d.ts.map +1 -0
  273. package/event/event-gates.d.ts +23 -0
  274. package/event/event-gates.d.ts.map +1 -0
  275. package/event/event-outbound.d.ts +9 -0
  276. package/event/event-outbound.d.ts.map +1 -0
  277. package/event/event-publisher.d.ts +14 -0
  278. package/event/event-publisher.d.ts.map +1 -0
  279. package/event/event-reauthorization.d.ts +35 -0
  280. package/event/event-reauthorization.d.ts.map +1 -0
  281. package/event/event-scope.helper.d.ts +23 -0
  282. package/event/event-scope.helper.d.ts.map +1 -0
  283. package/event/event-subscriber.d.ts +12 -0
  284. package/event/event-subscriber.d.ts.map +1 -0
  285. package/event/event.instance.d.ts +15 -0
  286. package/event/event.instance.d.ts.map +1 -0
  287. package/event/event.registry.d.ts +97 -0
  288. package/event/event.registry.d.ts.map +1 -0
  289. package/event/event.utils.d.ts +6 -0
  290. package/event/event.utils.d.ts.map +1 -0
  291. package/event/flows/event-deliver.flow.d.ts +73 -0
  292. package/event/flows/event-deliver.flow.d.ts.map +1 -0
  293. package/event/flows/event-poll.flow.d.ts +105 -0
  294. package/event/flows/event-poll.flow.d.ts.map +1 -0
  295. package/event/flows/event-publish-http.flow.d.ts +114 -0
  296. package/event/flows/event-publish-http.flow.d.ts.map +1 -0
  297. package/event/flows/event-publish.flow.d.ts +109 -0
  298. package/event/flows/event-publish.flow.d.ts.map +1 -0
  299. package/event/flows/event-stream.flow.d.ts +78 -0
  300. package/event/flows/event-stream.flow.d.ts.map +1 -0
  301. package/event/flows/event-subscribe.flow.d.ts +132 -0
  302. package/event/flows/event-subscribe.flow.d.ts.map +1 -0
  303. package/event/flows/event-unsubscribe.flow.d.ts +71 -0
  304. package/event/flows/event-unsubscribe.flow.d.ts.map +1 -0
  305. package/event/flows/list-events.flow.d.ts +75 -0
  306. package/event/flows/list-events.flow.d.ts.map +1 -0
  307. package/event/index.d.ts +46 -0
  308. package/event/index.d.ts.map +1 -0
  309. package/event/poll/event-buffer.d.ts +54 -0
  310. package/event/poll/event-buffer.d.ts.map +1 -0
  311. package/event/poll/event-poll-leases.d.ts +63 -0
  312. package/event/poll/event-poll-leases.d.ts.map +1 -0
  313. package/event/publish-endpoint/event-publish-endpoint.d.ts +29 -0
  314. package/event/publish-endpoint/event-publish-endpoint.d.ts.map +1 -0
  315. package/event/publish-endpoint/event-publish-idempotency.d.ts +35 -0
  316. package/event/publish-endpoint/event-publish-idempotency.d.ts.map +1 -0
  317. package/event/replay/event-replays.d.ts +116 -0
  318. package/event/replay/event-replays.d.ts.map +1 -0
  319. package/event/stream/event-stream.d.ts +116 -0
  320. package/event/stream/event-stream.d.ts.map +1 -0
  321. package/event/stream/event-streams.d.ts +52 -0
  322. package/event/stream/event-streams.d.ts.map +1 -0
  323. package/event/subscription/event-callback-verifier.d.ts +58 -0
  324. package/event/subscription/event-callback-verifier.d.ts.map +1 -0
  325. package/event/subscription/event-subscription-store.factory.d.ts +31 -0
  326. package/event/subscription/event-subscription-store.factory.d.ts.map +1 -0
  327. package/event/subscription/event-subscription-termination.d.ts +25 -0
  328. package/event/subscription/event-subscription-termination.d.ts.map +1 -0
  329. package/event/subscription/event-subscription.store.d.ts +131 -0
  330. package/event/subscription/event-subscription.store.d.ts.map +1 -0
  331. package/event/subscription/event-subscriptions.d.ts +66 -0
  332. package/event/subscription/event-subscriptions.d.ts.map +1 -0
  333. package/event-client/event-client.errors.d.ts +35 -0
  334. package/event-client/event-client.errors.d.ts.map +1 -0
  335. package/event-client/event-webhook-receiver.d.ts +75 -0
  336. package/event-client/event-webhook-receiver.d.ts.map +1 -0
  337. package/event-client/events-client.d.ts +33 -0
  338. package/event-client/events-client.d.ts.map +1 -0
  339. package/event-client/events-client.types.d.ts +74 -0
  340. package/event-client/events-client.types.d.ts.map +1 -0
  341. package/event-client/index.d.ts +6 -0
  342. package/event-client/index.d.ts.map +1 -0
  343. package/front-mcp/authorities-rules.check.d.ts +5 -0
  344. package/front-mcp/authorities-rules.check.d.ts.map +1 -1
  345. package/front-mcp/front-mcp.d.ts.map +1 -1
  346. package/index.d.ts +70 -0
  347. package/index.d.ts.map +1 -1
  348. package/index.js +46 -42
  349. package/job/execution/job-execution.manager.d.ts +7 -0
  350. package/job/execution/job-execution.manager.d.ts.map +1 -1
  351. package/job/job-scope.helper.d.ts.map +1 -1
  352. package/job/store/job-state.interface.d.ts +2 -0
  353. package/job/store/job-state.interface.d.ts.map +1 -1
  354. package/job/store/memory-job-state.store.d.ts +1 -0
  355. package/job/store/memory-job-state.store.d.ts.map +1 -1
  356. package/job/store/redis-job-state.store.d.ts +3 -0
  357. package/job/store/redis-job-state.store.d.ts.map +1 -1
  358. package/job/store/storage-job-state.store.d.ts +1 -0
  359. package/job/store/storage-job-state.store.d.ts.map +1 -1
  360. package/notification/index.d.ts +1 -1
  361. package/notification/index.d.ts.map +1 -1
  362. package/notification/notification.service.d.ts +31 -2
  363. package/notification/notification.service.d.ts.map +1 -1
  364. package/package.json +11 -10
  365. package/provider/create-container.d.ts +14 -4
  366. package/provider/create-container.d.ts.map +1 -1
  367. package/provider/provider.lifecycle.d.ts +11 -1
  368. package/provider/provider.lifecycle.d.ts.map +1 -1
  369. package/provider/provider.registry.d.ts +18 -4
  370. package/provider/provider.registry.d.ts.map +1 -1
  371. package/scope/event-publisher.providers.d.ts +17 -0
  372. package/scope/event-publisher.providers.d.ts.map +1 -0
  373. package/scope/scope.instance.d.ts +6 -1
  374. package/scope/scope.instance.d.ts.map +1 -1
  375. package/shared/shared-attach.d.ts +3 -1
  376. package/shared/shared-attach.d.ts.map +1 -1
  377. package/shared/shared-server.lifecycle.d.ts +14 -5
  378. package/shared/shared-server.lifecycle.d.ts.map +1 -1
  379. package/skill/skill-instructions.helper.d.ts +10 -4
  380. package/skill/skill-instructions.helper.d.ts.map +1 -1
  381. package/subsystems.d.ts +1 -0
  382. package/subsystems.d.ts.map +1 -1
  383. package/tool/flows/tools-list.flow.d.ts +0 -11
  384. package/tool/flows/tools-list.flow.d.ts.map +1 -1
  385. package/transport/adapters/transport.local.adapter.d.ts.map +1 -1
  386. package/transport/build-scoped-server-options.d.ts.map +1 -1
  387. package/transport/flows/handle.mcp-20260728.flow.d.ts +8 -2
  388. package/transport/flows/handle.mcp-20260728.flow.d.ts.map +1 -1
  389. package/transport/in-memory-server.d.ts.map +1 -1
  390. package/transport/mcp-20260728/discover.d.ts.map +1 -1
  391. package/transport/mcp-20260728/event-stream-response.d.ts +12 -0
  392. package/transport/mcp-20260728/event-stream-response.d.ts.map +1 -0
  393. package/transport/mcp-20260728/index.d.ts +1 -0
  394. package/transport/mcp-20260728/index.d.ts.map +1 -1
  395. package/transport/mcp-20260728/protocol-20260728.constants.d.ts.map +1 -1
  396. package/transport/mcp-20260728/request-validation.d.ts +2 -0
  397. package/transport/mcp-20260728/request-validation.d.ts.map +1 -1
  398. package/transport/mcp-handlers/events-list-request.handler.d.ts +5 -0
  399. package/transport/mcp-handlers/events-list-request.handler.d.ts.map +1 -0
  400. package/transport/mcp-handlers/events-poll-request.handler.d.ts +5 -0
  401. package/transport/mcp-handlers/events-poll-request.handler.d.ts.map +1 -0
  402. package/transport/mcp-handlers/events-stream-request.handler.d.ts +8 -0
  403. package/transport/mcp-handlers/events-stream-request.handler.d.ts.map +1 -0
  404. package/transport/mcp-handlers/events-subscribe-request.handler.d.ts +5 -0
  405. package/transport/mcp-handlers/events-subscribe-request.handler.d.ts.map +1 -0
  406. package/transport/mcp-handlers/events-unsubscribe-request.handler.d.ts +5 -0
  407. package/transport/mcp-handlers/events-unsubscribe-request.handler.d.ts.map +1 -0
  408. package/transport/mcp-handlers/index.d.ts +162 -3
  409. package/transport/mcp-handlers/index.d.ts.map +1 -1
  410. package/transport/mcp-handlers/initialize-request.handler.d.ts.map +1 -1
  411. package/transport/stdio-revision-router.d.ts +2 -0
  412. package/transport/stdio-revision-router.d.ts.map +1 -1
  413. package/worker/worker.lifecycle.d.ts +63 -0
  414. package/worker/worker.lifecycle.d.ts.map +1 -0
  415. package/worker/worker.supervisor.d.ts +62 -0
  416. package/worker/worker.supervisor.d.ts.map +1 -0
  417. package/workflow/tools/register-workflow.tool.d.ts +2 -1
  418. package/workflow/tools/register-workflow.tool.d.ts.map +1 -1
  419. package/workflow/trigger/workflow-events.d.ts.map +1 -1
  420. package/workflow/trigger/workflow-schedules.d.ts +76 -0
  421. package/workflow/trigger/workflow-schedules.d.ts.map +1 -0
  422. package/workflow/trigger/workflow-triggers.d.ts +16 -1
  423. package/workflow/trigger/workflow-triggers.d.ts.map +1 -1
@@ -0,0 +1,116 @@
1
+ import { type EventError } from '@frontmcp/protocol';
2
+ import { type EventContext, type EventEntry, type EventSubscriptionRef, type FrontMcpLogger } from '../../common';
3
+ import { type EventReader } from '../event-gates';
4
+ import { type EventReauthorization } from '../event-reauthorization';
5
+ import { type BufferedEvent, type EventBuffer } from '../poll/event-buffer';
6
+ /** A notification of one stream, as it is sent to the client. */
7
+ export interface EventStreamNotification {
8
+ method: string;
9
+ params: Record<string, unknown>;
10
+ }
11
+ export interface EventStreamOptions {
12
+ /** The JSON-RPC id of the `events/stream` request: every notification carries it. */
13
+ requestId: string | number;
14
+ event: EventEntry;
15
+ context: EventContext;
16
+ reader: EventReader;
17
+ subscription: EventSubscriptionRef;
18
+ arguments: Record<string, unknown>;
19
+ /** The cursor of the request; `null` or none starts from now. */
20
+ cursor: string | null | undefined;
21
+ maxAgeMs: number | undefined;
22
+ /** The published occurrences a cursor replays from; none for an event with `check()`. */
23
+ buffer: EventBuffer | undefined;
24
+ /** `events.push.heartbeatMs`. */
25
+ heartbeatMs: number;
26
+ /** How often `check()` is called when it names no interval of its own. */
27
+ checkIntervalMs: number;
28
+ /** How many events one `check()` is asked for. */
29
+ checkMaxEvents: number;
30
+ /** How often the reader's access is checked again. */
31
+ reauthorizeEveryMs: number;
32
+ /** Check the reader again: its event's `authorities`, then its `authorize()`. */
33
+ reauthorize: () => Promise<EventReauthorization>;
34
+ /** The error a stream whose reader lost access ends with. */
35
+ accessRevoked: EventError;
36
+ /** Ends the stream when the client cancels the request or disconnects. */
37
+ signal: AbortSignal | undefined;
38
+ logger: FrontMcpLogger;
39
+ }
40
+ /** Notifications waiting for a slow client; past it the stream reports a gap instead of growing. */
41
+ export declare const MAX_QUEUED_NOTIFICATIONS = 1000;
42
+ /**
43
+ * One open `events/stream` request: `active` first, then an `event` for each occurrence its reader may receive, a
44
+ * `heartbeat` while it is quiet, and `terminated` when the server ends it. It is consumed as an async iterable.
45
+ */
46
+ export declare class EventStream implements AsyncIterable<EventStreamNotification> {
47
+ private readonly options;
48
+ private readonly queue;
49
+ private readonly closeListeners;
50
+ private wake?;
51
+ private closed;
52
+ private cursor;
53
+ private lastAuthorizedAt;
54
+ /** The last check of the reader's access could not be made: nothing is delivered until one is. */
55
+ private accessUnchecked;
56
+ /** Published events were held back while the access was unchecked. */
57
+ private withheld;
58
+ private heartbeatTimer?;
59
+ private checkTimer?;
60
+ /** Offers are delivered one after the other, in the order they came; behind the replay while the stream opens. */
61
+ private delivering;
62
+ private releaseDelivery;
63
+ /** The buffer sequence of the last occurrence taken: one replayed and offered live too is delivered once. */
64
+ private lastSequence;
65
+ /** Takes the request's options, holds delivery behind a buffer replay, and closes when `signal` aborts. */
66
+ constructor(options: EventStreamOptions);
67
+ /** The subscription this stream stands for. */
68
+ get subscription(): EventSubscriptionRef;
69
+ /** The name of the event the stream carries. */
70
+ get eventName(): string;
71
+ /** The owner's key; undefined for an anonymous reader. */
72
+ get principalKey(): string | undefined;
73
+ /** Whether the stream has ended. */
74
+ get isClosed(): boolean;
75
+ /** Confirm the stream, replay what the cursor asks for, and start the heartbeat and, with `check()`, its loop. */
76
+ open(): Promise<void>;
77
+ /** Deliver a published occurrence, when it is for this stream's reader and arguments, after those offered before. */
78
+ offer(buffered: BufferedEvent): Promise<void>;
79
+ /** End the stream on the server's side: the client gets `terminated` with the reason, then the final frame. */
80
+ terminate(error: EventError): void;
81
+ /** End the stream: stop its timers and let the consumer drain what is queued. */
82
+ close(): void;
83
+ /** Call `listener` once, when the stream ends. */
84
+ onClose(listener: () => void): void;
85
+ /** The notifications of the stream, in order, until it ends. A reader that stops reading ends the stream. */
86
+ [Symbol.asyncIterator](): AsyncIterator<EventStreamNotification>;
87
+ /** The next queued notification, waiting for one while the stream is open. */
88
+ private nextNotification;
89
+ /** Start a stream of published events: from now, or replaying the buffer after the request's cursor. */
90
+ private openOnBuffer;
91
+ /** Deliver one occurrence not taken yet; the cursor moves only on a stream of published events. */
92
+ private deliver;
93
+ /** Start a stream of an event with `check()`: ask it for the position or the backlog, then keep asking. */
94
+ private openOnCheck;
95
+ /** Call the event's `check()` from the stream's cursor; a failure is reported on the stream, which stays open. */
96
+ private check;
97
+ /** Call `check()` again after its interval, for as long as the stream is open. */
98
+ private scheduleCheck;
99
+ /** One turn of the `check()` loop: deliver what it found, report a gap, and schedule the next turn. */
100
+ private runCheck;
101
+ /** Deliver the items a `check()` returned, each validated against the payload schema. */
102
+ private pushChecked;
103
+ /** A published occurrence as this stream's reader receives it; undefined when it is not for it. */
104
+ private occurrenceFor;
105
+ /** The heartbeat: the cursor to persist while nothing happens, and the moment access is checked again. */
106
+ private beat;
107
+ /** Deliver again after a check that could not be made; held-back events are reported as a gap from the cursor. */
108
+ private resumeAfterCheck;
109
+ /** Queue the confirmation of the stream, or of a gap in it, with the cursor delivery continues from. */
110
+ private pushActive;
111
+ /** Queue one occurrence, with the cursor after it. */
112
+ private pushEvent;
113
+ /** Queue a notification tagged with the stream's id; a queue a slow client let fill up is replaced by a gap. */
114
+ private push;
115
+ }
116
+ //# sourceMappingURL=event-stream.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"event-stream.d.ts","sourceRoot":"","sources":["../../../src/event/stream/event-stream.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,UAAU,EAEhB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EAEL,KAAK,YAAY,EACjB,KAAK,UAAU,EACf,KAAK,oBAAoB,EACzB,KAAK,cAAc,EACpB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAElD,OAAO,EAAE,KAAK,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAErE,OAAO,EAAE,KAAK,aAAa,EAAE,KAAK,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAE5E,iEAAiE;AACjE,MAAM,WAAW,uBAAuB;IACtC,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACjC;AAED,MAAM,WAAW,kBAAkB;IACjC,qFAAqF;IACrF,SAAS,EAAE,MAAM,GAAG,MAAM,CAAC;IAC3B,KAAK,EAAE,UAAU,CAAC;IAClB,OAAO,EAAE,YAAY,CAAC;IACtB,MAAM,EAAE,WAAW,CAAC;IACpB,YAAY,EAAE,oBAAoB,CAAC;IACnC,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACnC,iEAAiE;IACjE,MAAM,EAAE,MAA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,kBAAkB;IASxD,+CAA+C;IAC/C,IAAI,YAAY,IAAI,oBAAoB,CAEvC;IAED,gDAAgD;IAChD,IAAI,SAAS,IAAI,MAAM,CAEtB;IAED,0DAA0D;IAC1D,IAAI,YAAY,IAAI,MAAM,GAAG,SAAS,CAErC;IAED,oCAAoC;IACpC,IAAI,QAAQ,IAAI,OAAO,CAEtB;IAED,kHAAkH;IAC5G,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAa3B,qHAAqH;IACrH,KAAK,CAAC,QAAQ,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC;IAS7C,+GAA+G;IAC/G,SAAS,CAAC,KAAK,EAAE,UAAU,GAAG,IAAI;IAMlC,iFAAiF;IACjF,KAAK,IAAI,IAAI;IAUb,kDAAkD;IAClD,OAAO,CAAC,QAAQ,EAAE,MAAM,IAAI,GAAG,IAAI;IAKnC,6GAA6G;IAC7G,CAAC,MAAM,CAAC,aAAa,CAAC,IAAI,aAAa,CAAC,uBAAuB,CAAC;IAUhE,8EAA8E;YAChE,gBAAgB;IAU9B,wGAAwG;YAC1F,YAAY;IAwB1B,mGAAmG;YACrF,OAAO;IAcrB,2GAA2G;YAC7F,WAAW;IAOzB,kHAAkH;YACpG,KAAK;IAiBnB,kFAAkF;IAClF,OAAO,CAAC,aAAa;IAMrB,uGAAuG;YACzF,QAAQ;IAWtB,yFAAyF;IACzF,OAAO,CAAC,WAAW;IAgBnB,mGAAmG;YACrF,aAAa;IAiB3B,0GAA0G;YAC5F,IAAI;IAsBlB,kHAAkH;IAClH,OAAO,CAAC,gBAAgB;IAOxB,wGAAwG;IACxG,OAAO,CAAC,UAAU;IAIlB,sDAAsD;IACtD,OAAO,CAAC,SAAS;IAIjB,gHAAgH;IAChH,OAAO,CAAC,IAAI;CAab"}
@@ -0,0 +1,52 @@
1
+ import { type NamespacedStorage } from '@frontmcp/utils';
2
+ import { type FrontMcpLogger } from '../../common';
3
+ import { type BufferedEvent, type EventBuffer } from '../poll/event-buffer';
4
+ import { type EventStream } from './event-stream';
5
+ export interface EventStreamsOptions {
6
+ buffer: EventBuffer;
7
+ /** `events.subscriptions.maxPerPrincipal`: how many streams one caller may hold open. */
8
+ maxPerPrincipal: number;
9
+ /** A storage with pub/sub carries published occurrences to the streams other processes hold. */
10
+ storage?: NamespacedStorage;
11
+ logger: FrontMcpLogger;
12
+ }
13
+ /** The pub/sub channel published occurrences are relayed on. */
14
+ export declare const EVENT_RELAY_CHANNEL = "occurrences";
15
+ /** How many streams one process holds open, for all callers together. */
16
+ export declare const MAX_OPEN_STREAMS = 10000;
17
+ /** The open `events/stream` requests of a server: what is published reaches each stream of its event. */
18
+ export declare class EventStreams {
19
+ private readonly options;
20
+ /** The streams that receive what is published, by event name. */
21
+ private readonly streams;
22
+ /** Every stream counted against the limits, including one still opening. */
23
+ private readonly held;
24
+ private readonly nodeId;
25
+ private readonly logger;
26
+ private stopRelay?;
27
+ /** Takes the buffer, the per-caller limit and the relay storage; draws the id this process relays as. */
28
+ constructor(options: EventStreamsOptions);
29
+ /** Whether occurrences reach the streams of other processes. */
30
+ get isRelayed(): boolean;
31
+ /** How many streams are open or opening. */
32
+ get size(): number;
33
+ /** Listen for the occurrences other processes publish, when the storage can carry them. */
34
+ start(): Promise<void>;
35
+ /** Stop listening and end every open stream. */
36
+ stop(): Promise<void>;
37
+ /** Whether one more stream exceeds what one owner (all anonymous readers are one), or the process, may hold. */
38
+ isFull(principalKey: string | undefined): boolean;
39
+ /** Count a stream against the limits before it opens; false, and nothing counted, when it would exceed one. */
40
+ reserve(stream: EventStream): boolean;
41
+ /** Deliver what is published to a stream, for as long as it is open. */
42
+ add(stream: EventStream): void;
43
+ /** Count a stream until it closes. */
44
+ private hold;
45
+ /** Deliver an occurrence this process published to its streams, and relay it to the other processes. */
46
+ publish(buffered: BufferedEvent): Promise<void>;
47
+ /** Offer an occurrence to every open stream of its event. */
48
+ private deliver;
49
+ /** Take an occurrence another process published: keep it in this process's buffer and deliver it here. */
50
+ private receive;
51
+ }
52
+ //# sourceMappingURL=event-streams.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"event-streams.d.ts","sourceRoot":"","sources":["../../../src/event/stream/event-streams.ts"],"names":[],"mappings":"AACA,OAAO,EAAc,KAAK,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAErE,OAAO,EAAsB,KAAK,cAAc,EAAE,MAAM,cAAc,CAAC;AACvE,OAAO,EAAE,KAAK,aAAa,EAAE,KAAK,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAC5E,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAElD,MAAM,WAAW,mBAAmB;IAClC,MAAM,EAAE,WAAW,CAAC;IACpB,yFAAyF;IACzF,eAAe,EAAE,MAAM,CAAC;IACxB,gGAAgG;IAChG,OAAO,CAAC,EAAE,iBAAiB,CAAC;IAC5B,MAAM,EAAE,cAAc,CAAC;CACxB;AAUD,gEAAgE;AAChE,eAAO,MAAM,mBAAmB,gBAAgB,CAAC;AACjD,yEAAyE;AACzE,eAAO,MAAM,gBAAgB,QAAS,CAAC;AAEvC,yGAAyG;AACzG,qBAAa,YAAY;IAUX,OAAO,CAAC,QAAQ,CAAC,OAAO;IATpC,iEAAiE;IACjE,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAuC;IAC/D,4EAA4E;IAC5E,OAAO,CAAC,QAAQ,CAAC,IAAI,CAA0B;IAC/C,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAChC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAiB;IACxC,OAAO,CAAC,SAAS,CAAC,CAA6B;IAE/C,yGAAyG;gBAC5E,OAAO,EAAE,mBAAmB;IAKzD,gEAAgE;IAChE,IAAI,SAAS,IAAI,OAAO,CAEvB;IAED,4CAA4C;IAC5C,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED,2FAA2F;IACrF,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAM5B,gDAAgD;IAC1C,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAQ3B,gHAAgH;IAChH,MAAM,CAAC,YAAY,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO;IASjD,+GAA+G;IAC/G,OAAO,CAAC,MAAM,EAAE,WAAW,GAAG,OAAO;IAOrC,wEAAwE;IACxE,GAAG,CAAC,MAAM,EAAE,WAAW,GAAG,IAAI;IAQ9B,sCAAsC;IACtC,OAAO,CAAC,IAAI;IASZ,wGAAwG;IAClG,OAAO,CAAC,QAAQ,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC;IAarD,6DAA6D;YAC/C,OAAO;IAMrB,0GAA0G;IAC1G,OAAO,CAAC,OAAO;CAMhB"}
@@ -0,0 +1,58 @@
1
+ import { type EventDeliveryErrorCategory } from '@frontmcp/protocol';
2
+ import { type OutboundRequest, type OutboundResult } from '@frontmcp/utils';
3
+ export interface EventCallbackVerifierOptions {
4
+ /** `events.webhook.allowedCallbacks`: URL prefixes accepted without a request. */
5
+ allowedCallbacks: readonly string[];
6
+ /** `events.webhook.unsafeAllowLocalCallbacks`. */
7
+ allowLocal: boolean;
8
+ /** How long a verified `(principal, url)` pair stays verified. */
9
+ cacheTtlMs: number;
10
+ timeoutMs: number;
11
+ /** `events.webhook.verification.maxAttemptsPerHost`. @default VERIFICATION_ATTEMPTS_PER_HOST */
12
+ maxAttemptsPerHost?: number;
13
+ /** Sends a request: the hardened fetch, unless a test replaces it. */
14
+ send?: (request: OutboundRequest) => Promise<OutboundResult>;
15
+ }
16
+ export interface EventCallbackVerificationRequest {
17
+ principalKey: string;
18
+ url: string;
19
+ secret: string;
20
+ subscriptionId: string;
21
+ /** When the stored subscription was last verified, when there is one. */
22
+ verifiedAt?: number | null;
23
+ }
24
+ export type EventCallbackVerification = {
25
+ outcome: 'verified';
26
+ verifiedAt: number;
27
+ } | {
28
+ outcome: 'failed';
29
+ reason: EventDeliveryErrorCategory;
30
+ } | {
31
+ outcome: 'limited';
32
+ max: number;
33
+ };
34
+ /** Verification requests one destination host may receive in each window, unless configured. */
35
+ export declare const VERIFICATION_ATTEMPTS_PER_HOST = 10;
36
+ /**
37
+ * Proves a callback accepts MCP deliveries before a subscription is activated: a configured prefix, a fresh earlier
38
+ * proof for the same owner and URL, the receiver's well-known document, or a signed challenge it must echo.
39
+ */
40
+ export declare class EventCallbackVerifier {
41
+ private readonly options;
42
+ private readonly verifiedPairs;
43
+ private readonly receiversByOrigin;
44
+ private readonly attemptsByHost;
45
+ private readonly send;
46
+ private readonly maxAttemptsPerHost;
47
+ /** Takes the allowed prefixes, cache lifetime, timeout, attempt limit and sender (the hardened request by default). */
48
+ constructor(options: EventCallbackVerifierOptions);
49
+ /** Verify the callback of a subscription, sending at most one well-known request and one challenge. */
50
+ verify(request: EventCallbackVerificationRequest): Promise<EventCallbackVerification>;
51
+ /** Count a verification attempt against its destination host; false once the host's window is full. */
52
+ private takeAttempt;
53
+ /** Whether the callback's origin publishes a well-known document whose path prefixes cover the callback. */
54
+ private isDeclaredReceiver;
55
+ /** Send the signed verification envelope; the failure category, or undefined when the nonce came back. */
56
+ private challenge;
57
+ }
58
+ //# sourceMappingURL=event-callback-verifier.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"event-callback-verifier.d.ts","sourceRoot":"","sources":["../../../src/event/subscription/event-callback-verifier.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,0BAA0B,EAChC,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAUL,KAAK,eAAe,EACpB,KAAK,cAAc,EACpB,MAAM,iBAAiB,CAAC;AAIzB,MAAM,WAAW,4BAA4B;IAC3C,kFAAkF;IAClF,gBAAgB,EAAE,SAAS,MAAM,EAAE,CAAC;IACpC,kDAAkD;IAClD,UAAU,EAAE,OAAO,CAAC;IACpB,kEAAkE;IAClE,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,gGAAgG;IAChG,kBAAkB,CAAC,EAAE,MAAM,CA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} from '@frontmcp/utils';
2
+ import { type FrontMcpLogger, type RedisOptions } from '../../common';
3
+ import { type EventSubscriptionStore } from './event-subscription.store';
4
+ export type EventSubscriptionStoreType = 'memory' | 'redis' | 'sqlite';
5
+ export interface EventSubscriptionStoreOptions {
6
+ /** `events.store.redis`. */
7
+ redis?: RedisOptions;
8
+ /** `events.store.sqlite`. */
9
+ sqlite?: SqliteAdapterOptions;
10
+ /** @default 'mcp:events:' */
11
+ keyPrefix?: string;
12
+ /** Encrypts stored subscriptions. By default `MCP_EVENTS_SECRET`, else `MCP_SESSION_SECRET`, else `MCP_SERVER_SECRET`. */
13
+ secret?: string;
14
+ logger?: FrontMcpLogger;
15
+ }
16
+ export interface EventSubscriptionStoreResult {
17
+ store: EventSubscriptionStore;
18
+ type: EventSubscriptionStoreType;
19
+ /** Whether subscriptions outlive the process: Redis and SQLite do, memory does not. */
20
+ durable: boolean;
21
+ encrypted: boolean;
22
+ /** The storage the store owns; the outbox keeps its records in it too. */
23
+ storage: RootStorage;
24
+ /** The secret records are encrypted with, for the outbox to encrypt its own. Never log it. */
25
+ secret?: string;
26
+ }
27
+ /** Open the storage `events.store` names without a subscription store on it, for a server that keeps none. */
28
+ export declare function openEventStorage(options?: Pick<EventSubscriptionStoreOptions, 'redis' | 'sqlite' | 'keyPrefix'>): Promise<RootStorage>;
29
+ /** Open the subscription store: memory by default, `events.store.redis` or `events.store.sqlite` when configured. */
30
+ export declare function createEventSubscriptionStore(options?: EventSubscriptionStoreOptions): Promise<EventSubscriptionStoreResult>;
31
+ //# sourceMappingURL=event-subscription-store.factory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"event-subscription-store.factory.d.ts","sourceRoot":"","sources":["../../../src/event/subscription/event-subscription-store.factory.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,WAAW,EAChB,KAAK,oBAAoB,EAE1B,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAmB,KAAK,cAAc,EAAE,KAAK,YAAY,EAAE,MAAM,cAAc,CAAC;AAEvF,OAAO,EAAiC,KAAK,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AAExG,MAAM,MAAM,0BAA0B,GAAG,QAAQ,GAAG,OAAO,GAAG,QAAQ,CAAC;AAEvE,MAAM,WAAW,6BAA6B;IAC5C,4BAA4B;IAC5B,KAAK,CAAC,EAAE,YAAY,CAAC;IACrB,6BAA6B;IAC7B,MAAM,CAAC,EAAE,oBAAoB,CAAC;IAC9B,6BAA6B;IAC7B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,0HAA0H;IAC1H,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,cAAc,CAAC;CACzB;AAED,MAAM,WAAW,4BAA4B;IAC3C,KAAK,EAAE,sBAAsB,CAAC;IAC9B,IAAI,EAAE,0BAA0B,CAAC;IACjC,uFAAuF;IACvF,OAAO,EAAE,OAAO,CAAC;IACjB,SAAS,EAAE,OAAO,CAAC;IACnB,0EAA0E;IAC1E,OAAO,EAAE,WAAW,CAAC;IACrB,8FAA8F;IAC9F,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAgCD,8GAA8G;AAC9G,wBAAgB,gBAAgB,CAC9B,OAAO,GAAE,IAAI,CAAC,6BAA6B,EAAE,OAAO,GAAG,QAAQ,GAAG,WAAW,CAAM,GAClF,OAAO,CAAC,WAAW,CAAC,CAEtB;AAED,qHAAqH;AACrH,wBAAsB,4BAA4B,CAChD,OAAO,GAAE,6BAAkC,GAC1C,OAAO,CAAC,4BAA4B,CAAC,CAuBvC"}
@@ -0,0 +1,25 @@
1
+ import { type FrontMcpLogger } from '../../common';
2
+ import { type EventMetrics } from '../delivery/event-metrics';
3
+ import { type EventOutbox } from '../delivery/event-outbox';
4
+ import { type EventDialect } from '../event-dialect';
5
+ import { type EventSubscriptionRecord } from './event-subscription.store';
6
+ import { type EventSubscriptions } from './event-subscriptions';
7
+ /** The error a terminated subscription's callback is told, in the `terminated` envelope. */
8
+ export interface EventTerminationError {
9
+ code: number;
10
+ message: string;
11
+ data: Record<string, unknown>;
12
+ }
13
+ export interface TerminateEventSubscriptionArgs {
14
+ subscriptions: EventSubscriptions | undefined;
15
+ outbox: Pick<EventOutbox, 'enqueue'> | undefined;
16
+ metrics: EventMetrics | undefined;
17
+ logger: FrontMcpLogger;
18
+ subscription: EventSubscriptionRecord;
19
+ error: EventTerminationError;
20
+ }
21
+ /** The error of a subscription whose owner was refused when checked again, in the codes of its dialect. */
22
+ export declare function accessRevokedError(dialect: EventDialect): EventTerminationError;
23
+ /** End a subscription the server no longer serves: remove it, tell its event, and tell its callback when the dialect does. */
24
+ export declare function terminateEventSubscription(args: TerminateEventSubscriptionArgs): Promise<void>;
25
+ //# sourceMappingURL=event-subscription-termination.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"event-subscription-termination.d.ts","sourceRoot":"","sources":["../../../src/event/subscription/event-subscription-termination.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,cAAc,CAAC;AACnD,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,EAAkB,KAAK,YAAY,EAAE,MAAM,kBAAkB,CAAC;AACrE,OAAO,EAAE,KAAK,uBAAuB,EAAE,MAAM,4BAA4B,CAAC;AAC1E,OAAO,EAAE,KAAK,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAEhE,4FAA4F;AAC5F,MAAM,WAAW,qBAAqB;IACpC,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAC/B;AAED,MAAM,WAAW,8BAA8B;IAC7C,aAAa,EAAE,kBAAkB,GAAG,SAAS,CAAC;IAC9C,MAAM,EAAE,IAAI,CAAC,WAAW,EAAE,SAAS,CAAC,GAAG,SAAS,CAAC;IACjD,OAAO,EAAE,YAAY,GAAG,SAAS,CAAC;IAClC,MAAM,EAAE,cAAc,CAAC;IACvB,YAAY,EAAE,uBAAuB,CAAC;IACtC,KAAK,EAAE,qBAAqB,CAAC;CAC9B;AAED,2GAA2G;AAC3G,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,YAAY,GAAG,qBAAqB,CAM/E;AAED,8HAA8H;AAC9H,wBAAsB,0BAA0B,CAAC,IAAI,EAAE,8BAA8B,GAAG,OAAO,CAAC,IAAI,CAAC,CAoBpG"}
@@ -0,0 +1,131 @@
1
+ import type { EventDeliveryErrorCategory } from '@frontmcp/protocol';
2
+ import { type NamespacedStorage } from '@frontmcp/utils';
3
+ import { type EventSubscriber } from '../../common';
4
+ import { type EventDialect } from '../event-dialect';
5
+ /** Where a webhook subscription is delivered, and the secrets its deliveries are signed with. */
6
+ export interface EventWebhookDelivery {
7
+ mode: 'webhook';
8
+ url: string;
9
+ secret: string;
10
+ /** The secret a refresh replaced: deliveries are also signed with it until `previousSecretUntil`. */
11
+ previousSecret?: string;
12
+ previousSecretUntil?: number;
13
+ }
14
+ export interface EventSubscriptionStatus {
15
+ lastDeliveryAt?: number;
16
+ lastError?: EventDeliveryErrorCategory;
17
+ failedSince?: number;
18
+ /** Failed delivery attempts in a row; a delivery the callback acknowledges ends the count. */
19
+ failures?: number;
20
+ /** When delivery was suspended. */
21
+ suspendedSince?: number;
22
+ }
23
+ /** The deliveries one `check()` produced, and the position after them. */
24
+ export interface EventReplayBatch {
25
+ cursor: string | null;
26
+ deliveryIds: string[];
27
+ }
28
+ /** Where the webhook subscription of an event with `check()` stands in its upstream. */
29
+ export interface EventReplayState {
30
+ /** The position the next `check()` reads from. */
31
+ cursor: string | null;
32
+ /** The position a client may persist: everything at or before it was acknowledged or abandoned. */
33
+ watermark: string | null;
34
+ /** The batches whose deliveries are not all done, oldest first. */
35
+ pending: EventReplayBatch[];
36
+ /** A gap the client has not been told about yet: its next refresh answers `truncated`. */
37
+ truncated?: boolean;
38
+ /** How many of the items `check()` returns from `cursor` are already queued: a turn that failed part-way. */
39
+ queuedAtCursor?: number;
40
+ }
41
+ export interface EventSubscriptionRecord {
42
+ /** `sub_` and 32 hex characters, derived from the owner, the callback, the event and its arguments. */
43
+ id: string;
44
+ principalKey: string;
45
+ /** The owner as the server knew them at the last `events/subscribe`. */
46
+ subscriber: EventSubscriber;
47
+ eventName: string;
48
+ arguments: Record<string, unknown>;
49
+ /** The canonical JSON of `arguments`. */
50
+ argumentsKey: string;
51
+ delivery: EventWebhookDelivery;
52
+ dialect: EventDialect;
53
+ createdAt: number;
54
+ updatedAt: number;
55
+ /** When the subscription ends, in Unix milliseconds; `null` for one that never expires. */
56
+ expiresAt: number | null;
57
+ verifiedAt: number | null;
58
+ lastAuthorizedAt: number;
59
+ /** `false` while delivery is suspended; the next `events/subscribe` sets it again. */
60
+ active: boolean;
61
+ status: EventSubscriptionStatus;
62
+ /** Set for an event with `check()`: the position of the loop that feeds this subscription. */
63
+ replay?: EventReplayState;
64
+ }
65
+ /** What `update` may change; identity and lifetime change through `upsert` alone. */
66
+ export type EventSubscriptionChanges = Partial<Pick<EventSubscriptionRecord, 'active' | 'status' | 'verifiedAt' | 'lastAuthorizedAt' | 'subscriber' | 'delivery' | 'replay'>>;
67
+ export type EventSubscriptionPatch = EventSubscriptionChanges | ((current: EventSubscriptionRecord) => EventSubscriptionChanges);
68
+ /** Stored subscriptions, shared by every node of a server. Reads leave out a subscription whose lifetime is over. */
69
+ export interface EventSubscriptionStore {
70
+ /** Create the subscription, or replace the one with the same id. */
71
+ upsert(record: EventSubscriptionRecord): Promise<void>;
72
+ get(id: string): Promise<EventSubscriptionRecord | undefined>;
73
+ /** Remove a subscription, expired or not; resolves to it for the one caller that removed it. */
74
+ delete(id: string): Promise<EventSubscriptionRecord | undefined>;
75
+ /** Remove a subscription whose lifetime ended at or before `now`; resolves to it for the caller that removed it. */
76
+ deleteExpired(id: string, now: number): Promise<EventSubscriptionRecord | undefined>;
77
+ listByEvent(eventName: string): Promise<EventSubscriptionRecord[]>;
78
+ countByPrincipal(principalKey: string): Promise<number>;
79
+ /** Change a subscription in place; undefined when it is gone. */
80
+ update(id: string, patch: EventSubscriptionPatch): Promise<EventSubscriptionRecord | undefined>;
81
+ /** The subscriptions whose lifetime ended at or before `now` and that are still stored. */
82
+ listExpired(now: number): Promise<EventSubscriptionRecord[]>;
83
+ close(): Promise<void>;
84
+ }
85
+ export interface StorageEventSubscriptionStoreOptions {
86
+ /** Owned by the store: it is disconnected on `close()`. */
87
+ storage: NamespacedStorage;
88
+ /** Encrypts each record and keys the indexes by HMACs. Required for a store that outlives the process. */
89
+ secret?: string;
90
+ }
91
+ /** Subscriptions in a storage with atomic compare-and-set (memory, Redis, SQLite), indexed by event and by owner. */
92
+ export declare class StorageEventSubscriptionStore implements EventSubscriptionStore {
93
+ private readonly options;
94
+ /** Takes the storage it owns and the secret, if any, that encrypts the records and keys the indexes. */
95
+ constructor(options: StorageEventSubscriptionStoreOptions);
96
+ /** Write the record and its index keys, with a storage TTL that outlasts a finite lifetime. */
97
+ upsert(record: EventSubscriptionRecord): Promise<void>;
98
+ /** The live subscription of an id. */
99
+ get(id: string): Promise<EventSubscriptionRecord | undefined>;
100
+ /** Remove a subscription, expired or not. */
101
+ delete(id: string): Promise<EventSubscriptionRecord | undefined>;
102
+ /** Remove a subscription only when its lifetime is over. */
103
+ deleteExpired(id: string, now: number): Promise<EventSubscriptionRecord | undefined>;
104
+ /** The live subscriptions of an event, through its index. */
105
+ listByEvent(eventName: string): Promise<EventSubscriptionRecord[]>;
106
+ /** How many live subscriptions an owner holds, through its index. */
107
+ countByPrincipal(principalKey: string): Promise<number>;
108
+ /** Apply a patch with compare-and-set, on top of whatever another writer stored first. */
109
+ update(id: string, patch: EventSubscriptionPatch): Promise<EventSubscriptionRecord | undefined>;
110
+ /** The expired subscriptions the expiry index names, dropping index keys that no longer apply. */
111
+ listExpired(now: number): Promise<EventSubscriptionRecord[]>;
112
+ /** Disconnect the storage. */
113
+ close(): Promise<void>;
114
+ /** Remove the stored subscription when `shouldRemove` accepts it, once across every node. */
115
+ private remove;
116
+ /** The live subscriptions an index pattern names. */
117
+ private liveRecordsOf;
118
+ /** The stored subscription, expired or not, with the exact value a compare-and-set needs. */
119
+ private read;
120
+ /** The record as stored: encrypted under a key of its own when the store has a secret. */
121
+ private encode;
122
+ /** The record a stored value holds; undefined for one that cannot be read or belongs to another id. */
123
+ private decode;
124
+ /** The index key that lists the subscription under its event. */
125
+ private eventIndexKey;
126
+ /** The index key that lists the subscription under its owner. */
127
+ private principalIndexKey;
128
+ /** A key part that names `value` without showing it: an HMAC with the secret, else a SHA-256. */
129
+ private digest;
130
+ }
131
+ //# sourceMappingURL=event-subscription.store.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"event-subscription.store.d.ts","sourceRoot":"","sources":["../../../src/event/subscription/event-subscription.store.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,oBAAoB,CAAC;AACrE,OAAO,EAAqC,KAAK,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAE5F,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,cAAc,CAAC;AAGpD,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAErD,iGAAiG;AACjG,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,SAAS,CAAC;IAChB,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;IACf,qGAAqG;IACrG,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,mBAAmB,CAAC,EAAE,MAAM,CAAC;CAC9B;AAED,MAAM,WAAW,uBAAuB;IACtC,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,SAAS,CAAC,EAAE,0BAA0B,CAAC;IACvC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,8FAA8F;IAC9F,QAAQ,CAAC,EA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B;IAIzB,iGAAiG;IACjG,OAAO,CAAC,MAAM;CAMf"}
@@ -0,0 +1,66 @@
1
+ import type { AuthInfo, EventDeliveryStatus } from '@frontmcp/protocol';
2
+ import { type EventEntry, type EventSubscriptionRef, type EventUnsubscribeReason, type FrontMcpLogger } from '../../common';
3
+ import { type EventsConfig } from '../../common/metadata/event.metadata';
4
+ import { type EventCallbackVerifier } from './event-callback-verifier';
5
+ import { type EventSubscriptionRecord, type EventSubscriptionStore, type EventWebhookDelivery } from './event-subscription.store';
6
+ export interface EventSubscriptionsOptions {
7
+ /** The registered events, by name. */
8
+ events: {
9
+ findByName(name: string): EventEntry | undefined;
10
+ };
11
+ store: EventSubscriptionStore;
12
+ /** Whether the store outlives the process; a subscription without expiry needs one that does. */
13
+ durable: boolean;
14
+ verifier: EventCallbackVerifier;
15
+ settings: EventsConfig['subscriptions'];
16
+ /** `events.webhook.rotationGraceMs`. */
17
+ rotationGraceMs: number;
18
+ logger: FrontMcpLogger;
19
+ }
20
+ export interface EventSubscriptionIdentity {
21
+ id: string;
22
+ /** The canonical JSON of the arguments. */
23
+ argumentsKey: string;
24
+ }
25
+ /** How often expired subscriptions are looked for. */
26
+ export declare const SUBSCRIPTION_SWEEP_INTERVAL_MS = 60000;
27
+ /** The subscription as an event's lifecycle methods see it. */
28
+ export declare function subscriptionRefOf(record: EventSubscriptionRecord): EventSubscriptionRef;
29
+ /** The delivery status a client reads on a refresh. */
30
+ export declare function deliveryStatusOf(record: EventSubscriptionRecord): EventDeliveryStatus;
31
+ /** The stored subscriptions of a server: their identity, their lifetime, and the event methods their life calls. */
32
+ export declare class EventSubscriptions {
33
+ private readonly options;
34
+ readonly store: EventSubscriptionStore;
35
+ readonly verifier: EventCallbackVerifier;
36
+ private readonly logger;
37
+ private sweepTimer?;
38
+ private lastSweepAt;
39
+ /** Takes the store, the verifier and the lifetime rules of the scope's subscriptions. */
40
+ constructor(options: EventSubscriptionsOptions);
41
+ /** The limits of `events.subscriptions`, with their defaults. */
42
+ get settings(): EventsConfig['subscriptions'];
43
+ /** The identity of a subscription: the same owner, callback, event and arguments always give the same id. */
44
+ identityOf(principalKey: string, url: string, eventName: string, args: Record<string, unknown>): EventSubscriptionIdentity;
45
+ /** When a subscription that asks for `requestedTtlMs` ends: `null` only for a granted request for no expiry. */
46
+ grantExpiry(event: EventEntry, requestedTtlMs: number | null | undefined, now: number): number | null;
47
+ /** The delivery of a subscription after a refresh: a replaced secret keeps signing until the grace ends. */
48
+ rotatedDelivery(current: EventWebhookDelivery | undefined, url: string, secret: string, now: number): EventWebhookDelivery;
49
+ /** Call the event's `onSubscribe` for a subscription that was just created. */
50
+ notifySubscribed(event: EventEntry, record: EventSubscriptionRecord, authInfo: Partial<AuthInfo>): Promise<void>;
51
+ /** Call the event's `onUnsubscribe` for a removed subscription; a failure there is logged, never thrown. */
52
+ notifyUnsubscribed(record: EventSubscriptionRecord, reason: EventUnsubscribeReason, authInfo?: Partial<AuthInfo>): Promise<void>;
53
+ /** End one subscription whose lifetime is over, telling its event once across every node. */
54
+ expire(id: string, now?: number): Promise<void>;
55
+ /** End every subscription whose lifetime is over. */
56
+ sweep(now?: number): Promise<void>;
57
+ /** Sweep in the background when the last sweep is old enough: the only sweep on serverless and edge runtimes. */
58
+ sweepIfDue(now?: number): void;
59
+ /** Sweep on a timer, where the process is long-lived. */
60
+ start(): void;
61
+ /** Stop the timer and close the store. */
62
+ close(): Promise<void>;
63
+ /** Run a sweep nobody waits for; its failure is logged. */
64
+ private sweepInBackground;
65
+ }
66
+ //# sourceMappingURL=event-subscriptions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"event-subscriptions.d.ts","sourceRoot":"","sources":["../../../src/event/subscription/event-subscriptions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAGxE,OAAO,EACL,KAAK,UAAU,EACf,KAAK,oBAAoB,EACzB,KAAK,sBAAsB,EAC3B,K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AAI,CAAC;IAM5B,2DAA2D;IAC3D,OAAO,CAAC,iBAAiB;CAG1B"}
@@ -0,0 +1,35 @@
1
+ import { PublicMcpError } from '../errors/mcp.error';
2
+ /** The JSON-RPC error a server answered an events request of the client with. */
3
+ export declare class EventRequestError extends PublicMcpError {
4
+ readonly method: string;
5
+ readonly rpcCode: number;
6
+ readonly data?: unknown | undefined;
7
+ /** The error of `method`, with the JSON-RPC code and data the server sent. */
8
+ constructor(method: string, rpcCode: number, message: string, data?: unknown | undefined);
9
+ }
10
+ /** None of the delivery modes the event offers is one this client can use. */
11
+ export declare class NoCompatibleDeliveryModeError extends PublicMcpError {
12
+ /** Names the modes the event offers and the modes the client can use. */
13
+ constructor(eventName: string, offered: readonly string[], usable: readonly string[]);
14
+ }
15
+ /** The server ended a subscription of the client, for example because its access was revoked. */
16
+ export declare class EventSubscriptionTerminatedError extends PublicMcpError {
17
+ readonly eventName: string;
18
+ readonly error: {
19
+ code: number;
20
+ message: string;
21
+ data?: Record<string, unknown>;
22
+ };
23
+ /** Carries the error the server ended the subscription with. */
24
+ constructor(eventName: string, error: {
25
+ code: number;
26
+ message: string;
27
+ data?: Record<string, unknown>;
28
+ });
29
+ }
30
+ /** The client already holds a webhook subscription that the server knows by the same id. */
31
+ export declare class DuplicateEventSubscriptionError extends PublicMcpError {
32
+ /** Names the event and the callback URL the existing subscription delivers to. */
33
+ constructor(eventName: string, url: string);
34
+ }
35
+ //# sourceMappingURL=event-client.errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"event-client.errors.d.ts","sourceRoot":"","sources":["../../src/event-client/event-client.errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAErD,iFAAiF;AACjF,qBAAa,iBAAkB,SAAQ,cAAc;IAGjD,QAAQ,CAAC,MAAM,EAAE,MAAM;IACvB,QAAQ,CAAC,OAAO,EAAE,MAAM;IAExB,QAAQ,CAAC,IAAI,CAAC,EAAE,OAAO;IALzB,8EAA8E;gBAEnE,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,MAAM,EACxB,OAAO,EAAE,MAAM,EACN,IAAI,CAAC,EAAE,OAAO,YAAA;CAI1B;AAED,8EAA8E;AAC9E,qBAAa,6BAA8B,SAAQ,cAAc;IAC/D,yEAAyE;gBAC7D,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,SAAS,MAAM,EAAE,EAAE,MAAM,EAAE,SAAS,MAAM,EAAE;CAQrF;AAED,iGAAiG;AACjG,qBAAa,gCAAiC,SAAQ,cAAc;IAGhE,QAAQ,CAAC,SAAS,EAAE,MAAM;IAC1B,QAAQ,CAAC,KAAK,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;KAAE;IAHnF,gEAAgE;gBAErD,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;KAAE;CAIpF;AAED,4FAA4F;AAC5F,qBAAa,+BAAgC,SAAQ,cAAc;IACjE,kFAAkF;gBACtE,SAAS,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM;CAQ3C"}