@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
@@ -0,0 +1,6 @@
1
+ -- Direct cutover: task-backed scenes are claimed by the task execution adapter.
2
+ -- Existing activations keep their template identity; no compatibility runtime remains.
3
+ UPDATE scene_template_versions
4
+ SET manifest_json = json_set(manifest_json, '$.execution.kind', 'task'),
5
+ content_hash = '4e0e6b0bfb597c06c81e34898f64af6b45b6d8705b65d1f4665d8027cddf5406'
6
+ WHERE template_key = 'task-follow-up' AND version = '1.0.0';
@@ -0,0 +1 @@
1
+ DROP TABLE IF EXISTS scene_model_usage;
@@ -0,0 +1,4 @@
1
+ DROP TABLE IF EXISTS memory_relations;
2
+ DROP TABLE IF EXISTS memory_fts;
3
+ DROP TABLE IF EXISTS memory_chunks;
4
+ DROP TABLE IF EXISTS memory_files;
@@ -0,0 +1,26 @@
1
+ CREATE INDEX idx_task_runs_contract
2
+ ON task_runs(task_id, contract_version);
3
+ CREATE INDEX idx_task_runs_conversation
4
+ ON task_runs(conversation_id);
5
+ CREATE INDEX idx_task_runs_parent
6
+ ON task_runs(parent_run_id);
7
+ CREATE INDEX idx_task_runs_retry
8
+ ON task_runs(retry_of_run_id);
9
+ CREATE INDEX idx_task_runs_context_snapshot
10
+ ON task_runs(context_snapshot_id);
11
+ CREATE INDEX idx_task_run_feedback_run
12
+ ON task_run_feedback(run_id);
13
+ CREATE INDEX idx_work_discovery_runs_conversation
14
+ ON work_discovery_runs(conversation_id);
15
+ CREATE INDEX idx_connector_execution_audit_connection
16
+ ON connector_execution_audit(connection_id);
17
+ CREATE INDEX idx_connector_execution_audit_installation
18
+ ON connector_execution_audit(installation_id);
19
+ CREATE INDEX idx_connector_learning_jobs_connection
20
+ ON connector_learning_jobs(connection_id);
21
+ CREATE INDEX idx_connector_approvals_connection
22
+ ON connector_approvals(connection_id);
23
+ CREATE INDEX idx_knowledge_source_changes_item
24
+ ON knowledge_source_changes(source_item_id);
25
+ CREATE INDEX idx_notification_deliveries_device
26
+ ON notification_deliveries(device_id);
@@ -0,0 +1,123 @@
1
+ CREATE TABLE automations_next (
2
+ automation_id TEXT PRIMARY KEY,
3
+ name TEXT NOT NULL,
4
+ description TEXT,
5
+ enabled INTEGER NOT NULL,
6
+ trigger_json TEXT NOT NULL CHECK(json_valid(trigger_json)),
7
+ action_json TEXT NOT NULL CHECK(json_valid(action_json)),
8
+ reliability_json TEXT CHECK(reliability_json IS NULL OR json_valid(reliability_json)),
9
+ state_json TEXT NOT NULL DEFAULT '{}' CHECK(json_valid(state_json)),
10
+ created_at_ms INTEGER NOT NULL,
11
+ updated_at_ms INTEGER NOT NULL,
12
+ safety_json TEXT CHECK(safety_json IS NULL OR json_valid(safety_json)),
13
+ project_id TEXT,
14
+ conversation_mode TEXT NOT NULL DEFAULT 'new_session'
15
+ CHECK(conversation_mode IN ('new_session', 'continuous')),
16
+ management_json TEXT CHECK(management_json IS NULL OR json_valid(management_json)),
17
+ delivery_json TEXT NOT NULL CHECK(json_valid(delivery_json))
18
+ );
19
+
20
+ INSERT INTO automations_next SELECT * FROM automations;
21
+ DROP TABLE automations;
22
+ ALTER TABLE automations_next RENAME TO automations;
23
+ CREATE INDEX idx_automations_enabled ON automations(enabled, updated_at_ms DESC);
24
+ CREATE INDEX idx_automations_updated ON automations(updated_at_ms DESC);
25
+ CREATE INDEX idx_automations_project ON automations(project_id, updated_at_ms DESC);
26
+
27
+ CREATE TABLE automation_events_next (
28
+ event_id TEXT PRIMARY KEY,
29
+ event_type TEXT NOT NULL,
30
+ schema_version INTEGER NOT NULL DEFAULT 1,
31
+ source TEXT NOT NULL,
32
+ subject_kind TEXT,
33
+ subject_id TEXT,
34
+ occurred_at_ms INTEGER NOT NULL,
35
+ ingested_at_ms INTEGER NOT NULL,
36
+ correlation_id TEXT NOT NULL,
37
+ causation_id TEXT,
38
+ root_event_id TEXT NOT NULL,
39
+ chain_depth INTEGER NOT NULL DEFAULT 0 CHECK(chain_depth BETWEEN 0 AND 32),
40
+ dedupe_key TEXT,
41
+ trust TEXT NOT NULL CHECK(trust IN ('system', 'user', 'connector', 'untrusted_webhook')),
42
+ payload_json TEXT NOT NULL CHECK(json_valid(payload_json)),
43
+ projection_status TEXT NOT NULL DEFAULT 'pending'
44
+ CHECK(projection_status IN ('pending', 'projecting', 'retrying', 'projected', 'dead_letter')),
45
+ projected_at_ms INTEGER,
46
+ projection_attempts INTEGER NOT NULL DEFAULT 0,
47
+ projection_next_attempt_at_ms INTEGER NOT NULL DEFAULT 0,
48
+ projection_error TEXT,
49
+ projection_owner TEXT,
50
+ projection_lease_until_ms INTEGER
51
+ );
52
+
53
+ INSERT INTO automation_events_next SELECT * FROM automation_events;
54
+ DROP TABLE automation_events;
55
+ ALTER TABLE automation_events_next RENAME TO automation_events;
56
+ CREATE UNIQUE INDEX idx_automation_events_source_dedupe
57
+ ON automation_events(source, dedupe_key) WHERE dedupe_key IS NOT NULL;
58
+ CREATE INDEX idx_automation_events_projection
59
+ ON automation_events(projection_status, projection_next_attempt_at_ms, ingested_at_ms);
60
+
61
+ CREATE TABLE automation_result_deliveries_next (
62
+ delivery_id TEXT NOT NULL UNIQUE,
63
+ run_id TEXT NOT NULL,
64
+ destination_key TEXT NOT NULL,
65
+ kind TEXT NOT NULL,
66
+ status TEXT NOT NULL CHECK(status IN ('pending', 'delivering', 'retrying', 'delivered', 'dead_letter')),
67
+ config_json TEXT NOT NULL CHECK(json_valid(config_json)),
68
+ attempts INTEGER NOT NULL DEFAULT 0,
69
+ next_attempt_at_ms INTEGER NOT NULL,
70
+ last_error TEXT,
71
+ lease_owner TEXT,
72
+ lease_until_ms INTEGER,
73
+ created_at_ms INTEGER NOT NULL,
74
+ updated_at_ms INTEGER NOT NULL,
75
+ PRIMARY KEY(run_id, destination_key),
76
+ FOREIGN KEY(run_id) REFERENCES automation_results(run_id) ON DELETE CASCADE
77
+ );
78
+
79
+ INSERT INTO automation_result_deliveries_next SELECT * FROM automation_result_deliveries;
80
+ DROP TABLE automation_result_deliveries;
81
+ ALTER TABLE automation_result_deliveries_next RENAME TO automation_result_deliveries;
82
+ CREATE INDEX idx_automation_result_deliveries_pending
83
+ ON automation_result_deliveries(status, next_attempt_at_ms, created_at_ms);
84
+
85
+ CREATE TABLE ai_usage_events_next (
86
+ id TEXT PRIMARY KEY,
87
+ trace_id TEXT NOT NULL,
88
+ parent_event_id TEXT,
89
+ conversation_id TEXT,
90
+ run_id TEXT,
91
+ agent_id TEXT,
92
+ category TEXT NOT NULL,
93
+ operation TEXT NOT NULL,
94
+ trigger_kind TEXT NOT NULL,
95
+ reason_key TEXT NOT NULL,
96
+ provider TEXT NOT NULL,
97
+ model TEXT NOT NULL,
98
+ status TEXT NOT NULL CHECK(status IN ('running', 'succeeded', 'failed', 'aborted', 'unknown')),
99
+ started_at INTEGER NOT NULL,
100
+ finished_at INTEGER,
101
+ duration_ms INTEGER,
102
+ input_tokens INTEGER,
103
+ output_tokens INTEGER,
104
+ cache_read_tokens INTEGER,
105
+ cache_write_tokens INTEGER,
106
+ reasoning_tokens INTEGER,
107
+ total_tokens INTEGER,
108
+ estimated_cost_microusd INTEGER,
109
+ cost_source TEXT NOT NULL CHECK(cost_source IN ('model_catalog', 'local', 'unknown')),
110
+ pricing_snapshot_json TEXT CHECK(pricing_snapshot_json IS NULL OR json_valid(pricing_snapshot_json)),
111
+ error_summary TEXT,
112
+ created_at INTEGER NOT NULL,
113
+ updated_at INTEGER NOT NULL
114
+ );
115
+
116
+ INSERT INTO ai_usage_events_next SELECT * FROM ai_usage_events;
117
+ DROP TABLE ai_usage_events;
118
+ ALTER TABLE ai_usage_events_next RENAME TO ai_usage_events;
119
+ CREATE INDEX idx_ai_usage_events_started ON ai_usage_events(started_at DESC, id DESC);
120
+ CREATE INDEX idx_ai_usage_events_conversation ON ai_usage_events(conversation_id, started_at DESC);
121
+ CREATE INDEX idx_ai_usage_events_trace ON ai_usage_events(trace_id, started_at ASC);
122
+ CREATE INDEX idx_ai_usage_events_agent ON ai_usage_events(agent_id, started_at DESC);
123
+ CREATE INDEX idx_ai_usage_events_category ON ai_usage_events(category, started_at DESC);
@@ -0,0 +1,339 @@
1
+ CREATE TABLE sessions_next (
2
+ conversation_id TEXT PRIMARY KEY,
3
+ agent_id TEXT NOT NULL,
4
+ active_transcript_id TEXT NOT NULL UNIQUE,
5
+ status TEXT NOT NULL DEFAULT 'active',
6
+ name TEXT,
7
+ tags_json TEXT NOT NULL DEFAULT '[]',
8
+ created_at INTEGER NOT NULL,
9
+ updated_at INTEGER NOT NULL,
10
+ last_accessed_at INTEGER NOT NULL,
11
+ session_started_at INTEGER,
12
+ last_interaction_at INTEGER,
13
+ source_channel TEXT NOT NULL DEFAULT '',
14
+ source_chat_id TEXT NOT NULL DEFAULT '',
15
+ session_type TEXT,
16
+ hidden_from_session_list INTEGER NOT NULL DEFAULT 0,
17
+ parent_conversation_id TEXT,
18
+ workflow_run_id TEXT,
19
+ workflow_definition_id TEXT,
20
+ workflow_agent_id TEXT,
21
+ workflow_agent_label TEXT,
22
+ routing_json TEXT,
23
+ custom_data_json TEXT,
24
+ message_count INTEGER NOT NULL DEFAULT 0,
25
+ estimated_tokens INTEGER NOT NULL DEFAULT 0,
26
+ compacted_count INTEGER NOT NULL DEFAULT 0,
27
+ last_flushed_at INTEGER,
28
+ flush_count INTEGER NOT NULL DEFAULT 0,
29
+ thinking_level TEXT,
30
+ verbose_level TEXT,
31
+ project_id TEXT
32
+ );
33
+ INSERT INTO sessions_next SELECT
34
+ conversation_id, agent_id, active_transcript_id, status, name, tags_json, created_at,
35
+ updated_at, last_accessed_at, session_started_at, last_interaction_at, source_channel,
36
+ source_chat_id, session_type, hidden_from_session_list, parent_conversation_id,
37
+ workflow_run_id, workflow_definition_id, workflow_agent_id, workflow_agent_label,
38
+ routing_json, custom_data_json, message_count, estimated_tokens, compacted_count,
39
+ CASE WHEN last_flushed_at IS NULL THEN NULL
40
+ WHEN typeof(last_flushed_at) IN ('integer', 'real') THEN CAST(last_flushed_at AS INTEGER)
41
+ ELSE CAST(ROUND((julianday(last_flushed_at) - 2440587.5) * 86400000) AS INTEGER) END,
42
+ flush_count, thinking_level, verbose_level, project_id
43
+ FROM sessions;
44
+ DROP TABLE sessions;
45
+ ALTER TABLE sessions_next RENAME TO sessions;
46
+ CREATE INDEX idx_sessions_agent_updated ON sessions(agent_id, updated_at DESC);
47
+ CREATE INDEX idx_sessions_last_interaction ON sessions(last_interaction_at DESC);
48
+ CREATE INDEX idx_sessions_parent ON sessions(parent_conversation_id);
49
+ CREATE INDEX idx_sessions_project ON sessions(project_id, updated_at DESC);
50
+ CREATE INDEX idx_sessions_source_channel ON sessions(source_channel);
51
+ CREATE INDEX idx_sessions_status ON sessions(status);
52
+ CREATE INDEX idx_sessions_type ON sessions(session_type);
53
+ CREATE INDEX idx_sessions_workflow_run ON sessions(workflow_run_id);
54
+
55
+ CREATE TABLE connector_catalog_entries_next (
56
+ connector_id TEXT PRIMARY KEY,
57
+ provider TEXT NOT NULL,
58
+ definition_json TEXT NOT NULL,
59
+ fetched_at INTEGER NOT NULL,
60
+ expires_at INTEGER
61
+ );
62
+ INSERT INTO connector_catalog_entries_next SELECT
63
+ connector_id, provider, definition_json,
64
+ CASE WHEN typeof(fetched_at) IN ('integer', 'real') THEN CAST(fetched_at AS INTEGER)
65
+ ELSE CAST(ROUND((julianday(fetched_at) - 2440587.5) * 86400000) AS INTEGER) END,
66
+ CASE WHEN expires_at IS NULL THEN NULL
67
+ WHEN typeof(expires_at) IN ('integer', 'real') THEN CAST(expires_at AS INTEGER)
68
+ ELSE CAST(ROUND((julianday(expires_at) - 2440587.5) * 86400000) AS INTEGER) END
69
+ FROM connector_catalog_entries;
70
+ DROP TABLE connector_catalog_entries;
71
+ ALTER TABLE connector_catalog_entries_next RENAME TO connector_catalog_entries;
72
+ CREATE INDEX idx_connector_catalog_provider ON connector_catalog_entries(provider, fetched_at DESC);
73
+
74
+ CREATE TABLE connector_installations_next (
75
+ id TEXT PRIMARY KEY,
76
+ connector_id TEXT NOT NULL,
77
+ principal_id TEXT NOT NULL,
78
+ enabled INTEGER NOT NULL DEFAULT 1 CHECK(enabled IN (0, 1)),
79
+ allowed_agent_ids_json TEXT NOT NULL DEFAULT '[]',
80
+ max_scope TEXT NOT NULL DEFAULT 'read' CHECK(max_scope IN ('read', 'write', 'admin')),
81
+ confirmation_policy TEXT NOT NULL DEFAULT 'writes'
82
+ CHECK(confirmation_policy IN ('always', 'writes', 'admin', 'never')),
83
+ selected_account_ids_json TEXT NOT NULL DEFAULT '[]',
84
+ created_at INTEGER NOT NULL,
85
+ updated_at INTEGER NOT NULL,
86
+ UNIQUE(connector_id, principal_id)
87
+ );
88
+ INSERT INTO connector_installations_next SELECT
89
+ id, connector_id, principal_id, enabled, allowed_agent_ids_json, max_scope,
90
+ confirmation_policy, selected_account_ids_json,
91
+ CASE WHEN typeof(created_at) IN ('integer', 'real') THEN CAST(created_at AS INTEGER)
92
+ ELSE CAST(ROUND((julianday(created_at) - 2440587.5) * 86400000) AS INTEGER) END,
93
+ CASE WHEN typeof(updated_at) IN ('integer', 'real') THEN CAST(updated_at AS INTEGER)
94
+ ELSE CAST(ROUND((julianday(updated_at) - 2440587.5) * 86400000) AS INTEGER) END
95
+ FROM connector_installations;
96
+ DROP TABLE connector_installations;
97
+ ALTER TABLE connector_installations_next RENAME TO connector_installations;
98
+ CREATE INDEX idx_connector_installations_principal
99
+ ON connector_installations(principal_id, enabled, connector_id);
100
+
101
+ CREATE TABLE connector_accounts_next (
102
+ id TEXT PRIMARY KEY,
103
+ connector_id TEXT NOT NULL,
104
+ principal_id TEXT NOT NULL,
105
+ identity_key TEXT,
106
+ identity_json TEXT NOT NULL DEFAULT '{}',
107
+ current_connection_id TEXT,
108
+ created_at INTEGER NOT NULL,
109
+ updated_at INTEGER NOT NULL,
110
+ label TEXT,
111
+ enabled INTEGER NOT NULL DEFAULT 1,
112
+ allowed_agent_ids_json TEXT,
113
+ backend_id TEXT,
114
+ runtime_instance_id TEXT
115
+ );
116
+ INSERT INTO connector_accounts_next SELECT
117
+ id, connector_id, principal_id, identity_key, identity_json, current_connection_id,
118
+ CASE WHEN typeof(created_at) IN ('integer', 'real') THEN CAST(created_at AS INTEGER)
119
+ ELSE CAST(ROUND((julianday(created_at) - 2440587.5) * 86400000) AS INTEGER) END,
120
+ CASE WHEN typeof(updated_at) IN ('integer', 'real') THEN CAST(updated_at AS INTEGER)
121
+ ELSE CAST(ROUND((julianday(updated_at) - 2440587.5) * 86400000) AS INTEGER) END,
122
+ label, enabled, allowed_agent_ids_json, backend_id, runtime_instance_id
123
+ FROM connector_accounts;
124
+ DROP TABLE connector_accounts;
125
+ ALTER TABLE connector_accounts_next RENAME TO connector_accounts;
126
+ CREATE UNIQUE INDEX idx_cli_account_identity
127
+ ON connector_accounts(principal_id, runtime_instance_id, identity_key)
128
+ WHERE runtime_instance_id IS NOT NULL AND identity_key IS NOT NULL;
129
+ CREATE UNIQUE INDEX idx_connector_accounts_identity
130
+ ON connector_accounts(principal_id, backend_id, connector_id, identity_key)
131
+ WHERE identity_key IS NOT NULL;
132
+
133
+ CREATE TABLE connector_connections_next (
134
+ id TEXT PRIMARY KEY,
135
+ installation_id TEXT REFERENCES connector_installations(id) ON DELETE SET NULL,
136
+ connector_id TEXT NOT NULL,
137
+ provider TEXT NOT NULL,
138
+ principal_id TEXT NOT NULL,
139
+ provider_connection_id TEXT NOT NULL,
140
+ alias TEXT,
141
+ identity_json TEXT NOT NULL DEFAULT '{}',
142
+ status TEXT NOT NULL DEFAULT 'unknown'
143
+ CHECK(status IN ('pending', 'active', 'expired', 'failed', 'revoked', 'disabled', 'unknown')),
144
+ is_default INTEGER NOT NULL DEFAULT 0 CHECK(is_default IN (0, 1)),
145
+ connected_at INTEGER,
146
+ expires_at INTEGER,
147
+ last_error TEXT,
148
+ metadata_json TEXT NOT NULL DEFAULT '{}',
149
+ created_at INTEGER NOT NULL,
150
+ updated_at INTEGER NOT NULL,
151
+ account_id TEXT REFERENCES connector_accounts(id) ON DELETE CASCADE
152
+ );
153
+ INSERT INTO connector_connections_next SELECT
154
+ id, installation_id, connector_id, provider, principal_id, provider_connection_id,
155
+ alias, identity_json, status, is_default,
156
+ CASE WHEN connected_at IS NULL THEN NULL
157
+ WHEN typeof(connected_at) IN ('integer', 'real') THEN CAST(connected_at AS INTEGER)
158
+ ELSE CAST(ROUND((julianday(connected_at) - 2440587.5) * 86400000) AS INTEGER) END,
159
+ CASE WHEN expires_at IS NULL THEN NULL
160
+ WHEN typeof(expires_at) IN ('integer', 'real') THEN CAST(expires_at AS INTEGER)
161
+ ELSE CAST(ROUND((julianday(expires_at) - 2440587.5) * 86400000) AS INTEGER) END,
162
+ last_error, metadata_json,
163
+ CASE WHEN typeof(created_at) IN ('integer', 'real') THEN CAST(created_at AS INTEGER)
164
+ ELSE CAST(ROUND((julianday(created_at) - 2440587.5) * 86400000) AS INTEGER) END,
165
+ CASE WHEN typeof(updated_at) IN ('integer', 'real') THEN CAST(updated_at AS INTEGER)
166
+ ELSE CAST(ROUND((julianday(updated_at) - 2440587.5) * 86400000) AS INTEGER) END,
167
+ account_id
168
+ FROM connector_connections;
169
+ DROP TABLE connector_connections;
170
+ ALTER TABLE connector_connections_next RENAME TO connector_connections;
171
+ CREATE INDEX idx_connector_connections_account ON connector_connections(account_id);
172
+ CREATE INDEX idx_connector_connections_principal
173
+ ON connector_connections(principal_id, connector_id, status);
174
+ CREATE UNIQUE INDEX idx_connector_connections_provider_backend
175
+ ON connector_connections(provider, COALESCE(json_extract(metadata_json, '$.backendId'), ''), provider_connection_id);
176
+
177
+ CREATE TABLE connector_action_metadata_next (
178
+ connector_id TEXT NOT NULL,
179
+ action_id TEXT NOT NULL,
180
+ toolkit TEXT,
181
+ scope TEXT NOT NULL DEFAULT 'write' CHECK(scope IN ('read', 'write', 'admin')),
182
+ curated INTEGER NOT NULL DEFAULT 0 CHECK(curated IN (0, 1)),
183
+ input_schema_json TEXT,
184
+ schema_version TEXT,
185
+ cached_at INTEGER NOT NULL,
186
+ PRIMARY KEY(connector_id, action_id)
187
+ );
188
+ INSERT INTO connector_action_metadata_next SELECT
189
+ connector_id, action_id, toolkit, scope, curated, input_schema_json, schema_version,
190
+ CASE WHEN typeof(cached_at) IN ('integer', 'real') THEN CAST(cached_at AS INTEGER)
191
+ ELSE CAST(ROUND((julianday(cached_at) - 2440587.5) * 86400000) AS INTEGER) END
192
+ FROM connector_action_metadata;
193
+ DROP TABLE connector_action_metadata;
194
+ ALTER TABLE connector_action_metadata_next RENAME TO connector_action_metadata;
195
+ CREATE INDEX idx_connector_action_scope
196
+ ON connector_action_metadata(connector_id, scope, curated);
197
+
198
+ CREATE TABLE connector_execution_audit_next (
199
+ id TEXT PRIMARY KEY,
200
+ installation_id TEXT REFERENCES connector_installations(id) ON DELETE SET NULL,
201
+ connection_id TEXT REFERENCES connector_connections(id) ON DELETE SET NULL,
202
+ connector_id TEXT NOT NULL,
203
+ principal_id TEXT NOT NULL,
204
+ agent_id TEXT,
205
+ conversation_id TEXT,
206
+ action_id TEXT NOT NULL,
207
+ scope TEXT NOT NULL CHECK(scope IN ('read', 'write', 'admin')),
208
+ decision TEXT NOT NULL CHECK(decision IN ('allowed', 'denied', 'confirmation_required')),
209
+ result_status TEXT NOT NULL CHECK(result_status IN ('success', 'error', 'not_executed')),
210
+ duration_ms INTEGER,
211
+ error_code TEXT,
212
+ created_at INTEGER NOT NULL
213
+ );
214
+ INSERT INTO connector_execution_audit_next SELECT
215
+ id, installation_id, connection_id, connector_id, principal_id, agent_id,
216
+ conversation_id, action_id, scope, decision, result_status, duration_ms, error_code,
217
+ CASE WHEN typeof(created_at) IN ('integer', 'real') THEN CAST(created_at AS INTEGER)
218
+ ELSE CAST(ROUND((julianday(created_at) - 2440587.5) * 86400000) AS INTEGER) END
219
+ FROM connector_execution_audit;
220
+ DROP TABLE connector_execution_audit;
221
+ ALTER TABLE connector_execution_audit_next RENAME TO connector_execution_audit;
222
+ CREATE INDEX idx_connector_audit_connector_time
223
+ ON connector_execution_audit(connector_id, created_at DESC);
224
+ CREATE INDEX idx_connector_audit_principal_time
225
+ ON connector_execution_audit(principal_id, created_at DESC);
226
+ CREATE INDEX idx_connector_execution_audit_connection
227
+ ON connector_execution_audit(connection_id);
228
+ CREATE INDEX idx_connector_execution_audit_installation
229
+ ON connector_execution_audit(installation_id);
230
+
231
+ CREATE TABLE connector_approvals_next (
232
+ id TEXT PRIMARY KEY,
233
+ principal_id TEXT NOT NULL,
234
+ connector_id TEXT NOT NULL,
235
+ connection_id TEXT REFERENCES connector_connections(id) ON DELETE SET NULL,
236
+ agent_id TEXT,
237
+ conversation_id TEXT,
238
+ action_id TEXT NOT NULL,
239
+ scope TEXT NOT NULL CHECK(scope IN ('read', 'write', 'admin')),
240
+ arguments_hash TEXT NOT NULL,
241
+ arguments_preview_json TEXT NOT NULL DEFAULT '{}',
242
+ status TEXT NOT NULL DEFAULT 'pending'
243
+ CHECK(status IN ('pending', 'approved', 'denied', 'expired', 'consumed')),
244
+ expires_at INTEGER NOT NULL,
245
+ created_at INTEGER NOT NULL,
246
+ decided_at INTEGER,
247
+ consumed_at INTEGER,
248
+ wait_id TEXT
249
+ );
250
+ INSERT INTO connector_approvals_next SELECT
251
+ id, principal_id, connector_id, connection_id, agent_id, conversation_id, action_id,
252
+ scope, arguments_hash, arguments_preview_json, status,
253
+ CASE WHEN typeof(expires_at) IN ('integer', 'real') THEN CAST(expires_at AS INTEGER)
254
+ ELSE CAST(ROUND((julianday(expires_at) - 2440587.5) * 86400000) AS INTEGER) END,
255
+ CASE WHEN typeof(created_at) IN ('integer', 'real') THEN CAST(created_at AS INTEGER)
256
+ ELSE CAST(ROUND((julianday(created_at) - 2440587.5) * 86400000) AS INTEGER) END,
257
+ CASE WHEN decided_at IS NULL THEN NULL
258
+ WHEN typeof(decided_at) IN ('integer', 'real') THEN CAST(decided_at AS INTEGER)
259
+ ELSE CAST(ROUND((julianday(decided_at) - 2440587.5) * 86400000) AS INTEGER) END,
260
+ CASE WHEN consumed_at IS NULL THEN NULL
261
+ WHEN typeof(consumed_at) IN ('integer', 'real') THEN CAST(consumed_at AS INTEGER)
262
+ ELSE CAST(ROUND((julianday(consumed_at) - 2440587.5) * 86400000) AS INTEGER) END,
263
+ wait_id
264
+ FROM connector_approvals;
265
+ DROP TABLE connector_approvals;
266
+ ALTER TABLE connector_approvals_next RENAME TO connector_approvals;
267
+ CREATE INDEX idx_connector_approvals_connection ON connector_approvals(connection_id);
268
+ CREATE INDEX idx_connector_approvals_pending
269
+ ON connector_approvals(principal_id, status, expires_at, created_at DESC);
270
+ CREATE INDEX idx_connector_approvals_session
271
+ ON connector_approvals(conversation_id, status, created_at DESC);
272
+
273
+ CREATE TABLE connector_webhook_deliveries_next (
274
+ id TEXT PRIMARY KEY,
275
+ provider TEXT NOT NULL,
276
+ payload_hash TEXT NOT NULL,
277
+ status TEXT NOT NULL DEFAULT 'processing'
278
+ CHECK(status IN ('pending', 'processing', 'processed')),
279
+ attempts INTEGER NOT NULL DEFAULT 1,
280
+ received_at INTEGER NOT NULL,
281
+ processing_at INTEGER,
282
+ processed_at INTEGER,
283
+ last_error TEXT
284
+ );
285
+ INSERT INTO connector_webhook_deliveries_next SELECT
286
+ id, provider, payload_hash, status, attempts,
287
+ CASE WHEN typeof(received_at) IN ('integer', 'real') THEN CAST(received_at AS INTEGER)
288
+ ELSE CAST(ROUND((julianday(received_at) - 2440587.5) * 86400000) AS INTEGER) END,
289
+ CASE WHEN processing_at IS NULL THEN NULL
290
+ WHEN typeof(processing_at) IN ('integer', 'real') THEN CAST(processing_at AS INTEGER)
291
+ ELSE CAST(ROUND((julianday(processing_at) - 2440587.5) * 86400000) AS INTEGER) END,
292
+ CASE WHEN processed_at IS NULL THEN NULL
293
+ WHEN typeof(processed_at) IN ('integer', 'real') THEN CAST(processed_at AS INTEGER)
294
+ ELSE CAST(ROUND((julianday(processed_at) - 2440587.5) * 86400000) AS INTEGER) END,
295
+ last_error
296
+ FROM connector_webhook_deliveries;
297
+ DROP TABLE connector_webhook_deliveries;
298
+ ALTER TABLE connector_webhook_deliveries_next RENAME TO connector_webhook_deliveries;
299
+ CREATE INDEX idx_connector_webhook_deliveries_status
300
+ ON connector_webhook_deliveries(provider, status, received_at DESC);
301
+
302
+ CREATE TABLE user_trust_policies_next (
303
+ principal_id TEXT PRIMARY KEY,
304
+ default_action_level TEXT NOT NULL DEFAULT 'confirm'
305
+ CHECK(default_action_level IN ('observe', 'suggest', 'confirm', 'auto')),
306
+ updated_at INTEGER NOT NULL
307
+ );
308
+ INSERT INTO user_trust_policies_next SELECT
309
+ principal_id, default_action_level,
310
+ CASE WHEN typeof(updated_at) IN ('integer', 'real') THEN CAST(updated_at AS INTEGER)
311
+ ELSE CAST(ROUND((julianday(updated_at) - 2440587.5) * 86400000) AS INTEGER) END
312
+ FROM user_trust_policies;
313
+ DROP TABLE user_trust_policies;
314
+ ALTER TABLE user_trust_policies_next RENAME TO user_trust_policies;
315
+
316
+ CREATE TABLE connector_backends_next (
317
+ id TEXT PRIMARY KEY,
318
+ mode TEXT NOT NULL CHECK(mode IN ('managed', 'byok')),
319
+ label TEXT NOT NULL,
320
+ credential_ref TEXT,
321
+ credential_source TEXT NOT NULL DEFAULT 'stored'
322
+ CHECK(credential_source IN ('stored', 'environment')),
323
+ verified_at INTEGER,
324
+ active INTEGER NOT NULL DEFAULT 0,
325
+ created_at INTEGER NOT NULL
326
+ );
327
+ INSERT INTO connector_backends_next SELECT
328
+ id, mode, label, credential_ref, credential_source,
329
+ CASE WHEN verified_at IS NULL THEN NULL
330
+ WHEN typeof(verified_at) IN ('integer', 'real') THEN CAST(verified_at AS INTEGER)
331
+ ELSE CAST(ROUND((julianday(verified_at) - 2440587.5) * 86400000) AS INTEGER) END,
332
+ active,
333
+ CASE WHEN typeof(created_at) IN ('integer', 'real') THEN CAST(created_at AS INTEGER)
334
+ ELSE CAST(ROUND((julianday(created_at) - 2440587.5) * 86400000) AS INTEGER) END
335
+ FROM connector_backends;
336
+ DROP TABLE connector_backends;
337
+ ALTER TABLE connector_backends_next RENAME TO connector_backends;
338
+ CREATE UNIQUE INDEX idx_connector_backend_active
339
+ ON connector_backends(active) WHERE active = 1;
@@ -0,0 +1,2 @@
1
+ CREATE INDEX idx_ai_usage_events_provider_model
2
+ ON ai_usage_events(provider, model, started_at DESC);
@@ -0,0 +1,13 @@
1
+ INSERT INTO session_config (
2
+ conversation_id, thinking_level, verbose_level, updated_at
3
+ )
4
+ SELECT conversation_id, thinking_level, verbose_level, updated_at
5
+ FROM sessions
6
+ WHERE thinking_level IS NOT NULL OR verbose_level IS NOT NULL
7
+ ON CONFLICT(conversation_id) DO UPDATE SET
8
+ thinking_level = COALESCE(session_config.thinking_level, excluded.thinking_level),
9
+ verbose_level = COALESCE(session_config.verbose_level, excluded.verbose_level),
10
+ updated_at = MAX(session_config.updated_at, excluded.updated_at);
11
+
12
+ ALTER TABLE sessions DROP COLUMN thinking_level;
13
+ ALTER TABLE sessions DROP COLUMN verbose_level;
@@ -3,7 +3,7 @@ import type { ApplyMigrationsOptions } from './types.js';
3
3
  /** Baseline schema version applied from schema.sql on first open. */
