@xopcai/xopc 0.0.464 → 0.0.466

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 (388) hide show
  1. package/dist/browser-ext/manifest.json +1 -1
  2. package/dist/extensions/dingtalk/src/index.d.ts +8 -0
  3. package/dist/extensions/dingtalk/src/index.js +159 -0
  4. package/dist/extensions/dingtalk/xopc.extension.json +131 -0
  5. package/dist/extensions/discord/src/gateway.d.ts +13 -0
  6. package/dist/extensions/discord/src/gateway.js +186 -0
  7. package/dist/extensions/discord/src/index.d.ts +8 -0
  8. package/dist/extensions/discord/src/index.js +184 -0
  9. package/dist/extensions/discord/xopc.extension.json +113 -0
  10. package/dist/extensions/feishu/src/adapters/cli-login.js +23 -49
  11. package/dist/extensions/feishu/src/adapters/gateway-setup.d.ts +3 -0
  12. package/dist/extensions/feishu/src/adapters/gateway-setup.js +210 -151
  13. package/dist/extensions/feishu/src/adapters/onboard-cli.d.ts +1 -1
  14. package/dist/extensions/feishu/src/adapters/onboard-cli.js +27 -15
  15. package/dist/extensions/feishu/src/auth/app-registration.d.ts +1 -0
  16. package/dist/extensions/feishu/src/auth/app-registration.js +12 -9
  17. package/dist/extensions/feishu/src/outbound/outbound-adapter.js +40 -16
  18. package/dist/extensions/feishu/src/plugin.d.ts +2 -0
  19. package/dist/extensions/feishu/src/plugin.js +37 -23
  20. package/dist/extensions/feishu/src/status/status-adapter.d.ts +1 -1
  21. package/dist/extensions/feishu/src/status/status-adapter.js +8 -5
  22. package/dist/extensions/feishu/src/streaming/streaming-adapter.js +97 -69
  23. package/dist/extensions/feishu/src/transport/client/bot-info.d.ts +10 -0
  24. package/dist/extensions/feishu/src/transport/client/bot-info.js +34 -0
  25. package/dist/extensions/feishu/src/transport/client/client.d.ts +7 -1
  26. package/dist/extensions/feishu/src/transport/client/client.js +6 -5
  27. package/dist/extensions/feishu/src/transport/client/install-sdk.d.ts +2 -0
  28. package/dist/extensions/feishu/src/transport/client/install-sdk.js +77 -0
  29. package/dist/extensions/feishu/src/transport/client/lark-sdk.d.ts +2 -0
  30. package/dist/extensions/feishu/src/transport/client/lark-sdk.js +27 -3
  31. package/dist/extensions/feishu/src/transport/client/sdk-catalog.d.ts +1 -0
  32. package/dist/extensions/feishu/src/transport/client/sdk-catalog.js +317 -0
  33. package/dist/extensions/feishu/src/transport/reliability/inbound-pipeline.d.ts +1 -1
  34. package/dist/extensions/feishu/src/transport/reliability/inbound-pipeline.js +13 -5
  35. package/dist/extensions/feishu/src/transport/reliability/message-ingress.d.ts +21 -0
  36. package/dist/extensions/feishu/src/transport/reliability/message-ingress.js +313 -0
  37. package/dist/extensions/feishu/src/transport/socket-mode/monitor.d.ts +1 -0
  38. package/dist/extensions/feishu/src/transport/socket-mode/monitor.js +56 -171
  39. package/dist/extensions/feishu/src/transport/webhook/monitor.d.ts +1 -0
  40. package/dist/extensions/feishu/src/transport/webhook/monitor.js +10 -102
  41. package/dist/extensions/slack/src/index.d.ts +8 -0
  42. package/dist/extensions/slack/src/index.js +169 -0
  43. package/dist/extensions/slack/src/manifest.d.ts +33 -0
  44. package/dist/extensions/slack/src/manifest.js +32 -0
  45. package/dist/extensions/slack/xopc.extension.json +124 -0
  46. package/dist/extensions/telegram/src/account-manager.d.ts +1 -0
  47. package/dist/extensions/telegram/src/account-manager.js +3 -0
  48. package/dist/extensions/telegram/src/adapters/debounce-keys.js +7 -2
  49. package/dist/extensions/telegram/src/adapters/gateway-setup.js +116 -63
  50. package/dist/extensions/telegram/src/adapters/streaming-adapter.js +8 -4
  51. package/dist/extensions/telegram/src/doctor.js +1 -1
  52. package/dist/extensions/telegram/src/inbound-coalescer.d.ts +8 -6
  53. package/dist/extensions/telegram/src/inbound-coalescer.js +47 -88
  54. package/dist/extensions/telegram/src/inbound-processor.js +5 -1
  55. package/dist/extensions/telegram/src/outbound-sender.js +16 -23
  56. package/dist/extensions/telegram/src/plugin.js +80 -57
  57. package/dist/extensions/telegram/src/polling-session.d.ts +3 -6
  58. package/dist/extensions/telegram/src/polling-session.js +107 -94
  59. package/dist/extensions/telegram/src/rich-message.d.ts +4 -0
  60. package/dist/extensions/telegram/src/rich-message.js +23 -0
  61. package/dist/extensions/telegram/src/timeout-abort.d.ts +1 -1
  62. package/dist/extensions/telegram/src/timeout-abort.js +9 -3
  63. package/dist/extensions/telegram/src/update-offset-store.d.ts +1 -0
  64. package/dist/extensions/telegram/src/update-offset-store.js +6 -1
  65. package/dist/extensions/telegram/xopc.extension.json +1 -1
  66. package/dist/extensions/wecom/src/index.d.ts +8 -0
  67. package/dist/extensions/wecom/src/index.js +188 -0
  68. package/dist/extensions/wecom/xopc.extension.json +131 -0
  69. package/dist/extensions/weixin/src/api/api.d.ts +1 -0
  70. package/dist/extensions/weixin/src/api/api.js +12 -6
  71. package/dist/extensions/weixin/src/api/types.d.ts +5 -2
  72. package/dist/extensions/weixin/src/auth/login-qr.d.ts +7 -1
  73. package/dist/extensions/weixin/src/auth/login-qr.js +48 -13
  74. package/dist/extensions/weixin/src/cdn/pic-decrypt.d.ts +2 -2
  75. package/dist/extensions/weixin/src/cdn/pic-decrypt.js +37 -25
  76. package/dist/extensions/weixin/src/cli/gateway-qr-login.d.ts +8 -0
  77. package/dist/extensions/weixin/src/cli/gateway-qr-login.js +45 -6
  78. package/dist/extensions/weixin/src/cli/qr-login.d.ts +1 -1
  79. package/dist/extensions/weixin/src/cli/qr-login.js +9 -3
  80. package/dist/extensions/weixin/src/media/media-download.d.ts +1 -0
  81. package/dist/extensions/weixin/src/media/media-download.js +4 -5
  82. package/dist/extensions/weixin/src/messaging/process-message.d.ts +2 -0
  83. package/dist/extensions/weixin/src/messaging/process-message.js +90 -65
  84. package/dist/extensions/weixin/src/messaging/quote-cache.d.ts +10 -0
  85. package/dist/extensions/weixin/src/messaging/quote-cache.js +46 -0
  86. package/dist/extensions/weixin/src/monitor/monitor.d.ts +3 -3
  87. package/dist/extensions/weixin/src/monitor/monitor.js +108 -104
  88. package/dist/extensions/weixin/src/plugin.d.ts +5 -1
  89. package/dist/extensions/weixin/src/plugin.js +138 -42
  90. package/dist/gateway/static/root/assets/{activity-store-B9heFbtJ.js → activity-store-CdEua6PR.js} +1 -1
  91. package/dist/gateway/static/root/assets/{agent-avatar-dicebear-nzhB7Xjk.js → agent-avatar-dicebear-l8GQ4I9J.js} +1 -1
  92. package/dist/gateway/static/root/assets/{agent-avatar-display-DBzgoHMD.js → agent-avatar-display-BO1bqKlR.js} +2 -2
  93. package/dist/gateway/static/root/assets/{agent-defaults-settings-panel-BJrNV93g.js → agent-defaults-settings-panel-Dj_H2kDD.js} +1 -1
  94. package/dist/gateway/static/root/assets/{agent-plugin-dialog-DLbTHALG.js → agent-plugin-dialog-BQA2brAU.js} +1 -1
  95. package/dist/gateway/static/root/assets/agents-C5C5l13A.js +77 -0
  96. package/dist/gateway/static/root/assets/{agents-admin-api-CqQbYIiY.js → agents-admin-api-DZ1lLnrj.js} +1 -1
  97. package/dist/gateway/static/root/assets/api-CG-SjNfw.js +1 -0
  98. package/dist/gateway/static/root/assets/{api-BGodd--L.js → api-DDWYNF7I.js} +1 -1
  99. package/dist/gateway/static/root/assets/{api-8tNOT72p.js → api-DVXcGKP-.js} +1 -1
  100. package/dist/gateway/static/root/assets/{app-link-DImAfVs5.js → app-link-BkEO3eBe.js} +1 -1
  101. package/dist/gateway/static/root/assets/{app-management-settings-panel-Q7apF7KE.js → app-management-settings-panel-B5-7E03Z.js} +1 -1
  102. package/dist/gateway/static/root/assets/{appearance-settings-ClVZeUmo.js → appearance-settings-E_BcjEDM.js} +1 -1
  103. package/dist/gateway/static/root/assets/{apps-page-BsJJwpKj.js → apps-page-BjB_mjXu.js} +1 -1
  104. package/dist/gateway/static/root/assets/{archive-plugin-Bl_M0WJp.js → archive-plugin-MvSiDvxK.js} +1 -1
  105. package/dist/gateway/static/root/assets/{automation-api-BOnIc_vw.js → automation-api-24NjW7qG.js} +1 -1
  106. package/dist/gateway/static/root/assets/{automation-result-state-BwDSJs05.js → automation-result-state-C94Q3OEL.js} +1 -1
  107. package/dist/gateway/static/root/assets/{automation-run-list-CqlIq4BG.js → automation-run-list-BShRirWV.js} +1 -1
  108. package/dist/gateway/static/root/assets/automation-task-card-Bgq5Plux.js +2 -0
  109. package/dist/gateway/static/root/assets/{automations-page-Bimqx5Pc.js → automations-page-_apIsCPT.js} +1 -1
  110. package/dist/gateway/static/root/assets/automations-workspace-WmcQUi9O.js +9 -0
  111. package/dist/gateway/static/root/assets/{binary-plugins-DDNKe1Io.js → binary-plugins-C7i5pqkO.js} +1 -1
  112. package/dist/gateway/static/root/assets/{block-editor-BQ3amsRP.js → block-editor-DAWXPErA.js} +1 -1
  113. package/dist/gateway/static/root/assets/{browser-settings-page-CHf1_RVl.js → browser-settings-page-DI2PYAPC.js} +1 -1
  114. package/dist/gateway/static/root/assets/{capabilities-C5oWMC-Z.js → capabilities-CFWTer_v.js} +1 -1
  115. package/dist/gateway/static/root/assets/{capabilities-Cj8vl1ZY.js → capabilities-Dyw8xW90.js} +1 -1
  116. package/dist/gateway/static/root/assets/capabilities-page-C2RB9fzC.js +2 -0
  117. package/dist/gateway/static/root/assets/capabilities-settings-panel-DuQGhgAl.js +8 -0
  118. package/dist/gateway/static/root/assets/{capability-navigation-QtHJxxW2.js → capability-navigation-CZbCI5C2.js} +1 -1
  119. package/dist/gateway/static/root/assets/channels-DiDfjON8.js +1 -0
  120. package/dist/gateway/static/root/assets/{chat-agents-api-C3JChTsh.js → chat-agents-api-BksS0CNy.js} +1 -1
  121. package/dist/gateway/static/root/assets/{chat-chart-block-DrtmYOIo.js → chat-chart-block-aZIklMNN.js} +1 -1
  122. package/dist/gateway/static/root/assets/chat-page-BMZwIVXH.js +71 -0
  123. package/dist/gateway/static/root/assets/{chat-terminal-dock-B0D220I-.js → chat-terminal-dock-B4HoRIzf.js} +1 -1
  124. package/dist/gateway/static/root/assets/{command-palette-api-CkJ6_Yf3.js → command-palette-api-VhBEUFmw.js} +1 -1
  125. package/dist/gateway/static/root/assets/{composer-handoff-params-GKGdXjMZ.js → composer-handoff-params-DBpzHuNo.js} +1 -1
  126. package/dist/gateway/static/root/assets/{composer-model-config-control-DQCOWHzJ.js → composer-model-config-control-BhRAbdPW.js} +1 -1
  127. package/dist/gateway/static/root/assets/{composer-notifications-D__OU_xx.js → composer-notifications-nT-U6jcc.js} +1 -1
  128. package/dist/gateway/static/root/assets/{composer-payload-handoff-BBTbJ1bO.js → composer-payload-handoff-xEFHDnLo.js} +1 -1
  129. package/dist/gateway/static/root/assets/{computer-settings-page-DGRUCkOt.js → computer-settings-page-DXlH96m6.js} +1 -1
  130. package/dist/gateway/static/root/assets/{connected-providers-grid-BoDipD2g.js → connected-providers-grid-D8vBFsbY.js} +1 -1
  131. package/dist/gateway/static/root/assets/{connection-usage-guide-B1VUqibv.js → connection-usage-guide-C8jPm7QO.js} +1 -1
  132. package/dist/gateway/static/root/assets/{connector-service-page-bwQ1PekA.js → connector-service-page-B42yWHxS.js} +1 -1
  133. package/dist/gateway/static/root/assets/{connectors-api-BvYGL65q.js → connectors-api-so2a7xrD.js} +1 -1
  134. package/dist/gateway/static/root/assets/{connectors-page-BX6Jt6w5.js → connectors-page-yhOZIiUZ.js} +1 -1
  135. package/dist/gateway/static/root/assets/{date-picker-ClRDaNBJ.js → date-picker-UEh3JM7r.js} +1 -1
  136. package/dist/gateway/static/root/assets/{date-time-picker-CA6H47M6.js → date-time-picker-Dci0LfAU.js} +1 -1
  137. package/dist/gateway/static/root/assets/{desktop-pet-Bi8Hgf-x.js → desktop-pet-BAU_GuBe.js} +1 -1
  138. package/dist/gateway/static/root/assets/{desktop-pet-settings-CQ6qE8lf.js → desktop-pet-settings-CYE2eTTf.js} +1 -1
  139. package/dist/gateway/static/root/assets/{dev-view-store-UCqQeWa2.js → dev-view-store-C7v4CIlF.js} +1 -1
  140. package/dist/gateway/static/root/assets/{device-pairing-wizard-gC-XZxt2.js → device-pairing-wizard-7NDkYmiZ.js} +1 -1
  141. package/dist/gateway/static/root/assets/{directory-picker-path-field-Y8snl5Xl.js → directory-picker-path-field-DmRZY8kg.js} +1 -1
  142. package/dist/gateway/static/root/assets/{extension-authoritative-grants-D2abOXTl.js → extension-authoritative-grants-DIeg1mg8.js} +1 -1
  143. package/dist/gateway/static/root/assets/{extension-debug-page-OOlRCInL.js → extension-debug-page-D8TAJgZ_.js} +1 -1
  144. package/dist/gateway/static/root/assets/{extension-iframe-host-D_WXBf6a.js → extension-iframe-host-CjfRKtQ4.js} +1 -1
  145. package/dist/gateway/static/root/assets/{extension-marketplace-api-Bmtm6-L1.js → extension-marketplace-api-V1oFBxVi.js} +1 -1
  146. package/dist/gateway/static/root/assets/{extension-message-router-xqjjSxcp.js → extension-message-router-DZahH1Hd.js} +1 -1
  147. package/dist/gateway/static/root/assets/{extension-page-bpQnyNz-.js → extension-page-DMuHBIHa.js} +1 -1
  148. package/dist/gateway/static/root/assets/{extension-provider-l7SvHEK1.js → extension-provider-lqJ1zIkA.js} +1 -1
  149. package/dist/gateway/static/root/assets/extension-settings-page-D5IfKVff.js +1 -0
  150. package/dist/gateway/static/root/assets/{file-preview-surface-B-r2ZnCV.js → file-preview-surface-B7B9qXm9.js} +1 -1
  151. package/dist/gateway/static/root/assets/{gateway-config-swr-DOwezeL2.js → gateway-config-swr-Dk3FtNv1.js} +1 -1
  152. package/dist/gateway/static/root/assets/{gateway-realtime-Br7dErHY.js → gateway-realtime-DMvo4pAc.js} +1 -1
  153. package/dist/gateway/static/root/assets/gateway-realtime-store-CJf-qaHZ.js +1 -0
  154. package/dist/gateway/static/root/assets/{gateway-restart-B3Xro3qd.js → gateway-restart-C2h5R1eP.js} +1 -1
  155. package/dist/gateway/static/root/assets/{gateway-settings-DCnP-HPj.js → gateway-settings-DGPaikv5.js} +1 -1
  156. package/dist/gateway/static/root/assets/{gateway-startup-retry-vteSIhYI.js → gateway-startup-retry-yZn7ShiP.js} +1 -1
  157. package/dist/gateway/static/root/assets/{global-defaults-api-Bpje9rVk.js → global-defaults-api-gsAa0Kj9.js} +1 -1
  158. package/dist/gateway/static/root/assets/{home-page-CNEgNWEQ.js → home-page-Dgopm60U.js} +3 -3
  159. package/dist/gateway/static/root/assets/{image-generation-api-BvpAa3Lj.js → image-generation-api-DPn1SBMH.js} +1 -1
  160. package/dist/gateway/static/root/assets/{imports-page-Dx5T5pqw.js → imports-page-Cc48Uq20.js} +1 -1
  161. package/dist/gateway/static/root/assets/index-BE3XMuQI.js +11 -0
  162. package/dist/gateway/static/root/assets/index-CY5vdQcc.css +1 -0
  163. package/dist/gateway/static/root/assets/{install-connector-dialog-Cb4ufypG.js → install-connector-dialog-QkJMw_uW.js} +1 -1
  164. package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-BEuXrnv0.js → keyboard-shortcuts-settings-BZXqXuI4.js} +1 -1
  165. package/dist/gateway/static/root/assets/{local-app-workbench-page-CPFIbEbv.js → local-app-workbench-page-wekatwet.js} +1 -1
  166. package/dist/gateway/static/root/assets/{local-apps-page-DxHcRSxc.js → local-apps-page-D-bRvlZY.js} +1 -1
  167. package/dist/gateway/static/root/assets/{local-session-drafts-Cmc-GCVa.js → local-session-drafts-CZ19DRRK.js} +1 -1
  168. package/dist/gateway/static/root/assets/{locale-store-tI9VX7dp.js → locale-store-DIBIYLnI.js} +1 -1
  169. package/dist/gateway/static/root/assets/{logs-page-BcibwftP.js → logs-page-CukseY3k.js} +1 -1
  170. package/dist/gateway/static/root/assets/{management-api-C9tFjLcE.js → management-api-EG5duPec.js} +1 -1
  171. package/dist/gateway/static/root/assets/{management-settings-DbnAlXoB.js → management-settings-B7RWHrwo.js} +1 -1
  172. package/dist/gateway/static/root/assets/{markdown-view-CSpQhSka.js → markdown-view-C30KvTaE.js} +1 -1
  173. package/dist/gateway/static/root/assets/{mcp-conversation-setup-page-DedbjJbF.js → mcp-conversation-setup-page-BZ1PDTYY.js} +1 -1
  174. package/dist/gateway/static/root/assets/{media-plugins-BYnP_orq.js → media-plugins-DlMEwcS8.js} +1 -1
  175. package/dist/gateway/static/root/assets/messages-BDBGlBKh.js +3 -0
  176. package/dist/gateway/static/root/assets/{model-selector-B4oTiJI6.js → model-selector-COGICRIG.js} +1 -1
  177. package/dist/gateway/static/root/assets/{models-hub-cache-DpEClnsE.js → models-hub-cache-aRYHi2dh.js} +1 -1
  178. package/dist/gateway/static/root/assets/new-chat-navigation-DXYDldT_.js +1 -0
  179. package/dist/gateway/static/root/assets/{note-detail-panel-D8asMfBm.js → note-detail-panel-yAPC_cZU.js} +3 -3
  180. package/dist/gateway/static/root/assets/note-image-lightbox-CxXu_Tkh.js +1 -0
  181. package/dist/gateway/static/root/assets/{notes-api-pVC1amyp.js → notes-api-BXevQivV.js} +1 -1
  182. package/dist/gateway/static/root/assets/{notes-page-CG1_6PLz.js → notes-page-CUMhjKKd.js} +1 -1
  183. package/dist/gateway/static/root/assets/{oauth-api-BsVPwufr.js → oauth-api-enDU_32p.js} +1 -1
  184. package/dist/gateway/static/root/assets/{oauth-provider-connect-Bu20kmPq.js → oauth-provider-connect-C2pfvPOI.js} +1 -1
  185. package/dist/gateway/static/root/assets/{page-context-capture-button-CDsnNXjS.js → page-context-capture-button-BaSooYGv.js} +1 -1
  186. package/dist/gateway/static/root/assets/{page-context-draft-D6tu8c_9.js → page-context-draft-4-3RtO0q.js} +1 -1
  187. package/dist/gateway/static/root/assets/page-header-store-C2ydtnXa.js +1 -0
  188. package/dist/gateway/static/root/assets/{personal-avatar-BboNc6e2.js → personal-avatar-BPQpvC34.js} +1 -1
  189. package/dist/gateway/static/root/assets/personal-page-POCG1_kK.js +1 -0
  190. package/dist/gateway/static/root/assets/{personal-profile-settings-Cd4QyseL.js → personal-profile-settings-DwMdjQ6H.js} +1 -1
  191. package/dist/gateway/static/root/assets/{personal-settings-panel-CtBY_Uk1.js → personal-settings-panel-DiNpP_g3.js} +1 -1
  192. package/dist/gateway/static/root/assets/{phone-dependencies-card-BgH1LluB.js → phone-dependencies-card-DUT-qRLZ.js} +1 -1
  193. package/dist/gateway/static/root/assets/{phone-model-connection-DkdKU5Kv.js → phone-model-connection-pvOciDNo.js} +1 -1
  194. package/dist/gateway/static/root/assets/{phone-model-picker-0g1z4RPL.js → phone-model-picker-CD97E6C5.js} +1 -1
  195. package/dist/gateway/static/root/assets/{phone-settings-page-DlIUajBY.js → phone-settings-page-BUZ1dh7s.js} +1 -1
  196. package/dist/gateway/static/root/assets/{phone-workspace-store-DW2sZtkh.js → phone-workspace-store-BwilERgv.js} +1 -1
  197. package/dist/gateway/static/root/assets/{plugin-details-dialog-9KUkZk_t.js → plugin-details-dialog-C_uOVmJv.js} +1 -1
  198. package/dist/gateway/static/root/assets/{preference-select-fields-DH5QZhIc.js → preference-select-fields-BSUgcO7-.js} +1 -1
  199. package/dist/gateway/static/root/assets/{product-automation-feedback-a1thJ0M9.js → product-automation-feedback-BlwtlUY7.js} +1 -1
  200. package/dist/gateway/static/root/assets/product-delivery-CnvCn9L-.js +1 -0
  201. package/dist/gateway/static/root/assets/{product-open-page-DCzQh7tr.js → product-open-page-Dy6D5exJ.js} +1 -1
  202. package/dist/gateway/static/root/assets/{product-preview-content-C5TLcagj.js → product-preview-content-DEUPAilo.js} +1 -1
  203. package/dist/gateway/static/root/assets/product-preview-modal-C4TV9RUd.js +2 -0
  204. package/dist/gateway/static/root/assets/project-detail-page-BjOzJyw1.js +7 -0
  205. package/dist/gateway/static/root/assets/{project-understanding-CoPBvlqf.js → project-understanding-lOJ5Tz2V.js} +1 -1
  206. package/dist/gateway/static/root/assets/{projects-page-k1v8Fry8.js → projects-page-B3aGdPHy.js} +1 -1
  207. package/dist/gateway/static/root/assets/{providers-api-BSJZyO8n.js → providers-api-C26HgxZY.js} +1 -1
  208. package/dist/gateway/static/root/assets/{recording-upload-CExCePtr.js → recording-upload-BJkXktA-.js} +1 -1
  209. package/dist/gateway/static/root/assets/{registry-api-CqcJj60w.js → registry-api-pQ0eInzG.js} +1 -1
  210. package/dist/gateway/static/root/assets/{remote-access-hub-BLFkNl1y.js → remote-access-hub-CjWrYzjf.js} +1 -1
  211. package/dist/gateway/static/root/assets/{resource-unavailable-B_BXTQa7.js → resource-unavailable-Y9WRHOnz.js} +1 -1
  212. package/dist/gateway/static/root/assets/{right-workspace-store-OceFhUjM.js → right-workspace-store-DHHyicqQ.js} +1 -1
  213. package/dist/gateway/static/root/assets/route-preload-DjYsRhY1.js +2 -0
  214. package/dist/gateway/static/root/assets/{routine-panel-BsE9o9uu.js → routine-panel-DSNsdpy8.js} +2 -2
  215. package/dist/gateway/static/root/assets/{runtime-tools-api-aAZChVm4.js → runtime-tools-api-BoJQ3u5o.js} +1 -1
  216. package/dist/gateway/static/root/assets/{runtime-tools-settings-panel-Bn9HTrK5.js → runtime-tools-settings-panel-DB7cfLrX.js} +1 -1
  217. package/dist/gateway/static/root/assets/schema-form-DXHzZPMr.js +1 -0
  218. package/dist/gateway/static/root/assets/send-1f1Ntw6E.js +1 -0
  219. package/dist/gateway/static/root/assets/{service-recommendation-list-BNIVRGDf.js → service-recommendation-list-_rFmwIwY.js} +1 -1
  220. package/dist/gateway/static/root/assets/{session-api-DdW7Wix2.js → session-api-a6wb0_Gf.js} +1 -1
  221. package/dist/gateway/static/root/assets/{session-channel-icon-DUJbB-Km.js → session-channel-icon-COynhpeK.js} +1 -1
  222. package/dist/gateway/static/root/assets/{session-identity-label-DjhlQ6LU.js → session-identity-label-DCIZvqbN.js} +1 -1
  223. package/dist/gateway/static/root/assets/session-manager-D5g6LOU-.js +25 -0
  224. package/dist/gateway/static/root/assets/{sessions-page-CfhKeUkZ.js → sessions-page-dEupc-3A.js} +1 -1
  225. package/dist/gateway/static/root/assets/settings-advanced-gate-DjyibJZ1.js +1 -0
  226. package/dist/gateway/static/root/assets/{settings-advanced-section-BOoJfJuB.js → settings-advanced-section-CnGJr2xp.js} +1 -1
  227. package/dist/gateway/static/root/assets/{settings-mode-store-BMh_BQ9a.js → settings-mode-store-DWRhupcY.js} +1 -1
  228. package/dist/gateway/static/root/assets/{settings-page-header-Bfu4cuQd.js → settings-page-header-wL2jvs-y.js} +1 -1
  229. package/dist/gateway/static/root/assets/{settings-page-layout-BnZa1qHH.js → settings-page-layout-BkUQVmyY.js} +1 -1
  230. package/dist/gateway/static/root/assets/{settings-page-DNiRlM5x.js → settings-page-u-U9D9qT.js} +1 -1
  231. package/dist/gateway/static/root/assets/{setup-interaction-page-CVlrVNrm.js → setup-interaction-page-D238tuw-.js} +1 -1
  232. package/dist/gateway/static/root/assets/{setup-status-panel-FFyDODEx.js → setup-status-panel-DXvYjIu3.js} +1 -1
  233. package/dist/gateway/static/root/assets/{share-link-dialog-Cv-eDEw_.js → share-link-dialog-DFDJyl3N.js} +1 -1
  234. package/dist/gateway/static/root/assets/{share-preview-page-BctH6eFs.js → share-preview-page-BYPdlPIb.js} +1 -1
  235. package/dist/gateway/static/root/assets/{shares-api-cLTEcQLE.js → shares-api-CfFiW03g.js} +1 -1
  236. package/dist/gateway/static/root/assets/{shares-settings-DcetAN8K.js → shares-settings-B85XIDFv.js} +1 -1
  237. package/dist/gateway/static/root/assets/{skill-api-CgEZJoy9.js → skill-api-CWRhFSkA.js} +1 -1
  238. package/dist/gateway/static/root/assets/{skill-list-api-BWVr2PL5.js → skill-list-api-CmPp2czp.js} +1 -1
  239. package/dist/gateway/static/root/assets/{skill-reload-api-BLhHNvaK.js → skill-reload-api-BGsSq3dj.js} +1 -1
  240. package/dist/gateway/static/root/assets/{skills-page-DIjcAvA0.js → skills-page-DqD0FPeH.js} +1 -1
  241. package/dist/gateway/static/root/assets/{system-settings-panel-C7LAPaN_.js → system-settings-panel-aw9C86I8.js} +1 -1
  242. package/dist/gateway/static/root/assets/task-detail-page-BPHt6S1V.js +3 -0
  243. package/dist/gateway/static/root/assets/{task-result-evidence-BsBn3n_l.js → task-result-evidence-C-zIBpzi.js} +1 -1
  244. package/dist/gateway/static/root/assets/{terminal-panel-store-DJbLuUku.js → terminal-panel-store-CgPqgrm7.js} +1 -1
  245. package/dist/gateway/static/root/assets/{theme-store-QGcjV6pN.js → theme-store-DxF7S6I2.js} +1 -1
  246. package/dist/gateway/static/root/assets/{tracing-settings-page-BKCiPwYL.js → tracing-settings-page-Dvlunx28.js} +1 -1
  247. package/dist/gateway/static/root/assets/{tunnel-api-S7J5Lpzt.js → tunnel-api-CIte6n0U.js} +1 -1
  248. package/dist/gateway/static/root/assets/{understanding-activity-store-BNVhtJkn.js → understanding-activity-store-C2RHmRo8.js} +1 -1
  249. package/dist/gateway/static/root/assets/understanding-refresh-store-CPeQIXS_.js +1 -0
  250. package/dist/gateway/static/root/assets/{usage-page-D-AqzjIx.js → usage-page-DPUjEj39.js} +1 -1
  251. package/dist/gateway/static/root/assets/{use-autosave-CqZbhhCc.js → use-autosave-xX2KrbXw.js} +1 -1
  252. package/dist/gateway/static/root/assets/{use-composer-attachments-BfLhIb2_.js → use-composer-attachments-UhypPQH_.js} +1 -1
  253. package/dist/gateway/static/root/assets/{use-file-preview-expanded-DufxDues.js → use-file-preview-expanded-BvEF3yHL.js} +3 -3
  254. package/dist/gateway/static/root/assets/{use-personal-profile-RnjxZnLa.js → use-personal-profile-BJgaheR4.js} +1 -1
  255. package/dist/gateway/static/root/assets/{use-realtime-voice-w3aHR2dr.js → use-realtime-voice-RQW5KnIN.js} +1 -1
  256. package/dist/gateway/static/root/assets/{use-workspace-tree-2Ck-ql5c.js → use-workspace-tree-B6QFV5gR.js} +1 -1
  257. package/dist/gateway/static/root/assets/user-model-page-hKnsTcMk.js +2 -0
  258. package/dist/gateway/static/root/assets/{voice-api-key-field-C4rhpgco.js → voice-api-key-field-BeEF7Thh.js} +1 -1
  259. package/dist/gateway/static/root/assets/{voice-config-api-7AHN-ns6.js → voice-config-api-vbBoKnqd.js} +1 -1
  260. package/dist/gateway/static/root/assets/{voice-input-shortcut-events-BbRrj833.js → voice-input-shortcut-events-CKn6X3qL.js} +1 -1
  261. package/dist/gateway/static/root/assets/{voice-settings-wamtp0lg.js → voice-settings-BUrk4mwV.js} +1 -1
  262. package/dist/gateway/static/root/assets/{work-discovery-overlay-fVofN7aP.js → work-discovery-overlay-Ddvqu02U.js} +1 -1
  263. package/dist/gateway/static/root/assets/{work-discovery-page-DcQG5GWy.js → work-discovery-page-BdBpri6P.js} +1 -1
  264. package/dist/gateway/static/root/assets/{working-directory-picker-modal-D8Stwszr.js → working-directory-picker-modal-DStgfCzQ.js} +1 -1
  265. package/dist/gateway/static/root/assets/{workspace-api-D3iuTdNK.js → workspace-api-CscTRODe.js} +2 -2
  266. package/dist/gateway/static/root/assets/workspace-editor-agent-store-CyPjTDSx.js +1 -0
  267. package/dist/gateway/static/root/assets/{workspace-file-preview-dialog-BXbL5Y1h.js → workspace-file-preview-dialog-BRQIf4sc.js} +1 -1
  268. package/dist/gateway/static/root/assets/{workspace-open-location-menu-1gFO_BdL.js → workspace-open-location-menu-CBHFZ2iQ.js} +1 -1
  269. package/dist/gateway/static/root/assets/{workspace-preview-store-adwmi4nx.js → workspace-preview-store-DNLnuHlf.js} +1 -1
  270. package/dist/gateway/static/root/assets/{xopc-cloud-account-card-DhGh4rm7.js → xopc-cloud-account-card-Cm0Saa8B.js} +1 -1
  271. package/dist/gateway/static/root/index.html +99 -97
  272. package/dist/package.js +1 -1
  273. package/dist/packages/gateway-contract/src/index.js +2 -0
  274. package/dist/packages/gateway-contract/src/product-delivery.js +2 -0
  275. package/dist/packages/gateway-contract/src/video-generation.js +75 -0
  276. package/dist/src/agent/embedded/runs.d.ts +1 -0
  277. package/dist/src/agent/embedded/runs.js +5 -2
  278. package/dist/src/agent/inbound/attachment-pipeline.d.ts +1 -1
  279. package/dist/src/agent/inbound/attachment-pipeline.js +16 -10
  280. package/dist/src/agent/inbound/inbound-loop.js +14 -0
  281. package/dist/src/agent/inbound/turn-dispatcher.d.ts +2 -0
  282. package/dist/src/agent/inbound/turn-dispatcher.js +31 -13
  283. package/dist/src/agent/messaging/outbound-coordinator.js +2 -1
  284. package/dist/src/agent/prompt/service-prompt-builder.js +1 -1
  285. package/dist/src/agent/tools/xopc-use-tool.js +12 -1
  286. package/dist/src/channels/bundled-channel-extensions.d.ts +1 -0
  287. package/dist/src/channels/bundled-channel-extensions.js +15 -0
  288. package/dist/src/channels/connection-probe.d.ts +23 -0
  289. package/dist/src/channels/connection-probe.js +98 -0
  290. package/dist/src/channels/enterprise/config-surface.d.ts +1 -0
  291. package/dist/src/channels/enterprise/config-surface.js +19 -0
  292. package/dist/src/channels/enterprise/plugin.d.ts +39 -0
  293. package/dist/src/channels/enterprise/plugin.js +219 -0
  294. package/dist/src/channels/enterprise/setup.d.ts +34 -0
  295. package/dist/src/channels/enterprise/setup.js +262 -0
  296. package/dist/src/channels/enterprise/socket.d.ts +12 -0
  297. package/dist/src/channels/enterprise/socket.js +107 -0
  298. package/dist/src/channels/lifecycle-supervisor.js +11 -1
  299. package/dist/src/channels/manager.d.ts +2 -0
  300. package/dist/src/channels/manager.js +5 -0
  301. package/dist/src/channels/message-journal.d.ts +25 -0
  302. package/dist/src/channels/message-journal.js +79 -0
  303. package/dist/src/channels/outbound-sender.d.ts +8 -0
  304. package/dist/src/channels/outbound-sender.js +60 -1
  305. package/dist/src/channels/plugin-types.d.ts +9 -0
  306. package/dist/src/channels/plugins/types.adapters.d.ts +16 -0
  307. package/dist/src/channels/verified-inbound.js +20 -14
  308. package/dist/src/cli/commands/doctor/checks/database-schema.js +1 -1
  309. package/dist/src/extensions/activation-planner.js +8 -2
  310. package/dist/src/extensions/bundled-extension-activation.js +9 -0
  311. package/dist/src/gateway/hono/app.js +6 -2
  312. package/dist/src/gateway/hono/lib/config-payload.d.ts +1 -1
  313. package/dist/src/gateway/hono/lib/config-payload.js +2 -1
  314. package/dist/src/gateway/hono/routes/auth-registry-extensions.js +2 -1
  315. package/dist/src/gateway/hono/routes/channels.js +25 -11
  316. package/dist/src/gateway/hono/routes/lazy-bundles.js +8 -0
  317. package/dist/src/gateway/hono/routes/user-model.js +48 -20
  318. package/dist/src/gateway/hono/routes/video-generation.d.ts +3 -0
  319. package/dist/src/gateway/hono/routes/video-generation.js +166 -0
  320. package/dist/src/gateway/security/gateway-scopes.js +2 -0
  321. package/dist/src/gateway/service/session-input-coordinator.d.ts +2 -0
  322. package/dist/src/gateway/service/session-input-coordinator.js +11 -3
  323. package/dist/src/gateway/service.d.ts +1 -0
  324. package/dist/src/gateway/service.js +5 -1
  325. package/dist/src/infra/bus/index.d.ts +1 -1
  326. package/dist/src/infra/bus/queue.d.ts +16 -3
  327. package/dist/src/infra/bus/queue.js +74 -3
  328. package/dist/src/infra/debounce.d.ts +1 -0
  329. package/dist/src/infra/debounce.js +40 -35
  330. package/dist/src/knowledge-memory/index.js +2 -2
  331. package/dist/src/knowledge-memory/repository.d.ts +9 -0
  332. package/dist/src/knowledge-memory/repository.js +12 -2
  333. package/dist/src/runtime-tools/types.d.ts +1 -1
  334. package/dist/src/session/client-history.d.ts +1 -0
  335. package/dist/src/session/client-history.js +5 -6
  336. package/dist/src/session/store.js +4 -0
  337. package/dist/src/storage/sqlite/schema.d.ts +2 -2
  338. package/dist/src/storage/sqlite/schema.js +7 -7
  339. package/dist/src/storage/sqlite/schema.sql +31 -0
  340. package/dist/src/storage/sqlite/session-input-repository.js +5 -2
  341. package/dist/src/storage/sqlite/transcript-repository.js +12 -0
  342. package/dist/src/storage/sqlite/upgrades/275_video_generation.sql +28 -0
  343. package/dist/src/storage/sqlite/upgrades/276_video_provider_selection.sql +11 -0
  344. package/dist/src/video-generation/artifact.d.ts +5 -0
  345. package/dist/src/video-generation/artifact.js +91 -0
  346. package/dist/src/video-generation/provider-types.d.ts +21 -0
  347. package/dist/src/video-generation/provider-types.js +14 -0
  348. package/dist/src/video-generation/providers.d.ts +15 -0
  349. package/dist/src/video-generation/providers.js +72 -0
  350. package/dist/src/video-generation/repository.d.ts +58 -0
  351. package/dist/src/video-generation/repository.js +91 -0
  352. package/dist/src/video-generation/seedance.d.ts +4 -0
  353. package/dist/src/video-generation/seedance.js +72 -0
  354. package/dist/src/video-generation/settings.d.ts +5 -0
  355. package/dist/src/video-generation/settings.js +25 -0
  356. package/dist/src/video-generation/wan.d.ts +9 -0
  357. package/dist/src/video-generation/wan.js +59 -0
  358. package/dist/src/video-generation/worker.d.ts +8 -0
  359. package/dist/src/video-generation/worker.js +98 -0
  360. package/package.json +5 -6
  361. package/dist/gateway/static/root/assets/agents-C2xG8f56.js +0 -77
  362. package/dist/gateway/static/root/assets/arrow-up-right-T72JbQ1Q.js +0 -1
  363. package/dist/gateway/static/root/assets/automation-task-card-D3WXVKRs.js +0 -2
  364. package/dist/gateway/static/root/assets/automations-workspace-2SOvmw-f.js +0 -9
  365. package/dist/gateway/static/root/assets/capabilities-page-rTjkjo71.js +0 -2
  366. package/dist/gateway/static/root/assets/capabilities-settings-panel-k5CcwhXN.js +0 -8
  367. package/dist/gateway/static/root/assets/channels-DvB2fwPI.js +0 -1
  368. package/dist/gateway/static/root/assets/chat-page-qnsMsF_s.js +0 -71
  369. package/dist/gateway/static/root/assets/extension-settings-page-DKAJE4h9.js +0 -1
  370. package/dist/gateway/static/root/assets/gateway-realtime-store-OaEqjNTb.js +0 -1
  371. package/dist/gateway/static/root/assets/index-BGA-G-Bp.css +0 -1
  372. package/dist/gateway/static/root/assets/index-pmlYYCCU.js +0 -11
  373. package/dist/gateway/static/root/assets/messages-e5MhDONm.js +0 -3
  374. package/dist/gateway/static/root/assets/new-chat-navigation-B6NPQ4h4.js +0 -1
  375. package/dist/gateway/static/root/assets/note-image-lightbox-DcDw5kp4.js +0 -1
  376. package/dist/gateway/static/root/assets/page-header-store-DeaRqZgV.js +0 -1
  377. package/dist/gateway/static/root/assets/personal-page-gMRmLCWG.js +0 -1
  378. package/dist/gateway/static/root/assets/product-delivery-BFfqdKLe.js +0 -1
  379. package/dist/gateway/static/root/assets/product-preview-modal-D9f-7kcI.js +0 -2
  380. package/dist/gateway/static/root/assets/project-detail-page-C4Z2HTRZ.js +0 -7
  381. package/dist/gateway/static/root/assets/route-preload-5iwjWERk.js +0 -2
  382. package/dist/gateway/static/root/assets/schema-form-C9TYGa0_.js +0 -1
  383. package/dist/gateway/static/root/assets/session-manager-XgtApqIh.js +0 -25
  384. package/dist/gateway/static/root/assets/settings-advanced-gate-BBG8dTIY.js +0 -1
  385. package/dist/gateway/static/root/assets/task-detail-page-DmNEMg-l.js +0 -3
  386. package/dist/gateway/static/root/assets/understanding-refresh-store-Cf0DUO_C.js +0 -1
  387. package/dist/gateway/static/root/assets/user-model-page-CdB9qH57.js +0 -2
  388. package/dist/gateway/static/root/assets/workspace-editor-agent-store-C-J7vr2o.js +0 -1
