@xopcai/xopc 0.0.332 → 0.0.333

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 (329) 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/{agent-avatar-dicebear-C2wg3xC_.js → agent-avatar-dicebear-DiI2O7lC.js} +1 -1
  4. package/dist/gateway/static/root/assets/agent-defaults-settings-panel-CVp3J969.js +1 -0
  5. package/dist/gateway/static/root/assets/{agent-plugin-dialog-BeNnu1Ts.js → agent-plugin-dialog-CacyndrS.js} +1 -1
  6. package/dist/gateway/static/root/assets/agents-DXYZSuUV.js +70 -0
  7. package/dist/gateway/static/root/assets/{app-management-settings-panel-etFSkfzl.js → app-management-settings-panel-BcszTlqr.js} +1 -1
  8. package/dist/gateway/static/root/assets/{appearance-settings-DKmU2VAP.js → appearance-settings-B1XPe8qz.js} +1 -1
  9. package/dist/gateway/static/root/assets/{apps-page-DVNySL58.js → apps-page-ZqANbUZv.js} +1 -1
  10. package/dist/gateway/static/root/assets/{archive-plugin-D0z_Fr2G.js → archive-plugin-MjUsJcNb.js} +1 -1
  11. package/dist/gateway/static/root/assets/{attachment-load-DNCDbeOX.js → attachment-load-DHa-BI9a.js} +1 -1
  12. package/dist/gateway/static/root/assets/{automations-page-B7_C-p66.js → automations-page-Dsjivdxs.js} +1 -1
  13. package/dist/gateway/static/root/assets/automations-workspace-B37vs5tk.js +7 -0
  14. package/dist/gateway/static/root/assets/{binary-plugins-BYn2hScX.js → binary-plugins-DQYcuBHP.js} +1 -1
  15. package/dist/gateway/static/root/assets/{block-editor-ChWW8Z9L.js → block-editor-Bx0uXbJP.js} +3 -3
  16. package/dist/gateway/static/root/assets/{browser-automation-inputs-C5s1yHOu.js → browser-automation-inputs-1ZIPGDeq.js} +1 -1
  17. package/dist/gateway/static/root/assets/{browser-automations-page-BV00BXRb.js → browser-automations-page-CCjYipHc.js} +2 -2
  18. package/dist/gateway/static/root/assets/browser-settings-page-CSv4rvmx.js +3 -0
  19. package/dist/gateway/static/root/assets/capabilities-BnO9LV7U.js +1 -0
  20. package/dist/gateway/static/root/assets/{capabilities-page-v0WkhV5o.js → capabilities-page-BfvDvIY1.js} +2 -2
  21. package/dist/gateway/static/root/assets/capabilities-settings-panel-CoW7-ESq.js +8 -0
  22. package/dist/gateway/static/root/assets/{capability-header-actions-vmx35sbu.js → capability-header-actions-D_hbWRRF.js} +1 -1
  23. package/dist/gateway/static/root/assets/channels-BhMaRh1x.js +1 -0
  24. package/dist/gateway/static/root/assets/{chat-terminal-dock-C41mXCAi.js → chat-terminal-dock-Fnum_IEm.js} +1 -1
  25. package/dist/gateway/static/root/assets/{computer-settings-page-BJkqok2G.js → computer-settings-page-DI1zfCTA.js} +1 -1
  26. package/dist/gateway/static/root/assets/{connector-service-page-BKCZMmwm.js → connector-service-page-CiGDAubm.js} +1 -1
  27. package/dist/gateway/static/root/assets/connectors-page-Ono0Pha1.js +2 -0
  28. package/dist/gateway/static/root/assets/{date-picker-CrOV4Ynd.js → date-picker-D-JhzZyW.js} +1 -1
  29. package/dist/gateway/static/root/assets/{dependency-picker-CqADAHZp.js → dependency-picker-DpD3xaEB.js} +1 -1
  30. package/dist/gateway/static/root/assets/{desktop-pet-Bab-iWED.js → desktop-pet-CCoDxKqh.js} +1 -1
  31. package/dist/gateway/static/root/assets/{desktop-pet-settings-BqgzLOdi.js → desktop-pet-settings-GxndKfCx.js} +1 -1
  32. package/dist/gateway/static/root/assets/{device-pairing-wizard-DFg7FDPf.js → device-pairing-wizard-B71w3ptm.js} +1 -1
  33. package/dist/gateway/static/root/assets/{directory-picker-path-field-hqJ9sFCR.js → directory-picker-path-field-CUzjJvjs.js} +1 -1
  34. package/dist/gateway/static/root/assets/{extension-debug-page-DX3PFhRE.js → extension-debug-page-BtDY8ntX.js} +1 -1
  35. package/dist/gateway/static/root/assets/{extension-page-DkREdHLs.js → extension-page-D9_XF-XC.js} +1 -1
  36. package/dist/gateway/static/root/assets/{extension-settings-page-wF-HNTM-.js → extension-settings-page-CjhUFAaC.js} +1 -1
  37. package/dist/gateway/static/root/assets/{gateway-config-swr-cR-tz7-Q.js → gateway-config-swr-CgIjCxM8.js} +1 -1
  38. package/dist/gateway/static/root/assets/{gateway-settings-Du-Dos9O.js → gateway-settings-BWaCnwT1.js} +1 -1
  39. package/dist/gateway/static/root/assets/{gateway-startup-retry-6jLRcQsu.js → gateway-startup-retry-i-1lTrwY.js} +1 -1
  40. package/dist/gateway/static/root/assets/home-page-BTjGLngn.js +1 -0
  41. package/dist/gateway/static/root/assets/{image-generation-api-CSSkwsyC.js → image-generation-api-gilc-u7M.js} +1 -1
  42. package/dist/gateway/static/root/assets/{imports-page-B80Cv043.js → imports-page-BEtq5BRU.js} +1 -1
  43. package/dist/gateway/static/root/assets/index-DHL16aYZ.js +121 -0
  44. package/dist/gateway/static/root/assets/index-N1e6PDwx.css +1 -0
  45. package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-BgoFaTwv.js → keyboard-shortcuts-settings-JUYY_18v.js} +1 -1
  46. package/dist/gateway/static/root/assets/local-app-workbench-page-uI7mtoVz.js +1 -0
  47. package/dist/gateway/static/root/assets/{local-apps-page-HO6OQlQT.js → local-apps-page-BlYESNqz.js} +1 -1
  48. package/dist/gateway/static/root/assets/{locale-store-wNXWkWu5.js → locale-store-BY30D6tg.js} +1 -1
  49. package/dist/gateway/static/root/assets/{logs-page-CjzR9Rpj.js → logs-page-BbLQreeN.js} +2 -2
  50. package/dist/gateway/static/root/assets/management-settings-c4krhYU7.js +1 -0
  51. package/dist/gateway/static/root/assets/{markdown-view-DlT9KqwF.js → markdown-view-BEeXMfDw.js} +1 -1
  52. package/dist/gateway/static/root/assets/{media-plugins-Dlj6TD3M.js → media-plugins-DEFN1I73.js} +1 -1
  53. package/dist/gateway/static/root/assets/messages-_6IXbP2u.js +3 -0
  54. package/dist/gateway/static/root/assets/note-detail-panel--09xGxyE.js +5 -0
  55. package/dist/gateway/static/root/assets/notes-page-DsxcVBXF.js +8 -0
  56. package/dist/gateway/static/root/assets/{page-context-capture-button-BArPtqp5.js → page-context-capture-button-D43aVpCj.js} +1 -1
  57. package/dist/gateway/static/root/assets/{page-tabs-vqI30Yrg.js → page-tabs-BhYBCqls.js} +1 -1
  58. package/dist/gateway/static/root/assets/{preview-open-alternatives-B-mwPBJW.js → preview-open-alternatives-CP8agNlc.js} +1 -1
  59. package/dist/gateway/static/root/assets/{product-open-page-D--sj_uN.js → product-open-page-CU7fRhfT.js} +1 -1
  60. package/dist/gateway/static/root/assets/project-detail-page-U-EdDfAW.js +1 -0
  61. package/dist/gateway/static/root/assets/{projects-page-DBsBwAQ6.js → projects-page-DUOKZLt7.js} +1 -1
  62. package/dist/gateway/static/root/assets/{registry-api-BIpltJ47.js → registry-api-BvVx0G1o.js} +1 -1
  63. package/dist/gateway/static/root/assets/{remote-access-hub-BurdDY0m.js → remote-access-hub-fVPQe5YS.js} +1 -1
  64. package/dist/gateway/static/root/assets/{runtime-tools-settings-panel-CAnb0PNY.js → runtime-tools-settings-panel-Czvzsuj_.js} +2 -2
  65. package/dist/gateway/static/root/assets/scenes-page-C0-WHOY3.js +2 -0
  66. package/dist/gateway/static/root/assets/{schema-form-BKj6wIMb.js → schema-form-B9Ni5O93.js} +1 -1
  67. package/dist/gateway/static/root/assets/sessions-page-DdXvW09N.js +1 -0
  68. package/dist/gateway/static/root/assets/settings-advanced-gate-BtF83fBY.js +1 -0
  69. package/dist/gateway/static/root/assets/{settings-form-section-78ycUHfv.js → settings-form-section-jquf1P7n.js} +1 -1
  70. package/dist/gateway/static/root/assets/{settings-page-BOdxIVzo.js → settings-page-DPomsvba.js} +1 -1
  71. package/dist/gateway/static/root/assets/{setup-status-panel-CbKHBjrU.js → setup-status-panel-BvVlqpHf.js} +1 -1
  72. package/dist/gateway/static/root/assets/{share-preview-page-DyLfktib.js → share-preview-page-b9DI0N1J.js} +1 -1
  73. package/dist/gateway/static/root/assets/shares-settings-R_qwc4DN.js +1 -0
  74. package/dist/gateway/static/root/assets/{skill-api-CiBGQ0Jg.js → skill-api-Bu7-3w-L.js} +1 -1
  75. package/dist/gateway/static/root/assets/skill-reload-api-CNJAQ_e-.js +1 -0
  76. package/dist/gateway/static/root/assets/{skills-page-C35VKjhb.js → skills-page-D7XPEQu_.js} +1 -1
  77. package/dist/gateway/static/root/assets/{system-settings-panel-CyJUeREH.js → system-settings-panel-BwFR0Uci.js} +1 -1
  78. package/dist/gateway/static/root/assets/task-detail-page-PFjGW2g1.js +1 -0
  79. package/dist/gateway/static/root/assets/{tunnel-api-Day9zhKi.js → tunnel-api-PfucxMP3.js} +1 -1
  80. package/dist/gateway/static/root/assets/usage-page-t_zdQHcy.js +1 -0
  81. package/dist/gateway/static/root/assets/{use-autosave-Bj9hC6ML.js → use-autosave-DLyy2wHz.js} +1 -1
  82. package/dist/gateway/static/root/assets/user-model-page-OyfPVfB9.js +2 -0
  83. package/dist/gateway/static/root/assets/{voice-api-key-field-fWRD6B8r.js → voice-api-key-field-CQDY5EBK.js} +1 -1
  84. package/dist/gateway/static/root/assets/{voice-config-api-ujEySjyc.js → voice-config-api-Bwy3Al3J.js} +1 -1
  85. package/dist/gateway/static/root/assets/{work-discovery-overlay-CnxdvIk8.js → work-discovery-overlay-CJzqJ47I.js} +1 -1
  86. package/dist/gateway/static/root/assets/{workflow-run-setup-panel-DlWNN1VA.js → workflow-run-setup-panel-sCOk-esV.js} +2 -2
  87. package/dist/gateway/static/root/assets/workflows-page-DYBGjN7C.js +6 -0
  88. package/dist/gateway/static/root/index.html +9 -9
  89. package/dist/package.js +1 -1
  90. package/dist/packages/gateway-contract/src/automations.js +44 -14
  91. package/dist/packages/gateway-contract/src/capabilities.js +106 -8
  92. package/dist/packages/gateway-contract/src/index.js +2 -0
  93. package/dist/packages/gateway-contract/src/scenes.js +7 -6
  94. package/dist/packages/gateway-contract/src/sessions.js +2 -1
  95. package/dist/packages/gateway-contract/src/usage.js +6 -0
  96. package/dist/src/agent/agent-manager.js +9 -3
  97. package/dist/src/agent/background-review/run-background-review.js +6 -1
  98. package/dist/src/agent/embedded/run-turn.js +7 -1
  99. package/dist/src/agent/external-tools/gateway-tools.d.ts +2 -1
  100. package/dist/src/agent/external-tools/gateway-tools.js +44 -11
  101. package/dist/src/agent/external-tools/index.js +1 -1
  102. package/dist/src/agent/image/understanding/pi-ai-provider.js +1 -1
  103. package/dist/src/agent/memory/compaction.js +4 -0
  104. package/dist/src/agent/service/btw-query.js +8 -2
  105. package/dist/src/agent/service.js +1 -1
  106. package/dist/src/agent/skills/filesystem-watcher.js +1 -1
  107. package/dist/src/agent/skills/hub-pull.js +2 -2
  108. package/dist/src/agent/skills/marketplace/adapters/store/adapter.js +1 -1
  109. package/dist/src/agent/skills/marketplace/adapters/store/store-api-client.js +1 -1
  110. package/dist/src/agent/tasks/task-judge-service.js +4 -0
  111. package/dist/src/agent/tool-manuals/xopc-use.d.ts +1 -1
  112. package/dist/src/agent/tool-manuals/xopc-use.js +5 -4
  113. package/dist/src/agent/tools/automation-tool.d.ts +4 -1
  114. package/dist/src/agent/tools/automation-tool.js +42 -4
  115. package/dist/src/agent/tools/session-search-tool.js +1 -1
  116. package/dist/src/agent/tools/web-extract.js +1 -1
  117. package/dist/src/agent/tools/xopc-use-tool.js +49 -8
  118. package/dist/src/ai-assist/text-assist.js +5 -1
  119. package/dist/src/automations/api/routes.js +65 -0
  120. package/dist/src/automations/capabilities/read.js +24 -0
  121. package/dist/src/automations/capabilities/write.d.ts +52 -14
  122. package/dist/src/automations/capabilities/write.js +52 -3
  123. package/dist/src/automations/delivery/delivery-router.d.ts +50 -0
  124. package/dist/src/automations/delivery/delivery-router.js +318 -0
  125. package/dist/src/automations/delivery/index.d.ts +1 -0
  126. package/dist/src/automations/delivery/index.js +2 -0
  127. package/dist/src/automations/domain/defaults.d.ts +0 -1
  128. package/dist/src/automations/domain/defaults.js +1 -1
  129. package/dist/src/automations/domain/index.js +2 -2
  130. package/dist/src/automations/domain/types.d.ts +158 -7
  131. package/dist/src/automations/domain/validation.d.ts +104 -22
  132. package/dist/src/automations/domain/validation.js +66 -13
  133. package/dist/src/automations/draft/automation-draft-prompt.js +3 -4
  134. package/dist/src/automations/draft/automation-draft-service.js +6 -0
  135. package/dist/src/automations/draft/automation-draft-validator.d.ts +22 -3
  136. package/dist/src/automations/draft/automation-draft-validator.js +4 -4
  137. package/dist/src/automations/events/event-catalog.d.ts +14 -0
  138. package/dist/src/automations/events/event-catalog.js +117 -0
  139. package/dist/src/automations/events/event-dispatcher.d.ts +27 -0
  140. package/dist/src/automations/events/event-dispatcher.js +140 -0
  141. package/dist/src/automations/events/event-repository.d.ts +59 -0
  142. package/dist/src/automations/events/event-repository.js +361 -0
  143. package/dist/src/automations/events/index.d.ts +3 -0
  144. package/dist/src/automations/events/index.js +4 -0
  145. package/dist/src/automations/index.d.ts +3 -1
  146. package/dist/src/automations/index.js +9 -3
  147. package/dist/src/automations/service/action-executor.d.ts +20 -1
  148. package/dist/src/automations/service/action-executor.js +80 -40
  149. package/dist/src/automations/service/automation-service.d.ts +21 -4
  150. package/dist/src/automations/service/automation-service.js +150 -100
  151. package/dist/src/automations/storage/automation-repository.js +4 -5
  152. package/dist/src/automations/storage/automation-run-repository.d.ts +1 -0
  153. package/dist/src/automations/storage/automation-run-repository.js +26 -1
  154. package/dist/src/automations/storage/index.js +2 -2
  155. package/dist/src/automations/webhook-secrets.d.ts +1 -0
  156. package/dist/src/automations/webhook-secrets.js +16 -0
  157. package/dist/src/capabilities/store-connector.d.ts +17 -1
  158. package/dist/src/capabilities/store-connector.js +69 -3
  159. package/dist/src/cli/commands/connectors.js +4 -3
  160. package/dist/src/cli/commands/doctor/checks/automation-integrity.d.ts +2 -0
  161. package/dist/src/cli/commands/doctor/checks/automation-integrity.js +55 -0
  162. package/dist/src/cli/commands/doctor/checks/database-relations.d.ts +2 -0
  163. package/dist/src/cli/commands/doctor/checks/database-relations.js +81 -0
  164. package/dist/src/cli/commands/doctor/checks/database-schema.js +1 -1
  165. package/dist/src/cli/commands/doctor/flow.js +5 -1
  166. package/dist/src/cli/commands/extension-marketplace.js +1 -1
  167. package/dist/src/cli/commands/skills.js +1 -1
  168. package/dist/src/connectors/approval-resume.js +1 -1
  169. package/dist/src/connectors/cli/store.js +1 -1
  170. package/dist/src/connectors/composio-backends.js +14 -4
  171. package/dist/src/connectors/composio-managed-events.d.ts +5 -2
  172. package/dist/src/connectors/composio-managed-events.js +4 -1
  173. package/dist/src/connectors/connection-recovery-service.d.ts +2 -1
  174. package/dist/src/connectors/connection-recovery-service.js +89 -4
  175. package/dist/src/discussions/analyzer.js +4 -4
  176. package/dist/src/extensions/update.js +1 -1
  177. package/dist/src/gateway/agent-builtin-tools.d.ts +1 -1
  178. package/dist/src/gateway/home-intelligence-automation-reconciler.js +4 -1
  179. package/dist/src/gateway/hono/routes/capabilities.js +1 -1
  180. package/dist/src/gateway/hono/routes/connection-waits.js +3 -2
  181. package/dist/src/gateway/hono/routes/lazy-bundles.js +14 -1
  182. package/dist/src/gateway/hono/routes/public-gateway.js +93 -3
  183. package/dist/src/gateway/hono/routes/scenes.js +57 -41
  184. package/dist/src/gateway/hono/routes/sessions.js +15 -0
  185. package/dist/src/gateway/hono/routes/usage.d.ts +3 -0
  186. package/dist/src/gateway/hono/routes/usage.js +61 -0
  187. package/dist/src/gateway/hono/routes/voice.js +1 -1
  188. package/dist/src/gateway/memory-maintenance-automation-reconciler.js +5 -2
  189. package/dist/src/gateway/scenes/host.js +27 -14
  190. package/dist/src/gateway/scenes/slackThreadSource.d.ts +2 -2
  191. package/dist/src/gateway/security/gateway-scopes.js +1 -0
  192. package/dist/src/gateway/service/active-execution.d.ts +19 -0
  193. package/dist/src/gateway/service/active-execution.js +16 -0
  194. package/dist/src/gateway/service/agent-runner.d.ts +4 -0
  195. package/dist/src/gateway/service/agent-runner.js +19 -1
  196. package/dist/src/gateway/service/marketplace-service.js +2 -2
  197. package/dist/src/gateway/service/run-gateway-agent.d.ts +2 -0
  198. package/dist/src/gateway/service/run-gateway-agent.js +9 -1
  199. package/dist/src/gateway/service/sessions-api.d.ts +13 -0
  200. package/dist/src/gateway/service/sessions-api.js +23 -0
  201. package/dist/src/gateway/service.d.ts +6 -3
  202. package/dist/src/gateway/service.js +82 -85
  203. package/dist/src/gateway/side-chat/run-service.js +10 -7
  204. package/dist/src/home-intelligence/generator.js +4 -1
  205. package/dist/src/home-intelligence/host.js +1 -1
  206. package/dist/src/infra/domain-outbox-dispatcher.d.ts +0 -3
  207. package/dist/src/infra/domain-outbox-dispatcher.js +15 -7
  208. package/dist/src/local-apps/service.js +1 -1
  209. package/dist/src/notes/service.js +2 -3
  210. package/dist/src/projects/project-service.js +1 -2
  211. package/dist/src/projects/project-skill-service.js +2 -2
  212. package/dist/src/providers/model-call.d.ts +3 -2
  213. package/dist/src/providers/model-call.js +30 -5
  214. package/dist/src/scenes/activationAdapter.d.ts +19 -0
  215. package/dist/src/scenes/activationAdapter.js +1 -0
  216. package/dist/src/scenes/agentExecutor.js +3 -10
  217. package/dist/src/scenes/contracts.d.ts +3 -9
  218. package/dist/src/scenes/contracts.js +1 -0
  219. package/dist/src/scenes/execution.d.ts +9 -3
  220. package/dist/src/scenes/execution.js +12 -11
  221. package/dist/src/scenes/httpServices.d.ts +5 -2
  222. package/dist/src/scenes/mailContext.d.ts +4 -0
  223. package/dist/src/scenes/mailContext.js +9 -0
  224. package/dist/src/scenes/maintenance.js +1 -5
  225. package/dist/src/scenes/metrics.d.ts +0 -6
  226. package/dist/src/scenes/metrics.js +0 -11
  227. package/dist/src/scenes/registry.d.ts +11 -0
  228. package/dist/src/scenes/registry.js +28 -0
  229. package/dist/src/scenes/repository.d.ts +6 -3
  230. package/dist/src/scenes/repository.js +43 -5
  231. package/dist/src/scenes/service.d.ts +2 -1
  232. package/dist/src/scenes/service.js +9 -7
  233. package/dist/src/scenes/taskFollowUp/contracts.d.ts +37 -7
  234. package/dist/src/scenes/taskFollowUp/contracts.js +36 -17
  235. package/dist/src/scenes/taskFollowUp/service.d.ts +35 -7
  236. package/dist/src/scenes/taskFollowUp/service.js +86 -28
  237. package/dist/src/scenes/templates.d.ts +2 -2
  238. package/dist/src/scenes/userNotes.d.ts +3 -0
  239. package/dist/src/scenes/userNotes.js +6 -0
  240. package/dist/src/session/client-history.d.ts +3 -0
  241. package/dist/src/session/client-history.js +10 -5
  242. package/dist/src/session/manager.d.ts +1 -0
  243. package/dist/src/session/resolve-session.js +4 -3
  244. package/dist/src/session/session-title.js +1 -1
  245. package/dist/src/session/store.d.ts +1 -0
  246. package/dist/src/session/store.js +3 -2
  247. package/dist/src/storage/sqlite/ai-usage-repository.d.ts +137 -0
  248. package/dist/src/storage/sqlite/ai-usage-repository.js +175 -0
  249. package/dist/src/storage/sqlite/connector-account-repository.js +7 -5
  250. package/dist/src/storage/sqlite/connector-repository.js +36 -34
  251. package/dist/src/storage/sqlite/index.d.ts +2 -2
  252. package/dist/src/storage/sqlite/index.js +3 -3
  253. package/dist/src/storage/sqlite/migrations/209_automation_event_hub.sql +48 -0
  254. package/dist/src/storage/sqlite/migrations/210_remove_legacy_automation_timeout.sql +14 -0
  255. package/dist/src/storage/sqlite/migrations/211_automation_result_deliveries.sql +16 -0
  256. package/dist/src/storage/sqlite/migrations/212_automation_delivery_policy.sql +30 -0
  257. package/dist/src/storage/sqlite/migrations/213_automation_reliability_contract.sql +188 -0
  258. package/dist/src/storage/sqlite/migrations/214_ai_usage_ledger.sql +41 -0
  259. package/dist/src/storage/sqlite/migrations/215_scene_execution_adapters.sql +6 -0
  260. package/dist/src/storage/sqlite/migrations/216_remove_scene_model_usage.sql +1 -0
  261. package/dist/src/storage/sqlite/migrations/217_remove_legacy_memory_tables.sql +4 -0
  262. package/dist/src/storage/sqlite/migrations/218_core_relation_indexes.sql +26 -0
  263. package/dist/src/storage/sqlite/migrations/219_json_contracts.sql +123 -0
  264. package/dist/src/storage/sqlite/migrations/220_normalize_timestamps.sql +339 -0
  265. package/dist/src/storage/sqlite/migrations/221_ai_usage_retention_index.sql +2 -0
  266. package/dist/src/storage/sqlite/migrations/222_session_config_authority.sql +13 -0
  267. package/dist/src/storage/sqlite/migrations/runner.d.ts +1 -1
  268. package/dist/src/storage/sqlite/migrations/runner.js +4 -4
  269. package/dist/src/storage/sqlite/row-mappers.d.ts +3 -7
  270. package/dist/src/storage/sqlite/row-mappers.js +6 -6
  271. package/dist/src/storage/sqlite/scenes-schema.d.ts +1 -1
  272. package/dist/src/storage/sqlite/scenes-schema.js +0 -1
  273. package/dist/src/storage/sqlite/schema.js +1 -1
  274. package/dist/src/storage/sqlite/schema.sql +0 -52
  275. package/dist/src/storage/sqlite/schemas/scenes.sql +0 -7
  276. package/dist/src/storage/sqlite/session-input-repository.d.ts +8 -0
  277. package/dist/src/storage/sqlite/session-input-repository.js +18 -1
  278. package/dist/src/storage/sqlite/session-read-repository.d.ts +1 -1
  279. package/dist/src/storage/sqlite/session-read-repository.js +0 -1
  280. package/dist/src/storage/sqlite/session-repository.d.ts +0 -4
  281. package/dist/src/storage/sqlite/session-repository.js +8 -18
  282. package/dist/src/storage/sqlite/timestamps.d.ts +4 -0
  283. package/dist/src/storage/sqlite/timestamps.js +20 -0
  284. package/dist/src/storage/sqlite/transcript-repository.d.ts +1 -0
  285. package/dist/src/storage/sqlite/transcript-repository.js +23 -15
  286. package/dist/src/storage/sqlite/user-trust-repository.js +4 -2
  287. package/dist/src/tasks/capabilities/write.d.ts +1 -1
  288. package/dist/src/tasks/home-query-service.js +3 -3
  289. package/dist/src/tasks/task-contract-planner.js +1 -1
  290. package/dist/src/usage/cost.d.ts +4 -0
  291. package/dist/src/usage/cost.js +28 -0
  292. package/dist/src/usage/recorder.d.ts +13 -0
  293. package/dist/src/usage/recorder.js +117 -0
  294. package/dist/src/usage/scenario-registry.d.ts +8 -0
  295. package/dist/src/usage/scenario-registry.js +117 -0
  296. package/dist/src/usage/types.d.ts +55 -0
  297. package/dist/src/usage/types.js +1 -0
  298. package/dist/src/voice/tts/summarize.js +1 -1
  299. package/dist/src/work-discovery/analyzer.js +2 -2
  300. package/dist/src/work-discovery/investigator.js +1 -1
  301. package/dist/src/workflows/service/workflow-run-service.js +15 -2
  302. package/package.json +3 -3
  303. package/dist/gateway/static/root/assets/agent-defaults-settings-panel-Se1Z72VG.js +0 -1
  304. package/dist/gateway/static/root/assets/agents-udIitwV8.js +0 -70
  305. package/dist/gateway/static/root/assets/automations-workspace-BMgJvdcv.js +0 -7
  306. package/dist/gateway/static/root/assets/browser-settings-page-xwTmuZjS.js +0 -3
  307. package/dist/gateway/static/root/assets/capabilities-CHA-sTAZ.js +0 -1
  308. package/dist/gateway/static/root/assets/capabilities-settings-panel-DefBGjhV.js +0 -8
  309. package/dist/gateway/static/root/assets/channels-Eo4ONF5X.js +0 -1
  310. package/dist/gateway/static/root/assets/connectors-page-DZYgogQw.js +0 -2
  311. package/dist/gateway/static/root/assets/home-page-D7YoMHq4.js +0 -1
  312. package/dist/gateway/static/root/assets/index-BEw0xrde.css +0 -1
  313. package/dist/gateway/static/root/assets/index-DalslRUx.js +0 -121
  314. package/dist/gateway/static/root/assets/local-app-workbench-page-BKL5UZAj.js +0 -1
  315. package/dist/gateway/static/root/assets/management-settings-Dk_gTJb9.js +0 -1
  316. package/dist/gateway/static/root/assets/messages-fmf0dnr4.js +0 -3
  317. package/dist/gateway/static/root/assets/note-detail-panel-BebJPjjk.js +0 -5
  318. package/dist/gateway/static/root/assets/notes-page-CmS_hvz8.js +0 -8
  319. package/dist/gateway/static/root/assets/project-detail-page-BFUdtWXF.js +0 -1
  320. package/dist/gateway/static/root/assets/scenes-page-Cj8xtr5t.js +0 -2
  321. package/dist/gateway/static/root/assets/sessions-page-BCsjgkCs.js +0 -1
  322. package/dist/gateway/static/root/assets/settings-advanced-gate-BLL7csOJ.js +0 -1
  323. package/dist/gateway/static/root/assets/shares-settings-BzvSNouj.js +0 -1
  324. package/dist/gateway/static/root/assets/skill-reload-api-BHnru0F5.js +0 -1
  325. package/dist/gateway/static/root/assets/task-detail-page-Bd1_Fguk.js +0 -1
  326. package/dist/gateway/static/root/assets/user-model-page-DuYzuR1T.js +0 -2
  327. package/dist/gateway/static/root/assets/workflows-page-B45YDiEw.js +0 -6
  328. package/dist/src/automations/product-events.d.ts +0 -5
  329. package/dist/src/automations/product-events.js +0 -19
