@xopcai/xopc 0.0.309 → 0.0.311

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 (489) hide show
  1. package/dist/browser-ext/manifest.json +1 -1
  2. package/dist/extensions/telegram/xopc.extension.json +1 -1
  3. package/dist/gateway/static/root/assets/{activity-store-XKNYlFUI.js → activity-store-DVUTs1fk.js} +1 -1
  4. package/dist/gateway/static/root/assets/{agent-avatar-dicebear-1S2TFECE.js → agent-avatar-dicebear-zKINl7UH.js} +1 -1
  5. package/dist/gateway/static/root/assets/agent-defaults-settings-panel-D2ePZKdY.js +1 -0
  6. package/dist/gateway/static/root/assets/{agents-CPqUMtCL.js → agents-BiD9STyv.js} +1 -1
  7. package/dist/gateway/static/root/assets/{api-BEUEE4f2.js → api-_aHQA8bd.js} +1 -1
  8. package/dist/gateway/static/root/assets/{app-link-BiBXVEvp.js → app-link-wamYbNUl.js} +1 -1
  9. package/dist/gateway/static/root/assets/{app-management-settings-panel-CgVBSqzu.js → app-management-settings-panel-C94LAxyt.js} +1 -1
  10. package/dist/gateway/static/root/assets/{appearance-settings-CoWdCokb.js → appearance-settings-CP01zHvC.js} +1 -1
  11. package/dist/gateway/static/root/assets/apps-page-B7DmSJQj.js +1 -0
  12. package/dist/gateway/static/root/assets/{archive-plugin-C3ZA6LRS.js → archive-plugin-SwWFt5MT.js} +1 -1
  13. package/dist/gateway/static/root/assets/{attachment-load-CdgS6_zy.js → attachment-load-DdTFml9l.js} +1 -1
  14. package/dist/gateway/static/root/assets/{automations-page-BtHL2hpg.js → automations-page-Kmr5WVFp.js} +1 -1
  15. package/dist/gateway/static/root/assets/automations-workspace-bkijiu-Y.js +7 -0
  16. package/dist/gateway/static/root/assets/{binary-plugins-CiDhtq_H.js → binary-plugins-47UTtDNq.js} +1 -1
  17. package/dist/gateway/static/root/assets/{block-editor-Br00T83w.js → block-editor-DvzZkMG8.js} +3 -3
  18. package/dist/gateway/static/root/assets/{browser-automation-inputs-D2tILykA.js → browser-automation-inputs-C611KRBx.js} +1 -1
  19. package/dist/gateway/static/root/assets/{browser-automations-page-BVuEmryB.js → browser-automations-page-DrUKNL9X.js} +2 -2
  20. package/dist/gateway/static/root/assets/browser-settings-page-Dhf_MWCf.js +3 -0
  21. package/dist/gateway/static/root/assets/capabilities-settings-panel-BCubrDf8.js +8 -0
  22. package/dist/gateway/static/root/assets/channels-settings-e4T1DEfN.js +1 -0
  23. package/dist/gateway/static/root/assets/{chat-terminal-dock-JsMtzDao.js → chat-terminal-dock-Bg_m7HUE.js} +2 -2
  24. package/dist/gateway/static/root/assets/{chunk-KS7C4IRE-Cq1tE_3b.js → chunk-KS7C4IRE-BMYIfy9x.js} +2 -2
  25. package/dist/gateway/static/root/assets/computer-settings-page-CosCmVsT.js +1 -0
  26. package/dist/gateway/static/root/assets/{connector-service-page-DZFNUTiN.js → connector-service-page-BL-hSR7_.js} +1 -1
  27. package/dist/gateway/static/root/assets/connectors-page-C0WWxnxJ.js +2 -0
  28. package/dist/gateway/static/root/assets/date-picker-DqYFVasF.js +1 -0
  29. package/dist/gateway/static/root/assets/{dependency-picker-B-BcuG1y.js → dependency-picker-DCyyFLKp.js} +1 -1
  30. package/dist/gateway/static/root/assets/{desktop-pet-CdBBhhdY.js → desktop-pet-CFnnpRA_.js} +1 -1
  31. package/dist/gateway/static/root/assets/desktop-pet-settings-U5wWRH4c.js +1 -0
  32. package/dist/gateway/static/root/assets/device-pairing-wizard-BhHxvFO1.js +1 -0
  33. package/dist/gateway/static/root/assets/{extension-debug-page-BFp5eKtY.js → extension-debug-page-DA8WJ3-E.js} +1 -1
  34. package/dist/gateway/static/root/assets/{extension-page-DL3vyyH6.js → extension-page-C2BIB88m.js} +1 -1
  35. package/dist/gateway/static/root/assets/{extension-settings-page-BXtvdAsY.js → extension-settings-page-kpYo979N.js} +1 -1
  36. package/dist/gateway/static/root/assets/{gateway-config-swr-xAOGtenO.js → gateway-config-swr-DUDX42qY.js} +1 -1
  37. package/dist/gateway/static/root/assets/{gateway-realtime-BuaTsMSi.js → gateway-realtime-CGOW0-b4.js} +1 -1
  38. package/dist/gateway/static/root/assets/gateway-realtime-store-D4um_sV7.js +1 -0
  39. package/dist/gateway/static/root/assets/gateway-settings-CE9t1yTa.js +1 -0
  40. package/dist/gateway/static/root/assets/{gateway-startup-retry-BwDxKHd4.js → gateway-startup-retry-Cf8OxlvY.js} +1 -1
  41. package/dist/gateway/static/root/assets/home-page-C7Ezx8Du.js +1 -0
  42. package/dist/gateway/static/root/assets/{image-generation-api-wGMeI_yW.js → image-generation-api-D2YorS--.js} +1 -1
  43. package/dist/gateway/static/root/assets/{imports-page-zexFT5Rq.js → imports-page-NPk698vI.js} +1 -1
  44. package/dist/gateway/static/root/assets/index-1wIKA-kM.css +1 -0
  45. package/dist/gateway/static/root/assets/index-DxYitLp8.js +79 -0
  46. package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-CutG9zLh.js → keyboard-shortcuts-settings-BhreF0_O.js} +1 -1
  47. package/dist/gateway/static/root/assets/local-app-workbench-page-CPmynb3x.js +2 -0
  48. package/dist/gateway/static/root/assets/{local-apps-page-CJy6I7Dt.js → local-apps-page-DOZZBdqj.js} +1 -1
  49. package/dist/gateway/static/root/assets/{locale-store-DPZ79W1-.js → locale-store-DA0Z5jM_.js} +1 -1
  50. package/dist/gateway/static/root/assets/{logs-page-egGcPHNi.js → logs-page-M8kz26yo.js} +2 -2
  51. package/dist/gateway/static/root/assets/{management-settings-BQhIOELc.js → management-settings-JLqHYQvY.js} +1 -1
  52. package/dist/gateway/static/root/assets/{markdown-view-p2P5hP1U.js → markdown-view-BDpcjR_Z.js} +1 -1
  53. package/dist/gateway/static/root/assets/markdown-view-DSjfHfaW.css +1 -0
  54. package/dist/gateway/static/root/assets/{media-plugins-CsBylqlN.js → media-plugins-B75SWUJd.js} +1 -1
  55. package/dist/gateway/static/root/assets/messages-4BtQKYlM.js +3 -0
  56. package/dist/gateway/static/root/assets/note-detail-panel-B_Ft0M32.js +5 -0
  57. package/dist/gateway/static/root/assets/notes-page-C32mxSD-.js +8 -0
  58. package/dist/gateway/static/root/assets/{page-tabs-ChQ4jJFs.js → page-tabs-CMlQUzT6.js} +1 -1
  59. package/dist/gateway/static/root/assets/{popover-select-9i-ZtHXL.js → popover-select-B-GDnZO9.js} +1 -1
  60. package/dist/gateway/static/root/assets/preview-open-alternatives-cZ2hszQT.js +1 -0
  61. package/dist/gateway/static/root/assets/{product-open-page-BADxWEdP.js → product-open-page-CPoSbglF.js} +1 -1
  62. package/dist/gateway/static/root/assets/project-detail-page-DYttWua0.js +1 -0
  63. package/dist/gateway/static/root/assets/projects-page-D46drWbl.js +1 -0
  64. package/dist/gateway/static/root/assets/{registry-api-B_e_nZSN.js → registry-api-C0DCx3wv.js} +1 -1
  65. package/dist/gateway/static/root/assets/remote-access-hub-C9n9Nuhi.js +1 -0
  66. package/dist/gateway/static/root/assets/{runtime-tools-settings-panel-D-pwiIyp.js → runtime-tools-settings-panel-bMLWRApp.js} +2 -2
  67. package/dist/gateway/static/root/assets/scenes-page-Dw3hmHAr.js +1 -0
  68. package/dist/gateway/static/root/assets/{schema-form-IWmb05DX.js → schema-form-UVJV_7AS.js} +1 -1
  69. package/dist/gateway/static/root/assets/sessions-page-C8P6ff91.js +1 -0
  70. package/dist/gateway/static/root/assets/settings-advanced-gate-whpUsAy3.js +1 -0
  71. package/dist/gateway/static/root/assets/{settings-form-section-B0veRBZs.js → settings-form-section-BqzOqonM.js} +1 -1
  72. package/dist/gateway/static/root/assets/settings-page-DQ9RJ8-b.js +1 -0
  73. package/dist/gateway/static/root/assets/settings-page-layout-D3Spald3.js +1 -0
  74. package/dist/gateway/static/root/assets/{settings-shell-layer-context-DCp6ykjQ.js → settings-shell-layer-context-BTQUDoJ2.js} +1 -1
  75. package/dist/gateway/static/root/assets/setup-status-panel-C8u601m8.js +1 -0
  76. package/dist/gateway/static/root/assets/{share-preview-page-CirpgkfD.js → share-preview-page-BcgYzA7y.js} +1 -1
  77. package/dist/gateway/static/root/assets/shares-settings-Bv-2rZ8e.js +1 -0
  78. package/dist/gateway/static/root/assets/skill-reload-api-LM-cgWUS.js +1 -0
  79. package/dist/gateway/static/root/assets/skills-page-ggmb7rCW.js +2 -0
  80. package/dist/gateway/static/root/assets/{skills-page.utils-B42mpWKV.js → skills-page.utils-ADABzrtk.js} +1 -1
  81. package/dist/gateway/static/root/assets/system-settings-panel-DfkcW_Za.js +1 -0
  82. package/dist/gateway/static/root/assets/task-detail-page-DC4yqDFd.js +1 -0
  83. package/dist/gateway/static/root/assets/{theme-store-BFbj_2Tu.js → theme-store-CegIlB8d.js} +1 -1
  84. package/dist/gateway/static/root/assets/tunnel-api-CTuwTdMm.js +1 -0
  85. package/dist/gateway/static/root/assets/use-autosave-5ZDd9XKh.js +1 -0
  86. package/dist/gateway/static/root/assets/user-model-page-BFKFhdZ0.js +2 -0
  87. package/dist/gateway/static/root/assets/{voice-api-key-field-BZbKQ8HT.js → voice-api-key-field-D3urfd-n.js} +1 -1
  88. package/dist/gateway/static/root/assets/{voice-config-api-SKCeQLrH.js → voice-config-api-DTyMdGOR.js} +1 -1
  89. package/dist/gateway/static/root/assets/{work-discovery-overlay-BRVTTXNG.js → work-discovery-overlay-JzM3Ylbs.js} +1 -1
  90. package/dist/gateway/static/root/assets/{workflow-run-setup-panel-D2kuwv5e.js → workflow-run-setup-panel-Bn2CtRdB.js} +2 -2
  91. package/dist/gateway/static/root/assets/workflows-page-BiCmt98A.js +6 -0
  92. package/dist/gateway/static/root/connector-icons/SOURCES.md +0 -2
  93. package/dist/gateway/static/root/index.html +17 -20
  94. package/dist/gateway/static/root/notification-sw.js +1 -1
  95. package/dist/package.js +1 -1
  96. package/dist/packages/gateway-contract/src/notifications.js +12 -11
  97. package/dist/packages/gateway-contract/src/proactive.js +6 -6
  98. package/dist/packages/gateway-contract/src/project-monitoring.js +4 -4
  99. package/dist/packages/gateway-contract/src/project-operating.js +1 -4
  100. package/dist/src/agent/agent-manager.d.ts +2 -6
  101. package/dist/src/agent/agent-manager.js +2 -1
  102. package/dist/src/agent/background-review/run-background-review.js +1 -1
  103. package/dist/src/agent/commands/command-registry.js +1 -1
  104. package/dist/src/agent/context/execution-scope.js +1 -1
  105. package/dist/src/agent/external-tools/cliProvider.d.ts +47 -0
  106. package/dist/src/agent/external-tools/cliProvider.js +317 -0
  107. package/dist/src/agent/external-tools/composio-provider.js +3 -3
  108. package/dist/src/agent/external-tools/gateway-tools.js +8 -2
  109. package/dist/src/agent/external-tools/index.js +6 -0
  110. package/dist/src/agent/external-tools/service.js +1 -1
  111. package/dist/src/agent/external-tools/types.d.ts +1 -1
  112. package/dist/src/agent/external-tools/types.js +1 -0
  113. package/dist/src/agent/mcp/bundle-mcp-runtime.js +1 -1
  114. package/dist/src/agent/mcp/oauth/mcp-oauth-manager.js +1 -1
  115. package/dist/src/agent/memory/turn-provenance.js +2 -1
  116. package/dist/src/agent/service/parse-outbound-session-key.js +1 -1
  117. package/dist/src/agent/service.js +1 -0
  118. package/dist/src/agent/service.types.d.ts +2 -0
  119. package/dist/src/agent/tools/factory.d.ts +2 -0
  120. package/dist/src/agent/tools/factory.js +3 -2
  121. package/dist/src/agent/tools/search/providers/xopc-cloud.d.ts +20 -0
  122. package/dist/src/agent/tools/search/providers/xopc-cloud.js +56 -0
  123. package/dist/src/agent/tools/search/registry.d.ts +4 -2
  124. package/dist/src/agent/tools/search/registry.js +5 -3
  125. package/dist/src/agent/tools/xopc-use-tool.d.ts +4 -2
  126. package/dist/src/agent/tools/xopc-use-tool.js +46 -43
  127. package/dist/src/automations/service/automation-service.d.ts +0 -4
  128. package/dist/src/automations/service/automation-service.js +0 -31
  129. package/dist/src/capabilities/store-connector.js +46 -0
  130. package/dist/src/cli/commands/doctor/checks/database-schema.js +1 -1
  131. package/dist/src/cli/commands/project.js +1 -1
  132. package/dist/src/config/schema.d.ts +4 -4
  133. package/dist/src/config/schema.js +2 -12
  134. package/dist/src/config/web-patch.js +0 -5
  135. package/dist/src/connectors/account-selection.d.ts +14 -0
  136. package/dist/src/connectors/account-selection.js +26 -0
  137. package/dist/src/connectors/china-catalog.js +93 -226
  138. package/dist/src/connectors/cli/adapterRegistry.d.ts +4 -0
  139. package/dist/src/connectors/cli/adapterRegistry.js +26 -0
  140. package/dist/src/connectors/cli/adapters/lark.d.ts +2 -0
  141. package/dist/src/connectors/cli/adapters/lark.js +143 -0
  142. package/dist/src/connectors/cli/adapters/larkShortcuts.d.ts +3 -0
  143. package/dist/src/connectors/cli/adapters/larkShortcuts.js +64 -0
  144. package/dist/src/connectors/cli/adapters/wecom.d.ts +2 -0
  145. package/dist/src/connectors/cli/adapters/wecom.js +97 -0
  146. package/dist/src/connectors/cli/adapters/wps365/bundle.js +575 -0
  147. package/dist/src/connectors/cli/adapters/wps365.d.ts +2 -0
  148. package/dist/src/connectors/cli/adapters/wps365.js +115 -0
  149. package/dist/src/connectors/cli/assets.d.ts +3 -0
  150. package/dist/src/connectors/cli/assets.js +44 -0
  151. package/dist/src/connectors/cli/authorization.d.ts +16 -0
  152. package/dist/src/connectors/cli/authorization.js +184 -0
  153. package/dist/src/connectors/cli/distributions.d.ts +4 -0
  154. package/dist/src/connectors/cli/distributions.js +69 -0
  155. package/dist/src/connectors/cli/installer.d.ts +5 -0
  156. package/dist/src/connectors/cli/installer.js +102 -0
  157. package/dist/src/connectors/cli/lifecycle.d.ts +1 -0
  158. package/dist/src/connectors/cli/lifecycle.js +19 -0
  159. package/dist/src/connectors/cli/process.d.ts +18 -0
  160. package/dist/src/connectors/cli/process.js +100 -0
  161. package/dist/src/connectors/cli/protocol.d.ts +10 -0
  162. package/dist/src/connectors/cli/protocol.js +63 -0
  163. package/dist/src/connectors/cli/runtime.d.ts +10 -0
  164. package/dist/src/connectors/cli/runtime.js +93 -0
  165. package/dist/src/connectors/cli/store.d.ts +35 -0
  166. package/dist/src/connectors/cli/store.js +121 -0
  167. package/dist/src/connectors/cli/types.d.ts +73 -0
  168. package/dist/src/connectors/composio-backends.js +1 -1
  169. package/dist/src/connectors/composio-sessions.d.ts +1 -0
  170. package/dist/src/connectors/composio-sessions.js +8 -3
  171. package/dist/src/connectors/composio.js +1 -1
  172. package/dist/src/connectors/connection-candidates.js +22 -3
  173. package/dist/src/connectors/connection-recovery-service.d.ts +1 -0
  174. package/dist/src/connectors/connection-recovery-service.js +53 -8
  175. package/dist/src/connectors/health.js +52 -0
  176. package/dist/src/connectors/instances.js +5 -1
  177. package/dist/src/connectors/lifecycle.js +2 -0
  178. package/dist/src/connectors/principal.js +2 -1
  179. package/dist/src/connectors/runtime-adapter-registry.js +31 -0
  180. package/dist/src/connectors/types.d.ts +13 -1
  181. package/dist/src/connectors/usage.js +1 -1
  182. package/dist/src/connectors/workflow-preflight.js +8 -4
  183. package/dist/src/extensions/install.js +1 -1
  184. package/dist/src/gateway/hono/app.d.ts +2 -0
  185. package/dist/src/gateway/hono/app.js +4 -2
  186. package/dist/src/gateway/hono/lib/config-payload.d.ts +0 -15
  187. package/dist/src/gateway/hono/lib/config-payload.js +0 -11
  188. package/dist/src/gateway/hono/routes/cli-connectors.d.ts +3 -0
  189. package/dist/src/gateway/hono/routes/cli-connectors.js +219 -0
  190. package/dist/src/gateway/hono/routes/config-patch/gateway.d.ts +2 -2
  191. package/dist/src/gateway/hono/routes/config-patch/gateway.js +0 -59
  192. package/dist/src/gateway/hono/routes/config.js +0 -16
  193. package/dist/src/gateway/hono/routes/connectors.js +21 -22
  194. package/dist/src/gateway/hono/routes/deps.d.ts +2 -0
  195. package/dist/src/gateway/hono/routes/lazy-bundles.js +4 -17
  196. package/dist/src/gateway/hono/routes/projects.js +1 -1
  197. package/dist/src/gateway/hono/routes/public-gateway.js +0 -1
  198. package/dist/src/gateway/hono/routes/scenes.d.ts +3 -0
  199. package/dist/src/gateway/hono/routes/scenes.js +142 -0
  200. package/dist/src/gateway/hono/routes/tasks.js +0 -46
  201. package/dist/src/gateway/hono/routes/user-model.js +54 -1
  202. package/dist/src/gateway/scenes/browserNotifications.d.ts +4 -0
  203. package/dist/src/gateway/scenes/browserNotifications.js +54 -0
  204. package/dist/src/gateway/scenes/host.d.ts +34 -0
  205. package/dist/src/gateway/scenes/host.js +129 -0
  206. package/dist/src/gateway/scenes/mailContext.d.ts +32 -0
  207. package/dist/src/gateway/scenes/mailContext.js +235 -0
  208. package/dist/src/gateway/security/gateway-scopes.js +0 -4
  209. package/dist/src/gateway/security/index.js +1 -1
  210. package/dist/src/gateway/service/config-coordinator.d.ts +1 -10
  211. package/dist/src/gateway/service/config-coordinator.js +0 -16
  212. package/dist/src/gateway/service/run-gateway-agent.js +1 -1
  213. package/dist/src/gateway/service.d.ts +4 -25
  214. package/dist/src/gateway/service.js +44 -99
  215. package/dist/src/gateway/session-context-summary.js +2 -1
  216. package/dist/src/heartbeat/index.js +1 -1
  217. package/dist/src/infra/unhandled-rejections.js +1 -1
  218. package/dist/src/migrations/runner.js +1 -4
  219. package/dist/src/notifications/browser-endpoint.d.ts +2 -0
  220. package/dist/src/notifications/browser-endpoint.js +13 -0
  221. package/dist/src/notifications/browserSubscriptions.d.ts +20 -0
  222. package/dist/src/notifications/browserSubscriptions.js +59 -0
  223. package/dist/src/notifications/browserTransport.d.ts +9 -0
  224. package/dist/src/notifications/browserTransport.js +64 -0
  225. package/dist/src/notifications/dispatch.d.ts +46 -0
  226. package/dist/src/notifications/dispatch.js +109 -0
  227. package/dist/src/notifications/domain-delivery.d.ts +21 -0
  228. package/dist/src/notifications/planner.js +0 -36
  229. package/dist/src/notifications/quietHours.d.ts +6 -0
  230. package/dist/src/notifications/quietHours.js +23 -0
  231. package/dist/src/notifications/resultOutbox.d.ts +23 -0
  232. package/dist/src/notifications/resultOutbox.js +49 -0
  233. package/dist/src/notifications/service.d.ts +18 -4
  234. package/dist/src/notifications/service.js +42 -61
  235. package/dist/src/notifications/store.d.ts +2 -1
  236. package/dist/src/notifications/store.js +7 -8
  237. package/dist/src/projects/project-service.d.ts +1 -4
  238. package/dist/src/projects/project-service.js +2 -30
  239. package/dist/src/projects/workspace.js +1 -1
  240. package/dist/src/providers/model-catalog-persistence.js +19 -1
  241. package/dist/src/providers/model-catalog-store.js +1 -0
  242. package/dist/src/providers/model-catalog-types.d.ts +17 -0
  243. package/dist/src/providers/xopc-cloud-model-source.js +27 -0
  244. package/dist/src/scenes/agentExecutor.d.ts +8 -0
  245. package/dist/src/scenes/agentExecutor.js +63 -0
  246. package/dist/src/scenes/contracts.d.ts +118 -0
  247. package/dist/src/scenes/contracts.js +145 -0
  248. package/dist/src/scenes/execution.d.ts +56 -0
  249. package/dist/src/scenes/execution.js +168 -0
  250. package/dist/src/scenes/httpServices.d.ts +34 -0
  251. package/dist/src/scenes/inbox.d.ts +16 -0
  252. package/dist/src/scenes/inbox.js +68 -0
  253. package/dist/src/scenes/mailContext.d.ts +20 -0
  254. package/dist/src/scenes/mailContext.js +106 -0
  255. package/dist/src/scenes/mailObservations.d.ts +20 -0
  256. package/dist/src/scenes/mailObservations.js +107 -0
  257. package/dist/src/scenes/maintenance.d.ts +3 -0
  258. package/dist/src/scenes/maintenance.js +24 -0
  259. package/dist/src/scenes/metrics.d.ts +35 -0
  260. package/dist/src/scenes/metrics.js +94 -0
  261. package/dist/src/scenes/notificationEligibility.d.ts +17 -0
  262. package/dist/src/scenes/notificationEligibility.js +72 -0
  263. package/dist/src/scenes/notificationPublication.d.ts +7 -0
  264. package/dist/src/scenes/notificationPublication.js +43 -0
  265. package/dist/src/scenes/preferences.d.ts +40 -0
  266. package/dist/src/scenes/preferences.js +108 -0
  267. package/dist/src/scenes/readiness.d.ts +7 -0
  268. package/dist/src/scenes/readiness.js +20 -0
  269. package/dist/src/scenes/repository.d.ts +174 -0
  270. package/dist/src/scenes/repository.js +740 -0
  271. package/dist/src/scenes/resultNotifications.d.ts +17 -0
  272. package/dist/src/scenes/resultNotifications.js +204 -0
  273. package/dist/src/scenes/runtime.d.ts +25 -0
  274. package/dist/src/scenes/runtime.js +101 -0
  275. package/dist/src/scenes/schedule.d.ts +9 -0
  276. package/dist/src/scenes/schedule.js +45 -0
  277. package/dist/src/scenes/service.d.ts +29 -0
  278. package/dist/src/scenes/service.js +116 -0
  279. package/dist/src/scenes/templates.d.ts +64 -0
  280. package/dist/src/scenes/templates.js +76 -0
  281. package/dist/src/scenes/userNotes.d.ts +10 -0
  282. package/dist/src/scenes/userNotes.js +34 -0
  283. package/dist/src/session/resolve-session.js +2 -1
  284. package/dist/src/session/store.js +2 -1
  285. package/dist/src/share/share-config.js +0 -5
  286. package/dist/src/share/site-share-config.js +0 -5
  287. package/dist/src/storage/sqlite/connection-wait-repository.js +20 -7
  288. package/dist/src/storage/sqlite/connection.js +1 -1
  289. package/dist/src/storage/sqlite/connector-account-repository.js +1 -0
  290. package/dist/src/storage/sqlite/connector-sync-policy-repository.d.ts +0 -4
  291. package/dist/src/storage/sqlite/connector-sync-policy-repository.js +3 -17
  292. package/dist/src/storage/sqlite/conversation-repository.js +2 -1
  293. package/dist/src/storage/sqlite/index.js +2 -1
  294. package/dist/src/storage/sqlite/migrations/187_cli_connectors.sql +34 -0
  295. package/dist/src/storage/sqlite/migrations/188_scene_storage.sql +2 -0
  296. package/dist/src/storage/sqlite/migrations/189_scene_source_health.sql +8 -0
  297. package/dist/src/storage/sqlite/migrations/conversation-backup.d.ts +2 -0
  298. package/dist/src/storage/sqlite/migrations/conversation-backup.js +7 -3
  299. package/dist/src/storage/sqlite/migrations/runner.d.ts +1 -1
  300. package/dist/src/storage/sqlite/migrations/runner.js +20 -44
  301. package/dist/src/storage/sqlite/migrations/scene-reset.d.ts +5 -0
  302. package/dist/src/storage/sqlite/migrations/scene-reset.js +40 -0
  303. package/dist/src/storage/sqlite/scenes-schema.d.ts +8 -0
  304. package/dist/src/storage/sqlite/scenes-schema.js +61 -0
  305. package/dist/src/storage/sqlite/schema.js +4 -10
  306. package/dist/src/storage/sqlite/schemas/notifications.sql +65 -0
  307. package/dist/src/storage/sqlite/schemas/scenes.sql +212 -0
  308. package/dist/src/storage/sqlite/session-read-repository.d.ts +8 -0
  309. package/dist/src/storage/sqlite/session-read-repository.js +35 -0
  310. package/dist/src/storage/sqlite/session-repository.d.ts +1 -1
  311. package/dist/src/storage/sqlite/session-repository.js +2 -25
  312. package/dist/src/storage/sqlite/sql-assets.d.ts +2 -0
  313. package/dist/src/storage/sqlite/sql-assets.js +18 -0
  314. package/dist/src/storage/sqlite/transaction.d.ts +2 -0
  315. package/dist/src/storage/sqlite/transaction.js +20 -1
  316. package/dist/src/tasks/home-query-service.d.ts +0 -2
  317. package/dist/src/tasks/home-query-service.js +13 -43
  318. package/dist/src/tasks/index.d.ts +0 -1
  319. package/dist/src/tasks/index.js +4 -5
  320. package/dist/src/tasks/project-operating-view-service.js +1 -4
  321. package/dist/src/tui/backends/embedded-backend.js +1 -1
  322. package/dist/src/tui/tui-commands.js +1 -1
  323. package/dist/src/user-model/goals.d.ts +10 -0
  324. package/dist/src/user-model/goals.js +29 -1
  325. package/dist/src/user-model/index.js +2 -2
  326. package/dist/src/voice/realtime/memory-context.js +2 -1
  327. package/dist/src/workflows/service/workflow-run-service.js +1 -1
  328. package/package.json +4 -2
  329. package/dist/gateway/static/root/assets/agent-defaults-settings-panel-f0-YFMUz.js +0 -1
  330. package/dist/gateway/static/root/assets/api-CN4id43t.js +0 -1
  331. package/dist/gateway/static/root/assets/apps-page-CexHOcWg.js +0 -1
  332. package/dist/gateway/static/root/assets/automations-workspace-onJPfmO6.js +0 -6
  333. package/dist/gateway/static/root/assets/browser-settings-page-BgVTyPFY.js +0 -3
  334. package/dist/gateway/static/root/assets/capabilities-settings-panel-Dra8wj1S.js +0 -8
  335. package/dist/gateway/static/root/assets/channels-settings-CkxiMDJ4.js +0 -1
  336. package/dist/gateway/static/root/assets/channels-status-swr-Dtder4G_.js +0 -1
  337. package/dist/gateway/static/root/assets/computer-settings-page-DHerePwo.js +0 -1
  338. package/dist/gateway/static/root/assets/connectors-page-cl9ZrV4D.js +0 -2
  339. package/dist/gateway/static/root/assets/cron-expression-DAhdv_Xv.js +0 -2
  340. package/dist/gateway/static/root/assets/date-picker-PacO1m3a.js +0 -1
  341. package/dist/gateway/static/root/assets/desktop-pet-settings-Gy03NgMI.js +0 -1
  342. package/dist/gateway/static/root/assets/device-pairing-wizard-aV25nKag.js +0 -1
  343. package/dist/gateway/static/root/assets/external-link-DjqjBmc3.js +0 -1
  344. package/dist/gateway/static/root/assets/gateway-realtime-store-BG95uGVW.js +0 -1
  345. package/dist/gateway/static/root/assets/gateway-settings-Dcr2Ikeh.js +0 -1
  346. package/dist/gateway/static/root/assets/globe-DSSGFWFn.js +0 -1
  347. package/dist/gateway/static/root/assets/heartbeat-settings-DOy3alvT.js +0 -1
  348. package/dist/gateway/static/root/assets/home-page-CDm3dGVy.js +0 -1
  349. package/dist/gateway/static/root/assets/index-D-vczw_0.css +0 -1
  350. package/dist/gateway/static/root/assets/index-DJo4DimT.js +0 -79
  351. package/dist/gateway/static/root/assets/loader-circle-CifKLtgG.js +0 -1
  352. package/dist/gateway/static/root/assets/local-app-workbench-page-CwLvTwjn.js +0 -2
  353. package/dist/gateway/static/root/assets/markdown-view-Y68dCxuc.css +0 -1
  354. package/dist/gateway/static/root/assets/messages-BiYTyLJr.js +0 -3
  355. package/dist/gateway/static/root/assets/note-detail-panel-c2k5Uz6X.js +0 -5
  356. package/dist/gateway/static/root/assets/notes-page-BLQWJMhf.js +0 -8
  357. package/dist/gateway/static/root/assets/preview-open-alternatives-9B5W7nVE.js +0 -1
  358. package/dist/gateway/static/root/assets/proactive-page-iOjI0d_e.js +0 -1
  359. package/dist/gateway/static/root/assets/project-detail-page-BcxbQn2M.js +0 -1
  360. package/dist/gateway/static/root/assets/projects-page-BuSvld0O.js +0 -1
  361. package/dist/gateway/static/root/assets/remote-access-hub-CFS8LQKW.js +0 -1
  362. package/dist/gateway/static/root/assets/sessions-page-DZjc__ok.js +0 -1
  363. package/dist/gateway/static/root/assets/settings-advanced-gate-C1SM5B93.js +0 -1
  364. package/dist/gateway/static/root/assets/settings-page-CxRWyWYe.js +0 -1
  365. package/dist/gateway/static/root/assets/settings-page-layout-X1x-2Cp9.js +0 -1
  366. package/dist/gateway/static/root/assets/setup-status-panel-D9Rl7Tec.js +0 -1
  367. package/dist/gateway/static/root/assets/shares-settings-CwCThBs0.js +0 -1
  368. package/dist/gateway/static/root/assets/skill-reload-api-DG6VGbOX.js +0 -1
  369. package/dist/gateway/static/root/assets/skills-page-BdRJ2vnL.js +0 -2
  370. package/dist/gateway/static/root/assets/system-settings-panel-DXIZpAvU.js +0 -1
  371. package/dist/gateway/static/root/assets/task-detail-page-QXo9LJly.js +0 -1
  372. package/dist/gateway/static/root/assets/tunnel-api-Db2guRdW.js +0 -1
  373. package/dist/gateway/static/root/assets/use-autosave-DDY9qoXZ.js +0 -1
  374. package/dist/gateway/static/root/assets/user-model-page-CzPmMkaO.js +0 -2
  375. package/dist/gateway/static/root/assets/workflows-page-CQXtiYtq.js +0 -6
  376. package/dist/gateway/static/root/connector-icons/wps-calendar.svg +0 -14
  377. package/dist/gateway/static/root/connector-icons/wps-mail.svg +0 -7
  378. package/dist/src/connectors/source-change-publisher.d.ts +0 -17
  379. package/dist/src/connectors/source-change-publisher.js +0 -151
  380. package/dist/src/gateway/heartbeat/check-store.d.ts +0 -18
  381. package/dist/src/gateway/heartbeat/check-store.js +0 -74
  382. package/dist/src/gateway/heartbeat/index.d.ts +0 -1
  383. package/dist/src/gateway/heartbeat/index.js +0 -2
  384. package/dist/src/gateway/heartbeat/service.d.ts +0 -55
  385. package/dist/src/gateway/heartbeat/service.js +0 -228
  386. package/dist/src/gateway/hono/routes/proactive-control.d.ts +0 -3
  387. package/dist/src/gateway/hono/routes/proactive-control.js +0 -135
  388. package/dist/src/gateway/hono/routes/proactive.d.ts +0 -4
  389. package/dist/src/gateway/hono/routes/proactive.js +0 -164
  390. package/dist/src/gateway/hono/routes/workspace.d.ts +0 -3
  391. package/dist/src/gateway/hono/routes/workspace.js +0 -62
  392. package/dist/src/gateway/workspace-heartbeat-path.d.ts +0 -3
  393. package/dist/src/gateway/workspace-heartbeat-path.js +0 -14
  394. package/dist/src/migrations/conversation-routing-config.d.ts +0 -2
  395. package/dist/src/migrations/conversation-routing-config.js +0 -42
  396. package/dist/src/notifications/proactive-channel.d.ts +0 -8
  397. package/dist/src/notifications/proactive-channel.js +0 -60
  398. package/dist/src/notifications/proactive-policy.d.ts +0 -3
  399. package/dist/src/notifications/proactive-policy.js +0 -35
  400. package/dist/src/notifications/web-push.d.ts +0 -19
  401. package/dist/src/notifications/web-push.js +0 -185
  402. package/dist/src/proactive/actions/service.d.ts +0 -1
  403. package/dist/src/proactive/actions/service.js +0 -82
  404. package/dist/src/proactive/events/envelope.d.ts +0 -2
  405. package/dist/src/proactive/events/envelope.js +0 -54
  406. package/dist/src/proactive/events/product-event-bridge.d.ts +0 -7
  407. package/dist/src/proactive/events/product-event-bridge.js +0 -87
  408. package/dist/src/proactive/events/publisher.d.ts +0 -4
  409. package/dist/src/proactive/events/repository.d.ts +0 -9
  410. package/dist/src/proactive/events/repository.js +0 -63
  411. package/dist/src/proactive/events/types.d.ts +0 -44
  412. package/dist/src/proactive/events/types.js +0 -15
  413. package/dist/src/proactive/execution/agent-executor.d.ts +0 -21
  414. package/dist/src/proactive/execution/agent-executor.js +0 -125
  415. package/dist/src/proactive/execution/authorization.d.ts +0 -7
  416. package/dist/src/proactive/execution/authorization.js +0 -71
  417. package/dist/src/proactive/execution/context.d.ts +0 -49
  418. package/dist/src/proactive/execution/context.js +0 -408
  419. package/dist/src/proactive/execution/insight.d.ts +0 -14
  420. package/dist/src/proactive/execution/insight.js +0 -132
  421. package/dist/src/proactive/execution/repository.d.ts +0 -28
  422. package/dist/src/proactive/execution/repository.js +0 -211
  423. package/dist/src/proactive/execution/types.d.ts +0 -80
  424. package/dist/src/proactive/execution/worker.d.ts +0 -15
  425. package/dist/src/proactive/execution/worker.js +0 -146
  426. package/dist/src/proactive/experience.d.ts +0 -89
  427. package/dist/src/proactive/experience.js +0 -195
  428. package/dist/src/proactive/follow-ups.d.ts +0 -128
  429. package/dist/src/proactive/follow-ups.js +0 -182
  430. package/dist/src/proactive/inbox/cards.d.ts +0 -21
  431. package/dist/src/proactive/inbox/cards.js +0 -276
  432. package/dist/src/proactive/inbox/delivery.d.ts +0 -6
  433. package/dist/src/proactive/inbox/delivery.js +0 -54
  434. package/dist/src/proactive/inbox/digest.d.ts +0 -8
  435. package/dist/src/proactive/inbox/digest.js +0 -123
  436. package/dist/src/proactive/inbox/lifecycle.d.ts +0 -4
  437. package/dist/src/proactive/inbox/lifecycle.js +0 -62
  438. package/dist/src/proactive/inbox/notification-policy.d.ts +0 -1
  439. package/dist/src/proactive/inbox/notification-policy.js +0 -25
  440. package/dist/src/proactive/inbox/repository.d.ts +0 -25
  441. package/dist/src/proactive/inbox/repository.js +0 -244
  442. package/dist/src/proactive/inbox/service.d.ts +0 -23
  443. package/dist/src/proactive/inbox/service.js +0 -46
  444. package/dist/src/proactive/inbox/types.d.ts +0 -64
  445. package/dist/src/proactive/inbox/worker.d.ts +0 -13
  446. package/dist/src/proactive/inbox/worker.js +0 -71
  447. package/dist/src/proactive/index.d.ts +0 -20
  448. package/dist/src/proactive/index.js +0 -14
  449. package/dist/src/proactive/mail-thread.d.ts +0 -13
  450. package/dist/src/proactive/mail-thread.js +0 -55
  451. package/dist/src/proactive/maintenance.d.ts +0 -4
  452. package/dist/src/proactive/maintenance.js +0 -28
  453. package/dist/src/proactive/metrics.d.ts +0 -10
  454. package/dist/src/proactive/metrics.js +0 -28
  455. package/dist/src/proactive/policy/presence.d.ts +0 -2
  456. package/dist/src/proactive/policy/presence.js +0 -30
  457. package/dist/src/proactive/policy/service.d.ts +0 -54
  458. package/dist/src/proactive/policy/service.js +0 -123
  459. package/dist/src/proactive/routing/batch-repository.d.ts +0 -27
  460. package/dist/src/proactive/routing/batch-repository.js +0 -57
  461. package/dist/src/proactive/routing/matcher.d.ts +0 -5
  462. package/dist/src/proactive/routing/matcher.js +0 -57
  463. package/dist/src/proactive/routing/types.d.ts +0 -44
  464. package/dist/src/proactive/routing/types.js +0 -1
  465. package/dist/src/proactive/scenarios/control.d.ts +0 -52
  466. package/dist/src/proactive/scenarios/control.js +0 -75
  467. package/dist/src/proactive/scenarios/prompt-composer.d.ts +0 -14
  468. package/dist/src/proactive/scenarios/prompt-composer.js +0 -26
  469. package/dist/src/proactive/scenarios/repository.d.ts +0 -23
  470. package/dist/src/proactive/scenarios/repository.js +0 -174
  471. package/dist/src/proactive/scenarios/service.d.ts +0 -15
  472. package/dist/src/proactive/scenarios/service.js +0 -26
  473. package/dist/src/proactive/scenarios/types.d.ts +0 -43
  474. package/dist/src/proactive/scenarios/types.js +0 -1
  475. package/dist/src/proactive/service.d.ts +0 -25
  476. package/dist/src/proactive/service.js +0 -78
  477. package/dist/src/proactive/source-freshness.d.ts +0 -8
  478. package/dist/src/proactive/source-freshness.js +0 -28
  479. package/dist/src/proactive/status.d.ts +0 -2
  480. package/dist/src/proactive/status.js +0 -22
  481. package/dist/src/proactive/temporal/schedule.d.ts +0 -3
  482. package/dist/src/proactive/temporal/schedule.js +0 -68
  483. package/dist/src/proactive/temporal/worker.d.ts +0 -17
  484. package/dist/src/proactive/temporal/worker.js +0 -129
  485. package/dist/src/tasks/project-monitoring-service.d.ts +0 -32
  486. package/dist/src/tasks/project-monitoring-service.js +0 -118
  487. /package/dist/src/{proactive/execution → connectors/cli}/types.js +0 -0
  488. /package/dist/src/{proactive/events/publisher.js → notifications/domain-delivery.js} +0 -0
  489. /package/dist/src/{proactive/inbox/types.js → scenes/httpServices.js} +0 -0