@@ -1,7 +1,7 @@
1
1
  import { init_transaction, runSqliteWriteTransaction } from "../../../storage/sqlite/transaction.js";
2
2
  import { createCollaborationRule, getCollaborationRule, listCollaborationRules, setCollaborationRuleStatus } from "../../../storage/sqlite/collaboration-rule-repository.js";
3
3
  import { getActiveUnderstandingConsent } from "../../../user-context/sources/consent-repository.js";
4
- import { KnowledgeReviewConflictError, deleteKnowledgeItem, getKnowledgeItem, listKnowledgeItems, reviewKnowledgeItem, searchKnowledgeItems, setKnowledgeScope } from "../../../knowledge-memory/repository.js";
4
+ import { KnowledgeReviewConflictError, deleteKnowledgeItem, getKnowledgeItem, listKnowledgeItems, listManagedWorkMemory, reviewKnowledgeItem, searchKnowledgeItems, setKnowledgeScope } from "../../../knowledge-memory/repository.js";
5
5
  import "../../../knowledge-memory/index.js";
6
6
  import { listUserAssertionEdges, listUserModelObservations } from "../../../user-model/observation-repository.js";
7
7
  import { createPriorityWindow, createUserGoal, listPriorityWindows, listUserGoals, setUserGoalStatus, updatePriorityWindow, updateUserGoal } from "../../../user-model/goals.js";