4
4
  export declare const XOPC_DB_BASELINE_SCHEMA_VERSION = 165;
5
5
  /** Latest schema version this release supports (increment when adding migrations). */
6
- export declare const XOPC_DB_SCHEMA_VERSION = 208;
6
+ export declare const XOPC_DB_SCHEMA_VERSION = 222;
7
7
  export declare function resolveMigrationsDir(override?: string): string;
8
8
  /**
9
9
  * Apply sequential SQL migrations from (currentVersion + 1) through targetVersion.
@@ -26,7 +26,7 @@ function applySingleMigration(db, migration, discardOldScenes = false) {
26
26
  targetVersion: migration.targetVersion,
27
27
  file: migration.filename
28
28
  }, "Applying SQLite migration");
29
- const requiresForeignKeyPause = discardOldScenes || migration.targetVersion === 179 || migration.targetVersion === 182 || migration.targetVersion === 188 || migration.targetVersion === 200 || migration.targetVersion === 201 || migration.targetVersion === 203;
29
+ const requiresForeignKeyPause = discardOldScenes || migration.targetVersion === 179 || migration.targetVersion === 182 || migration.targetVersion === 188 || migration.targetVersion === 200 || migration.targetVersion === 201 || migration.targetVersion === 203 || migration.targetVersion === 219 || migration.targetVersion === 220;
30
30
  const foreignKeysEnabled = Number(db.prepare("PRAGMA foreign_keys").get()?.foreign_keys) === 1;
31
31
  if (requiresForeignKeyPause) db.exec("PRAGMA foreign_keys = OFF");
32
32
  let transactionStarted = false;
@@ -57,7 +57,7 @@ function applySingleMigration(db, migration, discardOldScenes = false) {
57
57
  */