@@ -6,9 +6,11 @@ import { getRuntimeLogStats } from "../utils/logger/stats.js";
6
6
  import { createLogger } from "../utils/logger/index.js";
7
7
  import { init_logger } from "../utils/logger.js";
8
8
  import { closeXopcDatabase, openXopcDatabase } from "../storage/sqlite/connection.js";
9
+ import { getSqliteDatabase, init_transaction } from "../storage/sqlite/transaction.js";
9
10
  import { findSessionInput, init_session_input_repository, insertSessionInput } from "../storage/sqlite/session-input-repository.js";
10
11
  import { init_changes, notifyUserContextChange } from "../user-context/changes.js";
11
- import { getSessionMetadata, init_session_repository, patchSessionMetadata } from "../storage/sqlite/session-repository.js";
12
+ import { getSessionMetadata } from "../storage/sqlite/session-read-repository.js";
13
+ import { init_session_repository, patchSessionMetadata } from "../storage/sqlite/session-repository.js";
12
14
  import { getSessionConfig } from "../storage/sqlite/config-repository.js";
13
15
  import "../storage/sqlite/index.js";
14
16
  import { getAgentDefaultModelRef, init_schema } from "../config/schema.js";
@@ -33,13 +35,10 @@ import { resolveProjectAgentId } from "../projects/project-agent.js";
33
35
  import "../projects/index.js";