@@ -201,14 +201,14 @@ function matchesMobileSearch(item, query) {
201
201
  ])
202
202
  ].join(" ")).includes(query);
203
203
  }
204
- function encodeMobileCursor(item) {
205
- return Buffer.from(JSON.stringify([item.recordedAt, item.id])).toString("base64url");
204
+ function encodeTimeCursor(timestamp, id) {
205
+ return Buffer.from(JSON.stringify([timestamp, id])).toString("base64url");
206
206
  }
207
- function decodeMobileCursor(value) {
207
+ function decodeTimeCursor(value) {
208
208
  if (!value) return void 0;
209
209
  try {
210
210
  const parsed = JSON.parse(Buffer.from(value, "base64url").toString("utf8"));
211
- return Array.isArray(parsed) && typeof parsed[0] === "number" && typeof parsed[1] === "string" ? [parsed[0], parsed[1]] : void 0;
211
+ return Array.isArray(parsed) && typeof parsed[0] === "number" && Number.isSafeInteger(parsed[0]) && typeof parsed[1] === "string" ? [parsed[0], parsed[1]] : void 0;
212
212
  } catch {
213
213
  return;
214
214
  }
@@ -225,7 +225,7 @@ function registerUserModelRoutes(authenticated, deps) {
225
225
  sensitiveWritePolicy: userContext.userModel.sensitiveWritePolicy
226
226
  };
227
227
  };
228
- const snapshot = () => {
228
+ const snapshot = (aboutOnly = false) => {
229
229
  const rawAssertions = listUserAssertions({
230
230
  statuses: [
231
231
  "active",
@@ -240,10 +240,6 @@ function registerUserModelRoutes(authenticated, deps) {
240
240
  const assertions = rawAssertions.map((item) => assertionView(item, assertionSources.get(item.id) ?? []));
241
241
  const goals = listUserGoals();
242
242
  const priorities = listPriorityWindows();
243
- const knowledge = listKnowledgeItems({
244
- recordClass: "memory",
245
- limit: 1e3
246
- });
247
243
  const profile = getUserProfileSnapshot();
248
244
  const sources = listUnderstandingSourceGrants().map((source) => ({
249
245
  id: source.id,
@@ -254,23 +250,31 @@ function registerUserModelRoutes(authenticated, deps) {
254
250
  ...source.lastCollectedAt ? { lastCollectedAt: source.lastCollectedAt } : {},
255
251
  consent: getActiveUnderstandingConsent(source.id)
256
252
  }));
257
- return {
253
+ const about = {
258
254
  assertions,
259
- assertionEdges: listUserAssertionEdges(assertions.map((item) => item.id)),
260
- observations: listUserModelObservations({ limit: 500 }),
261
255
  goals,
262
256
  priorities,
263
257
  rules: listCollaborationRules(),
264
258
  ruleSuggestions: listActionRuleSuggestions(),
259
+ profile,
260
+ sources,
261
+ suggestedCallName: profile.callName || machineCallName(),
262
+ settings: memorySettings()
263
+ };
264
+ if (aboutOnly) return about;
265
+ const knowledge = listKnowledgeItems({
266
+ recordClass: "memory",
267
+ limit: 1e3
268
+ });
269
+ return {
270
+ ...about,
271
+ assertionEdges: listUserAssertionEdges(assertions.map((item) => item.id)),
272
+ observations: listUserModelObservations({ limit: 500 }),
265
273
  knowledge: knowledge.map((item) => ({
266
274
  ...item,
267
275
  version: memoryVersion(item)
268
276
  })),
269
277
  maintenance: { lastRun: listMemoryMaintenanceRuns(1)[0] ?? null },
270
- profile,
271
- sources,
272
- suggestedCallName: profile.callName || machineCallName(),
273
- settings: memorySettings(),
274
278
  counts: {
275
279
  activeAssertions: assertions.filter((item) => item.status === "active").length,
276
280
  reviewAssertions: assertions.filter((item) => item.status === "needs_review" || item.status === "conflicted").length,
@@ -280,7 +284,7 @@ function registerUserModelRoutes(authenticated, deps) {
280
284
  }
281
285
  };
282
286
  };
283
- authenticated.get("/api/user-model", (c) => c.json(snapshot()));
287
+ authenticated.get("/api/user-model", (c) => c.json(snapshot(c.req.query("view") === "about")));
284
288
  authenticated.patch("/api/user-model/settings", write, async (c) => {
285
289
  const input = await body(c);
286
290
  const memoryEnabled = input?.memoryEnabled;
@@ -433,7 +437,7 @@ function registerUserModelRoutes(authenticated, deps) {
433
437
  const limit = Number.isFinite(requestedLimit) ? Math.max(1, Math.min(50, Math.trunc(requestedLimit))) : 20;
434
438
  const query = normalizeMobileSearch(c.req.query("q"), 100);
435
439
  const cursorValue = c.req.query("cursor");
436
- const cursor = decodeMobileCursor(cursorValue);
440
+ const cursor = decodeTimeCursor(cursorValue);
437
441
  if (cursorValue && !cursor) return c.json({ error: "Invalid cursor" }, 400);
438
442
  const assertions = listUserAssertions({
439
443
  statuses: [
@@ -450,7 +454,7 @@ function registerUserModelRoutes(authenticated, deps) {
450
454
  const items = filtered.slice(0, limit);
451
455
  const result = {
452
456
  items,
453
- ...filtered.length > limit && items.length ? { nextCursor: encodeMobileCursor(items[items.length - 1]) } : {}
457
+ ...filtered.length > limit && items.length ? { nextCursor: encodeTimeCursor(items[items.length - 1].recordedAt, items[items.length - 1].id) } : {}
454
458
  };
455
459
  return c.json(result);
456
460
  }
@@ -736,6 +740,30 @@ function registerUserModelRoutes(authenticated, deps) {
736
740
  });
737
741
  authenticated.get("/api/knowledge-memory", (c) => {
738
742
  const query = c.req.query("q")?.trim();
743
+ if (c.req.query("view") === "manage") {
744
+ const cursor = c.req.query("cursor");
745
+ const before = cursor ? decodeTimeCursor(cursor) : void 0;
746
+ if (cursor && !before) return c.json({ error: "Invalid memory cursor" }, 400);
747
+ const limit = 24;
748
+ const records = listManagedWorkMemory({
749
+ query: query ?? "",
750
+ kind: c.req.query("kind"),
751
+ before: before && {
752
+ updatedAt: before[0],
753
+ id: before[1]
754
+ },
755
+ limit: limit + 1
756
+ });
757
+ const items = records.slice(0, limit);
758
+ const last = items.at(-1);
759
+ return c.json({
760
+ items: items.map((item) => ({
761
+ ...item,
762
+ version: memoryVersion(item)
763
+ })),
764
+ ...last && records.length > limit ? { nextCursor: encodeTimeCursor(last.updatedAt, last.id) } : {}
765
+ });
766
+ }
739
767
  if (!query) return c.json({ items: listKnowledgeItems({
740
768
  recordClass: "memory",
741
769
  limit: 500
@@ -0,0 +1,3 @@
1
+ import type { Hono } from 'hono';
2
+ import type { AuthenticatedRouteDeps } from './deps.js';
3
+ export declare function registerVideoGenerationRoutes(app: Hono, deps: AuthenticatedRouteDeps): void;
@@ -0,0 +1,166 @@
1
+ import { VIDEO_IMAGE_MAX_BYTES, VIDEO_MODELS, VIDEO_MODEL_REFS, VIDEO_RESOLUTIONS, WAN_VIDEO_MODEL_REF, isVideoDurationSupported } from "../../../../packages/gateway-contract/src/video-generation.js";
2
+ import { init_src } from "../../../../packages/gateway-contract/src/index.js";
3
+ import { readMediaReference } from "../../../media/media-reference.js";
4
+ import { readVideoArtifact } from "../../../video-generation/artifact.js";
5
+ import { getVideoDefaults, getVideoModel, setVideoDefaults, setVideoModel } from "../../../video-generation/settings.js";
6
+ import { enqueueVideoJob, getVideoJob, listVideoJobs } from "../../../video-generation/repository.js";
7
+ import { getConfiguredVideoProviders, getVideoProvider } from "../../../video-generation/providers.js";
8
+ import { resolveScopedMediaReference } from "../../media-access.js";
9
+ import { createHash } from "node:crypto";
10
+ import { z } from "zod";
11
+ //#region src/gateway/hono/routes/video-generation.ts
12
+ init_src();
13
+ const settingsPath = "/api/video-generation/settings";
14
+ const modelSchema = z.enum(VIDEO_MODEL_REFS);
15
+ const path = "/api/video-generation/sessions/:conversationId/jobs";
16
+ const requestSchema = z.object({
17
+ id: z.string().uuid(),
18
+ modelRef: modelSchema.default(WAN_VIDEO_MODEL_REF),
19
+ transcriptId: z.string().min(1).max(128),
20
+ prompt: z.string().trim().min(1).max(1e3),
21
+ duration: z.coerce.number().int(),
22
+ ratio: z.enum([
23
+ "16:9",
24
+ "9:16",
25
+ "adaptive"
26
+ ]),
27
+ resolution: z.enum(VIDEO_RESOLUTIONS),
28
+ imageUri: z.string().startsWith("media://").max(512).nullable()
29
+ });
30
+ function imageMime(bytes) {
31
+ if (bytes.subarray(0, 8).equals(Buffer.from([
32
+ 137,
33
+ 80,
34
+ 78,
35
+ 71,
36
+ 13,
37
+ 10,
38
+ 26,
39
+ 10
40
+ ]))) return "image/png";
41
+ if (bytes.subarray(0, 3).equals(Buffer.from([
42
+ 255,
43
+ 216,
44
+ 255
45
+ ]))) return "image/jpeg";
46
+ if (bytes.toString("ascii", 0, 4) === "RIFF" && bytes.toString("ascii", 8, 12) === "WEBP") return "image/webp";
47
+ }
48
+ async function videoSettings() {
49
+ const configured = await getConfiguredVideoProviders();
50
+ const modelRef = getVideoModel();
51
+ return {
52
+ modelRef,
53
+ defaults: getVideoDefaults(modelRef),
54
+ configured
55
+ };
56
+ }
57
+ function registerVideoGenerationRoutes(app, deps) {
58
+ app.get(settingsPath, async (c) => c.json(await videoSettings()));
59
+ app.put(settingsPath, deps.strictRateLimitMiddleware, async (c) => {
60
+ const parsed = z.object({ modelRef: modelSchema }).safeParse(await c.req.json().catch(() => null));
61
+ if (!parsed.success) return c.json({ error: "Unknown video generation model" }, 400);
62
+ setVideoModel(parsed.data.modelRef);
63
+ return c.json(await videoSettings());
64
+ });
65
+ app.patch(settingsPath, deps.strictRateLimitMiddleware, async (c) => {
66
+ const parsed = z.object({
67
+ modelRef: modelSchema,
68
+ duration: z.number().int(),
69
+ resolution: z.enum(VIDEO_RESOLUTIONS)
70
+ }).safeParse(await c.req.json().catch(() => null));
71
+ if (!parsed.success) return c.json({ error: "Invalid video defaults" }, 400);
72
+ const { modelRef, duration, resolution } = parsed.data;
73
+ const model = VIDEO_MODELS[modelRef];
74
+ if (!isVideoDurationSupported(model, duration) || !model.resolutions.includes(resolution)) return c.json({ error: "The selected model does not support these video defaults" }, 400);
75
+ setVideoDefaults(modelRef, {
76
+ duration,
77
+ resolution
78
+ });
79
+ return c.json(await videoSettings());
80
+ });
81
+ app.get(path, async (c) => {
82
+ const conversationId = c.req.param("conversationId");
83
+ const session = await deps.service.sessionIndexInstance.getSessionMetadata(conversationId);
84
+ if (!session?.transcriptId) return c.json({ error: "Conversation not found" }, 404);
85
+ const modelRef = getVideoModel();
86
+ const configured = Boolean(await getVideoProvider(modelRef).resolveKey().catch(() => void 0));
87
+ return c.json({
88
+ transcriptId: session.transcriptId,
89
+ modelRef,
90
+ configured,
91
+ defaults: getVideoDefaults(modelRef),
92
+ jobs: listVideoJobs(conversationId)
93
+ });
94
+ });
95
+ app.post(path, deps.strictRateLimitMiddleware, async (c) => {
96
+ const conversationId = c.req.param("conversationId");
97
+ if (!(await deps.service.sessionIndexInstance.getSessionMetadata(conversationId))?.transcriptId) return c.json({ error: "Conversation not found" }, 404);
98
+ const form = await c.req.formData().catch(() => null);
99
+ if (!form) return c.json({ error: "Invalid video request" }, 400);
100
+ const parsed = requestSchema.safeParse({
101
+ id: form.get("id"),
102
+ modelRef: form.get("modelRef") ?? void 0,
103
+ transcriptId: form.get("transcriptId"),
104
+ prompt: form.get("prompt"),
105
+ duration: form.get("duration"),
106
+ ratio: form.get("ratio"),
107
+ resolution: form.get("resolution"),
108
+ imageUri: form.get("imageUri")
109
+ });
110
+ if (!parsed.success) return c.json({ error: "Invalid video settings" }, 400);
111
+ const { imageUri, modelRef, ...request } = parsed.data;
112
+ const upload = form.get("image");
113
+ if (upload !== null && (!(upload instanceof File) || imageUri || !upload.size || upload.size > 5242880)) return c.json({ error: "Provide one PNG, JPEG or WebP image up to 5 MiB" }, 400);
114
+ const model = VIDEO_MODELS[modelRef];
115
+ const hasImage = Boolean(upload || imageUri);
116
+ if (!isVideoDurationSupported(model, request.duration) || !model.resolutions.includes(request.resolution) || hasImage && !model.imageRatios.includes(request.ratio)) return c.json({ error: "The selected model does not support these video settings" }, 400);
117
+ let bytes;
118
+ let imageName = null;
119
+ if (upload instanceof File) {
120
+ bytes = Buffer.from(await upload.arrayBuffer());
121
+ imageName = upload.name.slice(0, 160);
122
+ } else if (imageUri) try {
123
+ const media = await resolveScopedMediaReference(deps.service, imageUri, { conversationId });
124
+ bytes = (await readMediaReference(media.uri, VIDEO_IMAGE_MAX_BYTES)).buffer;
125
+ imageName = media.id;
126
+ } catch {
127
+ return c.json({ error: "Reference image is unavailable in this conversation or exceeds 5 MiB" }, 400);
128
+ }
129
+ const mime = bytes && imageMime(bytes);
130
+ if (bytes && !mime) return c.json({ error: "Reference image must be PNG, JPEG or WebP" }, 400);
131
+ if (bytes && model.provider === "volcengine-ark") {
132
+ const { default: sharp } = await import("sharp");
133
+ const size = await sharp(bytes, { limitInputPixels: 36e6 }).metadata().catch(() => void 0);
134
+ const width = size?.autoOrient.width ?? 0;
135
+ const height = size?.autoOrient.height ?? 0;
136
+ if (width < 300 || height < 300 || width > 6e3 || height > 6e3 || width / height < .4 || width / height > 2.5) return c.json({ error: "Seedance requires a readable image with sides of 300–6000 px and an aspect ratio of 0.4–2.5" }, 400);
137
+ }
138
+ const provider = getVideoProvider(modelRef);
139
+ if (!await provider.resolveKey().catch(() => void 0)) return c.json({ error: `Configure a ${provider.name} API key on the Gateway` }, 503);
140
+ const hash = createHash("sha256").update(JSON.stringify({
141
+ ...request,
142
+ imageName
143
+ }));
144
+ if (bytes) hash.update(bytes);
145
+ const result = enqueueVideoJob(conversationId, {
146
+ ...request,
147
+ modelRef,
148
+ imageName
149
+ }, hash.digest("hex"), bytes && mime ? {
150
+ bytes,
151
+ mime
152
+ } : void 0);
153
+ if (result.error === "budget_exhausted") return c.json({ error: "The Gateway video generation budget for today has been reached." }, 429);
154
+ if (result.error === "queue_full") return c.json({ error: "The video queue is full. Try again after a task completes." }, 429);
155
+ if (result.error === "model_changed") return c.json({ error: "The video model changed. Review the updated model before submitting." }, 409);
156
+ if (result.error) return c.json({ error: "The conversation or video request changed. Reopen the video form." }, 409);
157
+ return c.json(result.job, 202);
158
+ });
159
+ app.get(`${path}/:jobId/video`, async (c) => {
160
+ const job = getVideoJob(c.req.param("conversationId"), c.req.param("jobId"));
161
+ if (job?.state !== "completed") return c.json({ error: "Video not found" }, 404);
162
+ return readVideoArtifact(job.id, c.req.header("Range"), c.req.query("download") === "1");
163
+ });
164
+ }
165
+ //#endregion
166
+ export { registerVideoGenerationRoutes };
@@ -44,6 +44,8 @@ function requiredGatewayScope(method, path) {
44
44
  if (path === "/api/observability" || path.startsWith("/api/observability/")) return "gateway.admin";
45
45
  if (path.startsWith("/api/usage")) return "gateway.admin";
46
46
  if (path.startsWith("/api/agents") || path.startsWith("/api/models")) return methodScope(method, "agents.read", "gateway.admin");
47
+ if (path === "/api/video-generation/settings") return "gateway.admin";
48
+ if (path.startsWith("/api/video-generation/")) return methodScope(method, "sessions.read", "sessions.write");
47
49
  if (path.startsWith("/api/sessions") || path.startsWith("/api/side-chats")) return methodScope(method, "sessions.read", "sessions.write");
48
50
  if (path.startsWith("/api/tasks")) return methodScope(method, "tasks.read", "tasks.write");
49
51
  if (path === "/api/task-runs" || path.startsWith("/api/task-runs/")) return methodScope(method, "tasks.read", "tasks.write");
@@ -65,6 +65,8 @@ export declare class SessionInputCoordinator {
65
65
  attachments?: UserTurnAttachment[];
66
66
  sourceContexts?: AgentSourceContext[];
67
67
  voiceAgentInstruction?: boolean;
68
+ clientMessageId?: string;
69
+ onHandled?: () => void;
68
70
  }) => Promise<boolean>;
69
71
  emit: (type: string, payload: unknown) => void;
70
72
  });
@@ -108,7 +108,6 @@ var SessionInputCoordinator = class {
108
108
  const row = command.inputId ? getSessionInputById(conversationId, command.inputId) : void 0;
109
109
  if (!replay && command.action === "steer" && (!row || !canSteerContexts(this.snapshot(conversationId), row.origin, row.contextSnapshots))) throw new SessionInputControlConflict("This input cannot steer the active reply");
110
110
  const accepted = acceptSessionInputControl(conversationId, command);
111
- this.publish(conversationId);
112
111
  if (command.action === "steer") {
113
112
  if (!accepted.replay && row) try {
114
113
  if (!await this.steerInput(row, accepted.runId)) setSessionInputStatus(row.id, "interrupted", {
@@ -125,6 +124,7 @@ var SessionInputCoordinator = class {
125
124
  }
126
125
  return this.publish(conversationId);
127
126
  }
127
+ this.publish(conversationId);
128
128
  if (accepted.runId) await this.deps.interrupt?.(conversationId, accepted.runId, "user_stop");
129
129
  if ((command.action === "resume" || command.action === "send") && !accepted.replay) this.drain(conversationId);
130
130
  return this.publish(conversationId);
@@ -507,11 +507,19 @@ var SessionInputCoordinator = class {
507
507
  steerInput(row, runId) {
508
508
  const text = steeringText(row.content, row.contextSnapshots);
509
509
  const voiceAgentInstruction = isNaturalVoiceDelegation(row);
510
- if (!voiceAgentInstruction && !row.attachments?.length && !row.contextSnapshots?.length) return this.deps.steer(row.conversationId, text, runId);
510
+ const trackDelivery = row.origin.type === "endpoint";
511
+ if (!trackDelivery && !voiceAgentInstruction && !row.attachments?.length && !row.contextSnapshots?.length) return this.deps.steer(row.conversationId, text, runId);
511
512
  return this.deps.steer(row.conversationId, text, runId, {
512
513
  attachments: row.attachments,
513
514
  sourceContexts: row.contextSnapshots,
514
- ...voiceAgentInstruction ? { voiceAgentInstruction: true } : {}
515
+ ...voiceAgentInstruction ? { voiceAgentInstruction: true } : {},
516
+ ...trackDelivery ? {
517
+ clientMessageId: row.clientMessageId,
518
+ onHandled: () => {
519
+ const current = getSessionInputById(row.conversationId, row.id);
520
+ if (current?.status === "injecting" && current.targetRunId === runId) setSessionInputStatus(row.id, "completed");
521
+ }
522
+ } : {}
515
523
  });
516
524
  }
517
525
  async drain(conversationId) {
@@ -222,6 +222,7 @@ export declare class GatewayService {
222
222
  private loadDeferredExtensions;
223
223
  private schedulePostReadySidecars;
224
224
  private runPostReadySidecars;
225
+ private readonly videoGenerationWorker;
225
226
  start(): Promise<void>;
226
227
  private startRuntime;
227
228
  /** Called when the HTTP listener is bound (before deferred channel work). */
@@ -146,6 +146,7 @@ import { NotificationService } from "../notifications/service.js";
146
146
  import "../local-apps/index.js";
147
147
  import { TaskAllocationDispatcher } from "../tasks/task-allocation-service.js";
148
148
  import { TaskResultDeliveryService } from "../tasks/task-result-delivery-service.js";
149
+ import { VideoGenerationWorker } from "../video-generation/worker.js";
149
150
  import { scheduleGatewayUpdateCheck } from "../infra/update-startup.js";
150
151
  import { resolveChannelConnectDeferSet } from "./resolve-channel-connect-defer.js";
151
152
  import { restartGatewayProcessWithFreshPid } from "./respawn.js";
@@ -1346,6 +1347,7 @@ var GatewayService = class {
1346
1347
  }, `Deferred extension load failed: ${em}`);
1347
1348
  }
1348
1349
  }
1350
+ videoGenerationWorker = new VideoGenerationWorker();
1349
1351
  async start() {
1350
1352
  try {
1351
1353
  await this.startRuntime();
@@ -1587,6 +1589,7 @@ var GatewayService = class {
1587
1589
  await this.notesService.initialize();
1588
1590
  this.discussionLiveWorker.start();
1589
1591
  this.discussionSealer.start();
1592
+ this.videoGenerationWorker.start();
1590
1593
  this.discussionWorker.start();
1591
1594
  this.connectorSupervisor = startConnectorSupervisor({
1592
1595
  getConfig: () => this.config,
@@ -1752,6 +1755,7 @@ var GatewayService = class {
1752
1755
  this.homeIntelligenceHost = null;
1753
1756
  this.realtime.close();
1754
1757
  this.voiceRealtime.close();
1758
+ await this.videoGenerationWorker.stop();
1755
1759
  await this.discussionWorker.stop();
1756
1760
  await this.discussionSealer.stop();
1757
1761
  await this.discussionLiveWorker.stop();
@@ -1803,7 +1807,7 @@ var GatewayService = class {
1803
1807
  log.debug("Starting outbound message processor");
1804
1808
  while (this.running) try {
1805
1809
  const msg = await this.bus.consumeOutbound();
1806
- await this.channelManager.send(msg);
1810
+ await this.channelManager.sendQueuedOutboundMessage(msg);
1807
1811
  } catch (error) {
1808
1812
  if (error instanceof MessageBusShutdownError) break;
1809
1813
  const em = error instanceof Error ? error.message : String(error);
@@ -1,3 +1,3 @@
1
1
  export { bus, MessageBus, MessageBusShutdownError } from './queue.js';
2
- export type { MessageBusEvents } from './queue.js';
2
+ export type { InboundDelivery, MessageBusEvents } from './queue.js';
3
3
  export type { InboundMessage, OutboundMessage } from '../../channels/transport-types.js';
@@ -1,5 +1,9 @@
1
1
  import { EventEmitter } from 'events';
2
- import { InboundMessage, OutboundMessage } from '../../channels/transport-types.js';
2
+ import type { InboundMessage, OutboundMessage } from '../../channels/transport-types.js';
3
+ export type InboundDelivery = {
4
+ scope: string;
5
+ id: string;
6
+ };
3
7
  interface MessageBusEvents {
4
8
  inbound: (msg: InboundMessage) => void;
5
9
  outbound: (msg: OutboundMessage) => void;
@@ -16,8 +20,17 @@ declare class MessageBus extends EventEmitter {
16
20
  private inboundConsumers;
17
21
  private outboundConsumers;
18
22
  private isShutdown;
19
- publishInbound(msg: InboundMessage): Promise<void>;
20
- publishOutbound(msg: OutboundMessage): Promise<void>;
23
+ private readonly durableInboundJournals;
24
+ private readonly inboundReceipts;
25
+ private persistOutboundReply?;
26
+ publishInbound(msg: InboundMessage, delivery?: InboundDelivery, verify?: (msg: InboundMessage) => void): Promise<void>;
27
+ restoreDurableInbound(channel: string, scope: string, verify?: (msg: InboundMessage, acceptedAt: number) => void): void;
28
+ beginInboundProcessing(msg: InboundMessage): boolean;
29
+ finishInboundProcessing(msg: InboundMessage, completed: boolean): void;
30
+ private durableInboundJournal;
31
+ private enqueueInbound;
32
+ setOutboundReplyPersistence(persist: (msg: OutboundMessage, delivery: InboundDelivery) => boolean): void;
33
+ publishOutbound(msg: OutboundMessage, replyingTo?: InboundMessage): Promise<void>;
21
34
  consumeInbound(): Promise<InboundMessage>;
22
35
  consumeOutbound(): Promise<OutboundMessage>;
23
36
  /**
@@ -1,5 +1,11 @@
1
+ import { createLogger } from "../../utils/logger/index.js";
2
+ import { init_logger } from "../../utils/logger.js";
3
+ import { persistInboundAttachments } from "../../channels/attachments/inbound-persist.js";
4
+ import { ChannelMessageJournal } from "../../channels/message-journal.js";
1
5
  import { EventEmitter } from "events";
2
6
  //#region src/infra/bus/queue.ts
7
+ init_logger();
8
+ const log = createLogger("ChannelInbox");
3
9
  /**
4
10
  * Error thrown when MessageBus is shut down
5
11
  */
@@ -15,13 +21,77 @@ var MessageBus = class extends EventEmitter {
15
21
  inboundConsumers = [];
16
22
  outboundConsumers = [];
17
23
  isShutdown = false;
18
- async publishInbound(msg) {
19
- if (this.isShutdown) return;
24
+ durableInboundJournals = /* @__PURE__ */ new Map();
25
+ inboundReceipts = /* @__PURE__ */ new WeakMap();
26
+ persistOutboundReply;
27
+ async publishInbound(msg, delivery, verify) {
28
+ if (!delivery) {
29
+ if (!this.isShutdown) this.enqueueInbound(msg);
30
+ return;
31
+ }
32
+ const journal = this.durableInboundJournal(msg.channel, delivery.scope);
33
+ const attachments = await persistInboundAttachments(msg.attachments);
34
+ const payload = attachments ? {
35
+ ...msg,
36
+ attachments
37
+ } : msg;
38
+ if (!journal.accept([{
39
+ id: delivery.id,
40
+ payload
41
+ }]).length) return;
42
+ verify?.(payload);
43
+ this.inboundReceipts.set(payload, {
44
+ journal,
45
+ ...delivery
46
+ });
47
+ if (!this.isShutdown) this.enqueueInbound(payload);
48
+ }
49
+ restoreDurableInbound(channel, scope, verify) {
50
+ const key = JSON.stringify([channel, scope]);
51
+ if (this.durableInboundJournals.has(key)) return;
52
+ const journal = this.durableInboundJournal(channel, scope);
53
+ const interrupted = journal.recoverInterrupted();
54
+ if (interrupted) log.warn({
55
+ channel,
56
+ interrupted
57
+ }, "Channel inputs interrupted during execution");
58
+ for (const { id, payload, enqueuedAt } of journal.pending(500)) {
59
+ verify?.(payload, enqueuedAt);
60
+ this.inboundReceipts.set(payload, {
61
+ journal,
62
+ id,
63
+ scope
64
+ });
65
+ if (!this.isShutdown) this.enqueueInbound(payload);
66
+ }
67
+ }
68
+ beginInboundProcessing(msg) {
69
+ const receipt = this.inboundReceipts.get(msg);
70
+ return !receipt || receipt.journal.begin(receipt.id);
71
+ }
72
+ finishInboundProcessing(msg, completed) {
73
+ const receipt = this.inboundReceipts.get(msg);
74
+ receipt?.journal.finish(receipt.id, completed ? "completed" : "interrupted");
75
+ }
76
+ durableInboundJournal(channel, scope) {
77
+ const key = JSON.stringify([channel, scope]);
78
+ const existing = this.durableInboundJournals.get(key);
79
+ if (existing) return existing;
80
+ const journal = new ChannelMessageJournal(`${channel}:agent`, scope);
81
+ this.durableInboundJournals.set(key, journal);
82
+ return journal;
83
+ }
84
+ enqueueInbound(msg) {
20
85
  this.emit("inbound", msg);
21
86
  if (this.inboundConsumers.length > 0) this.inboundConsumers.shift()(msg);
22
87
  else this.inboundQueue.push(msg);
23
88
  }
24
- async publishOutbound(msg) {
89
+ setOutboundReplyPersistence(persist) {
90
+ this.persistOutboundReply = persist;
91
+ }
92
+ async publishOutbound(msg, replyingTo) {
93
+ const receipt = replyingTo && this.inboundReceipts.get(replyingTo);
94
+ if (receipt && this.persistOutboundReply && !this.persistOutboundReply(msg, receipt)) return;
25
95
  if (this.isShutdown) return;
26
96
  this.emit("outbound", msg);
27
97
  if (this.outboundConsumers.length > 0) this.outboundConsumers.shift()(msg);
@@ -71,6 +141,7 @@ var MessageBus = class extends EventEmitter {
71
141
  */
72
142
  reset() {
73
143
  this.isShutdown = false;
144
+ this.durableInboundJournals.clear();
74
145
  this.clear();
75
146
  }
76
147
  clear() {
@@ -11,6 +11,7 @@ export interface InboundDebounceOptions<T> {
11
11
  }
12
12
  export declare function createInboundDebouncer<T>(options: InboundDebounceOptions<T>): {
13
13
  enqueue: (item: T) => Promise<void>;
14
+ enqueueAndWait: (item: T) => Promise<void>;
14
15
  flushKey: (key: string) => Promise<void>;
15
16
  flushAll: () => Promise<void>;
16
17
  getBufferCount: () => number;
@@ -14,11 +14,7 @@ function createInboundDebouncer(options) {
14
14
  buffer.timeout = null;
15
15
  }
16
16
  if (buffer.items.length === 0) return;
17
- try {
18
- await onFlush(buffer.items);
19
- } catch (err) {
20
- onError?.(err, buffer.items);
21
- }
17
+ await process(buffer.items);
22
18
  }
23
19
  async function flushKey(key) {
24
20
  const buffer = buffers.get(key);
@@ -32,40 +28,48 @@ function createInboundDebouncer(options) {
32
28
  }, buffer.debounceMs);
33
29
  buffer.timeout.unref?.();
34
30
  }
35
- async function enqueue(item) {
31
+ async function process(entries) {
32
+ const items = entries.map((entry) => entry.item);
33
+ try {
34
+ await onFlush(items);
35
+ for (const entry of entries) entry.resolve?.();
36
+ } catch (err) {
37
+ for (const entry of entries) entry.reject?.(err);
38
+ onError?.(err, items);
39
+ }
40
+ }
41
+ async function enqueueEntry(entry) {
42
+ const { item } = entry;
36
43
  const key = buildKey(item);
37
44
  const debounceMs = resolveMs(item);
38
- if (!(debounceMs > 0 && (shouldDebounce?.(item) ?? true))) {
39
- if (key && buffers.has(key)) await flushKey(key);
40
- try {
41
- await onFlush([item]);
42
- } catch (err) {
43
- onError?.(err, [item]);
44
- }
45
- return;
46
- }
47
- if (!key) {
48
- try {
49
- await onFlush([item]);
50
- } catch (err) {
51
- onError?.(err, [item]);
52
- }
45
+ const canDebounce = debounceMs > 0 && (shouldDebounce?.(item) ?? true);
46
+ if (!key || !canDebounce) {
47
+ if (key) await flushKey(key);
48
+ await process([entry]);
53
49
  return;
54
50
  }
55
- const existing = buffers.get(key);
56
- if (existing) {
57
- existing.items.push(item);
58
- existing.debounceMs = debounceMs;
59
- scheduleFlush(key, existing);
60
- } else {
61
- const buffer = {
62
- items: [item],
63
- timeout: null,
64
- debounceMs
65
- };
66
- buffers.set(key, buffer);
67
- scheduleFlush(key, buffer);
68
- }
51
+ const buffer = buffers.get(key) ?? {
52
+ items: [],
53
+ timeout: null,
54
+ debounceMs
55
+ };
56
+ buffer.items.push(entry);
57
+ buffer.debounceMs = debounceMs;
58
+ buffers.set(key, buffer);
59
+ scheduleFlush(key, buffer);
60
+ }
61
+ function enqueue(item) {
62
+ return enqueueEntry({ item });
63
+ }
64
+ /** Resolve only after buffered items are dispatched. Used by durable ingress. */
65
+ function enqueueAndWait(item) {
66
+ return new Promise((resolve, reject) => {
67
+ enqueueEntry({
68
+ item,
69
+ resolve,
70
+ reject
71
+ }).catch(reject);
72
+ });
69
73
  }
70
74
  async function flushAll() {
71
75
  const keys = Array.from(buffers.keys());
@@ -76,6 +80,7 @@ function createInboundDebouncer(options) {
76
80
  }
77
81
  return {
78
82
  enqueue,
83
+ enqueueAndWait,
79
84
  flushKey,
80
85
  flushAll,
81
86
  getBufferCount