@@ -67,15 +67,41 @@ export interface AutomationManagement {
67
67
  }
68
68
  export type AutomationConversationMode = 'new_session' | 'continuous';
69
69
  export type AutomationNotificationPolicy = 'attention' | 'all' | 'none';
70
+ export type AutomationDeliveryDestination = {
71
+ key: string;
72
+ kind: 'gateway_event';
73
+ } | {
74
+ key: string;
75
+ kind: 'webhook';
76
+ endpoint: string;
77
+ secretId: string;
78
+ } | {
79
+ key: string;
80
+ kind: 'file';
81
+ targetId: string;
82
+ pathTemplate: string;
83
+ } | {
84
+ key: string;
85
+ kind: 'card';
86
+ channelId: string;
87
+ templateId: string;
88
+ };
89
+ export interface AutomationDeliveryPolicy {
90
+ notificationPolicy: AutomationNotificationPolicy;
91
+ destinations: AutomationDeliveryDestination[];
92
+ }
93
+ export interface AutomationRunDeliveryContext {
94
+ notificationPolicy: AutomationNotificationPolicy;
95
+ requiresAttention: boolean;
96
+ projectId?: string;
97
+ }
70
98
  export interface AutomationReliability {
71
- /** Overall run deadline. `timeoutSeconds` remains a read-only legacy fallback. */
72
99
  executionTimeoutSeconds?: number;
73
- timeoutSeconds?: number;
74
100
  retryCount?: number;
75
101
  maxConcurrentRuns?: number;
76
102
  disableAfterConsecutiveFailures?: number;
77
103
  }