34
36
  import { resolveEffectiveGatewayPort } from "./host.js";
35
37
  import { onSessionTranscriptUpdate } from "../session/transcript-events.js";
36
- import { ProactiveScenarioService } from "../proactive/scenarios/service.js";
37
- import { ProactiveEventService } from "../proactive/service.js";
38
- import { TaskApplicationService } from "../tasks/task-application-service.js";
39
- import { ProactiveInboxService } from "../proactive/inbox/service.js";
40
38
  import { AutomationService } from "../automations/service/automation-service.js";
41
39
  import { onAutomationProductEvent, publishAutomationProductEvent } from "../automations/product-events.js";
42
40
  import "../automations/index.js";
41
+ import { TaskApplicationService } from "../tasks/task-application-service.js";
43
42
  import { TaskOutboxDispatcher } from "../tasks/task-outbox-dispatcher.js";
44
43
  import { TaskRunDispatcher } from "../tasks/task-run-dispatcher.js";
45
44
  import { TaskSignalService } from "../tasks/task-signal-service.js";
@@ -64,7 +63,6 @@ import { startConnectedKnowledgeCoordinator } from "../knowledge/coordinator.js"
64
63
  import "../knowledge/index.js";
65
64
  import { ConnectionRecoveryService } from "../connectors/connection-recovery-service.js";
