@xopcai/xopc 0.0.331 → 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 (388) 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-B0BtF24E.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-DbvLXQO2.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-fwzTRJfP.js → app-management-settings-panel-BcszTlqr.js} +1 -1
  8. package/dist/gateway/static/root/assets/{appearance-settings-v_GGe8UZ.js → appearance-settings-B1XPe8qz.js} +1 -1
  9. package/dist/gateway/static/root/assets/{apps-page-C9ZMEuuA.js → apps-page-ZqANbUZv.js} +1 -1
  10. package/dist/gateway/static/root/assets/{archive-plugin-B6EgADeH.js → archive-plugin-MjUsJcNb.js} +1 -1
  11. package/dist/gateway/static/root/assets/{attachment-load-B4H_IFeX.js → attachment-load-DHa-BI9a.js} +1 -1
  12. package/dist/gateway/static/root/assets/{automations-page-UlVCvg4r.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-BxTSx30f.js → binary-plugins-DQYcuBHP.js} +1 -1
  15. package/dist/gateway/static/root/assets/{block-editor-CVzdrpjl.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-CBVD8k6O.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-BAT7Vvb8.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-EETjXmkG.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-DCqm9j9W.js → chat-terminal-dock-Fnum_IEm.js} +1 -1
  25. package/dist/gateway/static/root/assets/{computer-settings-page-CxFWdovV.js → computer-settings-page-DI1zfCTA.js} +1 -1
  26. package/dist/gateway/static/root/assets/{connector-service-page-wxsEhmlU.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-h_OS6uBR.js → date-picker-D-JhzZyW.js} +1 -1
  29. package/dist/gateway/static/root/assets/{dependency-picker-DNgSSH3z.js → dependency-picker-DpD3xaEB.js} +1 -1
  30. package/dist/gateway/static/root/assets/{desktop-pet-CflvPnB-.js → desktop-pet-CCoDxKqh.js} +1 -1
  31. package/dist/gateway/static/root/assets/{desktop-pet-settings-CXy0X5Js.js → desktop-pet-settings-GxndKfCx.js} +1 -1
  32. package/dist/gateway/static/root/assets/{device-pairing-wizard-BDMiJcsK.js → device-pairing-wizard-B71w3ptm.js} +1 -1
  33. package/dist/gateway/static/root/assets/{directory-picker-path-field-BqkOh13m.js → directory-picker-path-field-CUzjJvjs.js} +1 -1
  34. package/dist/gateway/static/root/assets/{extension-debug-page-VT4s-9pK.js → extension-debug-page-BtDY8ntX.js} +1 -1
  35. package/dist/gateway/static/root/assets/{extension-page-CBSeGhGA.js → extension-page-D9_XF-XC.js} +1 -1
  36. package/dist/gateway/static/root/assets/{extension-settings-page-DRB6uOo8.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-lF-FpnZy.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-DGkOijwE.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-iU6c2zg1.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-C0BWC8D2.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-Dpoi-r-_.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-C8E_F2F_.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-qqWG_gs_.js → page-context-capture-button-D43aVpCj.js} +1 -1
  57. package/dist/gateway/static/root/assets/{page-tabs-b3lheKy4.js → page-tabs-BhYBCqls.js} +1 -1
  58. package/dist/gateway/static/root/assets/{preview-open-alternatives-0Q4rTfGX.js → preview-open-alternatives-CP8agNlc.js} +1 -1
  59. package/dist/gateway/static/root/assets/{product-open-page-jnJZCrKQ.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-r96k_2wB.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-B1d8pB_y.js → remote-access-hub-fVPQe5YS.js} +1 -1
  64. package/dist/gateway/static/root/assets/{runtime-tools-settings-panel-Do_iF13W.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-Cfft26Je.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-iI0MTyuU.js → settings-form-section-jquf1P7n.js} +1 -1
  70. package/dist/gateway/static/root/assets/{settings-page-C2Ka9oJm.js → settings-page-DPomsvba.js} +1 -1
  71. package/dist/gateway/static/root/assets/{setup-status-panel-nnmS_p5h.js → setup-status-panel-BvVlqpHf.js} +1 -1
  72. package/dist/gateway/static/root/assets/{share-preview-page-D0Knvtlp.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-BuZKcy9b.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-DcxWxIrR.js → skills-page-D7XPEQu_.js} +1 -1
  77. package/dist/gateway/static/root/assets/{system-settings-panel-CMG0ZAsd.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-DGYA6GyO.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-CDemMoSX.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-CXArY4t5.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-Dk5KsKOm.js → work-discovery-overlay-CJzqJ47I.js} +1 -1
  86. package/dist/gateway/static/root/assets/{workflow-run-setup-panel-DNpdaI-2.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 +59 -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 +13 -7
  97. package/dist/src/agent/background-review/run-background-review.js +7 -2
  98. package/dist/src/agent/bootstrap/filter-bootstrap-files.js +1 -1
  99. package/dist/src/agent/embedded/run-turn.js +7 -1
  100. package/dist/src/agent/external-tools/endpoint-provider.js +2 -2
  101. package/dist/src/agent/external-tools/gateway-tools.d.ts +2 -1
  102. package/dist/src/agent/external-tools/gateway-tools.js +44 -11
  103. package/dist/src/agent/external-tools/index.js +1 -1
  104. package/dist/src/agent/image/tool-model-config.js +1 -1
  105. package/dist/src/agent/image/understanding/pi-ai-provider.js +1 -1
  106. package/dist/src/agent/memory/compaction.js +4 -0
  107. package/dist/src/agent/orchestration/agent-orchestrator.js +0 -21
  108. package/dist/src/agent/service/btw-query.js +8 -2
  109. package/dist/src/agent/service.js +3 -3
  110. package/dist/src/agent/skills/filesystem-watcher.js +1 -1
  111. package/dist/src/agent/skills/hub-pull.js +2 -2
  112. package/dist/src/agent/skills/marketplace/adapters/store/adapter.js +1 -1
  113. package/dist/src/agent/skills/marketplace/adapters/store/store-api-client.js +1 -1
  114. package/dist/src/agent/tasks/task-judge-service.js +4 -0
  115. package/dist/src/agent/tool-manuals/xopc-use.d.ts +1 -1
  116. package/dist/src/agent/tool-manuals/xopc-use.js +5 -4
  117. package/dist/src/agent/tools/automation-tool.d.ts +4 -1
  118. package/dist/src/agent/tools/automation-tool.js +42 -4
  119. package/dist/src/agent/tools/session-search-tool.js +1 -1
  120. package/dist/src/agent/tools/web-extract.js +1 -1
  121. package/dist/src/agent/tools/xopc-use-tool.js +50 -9
  122. package/dist/src/agent-catalog/capabilities.js +2 -2
  123. package/dist/src/ai-assist/text-assist.js +5 -1
  124. package/dist/src/auth/credentials.js +1 -1
  125. package/dist/src/auth/oauth-provider-lock.js +1 -1
  126. package/dist/src/auth/sync-provider-auth.js +1 -1
  127. package/dist/src/automations/api/routes.js +65 -0
  128. package/dist/src/automations/capabilities/drafts.js +1 -1
  129. package/dist/src/automations/capabilities/read.js +24 -0
  130. package/dist/src/automations/capabilities/write.d.ts +69 -14
  131. package/dist/src/automations/capabilities/write.js +78 -5
  132. package/dist/src/automations/delivery/delivery-router.d.ts +50 -0
  133. package/dist/src/automations/delivery/delivery-router.js +318 -0
  134. package/dist/src/automations/delivery/index.d.ts +1 -0
  135. package/dist/src/automations/delivery/index.js +2 -0
  136. package/dist/src/automations/domain/defaults.d.ts +0 -1
  137. package/dist/src/automations/domain/defaults.js +2 -2
  138. package/dist/src/automations/domain/index.js +2 -2
  139. package/dist/src/automations/domain/types.d.ts +180 -7
  140. package/dist/src/automations/domain/validation.d.ts +172 -22
  141. package/dist/src/automations/domain/validation.js +82 -13
  142. package/dist/src/automations/draft/automation-draft-prompt.js +3 -4
  143. package/dist/src/automations/draft/automation-draft-service.js +6 -0
  144. package/dist/src/automations/draft/automation-draft-validator.d.ts +31 -3
  145. package/dist/src/automations/draft/automation-draft-validator.js +5 -4
  146. package/dist/src/automations/events/event-catalog.d.ts +14 -0
  147. package/dist/src/automations/events/event-catalog.js +117 -0
  148. package/dist/src/automations/events/event-dispatcher.d.ts +27 -0
  149. package/dist/src/automations/events/event-dispatcher.js +140 -0
  150. package/dist/src/automations/events/event-repository.d.ts +59 -0
  151. package/dist/src/automations/events/event-repository.js +361 -0
  152. package/dist/src/automations/events/index.d.ts +3 -0
  153. package/dist/src/automations/events/index.js +4 -0
  154. package/dist/src/automations/index.d.ts +3 -1
  155. package/dist/src/automations/index.js +9 -3
  156. package/dist/src/automations/service/action-executor.d.ts +20 -1
  157. package/dist/src/automations/service/action-executor.js +80 -24
  158. package/dist/src/automations/service/automation-service.d.ts +21 -4
  159. package/dist/src/automations/service/automation-service.js +150 -100
  160. package/dist/src/automations/storage/automation-repository.js +7 -7
  161. package/dist/src/automations/storage/automation-run-repository.d.ts +1 -0
  162. package/dist/src/automations/storage/automation-run-repository.js +26 -1
  163. package/dist/src/automations/storage/index.js +2 -2
  164. package/dist/src/automations/webhook-secrets.d.ts +1 -0
  165. package/dist/src/automations/webhook-secrets.js +16 -0
  166. package/dist/src/bootstrap/application-state.js +1 -1
  167. package/dist/src/capabilities/runtime/dispatcher.js +1 -1
  168. package/dist/src/capabilities/runtime/product.js +1 -1
  169. package/dist/src/capabilities/store-connector.d.ts +17 -1
  170. package/dist/src/capabilities/store-connector.js +69 -3
  171. package/dist/src/chat-commands/agent-edit.js +1 -1
  172. package/dist/src/chat-commands/builtins/config.js +1 -1
  173. package/dist/src/cli/commands/agent.js +1 -1
  174. package/dist/src/cli/commands/agents.js +1 -1
  175. package/dist/src/cli/commands/connectors.js +4 -3
  176. package/dist/src/cli/commands/doctor/checks/automation-integrity.d.ts +2 -0
  177. package/dist/src/cli/commands/doctor/checks/automation-integrity.js +55 -0
  178. package/dist/src/cli/commands/doctor/checks/database-relations.d.ts +2 -0
  179. package/dist/src/cli/commands/doctor/checks/database-relations.js +81 -0
  180. package/dist/src/cli/commands/doctor/checks/database-schema.js +1 -1
  181. package/dist/src/cli/commands/doctor/flow.js +5 -1
  182. package/dist/src/cli/commands/extension-marketplace.js +1 -1
  183. package/dist/src/cli/commands/models.js +1 -1
  184. package/dist/src/cli/commands/onboard/model.js +2 -2
  185. package/dist/src/cli/commands/skills.js +1 -1
  186. package/dist/src/cli/utils/init-workspace-core.js +1 -1
  187. package/dist/src/config/index.js +4 -4
  188. package/dist/src/config/loader.js +2 -2
  189. package/dist/src/config/models-json.js +1 -1
  190. package/dist/src/config/schema.d.ts +4 -0
  191. package/dist/src/config/schema.js +5 -1
  192. package/dist/src/connectors/approval-resume.js +1 -1
  193. package/dist/src/connectors/cli/store.js +1 -1
  194. package/dist/src/connectors/composio-backends.js +14 -4
  195. package/dist/src/connectors/composio-managed-events.d.ts +5 -2
  196. package/dist/src/connectors/composio-managed-events.js +4 -1
  197. package/dist/src/connectors/connection-recovery-service.d.ts +2 -1
  198. package/dist/src/connectors/connection-recovery-service.js +89 -4
  199. package/dist/src/discussions/analyzer.js +4 -4
  200. package/dist/src/extensions/agent-plugins/validation.js +1 -1
  201. package/dist/src/extensions/update.js +1 -1
  202. package/dist/src/gateway/agent-builtin-tools.d.ts +1 -1
  203. package/dist/src/gateway/agents-admin.js +2 -2
  204. package/dist/src/gateway/file-path-classifier.js +1 -1
  205. package/dist/src/gateway/home-intelligence-automation-reconciler.d.ts +3 -0
  206. package/dist/src/gateway/home-intelligence-automation-reconciler.js +52 -0
  207. package/dist/src/gateway/hono/lib/config-payload.js +1 -1
  208. package/dist/src/gateway/hono/routes/capabilities.js +1 -1
  209. package/dist/src/gateway/hono/routes/config-patch/misc.js +18 -4
  210. package/dist/src/gateway/hono/routes/connection-waits.js +3 -2
  211. package/dist/src/gateway/hono/routes/home.js +0 -1
  212. package/dist/src/gateway/hono/routes/lazy-bundles.js +14 -1
  213. package/dist/src/gateway/hono/routes/notes.js +2 -2
  214. package/dist/src/gateway/hono/routes/projects.js +2 -2
  215. package/dist/src/gateway/hono/routes/public-gateway.js +93 -3
  216. package/dist/src/gateway/hono/routes/scenes.js +57 -41
  217. package/dist/src/gateway/hono/routes/session-input-handler.js +1 -1
  218. package/dist/src/gateway/hono/routes/sessions.js +15 -0
  219. package/dist/src/gateway/hono/routes/tasks.js +1 -1
  220. package/dist/src/gateway/hono/routes/update.js +6 -1
  221. package/dist/src/gateway/hono/routes/usage.d.ts +3 -0
  222. package/dist/src/gateway/hono/routes/usage.js +61 -0
  223. package/dist/src/gateway/hono/routes/voice.js +1 -1
  224. package/dist/src/gateway/image-generation-setup.js +2 -2
  225. package/dist/src/gateway/lock.js +1 -1
  226. package/dist/src/gateway/memory-maintenance-automation-reconciler.js +21 -15
  227. package/dist/src/gateway/scenes/host.js +27 -14
  228. package/dist/src/gateway/scenes/slackThreadSource.d.ts +2 -2
  229. package/dist/src/gateway/security/gateway-scopes.js +1 -0
  230. package/dist/src/gateway/service/active-execution.d.ts +19 -0
  231. package/dist/src/gateway/service/active-execution.js +16 -0
  232. package/dist/src/gateway/service/agent-runner.d.ts +4 -0
  233. package/dist/src/gateway/service/agent-runner.js +19 -1
  234. package/dist/src/gateway/service/marketplace-service.js +2 -2
  235. package/dist/src/gateway/service/run-gateway-agent.d.ts +2 -0
  236. package/dist/src/gateway/service/run-gateway-agent.js +9 -1
  237. package/dist/src/gateway/service/sessions-api.d.ts +13 -0
  238. package/dist/src/gateway/service/sessions-api.js +23 -0
  239. package/dist/src/gateway/service.d.ts +7 -3
  240. package/dist/src/gateway/service.js +108 -89
  241. package/dist/src/gateway/side-chat/run-service.js +10 -7
  242. package/dist/src/gateway/xopc-cloud-capability-setup.js +1 -1
  243. package/dist/src/home-intelligence/generator.js +4 -1
  244. package/dist/src/home-intelligence/host.d.ts +1 -1
  245. package/dist/src/home-intelligence/host.js +2 -10
  246. package/dist/src/home-intelligence/notification.js +1 -1
  247. package/dist/src/home-intelligence/repository.d.ts +1 -1
  248. package/dist/src/infra/domain-outbox-dispatcher.d.ts +0 -3
  249. package/dist/src/infra/domain-outbox-dispatcher.js +15 -7
  250. package/dist/src/infra/update-check.d.ts +8 -4
  251. package/dist/src/infra/update-check.js +43 -41
  252. package/dist/src/infra/update-startup.d.ts +7 -1
  253. package/dist/src/infra/update-startup.js +15 -6
  254. package/dist/src/local-apps/service.js +2 -2
  255. package/dist/src/memory-maintenance/index.js +2 -2
  256. package/dist/src/memory-maintenance/schedule.d.ts +0 -3
  257. package/dist/src/memory-maintenance/schedule.js +1 -8
  258. package/dist/src/notes/service.js +2 -3
  259. package/dist/src/projects/project-service.js +1 -2
  260. package/dist/src/projects/project-skill-service.js +2 -2
  261. package/dist/src/providers/model-call.d.ts +3 -2
  262. package/dist/src/providers/model-call.js +30 -5
  263. package/dist/src/providers/model-catalog-persistence.js +1 -1
  264. package/dist/src/scenes/activationAdapter.d.ts +19 -0
  265. package/dist/src/scenes/activationAdapter.js +1 -0
  266. package/dist/src/scenes/agentExecutor.js +3 -10
  267. package/dist/src/scenes/contracts.d.ts +3 -9
  268. package/dist/src/scenes/contracts.js +1 -0
  269. package/dist/src/scenes/execution.d.ts +9 -3
  270. package/dist/src/scenes/execution.js +12 -11
  271. package/dist/src/scenes/httpServices.d.ts +5 -2
  272. package/dist/src/scenes/mailContext.d.ts +4 -0
  273. package/dist/src/scenes/mailContext.js +9 -0
  274. package/dist/src/scenes/maintenance.js +1 -5
  275. package/dist/src/scenes/metrics.d.ts +0 -6
  276. package/dist/src/scenes/metrics.js +0 -11
  277. package/dist/src/scenes/registry.d.ts +11 -0
  278. package/dist/src/scenes/registry.js +28 -0
  279. package/dist/src/scenes/repository.d.ts +6 -3
  280. package/dist/src/scenes/repository.js +43 -5
  281. package/dist/src/scenes/service.d.ts +2 -1
  282. package/dist/src/scenes/service.js +9 -7
  283. package/dist/src/scenes/taskFollowUp/contracts.d.ts +37 -7
  284. package/dist/src/scenes/taskFollowUp/contracts.js +36 -17
  285. package/dist/src/scenes/taskFollowUp/service.d.ts +35 -7
  286. package/dist/src/scenes/taskFollowUp/service.js +86 -28
  287. package/dist/src/scenes/templates.d.ts +2 -2
  288. package/dist/src/scenes/userNotes.d.ts +3 -0
  289. package/dist/src/scenes/userNotes.js +6 -0
  290. package/dist/src/session/client-history.d.ts +3 -0
  291. package/dist/src/session/client-history.js +10 -5
  292. package/dist/src/session/manager.d.ts +1 -0
  293. package/dist/src/session/resolve-session.js +4 -3
  294. package/dist/src/session/session-title.js +1 -1
  295. package/dist/src/session/store.d.ts +1 -0
  296. package/dist/src/session/store.js +3 -2
  297. package/dist/src/storage/sqlite/ai-usage-repository.d.ts +137 -0
  298. package/dist/src/storage/sqlite/ai-usage-repository.js +175 -0
  299. package/dist/src/storage/sqlite/connector-account-repository.js +7 -5
  300. package/dist/src/storage/sqlite/connector-repository.js +36 -34
  301. package/dist/src/storage/sqlite/index.d.ts +2 -2
  302. package/dist/src/storage/sqlite/index.js +3 -3
  303. package/dist/src/storage/sqlite/migrations/208_automation_management.sql +2 -0
  304. package/dist/src/storage/sqlite/migrations/209_automation_event_hub.sql +48 -0
  305. package/dist/src/storage/sqlite/migrations/210_remove_legacy_automation_timeout.sql +14 -0
  306. package/dist/src/storage/sqlite/migrations/211_automation_result_deliveries.sql +16 -0
  307. package/dist/src/storage/sqlite/migrations/212_automation_delivery_policy.sql +30 -0
  308. package/dist/src/storage/sqlite/migrations/213_automation_reliability_contract.sql +188 -0
  309. package/dist/src/storage/sqlite/migrations/214_ai_usage_ledger.sql +41 -0
  310. package/dist/src/storage/sqlite/migrations/215_scene_execution_adapters.sql +6 -0
  311. package/dist/src/storage/sqlite/migrations/216_remove_scene_model_usage.sql +1 -0
  312. package/dist/src/storage/sqlite/migrations/217_remove_legacy_memory_tables.sql +4 -0
  313. package/dist/src/storage/sqlite/migrations/218_core_relation_indexes.sql +26 -0
  314. package/dist/src/storage/sqlite/migrations/219_json_contracts.sql +123 -0
  315. package/dist/src/storage/sqlite/migrations/220_normalize_timestamps.sql +339 -0
  316. package/dist/src/storage/sqlite/migrations/221_ai_usage_retention_index.sql +2 -0
  317. package/dist/src/storage/sqlite/migrations/222_session_config_authority.sql +13 -0
  318. package/dist/src/storage/sqlite/migrations/runner.d.ts +1 -1
  319. package/dist/src/storage/sqlite/migrations/runner.js +4 -4
  320. package/dist/src/storage/sqlite/row-mappers.d.ts +3 -7
  321. package/dist/src/storage/sqlite/row-mappers.js +6 -6
  322. package/dist/src/storage/sqlite/scenes-schema.d.ts +1 -1
  323. package/dist/src/storage/sqlite/scenes-schema.js +0 -1
  324. package/dist/src/storage/sqlite/schema.js +1 -1
  325. package/dist/src/storage/sqlite/schema.sql +0 -52
  326. package/dist/src/storage/sqlite/schemas/scenes.sql +0 -7
  327. package/dist/src/storage/sqlite/session-input-repository.d.ts +8 -0
  328. package/dist/src/storage/sqlite/session-input-repository.js +18 -1
  329. package/dist/src/storage/sqlite/session-read-repository.d.ts +1 -1
  330. package/dist/src/storage/sqlite/session-read-repository.js +0 -1
  331. package/dist/src/storage/sqlite/session-repository.d.ts +0 -4
  332. package/dist/src/storage/sqlite/session-repository.js +8 -18
  333. package/dist/src/storage/sqlite/timestamps.d.ts +4 -0
  334. package/dist/src/storage/sqlite/timestamps.js +20 -0
  335. package/dist/src/storage/sqlite/transcript-repository.d.ts +1 -0
  336. package/dist/src/storage/sqlite/transcript-repository.js +23 -15
  337. package/dist/src/storage/sqlite/user-trust-repository.js +4 -2
  338. package/dist/src/tasks/capabilities/read.js +2 -2
  339. package/dist/src/tasks/capabilities/write.d.ts +1 -1
  340. package/dist/src/tasks/home-query-service.js +4 -3
  341. package/dist/src/tasks/task-contract-planner.js +1 -1
  342. package/dist/src/tui/backends/embedded-backend.js +2 -2
  343. package/dist/src/tui/tui-commands.js +1 -1
  344. package/dist/src/tui/tui-startup-resources.js +1 -1
  345. package/dist/src/tui/tui.js +1 -1
  346. package/dist/src/usage/cost.d.ts +4 -0
  347. package/dist/src/usage/cost.js +28 -0
  348. package/dist/src/usage/recorder.d.ts +13 -0
  349. package/dist/src/usage/recorder.js +117 -0
  350. package/dist/src/usage/scenario-registry.d.ts +8 -0
  351. package/dist/src/usage/scenario-registry.js +117 -0
  352. package/dist/src/usage/types.d.ts +55 -0
  353. package/dist/src/usage/types.js +1 -0
  354. package/dist/src/user-context/config.d.ts +9 -0
  355. package/dist/src/user-context/config.js +13 -4
  356. package/dist/src/voice/realtime/persona-context.js +1 -1
  357. package/dist/src/voice/tts/summarize.js +1 -1
  358. package/dist/src/work-discovery/analyzer.js +2 -2
  359. package/dist/src/work-discovery/investigator.js +1 -1
  360. package/dist/src/workflows/service/workflow-run-service.js +15 -2
  361. package/package.json +6 -6
  362. package/dist/gateway/static/root/assets/agent-defaults-settings-panel-DgP5DEJF.js +0 -1
  363. package/dist/gateway/static/root/assets/agents-Bh4XNLyk.js +0 -70
  364. package/dist/gateway/static/root/assets/automations-workspace-C7VS-yb7.js +0 -7
  365. package/dist/gateway/static/root/assets/browser-settings-page-CC43CC43.js +0 -3
  366. package/dist/gateway/static/root/assets/capabilities-sAZT4brT.js +0 -1
  367. package/dist/gateway/static/root/assets/capabilities-settings-panel-DPETQOfF.js +0 -8
  368. package/dist/gateway/static/root/assets/channels-CwA619os.js +0 -1
  369. package/dist/gateway/static/root/assets/connectors-page-l7goF6QS.js +0 -2
  370. package/dist/gateway/static/root/assets/home-page-DSaXXoLm.js +0 -1
  371. package/dist/gateway/static/root/assets/index-BEw0xrde.css +0 -1
  372. package/dist/gateway/static/root/assets/index-D99vN3es.js +0 -121
  373. package/dist/gateway/static/root/assets/local-app-workbench-page-rH33N8I9.js +0 -1
  374. package/dist/gateway/static/root/assets/management-settings-RFDLaquR.js +0 -1
  375. package/dist/gateway/static/root/assets/messages-fmf0dnr4.js +0 -3
  376. package/dist/gateway/static/root/assets/note-detail-panel-DI7CIjmM.js +0 -5
  377. package/dist/gateway/static/root/assets/notes-page-BkqnU-Jh.js +0 -8
  378. package/dist/gateway/static/root/assets/project-detail-page-BvvcTH2F.js +0 -1
  379. package/dist/gateway/static/root/assets/scenes-page-DK316w9a.js +0 -2
  380. package/dist/gateway/static/root/assets/sessions-page-EIk8iJTK.js +0 -1
  381. package/dist/gateway/static/root/assets/settings-advanced-gate-DcOsdz78.js +0 -1
  382. package/dist/gateway/static/root/assets/shares-settings-BcaxGQLC.js +0 -1
  383. package/dist/gateway/static/root/assets/skill-reload-api-Cb_CUL-U.js +0 -1
  384. package/dist/gateway/static/root/assets/task-detail-page-Cvr1qUTW.js +0 -1
  385. package/dist/gateway/static/root/assets/user-model-page-VXfz3rE7.js +0 -2
  386. package/dist/gateway/static/root/assets/workflows-page-DDNDLdId.js +0 -6
  387. package/dist/src/automations/product-events.d.ts +0 -5
  388. package/dist/src/automations/product-events.js +0 -19
@@ -1,7 +1,7 @@
1
1
  import { AgentCatalogRepository, init_repository } from "../agent-catalog/repository.js";
2
- import { AgentCatalogService } from "../agent-catalog/service.js";
3
2
  import { getModelCatalogStore, init_model_catalog_store } from "../providers/model-catalog-store.js";
4
3
  import { compareCatalogModels } from "../providers/model-catalog-ranking.js";
4
+ import { AgentCatalogService } from "../agent-catalog/service.js";
5
5
  import { prepareUpdateGlobalDefaults } from "./global-defaults-admin.js";
6
6
  //#region src/gateway/xopc-cloud-capability-setup.ts
7
7
  init_repository();
@@ -182,7 +182,7 @@ var HomeAdviceGenerator = class {
182
182
  maxTokens: 3e3,
183
183
  temperature: .1,
184
184
  signal: requestSignal
185
- });
185
+ }, void 0, { operation: "home.generate_advice" });
186
186
  const raw = extractHomeResponseText(response);