78
- export type AutomationRunPhase = 'queued' | 'action' | 'completion_hook' | 'cancelling' | 'completed';
104
+ export type AutomationRunPhase = 'queued' | 'action' | 'cancelling' | 'completed';
79
105
  export interface AutomationRunTermination {
80
106
  reason: 'completed' | 'failed' | 'user_cancelled' | 'deadline_exceeded';
81
107
  component?: 'automation' | 'agent_turn' | 'tool' | 'mcp' | 'process';
@@ -104,8 +130,7 @@ export interface Automation {
104
130
  action: AutomationAction;
105
131
  safety?: AutomationSafetyPolicy;
106
132
  conversationMode: AutomationConversationMode;
107
- notificationPolicy: AutomationNotificationPolicy;
108
- completionWebhookUrl?: string;
133
+ delivery: AutomationDeliveryPolicy;
109
134
  reliability?: AutomationReliability;
110
135
  management?: AutomationManagement;
111
136
  state: AutomationState;
@@ -142,7 +167,7 @@ export interface AutomationRun {
142
167
  rootRunId?: string;
143
168
  readAtMs?: number;
144
169
  }
145
- export type AutomationRunEventType = 'run.queued' | 'run.started' | 'run.deadline_resolved' | 'run.cancel_requested' | 'run.cancel_confirmed' | 'run.cancellation_unconfirmed' | 'run.recovered' | 'action.started' | 'action.retry_scheduled' | 'action.completed' | 'action.failed' | 'completion_hook.started' | 'completion_hook.completed' | 'completion_hook.failed' | 'run.completed';
170
+ export type AutomationRunEventType = 'run.queued' | 'run.started' | 'run.deadline_resolved' | 'run.cancel_requested' | 'run.cancel_confirmed' | 'run.cancellation_unconfirmed' | 'run.recovered' | 'action.started' | 'action.retry_scheduled' | 'action.completed' | 'action.failed' | 'run.completed';
146
171
  export interface AutomationRunEvent {
147
172
  id: string;
148
173
  runId: string;
@@ -157,10 +182,60 @@ export interface AutomationProductEventRun {
157
182
  triggerEvent: AutomationRunEvent;
158
183
  }
159
184
  export interface AutomationEvent {
185
+ id?: string;
160
186
  type: string;
161
187
  source?: string;
188
+ schemaVersion?: number;
189
+ subject?: {
190
+ kind: string;
191
+ id: string;
192
+ };
162
193
  payload?: Record<string, unknown>;
163
194
  occurredAtMs?: number;
195
+ correlationId?: string;
196
+ causationId?: string;
197
+ rootEventId?: string;
198
+ chainDepth?: number;
199
+ dedupeKey?: string;
200
+ trust?: 'system' | 'user' | 'connector' | 'untrusted_webhook';
201
+ }
202
+ export interface AutomationEventEnvelope extends AutomationEvent {
203
+ id: string;
204
+ source: string;
205
+ schemaVersion: number;
206
+ occurredAtMs: number;
207
+ ingestedAtMs: number;
208
+ correlationId: string;
209
+ rootEventId: string;
210
+ chainDepth: number;
211
+ trust: 'system' | 'user' | 'connector' | 'untrusted_webhook';
212
+ payload: Record<string, unknown>;
213
+ }
214
+ export type AutomationEventProjectionStatus = 'pending' | 'projecting' | 'retrying' | 'projected' | 'dead_letter';
215
+ export type AutomationEventDeliveryStatus = 'pending' | 'retrying' | 'queued' | 'completed' | 'failed' | 'cancelled' | 'skipped' | 'dead_letter';
216
+ export interface AutomationEventRecord {
217
+ event: AutomationEventEnvelope;
218
+ projectionStatus: AutomationEventProjectionStatus;
219
+ projectionAttempts: number;
220
+ projectionError?: string;
221
+ deliveries: Array<{
222
+ automationId: string;
223
+ status: AutomationEventDeliveryStatus;
224
+ runId?: string;
225
+ attempts: number;
226
+ lastError?: string;
227
+ }>;
228
+ }
229
+ export interface AutomationResultDeliveryRecord {
230
+ runId: string;
231
+ destinationKey: string;
232
+ kind: string;
233
+ status: 'pending' | 'delivering' | 'retrying' | 'delivered' | 'dead_letter';
234
+ attempts: number;
235
+ nextAttemptAtMs: number;
236
+ lastError?: string;
237
+ createdAtMs: number;
238
+ updatedAtMs: number;
164
239
  }
165
240
  export interface AutomationMetrics {
166
241
  totalAutomations: number;
@@ -172,7 +247,73 @@ export interface AutomationMetrics {
172
247
  name: string;
173
248
  runAtMs: number;
174
249
  };
250
+ pendingEvents: number;
251
+ oldestPendingEventAgeMs: number;
252
+ projectionDeadLetters: number;
253
+ pendingRunDeliveries: number;
254
+ runDeliveryDeadLetters: number;
255
+ pendingResultDeliveries: number;
256
+ resultDeliveryDeadLetters: number;
257
+ activeExecutions: number;
258
+ activeDeliveryLeases: number;
259
+ }
260
+ export type AutomationArtifact = {
261
+ id: string;
262
+ kind: 'text';
263
+ text: string;
264
+ mediaType: 'text/plain' | 'text/markdown';
265
+ } | {
266
+ id: string;
267
+ kind: 'json';
268
+ schema: string;
269
+ data: Record<string, unknown>;
270
+ } | {
271
+ id: string;
272
+ kind: 'file';
273
+ uri: string;
274
+ name: string;
275
+ mediaType: string;
276
+ bytes?: number;
277
+ sha256?: string;
278
+ } | {
279
+ id: string;
280
+ kind: 'card';
281
+ schema: string;
282
+ data: Record<string, unknown>;
283
+ } | {
284
+ id: string;
285
+ kind: 'reference';
286
+ resourceType: string;
287
+ resourceId: string;
288
+ url?: string;
289
+ };
290
+ export interface AutomationResultEnvelope {
291
+ schemaVersion: 1;
292
+ resultId: string;
293
+ runId: string;
294
+ automationId: string;
295
+ status: Extract<AutomationRunStatus, 'succeeded' | 'failed' | 'cancelled' | 'timeout'>;
296
+ summary?: string;
297
+ error?: {
298
+ code: string;
299
+ message: string;
300
+ retryable: boolean;
301
+ };
302
+ artifacts: AutomationArtifact[];
303
+ correlationId: string;
304
+ rootEventId: string;
305
+ createdAtMs: number;
306
+ completedAtMs: number;
175
307
  }
308
+ export type AutomationRetrySafety = {
309
+ mode: 'never';
310
+ } | {
311
+ mode: 'idempotent';
312
+ key: 'run_id';
313
+ } | {
314
+ mode: 'transient_only';
315
+ classify: (error: unknown) => boolean;
316
+ };
176
317
  export interface PrepareAutomationAgentSessionInput {
177
318
  automationName?: string;
178
319
  conversationId: string;
@@ -210,7 +351,16 @@ export interface AutomationDeps {
210
351
  error?: string;
211
352
  }>;
212
353
  };
213
- onRunCompleted?: (run: AutomationRun) => void;
354
+ onRunCompleted?: (run: AutomationRun, context: AutomationRunDeliveryContext) => void | Promise<void>;
355
+ onEvent?: (event: AutomationEventEnvelope, signal?: AbortSignal) => void | Promise<void>;
356
+ onReliabilityAttention?: (input: {
357
+ phase: 'event_projection' | 'event_delivery' | 'result_delivery';
358
+ eventId?: string;
359
+ automationId?: string;
360
+ runId?: string;
361
+ destinationKey?: string;
362
+ error: string;
363
+ }) => void;
214
364
  executeTaskCommand?: (input: {
215
365
  taskId: string;
216
366
  idempotencyKey: string;
@@ -242,6 +392,7 @@ export interface AutomationActionTask {
242
392
  model?: string;
243
393
  deadlineAtMs?: number;
244
394
  termination?: AutomationRunTermination;
395
+ artifacts?: AutomationArtifact[];
245
396
  }
246
397
  export interface AutomationActionExecutionHooks {
247
398
  onRunPatch?: (patch: Partial<AutomationRun>) => void | Promise<void>;
@@ -171,7 +171,6 @@ export declare const AutomationManagementSchema: z.ZodObject<{
171
171
  }, z.core.$strict>;
172
172
  export declare const AutomationReliabilitySchema: z.ZodObject<{
173
173
  executionTimeoutSeconds: z.ZodOptional<z.ZodNumber>;
174
- timeoutSeconds: z.ZodOptional<z.ZodNumber>;
175
174
  retryCount: z.ZodOptional<z.ZodNumber>;
176
175
  maxConcurrentRuns: z.ZodOptional<z.ZodNumber>;
177
176
  disableAfterConsecutiveFailures: z.ZodOptional<z.ZodNumber>;
@@ -183,6 +182,32 @@ export declare const AutomationSafetyPolicySchema: z.ZodObject<{
183
182
  auto_apply: "auto_apply";
184
183
  }>;
185
184
  }, z.core.$strict>;
185
+ export declare const AutomationDeliveryPolicySchema: z.ZodObject<{
186
+ notificationPolicy: z.ZodDefault<z.ZodEnum<{
187
+ attention: "attention";
188
+ all: "all";
189
+ none: "none";
190
+ }>>;
191
+ destinations: z.ZodDefault<z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
192
+ key: z.ZodString;
193
+ kind: z.ZodLiteral<"gateway_event">;
194
+ }, z.core.$strict>, z.ZodObject<{
195
+ key: z.ZodString;
196
+ kind: z.ZodLiteral<"webhook">;
197
+ endpoint: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
198
+ secretId: z.ZodString;
199
+ }, z.core.$strict>, z.ZodObject<{
200
+ key: z.ZodString;
201
+ kind: z.ZodLiteral<"file">;
202
+ targetId: z.ZodString;
203
+ pathTemplate: z.ZodString;
204
+ }, z.core.$strict>, z.ZodObject<{
205
+ key: z.ZodString;
206
+ kind: z.ZodLiteral<"card">;
207
+ channelId: z.ZodString;
208
+ templateId: z.ZodString;
209
+ }, z.core.$strict>], "kind">>>;
210
+ }, z.core.$strict>;
186
211
  export declare const AutomationStateSchema: z.ZodObject<{
187
212
  nextRunAtMs: z.ZodOptional<z.ZodNumber>;
188
213
  runningRunId: z.ZodPipe<z.ZodOptional<z.ZodNullable<z.ZodString>>, z.ZodTransform<string, string>>;
@@ -365,15 +390,34 @@ export declare const AutomationSchema: z.ZodObject<{
365
390
  new_session: "new_session";
366
391
  continuous: "continuous";
367
392
  }>>;
368
- notificationPolicy: z.ZodDefault<z.ZodEnum<{
369
- attention: "attention";
370
- all: "all";
371
- none: "none";
372
- }>>;
373
- completionWebhookUrl: z.ZodPipe<z.ZodOptional<z.ZodNullable<z.ZodString>>, z.ZodTransform<string, string>>;
393
+ delivery: z.ZodDefault<z.ZodObject<{
394
+ notificationPolicy: z.ZodDefault<z.ZodEnum<{
395
+ attention: "attention";
396
+ all: "all";
397
+ none: "none";
398
+ }>>;
399
+ destinations: z.ZodDefault<z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
400
+ key: z.ZodString;
401
+ kind: z.ZodLiteral<"gateway_event">;
402
+ }, z.core.$strict>, z.ZodObject<{
403
+ key: z.ZodString;
404
+ kind: z.ZodLiteral<"webhook">;
405
+ endpoint: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
406
+ secretId: z.ZodString;
407
+ }, z.core.$strict>, z.ZodObject<{
408
+ key: z.ZodString;
409
+ kind: z.ZodLiteral<"file">;
410
+ targetId: z.ZodString;
411
+ pathTemplate: z.ZodString;
412
+ }, z.core.$strict>, z.ZodObject<{
413
+ key: z.ZodString;
414
+ kind: z.ZodLiteral<"card">;
415
+ channelId: z.ZodString;
416
+ templateId: z.ZodString;
417
+ }, z.core.$strict>], "kind">>>;
418
+ }, z.core.$strict>>;
374
419
  reliability: z.ZodOptional<z.ZodObject<{
375
420
  executionTimeoutSeconds: z.ZodOptional<z.ZodNumber>;
376
- timeoutSeconds: z.ZodOptional<z.ZodNumber>;
377
421
  retryCount: z.ZodOptional<z.ZodNumber>;
378
422
  maxConcurrentRuns: z.ZodOptional<z.ZodNumber>;
379
423
  disableAfterConsecutiveFailures: z.ZodOptional<z.ZodNumber>;
@@ -570,15 +614,34 @@ export declare const CreateAutomationSchema: z.ZodObject<{
570
614
  new_session: "new_session";
571
615
  continuous: "continuous";
572
616
  }>>;
573
- notificationPolicy: z.ZodDefault<z.ZodEnum<{
574
- attention: "attention";
575
- all: "all";
576
- none: "none";
577
- }>>;
578
- completionWebhookUrl: z.ZodPipe<z.ZodOptional<z.ZodNullable<z.ZodString>>, z.ZodTransform<string, string>>;
617
+ delivery: z.ZodDefault<z.ZodObject<{
618
+ notificationPolicy: z.ZodDefault<z.ZodEnum<{
619
+ attention: "attention";
620
+ all: "all";
621
+ none: "none";
622
+ }>>;
623
+ destinations: z.ZodDefault<z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
624
+ key: z.ZodString;
625
+ kind: z.ZodLiteral<"gateway_event">;
626
+ }, z.core.$strict>, z.ZodObject<{
627
+ key: z.ZodString;
628
+ kind: z.ZodLiteral<"webhook">;
629
+ endpoint: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
630
+ secretId: z.ZodString;
631
+ }, z.core.$strict>, z.ZodObject<{
632
+ key: z.ZodString;
633
+ kind: z.ZodLiteral<"file">;
634
+ targetId: z.ZodString;
635
+ pathTemplate: z.ZodString;
636
+ }, z.core.$strict>, z.ZodObject<{
637
+ key: z.ZodString;
638
+ kind: z.ZodLiteral<"card">;
639
+ channelId: z.ZodString;
640
+ templateId: z.ZodString;
641
+ }, z.core.$strict>], "kind">>>;
642
+ }, z.core.$strict>>;
579
643
  reliability: z.ZodOptional<z.ZodObject<{
580
644
  executionTimeoutSeconds: z.ZodOptional<z.ZodNumber>;
581
- timeoutSeconds: z.ZodOptional<z.ZodNumber>;
582
645
  retryCount: z.ZodOptional<z.ZodNumber>;
583
646
  maxConcurrentRuns: z.ZodOptional<z.ZodNumber>;
584
647
  disableAfterConsecutiveFailures: z.ZodOptional<z.ZodNumber>;
@@ -772,10 +835,8 @@ export declare const UpdateAutomationSchema: z.ZodObject<{
772
835
  auto_apply: "auto_apply";
773
836
  }>;
774
837
  }, z.core.$strict>>>;
775
- completionWebhookUrl: z.ZodOptional<z.ZodPipe<z.ZodOptional<z.ZodNullable<z.ZodString>>, z.ZodTransform<string, string>>>;
776
838
  reliability: z.ZodOptional<z.ZodOptional<z.ZodObject<{
777
839
  executionTimeoutSeconds: z.ZodOptional<z.ZodNumber>;
778
- timeoutSeconds: z.ZodOptional<z.ZodNumber>;
779
840
  retryCount: z.ZodOptional<z.ZodNumber>;
780
841
  maxConcurrentRuns: z.ZodOptional<z.ZodNumber>;
781
842
  disableAfterConsecutiveFailures: z.ZodOptional<z.ZodNumber>;
@@ -793,11 +854,32 @@ export declare const UpdateAutomationSchema: z.ZodObject<{
793
854
  new_session: "new_session";
794
855
  continuous: "continuous";
795
856
  }>>;
796
- notificationPolicy: z.ZodOptional<z.ZodEnum<{
797
- attention: "attention";
798
- all: "all";
799
- none: "none";
800
- }>>;
857
+ delivery: z.ZodOptional<z.ZodOptional<z.ZodObject<{
858
+ notificationPolicy: z.ZodDefault<z.ZodEnum<{
859
+ attention: "attention";
860
+ all: "all";
861
+ none: "none";
862
+ }>>;
863
+ destinations: z.ZodDefault<z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
864
+ key: z.ZodString;
865
+ kind: z.ZodLiteral<"gateway_event">;
866
+ }, z.core.$strict>, z.ZodObject<{
867
+ key: z.ZodString;
868
+ kind: z.ZodLiteral<"webhook">;
869
+ endpoint: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
870
+ secretId: z.ZodString;
871
+ }, z.core.$strict>, z.ZodObject<{
872
+ key: z.ZodString;
873
+ kind: z.ZodLiteral<"file">;
874
+ targetId: z.ZodString;
875
+ pathTemplate: z.ZodString;
876
+ }, z.core.$strict>, z.ZodObject<{
877
+ key: z.ZodString;
878
+ kind: z.ZodLiteral<"card">;
879
+ channelId: z.ZodString;
880
+ templateId: z.ZodString;
881
+ }, z.core.$strict>], "kind">>>;
882
+ }, z.core.$strict>>>;
801
883
  state: z.ZodOptional<z.ZodObject<{
802
884
  nextRunAtMs: z.ZodOptional<z.ZodNumber>;
803
885
  runningRunId: z.ZodPipe<z.ZodOptional<z.ZodNullable<z.ZodString>>, z.ZodTransform<string, string>>;
@@ -6,6 +6,19 @@ import { CronExpressionParser } from "cron-parser";
6
6
  init_src();
7
7
  const nonEmptyString = z.string().trim().min(1);
8
8
  const optionalTrimmedString = (max) => z.string().trim().max(max).nullish().transform((value) => value || void 0);
9
+ const httpsUrl = z.string().trim().min(1).max(2e3).transform((value, ctx) => {
10
+ try {
11
+ const parsed = new URL(value);
12
+ if (parsed.protocol !== "https:") throw new Error("unsupported protocol");
13
+ return parsed.toString();
14
+ } catch {
15
+ ctx.addIssue({
16
+ code: "custom",
17
+ message: "Webhook endpoint must be a valid HTTPS URL"
18
+ });
19
+ return z.NEVER;
20
+ }
21
+ });
9
22
  const AutomationScheduleSchema = z.discriminatedUnion("kind", [
10
23
  z.object({
11
24
  kind: z.literal("once"),
@@ -108,7 +121,6 @@ const AutomationManagementSchema = z.object({
108
121
  }).strict();
109
122
  const AutomationReliabilitySchema = z.object({
110
123
  executionTimeoutSeconds: z.number().int().min(1).max(86400).optional(),
111
- timeoutSeconds: z.number().int().min(1).max(86400).optional(),
112
124
  retryCount: z.number().int().min(0).max(10).optional(),
113
125
  maxConcurrentRuns: z.number().int().min(1).max(20).optional(),
114
126
  disableAfterConsecutiveFailures: z.number().int().min(1).max(100).optional()
@@ -118,6 +130,50 @@ const AutomationSafetyPolicySchema = z.object({ mode: z.enum([
118
130
  "ask_before_apply",
119
131
  "auto_apply"
120
132
  ]) }).strict();
133
+ const AutomationDeliveryPolicySchema = z.object({
134
+ notificationPolicy: z.enum([
135
+ "attention",
136
+ "all",
137
+ "none"
138
+ ]).default("attention"),
139
+ destinations: z.array(z.discriminatedUnion("kind", [
140
+ z.object({
141
+ key: nonEmptyString.max(100),
142
+ kind: z.literal("gateway_event")
143
+ }).strict(),
144
+ z.object({
145
+ key: nonEmptyString.max(100),
146
+ kind: z.literal("webhook"),
147
+ endpoint: httpsUrl,
148
+ secretId: nonEmptyString.max(200)
149
+ }).strict(),
150
+ z.object({
151
+ key: nonEmptyString.max(100),
152
+ kind: z.literal("file"),
153
+ targetId: nonEmptyString.max(200),
154
+ pathTemplate: nonEmptyString.max(2e3)
155
+ }).strict(),
156
+ z.object({
157
+ key: nonEmptyString.max(100),
158
+ kind: z.literal("card"),
159
+ channelId: nonEmptyString.max(200),
160
+ templateId: nonEmptyString.max(200)
161
+ }).strict()
162
+ ])).max(20).superRefine((destinations, ctx) => {
163
+ const keys = /* @__PURE__ */ new Set();
164
+ destinations.forEach((destination, index) => {
165
+ if (keys.has(destination.key)) ctx.addIssue({
166
+ code: "custom",
167
+ path: [index, "key"],
168
+ message: `Duplicate destination key: ${destination.key}`
169
+ });
170
+ keys.add(destination.key);
171
+ });
172
+ }).default([{
173
+ key: "gateway_event",
174
+ kind: "gateway_event"
175
+ }])
176
+ }).strict();
121
177
  const AutomationStateSchema = z.object({
122
178
  nextRunAtMs: z.number().int().nonnegative().optional(),
123
179
  runningRunId: optionalTrimmedString(100),
@@ -144,12 +200,13 @@ const AutomationSchema = z.object({
144
200
  action: AutomationActionSchema,
145
201
  safety: AutomationSafetyPolicySchema.optional(),
146
202
  conversationMode: z.enum(["new_session", "continuous"]).default("new_session"),
147
- notificationPolicy: z.enum([
148
- "attention",
149
- "all",
150
- "none"
151
- ]).default("attention"),
152
- completionWebhookUrl: optionalTrimmedString(2e3),
203
+ delivery: AutomationDeliveryPolicySchema.default({
204
+ notificationPolicy: "attention",
205
+ destinations: [{
206
+ key: "gateway_event",
207
+ kind: "gateway_event"
208
+ }]
209
+ }),
153
210
  reliability: AutomationReliabilitySchema.optional(),
154
211
  management: AutomationManagementSchema.optional(),
155
212
  state: AutomationStateSchema.default({}),
@@ -173,12 +230,8 @@ const UpdateAutomationSchema = AutomationSchema.omit({
173
230
  updatedAtMs: true
174
231
  }).extend({
175
232
  conversationMode: z.enum(["new_session", "continuous"]),
176
- notificationPolicy: z.enum([
177
- "attention",
178
- "all",
179
- "none"
180
- ]),
233
+ delivery: AutomationDeliveryPolicySchema.optional(),
181
234
  state: AutomationStateSchema
182
235
  }).partial().refine((data) => Object.keys(data).length > 0, { message: "At least one field must be provided" });
183
236
  //#endregion
184
- export { AutomationActionSchema, AutomationManagementSchema, AutomationReliabilitySchema, AutomationSafetyPolicySchema, AutomationScheduleSchema, AutomationSchema, AutomationStateSchema, AutomationTriggerSchema, CreateAutomationSchema, UpdateAutomationSchema };
237
+ export { AutomationActionSchema, AutomationDeliveryPolicySchema, AutomationManagementSchema, AutomationReliabilitySchema, AutomationSafetyPolicySchema, AutomationScheduleSchema, AutomationSchema, AutomationStateSchema, AutomationTriggerSchema, CreateAutomationSchema, UpdateAutomationSchema };
@@ -11,7 +11,7 @@ JSON shape:
11
11
  "action": { "kind": "agent", "instruction": "clear instruction for the agent" },
12
12
  "safety": { "mode": "suggest_only" },
13
13
  "conversationMode": "new_session",
14
- "notificationPolicy": "attention",
14
+ "delivery": { "notificationPolicy": "attention" },
15
15
  "reliability": { "executionTimeoutSeconds": 300, "disableAfterConsecutiveFailures": 3 }
16
16
  },
17
17
  "explanation": "Short explanation",
@@ -52,7 +52,7 @@ Rules:
52
52
  - Use cron for daily/weekly schedules. Use standard 5-field cron.
53
53
  - Keep executionTimeoutSeconds between 60 and 1800.
54
54
  - Use conversationMode "new_session" unless the user explicitly wants each run to continue the same conversation.
55
- - Use notificationPolicy "attention" unless the user explicitly requests every-run notifications or no notifications.
55
+ - Use delivery.notificationPolicy "attention" unless the user explicitly requests every-run notifications or no notifications.
56
56
  - Language for user-facing copy: ${params.language ?? "en"}.
57
57
 
58
58
  User request:
@@ -85,8 +85,7 @@ JSON shape:
85
85
  "action": "optional complete action object",
86
86
  "safety": "optional complete safety object",
87
87
  "conversationMode": "optional new_session or continuous",
88
- "notificationPolicy": "optional attention, all, or none",
89
- "completionWebhookUrl": "optional HTTPS URL",
88
+ "delivery": { "notificationPolicy": "optional attention, all, or none", "destinations": [{ "key": "stable key", "kind": "gateway_event or webhook", "endpoint": "HTTPS URL for webhook", "secretId": "outbound secret id for webhook" }] },
90
89
  "reliability": "optional complete reliability object",
91
90
  "enabled": true
92
91
  },
@@ -37,6 +37,9 @@ var AutomationDraftService = class {
37
37
  maxTokens: 2048,
38
38
  temperature: attempt === 0 ? .2 : .1,
39
39
  signal
40
+ }, void 0, {
41
+ operation: "automation.generate_draft",
42
+ trigger: attempt === 0 ? "user" : "retry"
40
43
  }));
41
44
  try {
42
45
  return buildAutomationDraftResponse(parseGeneratedAutomationDraft(lastText), attempt);
@@ -90,6 +93,9 @@ var AutomationDraftService = class {
90
93
  maxTokens: 2048,
91
94
  temperature: attempt === 0 ? .15 : .05,
92
95
  signal
96
+ }, void 0, {
97
+ operation: "automation.generate_draft",
98
+ trigger: attempt === 0 ? "user" : "retry"
93
99
  }));
94
100
  try {
95
101
  return parseGeneratedAutomationRepairDraft(lastText, attempt);
@@ -12,7 +12,28 @@ export declare function buildAutomationDraftResponse(draft: GeneratedAutomationD
12
12
  automation: {
13
13
  name: string;
14
14
  conversationMode: "new_session" | "continuous";
15
- notificationPolicy: "attention" | "all" | "none";
15
+ delivery: {
16
+ notificationPolicy: "attention" | "all" | "none";
17
+ destinations: ({
18
+ key: string;
19
+ kind: "gateway_event";
20
+ } | {
21
+ key: string;
22
+ kind: "webhook";
23
+ secretId: string;
24
+ endpoint?: string;
25
+ } | {
26
+ key: string;
27
+ kind: "file";
28
+ targetId: string;
29
+ pathTemplate: string;
30
+ } | {
31
+ key: string;
32
+ kind: "card";
33
+ channelId: string;
34
+ templateId: string;
35
+ })[];
36
+ };
16
37
  projectId?: string;
17
38
  action?: {
18
39
  kind: "agent";
@@ -135,10 +156,8 @@ export declare function buildAutomationDraftResponse(draft: GeneratedAutomationD
135
156
  safety?: {
136
157
  mode: "suggest_only" | "ask_before_apply" | "auto_apply";
137
158
  };
138
- completionWebhookUrl?: string;
139
159
  reliability?: {
140
160
  executionTimeoutSeconds?: number;
141
- timeoutSeconds?: number;
142
161
  retryCount?: number;
143
162
  maxConcurrentRuns?: number;
144
163
  disableAfterConsecutiveFailures?: number;
@@ -54,9 +54,9 @@ function simulateAutomation(input) {
54
54
  const triggerSummary = summarizeTrigger(automation.trigger);
55
55
  const actionSummary = summarizeAction(automation.action);
56
56
  if (automation.action.kind === "agent" && /delete|remove|send|post|publish|付款|删除|发送|发布/i.test(automation.action.instruction)) requiredConfirmations.push("Agent instruction may perform an external or destructive action.");
57
- if (automation.completionWebhookUrl) {
58
- safetyNotes.push("The completion webhook will call an external URL after each run.");
59
- requiredConfirmations.push("External webhook call should be reviewed before publishing.");
57
+ if (automation.delivery.destinations.some((destination) => destination.kind === "webhook")) {
58
+ safetyNotes.push("The result webhook will call an external URL after each run.");
59
+ requiredConfirmations.push("External result delivery should be reviewed before publishing.");
60
60
  }
61
61
  const safetyMode = automation.safety?.mode ?? "auto_apply";
62
62
  if (safetyMode === "suggest_only") safetyNotes.push("Suggest-only safety mode will generate recommendations without applying changes.");
@@ -97,7 +97,7 @@ function summarizeAction(action) {
97
97
  }
98
98
  function repairPatchNeedsApproval(patch) {
99
99
  if (patch.safety?.mode === "auto_apply") return true;
100
- if (patch.completionWebhookUrl) return true;
100
+ if (patch.delivery?.destinations.some((destination) => destination.kind === "webhook")) return true;
101
101
  if (patch.trigger?.kind === "webhook") return true;
102
102
  if (patch.action?.kind === "agent") return /delete|remove|send|post|publish|付款|删除|发送|发布/i.test(patch.action.instruction);
103
103
  return false;
@@ -0,0 +1,14 @@
1
+ import { type ZodType } from 'zod';
2
+ import type { AutomationEventEnvelope } from '../domain/types.js';
3
+ export interface BusinessEventDefinition<TPayload extends Record<string, unknown> = Record<string, unknown>> {
4
+ type: string;
5
+ source: string;
6
+ schemaVersion: number;
7
+ payloadSchema: ZodType<TPayload>;
8
+ defaultTrust: Extract<AutomationEventEnvelope['trust'], 'system' | 'user' | 'connector'>;
9
+ description: string;
10
+ subjectKind: string;
11
+ }
12
+ export declare function registerBusinessEvent<TPayload extends Record<string, unknown>>(definition: BusinessEventDefinition<TPayload>): void;
13
+ export declare function validateCatalogedBusinessEvent(event: AutomationEventEnvelope): void;
14
+ export declare function listBusinessEventDefinitions(): BusinessEventDefinition[];