66
65
  import { startConnectorLearningCoordinator } from "../connectors/learning-coordinator.js";
67
- import { ConnectedSourceChangePublisher } from "../connectors/source-change-publisher.js";
68
66
  import { startConnectorSupervisor } from "../connectors/supervisor.js";
69
67
  import { DiscussionService } from "../discussions/service.js";
70
68
  import { DiscussionOrganizer } from "../discussions/organizer.js";
@@ -79,7 +77,6 @@ import { prepareAutomationAgentSession } from "./automation-agent-session.js";
79
77
  import { stopTailscaleExposure } from "./tailscale-lifecycle.js";
80
78
  import { createBackgroundTask } from "../infra/background-task.js";
81
79
  import { buildTaskAgentContext } from "../agent/source-context/task-context.js";
82
- import { deliverProactiveCard } from "../proactive/inbox/delivery.js";
83
80
  import { WorkDiscoveryService } from "../work-discovery/service.js";
84
81
  import { buildVoiceMemoryContext } from "../voice/realtime/memory-context.js";
85
82
  import { buildVoicePersonaContext } from "../voice/realtime/persona-context.js";
@@ -91,8 +88,6 @@ import "../notes/index.js";
91
88
  import { buildWorkflowChildTools } from "../agent/workflow/workflow-child-tools.js";
