@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
@@ -9,7 +9,7 @@ import { AppContextEnvelopeSchema, ResolvedAppContextSchema, init_app_context }
9
9
  import { SceneActivationSchema, SceneConfigureSchema, SceneFeedbackSchema, ScenePreferencePatchSchema, SceneTransitionSchema, SceneWorkItemCreateSchema, SceneWorkItemSchema, SceneWorkItemUpdateSchema, activationInputSchema, init_scenes, sceneNotesSchema, scenePreferencesSchema, sceneScheduleSchema, sceneTemplateSchema } from "./scenes.js";
10
10
  import { z } from "zod";
11
11
  //#region packages/gateway-contract/src/capabilities.ts
12
- var CapabilityErrorCodeSchema, CapabilityCallSchema, AutomationSimulationSchema, AutomationDraftRequestSchema, AutomationDraftOutputSchema, AutomationRepairDraftOutputSchema, CapabilityResourceInputSchema, ScenePageInputSchema, SceneWriteContracts, SceneOutcomeReadSchema, TaskRunCancelInputSchema, TaskRunFeedbackInputSchema, TaskRunFeedbackOutputSchema, TaskRunCancelOutputSchema, AutomationSetEnabledInputSchema, AutomationMutationOutputSchema, AutomationRunMutationOutputSchema, AutomationCancelOutputSchema, AutomationReadOutputSchema, AutomationReadAllInputSchema, AutomationReadAllOutputSchema, AutomationDeleteInputSchema, AutomationDeleteOutputSchema, NoteListInputSchema, NoteRecordSchema, NoteGetOutputSchema, NoteDeleteInputSchema, NoteDeleteOutputSchema, NoteCreateInputSchema, NoteUpdateInputSchema, NoteCaptureInputSchema, NoteAppendInputSchema, NoteRestoreInputSchema, NoteListOutputSchema, TaskListInputSchema, ProjectRecordSchema, ProjectSetPinnedInputSchema, ProjectMutationOutputSchema, ProjectResolveWorkspaceInputSchema, ProjectResolveWorkspaceOutputSchema, ProjectDeleteInputSchema, ProjectDeleteOutputSchema, ProjectFields, ProjectCreateInputSchema, ProjectEditInputSchema, ProjectListInputSchema, ProjectMilestoneSchema, ProjectUpdateSchema, MilestoneFields, ProjectMilestoneCreateInputSchema, ProjectMilestoneUpdateInputSchema, ProjectMilestoneDeleteInputSchema, ProjectMilestoneOutputSchema, ProjectMilestoneDeleteOutputSchema, ProjectUpdateCreateInputSchema, ProjectUpdateOutputSchema, ProductReadContracts;
12
+ var CapabilityErrorCodeSchema, CapabilityCallSchema, AutomationSimulationSchema, AutomationDraftRequestSchema, AutomationDraftOutputSchema, AutomationRepairDraftOutputSchema, CapabilityResourceInputSchema, ScenePageInputSchema, SceneWriteContracts, SceneOutcomeReadSchema, TaskRunCancelInputSchema, TaskRunFeedbackInputSchema, TaskRunFeedbackOutputSchema, TaskRunCancelOutputSchema, AutomationSetEnabledInputSchema, AutomationMutationOutputSchema, AutomationRunMutationOutputSchema, AutomationCancelOutputSchema, AutomationReadOutputSchema, AutomationReadAllInputSchema, AutomationReadAllOutputSchema, AutomationReplayEventInputSchema, AutomationRetryDeliveryInputSchema, AutomationRecoveryOutputSchema, AutomationDeleteInputSchema, AutomationDeleteOutputSchema, NoteListInputSchema, NoteRecordSchema, NoteGetOutputSchema, NoteDeleteInputSchema, NoteDeleteOutputSchema, NoteCreateInputSchema, NoteUpdateInputSchema, NoteCaptureInputSchema, NoteAppendInputSchema, NoteRestoreInputSchema, NoteListOutputSchema, TaskListInputSchema, ProjectRecordSchema, ProjectSetPinnedInputSchema, ProjectMutationOutputSchema, ProjectResolveWorkspaceInputSchema, ProjectResolveWorkspaceOutputSchema, ProjectDeleteInputSchema, ProjectDeleteOutputSchema, ProjectFields, ProjectCreateInputSchema, ProjectEditInputSchema, ProjectListInputSchema, ProjectMilestoneSchema, ProjectUpdateSchema, MilestoneFields, ProjectMilestoneCreateInputSchema, ProjectMilestoneUpdateInputSchema, ProjectMilestoneDeleteInputSchema, ProjectMilestoneOutputSchema, ProjectMilestoneDeleteOutputSchema, ProjectUpdateCreateInputSchema, ProjectUpdateOutputSchema, ProductReadContracts;
13
13
  var init_capabilities = __esmMin((() => {
14
14
  init_app_context();
15
15
  init_task_lifecycle();
@@ -227,6 +227,16 @@ var init_capabilities = __esmMin((() => {
227
227
  ok: z.literal(true),
228
228
  count: z.number().int().nonnegative()
229
229
  });
230
+ AutomationReplayEventInputSchema = CapabilityResourceInputSchema.extend({ reason: z.string().trim().min(1).max(2e3) });
231
+ AutomationRetryDeliveryInputSchema = z.strictObject({
232
+ runId: z.string().trim().min(1).max(200),
233
+ destinationKey: z.string().trim().min(1).max(100),
234
+ reason: z.string().trim().min(1).max(2e3)
235
+ });
236
+ AutomationRecoveryOutputSchema = z.object({
237
+ ok: z.literal(true),
238
+ accepted: z.literal(true)
239
+ });
230
240
  AutomationDeleteInputSchema = CapabilityResourceInputSchema.extend({ expectedRevision: z.number().int().nonnegative().nullable() });
231
241
  AutomationDeleteOutputSchema = z.object({
232
242
  ok: z.literal(true),
@@ -601,6 +611,100 @@ var init_capabilities = __esmMin((() => {
601
611
  metrics: AutomationMetricsSchema
602
612
  })
603
613
  },
614
+ "xopc.automations.events": {
615
+ input: z.strictObject({
616
+ type: z.string().trim().min(1).max(512).optional(),
617
+ source: z.string().trim().min(1).max(512).optional(),
618
+ limit: z.number().int().min(1).max(200).default(50)
619
+ }),
620
+ output: z.object({
621
+ ok: z.literal(true),
622
+ items: z.array(z.object({
623
+ event: z.object({
624
+ id: z.string(),
625
+ type: z.string(),
626
+ schemaVersion: z.number().int(),
627
+ source: z.string(),
628
+ subject: z.object({
629
+ kind: z.string(),
630
+ id: z.string()
631
+ }).optional(),
632
+ payload: z.record(z.string(), z.unknown()),
633
+ occurredAtMs: z.number(),
634
+ ingestedAtMs: z.number(),
635
+ correlationId: z.string(),
636
+ causationId: z.string().optional(),
637
+ rootEventId: z.string(),
638
+ chainDepth: z.number().int(),
639
+ dedupeKey: z.string().optional(),
640
+ trust: z.enum([
641
+ "system",
642
+ "user",
643
+ "connector",
644
+ "untrusted_webhook"
645
+ ])
646
+ }),
647
+ projectionStatus: z.enum([
648
+ "pending",
649
+ "projecting",
650
+ "retrying",
651
+ "projected",
652
+ "dead_letter"
653
+ ]),
654
+ projectionAttempts: z.number().int(),
655
+ projectionError: z.string().optional(),
656
+ deliveries: z.array(z.object({
657
+ automationId: z.string(),
658
+ status: z.enum([
659
+ "pending",
660
+ "retrying",
661
+ "queued",
662
+ "completed",
663
+ "failed",
664
+ "cancelled",
665
+ "skipped",
666
+ "dead_letter"
667
+ ]),
668
+ runId: z.string().optional(),
669
+ attempts: z.number().int(),
670
+ lastError: z.string().optional()
671
+ }))
672
+ }))
673
+ })
674
+ },
675
+ "xopc.automations.deliveries": {
676
+ input: z.strictObject({
677
+ runId: z.string().trim().min(1).max(200).optional(),
678
+ status: z.enum([
679
+ "pending",
680
+ "delivering",
681
+ "retrying",
682
+ "delivered",
683
+ "dead_letter"
684
+ ]).optional(),
685
+ limit: z.number().int().min(1).max(200).default(50)
686
+ }),
687
+ output: z.object({
688
+ ok: z.literal(true),
689
+ items: z.array(z.object({
690
+ runId: z.string(),
691
+ destinationKey: z.string(),
692
+ kind: z.string(),
693
+ status: z.enum([
694
+ "pending",
695
+ "delivering",
696
+ "retrying",
697
+ "delivered",
698
+ "dead_letter"
699
+ ]),
700
+ attempts: z.number().int(),
701
+ nextAttemptAtMs: z.number(),
702
+ lastError: z.string().optional(),
703
+ createdAtMs: z.number(),
704
+ updatedAtMs: z.number()
705
+ }))
706
+ })
707
+ },
604
708
  "xopc.automations.product_events": {
605
709
  input: z.strictObject({
606
710
  eventType: z.string().trim().min(1).max(512),
@@ -717,12 +821,6 @@ var init_capabilities = __esmMin((() => {
717
821
  currentModel: z.string().nullable(),
718
822
  pendingChecks: z.number().int().nonnegative(),
719
823
  oldestDueWaitMs: z.number().nonnegative(),
720
- lastSevenDays: z.object({
721
- modelCalls: z.number().int().nonnegative(),
722
- connectorReads: z.number().int().nonnegative(),
723
- tokens: z.number().nonnegative(),
724
- estimatedCost: z.number().nonnegative()
725
- }),
726
824
  notifications: z.array(z.object({
727
825
  status: z.string(),
728
826
  count: z.number().int().nonnegative()
@@ -969,4 +1067,4 @@ var init_capabilities = __esmMin((() => {
969
1067
  }));
970
1068
  //#endregion
971
1069
  init_capabilities();
972
- export { AutomationCancelOutputSchema, AutomationDeleteInputSchema, AutomationDeleteOutputSchema, AutomationDraftOutputSchema, AutomationDraftRequestSchema, AutomationMutationOutputSchema, AutomationReadAllInputSchema, AutomationReadAllOutputSchema, AutomationReadOutputSchema, AutomationRepairDraftOutputSchema, AutomationRunMutationOutputSchema, AutomationSetEnabledInputSchema, AutomationSimulationSchema, CapabilityCallSchema, CapabilityErrorCodeSchema, CapabilityResourceInputSchema, NoteAppendInputSchema, NoteCaptureInputSchema, NoteCreateInputSchema, NoteDeleteInputSchema, NoteDeleteOutputSchema, NoteGetOutputSchema, NoteListInputSchema, NoteListOutputSchema, NoteRecordSchema, NoteRestoreInputSchema, NoteUpdateInputSchema, ProductReadContracts, ProjectCreateInputSchema, ProjectDeleteInputSchema, ProjectDeleteOutputSchema, ProjectEditInputSchema, ProjectListInputSchema, ProjectMilestoneCreateInputSchema, ProjectMilestoneDeleteInputSchema, ProjectMilestoneDeleteOutputSchema, ProjectMilestoneOutputSchema, ProjectMilestoneSchema, ProjectMilestoneUpdateInputSchema, ProjectMutationOutputSchema, ProjectRecordSchema, ProjectResolveWorkspaceInputSchema, ProjectResolveWorkspaceOutputSchema, ProjectSetPinnedInputSchema, ProjectUpdateCreateInputSchema, ProjectUpdateOutputSchema, ProjectUpdateSchema, ScenePageInputSchema, SceneWriteContracts, TaskListInputSchema, TaskRunCancelInputSchema, TaskRunCancelOutputSchema, TaskRunFeedbackInputSchema, TaskRunFeedbackOutputSchema, init_capabilities };
1070
+ export { AutomationCancelOutputSchema, AutomationDeleteInputSchema, AutomationDeleteOutputSchema, AutomationDraftOutputSchema, AutomationDraftRequestSchema, AutomationMutationOutputSchema, AutomationReadAllInputSchema, AutomationReadAllOutputSchema, AutomationReadOutputSchema, AutomationRecoveryOutputSchema, AutomationRepairDraftOutputSchema, AutomationReplayEventInputSchema, AutomationRetryDeliveryInputSchema, AutomationRunMutationOutputSchema, AutomationSetEnabledInputSchema, AutomationSimulationSchema, CapabilityCallSchema, CapabilityErrorCodeSchema, CapabilityResourceInputSchema, NoteAppendInputSchema, NoteCaptureInputSchema, NoteCreateInputSchema, NoteDeleteInputSchema, NoteDeleteOutputSchema, NoteGetOutputSchema, NoteListInputSchema, NoteListOutputSchema, NoteRecordSchema, NoteRestoreInputSchema, NoteUpdateInputSchema, ProductReadContracts, ProjectCreateInputSchema, ProjectDeleteInputSchema, ProjectDeleteOutputSchema, ProjectEditInputSchema, ProjectListInputSchema, ProjectMilestoneCreateInputSchema, ProjectMilestoneDeleteInputSchema, ProjectMilestoneDeleteOutputSchema, ProjectMilestoneOutputSchema, ProjectMilestoneSchema, ProjectMilestoneUpdateInputSchema, ProjectMutationOutputSchema, ProjectRecordSchema, ProjectResolveWorkspaceInputSchema, ProjectResolveWorkspaceOutputSchema, ProjectSetPinnedInputSchema, ProjectUpdateCreateInputSchema, ProjectUpdateOutputSchema, ProjectUpdateSchema, ScenePageInputSchema, SceneWriteContracts, TaskListInputSchema, TaskRunCancelInputSchema, TaskRunCancelOutputSchema, TaskRunFeedbackInputSchema, TaskRunFeedbackOutputSchema, init_capabilities };
@@ -35,6 +35,7 @@ import { init_app_context } from "./app-context.js";
35
35
  import { init_scenes } from "./scenes.js";
36
36
  import { init_capabilities } from "./capabilities.js";
37
37
  import { init_extension_capabilities } from "./extension-capabilities.js";
38
+ import { init_usage } from "./usage.js";
38
39
  //#region packages/gateway-contract/src/index.ts
39
40
  var init_src = __esmMin((() => {
40
41
  init_agent_stream();
@@ -73,6 +74,7 @@ var init_src = __esmMin((() => {
73
74
  init_extension_capabilities();
74
75
  init_local_apps();
75
76
  init_chat_previews();
77
+ init_usage();
76
78
  }));
77
79
  //#endregion
78
80
  init_src();
@@ -1,7 +1,7 @@
1
1
  import { __esmMin } from "../../../_virtual/_rolldown/runtime.js";
2
2
  import { z } from "zod";
3
3
  //#region packages/gateway-contract/src/scenes.ts
4
- var identifier, uniqueIds, sceneOutcomeKinds, activationStatuses, sceneScopeSchema, limitsSchema, sceneTemplateSchema, scenePermissionSchema, sceneNotesSchema, activationInputSchema, SceneActivationSchema, SceneConfigureSchema, SceneTransitionSchema, SceneWorkItemCreateSchema, SceneWorkItemUpdateSchema, SceneWorkItemSchema, hour, scenePreferencesSchema, preferenceFields, ScenePreferencePatchSchema, SceneFeedbackSchema, sceneScheduleSchema;
4
+ var identifier, uniqueIds, sceneOutcomeKinds, activationStatuses, sceneScopeSchema, limitsSchema, executionSchema, sceneTemplateSchema, scenePermissionSchema, sceneNotesSchema, activationInputSchema, SceneActivationSchema, SceneConfigureSchema, SceneTransitionSchema, SceneWorkItemCreateSchema, SceneWorkItemUpdateSchema, SceneWorkItemSchema, hour, scenePreferencesSchema, preferenceFields, ScenePreferencePatchSchema, SceneFeedbackSchema, sceneScheduleSchema;
5
5
  var init_scenes = __esmMin((() => {
6
6
  identifier = z.string().trim().min(1).max(200);
7
7
  uniqueIds = z.array(identifier).max(100).refine((items) => new Set(items).size === items.length, "Duplicate identifiers");
@@ -42,6 +42,11 @@ var init_scenes = __esmMin((() => {
42
42
  maxToolCalls: z.number().int().min(0).max(100),
43
43
  maxOutputTokens: z.number().int().min(1).max(32768)
44
44
  });
45
+ executionSchema = z.strictObject({
46
+ kind: z.string().regex(/^[a-z][a-z0-9_-]{0,63}$/),
47
+ instruction: z.string().trim().min(1).max(32e3),
48
+ limits: limitsSchema
49
+ });
45
50
  sceneTemplateSchema = z.strictObject({
46
51
  schemaVersion: z.literal(1),
47
52
  key: z.string().regex(/^[a-z][a-z0-9-]{0,79}$/),
@@ -65,11 +70,7 @@ var init_scenes = __esmMin((() => {
65
70
  type: z.literal("schedule")
66
71
  })
67
72
  ])).min(1).max(20).refine((items) => new Set(items.map((item) => item.id)).size === items.length, "Duplicate trigger IDs"),
68
- execution: z.strictObject({
69
- kind: z.literal("agent"),
70
- instruction: z.string().trim().min(1).max(32e3),
71
- limits: limitsSchema
72
- }),
73
+ execution: executionSchema,
73
74
  allowedOutcomeKinds: z.array(z.enum(sceneOutcomeKinds)).min(1),
74
75
  allowedEffectHandlers: uniqueIds
75
76
  });
@@ -70,7 +70,8 @@ var init_sessions = __esmMin((() => {
70
70
  offset: z.number(),
71
71
  hasMore: z.boolean(),
72
72
  before: z.string().optional(),
73
- nextBeforeCursor: z.string().optional()
73
+ nextBeforeCursor: z.string().optional(),
74
+ revision: z.number().int().nonnegative().optional()
74
75
  }).passthrough()
75
76
  }).passthrough();
76
77
  z.object({ session: z.object({
@@ -0,0 +1,6 @@
1
+ import { __esmMin } from "../../../_virtual/_rolldown/runtime.js";
2
+ //#region packages/gateway-contract/src/usage.ts
3
+ var init_usage = __esmMin((() => {}));
4
+ //#endregion
5
+ init_usage();
6
+ export { init_usage };
@@ -18,6 +18,7 @@ import { init_sync_provider_auth, resolveProviderApiKeySync } from "../auth/sync
18
18
  import { CredentialResolver, init_credentials } from "../auth/credentials.js";
19
19
  import { getApiKeySync, getDefaultModelSync, init_providers, resolveModel } from "../providers/index.js";
20
20
  import { createExtensionAwareStreamFn } from "../providers/extension-stream-bridge.js";
21
+ import { continuesAfterTool, trackAiUsageStream } from "../usage/recorder.js";
21
22
  import { extractTextContent } from "./context/workspace.js";
22
23
  import { buildExecutionScopeContextForPrompt } from "./context/execution-scope.js";
23
24
  import { clearBootstrapSnapshot } from "./bootstrap/bootstrap-cache.js";
@@ -25,13 +26,13 @@ import { resolveBootstrapContextSync } from "./bootstrap/bootstrap-files.js";
25
26
  import { loadProjectAgentsContextFile } from "./bootstrap/project-agents-context.js";
26
27
  import { getEmbeddedExecutionRunId } from "./embedded/execution-context.js";
27
28
  import { parseExternalToolRef } from "./external-tools/refs.js";
29
+ import { loadSkillsLock } from "./skills/hub-lock.js";
30
+ import { isUnderManagedSkillsDir } from "./skills/managed-store.js";
28
31
  import { mcpToolPolicyId } from "./mcp/bundle-mcp-policy.js";
29
32
  import { disposeAllSessionMcpRuntimes, retireSessionMcpRuntimeForConversationId } from "./mcp/bundle-mcp-runtime.js";
30
33
  import { createSkillConfigManager, isSkillEnabled, resolveSkillConfig } from "./skills/config.js";
31
34
  import { isValidSkillEnvVarName } from "./skills/required-env-vars.js";
32
35
  import { resolveWorkspaceSkillsDir, resolveWorkspaceSkillsLockPath } from "./skills/workspace-skills-dir.js";
33
- import { loadSkillsLock } from "./skills/hub-lock.js";
34
- import { isUnderManagedSkillsDir } from "./skills/managed-store.js";
35
36
  import { replaceAgentSystemPrompt } from "./prompt/agent-system-prompt.js";
36
37
  import { evictAllEmbeddedSessionRunners, evictEmbeddedSessionRunner } from "./embedded/session-runner.js";
37
38
  import { createAgentTurnPolicy } from "./orchestration/agent-turn-policy.js";
@@ -1027,6 +1028,7 @@ var AgentManager = class {
1027
1028
  const registeredToolNames = tools.map((t) => t.name);
1028
1029
  const thinkingLevel = this.config.thinkingLevel ?? "medium";
1029
1030
  const turnPolicy = this.buildAgentTurnPolicy(conversationId, profile);
1031
+ const providerStreamFn = createExtensionAwareStreamFn();
1030
1032
  agent = new Agent({
1031
1033
  initialState: {
1032
1034
  systemPrompt: rt.systemPromptBuilder.build(contextFiles, {
@@ -1048,7 +1050,11 @@ var AgentManager = class {
1048
1050
  messages: []
1049
1051
  },
1050
1052
  toolExecution: "parallel",
1051
- streamFn: createExtensionAwareStreamFn(),
1053
+ streamFn: (streamModel, context, options) => trackAiUsageStream(streamModel, {
1054
+ operation: continuesAfterTool(context.messages) ? "agent.continue_after_tool" : "agent.answer",
1055
+ conversationId,
1056
+ agentId: profile.agentId
1057
+ }, () => providerStreamFn(streamModel, context, options)),
1052
1058
  getApiKey: (provider) => this.resolveApiKeyWithCache(provider),
1053
1059
  finishTurn: (context) => turnPolicy.shouldStopAfterTurn(context) ? { action: "end" } : void 0,
1054
1060
  beforeToolCall: turnPolicy.beforeToolCall,
@@ -8,6 +8,7 @@ import { extractProfileAgentId } from "../../config/agent-profile.js";
8
8
  import { init_sync_provider_auth, resolveProviderApiKeySync } from "../../auth/sync-provider-auth.js";
9
9
  import { getApiKeySync, init_providers, resolveModel } from "../../providers/index.js";
10
10
  import { createExtensionAwareStreamFn } from "../../providers/extension-stream-bridge.js";
11
+ import { trackAiUsageStream } from "../../usage/recorder.js";
11
12
  import { extractTextContent } from "../context/workspace.js";
12
13
  import { getAssertionSlot, listUserAssertions } from "../../user-model/repository.js";
13
14
  import { readAgentMessageContent } from "../memory/agent-message-access.js";
@@ -125,6 +126,7 @@ function resolveInterpreterRuntime(params) {
125
126
  };
126
127
  }
127
128
  async function interpret(params) {
129
+ const providerStreamFn = createExtensionAwareStreamFn();
128
130
  const reviewAgent = new Agent({
129
131
  initialState: {
130
132
  systemPrompt: USER_MODEL_MAINTAINER_SYSTEM_PROMPT,
@@ -133,7 +135,10 @@ async function interpret(params) {
133
135
  tools: [],
134
136
  messages: []
135
137
  },
136
- streamFn: createExtensionAwareStreamFn(),
138
+ streamFn: (model, context, options) => trackAiUsageStream(model, {
139
+ operation: "user_model.interpret",
140
+ conversationId: params.conversationId
141
+ }, () => providerStreamFn(model, context, options)),
137
142
  getApiKey: (provider) => resolveProviderApiKeySync(provider) ?? getApiKeySync(provider) ?? ""
138
143
  });
139
144
  reviewAgent.state.messages = params.evidence.map(tagMessage);
@@ -2,6 +2,7 @@ import { createLogger } from "../../utils/logger/index.js";
2
2
  import { init_logger } from "../../utils/logger.js";
3
3
  import { getClarification, getClarificationResumeInput, init_clarification_wait_repository, isClarificationSuspended } from "../../storage/sqlite/clarification-wait-repository.js";
4
4
  import { getConnectionResumeInput, init_connection_wait_repository, isConnectionSuspended } from "../../storage/sqlite/connection-wait-repository.js";
5
+ import { continuesAfterTool, trackAiUsageStream } from "../../usage/recorder.js";
5
6
  import { runWithEmbeddedExecutionSession } from "./execution-context.js";
6
7
  import { isComputerControlActive, isComputerLeaseTool, stopComputerControl } from "../../computer/control-guard.js";
7
8
  import { EmbeddedRunConflictError, abortEmbeddedRun, acquireEmbeddedRunLease, queueEmbeddedSteer } from "./runs.js";
@@ -450,7 +451,12 @@ async function runXopcEmbeddedTurn(params) {
450
451
  tools: effectiveTools
451
452
  } } : {}
452
453
  }, "Sending messages to AI");
453
- return streamFnWithXopcExtensions(streamModel, effectiveContext, { ...options });
454
+ return trackAiUsageStream(streamModel, {
455
+ operation: continuesAfterTool(effectiveContext.messages) ? "agent.continue_after_tool" : "agent.answer",
456
+ conversationId,
457
+ runId,
458
+ traceId: runId
459
+ }, () => streamFnWithXopcExtensions(streamModel, effectiveContext, { ...options }));
454
460
  };
455
461
  session.agent.streamFunction = loggingStreamFn;
456
462
  const verification = await RunVerification.open(workspaceDir);
@@ -1,4 +1,5 @@
1
1
  import type { AgentTool } from '@earendil-works/pi-agent-core';
2
+ import type { Config } from '../../config/schema.js';
2
3
  import type { ExternalToolTurnContext } from './types.js';
3
4
  import { type ExternalToolProvider } from './types.js';
4
5
  export declare const EXTERNAL_TOOL_NAMES: {
@@ -8,4 +9,4 @@ export declare const EXTERNAL_TOOL_NAMES: {
8
9
  readonly requireConnection: "xopc_require_connection";
9
10
  readonly updateConnectionObjective: "xopc_update_connection_objective";
10
11
  };
11
- export declare function createExternalToolGatewayTools(providers: ExternalToolProvider[], getContext?: () => ExternalToolTurnContext | null): AgentTool[];
12
+ export declare function createExternalToolGatewayTools(providers: ExternalToolProvider[], getContext?: () => ExternalToolTurnContext | null, getConfig?: () => Config | undefined): AgentTool[];
@@ -1,6 +1,7 @@
1
1
  import { init_connector_repository, listConnectorConnections } from "../../storage/sqlite/connector-repository.js";
2
2
  import { connectionBindings, getActiveConnectionWait, init_connection_wait_repository, publishConnectionWait, requireSessionConnection, reviseCurrentConnectionObjective } from "../../storage/sqlite/connection-wait-repository.js";
3
3
  import { connectorPrincipalForSession } from "../../connectors/principal.js";
4
+ import { getStoreConnectorInstallPlan, parseStoreConnectorCandidateRef, searchStoreConnectorInstallCandidates } from "../../capabilities/store-connector.js";
4
5
  import { connectionCandidates, resolveConnectionCandidate } from "../../connectors/connection-candidates.js";
5
6
  import { parsePluginMcpCandidateRef, resolvePluginMcpConnectionCandidate } from "../../extensions/agent-plugins/connection.js";
6
7
  import { ExternalToolService } from "./service.js";
@@ -48,21 +49,31 @@ function textResult(value, details = {}) {
48
49
  details
49
50
  };
50
51
  }
51
- function createExternalToolGatewayTools(providers, getContext) {
52
+ function createExternalToolGatewayTools(providers, getContext, getConfig) {
52
53
  const service = new ExternalToolService(providers);
53
54
  const searchTool = {
54
55
  name: EXTERNAL_TOOL_NAMES.search,
55
56
  label: "🔎 External Tool Search",
56
- description: `Search external tools from these sources: ${EXTERNAL_TOOL_SOURCES.join(", ")}. CLI connectors include Feishu/Lark, WeCom and WPS 365. Omit sources unless intentionally restricting the search; do not guess a source list. Use concise English capability keywords, e.g. "wecom doc.search". Returns compact references only; call xopc_tool_describe before execution. If a source-filtered search finds no relevant tools, retry without sources before concluding a capability is unavailable or requesting a connection.`,
57
+ description: `Search external tools from these sources: ${EXTERNAL_TOOL_SOURCES.join(", ")}. CLI connectors include Feishu/Lark, WeCom and WPS 365. Omit sources unless intentionally restricting the search; do not guess a source list. Use concise English capability keywords, e.g. "wecom doc.search". Returns executable tools, connection candidates, or reviewed Store install candidates. Call xopc_tool_describe before executing a tool. If a source-filtered search finds no relevant tools, retry without sources before concluding a capability is unavailable.`,
57
58
  parameters: ToolSearchSchema,
58
59
  async execute(_toolCallId, params) {
59
60
  const selectedSources = new Set(params.sources ?? []);
60
61
  const excludedSources = selectedSources.size ? EXTERNAL_TOOL_SOURCES.filter((source) => !selectedSources.has(source)) : [];
61
62
  const result = await service.search(params);
62
63
  const candidates = [...result.connectionCandidates, ...connectionCandidates(params.query)].filter((candidate, index, all) => all.findIndex((item) => item.candidateRef === candidate.candidateRef) === index);
64
+ let installCandidates = [];
65
+ let installCatalogError;
66
+ const config = getConfig?.();
67
+ if (!params.sources?.length && result.tools.length === 0 && candidates.length === 0 && config) try {
68
+ installCandidates = await searchStoreConnectorInstallCandidates(config, params.query, params.limit ?? 5);
69
+ } catch (error) {
70
+ installCatalogError = error instanceof Error ? error.message : String(error);
71
+ }
63
72
  return textResult({
64
73
  ...result,
65
74
  connectionCandidates: candidates,
75
+ installCandidates,
76
+ ...installCatalogError ? { installCatalogError } : {},
66
77
  ...excludedSources.length ? { searchScope: {
67
78
  excludedSources,
68
79
  instruction: "This search excluded these sources. Results from other apps do not establish that the requested app is unavailable. Retry without sources before declaring a capability unavailable or requesting authorization. Feishu/Lark, WeCom and WPS 365 connectors use cli."
@@ -140,7 +151,7 @@ function createExternalToolGatewayTools(providers, getContext) {
140
151
  name: EXTERNAL_TOOL_NAMES.requireConnection,
141
152
  label: "Connect app",
142
153
  parameters: requireSchema,
143
- description: "Request the connections returned as connectionCandidates by xopc_tool_search. Explain the need once before calling. This pauses the current objective and displays one action area above the input. Never return OAuth URLs or repeat a skipped request. If another objective is waiting, ask the user to continue or cancel it first.",
154
+ description: "Request a connectionCandidates or installCandidates entry returned by xopc_tool_search. Explain the need once before calling. This pauses the current objective and displays one action area above the input. Never invent a candidate reference, return OAuth URLs, or repeat a skipped request. If another objective is waiting, ask the user to continue or cancel it first.",
144
155
  async execute(_id, params) {
145
156
  const context = getContext?.();
146
157
  if (!context) throw new Error("No active conversation.");
@@ -152,10 +163,15 @@ function createExternalToolGatewayTools(providers, getContext) {
152
163
  const selected = connectionBindings(context.conversationId);
153
164
  if (params.requirements.every((item) => {
154
165
  const pluginTarget = parsePluginMcpCandidateRef(item.candidateRef);
155
- return selected.some((need) => need.target.type === "connector" ? need.target.connectorId === item.candidateRef && Boolean(need.connectionId) && (!item.accountId || item.accountId === need.accountId) && (!item.accountSelector || item.accountSelector === need.accountSelector) && listConnectorConnections({
156
- principalId: principal.principalId,
157
- connectorId: need.target.connectorId
158
- }).some((connection) => connection.id === need.connectionId && connection.status === "active") : Boolean(pluginTarget && need.target.pluginId === pluginTarget.pluginId && need.target.serverName === pluginTarget.serverName && need.connectionId === need.target.serverId));
166
+ return selected.some((need) => {
167
+ if (need.target.type === "connector") return need.target.connectorId === item.candidateRef && Boolean(need.connectionId) && (!item.accountId || item.accountId === need.accountId) && (!item.accountSelector || item.accountSelector === need.accountSelector) && listConnectorConnections({
168
+ principalId: principal.principalId,
169
+ connectorId: need.target.connectorId
170
+ }).some((connection) => connection.id === need.connectionId && connection.status === "active");
171
+ if (need.target.type === "plugin-mcp") return Boolean(pluginTarget && need.target.pluginId === pluginTarget.pluginId && need.target.serverName === pluginTarget.serverName && need.connectionId === need.target.serverId);
172
+ const storeTarget = parseStoreConnectorCandidateRef(item.candidateRef);
173
+ return Boolean(storeTarget && need.target.packageName === storeTarget.packageName && need.target.version === storeTarget.version && need.connectionId);
174
+ });
159
175
  })) return textResult({
160
176
  status: "already_connected",
161
177
  selectedConnections: selected,
@@ -167,9 +183,26 @@ function createExternalToolGatewayTools(providers, getContext) {
167
183
  agentId: principal.agentId ?? "main",
168
184
  summary: params.purpose,
169
185
  checkpoint: params.checkpoint,
170
- needs: params.requirements.map((item) => {
171
- const need = resolvePluginMcpConnectionCandidate(item.candidateRef) ?? resolveConnectionCandidate(item.candidateRef);
172
- if (item.accountId && need.target.type !== "connector") throw new Error("Plugin MCP connections do not support account selection.");
186
+ needs: await Promise.all(params.requirements.map(async (item) => {
187
+ const storeRef = parseStoreConnectorCandidateRef(item.candidateRef);
188
+ const config = getConfig?.();
189
+ const plan = storeRef && config ? await getStoreConnectorInstallPlan(config, storeRef.packageName, storeRef.version) : void 0;
190
+ if (plan && !plan.definition.provenance) throw new Error("Store Connector provenance is unavailable.");
191
+ const need = plan ? {
192
+ key: item.candidateRef,
193
+ target: {
194
+ type: "store-connector",
195
+ packageName: plan.packageName,
196
+ connectorId: plan.definition.id,
197
+ version: plan.version,
198
+ sha256: plan.definition.provenance.sha256,
199
+ reviewHash: plan.reviewHash,
200
+ description: plan.definition.description
201
+ },
202
+ label: plan.definition.displayName,
203
+ capabilities: plan.definition.capabilities
204
+ } : resolvePluginMcpConnectionCandidate(item.candidateRef) ?? resolveConnectionCandidate(item.candidateRef);
205
+ if (item.accountId && need.target.type !== "connector") throw new Error("This install candidate does not support account selection.");
173
206
  if (item.accountId && need.target.type === "connector" && !listConnectorConnections({
174
207
  principalId: principal.principalId,
175
208
  connectorId: need.target.connectorId
@@ -180,7 +213,7 @@ function createExternalToolGatewayTools(providers, getContext) {
180
213
  accountSelector: item.accountSelector,
181
214
  key: need.target.type === "connector" ? `${need.target.connectorId}:${item.accountId ?? item.accountSelector ?? "default"}` : need.key
182
215
  };
183
- })
216
+ }))
184
217
  });
185
218
  publishConnectionWait(context.conversationId);
186
219
  return textResult(result);
@@ -53,7 +53,7 @@ function createDefaultExternalToolGatewayTools(deps) {
53
53
  if (!deps.getConfig()) return void 0;
54
54
  const conversationId = deps.getCurrentContext()?.conversationId;
55
55
  return (conversationId ? resolveEffectiveAgentConfigForSession(conversationId) : deps.agentId ? resolveEffectiveAgentConfigForAgent(deps.agentId) : resolveEffectiveAgentConfigForSession(void 0)).config.tools[toolRef];
56
- })), deps.getCurrentContext);
56
+ })), deps.getCurrentContext, deps.getConfig);
57
57
  }
58
58
  //#endregion
59
59
  export { EXTERNAL_TOOL_NAMES, ExternalToolService, createDefaultExternalToolGatewayTools };
@@ -50,7 +50,7 @@ function buildPiAiImageUnderstandingProvider(providerId) {
50
50
  setTimeout(() => controller.abort(), timeoutMs);
51
51
  return controller.signal;
52
52
  })()
53
- }),
53
+ }, void 0, { operation: "media.understand_image" }),
54
54
  provider: providerId,
55
55
  model: modelId
56
56
  }),
@@ -518,6 +518,10 @@ Return a JSON delta containing only missing facts, using {"upserts":[]}. Include
518
518
  onPayload: compactionPayloadGuard(requestedMaxTokens, (actual) => {
519
519
  actualMaxTokens = actual;
520
520
  })
521
+ }, void 0, {
522
+ operation: "session.compact",
523
+ conversationId: callContext.conversationId,
524
+ trigger: attempt === 0 && modelIndex === 0 ? "system" : "retry"
521
525
  });
522
526
  parentSignal?.throwIfAborted();
523
527
  if (linked.timedOut()) throw new CompactionRequestError("timeout", "Compaction handover timed out");
@@ -108,7 +108,10 @@ async function runBtwQuery(opts) {
108
108
  };
109
109
  let streamedText = "";
110
110
  const response = opts.onTextDelta ? await (async () => {
111
- const stream = await createResolvedModelStream(model, { messages: [userMessage] }, modelCallOptions, opts.credentialOptions);
111
+ const stream = await createResolvedModelStream(model, { messages: [userMessage] }, modelCallOptions, opts.credentialOptions, {
112
+ operation: "agent.answer",
113
+ conversationId: opts.conversationId
114
+ });
112
115
  for await (const event of stream) {
113
116
  const streamEvent = event;
114
117
  if (streamEvent.type === "text_delta" && typeof streamEvent.delta === "string") {
@@ -123,7 +126,10 @@ async function runBtwQuery(opts) {
123
126
  }
124
127
  }
125
128
  return await stream.result();
126
- })() : await completeWithResolvedCredentials(model, { messages: [userMessage] }, modelCallOptions, opts.credentialOptions);
129
+ })() : await completeWithResolvedCredentials(model, { messages: [userMessage] }, modelCallOptions, opts.credentialOptions, {
130
+ operation: "agent.answer",
131
+ conversationId: opts.conversationId
132
+ });
127
133
  const text = (streamedText || textFromCompleteContent(response.content)).trim();
128
134
  if (text) return { text };
129
135
  const stopReason = typeof response.stopReason === "string" ? response.stopReason : void 0;
@@ -11,9 +11,9 @@ import { extractTextContent } from "./context/workspace.js";
11
11
  import { effectiveWorkspacePathForSession } from "../session/session-workspace.js";
12
12
  import { getProjectForSession } from "../projects/workspace.js";
13
13
  import { runWithEmbeddedExecutionSession } from "./embedded/execution-context.js";
14
- import { resolveWorkspaceSkillsDir, resolveWorkspaceSkillsLockPath } from "./skills/workspace-skills-dir.js";
15
14
  import { removeSkillsLockEntry } from "./skills/hub-lock.js";
16
15
  import { installSkillFromZip } from "./skills/managed-store.js";
16
+ import { resolveWorkspaceSkillsDir, resolveWorkspaceSkillsLockPath } from "./skills/workspace-skills-dir.js";
17
17
  import { pullSkillFromSource } from "./skills/hub-pull.js";
18
18
  import { getUserTimezone } from "../user-model/repository.js";
19
19
  import "../user-model/index.js";
@@ -2,10 +2,10 @@ import { resolveStateDir } from "../../config/paths-state.js";
2
2
  import { createLogger } from "../../utils/logger/index.js";
3
3
  import { init_logger } from "../../utils/logger.js";
4
4
  import { init_paths, resolveSkillsDir } from "../../config/paths.js";
5
+ import { isManagedSkillTransientDirName } from "./managed-store.js";
5
6
  import { createSkillConfigManager } from "./config.js";
6
7
  import { resolveWorkspaceSkillsDir } from "./workspace-skills-dir.js";
7
8
  import { resolveAgentsSkillsDir, resolveWorkspaceAgentsSkillsDir } from "./skill-sources.js";
8
- import { isManagedSkillTransientDirName } from "./managed-store.js";
9
9
  import path from "node:path";
10
10
  import chokidar from "chokidar";
11
11
  //#region src/agent/skills/filesystem-watcher.ts
@@ -1,8 +1,8 @@
1
1
  import { parseFrontmatter } from "../../markdown/frontmatter.js";
2
- import { formatScanSummary, scanSkillDirectory } from "./scanner.js";
3
- import { computeSkillTreeHashSync } from "./hub-hash.js";
4
2
  import { getSkillsLockEntry, recordSkillsHubInstall } from "./hub-lock.js";
5
3
  import { installSkillFromZip, isIgnorableZipEntry, isValidSkillId, prepareManagedSkillTempDir, promoteManagedSkillTempDir } from "./managed-store.js";
4
+ import { formatScanSummary, scanSkillDirectory } from "./scanner.js";
5
+ import { computeSkillTreeHashSync } from "./hub-hash.js";
6
6
  import { tmpdir } from "node:os";
7
7
  import { basename, dirname, join, normalize, resolve, sep } from "node:path";
8
8
  import { cpSync, existsSync, mkdirSync, mkdtempSync, readFileSync, readdirSync, rmSync, statSync, writeFileSync } from "node:fs";
@@ -1,6 +1,6 @@
1
+ import { downloadSkillZipBuffer, fetchMarketplacePackageDetail, listSkillCategories, listSkillPackages, resolveSkillZipDownloadUrl, resolveSkillsStoreBaseUrl, skillIdForMarketplaceInstall, verifyStoreArtifactSha256 } from "./store-api-client.js";
1
2
  import { registerMarketplaceAdapter } from "../../registry.js";
2
3
  import { buildSkillMarkdownPreviewFromRaw } from "../../../skill-markdown-preview-from-raw.js";
3
- import { downloadSkillZipBuffer, fetchMarketplacePackageDetail, listSkillCategories, listSkillPackages, resolveSkillZipDownloadUrl, resolveSkillsStoreBaseUrl, skillIdForMarketplaceInstall, verifyStoreArtifactSha256 } from "./store-api-client.js";
4
4
  //#region src/agent/skills/marketplace/adapters/store/adapter.ts
5
5
  const storeMarketplaceAdapter = {
6
6
  id: "store",
@@ -1,6 +1,6 @@
1
1
  import { init_resolution, resolveConnectedPlatformEndpoint } from "../../../../../platform/resolution.js";
2
- import { MAX_SKILL_ZIP_BYTES, isValidSkillId } from "../../../managed-store.js";
3
2
  import { MAX_EXTENSION_STORE_ZIP_BYTES } from "../../../../../extensions/store-zip-limits.js";
3
+ import { MAX_SKILL_ZIP_BYTES, isValidSkillId } from "../../../managed-store.js";
4
4
  import { createHash } from "node:crypto";
5
5
  //#region src/agent/skills/marketplace/adapters/store/store-api-client.ts
6
6
  /**
@@ -136,6 +136,10 @@ var TaskJudgeService = class {
136
136
  apiKey,
137
137
  maxTokens: 900,
138
138
  temperature: 0
139
+ }, void 0, {
140
+ operation: "task.judge_result",
141
+ conversationId: payload.conversationId,
142
+ runId: run.id
139
143
  });
140
144
  const modelError = getAssistantMessageErrorReason(response);
141
145
  if (modelError) throw new Error(modelError);