187
187
  let result;
188
188
  try {
@@ -205,6 +205,9 @@ var HomeAdviceGenerator = class {
205
205
  maxTokens: 3e3,
206
206
  temperature: 0,
207
207
  signal: requestSignal
208
+ }, void 0, {
209
+ operation: "home.generate_advice",
210
+ trigger: "retry"
208
211
  });
209
212
  try {
210
213
  result = HomeModelResultSchema.parse(parseJson(extractHomeResponseText(corrected)));
@@ -30,7 +30,6 @@ export declare class HomeIntelligenceHost {
30
30
  private timer?;
31
31
  private running;
32
32
  private stopped;
33
- private nextScheduledRefresh;
34
33
  private abortController;
35
34
  private localeHint;
36
35
  constructor(db: DatabaseSync, deps: HomeIntelligenceHostDeps);
@@ -43,6 +42,7 @@ export declare class HomeIntelligenceHost {
43
42
  sourceChanged(input: {
44
43
  sourceInstanceId: string;
45
44
  revision: string;
45
+ refresh: boolean;
46
46
  }): void;
47
47
  act(opportunityId: string, input: HomeOpportunityActionRequest): HomeOpportunityActionResponse;
48
48
  feedback(opportunityId: string, input: HomeOpportunityFeedbackRequest): void;
@@ -1,16 +1,15 @@
1
1
  import { createLogger } from "../utils/logger/index.js";
2
2
  import { init_logger } from "../utils/logger.js";
3
3
  import { homePatternKey } from "./strategy.js";
4
- import { HomeAdvicePolicy } from "./policy.js";
5
4
  import { HomeIntelligenceRepository } from "./repository.js";
6
5
  import { HomeOpportunityApplicationService } from "./application-service.js";
6
+ import { HomeAdvicePolicy } from "./policy.js";
7
7
  import { buildHomeOpportunityNotification } from "./notification.js";
8
8
  import { createHash } from "node:crypto";
9
9
  //#region src/home-intelligence/host.ts
10
10
  init_logger();
11
11
  const log = createLogger("HomeIntelligence");
12
12
  const POLL_INTERVAL_MS = 5e3;
13
- const REFRESH_INTERVAL_MS = 30 * 6e4;
14
13
  const GENERATION_LEASE_MS = 5 * 6e4;
15
14
  const DAILY_MODEL_GENERATION_BUDGET = 12;
16
15
  function generationFingerprint(snapshotHash, capabilities) {
@@ -28,7 +27,6 @@ var HomeIntelligenceHost = class {
28
27
  timer;
29
28
  running = false;
30
29
  stopped = false;
31
- nextScheduledRefresh = 0;
32
30
  abortController = new AbortController();
33
31
  localeHint;
34
32
  constructor(db, deps) {
@@ -41,7 +39,6 @@ var HomeIntelligenceHost = class {
41
39
  start() {
42
40
  if (this.timer) return;
43
41
  this.stopped = false;
44
- this.nextScheduledRefresh = this.now();
45
42
  this.timer = setInterval(() => void this.tick(), POLL_INTERVAL_MS);
46
43
  this.timer.unref?.();
47
44
  this.tick();
@@ -78,14 +75,13 @@ var HomeIntelligenceHost = class {
78
75
  return request.generationId;
79
76
  }
80
77
  sourceChanged(input) {
81
- if (this.deps.enabled?.() === false) return;
82
78
  const now = this.now();
83
79
  const invalidated = this.repository.invalidateOpportunitiesByEvidenceSources(this.deps.principal, new Set([
84
80
  "calendar",
85
81
  "mail",
86
82
  "communication"
87
83
  ]), now);
88
- this.requestRefresh("connector_changed", `connector:${input.sourceInstanceId}:${input.revision}`);
84
+ if (input.refresh) this.requestRefresh("connector_changed", `connector:${input.sourceInstanceId}:${input.revision}`);
89
85
  if (invalidated > 0) this.deps.publish("home.advisor.updated", {
90
86
  state: "source_changed",
91
87
  sourceInstanceId: input.sourceInstanceId,
@@ -155,10 +151,6 @@ var HomeIntelligenceHost = class {
155
151
  try {
156
152
  const now = this.now();
157
153
  this.repository.maintain(now);
158
- if (now >= this.nextScheduledRefresh) {
159
- this.nextScheduledRefresh = now + REFRESH_INTERVAL_MS;
160
- this.requestRefresh("scheduled_refresh", `scheduled_refresh:${Math.floor(now / REFRESH_INTERVAL_MS)}`);
161
- }
162
154
  const claim = this.repository.claimNext(this.deps.principal, `gateway:${process.pid}`, now, GENERATION_LEASE_MS);
163
155
  if (!claim) return;
164
156
  await this.process(claim);
@@ -2,7 +2,7 @@ import { createHash } from "node:crypto";
2
2
  //#region src/home-intelligence/notification.ts
3
3
  function buildHomeOpportunityNotification(opportunity, reasons, placement) {
4
4
  const backgroundRefresh = reasons.includes("connector_changed") || reasons.includes("scheduled_refresh");
5
- const foregroundRefresh = reasons.includes("home_opened") || reasons.includes("manual_refresh");
5
+ const foregroundRefresh = reasons.includes("manual_refresh");
6
6
  const hasCrossSourceEvidence = opportunity.evidence.some((item) => item.sourceType === "calendar" || item.sourceType === "mail" || item.sourceType === "communication");
7
7
  if (!backgroundRefresh || foregroundRefresh || placement !== "primary" || opportunity.confidence !== "high" || opportunity.urgency !== "now" || !opportunity.actions.canStart || !hasCrossSourceEvidence) return void 0;
8
8
  const evidenceRevision = opportunity.evidence.map((item) => `${item.sourceType}:${item.sourceRef}:${item.revision}`).sort().join("\n");
@@ -6,7 +6,7 @@ export interface HomePrincipal {
6
6
  ownerId: string;
7
7
  workspaceId: string;
8
8
  }
9
- export type HomeGenerationReason = 'home_opened' | 'manual_refresh' | 'project_changed' | 'task_changed' | 'conversation_changed' | 'connector_changed' | 'scheduled_refresh';
9
+ export type HomeGenerationReason = 'manual_refresh' | 'project_changed' | 'task_changed' | 'conversation_changed' | 'connector_changed' | 'scheduled_refresh';
10
10
  export interface HomeGenerationClaim extends HomePrincipal {
11
11
  generationId: string;
12
12
  leaseOwner: string;
@@ -1,6 +1,3 @@
1
- import type { AutomationEvent } from '../automations/domain/types.js';
2
1
  export declare class DomainOutboxDispatcher {
3
- private readonly publish;
4
- constructor(publish: (event: AutomationEvent) => void);
5
2
  drain(limit?: number, subjectKind?: string): number;
6
3
  }
@@ -1,26 +1,34 @@
1
1
  import { getSqliteDatabase, init_transaction, runSqliteWriteTransaction } from "../storage/sqlite/transaction.js";
2
+ import { automationEventPublisher } from "../automations/events/event-repository.js";
2
3
  //#region src/infra/domain-outbox-dispatcher.ts
3
4
  init_transaction();
4
5
  var DomainOutboxDispatcher = class {
5
- constructor(publish) {
6
- this.publish = publish;
7
- }
8
6
  drain(limit = 100, subjectKind) {
9
- const rows = getSqliteDatabase().prepare(`SELECT event_id, event_type, payload_json, created_at, subject_kind, operation_id
7
+ const rows = getSqliteDatabase().prepare(`SELECT event_id, event_type, payload_json, created_at, subject_kind, subject_id, operation_id
10
8
  FROM domain_outbox WHERE published_at IS NULL AND (? IS NULL OR subject_kind = ?)
11
- ORDER BY created_at, event_id LIMIT ?`).all(subjectKind ?? null, subjectKind ?? null, Math.max(1, Math.min(500, Math.floor(limit))));
9
+ ORDER BY created_at, rowid LIMIT ?`).all(subjectKind ?? null, subjectKind ?? null, Math.max(1, Math.min(500, Math.floor(limit))));
12
10
  let published = 0;
13
11
  for (const row of rows) try {
14
12
  const payload = JSON.parse(row.payload_json);
15
- this.publish({
13
+ automationEventPublisher.publish({
14
+ id: row.event_id,
16
15
  type: row.event_type,
17
16
  source: row.subject_kind === "note" ? "notes" : row.subject_kind === "project" ? "projects" : row.subject_kind === "scene" ? "scenes" : row.subject_kind === "local_app" ? "local_apps" : "tasks",
17
+ schemaVersion: 1,
18
+ subject: {
19
+ kind: row.subject_kind,
20
+ id: row.subject_id
21
+ },
18
22
  payload: {
19
23
  ...payload,
20
24
  sourceEventId: row.event_id,
21
25
  ...row.operation_id ? { operationId: row.operation_id } : {}
22
26
  },
23
- occurredAtMs: row.created_at
27
+ occurredAtMs: row.created_at,
28
+ correlationId: typeof payload.correlationId === "string" ? payload.correlationId : row.event_id,
29
+ causationId: typeof payload.causationId === "string" ? payload.causationId : void 0,
30
+ dedupeKey: row.event_id,
31
+ trust: "system"
24
32
  });
25
33
  runSqliteWriteTransaction((db) => {
26
34
  db.prepare(`UPDATE domain_outbox SET published_at = ?, attempts = attempts + 1
@@ -5,6 +5,10 @@ export type NpmTagResult = {
5
5
  version: string | null;
6
6
  error?: string;
7
7
  };
8
+ type RegistryResponse = Pick<Response, 'ok' | 'status' | 'json'>;
9
+ type RegistryFetch = (url: string, init: {
10
+ signal: AbortSignal;
11
+ }) => Promise<RegistryResponse>;
8
12
  export type UpdateCheckResult = {
9
13
  installKind: InstallKind;
10
14
  root: string | null;
@@ -21,6 +25,7 @@ export type UpdateAvailable = {
21
25
  export declare function fetchNpmTagVersion(params: {
22
26
  tag: string;
23
27
  timeoutMs?: number;
28
+ fetchImpl?: RegistryFetch;
24
29
  }): Promise<NpmTagResult>;
25
30
  /**
26
31
  * Resolve the best version for the given update channel.
@@ -29,10 +34,8 @@ export declare function fetchNpmTagVersion(params: {
29
34
  export declare function resolveNpmChannelTag(params: {
30
35
  channel: UpdateChannel;
31
36
  timeoutMs?: number;
32
- }): Promise<{
33
- tag: string;
34
- version: string | null;
35
- }>;
37
+ fetchImpl?: RegistryFetch;
38
+ }): Promise<NpmTagResult>;
36
39
  /**
37
40
  * Compare two semver strings. Returns:
38
41
  * -1 if a < b, 0 if equal, 1 if a > b, null if either is unparseable.
@@ -51,3 +54,4 @@ export declare function detectInstallKind(packageRoot: string): Promise<InstallK
51
54
  export declare function resolvePackageRoot(): Promise<string | null>;
52
55
  /** Get the current running version from package.json. */
53
56
  export declare function getCurrentVersion(): string;
57
+ export {};
@@ -3,6 +3,7 @@ import { channelToNpmTag } from "./update-channels.js";
3
3
  import { dirname, join } from "node:path";
4
4
  import { fileURLToPath } from "node:url";
5
5
  import { access, readFile } from "node:fs/promises";
6
+ import { Agent, fetch } from "undici";
6
7
  //#region src/infra/update-check.ts
7
8
  init_package_version();
8
9
  const REGISTRY_BASE = "https://registry.npmjs.org";
@@ -17,32 +18,42 @@ const INITIAL_REGISTRY_RETRY_DELAY_MS = 500;
17
18
  async function fetchNpmTagVersion(params) {
18
19
  const timeoutMs = params.timeoutMs ?? REGISTRY_TIMEOUT_MS;
19
20
  const url = `${REGISTRY_BASE}/${encodeURIComponent(PACKAGE_NAME).replace("%40", "@")}/${encodeURIComponent(params.tag)}`;
21
+ const dispatcher = params.fetchImpl ? null : new Agent();
22
+ const fetchImpl = params.fetchImpl ?? ((input, init) => fetch(input, {
23
+ ...init,
24
+ dispatcher
25
+ }));
20
26
  let lastError;
21
- for (let attempt = 0; attempt <= MAX_REGISTRY_RETRIES; attempt++) {
22
- if (attempt > 0) {
23
- const delayMs = INITIAL_REGISTRY_RETRY_DELAY_MS * Math.pow(2, attempt - 1);
24
- await new Promise((r) => setTimeout(r, delayMs));
25
- }
26
- try {
27
- const response = await fetch(url, { signal: AbortSignal.timeout(timeoutMs) });
28
- if (!response.ok) {
29
- lastError = `HTTP ${response.status}`;
30
- if (response.status >= 400 && response.status < 500) return {
27
+ try {
28
+ for (let attempt = 0; attempt <= MAX_REGISTRY_RETRIES; attempt++) {
29
+ if (attempt > 0) {
30
+ const delayMs = INITIAL_REGISTRY_RETRY_DELAY_MS * Math.pow(2, attempt - 1);
31
+ await new Promise((r) => setTimeout(r, delayMs));
32
+ }
33
+ try {
34
+ const response = await fetchImpl(url, { signal: AbortSignal.timeout(timeoutMs) });
35
+ if (!response.ok) {
36
+ lastError = `HTTP ${response.status}`;
37
+ if (response.status >= 400 && response.status < 500) return {
38
+ tag: params.tag,
39
+ version: null,
40
+ error: lastError
41
+ };
42
+ continue;
43
+ }
44
+ const json = await response.json();
45
+ const version = typeof json?.version === "string" ? json.version : null;
46
+ return {
31
47
  tag: params.tag,
32
- version: null,
33
- error: lastError
48
+ version,
49
+ ...version ? {} : { error: "Registry response did not include a version" }
34
50
  };
35
- continue;
51
+ } catch (err) {
52
+ lastError = err instanceof Error ? err.message : String(err);
36
53
  }
37
- const json = await response.json();
38
- const version = typeof json?.version === "string" ? json.version : null;
39
- return {
40
- tag: params.tag,
41
- version
42
- };
43
- } catch (err) {
44
- lastError = String(err);
45
54
  }
55
+ } finally {
56
+ await dispatcher?.close().catch(() => void 0);
46
57
  }
47
58
  return {
48
59
  tag: params.tag,
@@ -58,33 +69,24 @@ async function resolveNpmChannelTag(params) {
58
69
  const channelTag = channelToNpmTag(params.channel);
59
70
  const channelResult = await fetchNpmTagVersion({
60
71
  tag: channelTag,
61
- timeoutMs: params.timeoutMs
72
+ timeoutMs: params.timeoutMs,
73
+ fetchImpl: params.fetchImpl
62
74
  });
63
- if (params.channel !== "beta") return {
64
- tag: channelTag,
65
- version: channelResult.version
66
- };
75
+ if (params.channel !== "beta") return channelResult;
67
76
  const latestResult = await fetchNpmTagVersion({
68
77
  tag: "latest",
69
- timeoutMs: params.timeoutMs
78
+ timeoutMs: params.timeoutMs,
79
+ fetchImpl: params.fetchImpl
70
80
  });
71
- if (!latestResult.version) return {
81
+ if (!latestResult.version) return channelResult.version ? channelResult : {
72
82
  tag: channelTag,
73
- version: channelResult.version
74
- };
75
- if (!channelResult.version) return {
76
- tag: "latest",
77
- version: latestResult.version
83
+ version: null,
84
+ error: [channelResult.error, latestResult.error].filter(Boolean).join("; ") || void 0
78
85
  };
86
+ if (!channelResult.version) return latestResult;
79
87
  const comparison = compareSemver(channelResult.version, latestResult.version);
80
- if (comparison !== null && comparison < 0) return {
81
- tag: "latest",
82
- version: latestResult.version
83
- };
84
- return {
85
- tag: channelTag,
86
- version: channelResult.version
87
- };
88
+ if (comparison !== null && comparison < 0) return latestResult;
89
+ return channelResult;
88
90
  }
89
91
  /**
90
92
  * Parse a version string into comparable numeric parts.
@@ -3,6 +3,12 @@ import { type UpdateAvailable } from './update-check.js';
3
3
  import type { InProcessRestartTrigger } from './update-restart.js';
4
4
  /** Get the cached update-available state (populated after startup check). */
5
5
  export declare function getUpdateAvailable(): UpdateAvailable | null;
6
+ export type GatewayUpdateCheckResult = {
7
+ ok: true;
8
+ } | {
9
+ ok: false;
10
+ error: string;
11
+ };
6
12
  /**
7
13
  * Main startup update check. Called once when the gateway starts (or on demand).
8
14
  */
@@ -12,7 +18,7 @@ export declare function runGatewayUpdateCheck(params: {
12
18
  triggerInProcessRestart?: InProcessRestartTrigger;
13
19
  /** When true, bypass checkOnStart/auto-disabled early exit and throttle (for POST /api/update/check). */
14
20
  force?: boolean;
15
- }): Promise<void>;
21
+ }): Promise<GatewayUpdateCheckResult>;
16
22
  /**
17
23
  * Schedule periodic update checks. Returns a cleanup function to stop the timer.
18
24
  */
@@ -65,7 +65,7 @@ async function runGatewayUpdateCheck(params) {
65
65
  const { config, force } = params;
66
66
  const autoEnabled = config.update?.auto?.enabled ?? false;
67
67
  const shouldCheckHints = config.update?.checkOnStart !== false;
68
- if (!force && !shouldCheckHints && !autoEnabled) return;
68
+ if (!force && !shouldCheckHints && !autoEnabled) return { ok: true };
69
69
  const statePath = resolveUpdateCheckStatePath();
70
70
  const state = await readState(statePath);
71
71
  const now = Date.now();
@@ -83,8 +83,10 @@ async function runGatewayUpdateCheck(params) {
83
83
  }
84
84
  }
85
85
  const checkIntervalMs = resolveCheckIntervalMs(config);
86
- const shouldBypassThrottleForVersion = state.lastCheckPackageVersion === void 0 || state.lastCheckPackageVersion !== PACKAGE_VERSION;
87
- if (!force && !shouldBypassThrottleForVersion && lastCheckedAt && Number.isFinite(lastCheckedAt) && now - lastCheckedAt < checkIntervalMs) return;
86
+ const staleAvailableComparison = compareSemver(PACKAGE_VERSION, state.lastAvailableVersion ?? null);
87
+ const hasStaleAvailableVersion = staleAvailableComparison !== null && staleAvailableComparison >= 0;
88
+ const shouldBypassThrottleForVersion = state.lastCheckPackageVersion === void 0 || state.lastCheckPackageVersion !== PACKAGE_VERSION || hasStaleAvailableVersion;
89
+ if (!force && !shouldBypassThrottleForVersion && lastCheckedAt && Number.isFinite(lastCheckedAt) && now - lastCheckedAt < checkIntervalMs) return { ok: true };
88
90
  const root = await resolvePackageRoot();
89
91
  let installKind = "unknown";
90
92
  if (root) {
@@ -101,9 +103,15 @@ async function runGatewayUpdateCheck(params) {
101
103
  lastCheckedAt: new Date(now).toISOString()
102
104
  };
103
105
  if (!resolved.version) {
104
- nextState.lastCheckPackageVersion = PACKAGE_VERSION;
105
- await writeState(statePath, nextState);
106
- return;
106
+ const error = resolved.error ?? `npm tag ${resolved.tag} did not return a version`;
107
+ log.warn({
108
+ tag: resolved.tag,
109
+ errorMessage: error
110
+ }, `Update check failed: ${error}`);
111
+ return {
112
+ ok: false,
113
+ error
114
+ };
107
115
  }
108
116
  const comparison = compareSemver(PACKAGE_VERSION, resolved.version);
109
117
  if (comparison !== null && comparison < 0) {
@@ -147,6 +155,7 @@ async function runGatewayUpdateCheck(params) {
147
155
  }
148
156
  nextState.lastCheckPackageVersion = PACKAGE_VERSION;
149
157
  await writeState(statePath, nextState);
158
+ return { ok: true };
150
159
  }
151
160
  async function handleAutoUpdate(params) {
152
161
  const { channel, version, tag, state, nextState, now, root, config } = params;
@@ -5,10 +5,10 @@ import { currentOperationId, init_operation_context } from "../infra/operation-c
5
5
  import { afterSqliteCommit, init_transaction, runSqliteWriteTransaction } from "../storage/sqlite/transaction.js";
6
6
  import { ExtensionCapabilityBindingsSchema, extensionCapabilityPermissions } from "../../packages/gateway-contract/src/extension-capabilities.js";
7
7
  import { init_src } from "../../packages/gateway-contract/src/index.js";
8
- import { CapabilityError } from "../capabilities/runtime/errors.js";
9
8
  import { init_paths, resolveExtensionsDir } from "../config/paths.js";
10
9
  import { LocalAppStore } from "./store.js";
11
10
  import { slugifyProjectName } from "../projects/project-store.js";
11
+ import { CapabilityError } from "../capabilities/runtime/errors.js";
12
12
  import { DomainOutboxDispatcher } from "../infra/domain-outbox-dispatcher.js";
13
13
  import { validateLocalAppCapabilityContracts } from "./capabilities/contracts.js";
14
14
  import { buildLocalAppFixGuidance } from "./fix-guidance.js";
@@ -511,7 +511,7 @@ var LocalAppService = class {
511
511
  });
512
512
  }
513
513
  flushAcceptanceEvents() {
514
- new DomainOutboxDispatcher((event) => this.options.emit(event.type, event.payload)).drain(100, "local_app");
514
+ new DomainOutboxDispatcher().drain(100, "local_app");
515
515
  }
516
516
  releaseRoot(appId) {
517
517
  return join(resolveStateDir(), "local-apps", "releases", appId);
@@ -1,3 +1,3 @@
1
- import { MEMORY_MAINTENANCE_TOKEN, maintenanceInstruction, parseMaintenanceInstruction, resolveMemoryMaintenanceSchedules } from "./schedule.js";
1
+ import { resolveMemoryMaintenanceSchedules } from "./schedule.js";
2
2
  import { listMemoryMaintenanceRuns, runMemoryMaintenance } from "./service.js";
3
- export { MEMORY_MAINTENANCE_TOKEN, listMemoryMaintenanceRuns, maintenanceInstruction, parseMaintenanceInstruction, resolveMemoryMaintenanceSchedules, runMemoryMaintenance };
3
+ export { listMemoryMaintenanceRuns, resolveMemoryMaintenanceSchedules, runMemoryMaintenance };
@@ -1,6 +1,5 @@
1
1
  import type { Config } from '../config/schema.js';
2
2
  import type { MemoryMaintenanceJob } from './service.js';
3
- export declare const MEMORY_MAINTENANCE_TOKEN = "__xopc_memory_maintenance__";
4
3
  export interface MemoryMaintenanceSchedule {
5
4
  jobType: Exclude<MemoryMaintenanceJob, 'manual_repair'>;
6
5
  automationId: string;
@@ -9,5 +8,3 @@ export interface MemoryMaintenanceSchedule {
9
8
  timezone: string;
10
9
  }
11
10
  export declare function resolveMemoryMaintenanceSchedules(config: Config): MemoryMaintenanceSchedule[];
12
- export declare function maintenanceInstruction(jobType: MemoryMaintenanceSchedule['jobType']): string;
13
- export declare function parseMaintenanceInstruction(value: string): MemoryMaintenanceSchedule['jobType'] | undefined;
@@ -1,5 +1,4 @@
1
1
  //#region src/memory-maintenance/schedule.ts
2
- const MEMORY_MAINTENANCE_TOKEN = "__xopc_memory_maintenance__";
3
2
  const WEEKDAY = {
4
3
  sun: 0,
5
4
  mon: 1,
@@ -41,11 +40,5 @@ function resolveMemoryMaintenanceSchedules(config) {
41
40
  }
42
41
  ];
43
42
  }
44
- function maintenanceInstruction(jobType) {
45
- return `${MEMORY_MAINTENANCE_TOKEN}:${jobType}`;
46
- }
47
- function parseMaintenanceInstruction(value) {
48
- return new RegExp(`${MEMORY_MAINTENANCE_TOKEN}:(temporal_sweep|daily_reconciliation|weekly_knowledge)`).exec(value)?.[1];
49
- }
50
43
  //#endregion
51
- export { MEMORY_MAINTENANCE_TOKEN, maintenanceInstruction, parseMaintenanceInstruction, resolveMemoryMaintenanceSchedules };
44
+ export { resolveMemoryMaintenanceSchedules };
@@ -8,7 +8,6 @@ import { init_notes_repository, listNoteProjectSummaries } from "../storage/sqli
8
8
  import { changedFieldsFromPatch, emitActivity, previewText, systemActivityActor, systemActivitySource } from "../activity/emitter.js";
9
9
  import { getDefaultModelSync, init_providers, resolveModel } from "../providers/index.js";
10
10
  import { DomainOutboxDispatcher } from "../infra/domain-outbox-dispatcher.js";
11
- import { publishAutomationProductEvent } from "../automations/product-events.js";
12
11
  import { completeWithResolvedCredentials } from "../providers/model-call.js";
13
12
  import { partitionAttachmentsByReference } from "./note-attachment-sync.js";
14
13
  import { buildNoteAgentContextArtifact, getCachedNoteAgentContextArtifact } from "./agent-context.js";
@@ -153,7 +152,7 @@ async function buildAiCatalysisReport(note, config) {
153
152
  role: "user",
154
153
  content: buildCatalysisPrompt(note),
155
154
  timestamp: Date.now()
156
- }] }, { temperature: .2 });
155
+ }] }, { temperature: .2 }, void 0, { operation: "note.generate" });
157
156
  let responseText = "";
158
157
  if (Array.isArray(response.content)) {
159
158
  for (const part of response.content) if (part && typeof part === "object" && part.type === "text") responseText += String(part.text || "");
@@ -173,7 +172,7 @@ var NotesService = class {
173
172
  flushCommittedEffects() {
174
173
  this.store.drainAttachmentCleanup();
175
174
  this.store.drainDeletionCleanup();
176
- new DomainOutboxDispatcher(publishAutomationProductEvent).drain(100, "note");
175
+ new DomainOutboxDispatcher().drain(100, "note");
177
176
  }
178
177
  async quickCapture(markdown, source, idempotencyKey) {
179
178
  const note = this.quickCaptureAtomically(markdown, source, idempotencyKey);
@@ -8,7 +8,6 @@ import { enqueueProjectChanged } from "./project-change-events.js";
8
8
  import { ProjectWorkspaceConflictError, ProjectWorkspaceMissingError, canonicalWorkspacePath, inferProjectNameFromWorkspaceRoot, isPathSameOrInsideWorkspace, isSafeAutoCreateWorkspaceRoot, resolveWorkspaceProjectRoot, workspaceDirectoryExists } from "./workspace-project.js";
9
9
  import { drainProjectWorkspaceCreation, queueProjectWorkspaceCreation } from "./project-workspace-creation.js";
10
10
  import { DomainOutboxDispatcher } from "../infra/domain-outbox-dispatcher.js";
11
- import { publishAutomationProductEvent } from "../automations/product-events.js";
12
11
  import { listPendingProjectUnderstandingRuns } from "../work-discovery/repository.js";
13
12
  import { inferProjectExecutionMode } from "./project-kind.js";
14
13
  import { bindSessionToProject, listProjectConversationIds, unbindSessionFromProject } from "./session-bind.js";
@@ -280,7 +279,7 @@ var ProjectService = class {
280
279
  }
281
280
  flushCommittedEffects(projectId) {
282
281
  drainProjectWorkspaceCreation(projectId);
283
- new DomainOutboxDispatcher(publishAutomationProductEvent).drain(100, "project");
282
+ new DomainOutboxDispatcher().drain(100, "project");
284
283
  }
285
284
  listUpdates(projectId, limit) {
286
285
  return this.store.listUpdates(projectId, limit);
@@ -1,8 +1,8 @@
1
1
  import { init_paths, resolveBundledSkillsDir } from "../config/paths.js";
2
- import { resolveWorkspaceSkillsDir, resolveWorkspaceSkillsLockPath } from "../agent/skills/workspace-skills-dir.js";
3
- import { loadSkills, loadWorkspaceSkillInventory } from "../agent/skills/index.js";
4
2
  import { removeSkillsLockEntry } from "../agent/skills/hub-lock.js";
5
3
  import { deleteManagedSkill, installSkillFromZip, isValidSkillId } from "../agent/skills/managed-store.js";
4
+ import { resolveWorkspaceSkillsDir, resolveWorkspaceSkillsLockPath } from "../agent/skills/workspace-skills-dir.js";
5
+ import { loadSkills, loadWorkspaceSkillInventory } from "../agent/skills/index.js";
6
6
  import { pullSkillFromSource } from "../agent/skills/hub-pull.js";
7
7
  import { downloadFromMarketplace } from "../agent/skills/skills-marketplace.js";
8
8
  import { basename, dirname, join, relative, resolve, sep } from "node:path";
@@ -1,5 +1,6 @@
1
1
  import { type Api, type AssistantMessage, type Context, type Model, type SimpleStreamOptions } from '@earendil-works/pi-ai/compat';
2
2
  import type { CredentialResolverOptions } from '../auth/credentials.js';
3
+ import type { AiUsageContext } from '../usage/types.js';
3
4
  export declare function isLocalModelBaseUrl(baseUrl: string | undefined): boolean;
4
5
  /** Codex Responses rejects the temperature request parameter. */
5
6
  export declare function supportsModelTemperature(model: Model<Api>): boolean;
@@ -8,10 +9,10 @@ export declare function resolveModelCallOptions(model: Model<Api>, options?: Sim
8
9
  /**
9
10
  * Complete a one-shot request with xopc credential resolution and extension-provider routing.
10
11
  */
11
- export declare function completeWithResolvedCredentials(model: Model<Api>, context: Context, options?: SimpleStreamOptions, credentialOptions?: CredentialResolverOptions): Promise<AssistantMessage>;
12
+ export declare function completeWithResolvedCredentials(model: Model<Api>, context: Context, options: SimpleStreamOptions, credentialOptions: CredentialResolverOptions | undefined, usageContext: AiUsageContext): Promise<AssistantMessage>;
12
13
  /**
13
14
  * Start a model stream with xopc credential resolution and extension-provider routing.
14
15
  * Callers that need live visible output should consume the returned stream before calling
15
16
  * its `result()` method.
16
17
  */
17
- export declare function createResolvedModelStream(model: Model<Api>, context: Context, options?: SimpleStreamOptions, credentialOptions?: CredentialResolverOptions): Promise<import("@earendil-works/pi-ai/compat").AssistantMessageEventStream>;
18
+ export declare function createResolvedModelStream(model: Model<Api>, context: Context, options: SimpleStreamOptions, credentialOptions: CredentialResolverOptions | undefined, usageContext: AiUsageContext): Promise<import("@earendil-works/pi-ai/compat").AssistantMessageEventStream>;
@@ -1,6 +1,7 @@
1
1
  import { init_constants } from "./constants.js";
2
2
  import { getApiKey, init_providers } from "./index.js";
3
3
  import { createExtensionAwareStreamFn } from "./extension-stream-bridge.js";
4
+ import { finishAiUsageFromMessage, observeAiUsageStream, startAiUsageCall } from "../usage/recorder.js";
4
5
  import { completeSimple, normalizeContext } from "@earendil-works/pi-ai/compat";
5
6
  //#region src/providers/model-call.ts
6
7
  init_constants();
@@ -40,19 +41,43 @@ async function resolveModelCallOptions(model, options = {}, credentialOptions) {
40
41
  /**
41
42
  * Complete a one-shot request with xopc credential resolution and extension-provider routing.
42
43
  */
43
- async function completeWithResolvedCredentials(model, context, options = {}, credentialOptions) {
44
+ async function completeWithResolvedCredentials(model, context, options, credentialOptions, usageContext) {
44
45
  const resolvedOptions = await resolveModelCallOptions(model, options, credentialOptions);
45
- if (model.baseUrl === "extension://provider-plugin") return await (await createExtensionAwareStreamFn()(model, normalizeContext(context), resolvedOptions)).result();
46
- return await completeSimple(model, context, resolvedOptions);
46
+ const usageCall = startAiUsageCall(model, usageContext);
47
+ try {
48
+ if (model.baseUrl === "extension://provider-plugin") {
49
+ const result = await (await createExtensionAwareStreamFn()(model, normalizeContext(context), resolvedOptions)).result();
50
+ finishAiUsageFromMessage(usageCall, result);
51
+ return result;
52
+ }
53
+ const result = await completeSimple(model, context, resolvedOptions);
54
+ finishAiUsageFromMessage(usageCall, result);
55
+ return result;
56
+ } catch (error) {
57
+ usageCall?.finish({
58
+ status: "failed",
59
+ errorSummary: error instanceof Error ? error.message : String(error)
60
+ });
61
+ throw error;
62
+ }
47
63
  }
48
64
  /**
49
65
  * Start a model stream with xopc credential resolution and extension-provider routing.
50
66
  * Callers that need live visible output should consume the returned stream before calling
51
67
  * its `result()` method.
52
68
  */
53
- async function createResolvedModelStream(model, context, options = {}, credentialOptions) {
69
+ async function createResolvedModelStream(model, context, options, credentialOptions, usageContext) {
54
70
  const resolvedOptions = await resolveModelCallOptions(model, options, credentialOptions);
55
- return await createExtensionAwareStreamFn()(model, normalizeContext(context), resolvedOptions);
71
+ const usageCall = startAiUsageCall(model, usageContext);
72
+ try {
73
+ return observeAiUsageStream(await createExtensionAwareStreamFn()(model, normalizeContext(context), resolvedOptions), usageCall);
74
+ } catch (error) {
75
+ usageCall?.finish({
76
+ status: "failed",
77
+ errorSummary: error instanceof Error ? error.message : String(error)
78
+ });
79
+ throw error;
80
+ }
56
81
  }
57
82
  //#endregion
58
83
  export { completeWithResolvedCredentials, createResolvedModelStream, isLocalModelBaseUrl, resolveModelCallApiKey, resolveModelCallOptions, supportsModelTemperature };
@@ -1,7 +1,7 @@
1
1
  import { __esmMin } from "../../_virtual/_rolldown/runtime.js";
2
2
  import { init_paths_state, resolveXopcCloudCatalogCachePath } from "../config/paths-state.js";
3
- import { init_write_file_atomic, writeTextAtomic } from "../infra/write-file-atomic.js";
4
3
  import { ComputerProfileSchema, init_src } from "../../packages/computer-control-contract/src/index.js";
4
+ import { init_write_file_atomic, writeTextAtomic } from "../infra/write-file-atomic.js";
5
5
  import { voiceManifestSchema } from "../../packages/realtime-protocol/src/voice-catalog.js";
6
6
  import { init_voice } from "../../packages/realtime-protocol/src/voice.js";
7
7
  import { readFileSync, rmSync } from "node:fs";
@@ -0,0 +1,19 @@
1
+ import type { ScenePrincipal, SceneTemplate } from './contracts.js';
2
+ /** Extension point for activation shapes that need more than the core read-only setup. */
3
+ export interface SceneActivationAdapter {
4
+ id: string;
5
+ preflight(principal: ScenePrincipal, template: SceneTemplate, configuration: unknown): Promise<{
6
+ ready: boolean;
7
+ missing: string[];
8
+ }>;
9
+ create(principal: ScenePrincipal, template: SceneTemplate, configuration: unknown): Promise<unknown>;
10
+ get(principal: ScenePrincipal, activationId: string): unknown;
11
+ configure(principal: ScenePrincipal, activationId: string, expectedRevision: number, configuration: unknown): Promise<unknown>;
12
+ transition(principal: ScenePrincipal, activationId: string, expectedRevision: number, status: 'active' | 'paused' | 'archived'): Promise<unknown>;
13
+ tick(): Promise<void>;
14
+ stop(): Promise<void>;
15
+ executeTask?(runId: string, conversationId: string): Promise<boolean>;
16
+ allowsTaskNotification?(taskId: string): boolean;
17
+ listProjectBranches?(principal: ScenePrincipal, projectId: string): Promise<unknown>;
18
+ associateBranch?(principal: ScenePrincipal, input: unknown): Promise<unknown>;
19
+ }
@@ -0,0 +1 @@
1
+ export {};