92
89
  import { WorkflowRunService } from "../workflows/service/workflow-run-service.js";
93
90
  import { WorkflowSessionBridge } from "../workflows/service/workflow-session-bridge.js";
94
- import { HeartbeatService, heartbeatRunnerConfigFromConfig } from "./heartbeat/service.js";
95
- import "./heartbeat/index.js";
96
91
  import { EphemeralSideChatManager } from "./side-chat/manager.js";
97
92
  import { SideChatRunService } from "./side-chat/run-service.js";
98
93
  import "./side-chat/index.js";
@@ -113,13 +108,6 @@ import { LocalAppService } from "../local-apps/service.js";
113
108
  import "../local-apps/index.js";
114
109
  import { createRuntimeBrowserAutomationService } from "../browser/automations/runtime-service.js";
115
110
  import "../browser/automations/index.js";
116
- import { mapProductEventToProactive } from "../proactive/events/product-event-bridge.js";
117
- import { ReadonlyProactiveAgentExecutor } from "../proactive/execution/agent-executor.js";
118
- import { listInsights } from "../proactive/execution/repository.js";
119
- import { ProactiveWorker } from "../proactive/execution/worker.js";
120
- import { ProactiveTemporalWorker } from "../proactive/temporal/worker.js";
121
- import { ProactiveInboxWorker } from "../proactive/inbox/worker.js";
122
- import "../proactive/index.js";
123
111
  import { scheduleGatewayUpdateCheck } from "../infra/update-startup.js";
124
112
  import { resolveChannelConnectDeferSet } from "./resolve-channel-connect-defer.js";
125
113
  import { restartGatewayProcessWithFreshPid } from "./respawn.js";
@@ -134,6 +122,7 @@ import { DurableVoiceAgentBroker } from "../voice/realtime/agentBroker.js";
134
122
  import { reconcileMemoryMaintenanceAutomations } from "./memory-maintenance-automation-reconciler.js";
135
123
  import { GatewayReadiness } from "./startup-readiness.js";
136
124
  import { createGatewayStartupTrace } from "./startup-trace.js";
125
+ import { GatewaySceneHost } from "./scenes/host.js";
137
126
  import { applyAutomaticVoiceLanguage, inferProductLanguageFromEnvironment, initializeVoiceDefaults } from "../voice/language-profile.js";
138
127
  import crypto from "node:crypto";
139
128
  //#region src/gateway/service.ts
@@ -151,6 +140,7 @@ init_paths();
151
140
  init_package_version();
152
141
  init_resolve_route();
153
142
  init_session_key();
143
+ init_transaction();
154
144
  const log = createLogger("Gateway:Service");
