@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
@@ -0,0 +1,17 @@
1
+ import type { DatabaseSync } from 'node:sqlite';
2
+ import type { ProductNotification } from '@xopcai/gateway-contract';
3
+ import { type SceneActivation, type ScenePermission } from './contracts.js';
4
+ /** Page notifications commit with the result outbox; transport routing is never inferred. */
5
+ export declare class SceneResultNotifications {
6
+ private readonly db;
7
+ private readonly authorize;
8
+ private readonly publish;
9
+ private readonly clock;
10
+ private readonly outbox;
11
+ private committed;
12
+ constructor(db: DatabaseSync, authorize: (activation: SceneActivation) => ScenePermission, publish: (notification: ProductNotification) => void, clock?: () => number);
13
+ /** Realtime is a hint after commit; durable results and events survive a disconnected page. */
14
+ drain(limit?: number): number;
15
+ private reserveBudget;
16
+ private flushDigests;
17
+ }
@@ -0,0 +1,204 @@
1
+ import { init_transaction, runSqliteSavepoint } from "../storage/sqlite/transaction.js";
2
+ import { createNotificationEvent } from "../notifications/store.js";
3
+ import { enqueueBrowserDispatches } from "../notifications/browserSubscriptions.js";
4
+ import { intersectPermissions, sceneContentHash } from "./contracts.js";
5
+ import { nextSceneScheduleAt } from "./schedule.js";
6
+ import { SceneRepository } from "./repository.js";
7
+ import { ScenePreferenceService, sceneChecksAllowed } from "./preferences.js";
8
+ import { notificationQuietUntil } from "../notifications/quietHours.js";
9
+ import { sceneNotificationEligibility } from "./notificationEligibility.js";
10
+ import { createSceneNotificationOutbox } from "./notificationPublication.js";
11
+ import { randomUUID } from "node:crypto";
12
+ //#region src/scenes/resultNotifications.ts
13
+ init_transaction();
14
+ /** Page notifications commit with the result outbox; transport routing is never inferred. */
15
+ var SceneResultNotifications = class {
16
+ outbox;
17
+ committed = [];
18
+ constructor(db, authorize, publish, clock = Date.now) {
19
+ this.db = db;
20
+ this.authorize = authorize;
21
+ this.publish = publish;
22
+ this.clock = clock;
23
+ const repository = new SceneRepository(db);
24
+ const preferences = new ScenePreferenceService(db);
25
+ this.outbox = createSceneNotificationOutbox(db, (result, eligible) => {
26
+ const activation = repository.getActivation(result, eligible.activationId);
27
+ if (sceneContentHash(intersectPermissions(activation.permissions, authorize(activation))) !== sceneContentHash(intersectPermissions(activation.permissions))) return {
28
+ action: "settle",
29
+ reason: "permission_revoked"
30
+ };
31
+ const now = clock();
32
+ const policy = preferences.get(result);
33
+ if (policy.digestEnabled) {
34
+ const due = nextSceneScheduleAt({
35
+ weekdays: [
36
+ 0,
37
+ 1,
38
+ 2,
39
+ 3,
40
+ 4,
41
+ 5,
42
+ 6
43
+ ],
44
+ hour: policy.digestHour,
45
+ minute: policy.digestMinute,
46
+ timeZone: policy.timezone
47
+ }, now);
48
+ db.prepare(`INSERT INTO notification_digest_queue(subject_id, owner_id, workspace_id, subject_revision, mode, due_at, status)
49
+ VALUES (?, ?, ?, ?, 'daily', ?, 'pending') ON CONFLICT(subject_id) DO UPDATE SET
50
+ subject_revision = excluded.subject_revision, due_at = excluded.due_at, status = 'pending', consumed_at = NULL`).run(result.subjectId, result.ownerId, result.workspaceId, eligible.revision, due);
51
+ return {
52
+ action: "settle",
53
+ reason: "digest_queued"
54
+ };
55
+ }
56
+ const key = `scene.result:${eligible.presentationId}:${eligible.revision}`;
57
+ if (!this.reserveBudget(result, key, policy, now)) return {
58
+ action: "settle",
59
+ reason: "daily_budget"
60
+ };
61
+ const event = createNotificationEvent({
62
+ dedupeKey: key,
63
+ createdAt: now,
64
+ deviceIds: [],
65
+ notification: {
66
+ type: "scene.result",
67
+ priority: "normal",
68
+ target: {
69
+ kind: "scene_result",
70
+ activationId: eligible.activationId,
71
+ presentationId: eligible.presentationId
72
+ },
73
+ title: {
74
+ en: "A scene result is ready",
75
+ zh: "场景有新成果"
76
+ },
77
+ body: {
78
+ en: "Open the scene to review it.",
79
+ zh: "打开场景查看并反馈。"
80
+ },
81
+ payload: {
82
+ ownerId: result.ownerId,
83
+ workspaceId: result.workspaceId,
84
+ notificationRevision: eligible.revision,
85
+ deliveryChannel: "in_app"
86
+ }
87
+ }
88
+ }, db);
89
+ if (policy.preferredChannel === "browser") enqueueBrowserDispatches(db, result, event.notification.id, result.subjectId, eligible.revision, now);
90
+ if (event.created) this.committed.push(event.notification);
91
+ return {
92
+ action: "settle",
93
+ reason: "page_notification"
94
+ };
95
+ }, clock);
96
+ }
97
+ /** Realtime is a hint after commit; durable results and events survive a disconnected page. */
98
+ drain(limit = 100) {
99
+ if (!Number.isInteger(limit) || limit < 1 || limit > 1e3) throw new Error("Invalid scene notification batch size");
100
+ let drained = 0;
101
+ for (; drained < limit; drained++) {
102
+ this.committed = [];
103
+ if (!this.outbox.drainOne()) break;
104
+ for (const event of this.committed) if (this.db.prepare("SELECT 1 FROM notification_events WHERE event_id = ?").get(event.id)) this.publish(event);
105
+ }
106
+ this.flushDigests();
107
+ return drained;
108
+ }
109
+ reserveBudget(owner, key, policy, now) {
110
+ const day = new Intl.DateTimeFormat("en-CA", {
111
+ timeZone: policy.timezone,
112
+ year: "numeric",
113
+ month: "2-digit",
114
+ day: "2-digit"
115
+ }).format(now);
116
+ if (this.db.prepare("SELECT 1 FROM notification_attention_budget WHERE dedupe_key = ?").get(key)) return true;
117
+ if (Number(this.db.prepare(`SELECT count(*) AS n FROM notification_attention_budget
118
+ WHERE owner_id = ? AND workspace_id = ? AND local_day = ?`).get(owner.ownerId, owner.workspaceId, day)?.n) >= policy.dailyNotificationLimit) return false;
119
+ this.db.prepare("INSERT INTO notification_attention_budget VALUES (?, ?, ?, ?, ?)").run(key, owner.ownerId, owner.workspaceId, day, now);
120
+ return true;
121
+ }
122
+ flushDigests() {
123
+ const now = this.clock();
124
+ const owners = this.db.prepare(`SELECT DISTINCT owner_id, workspace_id FROM notification_digest_queue
125
+ WHERE status = 'pending' AND due_at <= ? ORDER BY owner_id, workspace_id LIMIT 100`).all(now);
126
+ for (const owner of owners) {
127
+ const event = runSqliteSavepoint(this.db, () => {
128
+ const principal = {
129
+ ownerId: String(owner.owner_id),
130
+ workspaceId: String(owner.workspace_id)
131
+ };
132
+ const policy = new ScenePreferenceService(this.db).get(principal);
133
+ const rows = this.db.prepare(`SELECT * FROM notification_digest_queue WHERE owner_id = ? AND workspace_id = ?
134
+ AND status = 'pending' AND due_at <= ? ORDER BY due_at, subject_id LIMIT 100`).all(principal.ownerId, principal.workspaceId, now);
135
+ const quiet = notificationQuietUntil(policy, now);
136
+ const members = [];
137
+ for (const row of rows) {
138
+ const result = {
139
+ ...principal,
140
+ id: String(row.subject_id),
141
+ subjectId: String(row.subject_id)
142
+ };
143
+ const eligible = sceneNotificationEligibility(this.db, result, now, Number(row.subject_revision));
144
+ let until = eligible.action === "defer" ? eligible.until : null;
145
+ let allowed = eligible.action === "eligible" && sceneChecksAllowed(policy, now) && !policy.notificationsMuted && policy.level !== "quiet";
146
+ if (allowed && eligible.action === "eligible") {
147
+ const activation = new SceneRepository(this.db).getActivation(principal, eligible.activationId);
148
+ allowed = sceneContentHash(intersectPermissions(activation.permissions, this.authorize(activation))) === sceneContentHash(intersectPermissions(activation.permissions));
149
+ if (policy.suppressWhileViewing && this.db.prepare(`SELECT 1 FROM notification_presence WHERE owner_id = ? AND workspace_id = ?
150
+ AND subject_id = ? AND subject_revision = ? AND expires_at > ?`).get(principal.ownerId, principal.workspaceId, row.subject_id, row.subject_revision, now)) allowed = false;
151
+ if (allowed) until = quiet;
152
+ }
153
+ if (until !== null) {
154
+ this.db.prepare("UPDATE notification_digest_queue SET due_at = ? WHERE subject_id = ?").run(until, row.subject_id);
155
+ continue;
156
+ }
157
+ this.db.prepare("UPDATE notification_digest_queue SET status = 'consumed', consumed_at = ? WHERE subject_id = ?").run(now, row.subject_id);
158
+ if (allowed) members.push({
159
+ id: String(row.subject_id),
160
+ revision: Number(row.subject_revision)
161
+ });
162
+ }
163
+ if (!members.length) return null;
164
+ const occurrence = `daily:${rows[0].due_at}:${members[0].id}`;
165
+ const key = `scene.digest:${sceneContentHash([principal, occurrence])}`;
166
+ if (!this.reserveBudget(principal, key, policy, now)) return null;
167
+ const id = randomUUID();
168
+ const created = createNotificationEvent({
169
+ dedupeKey: key,
170
+ createdAt: now,
171
+ deviceIds: [],
172
+ notification: {
173
+ type: "scene.digest",
174
+ priority: "normal",
175
+ target: {
176
+ kind: "scene_digest",
177
+ digestId: id
178
+ },
179
+ title: {
180
+ en: "Your scene digest is ready",
181
+ zh: "场景摘要已就绪"
182
+ },
183
+ body: {
184
+ en: "Open the app to review your results.",
185
+ zh: "打开页面查看成果。"
186
+ },
187
+ payload: {
188
+ ...principal,
189
+ deliveryChannel: "in_app"
190
+ }
191
+ }
192
+ }, this.db);
193
+ this.db.prepare("INSERT INTO notification_digests VALUES (?, ?, ?, ?, ?, ?)").run(id, principal.ownerId, principal.workspaceId, occurrence, now, created.notification.id);
194
+ const insert = this.db.prepare("INSERT INTO notification_digest_members VALUES (?, ?, ?)");
195
+ for (const member of members) insert.run(id, member.id, member.revision);
196
+ if (policy.preferredChannel === "browser") enqueueBrowserDispatches(this.db, principal, created.notification.id, null, 1, now);
197
+ return created.created ? created.notification : null;
198
+ });
199
+ if (event) this.publish(event);
200
+ }
201
+ }
202
+ };
203
+ //#endregion
204
+ export { SceneResultNotifications };
@@ -0,0 +1,25 @@
1
+ import type { SceneExecutionService } from './execution.js';
2
+ import type { SceneRepository } from './repository.js';
3
+ import type { SceneMailObservationService } from './mailObservations.js';
4
+ /** Single-Gateway pump. Durable occurrence, lease and budget rules remain in the domain. */
5
+ export declare class SceneRuntime {
6
+ private readonly repository;
7
+ private readonly execution;
8
+ private readonly observations;
9
+ private readonly clock;
10
+ private readonly intervalMs;
11
+ private readonly worker;
12
+ private controller;
13
+ private timer?;
14
+ private running?;
15
+ private observing?;
16
+ private observationCursor;
17
+ private stopping?;
18
+ constructor(repository: SceneRepository, execution: SceneExecutionService, observations: Pick<SceneMailObservationService, 'scan'>, clock?: () => number, intervalMs?: number);
19
+ start(): void;
20
+ /** Ingests due occurrences even when an earlier model call is still running. */
21
+ tick(): Promise<void>;
22
+ private observe;
23
+ /** Cancels the active read/model call before the host closes SQLite. */
24
+ stop(): Promise<void>;
25
+ }
@@ -0,0 +1,101 @@
1
+ import { createLogger } from "../utils/logger/index.js";
2
+ import { init_logger } from "../utils/logger.js";
3
+ import { randomUUID } from "node:crypto";
4
+ //#region src/scenes/runtime.ts
5
+ init_logger();
6
+ const log = createLogger("SceneRuntime");
7
+ /** Single-Gateway pump. Durable occurrence, lease and budget rules remain in the domain. */
8
+ var SceneRuntime = class {
9
+ worker = `scene:${randomUUID()}`;
10
+ controller = new AbortController();
11
+ timer;
12
+ running;
13
+ observing;
14
+ observationCursor = "";
15
+ stopping;
16
+ constructor(repository, execution, observations, clock = Date.now, intervalMs = 5e3) {
17
+ this.repository = repository;
18
+ this.execution = execution;
19
+ this.observations = observations;
20
+ this.clock = clock;
21
+ this.intervalMs = intervalMs;
22
+ if (!Number.isInteger(intervalMs) || intervalMs < 100 || intervalMs > 6e4) throw new Error("Invalid scene poll interval");
23
+ }
24
+ start() {
25
+ if (this.stopping) throw new Error("Scene runtime is stopping");
26
+ if (this.timer) return;
27
+ if (this.controller.signal.aborted) this.controller = new AbortController();
28
+ const poll = () => {
29
+ this.tick().catch((err) => log.error({
30
+ err,
31
+ phase: "scene_poll"
32
+ }, "Scene poll failed"));
33
+ };
34
+ this.timer = setInterval(poll, this.intervalMs);
35
+ this.timer.unref();
36
+ poll();
37
+ }
38
+ /** Ingests due occurrences even when an earlier model call is still running. */
39
+ async tick() {
40
+ this.controller.signal.throwIfAborted();
41
+ const now = this.clock();
42
+ this.repository.enqueueDueWorkItems(now);
43
+ this.repository.enqueueDueSchedules(now);
44
+ if (!this.observing) this.observe();
45
+ if (this.running) {
46
+ await Promise.all([this.running, this.observing]);
47
+ return;
48
+ }
49
+ const signal = this.controller.signal;
50
+ const run = this.execution.runNext(this.worker, signal).then(() => void 0);
51
+ this.running = run;
52
+ const execution = run.finally(() => {
53
+ if (this.running === run) this.running = void 0;
54
+ });
55
+ await Promise.all([execution, this.observing]);
56
+ }
57
+ observe() {
58
+ const controller = new AbortController();
59
+ const outer = this.controller.signal;
60
+ const abort = () => controller.abort(outer.reason);
61
+ outer.addEventListener("abort", abort, { once: true });
62
+ const timeout = setTimeout(() => controller.abort(/* @__PURE__ */ new Error("Scene mail observation timed out")), 3e4);
63
+ let removeListener = () => {};
64
+ const aborted = new Promise((_, reject) => {
65
+ const listener = () => reject(controller.signal.reason);
66
+ controller.signal.addEventListener("abort", listener, { once: true });
67
+ removeListener = () => controller.signal.removeEventListener("abort", listener);
68
+ });
69
+ const scan = Promise.resolve().then(() => {
70
+ controller.signal.throwIfAborted();
71
+ return this.observations.scan(controller.signal, this.observationCursor, (id) => {
72
+ if (!controller.signal.aborted) this.observationCursor = id;
73
+ });
74
+ }).then((result) => {
75
+ controller.signal.throwIfAborted();
76
+ this.observationCursor = result.nextCursor ?? "";
77
+ });
78
+ const observing = Promise.race([scan, aborted]).finally(() => {
79
+ clearTimeout(timeout);
80
+ removeListener();
81
+ outer.removeEventListener("abort", abort);
82
+ if (this.observing === observing) this.observing = void 0;
83
+ });
84
+ this.observing = observing;
85
+ }
86
+ /** Cancels the active read/model call before the host closes SQLite. */
87
+ stop() {
88
+ if (this.stopping) return this.stopping;
89
+ if (this.timer) clearInterval(this.timer);
90
+ this.timer = void 0;
91
+ this.controller.abort(/* @__PURE__ */ new Error("Scene runtime stopped"));
92
+ const stopped = Promise.allSettled([this.running, this.observing]).then(() => void 0);
93
+ this.stopping = stopped;
94
+ stopped.finally(() => {
95
+ if (this.stopping === stopped) this.stopping = void 0;
96
+ });
97
+ return stopped;
98
+ }
99
+ };
100
+ //#endregion
101
+ export { SceneRuntime };
@@ -0,0 +1,9 @@
1
+ import { z } from 'zod';
2
+ /** A local wall-clock schedule, not an arbitrary cron or workflow language. */
3
+ export declare const sceneScheduleSchema: z.ZodObject<{
4
+ weekdays: z.ZodArray<z.ZodNumber>;
5
+ hour: z.ZodNumber;
6
+ minute: z.ZodNumber;
7
+ timeZone: z.ZodString;
8
+ }, z.core.$strict>;
9
+ export declare function nextSceneScheduleAt(value: unknown, now: number): number;
@@ -0,0 +1,45 @@
1
+ import { z } from "zod";
2
+ import { DateTime } from "luxon";
3
+ //#region src/scenes/schedule.ts
4
+ /** A local wall-clock schedule, not an arbitrary cron or workflow language. */
5
+ const sceneScheduleSchema = z.strictObject({
6
+ weekdays: z.array(z.number().int().min(0).max(6)).min(1).max(7).refine((days) => new Set(days).size === days.length, "Duplicate weekdays"),
7
+ hour: z.number().int().min(0).max(23),
8
+ minute: z.number().int().min(0).max(59),
9
+ timeZone: z.string().trim().min(1).max(100).refine((timeZone) => {
10
+ try {
11
+ new Intl.DateTimeFormat("en", { timeZone });
12
+ return DateTime.now().setZone(timeZone).isValid;
13
+ } catch {
14
+ return false;
15
+ }
16
+ }, "Invalid time zone")
17
+ });
18
+ function nextSceneScheduleAt(value, now) {
19
+ if (!Number.isSafeInteger(now) || now < 0) throw new Error("Invalid scene schedule time");
20
+ const schedule = sceneScheduleSchema.parse(value);
21
+ const today = DateTime.fromMillis(now, { zone: schedule.timeZone }).startOf("day");
22
+ for (let day = 0; day < 15; day += 1) {
23
+ const date = today.plus({ days: day });
24
+ if (!schedule.weekdays.includes(date.weekday % 7)) continue;
25
+ let candidate = date.set({
26
+ hour: schedule.hour,
27
+ minute: schedule.minute,
28
+ second: 0,
29
+ millisecond: 0
30
+ });
31
+ if (candidate.hour !== schedule.hour || candidate.minute !== schedule.minute) {
32
+ const requestedMinute = schedule.hour * 60 + schedule.minute;
33
+ for (let step = 0; step < 1440; step += 1) {
34
+ const previous = candidate.minus({ minutes: 1 });
35
+ if (previous.toISODate() !== date.toISODate() || previous.hour * 60 + previous.minute < requestedMinute) break;
36
+ candidate = previous;
37
+ }
38
+ }
39
+ const first = Math.min(...candidate.getPossibleOffsets().map((value) => value.toMillis()));
40
+ if (first > now) return first;
41
+ }
42
+ throw new Error("No scene schedule occurrence within the search window");
43
+ }
44
+ //#endregion
45
+ export { nextSceneScheduleAt, sceneScheduleSchema };
@@ -0,0 +1,29 @@
1
+ import { type SceneActivation, type ScenePermission, type ScenePrincipal } from './contracts.js';
2
+ import type { SceneContextProvider } from './execution.js';
3
+ import { SceneRepository } from './repository.js';
4
+ export declare class SceneSetupError extends Error {
5
+ readonly missing: string[];
6
+ constructor(missing: string[]);
7
+ }
8
+ /** User-facing operations share one authorization boundary, independent of the UI. */
9
+ export declare class SceneApplicationService {
10
+ private readonly repository;
11
+ private readonly providers;
12
+ private readonly authorize;
13
+ private readonly clock;
14
+ private readonly modelReadiness;
15
+ constructor(repository: SceneRepository, providers: readonly SceneContextProvider[], authorize: (activation: SceneActivation) => Promise<ScenePermission>, clock?: () => number, modelReadiness?: () => string[]);
16
+ preflight(principal: ScenePrincipal, value: unknown): Promise<{
17
+ ready: boolean;
18
+ missing: string[];
19
+ }>;
20
+ private checkReadiness;
21
+ start(principal: ScenePrincipal, value: unknown, requestId: string): Promise<SceneActivation>;
22
+ check(principal: ScenePrincipal, activationId: string, requestId: string): string;
23
+ transition(principal: ScenePrincipal, id: string, value: unknown): Promise<SceneActivation>;
24
+ configure(principal: ScenePrincipal, id: string, value: unknown): SceneActivation;
25
+ writeNotes(principal: ScenePrincipal, id: string, value: unknown): number;
26
+ createWorkItem(principal: ScenePrincipal, id: string, value: unknown): import("./repository.js").SceneWorkItem;
27
+ setSchedule(principal: ScenePrincipal, id: string, triggerKey: string, value: unknown): number;
28
+ updateWorkItem(principal: ScenePrincipal, id: string, value: unknown): import("./repository.js").SceneWorkItem;
29
+ }
@@ -0,0 +1,116 @@
1
+ import { activationInputSchema, activationStatuses, intersectPermissions, validateTemplate } from "./contracts.js";
2
+ import { sceneScheduleSchema } from "./schedule.js";
3
+ import { z } from "zod";
4
+ //#region src/scenes/service.ts
5
+ var SceneSetupError = class extends Error {
6
+ constructor(missing) {
7
+ super(`Scene setup is incomplete: ${missing.join(", ")}`);
8
+ this.missing = missing;
9
+ }
10
+ };
11
+ /** User-facing operations share one authorization boundary, independent of the UI. */
12
+ var SceneApplicationService = class {
13
+ constructor(repository, providers, authorize, clock = Date.now, modelReadiness = () => []) {
14
+ this.repository = repository;
15
+ this.providers = providers;
16
+ this.authorize = authorize;
17
+ this.clock = clock;
18
+ this.modelReadiness = modelReadiness;
19
+ }
20
+ async preflight(principal, value) {
21
+ const input = activationInputSchema.parse(value);
22
+ return this.checkReadiness({
23
+ ...input,
24
+ ...principal,
25
+ id: "preflight",
26
+ revision: 1,
27
+ status: "needs_setup"
28
+ });
29
+ }
30
+ async checkReadiness(activation) {
31
+ const input = activation;
32
+ const template = validateTemplate(this.repository.getTemplate(input.templateKey, input.templateVersion), {
33
+ contextProviders: this.providers.map((provider) => provider.id),
34
+ effectHandlers: []
35
+ });
36
+ const permissions = intersectPermissions(input.permissions, await this.authorize(activation));
37
+ const missing = template.contextProviders.filter((provider) => !permissions.contextProviders.includes(provider)).map((id) => `context:${id}`);
38
+ missing.push(...this.modelReadiness());
39
+ missing.push(...input.permissions.accountIds.filter((id) => !permissions.accountIds.includes(id)).map((id) => `account:${id}`));
40
+ if (input.permissions.effectHandlers.length > 0) missing.push("read_only_execution");
41
+ if (input.permissions.contextProviders.some((id) => !template.contextProviders.includes(id))) missing.push("unrequested_context");
42
+ if (template.key === "mail-follow-up" && (input.scope.kind !== "objects" || input.scope.ids.length !== 1 || input.permissions.accountIds.length !== 1)) missing.push("one_mail_thread_and_account");
43
+ if (template.contextProviders.includes("user_notes") && input.scope.kind !== "personal") missing.push("personal_notes_scope");
44
+ return {
45
+ ready: missing.length === 0,
46
+ missing
47
+ };
48
+ }
49
+ async start(principal, value, requestId) {
50
+ if (!requestId.trim()) throw new Error("Scene request identity is required");
51
+ const preflight = await this.preflight(principal, value);
52
+ if (!preflight.ready) throw new SceneSetupError(preflight.missing);
53
+ const activation = this.repository.createActivation(principal, value, requestId);
54
+ if (activation.status !== "needs_setup") return activation;
55
+ return this.repository.transitionActivation(principal, activation.id, activation.revision, "active", this.clock());
56
+ }
57
+ check(principal, activationId, requestId) {
58
+ if (!requestId.trim() || requestId.length > 200) throw new Error("Scene request identity is required");
59
+ const activation = this.repository.getActivation(principal, activationId);
60
+ const trigger = this.repository.getTemplate(activation.templateKey, activation.templateVersion).triggers.find((item) => item.type === "manual");
61
+ if (!trigger) throw new Error("Scene template does not support manual checks");
62
+ return this.repository.acceptManualCheck(principal, activationId, trigger.id, requestId, this.clock());
63
+ }
64
+ async transition(principal, id, value) {
65
+ const input = z.strictObject({
66
+ expectedRevision: z.number().int().positive(),
67
+ status: z.enum(activationStatuses)
68
+ }).parse(value);
69
+ const activation = this.repository.getActivation(principal, id);
70
+ if (input.status === "active") {
71
+ const result = await this.checkReadiness(activation);
72
+ if (!result.ready) throw new SceneSetupError(result.missing);
73
+ }
74
+ return this.repository.transitionActivation(principal, id, input.expectedRevision, input.status, this.clock());
75
+ }
76
+ configure(principal, id, value) {
77
+ const { expectedRevision, ...input } = activationInputSchema.pick({
78
+ goal: true,
79
+ scope: true,
80
+ permissions: true
81
+ }).extend({ expectedRevision: z.number().int().positive() }).parse(value);
82
+ return this.repository.configureActivation(principal, id, expectedRevision, input);
83
+ }
84
+ writeNotes(principal, id, value) {
85
+ return this.repository.writeNotes(principal, id, value, this.clock());
86
+ }
87
+ createWorkItem(principal, id, value) {
88
+ const input = z.strictObject({
89
+ subjectId: z.string().trim().min(1).max(200),
90
+ accountId: z.string().trim().min(1).max(200),
91
+ dueAt: z.number().int().refine((time) => time > this.clock(), "Deadline must be in the future")
92
+ }).parse(value);
93
+ return this.repository.createWorkItem(principal, id, input, this.clock());
94
+ }
95
+ setSchedule(principal, id, triggerKey, value) {
96
+ const input = z.strictObject({
97
+ expectedRevision: z.number().int().nonnegative(),
98
+ schedule: sceneScheduleSchema
99
+ }).parse(value);
100
+ return this.repository.setSchedule(principal, id, triggerKey, input.expectedRevision, input.schedule, this.clock());
101
+ }
102
+ updateWorkItem(principal, id, value) {
103
+ const input = z.strictObject({
104
+ expectedRevision: z.number().int().positive(),
105
+ dueAt: z.number().int().nonnegative().optional(),
106
+ status: z.enum([
107
+ "watching",
108
+ "paused",
109
+ "completed"
110
+ ]).optional()
111
+ }).parse(value);
112
+ return this.repository.updateWorkItem(principal, id, input, this.clock());
113
+ }
114
+ };
115
+ //#endregion
116
+ export { SceneApplicationService, SceneSetupError };
@@ -0,0 +1,64 @@
1
+ export declare const mailFollowUpTemplate: {
2
+ schemaVersion: 1;
3
+ key: string;
4
+ version: string;
5
+ title: string;
6
+ description: string;
7
+ goalMode: "finite" | "ongoing";
8
+ contextProviders: string[];
9
+ triggers: ({
10
+ id: string;
11
+ type: "manual";
12
+ } | {
13
+ id: string;
14
+ type: "event";
15
+ eventType: string;
16
+ } | {
17
+ id: string;
18
+ type: "schedule";
19
+ })[];
20
+ execution: {
21
+ kind: "agent";
22
+ instruction: string;
23
+ limits: {
24
+ timeoutSeconds: number;
25
+ maxIterations: number;
26
+ maxToolCalls: number;
27
+ maxOutputTokens: number;
28
+ };
29
+ };
30
+ allowedOutcomeKinds: ("artifact" | "receipt" | "decision" | "observation" | "no_change" | "state_change" | "effect_proposal")[];
31
+ allowedEffectHandlers: string[];
32
+ };
33
+ export declare const familyPlanTemplate: {
34
+ schemaVersion: 1;
35
+ key: string;
36
+ version: string;
37
+ title: string;
38
+ description: string;
39
+ goalMode: "finite" | "ongoing";
40
+ contextProviders: string[];
41
+ triggers: ({
42
+ id: string;
43
+ type: "manual";
44
+ } | {
45
+ id: string;
46
+ type: "event";
47
+ eventType: string;
48
+ } | {
49
+ id: string;
50
+ type: "schedule";
51
+ })[];
52
+ execution: {
53
+ kind: "agent";
54
+ instruction: string;
55
+ limits: {
56
+ timeoutSeconds: number;
57
+ maxIterations: number;
58
+ maxToolCalls: number;
59
+ maxOutputTokens: number;
60
+ };
61
+ };
62
+ allowedOutcomeKinds: ("artifact" | "receipt" | "decision" | "observation" | "no_change" | "state_change" | "effect_proposal")[];
63
+ allowedEffectHandlers: string[];
64
+ };