58
58
  function applyPendingMigrations(db, options = {}) {
59
59
  db.function("xopc_operation_id", () => currentOperationId() ?? null);
60
- const targetVersion = options.targetVersion ?? 208;
60
+ const targetVersion = options.targetVersion ?? 222;
61
61
  let currentVersion = readSchemaVersion(db);
62
62
  if (currentVersion > targetVersion) throw new DatabaseSchemaTooNewError(currentVersion, targetVersion);
63
63
  if (!options.migrationsDir && currentVersion < 165) throw new DatabaseSchemaTooOldError(currentVersion, 165);
@@ -95,7 +95,7 @@ function applyPendingMigrations(db, options = {}) {
95
95
  }
96
96
  /** Inspect schema version without mutating the database. */
97
97
  function inspectSchemaMigrationStatus(db, options = {}) {
98
- const appVersion = options.targetVersion ?? 208;
98
+ const appVersion = options.targetVersion ?? 222;
99
99
  const dbVersion = readSchemaVersion(db);
100
100
  if (dbVersion > appVersion) return {
101
101
  dbVersion,
@@ -137,7 +137,7 @@ var init_runner = __esmMin((() => {
137
137
  init_errors();
138
138
  log = createLogger("Sqlite:Migrations");
139
139
  XOPC_DB_BASELINE_SCHEMA_VERSION = 165;
140
- XOPC_DB_SCHEMA_VERSION = 208;
140
+ XOPC_DB_SCHEMA_VERSION = 222;
141
141
  }));
142
142
  //#endregion
143
143
  init_runner();
@@ -29,10 +29,8 @@ export type SessionRow = {
29
29
  message_count: number;
30
30
  estimated_tokens: number;
31
31
  compacted_count: number;
32
- last_flushed_at: string | null;
32
+ last_flushed_at: number | null;
33
33
  flush_count: number;
34
- thinking_level: string | null;
35
- verbose_level: string | null;
36
34
  cwd?: string | null;
37
35
  };
38
36
  export type TranscriptEntryRow = {
@@ -59,7 +57,7 @@ export type SessionConfigRow = {
59
57
  updated_at: number;
60
58
  };
61
59
  export declare function sessionRowToMetadata(conversationId: string, row: SessionRow): SessionMetadata;
62
- export declare function metadataToSessionInsert(conversationId: string, transcriptId: string, metadata: SessionMetadata, thinkingLevel?: string | null, verboseLevel?: string | null): {
60
+ export declare function metadataToSessionInsert(conversationId: string, transcriptId: string, metadata: SessionMetadata): {
63
61
  conversationId: string;
64
62
  agentId: string;
65
63
  transcriptId: string;
@@ -86,10 +84,8 @@ export declare function metadataToSessionInsert(conversationId: string, transcri
86
84
  messageCount: number;
87
85
  estimatedTokens: number;
88
86
  compactedCount: number;
89
- lastFlushedAt: string | null;
87
+ lastFlushedAt: number | null;
90
88
  flushCount: number;
91
- thinkingLevel: string | null;
92
- verboseLevel: string | null;
93
89
  };
94
90
  export declare function sessionConfigRowToConfig(row: SessionConfigRow): SessionAgentConfig;
95
91
  export declare function transcriptEntryRowToStoredRow(row: TranscriptEntryRow): TranscriptStoredRow;
@@ -2,6 +2,7 @@ import { __esmMin } from "../../../_virtual/_rolldown/runtime.js";
2
2
  import { init_session_context_for_llm, isTranscriptContextEntry, isTranscriptSideChatOriginEntry } from "../../session/session-context-for-llm.js";
3
3
  import "../../session/types.js";
4
4
  import { buildDefaultSessionMetadata, init_session_metadata } from "./session-metadata.js";
5
+ import { init_timestamps, optionalTimestampToIso, optionalTimestampToMs } from "./timestamps.js";
5
6
  //#region src/storage/sqlite/row-mappers.ts
6
7
  function parseJson(raw) {
7
8
  if (!raw?.trim()) return;
@@ -50,7 +51,7 @@ function sessionRowToMetadata(conversationId, row) {
50
51
  messageCount: row.message_count,
51
52
  estimatedTokens: row.estimated_tokens,
52
53
  compactedCount: row.compacted_count,
53
- lastFlushedAt: row.last_flushed_at ?? void 0,
54
+ lastFlushedAt: optionalTimestampToIso(row.last_flushed_at),
54
55
  flushCount: row.flush_count,
55
56
  transcriptId: row.active_transcript_id,
56
57
  cwd: row.cwd ?? void 0,
@@ -61,7 +62,7 @@ function sessionRowToMetadata(conversationId, row) {
61
62
  }
62
63
  };
63
64
  }
64
- function metadataToSessionInsert(conversationId, transcriptId, metadata, thinkingLevel, verboseLevel) {
65
+ function metadataToSessionInsert(conversationId, transcriptId, metadata) {
65
66
  const now = Date.now();
66
67
  const agentId = (metadata.agentId || metadata.routing?.agentId)?.trim().toLowerCase();
67
68
  if (!agentId) throw new Error("Creating a conversation requires an explicit agent ID");
@@ -92,10 +93,8 @@ function metadataToSessionInsert(conversationId, transcriptId, metadata, thinkin
92
93
  messageCount: metadata.messageCount,
93
94
  estimatedTokens: metadata.estimatedTokens,
94
95
  compactedCount: metadata.compactedCount,
95
- lastFlushedAt: metadata.lastFlushedAt ?? null,
96
- flushCount: metadata.flushCount ?? 0,
97
- thinkingLevel: thinkingLevel ?? null,
98
- verboseLevel: verboseLevel ?? null
96
+ lastFlushedAt: optionalTimestampToMs(metadata.lastFlushedAt),
97
+ flushCount: metadata.flushCount ?? 0
99
98
  };
100
99
  }
101
100
  function sessionConfigRowToConfig(row) {
@@ -187,6 +186,7 @@ function buildGlobalSessionStats(sessions) {
187
186
  var init_row_mappers = __esmMin((() => {
188
187
  init_session_context_for_llm();
189
188
  init_session_metadata();
189
+ init_timestamps();
190
190
  }));
191
191
  //#endregion
192
192
  init_row_mappers();
@@ -1,6 +1,6 @@
1
1
  import type { DatabaseSync } from 'node:sqlite';
2
2
  export declare const NOTIFICATION_LEDGER_TABLES: readonly ["notification_browser_keys", "notification_browser_subscriptions", "notification_dispatches", "notification_result_outbox", "notification_attention_budget", "notification_digest_queue", "notification_digests", "notification_digest_members", "notification_dispatch_decisions", "notification_browser_probes", "notification_presence"];
3
- export declare const SCENE_TABLES: readonly ["scene_source_health", "scene_activation_requests", "scene_activations", "scene_context_snapshots", "scene_events", "scene_feedback", "scene_feedback_history", "scene_intent_events", "scene_model_reservations", "scene_notes", "scene_outcomes", "scene_preferences", "scene_presentations", "scene_runs", "scene_schedule_cursors", "scene_template_versions", "scene_trigger_intents", "scene_work_items", "scene_mail_sources", "scene_model_usage", "scene_connector_usage"];
3
+ export declare const SCENE_TABLES: readonly ["scene_source_health", "scene_activation_requests", "scene_activations", "scene_context_snapshots", "scene_events", "scene_feedback", "scene_feedback_history", "scene_intent_events", "scene_model_reservations", "scene_notes", "scene_outcomes", "scene_preferences", "scene_presentations", "scene_runs", "scene_schedule_cursors", "scene_template_versions", "scene_trigger_intents", "scene_work_items", "scene_mail_sources", "scene_connector_usage"];
4
4
  /** Installs fresh tables; the normal versioned upgrade owns existing databases. */
5
5
  export declare function installSceneSchema(db: DatabaseSync): void;
6
6
  export declare function installNotificationLedgerSchema(db: DatabaseSync): void;