155
145
  var GatewayService = class {
156
146
  bus;
@@ -163,7 +153,7 @@ var GatewayService = class {
163
153
  notesService;
164
154
  extensionLoader = null;
165
155
  extensionMetadataSnapshot = null;
166
- heartbeatService = null;
156
+ sceneHost = null;
167
157
  sessionIndex;
168
158
  running = false;
169
159
  startTime = Date.now();
@@ -287,7 +277,6 @@ var GatewayService = class {
287
277
  notificationService = null;
288
278
  connectorSupervisor = null;
289
279
  connectorLearningCoordinator = null;
290
- connectedSourceChangePublisher = null;
291
280
  connectedKnowledgeCoordinator = null;
292
281
  stopAutomationProductEventBridge = null;
293
282
  stopSessionTranscriptAutomationEvents = null;
@@ -329,25 +318,21 @@ var GatewayService = class {
329
318
  discussionSealer;
330
319
  /** Local user-created apps, their coder projects, previews, and installs. */
331
320
  localApps;
332
- /** Unified durable event spine for proactive scenarios. */
333
- proactiveScenarios = new ProactiveScenarioService();
334
- proactive = new ProactiveEventService(() => this.proactiveScenarios.routes());
335
- proactiveInbox = new ProactiveInboxService();
336
- proactiveInsights = listInsights;
337
- proactiveWorker;
338
- proactiveTemporalWorker;
339
- proactiveInboxWorker;
321
+ get sceneAccess() {
322
+ return this.sceneHost ? {
323
+ services: this.sceneHost.http,
324
+ principal: {
325
+ ownerId: "local-owner",
326
+ workspaceId: this.workspacePath
327
+ }
328
+ } : void 0;
329
+ }
340
330
  constructor(serviceConfig = {}) {
341
331
  this.serviceConfig = serviceConfig;
342
332
  this.bus = new MessageBus();
343
333
  this.configPath = serviceConfig.configPath || resolveConfigPath();
344
334
  runBootstrapMigrationsSync(this.configPath);
345
335
  this.config = loadConfig(this.configPath);
346
- this.proactiveWorker = new ProactiveWorker(new ReadonlyProactiveAgentExecutor(() => this.config));
347
- this.proactiveTemporalWorker = new ProactiveTemporalWorker(this.proactive);
348
- this.proactiveInboxWorker = new ProactiveInboxWorker({ deliver: async ({ inboxItem }) => {
349
- return deliverProactiveCard(inboxItem, this.createNotificationService(), (type, payload) => this.realtime.broker.publish("gateway", type, payload));
350
- } });
351
336
  let bootstrapConfigChanged = initializeVoiceDefaults(this.config, inferProductLanguageFromEnvironment());
352
337
  const starterResult = ensureStarterAgentsInitialized(this.config);
353
338
  if (starterResult.changed) {
@@ -401,9 +386,9 @@ var GatewayService = class {
401
386
  this.workspacePath = getWorkspacePath(this.config) || "./workspace";
402
387
  this.initializeExtensionLoader();
403
388
  this.sessionIndex = new SessionIndex({ config: this.config });
404
- this.automationService = new AutomationService(this.proactive, this.workspacePath);
389
+ this.automationService = new AutomationService();
405
390
  this.notesService = new NotesService(new NotesStore());
406
- this.projects = new ProjectService(void 0, this.proactive, this.workspacePath);
391
+ this.projects = new ProjectService();
407
392
  const emitDiscussion = (capture) => {
408
393
  this.emit("discussion.updated", capture);
409
394
  };
@@ -546,7 +531,6 @@ var GatewayService = class {
546
531
  },
547
532
  getAgentService: () => this.ensureAgentService(),
548
533
  getChannelManager: () => this.channelManager,
549
- getHeartbeatService: () => this.heartbeatService,
550
534
  getExtensionLoader: () => this.extensionLoader,
551
535
  reconcileMemoryMaintenanceAutomations: () => this.reconcileMemoryMaintenanceAutomations(),
552
536
  getChannelsStatus: () => this.getChannelsStatus(),
@@ -592,6 +576,7 @@ var GatewayService = class {
592
576
  extensionRegistry: this.extensionLoader?.getRegistry(),
593
577
  endpointTools: this.endpointTools,
594
578
  getAutomationService: () => this.automationService,
579
+ getSceneAccess: () => this.sceneAccess,
595
580
  getBrowserAutomationService: () => this.browserAutomations,
596
581
  emitBrowserEvent: (type, payload) => this.emit(type, payload),
597
582
  getNotesService: () => this.notesService,
@@ -666,17 +651,6 @@ var GatewayService = class {
666
651
  });
667
652
  return this._agentService;
668
653
  }
669
- ensureHeartbeatService() {
670
- if (this.heartbeatService) return this.heartbeatService;
671
- this.heartbeatService = new HeartbeatService({
672
- agentService: this.ensureAgentService(),
673
- messageBus: this.bus,
674
- sessionStore: this.sessionIndex.getStore(),
675
- getConfig: () => this.config,
676
- getWorkspace: () => this.workspacePath
677
- });
678
- return this.heartbeatService;
679
- }
680
654
  createTaskRunDispatcher() {
681
655
  if (!this.taskRunDispatcher) this.taskRunDispatcher = new TaskRunDispatcher({
682
656
  workerId: "gateway-agent",
@@ -712,21 +686,7 @@ var GatewayService = class {
712
686
  return this.taskRunDispatcher;
713
687
  }
714
688
  createNotificationService() {
715
- if (!this.notificationService) this.notificationService = new NotificationService({
716
- publish: (type, payload) => this.realtime.broker.publish("gateway", type, payload),
717
- sendChannel: async (target, text) => {
718
- const outbound = this.channelManager.getPlugin("telegram")?.outbound;
719
- if (!outbound?.sendText || !this.channelManager.getRunningChannels().includes("telegram")) throw new Error("Telegram is not connected");
720
- const result = await outbound.sendText({
721
- cfg: this.config,
722
- to: target.chatId,
723
- accountId: target.accountId,
724
- text
725
- });
726
- if (!result.success) throw new Error("Telegram delivery failed");
727
- return { messageId: result.messageId };
728
- }
729
- });
689
+ if (!this.notificationService) this.notificationService = new NotificationService({ publish: (type, payload) => this.realtime.broker.publish("gateway", type, payload) });
730
690
  return this.notificationService;
731
691
  }
732
692
  taskRunDispatch = createBackgroundTask(async () => {
@@ -967,6 +927,19 @@ var GatewayService = class {
967
927
  }
968
928
  }
969
929
  async start() {
930
+ try {
931
+ await this.startRuntime();
932
+ } catch (err) {
933
+ await this.stop().catch((cleanupError) => log.error({ err: cleanupError }, "Gateway startup cleanup failed"));
934
+ await this.sceneHost?.stop();
935
+ this.sceneHost = null;
936
+ this.stopRealtimeLogBridge?.();
937
+ this.stopRealtimeLogBridge = null;
938
+ setPairingBroadcastSink(null);
939
+ throw err;
940
+ }
941
+ }
942
+ async startRuntime() {
970
943
  if (this.running) return;
971
944
  this.stopRealtimeLogBridge = subscribeToLogs((entry) => {
972
945
  this.realtime.broker.publish("logs", "log.entry", entry);
@@ -983,9 +956,14 @@ var GatewayService = class {
983
956
  this.running = true;
984
957
  this.taskRunDispatchTimer = setInterval(() => this.dispatchTaskRuns(), 1e3);
985
958
  this.taskRunDispatchTimer.unref?.();
986
- this.proactiveWorker.start();
987
- this.proactiveTemporalWorker.start();
988
- this.proactiveInboxWorker.start();
959
+ this.sceneHost = new GatewaySceneHost(getSqliteDatabase(), {
960
+ principal: {
961
+ ownerId: "local-owner",
962
+ workspaceId: this.workspacePath
963
+ },
964
+ config: () => this.config,
965
+ publish: (type, notification) => this.realtime.broker.publish("gateway", type, notification)
966
+ });
989
967
  this.startupTrace = createGatewayStartupTrace();
990
968
  this.readiness.markStarting(this.startTime);
991
969
  const trace = this.startupTrace;
@@ -1128,7 +1106,6 @@ var GatewayService = class {
1128
1106
  this.discussionLiveWorker.start();
1129
1107
  this.discussionSealer.start();
1130
1108
  this.discussionWorker.start();
1131
- this.ensureHeartbeatService().start(heartbeatRunnerConfigFromConfig(this.config));
1132
1109
  this.connectorSupervisor = startConnectorSupervisor({
1133
1110
  getConfig: () => this.config,
1134
1111
  saveConfig: (cfg) => this.saveConfig(cfg)
@@ -1149,8 +1126,6 @@ var GatewayService = class {
1149
1126
  }
1150
1127
  });
1151
1128
  this.managedComposioEventPoller.start();
1152
- this.connectedSourceChangePublisher = new ConnectedSourceChangePublisher(this.proactive);
1153
- this.connectedSourceChangePublisher.start();
1154
1129
  this.connectedKnowledgeCoordinator = startConnectedKnowledgeCoordinator({ resolvePipelineOptions: () => ({
1155
1130
  agentId: resolveDefaultAgentId(this.config),
1156
1131
  workspaceId: this.currentWorkspacePath
@@ -1174,6 +1149,7 @@ var GatewayService = class {
1174
1149
  import("../share/share-auto.js").then(({ runStagingSweep }) => runStagingSweep([...new Set([getDefaultAgentId(this.config), ...listAgentEntries(this.config).map((entry) => entry.id)])].map((agentId) => resolveAgentWorkspaceDir(this.config, agentId)))).catch((err) => log.warn({ err }, "Share staging sweep failed"));
1175
1150
  if (this.serviceConfig.deferChannelConnectUntilAfterHttp !== true) this.markGatewayReady();
1176
1151
  else trace.mark("service.started-awaiting-http");
1152
+ this.sceneHost.start();
1177
1153
  log.debug("Gateway service started");
1178
1154
  }
1179
1155
  /** Called when the HTTP listener is bound (before deferred channel work). */
@@ -1267,14 +1243,13 @@ var GatewayService = class {
1267
1243
  this.readiness.markStarting();
1268
1244
  this.endpointTools.close();
1269
1245
  await this.sideChats.disposeAll();
1246
+ await this.sceneHost?.stop();
1247
+ this.sceneHost = null;
1270
1248
  this.realtime.close();
1271
1249
  this.voiceRealtime.close();
1272
- await this.proactiveWorker.stop();
1273
1250
  await this.discussionWorker.stop();
1274
1251
  await this.discussionSealer.stop();
1275
1252
  await this.discussionLiveWorker.stop();
1276
- this.proactiveTemporalWorker.stop();
1277
- await this.proactiveInboxWorker.stop();
1278
1253
  this.notificationService?.stop();
1279
1254
  if (this.taskRunDispatchTimer) {
1280
1255
  clearInterval(this.taskRunDispatchTimer);
@@ -1289,15 +1264,12 @@ var GatewayService = class {
1289
1264
  }
1290
1265
  this.modelCatalogSync.stop();
1291
1266
  await this.configCoordinator.stopHotReloader();
1292
- this.heartbeatService?.stop();
1293
1267
  this.connectorSupervisor?.stop();
1294
1268
  this.connectorSupervisor = null;
1295
1269
  this.connectorLearningCoordinator?.stop();
1296
1270
  this.connectorLearningCoordinator = null;
1297
1271
  this.managedComposioEventPoller?.stop();
1298
1272
  this.managedComposioEventPoller = void 0;
1299
- this.connectedSourceChangePublisher?.stop();
1300
- this.connectedSourceChangePublisher = null;
1301
1273
  this.connectedKnowledgeCoordinator?.stop();
1302
1274
  this.connectedKnowledgeCoordinator = null;
1303
1275
  await this.browserAutomationService?.shutdown();
@@ -1343,9 +1315,6 @@ var GatewayService = class {
1343
1315
  await new Promise((resolve) => setTimeout(resolve, 1e3));
1344
1316
  }
1345
1317
  }
1346
- reloadHeartbeatFromCurrentConfig() {
1347
- this.configCoordinator.reloadHeartbeatFromCurrentConfig();
1348
- }
1349
1318
  reloadConfig() {
1350
1319
  return this.configCoordinator.reloadConfig();
1351
1320
  }
@@ -1453,15 +1422,6 @@ var GatewayService = class {
1453
1422
  return a.id.localeCompare(b.id);
1454
1423
  });
1455
1424
  }
1456
- heartbeatStatus() {
1457
- return this.heartbeatService?.status() ?? null;
1458
- }
1459
- /**
1460
- * Request an immediate heartbeat run (coalesced like interval/cron wakes).
1461
- */
1462
- requestHeartbeatNow(opts) {
1463
- this.heartbeatService?.requestNow({ reason: opts?.reason ?? "manual" });
1464
- }
1465
1425
  requestConnectorLearning(connectionId, request) {
1466
1426
  return this.connectorLearningCoordinator?.enqueueConnection(connectionId, request) ?? null;
1467
1427
  }
@@ -1669,21 +1629,6 @@ var GatewayService = class {
1669
1629
  this.stopSessionTranscriptAutomationEvents?.();
1670
1630
  this.stopAutomationProductEventBridge = onAutomationProductEvent((event) => {
1671
1631
  if (event.type.startsWith("task.")) this.emit(event.type, event.payload);
1672
- const proactiveEvent = mapProductEventToProactive({
1673
- event,
1674
- workspaceId: this.currentWorkspacePath,
1675
- defaultAgentId: resolveDefaultAgentId(this.config)
1676
- });
1677
- if (proactiveEvent) try {
1678
- this.proactive.publish(proactiveEvent);
1679
- } catch (err) {
1680
- const em = err instanceof Error ? err.message : String(err);
1681
- log.warn({
1682
- err,
1683
- eventType: event.type,
1684
- source: event.source
1685
- }, `Proactive product event publication failed: ${em}`);
1686
- }
1687
1632
  this.automationService.triggerEvent(event).catch((err) => {
1688
1633
  const em = err instanceof Error ? err.message : String(err);
1689
1634
  log.warn({
@@ -2,7 +2,8 @@ import { createLogger } from "../utils/logger/index.js";
2
2
  import { init_logger } from "../utils/logger.js";
3
3
  import { getSqliteDatabase, init_transaction } from "../storage/sqlite/transaction.js";
4
4
  import { hasGatewayScope } from "./security/gateway-scopes.js";
5
- import { getSessionMetadata, init_session_repository } from "../storage/sqlite/session-repository.js";
5
+ import { getSessionMetadata } from "../storage/sqlite/session-read-repository.js";
6
+ import { init_session_repository } from "../storage/sqlite/session-repository.js";
6
7
  import { getSessionConfig } from "../storage/sqlite/config-repository.js";
7
8
  import { TaskRepository } from "../tasks/task-repository.js";
8
9
  import { TaskConversationRepository } from "../tasks/task-conversation-repository.js";
@@ -1,6 +1,6 @@
1
1
  import { DEFAULT_ACK_MAX_CHARS, HEARTBEAT_OK, NO_REPLY, shouldSilence, stripHeartbeatToken } from "./tokens.js";
2
- import { appendCronEventLines } from "./event-prompt.js";
3
2
  import { isWithinActiveHours } from "./active-hours.js";
4
3
  import { isHeartbeatContentEmpty } from "./content-check.js";
4
+ import { appendCronEventLines } from "./event-prompt.js";
5
5
  import { createHeartbeatWake } from "./wake.js";
6
6
  export { DEFAULT_ACK_MAX_CHARS, HEARTBEAT_OK, NO_REPLY, appendCronEventLines, createHeartbeatWake, isHeartbeatContentEmpty, isWithinActiveHours, shouldSilence, stripHeartbeatToken };
@@ -1,7 +1,7 @@
1
1
  import { __esmMin } from "../../_virtual/_rolldown/runtime.js";
2
- import { init_global_singleton, resolveGlobalSingleton } from "../utils/global-singleton.js";
3
2
  import { createLogger } from "../utils/logger/index.js";
4
3
  import { init_logger } from "../utils/logger.js";
4
+ import { init_global_singleton, resolveGlobalSingleton } from "../utils/global-singleton.js";
5
5
  import { init_process_diagnostics, recordProcessDiagnostic } from "./process-diagnostics.js";
6
6
  import { init_sqlite_errors, isTransientSqliteError } from "./sqlite-errors.js";
7
7
  //#region src/infra/unhandled-rejections.ts
@@ -2,7 +2,6 @@ import { createLogger } from "../utils/logger/index.js";
2
2
  import { init_logger } from "../utils/logger.js";
3
3
  import { ConfigSchema, init_schema } from "../config/schema.js";
4
4
  import { listRegisteredMigrations } from "./registry.js";
5
- import { conversationRoutingConfigMigration } from "./conversation-routing-config.js";
6
5
  import { memoryConfigMigration } from "./memory-config.js";
7
6
  import { dirname, join } from "node:path";
8
7
  import { existsSync, mkdirSync, readFileSync, renameSync, writeFileSync } from "node:fs";
@@ -12,7 +11,7 @@ init_logger();
12
11
  const log = createLogger("Migrations");
13
12
  const MIGRATION_LEDGER_FILENAME = "migrations.json";
14
13
  const CONFIG_BACKUP_COUNT = 10;
15
- const CORE_MIGRATIONS = [conversationRoutingConfigMigration, memoryConfigMigration];
14
+ const CORE_MIGRATIONS = [memoryConfigMigration];
16
15
  function listAllMigrations() {
17
16
  return [...CORE_MIGRATIONS, ...listRegisteredMigrations().map((entry) => entry.migration)];
18
17
  }
@@ -178,8 +177,6 @@ function runBootstrapMigrationsSync(configPath, options = {}) {
178
177
  ...options,
179
178
  mode: "auto-safe"
180
179
  });
181
- const failedCutover = result.items.find((item) => item.id === conversationRoutingConfigMigration.id && item.status === "error");
182
- if (failedCutover) throw new Error(failedCutover.message);
183
180
  if (result.changed) log.info({
184
181
  configPath,
185
182
  count: result.items.filter((item) => item.status === "applied").length
@@ -0,0 +1,2 @@
1
+ /** Only supported public browser-push providers may receive subscription requests. */
2
+ export declare function allowedPushEndpoint(value: string): boolean;
@@ -0,0 +1,13 @@
1
+ //#region src/notifications/browser-endpoint.ts
2
+ /** Only supported public browser-push providers may receive subscription requests. */
3
+ function allowedPushEndpoint(value) {
4
+ try {
5
+ const url = new URL(value);
6
+ const host = url.hostname;
7
+ return url.protocol === "https:" && !url.username && !url.password && (!url.port || url.port === "443") && (host === "fcm.googleapis.com" || host === "updates.push.services.mozilla.com" || host.endsWith(".push.services.mozilla.com") || host === "web.push.apple.com" || host.endsWith(".notify.windows.com"));
8
+ } catch {
9
+ return false;
10
+ }
11
+ }
12
+ //#endregion
13
+ export { allowedPushEndpoint };
@@ -0,0 +1,20 @@
1
+ import type { DatabaseSync } from 'node:sqlite';
2
+ type Owner = {
3
+ ownerId: string;
4
+ workspaceId: string;
5
+ };
6
+ /** User subscriptions share the same durable delivery ledger as every browser transport. */
7
+ export declare class BrowserSubscriptionService {
8
+ private readonly db;
9
+ private readonly clock;
10
+ constructor(db: DatabaseSync, clock?: () => number);
11
+ prepare(): {
12
+ publicKey: string;
13
+ };
14
+ register(owner: Owner, value: unknown): {
15
+ id: string;
16
+ };
17
+ remove(owner: Owner, id: string): void;
18
+ }
19
+ export declare function enqueueBrowserDispatches(db: DatabaseSync, owner: Owner, notificationId: string, subjectId: string | null, revision: number, now: number): void;
20
+ export {};
@@ -0,0 +1,59 @@
1
+ import { allowedPushEndpoint } from "./browser-endpoint.js";
2
+ import { createHash } from "node:crypto";
3
+ import { z } from "zod";
4
+ import webPush from "web-push";
5
+ //#region src/notifications/browserSubscriptions.ts
6
+ const inputSchema = z.strictObject({
7
+ endpoint: z.string().max(4096).refine(allowedPushEndpoint),
8
+ expirationTime: z.number().int().positive().nullable(),
9
+ language: z.enum(["en", "zh"]),
10
+ keys: z.strictObject({
11
+ auth: z.string().regex(/^[\w-]+$/).refine((value) => Buffer.from(value, "base64url").length === 16),
12
+ p256dh: z.string().regex(/^[\w-]+$/).refine((value) => Buffer.from(value, "base64url").length === 65)
13
+ })
14
+ });
15
+ /** User subscriptions share the same durable delivery ledger as every browser transport. */
16
+ var BrowserSubscriptionService = class {
17
+ constructor(db, clock = Date.now) {
18
+ this.db = db;
19
+ this.clock = clock;
20
+ }
21
+ prepare() {
22
+ let row = this.db.prepare("SELECT public_key FROM notification_browser_keys WHERE id = 1").get();
23
+ if (!row) {
24
+ const keys = webPush.generateVAPIDKeys();
25
+ this.db.prepare("INSERT INTO notification_browser_keys VALUES (1, ?, ?)").run(keys.publicKey, keys.privateKey);
26
+ row = { public_key: keys.publicKey };
27
+ }
28
+ return { publicKey: String(row.public_key) };
29
+ }
30
+ register(owner, value) {
31
+ const input = inputSchema.parse(value);
32
+ const now = this.clock();
33
+ if (input.expirationTime !== null && input.expirationTime <= now) throw new Error("Subscription expired");
34
+ const id = createHash("sha256").update(input.endpoint).digest("hex");
35
+ const existing = this.db.prepare("SELECT owner_id, workspace_id FROM notification_browser_subscriptions WHERE id = ?").get(id);
36
+ if (existing && (existing.owner_id !== owner.ownerId || existing.workspace_id !== owner.workspaceId)) throw new Error("Subscription belongs to another workspace");
37
+ this.db.prepare("DELETE FROM notification_browser_subscriptions WHERE expires_at <= ?").run(now);
38
+ if (!existing && Number(this.db.prepare("SELECT COUNT(*) AS n FROM notification_browser_subscriptions WHERE owner_id = ? AND workspace_id = ?").get(owner.ownerId, owner.workspaceId)?.n) >= 20) throw new Error("Subscription limit reached");
39
+ this.db.prepare(`INSERT INTO notification_browser_subscriptions VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)
40
+ ON CONFLICT(id) DO UPDATE SET auth_key = excluded.auth_key, public_key = excluded.public_key,
41
+ expires_at = excluded.expires_at, language = excluded.language`).run(id, owner.ownerId, owner.workspaceId, input.endpoint, input.keys.auth, input.keys.p256dh, input.expirationTime, input.language, now);
42
+ return { id };
43
+ }
44
+ remove(owner, id) {
45
+ this.db.prepare("DELETE FROM notification_browser_subscriptions WHERE id = ? AND owner_id = ? AND workspace_id = ?").run(id, owner.ownerId, owner.workspaceId);
46
+ this.db.prepare("UPDATE notification_dispatches SET status = 'cancelled' WHERE owner_id = ? AND workspace_id = ? AND destination_id = ? AND status = 'pending'").run(owner.ownerId, owner.workspaceId, id);
47
+ }
48
+ };
49
+ function enqueueBrowserDispatches(db, owner, notificationId, subjectId, revision, now) {
50
+ const subscriptions = db.prepare("SELECT id FROM notification_browser_subscriptions WHERE owner_id = ? AND workspace_id = ? AND (expires_at IS NULL OR expires_at > ?)").all(owner.ownerId, owner.workspaceId, now);
51
+ for (const subscription of subscriptions) {
52
+ const id = createHash("sha256").update(`${notificationId}:${subscription.id}`).digest("hex");
53
+ db.prepare(`INSERT OR IGNORE INTO notification_dispatches(id, notification_id, owner_id, workspace_id, channel, destination_id,
54
+ subject_id, subject_revision, status, attempt, next_attempt_at)
55
+ VALUES (?, ?, ?, ?, 'browser', ?, ?, ?, 'pending', 0, ?)`).run(id, notificationId, owner.ownerId, owner.workspaceId, subscription.id, subjectId, revision, now);
56
+ }
57
+ }
58
+ //#endregion
59
+ export { BrowserSubscriptionService, enqueueBrowserDispatches };
@@ -0,0 +1,9 @@
1
+ import type { DatabaseSync } from 'node:sqlite';
2
+ import webPush from 'web-push';
3
+ import type { DispatchReceipt, NotificationDispatch } from './dispatch.js';
4
+ /** Browser transport over the canonical ledger. Route resolution remains an authenticated host concern. */
5
+ export declare function createBrowserNotificationTransport(db: DatabaseSync, options: {
6
+ route: (dispatch: NotificationDispatch) => string | null;
7
+ send?: typeof webPush.sendNotification;
8
+ clock?: () => number;
9
+ }): (dispatch: NotificationDispatch, signal: AbortSignal) => Promise<DispatchReceipt>;
@@ -0,0 +1,64 @@
1
+ import { allowedPushEndpoint } from "./browser-endpoint.js";
2
+ import { createHash } from "node:crypto";
3
+ import webPush from "web-push";
4
+ //#region src/notifications/browserTransport.ts
5
+ /** Browser transport over the canonical ledger. Route resolution remains an authenticated host concern. */
6
+ function createBrowserNotificationTransport(db, options) {
7
+ return async (dispatch, signal) => {
8
+ const now = (options.clock ?? Date.now)();
9
+ if (dispatch.channel !== "browser" || signal.aborted) return { status: "rejected" };
10
+ const subscription = db.prepare(`SELECT * FROM notification_browser_subscriptions
11
+ WHERE id = ? AND owner_id = ? AND workspace_id = ? AND (expires_at IS NULL OR expires_at > ?)`).get(dispatch.destinationId, dispatch.ownerId, dispatch.workspaceId, now);
12
+ const keys = db.prepare("SELECT public_key, private_key FROM notification_browser_keys WHERE id = 1").get();
13
+ if (!subscription || !keys || !allowedPushEndpoint(String(subscription.endpoint))) return { status: "rejected" };
14
+ const route = options.route(dispatch);
15
+ if (!route || !route.startsWith("/") || route.startsWith("//") || /[\\\s]/u.test(route) || new URL(route, "https://xopc.invalid").origin !== "https://xopc.invalid") return { status: "rejected" };
16
+ const zh = subscription.language === "zh";
17
+ const payload = JSON.stringify({
18
+ id: dispatch.notificationId,
19
+ title: zh ? "有新成果需要查看" : "An update is ready",
20
+ body: zh ? "打开 xopc 查看详情。" : "Open xopc to review it.",
21
+ route
22
+ });
23
+ try {
24
+ await (options.send ?? webPush.sendNotification)({
25
+ endpoint: String(subscription.endpoint),
26
+ expirationTime: subscription.expires_at === null ? null : Number(subscription.expires_at),
27
+ keys: {
28
+ auth: String(subscription.auth_key),
29
+ p256dh: String(subscription.public_key)
30
+ }
31
+ }, payload, {
32
+ vapidDetails: {
33
+ subject: "https://xopc.ai",
34
+ publicKey: String(keys.public_key),
35
+ privateKey: String(keys.private_key)
36
+ },
37
+ TTL: 3600,
38
+ timeout: 1e4,
39
+ topic: createHash("sha256").update(dispatch.id).digest("base64url").slice(0, 32)
40
+ });
41
+ return {
42
+ status: "accepted",
43
+ providerMessageId: null
44
+ };
45
+ } catch (error) {
46
+ const status = error?.statusCode;
47
+ if (status === 429) return {
48
+ status: "rejected",
49
+ retryAt: (options.clock ?? Date.now)() + 3e4
50
+ };
51
+ if (status !== void 0 && [
52
+ 400,
53
+ 401,
54
+ 403,
55
+ 404,
56
+ 410,
57
+ 413
58
+ ].includes(status)) return { status: "rejected" };
59
+ throw new Error("Browser transport result is unconfirmed");
60
+ }
61
+ };
62
+ }
63
+ //#endregion
64
+ export { createBrowserNotificationTransport };
@@ -0,0 +1,46 @@
1
+ import type { DatabaseSync } from 'node:sqlite';
2
+ export interface NotificationDispatch {
3
+ id: string;
4
+ notificationId: string;
5
+ ownerId: string;
6
+ workspaceId: string;
7
+ channel: 'browser' | 'telegram';
8
+ destinationId: string;
9
+ destination: unknown;
10
+ subjectId: string | null;
11
+ subjectRevision: number;
12
+ attempt: number;
13
+ }
14
+ export type DispatchPolicy = {
15
+ action: 'send';
16
+ } | {
17
+ action: 'cancel';
18
+ } | {
19
+ action: 'defer';
20
+ until: number;
21
+ };
22
+ export type DispatchReceipt = {
23
+ status: 'accepted';
24
+ providerMessageId: string | null;
25
+ } | {
26
+ status: 'rejected';
27
+ retryAt?: number;
28
+ };
29
+ /** Owns durable delivery only. The host supplies policy and transports; neither may widen the saved scope. */
30
+ export declare class NotificationDispatcher {
31
+ private readonly db;
32
+ private readonly dependencies;
33
+ private active;
34
+ private stopped;
35
+ constructor(db: DatabaseSync, dependencies: {
36
+ authorize: (dispatch: NotificationDispatch, signal: AbortSignal) => Promise<DispatchPolicy>;
37
+ send: (dispatch: NotificationDispatch, signal: AbortSignal) => Promise<DispatchReceipt>;
38
+ clock?: () => number;
39
+ timeoutMs?: number;
40
+ });
41
+ /** Called by the host notification pump; overlapping passes never make a second claim. */
42
+ drainOne(): Promise<boolean>;
43
+ stop(): Promise<void>;
44
+ private now;
45
+ private deliver;
46
+ }