@xopcai/xopc 0.0.312 → 0.0.314

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 (497) hide show
  1. package/dist/browser-ext/dist/assets/{auth-C3yV1y_l.js → auth-DKo-NMUY.js} +18 -1
  2. package/dist/browser-ext/dist/background.js +68 -2
  3. package/dist/browser-ext/dist/sidepanel.html +1 -1
  4. package/dist/browser-ext/dist/sidepanel.js +1 -1
  5. package/dist/browser-ext/manifest.json +1 -1
  6. package/dist/extensions/feishu/src/outbound/media-load.js +1 -1
  7. package/dist/extensions/telegram/src/inbound-processor.js +1 -1
  8. package/dist/extensions/telegram/src/plugin.js +2 -2
  9. package/dist/extensions/telegram/xopc.extension.json +1 -1
  10. package/dist/gateway/static/root/assets/{agent-avatar-dicebear-BVIJMP8w.js → agent-avatar-dicebear-BFkjfurL.js} +1 -1
  11. package/dist/gateway/static/root/assets/agent-defaults-settings-panel-BdOZ6q8Z.js +1 -0
  12. package/dist/gateway/static/root/assets/{agents-D6g_SeWI.js → agents-CCcavsHq.js} +1 -1
  13. package/dist/gateway/static/root/assets/{api-_aHQA8bd.js → api-BYhRsTAc.js} +1 -1
  14. package/dist/gateway/static/root/assets/{app-link-CKueEVbT.js → app-link-nL8iPwEr.js} +1 -1
  15. package/dist/gateway/static/root/assets/{app-management-settings-panel-CLg_aXYG.js → app-management-settings-panel-B4kihr-A.js} +1 -1
  16. package/dist/gateway/static/root/assets/appearance-settings-N9sYmNOx.js +1 -0
  17. package/dist/gateway/static/root/assets/apps-page-BMcy10_s.js +1 -0
  18. package/dist/gateway/static/root/assets/{archive-plugin-CHO3heHX.js → archive-plugin-k_SuYWyV.js} +1 -1
  19. package/dist/gateway/static/root/assets/{attachment-load-BsmsBCI2.js → attachment-load-DRv5QWUK.js} +1 -1
  20. package/dist/gateway/static/root/assets/{automations-page-CftigJlf.js → automations-page-CkJV3DN0.js} +1 -1
  21. package/dist/gateway/static/root/assets/automations-workspace-BEa2doeR.js +7 -0
  22. package/dist/gateway/static/root/assets/{binary-plugins-CRCLWBo2.js → binary-plugins-Dg3h3TA7.js} +1 -1
  23. package/dist/gateway/static/root/assets/{block-editor-D0LDiOTT.js → block-editor-DVhdHntT.js} +29 -29
  24. package/dist/gateway/static/root/assets/{browser-automation-inputs-C611KRBx.js → browser-automation-inputs-BMRYUW8_.js} +1 -1
  25. package/dist/gateway/static/root/assets/{browser-automations-page-Djyv3vy-.js → browser-automations-page-Byv6-FY2.js} +2 -2
  26. package/dist/gateway/static/root/assets/browser-settings-page-DRCHGFpO.js +3 -0
  27. package/dist/gateway/static/root/assets/capabilities-D0S3DuAD.js +1 -0
  28. package/dist/gateway/static/root/assets/capabilities-settings-panel-mxRP0gl0.js +8 -0
  29. package/dist/gateway/static/root/assets/channels-settings-DBt_6GsB.js +1 -0
  30. package/dist/gateway/static/root/assets/{chat-terminal-dock-CIsKqdET.js → chat-terminal-dock-D4AHa51o.js} +2 -2
  31. package/dist/gateway/static/root/assets/{computer-settings-page-C0YL9J7m.js → computer-settings-page-eXPe500D.js} +1 -1
  32. package/dist/gateway/static/root/assets/connector-service-page-BQTFlq_k.js +1 -0
  33. package/dist/gateway/static/root/assets/connectors-page-BKeBWwcI.js +2 -0
  34. package/dist/gateway/static/root/assets/conversation-identity-Cw0n9uzK.js +1 -0
  35. package/dist/gateway/static/root/assets/{date-picker-CDsfv8R0.js → date-picker-7MtovynY.js} +1 -1
  36. package/dist/gateway/static/root/assets/{dependency-picker-DvhPj3CZ.js → dependency-picker-Bj_xkXID.js} +1 -1
  37. package/dist/gateway/static/root/assets/{desktop-pet-Cyg8XMpL.js → desktop-pet-CTmba9zH.js} +1 -1
  38. package/dist/gateway/static/root/assets/desktop-pet-settings-DNM_BlWN.js +1 -0
  39. package/dist/gateway/static/root/assets/device-pairing-wizard-C2XE0QhT.js +1 -0
  40. package/dist/gateway/static/root/assets/{extension-debug-page-D-AVJU3q.js → extension-debug-page-J_olaL7e.js} +1 -1
  41. package/dist/gateway/static/root/assets/{extension-page-DrFoQ9xt.js → extension-page-pK5RvqN8.js} +1 -1
  42. package/dist/gateway/static/root/assets/{extension-settings-page-DxWjESC1.js → extension-settings-page-BwroEN08.js} +1 -1
  43. package/dist/gateway/static/root/assets/files-BK6enEvD.js +1 -0
  44. package/dist/gateway/static/root/assets/{gateway-config-swr-DUDX42qY.js → gateway-config-swr-FuJTIg_a.js} +1 -1
  45. package/dist/gateway/static/root/assets/gateway-settings-CLLDp23J.js +1 -0
  46. package/dist/gateway/static/root/assets/{gateway-startup-retry-Cf8OxlvY.js → gateway-startup-retry-CKg_gu8_.js} +1 -1
  47. package/dist/gateway/static/root/assets/home-page-B5Epb1PH.js +1 -0
  48. package/dist/gateway/static/root/assets/{image-generation-api-D2YorS--.js → image-generation-api-Bo6NZ7zb.js} +1 -1
  49. package/dist/gateway/static/root/assets/{imports-page-BKucJlXI.js → imports-page-C8-hX8gS.js} +1 -1
  50. package/dist/gateway/static/root/assets/index-14F1yGJI.js +89 -0
  51. package/dist/gateway/static/root/assets/index-cB7rWIDY.css +1 -0
  52. package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-BxLXD-yU.js → keyboard-shortcuts-settings-BkBEjUZD.js} +1 -1
  53. package/dist/gateway/static/root/assets/local-app-workbench-page-6jC3vQpY.js +2 -0
  54. package/dist/gateway/static/root/assets/{local-apps-page-BAsQJQKJ.js → local-apps-page-CrbKIixo.js} +1 -1
  55. package/dist/gateway/static/root/assets/{locale-store-DA0Z5jM_.js → locale-store-CvGwNbml.js} +1 -1
  56. package/dist/gateway/static/root/assets/logs-page-DBHlZts9.js +2 -0
  57. package/dist/gateway/static/root/assets/management-settings-DsUWLu5m.js +1 -0
  58. package/dist/gateway/static/root/assets/{markdown-view-DYGPxPee.js → markdown-view-nXo5nrsv.js} +1 -1
  59. package/dist/gateway/static/root/assets/{media-plugins-CQtQzLyg.js → media-plugins-upxXJ-4l.js} +1 -1
  60. package/dist/gateway/static/root/assets/messages-B_AwRroN.js +3 -0
  61. package/dist/gateway/static/root/assets/note-detail-panel-0Q9TOtJG.js +5 -0
  62. package/dist/gateway/static/root/assets/notes-page-D0NmcwNw.js +8 -0
  63. package/dist/gateway/static/root/assets/page-context-capture-button-DUyA-K4L.js +1 -0
  64. package/dist/gateway/static/root/assets/{page-tabs-B6DjkyMM.js → page-tabs-Cl-NFPNr.js} +1 -1
  65. package/dist/gateway/static/root/assets/{preview-open-alternatives-Dn57uLhr.js → preview-open-alternatives-DX81PwJ3.js} +1 -1
  66. package/dist/gateway/static/root/assets/product-delivery-chCjIpvu.js +1 -0
  67. package/dist/gateway/static/root/assets/{product-open-page-H2YMk8TY.js → product-open-page-CrfIGwm8.js} +1 -1
  68. package/dist/gateway/static/root/assets/project-detail-page-BVfVrYmn.js +1 -0
  69. package/dist/gateway/static/root/assets/projects-page-nM9a9XNS.js +1 -0
  70. package/dist/gateway/static/root/assets/{registry-api-C0DCx3wv.js → registry-api-CHxgohY0.js} +1 -1
  71. package/dist/gateway/static/root/assets/remote-access-hub-C8b_k88G.js +1 -0
  72. package/dist/gateway/static/root/assets/runtime-tools-settings-panel-D3dLOW04.js +5 -0
  73. package/dist/gateway/static/root/assets/scenes-page-DEowreZV.js +2 -0
  74. package/dist/gateway/static/root/assets/{schema-form-CblI9WUA.js → schema-form-ZxuIvD2_.js} +1 -1
  75. package/dist/gateway/static/root/assets/schemas-88fK3zzl.js +64 -0
  76. package/dist/gateway/static/root/assets/sessions-page-B_nPhera.js +1 -0
  77. package/dist/gateway/static/root/assets/settings-advanced-gate-BqhIOuus.js +1 -0
  78. package/dist/gateway/static/root/assets/{settings-form-section-BAaVyxJH.js → settings-form-section-TZRfg4yo.js} +1 -1
  79. package/dist/gateway/static/root/assets/{settings-page-CKNPbm5q.js → settings-page-a8qcJpdZ.js} +1 -1
  80. package/dist/gateway/static/root/assets/{settings-page-layout-DqNCGKxQ.js → settings-page-layout-BfvlRT9q.js} +1 -1
  81. package/dist/gateway/static/root/assets/setup-status-panel-CRj5Ruqn.js +1 -0
  82. package/dist/gateway/static/root/assets/{share-preview-page-BzMfp_HM.js → share-preview-page-DCt1pTWB.js} +1 -1
  83. package/dist/gateway/static/root/assets/shares-settings-BNbXPk--.js +1 -0
  84. package/dist/gateway/static/root/assets/skill-reload-api-CNMCLbav.js +1 -0
  85. package/dist/gateway/static/root/assets/{skills-page-DIht92q6.js → skills-page-BIOcg44X.js} +1 -1
  86. package/dist/gateway/static/root/assets/{skills-page.utils-DLYRiEn3.js → skills-page.utils-CgZdzT4I.js} +1 -1
  87. package/dist/gateway/static/root/assets/{system-settings-panel-yYs4YgYk.js → system-settings-panel-_YaRncA6.js} +1 -1
  88. package/dist/gateway/static/root/assets/task-detail-page-CAcfAG-c.js +1 -0
  89. package/dist/gateway/static/root/assets/tasks-CDR_RVbQ.js +1 -0
  90. package/dist/gateway/static/root/assets/{tunnel-api-BasDYxvx.js → tunnel-api-uOupJOoS.js} +1 -1
  91. package/dist/gateway/static/root/assets/turn-outcome-D0SnyZ3Z.js +1 -0
  92. package/dist/gateway/static/root/assets/{use-autosave-CWAUHhcb.js → use-autosave-BezzHBLE.js} +1 -1
  93. package/dist/gateway/static/root/assets/user-model-page-BFFeneDq.js +2 -0
  94. package/dist/gateway/static/root/assets/{voice-api-key-field-Kc4UlxZs.js → voice-api-key-field-BmYifdwL.js} +1 -1
  95. package/dist/gateway/static/root/assets/{voice-config-api-DTyMdGOR.js → voice-config-api-D_5Q2_A3.js} +1 -1
  96. package/dist/gateway/static/root/assets/{work-discovery-overlay-BPC_c9dO.js → work-discovery-overlay-4DmyEckJ.js} +1 -1
  97. package/dist/gateway/static/root/assets/{workflow-run-setup-panel-DBTciOrq.js → workflow-run-setup-panel-DeZe8bTZ.js} +2 -2
  98. package/dist/gateway/static/root/assets/workflows-page-Sv4hEc6W.js +6 -0
  99. package/dist/gateway/static/root/index.html +16 -16
  100. package/dist/package.js +1 -1
  101. package/dist/packages/computer-control-contract/src/index.js +10 -1
  102. package/dist/packages/gateway-contract/src/app-context.js +55 -0
  103. package/dist/packages/gateway-contract/src/automations.js +16 -17
  104. package/dist/packages/gateway-contract/src/capabilities.js +1078 -0
  105. package/dist/packages/gateway-contract/src/extension-capabilities.js +26 -0
  106. package/dist/packages/gateway-contract/src/home.js +3 -3
  107. package/dist/packages/gateway-contract/src/index.js +8 -0
  108. package/dist/packages/gateway-contract/src/product-delivery.js +19 -4
  109. package/dist/packages/gateway-contract/src/scenes.js +199 -0
  110. package/dist/packages/gateway-contract/src/task-runs.js +8 -4
  111. package/dist/packages/gateway-contract/src/tasks.js +5 -4
  112. package/dist/packages/realtime-client/src/index.js +17 -4
  113. package/dist/src/agent/agent-manager.d.ts +1 -0
  114. package/dist/src/agent/agent-manager.js +1 -0
  115. package/dist/src/agent/child-agent-factory.d.ts +2 -0
  116. package/dist/src/agent/child-agent-factory.js +5 -0
  117. package/dist/src/agent/commands/approved-verification.d.ts +14 -0
  118. package/dist/src/agent/commands/approved-verification.js +48 -0
  119. package/dist/src/agent/context/execution-scope.js +2 -1
  120. package/dist/src/agent/context/project-context.js +2 -1
  121. package/dist/src/agent/external-tools/cliProvider.js +123 -75
  122. package/dist/src/agent/external-tools/composio-provider.d.ts +1 -1
  123. package/dist/src/agent/external-tools/composio-provider.js +70 -12
  124. package/dist/src/agent/external-tools/endpoint-provider.js +14 -1
  125. package/dist/src/agent/inbound/turn-dispatcher.d.ts +2 -0
  126. package/dist/src/agent/inbound/turn-dispatcher.js +2 -1
  127. package/dist/src/agent/memory/compaction-chunks.d.ts +6 -1
  128. package/dist/src/agent/memory/compaction-chunks.js +16 -3
  129. package/dist/src/agent/memory/compaction-ledger.d.ts +3 -1
  130. package/dist/src/agent/memory/compaction-ledger.js +31 -18
  131. package/dist/src/agent/memory/compaction-request.d.ts +2 -0
  132. package/dist/src/agent/memory/compaction-request.js +6 -1
  133. package/dist/src/agent/memory/compaction.d.ts +19 -1
  134. package/dist/src/agent/memory/compaction.js +112 -30
  135. package/dist/src/agent/service/process-direct-streaming.d.ts +3 -0
  136. package/dist/src/agent/service/process-direct-streaming.js +19 -10
  137. package/dist/src/agent/service.js +1 -0
  138. package/dist/src/agent/service.types.d.ts +1 -0
  139. package/dist/src/agent/skills/config.js +2 -0
  140. package/dist/src/agent/skills/format-skills-prompt.js +14 -1
  141. package/dist/src/agent/skills/index.js +16 -8
  142. package/dist/src/agent/skills/types.d.ts +1 -1
  143. package/dist/src/agent/source-context/app-context.d.ts +4 -0
  144. package/dist/src/agent/source-context/app-context.js +36 -0
  145. package/dist/src/agent/source-context/injector.js +1 -0
  146. package/dist/src/agent/source-context/types.d.ts +5 -1
  147. package/dist/src/agent/tasks/task-judge-service.js +2 -1
  148. package/dist/src/agent/tool-manuals/computer.d.ts +1 -1
  149. package/dist/src/agent/tool-manuals/computer.js +1 -1
  150. package/dist/src/agent/tools/automation-tool.d.ts +12 -1
  151. package/dist/src/agent/tools/automation-tool.js +106 -32
  152. package/dist/src/agent/tools/factory.d.ts +1 -0
  153. package/dist/src/agent/tools/factory.js +6 -1
  154. package/dist/src/agent/tools/scoped-workspace-tools.d.ts +8 -0
  155. package/dist/src/agent/tools/scoped-workspace-tools.js +81 -0
  156. package/dist/src/agent/tools/xopc-use-tool.d.ts +6 -3
  157. package/dist/src/agent/tools/xopc-use-tool.js +997 -908
  158. package/dist/src/agent/workflow/subagent-runner.js +1 -0
  159. package/dist/src/agent-config/index.js +2 -2
  160. package/dist/src/agent-config/schema.d.ts +5 -0
  161. package/dist/src/agent-config/schema.js +14 -10
  162. package/dist/src/automations/api/routes.js +244 -164
  163. package/dist/src/automations/capabilities/drafts.d.ts +4 -0
  164. package/dist/src/automations/capabilities/drafts.js +95 -0
  165. package/dist/src/automations/capabilities/read.d.ts +4 -0
  166. package/dist/src/automations/capabilities/read.js +119 -0
  167. package/dist/src/automations/capabilities/write.d.ts +349 -0
  168. package/dist/src/automations/capabilities/write.js +172 -0
  169. package/dist/src/automations/domain/index.js +2 -2
  170. package/dist/src/automations/domain/validation.d.ts +77 -77
  171. package/dist/src/automations/domain/validation.js +9 -6
  172. package/dist/src/automations/draft/automation-draft-validator.d.ts +2 -2
  173. package/dist/src/automations/index.js +6 -6
  174. package/dist/src/automations/service/automation-service.d.ts +31 -0
  175. package/dist/src/automations/service/automation-service.js +213 -75
  176. package/dist/src/automations/service/index.js +2 -2
  177. package/dist/src/automations/storage/automation-repository.d.ts +2 -0
  178. package/dist/src/automations/storage/automation-repository.js +9 -1
  179. package/dist/src/automations/storage/automation-run-repository.d.ts +4 -1
  180. package/dist/src/automations/storage/automation-run-repository.js +16 -3
  181. package/dist/src/automations/storage/index.js +3 -3
  182. package/dist/src/browser/automations/schema.d.ts +1 -1
  183. package/dist/src/browser/automations/service.d.ts +1 -1
  184. package/dist/src/browser/observation/format.js +4 -0
  185. package/dist/src/capabilities/adapters/http.d.ts +4 -0
  186. package/dist/src/capabilities/adapters/http.js +44 -0
  187. package/dist/src/capabilities/readiness/from-config.js +11 -7
  188. package/dist/src/capabilities/runtime/app-context.d.ts +3 -0
  189. package/dist/src/capabilities/runtime/app-context.js +72 -0
  190. package/dist/src/capabilities/runtime/atomic-operations.d.ts +11 -0
  191. package/dist/src/capabilities/runtime/atomic-operations.js +34 -0
  192. package/dist/src/capabilities/runtime/dispatcher.d.ts +67 -0
  193. package/dist/src/capabilities/runtime/dispatcher.js +170 -0
  194. package/dist/src/capabilities/runtime/errors.d.ts +6 -0
  195. package/dist/src/capabilities/runtime/errors.js +11 -0
  196. package/dist/src/capabilities/runtime/external-operations.d.ts +16 -0
  197. package/dist/src/capabilities/runtime/external-operations.js +92 -0
  198. package/dist/src/capabilities/runtime/product.d.ts +12 -0
  199. package/dist/src/capabilities/runtime/product.js +69 -0
  200. package/dist/src/capabilities/runtime/settings.d.ts +3 -0
  201. package/dist/src/capabilities/runtime/settings.js +27 -0
  202. package/dist/src/channels/index.js +2 -2
  203. package/dist/src/channels/manager.js +1 -1
  204. package/dist/src/cli/cli-log-level-preset.d.ts +2 -0
  205. package/dist/src/cli/cli-log-level-preset.js +4 -0
  206. package/dist/src/cli/command-catalog.js +4 -0
  207. package/dist/src/cli/command-loaders.js +1 -0
  208. package/dist/src/cli/command-manifest.js +4 -0
  209. package/dist/src/cli/commands/channels.js +1 -1
  210. package/dist/src/cli/commands/connectors.js +1 -1
  211. package/dist/src/cli/commands/doctor/checks/database-schema.js +1 -1
  212. package/dist/src/cli/commands/extension-marketplace.js +1 -1
  213. package/dist/src/cli/commands/mcp.d.ts +1 -0
  214. package/dist/src/cli/commands/mcp.js +51 -0
  215. package/dist/src/cli/commands/models.js +1 -1
  216. package/dist/src/cli/commands/onboard.js +1 -1
  217. package/dist/src/cli/commands/project.js +1 -1
  218. package/dist/src/computer/broker.d.ts +0 -1
  219. package/dist/src/computer/broker.js +4 -6
  220. package/dist/src/computer/evaluation-harness.d.ts +45 -0
  221. package/dist/src/computer/evaluation-harness.js +108 -0
  222. package/dist/src/computer/model-adapter.d.ts +37 -2
  223. package/dist/src/computer/model-adapter.js +333 -42
  224. package/dist/src/computer/model-policy.d.ts +4 -1
  225. package/dist/src/computer/model-policy.js +11 -3
  226. package/dist/src/computer/release-gate.d.ts +22 -0
  227. package/dist/src/computer/release-gate.js +19 -0
  228. package/dist/src/computer/runtime.js +14 -10
  229. package/dist/src/computer/task-state.d.ts +1 -0
  230. package/dist/src/computer/task-state.js +1 -0
  231. package/dist/src/config/models-json.d.ts +14 -8
  232. package/dist/src/config/models-json.js +1 -1
  233. package/dist/src/config/schema.d.ts +4 -0
  234. package/dist/src/config/schema.js +3 -9
  235. package/dist/src/connectors/composio-sessions.d.ts +4 -2
  236. package/dist/src/connectors/composio-sessions.js +10 -9
  237. package/dist/src/connectors/composio.js +10 -8
  238. package/dist/src/discussions/action-tasks.js +2 -1
  239. package/dist/src/discussions/recording.js +1 -1
  240. package/dist/src/execution-environments/local-worktree-manager.d.ts +1 -0
  241. package/dist/src/execution-environments/local-worktree-manager.js +13 -2
  242. package/dist/src/extensions/activation-context.js +3 -3
  243. package/dist/src/extensions/api.js +1 -1
  244. package/dist/src/extensions/normalize-manifest.js +6 -1
  245. package/dist/src/extensions/sdk/index.js +1 -1
  246. package/dist/src/extensions/sdk/media.js +1 -1
  247. package/dist/src/extensions/types/manifest.d.ts +3 -0
  248. package/dist/src/gateway/agent-builtin-tools.d.ts +1 -1
  249. package/dist/src/gateway/hono/lib/config-payload.d.ts +1 -0
  250. package/dist/src/gateway/hono/middleware/scopes.js +1 -1
  251. package/dist/src/gateway/hono/routes/auth-registry-extensions.js +5 -2
  252. package/dist/src/gateway/hono/routes/capability-operations.d.ts +3 -0
  253. package/dist/src/gateway/hono/routes/capability-operations.js +52 -0
  254. package/dist/src/gateway/hono/routes/lazy-bundles.js +16 -0
  255. package/dist/src/gateway/hono/routes/local-app-capabilities.d.ts +4 -0
  256. package/dist/src/gateway/hono/routes/local-app-capabilities.js +41 -0
  257. package/dist/src/gateway/hono/routes/local-apps.js +41 -9
  258. package/dist/src/gateway/hono/routes/models.js +2 -2
  259. package/dist/src/gateway/hono/routes/notes.js +215 -146
  260. package/dist/src/gateway/hono/routes/projects.js +217 -374
  261. package/dist/src/gateway/hono/routes/scenes.js +188 -75
  262. package/dist/src/gateway/hono/routes/session-input-handler.d.ts +60 -16
  263. package/dist/src/gateway/hono/routes/session-input-handler.js +43 -1
  264. package/dist/src/gateway/hono/routes/sessions.js +17 -0
  265. package/dist/src/gateway/hono/routes/status.js +1 -1
  266. package/dist/src/gateway/hono/routes/tasks.js +182 -326
  267. package/dist/src/gateway/hono/routes/user-model-refresh.js +1 -1
  268. package/dist/src/gateway/hono/routes/voice.js +4 -4
  269. package/dist/src/gateway/hono/routes/workflows.js +1 -1
  270. package/dist/src/gateway/media-access.js +2 -1
  271. package/dist/src/gateway/mobile-privacy.js +2 -2
  272. package/dist/src/gateway/scenes/host.js +14 -3
  273. package/dist/src/gateway/scenes/mailContext.js +1 -1
  274. package/dist/src/gateway/scenes/slackThreadSource.d.ts +41 -0
  275. package/dist/src/gateway/scenes/slackThreadSource.js +168 -0
  276. package/dist/src/gateway/security/gateway-scopes.d.ts +1 -1
  277. package/dist/src/gateway/security/gateway-scopes.js +5 -0
  278. package/dist/src/gateway/service/app-context-access.d.ts +11 -0
  279. package/dist/src/gateway/service/app-context-access.js +70 -0
  280. package/dist/src/gateway/service/run-gateway-agent.js +11 -2
  281. package/dist/src/gateway/service/session-input-coordinator.js +54 -15
  282. package/dist/src/gateway/service/sessions-api.d.ts +1 -0
  283. package/dist/src/gateway/service/sessions-api.js +3 -0
  284. package/dist/src/gateway/service/task-conversation-query-service.d.ts +3 -1
  285. package/dist/src/gateway/service/task-conversation-query-service.js +32 -3
  286. package/dist/src/gateway/service.d.ts +3 -0
  287. package/dist/src/gateway/service.js +69 -15
  288. package/dist/src/gateway/session-context-summary.js +2 -1
  289. package/dist/src/{tasks/task-outbox-dispatcher.d.ts → infra/domain-outbox-dispatcher.d.ts} +2 -2
  290. package/dist/src/{tasks/task-outbox-dispatcher.js → infra/domain-outbox-dispatcher.js} +10 -9
  291. package/dist/src/infra/operation-context.d.ts +2 -0
  292. package/dist/src/infra/operation-context.js +16 -0
  293. package/dist/src/local-apps/capabilities/contracts.d.ts +2 -0
  294. package/dist/src/local-apps/capabilities/contracts.js +32 -0
  295. package/dist/src/local-apps/capabilities/read.d.ts +3 -0
  296. package/dist/src/local-apps/capabilities/read.js +48 -0
  297. package/dist/src/local-apps/capabilities/runtime.d.ts +16 -0
  298. package/dist/src/local-apps/capabilities/runtime.js +66 -0
  299. package/dist/src/local-apps/capabilities/write.d.ts +3 -0
  300. package/dist/src/local-apps/capabilities/write.js +35 -0
  301. package/dist/src/local-apps/release-lock.d.ts +2 -0
  302. package/dist/src/local-apps/release-lock.js +20 -0
  303. package/dist/src/local-apps/runtime-entry.d.ts +0 -2
  304. package/dist/src/local-apps/runtime-entry.js +1 -14
  305. package/dist/src/local-apps/scaffold.js +4 -1
  306. package/dist/src/local-apps/service.d.ts +24 -1
  307. package/dist/src/local-apps/service.js +186 -43
  308. package/dist/src/local-apps/store.js +0 -2
  309. package/dist/src/mcp/capability-server.d.ts +4 -0
  310. package/dist/src/mcp/capability-server.js +96 -0
  311. package/dist/src/mcp/channel-bridge.js +1 -1
  312. package/dist/src/mcp/gateway-http-client.d.ts +7 -0
  313. package/dist/src/mcp/gateway-http-client.js +27 -5
  314. package/dist/src/media-understanding/openai-compatible-audio.js +1 -1
  315. package/dist/src/notes/agent-context.js +1 -1
  316. package/dist/src/notes/capabilities/read.d.ts +3 -0
  317. package/dist/src/notes/capabilities/read.js +96 -0
  318. package/dist/src/notes/capabilities/write.d.ts +7 -0
  319. package/dist/src/notes/capabilities/write.js +152 -0
  320. package/dist/src/notes/index.js +1 -1
  321. package/dist/src/notes/service.d.ts +12 -4
  322. package/dist/src/notes/service.js +188 -175
  323. package/dist/src/notes/store.d.ts +14 -9
  324. package/dist/src/notes/store.js +81 -21
  325. package/dist/src/notifications/service.d.ts +1 -0
  326. package/dist/src/notifications/service.js +5 -0
  327. package/dist/src/platform/client.d.ts +1 -1
  328. package/dist/src/platform/contracts.d.ts +1 -1
  329. package/dist/src/projects/capabilities/read.d.ts +3 -0
  330. package/dist/src/projects/capabilities/read.js +81 -0
  331. package/dist/src/projects/capabilities/write.d.ts +9 -0
  332. package/dist/src/projects/capabilities/write.js +260 -0
  333. package/dist/src/projects/index.js +2 -2
  334. package/dist/src/projects/project-change-events.d.ts +2 -0
  335. package/dist/src/projects/project-change-events.js +18 -0
  336. package/dist/src/projects/project-service.d.ts +11 -0
  337. package/dist/src/projects/project-service.js +121 -42
  338. package/dist/src/projects/project-store.js +12 -2
  339. package/dist/src/projects/project-workspace-creation.d.ts +3 -0
  340. package/dist/src/projects/project-workspace-creation.js +45 -0
  341. package/dist/src/projects/workspace-project.js +6 -0
  342. package/dist/src/providers/model-catalog-types.d.ts +2 -1
  343. package/dist/src/providers/model-reference-auditor.js +4 -4
  344. package/dist/src/providers/model-supplements.js +13 -3
  345. package/dist/src/providers/presentation.js +3 -3
  346. package/dist/src/providers/xopc-cloud-model-source.js +4 -2
  347. package/dist/src/realtime/runtime.js +4 -0
  348. package/dist/src/scenes/capabilities/read.d.ts +3 -0
  349. package/dist/src/scenes/capabilities/read.js +187 -0
  350. package/dist/src/scenes/capabilities/write.d.ts +3 -0
  351. package/dist/src/scenes/capabilities/write.js +151 -0
  352. package/dist/src/scenes/contracts.d.ts +2 -105
  353. package/dist/src/scenes/contracts.js +3 -88
  354. package/dist/src/scenes/execution.d.ts +1 -1
  355. package/dist/src/scenes/httpServices.d.ts +2 -0
  356. package/dist/src/scenes/inbox.d.ts +1 -0
  357. package/dist/src/scenes/inbox.js +7 -7
  358. package/dist/src/scenes/preferences.d.ts +3 -24
  359. package/dist/src/scenes/preferences.js +8 -30
  360. package/dist/src/scenes/repository.d.ts +1 -0
  361. package/dist/src/scenes/repository.js +7 -3
  362. package/dist/src/scenes/resultNotifications.js +2 -2
  363. package/dist/src/scenes/schedule.d.ts +1 -8
  364. package/dist/src/scenes/schedule.js +3 -15
  365. package/dist/src/scenes/service.d.ts +6 -0
  366. package/dist/src/scenes/service.js +29 -25
  367. package/dist/src/scenes/taskFollowUp/agentExecutor.d.ts +36 -0
  368. package/dist/src/scenes/taskFollowUp/agentExecutor.js +149 -0
  369. package/dist/src/scenes/taskFollowUp/branchInventory.d.ts +38 -0
  370. package/dist/src/scenes/taskFollowUp/branchInventory.js +70 -0
  371. package/dist/src/scenes/taskFollowUp/contracts.d.ts +91 -0
  372. package/dist/src/scenes/taskFollowUp/contracts.js +100 -0
  373. package/dist/src/scenes/taskFollowUp/resources.d.ts +19 -0
  374. package/dist/src/scenes/taskFollowUp/resources.js +97 -0
  375. package/dist/src/scenes/taskFollowUp/service.d.ts +810 -0
  376. package/dist/src/scenes/taskFollowUp/service.js +710 -0
  377. package/dist/src/scenes/taskFollowUp/workspaceFingerprint.d.ts +2 -0
  378. package/dist/src/scenes/taskFollowUp/workspaceFingerprint.js +46 -0
  379. package/dist/src/scenes/templates.d.ts +2 -2
  380. package/dist/src/scenes/templates.js +1 -1
  381. package/dist/src/session/session-find.d.ts +17 -0
  382. package/dist/src/session/session-find.js +56 -0
  383. package/dist/src/session/store.d.ts +4 -0
  384. package/dist/src/session/store.js +43 -7
  385. package/dist/src/share/note-share-revocation.d.ts +3 -0
  386. package/dist/src/share/note-share-revocation.js +26 -0
  387. package/dist/src/storage/sqlite/migrations/190_scene_development.sql +37 -0
  388. package/dist/src/storage/sqlite/migrations/191_scene_task_follow_up.sql +27 -0
  389. package/dist/src/storage/sqlite/migrations/192_capability_operations.sql +20 -0
  390. package/dist/src/storage/sqlite/migrations/193_note_file_cleanup.sql +8 -0
  391. package/dist/src/storage/sqlite/migrations/194_capability_external_outcomes.sql +11 -0
  392. package/dist/src/storage/sqlite/migrations/195_automation_deleted_revisions.sql +4 -0
  393. package/dist/src/storage/sqlite/migrations/196_automation_run_requests.sql +23 -0
  394. package/dist/src/storage/sqlite/migrations/197_note_deletion_cleanup.sql +8 -0
  395. package/dist/src/storage/sqlite/migrations/198_project_workspace_creation.sql +7 -0
  396. package/dist/src/storage/sqlite/migrations/199_scene_resource_events.sql +488 -0
  397. package/dist/src/storage/sqlite/migrations/runner.d.ts +1 -1
  398. package/dist/src/storage/sqlite/migrations/runner.js +6 -3
  399. package/dist/src/storage/sqlite/schema.js +1 -1
  400. package/dist/src/storage/sqlite/transaction.d.ts +5 -0
  401. package/dist/src/storage/sqlite/transaction.js +34 -3
  402. package/dist/src/tasks/capabilities/management.d.ts +195 -0
  403. package/dist/src/tasks/capabilities/management.js +111 -0
  404. package/dist/src/tasks/capabilities/read.d.ts +2 -0
  405. package/dist/src/tasks/capabilities/read.js +141 -0
  406. package/dist/src/tasks/capabilities/relations.d.ts +204 -0
  407. package/dist/src/tasks/capabilities/relations.js +140 -0
  408. package/dist/src/tasks/capabilities/runs.d.ts +2 -0
  409. package/dist/src/tasks/capabilities/runs.js +89 -0
  410. package/dist/src/tasks/capabilities/write.d.ts +207 -0
  411. package/dist/src/tasks/capabilities/write.js +107 -0
  412. package/dist/src/tasks/home-query-service.js +3 -2
  413. package/dist/src/tasks/index.d.ts +0 -1
  414. package/dist/src/tasks/index.js +9 -9
  415. package/dist/src/tasks/project-operating-view-service.js +2 -1
  416. package/dist/src/tasks/task-application-service.d.ts +1 -0
  417. package/dist/src/tasks/task-application-service.js +3 -2
  418. package/dist/src/tasks/task-change-events.js +5 -3
  419. package/dist/src/tasks/task-context-assembler.js +2 -1
  420. package/dist/src/tasks/task-deletion-service.js +2 -1
  421. package/dist/src/tasks/task-dependency-service.js +2 -1
  422. package/dist/src/tasks/task-handoff-service.js +2 -1
  423. package/dist/src/tasks/task-read-model-projector.js +2 -1
  424. package/dist/src/tasks/task-repository.d.ts +12 -7
  425. package/dist/src/tasks/task-repository.js +175 -154
  426. package/dist/src/tasks/task-run-coordinator.js +2 -1
  427. package/dist/src/tasks/task-run-dispatcher.js +2 -1
  428. package/dist/src/tasks/task-run-repository.d.ts +1 -0
  429. package/dist/src/tasks/task-run-repository.js +29 -14
  430. package/dist/src/tasks/task-signal-service.js +2 -1
  431. package/dist/src/tui/backends/embedded-backend.js +1 -1
  432. package/dist/src/tui/backends/gateway-realtime-backend.js +1 -1
  433. package/dist/src/tui/tui-commands.js +1 -1
  434. package/dist/src/user-context/config.d.ts +13 -0
  435. package/dist/src/user-context/config.js +2 -0
  436. package/dist/src/voice/platform-catalog.d.ts +1 -1
  437. package/dist/src/voice/realtime/runtime.js +3 -3
  438. package/dist/src/voice/stt/providers/alibaba-transcription.js +1 -1
  439. package/dist/src/voice/stt/providers/xopc-cloud-transcription.js +1 -1
  440. package/dist/src/voice/tts/providers/xopc-cloud-speech.js +1 -1
  441. package/dist/src/work-discovery/incremental-repository.js +1 -1
  442. package/dist/src/work-discovery/index.js +1 -1
  443. package/dist/src/work-discovery/repository.d.ts +1 -1
  444. package/dist/src/work-discovery/repository.js +3 -2
  445. package/dist/src/work-discovery/service.d.ts +4 -0
  446. package/dist/src/work-discovery/service.js +36 -11
  447. package/dist/src/workflows/context/workflow-context.js +3 -2
  448. package/dist/src/workflows/service/workflow-run-service.js +2 -1
  449. package/package.json +6 -2
  450. package/skills/THIRD_PARTY_NOTICES.md +2 -2
  451. package/skills/documents/xlsx/SKILL.md +5 -0
  452. package/skills/engineering/build-xopc-local-app/SKILL.md +2 -0
  453. package/skills/tools/find-skills/SKILL.md +3 -0
  454. package/dist/gateway/static/root/assets/activity-store-DVUTs1fk.js +0 -1
  455. package/dist/gateway/static/root/assets/agent-defaults-settings-panel-K3hTmu9d.js +0 -1
  456. package/dist/gateway/static/root/assets/appearance-settings-CU52MfIT.js +0 -1
  457. package/dist/gateway/static/root/assets/apps-page-ZpA1-6ad.js +0 -1
  458. package/dist/gateway/static/root/assets/automations-workspace-IEAxKRME.js +0 -7
  459. package/dist/gateway/static/root/assets/browser-settings-page-CU4VWsmX.js +0 -3
  460. package/dist/gateway/static/root/assets/capabilities-settings-panel-C9XQk3HL.js +0 -8
  461. package/dist/gateway/static/root/assets/channels-settings-Bqlhjooi.js +0 -1
  462. package/dist/gateway/static/root/assets/connector-service-page-BmH17JnO.js +0 -1
  463. package/dist/gateway/static/root/assets/connectors-page-zkx8Q-e6.js +0 -2
  464. package/dist/gateway/static/root/assets/desktop-pet-settings-CE4GOlMM.js +0 -1
  465. package/dist/gateway/static/root/assets/device-pairing-wizard-CdKJqnnw.js +0 -1
  466. package/dist/gateway/static/root/assets/files-Be5viEFY.js +0 -1
  467. package/dist/gateway/static/root/assets/gateway-realtime-CGOW0-b4.js +0 -1
  468. package/dist/gateway/static/root/assets/gateway-realtime-store-D4um_sV7.js +0 -1
  469. package/dist/gateway/static/root/assets/gateway-settings-CgXp2zq4.js +0 -1
  470. package/dist/gateway/static/root/assets/home-page-D6Idk732.js +0 -1
  471. package/dist/gateway/static/root/assets/index-1wIKA-kM.css +0 -1
  472. package/dist/gateway/static/root/assets/index-PFQHPGgi.js +0 -79
  473. package/dist/gateway/static/root/assets/local-app-workbench-page-BmAqTRb4.js +0 -2
  474. package/dist/gateway/static/root/assets/logs-page-ZjVYXXyM.js +0 -2
  475. package/dist/gateway/static/root/assets/management-settings-CSTkYVOZ.js +0 -1
  476. package/dist/gateway/static/root/assets/messages-4BtQKYlM.js +0 -3
  477. package/dist/gateway/static/root/assets/note-detail-panel-DuXCt-MM.js +0 -5
  478. package/dist/gateway/static/root/assets/notes-page-BjOgBVq5.js +0 -8
  479. package/dist/gateway/static/root/assets/product-delivery-CrAI8ZEa.js +0 -1
  480. package/dist/gateway/static/root/assets/project-detail-page-0zi4-i9X.js +0 -1
  481. package/dist/gateway/static/root/assets/projects-page-B18OxmJj.js +0 -1
  482. package/dist/gateway/static/root/assets/remote-access-hub-z-DxbuaE.js +0 -1
  483. package/dist/gateway/static/root/assets/runtime-tools-settings-panel-DGsBTbo6.js +0 -5
  484. package/dist/gateway/static/root/assets/scenes-page-Bgba03B_.js +0 -1
  485. package/dist/gateway/static/root/assets/schemas-BaskVM5g.js +0 -64
  486. package/dist/gateway/static/root/assets/sessions-page-B1t3bMsm.js +0 -1
  487. package/dist/gateway/static/root/assets/settings-advanced-gate-CBX0Ezhf.js +0 -1
  488. package/dist/gateway/static/root/assets/setup-status-panel-Bw71C2X3.js +0 -1
  489. package/dist/gateway/static/root/assets/shares-settings-BoVDQolc.js +0 -1
  490. package/dist/gateway/static/root/assets/skill-reload-api-DtTptpAt.js +0 -1
  491. package/dist/gateway/static/root/assets/task-detail-page-vgkiGo-D.js +0 -1
  492. package/dist/gateway/static/root/assets/theme-store-CegIlB8d.js +0 -1
  493. package/dist/gateway/static/root/assets/user-model-page-CAGafNfP.js +0 -2
  494. package/dist/gateway/static/root/assets/workflows-page-CSxHVs1p.js +0 -6
  495. package/skills/creative/algorithmic-art/SKILL.md +0 -44
  496. package/skills/creative/algorithmic-art/templates/generator-template.js +0 -27
  497. package/skills/creative/algorithmic-art/templates/viewer.html +0 -27
@@ -3,10 +3,10 @@ import { resolveProjectAgentId } from "../../../projects/project-agent.js";
3
3
  import "../../../projects/index.js";
4
4
  import { messagesToClientHistory } from "../../../session/client-history.js";
5
5
  import { validateWorkflowDefinitionInput } from "../../../workflows/domain/validation.js";
6
+ import { WorkflowDraftService } from "../../../workflows/draft/workflow-draft-service.js";
6
7
  import { WorkflowNameConflictError, WorkflowRevisionConflictError, createWorkflowCatalog } from "../../../agent/workflow/catalog.js";
7
8
  import "../../../workflows/domain/index.js";
8
9
  import { resolveWorkflowRunArtifactsDir } from "../../../workflows/store/paths.js";
9
- import { WorkflowDraftService } from "../../../workflows/draft/workflow-draft-service.js";
10
10
  import { WorkflowDraftConflictError, WorkflowDraftStore } from "../../../workflows/authoring/workflow-draft-store.js";
11
11
  import "../../../workflows/authoring/index.js";
12
12
  import "../../../workflows/draft/index.js";
@@ -1,10 +1,11 @@
1
- import { TaskRepository } from "../tasks/task-repository.js";
1
+ import { TaskRepository, init_task_repository } from "../tasks/task-repository.js";
2
2
  import { FileServiceError } from "../files/file-service.js";
3
3
  import { resolveMediaReference } from "../media/media-reference.js";
4
4
  import { pendingTranscriptReferencesMediaUri } from "../agent/inbound/attachment-pipeline.js";
5
5
  import { TaskContextRepository } from "../tasks/task-context-repository.js";
6
6
  import { messagesReferenceMediaUri } from "../media/session-references.js";
7
7
  //#region src/gateway/media-access.ts
8
+ init_task_repository();
8
9
  /** Resolve media only when the supplied session or task references it. */
9
10
  async function resolveScopedMediaReference(service, uri, scope) {
10
11
  const { conversationId, taskId } = scope;
@@ -1,9 +1,9 @@
1
1
  import { getProviderRegistry, init_plugin_registry } from "../providers/plugin-registry.js";
2
2
  import { PROVIDER_META, getAvailableModels, init_providers } from "../providers/index.js";
3
- import { resolveSpeechProviderChain } from "../voice/tts/factory.js";
4
- import { mergeTtsConfigFromAppConfig } from "../voice/tts/merge-config.js";
5
3
  import { resolveSTTProviderChain } from "../voice/stt/factory.js";
6
4
  import { mergeSttConfigFromAppConfig } from "../voice/stt/config.js";
5
+ import { resolveSpeechProviderChain } from "../voice/tts/factory.js";
6
+ import { mergeTtsConfigFromAppConfig } from "../voice/tts/merge-config.js";
7
7
  import { getVoiceProviderMetadata } from "../voice/metadata/registry.js";
8
8
  import "../voice/metadata/index.js";
9
9
  import { getImageGenerationCatalog } from "./image-generation-setup.js";
@@ -2,8 +2,9 @@ import { createLogger } from "../../utils/logger/index.js";
2
2
  import { init_logger } from "../../utils/logger.js";
3
3
  import { assertSceneStorageReady, init_scenes_schema } from "../../storage/sqlite/scenes-schema.js";
4
4
  import { init_providers, isProviderConfiguredSync, resolveModel } from "../../providers/index.js";
5
- import { BrowserSubscriptionService } from "../../notifications/browserSubscriptions.js";
6
5
  import { SceneRepository } from "../../scenes/repository.js";
6
+ import { SceneApplicationService } from "../../scenes/service.js";
7
+ import { BrowserSubscriptionService } from "../../notifications/browserSubscriptions.js";
7
8
  import { ScenePreferenceService } from "../../scenes/preferences.js";
8
9
  import { SceneExecutionService } from "../../scenes/execution.js";
9
10
  import { SceneAgentExecutor } from "../../scenes/agentExecutor.js";
@@ -14,11 +15,13 @@ import { SceneMetrics } from "../../scenes/metrics.js";
14
15
  import { resolveSceneModelRef } from "../../scenes/model.js";
15
16
  import { SceneResultNotifications } from "../../scenes/resultNotifications.js";
16
17
  import { SceneRuntime } from "../../scenes/runtime.js";
17
- import { SceneApplicationService } from "../../scenes/service.js";
18
18
  import { familyPlanTemplate, mailFollowUpTemplate } from "../../scenes/templates.js";
19
19
  import { SceneUserNotesProvider } from "../../scenes/userNotes.js";
20
20
  import { createSceneBrowserDispatcher } from "./browserNotifications.js";
21
21
  import { GatewaySceneMailContext } from "./mailContext.js";
22
+ import { SlackThreadSource } from "./slackThreadSource.js";
23
+ import { TaskSourceRegistry } from "../../scenes/taskFollowUp/contracts.js";
24
+ import { TaskFollowUpService } from "../../scenes/taskFollowUp/service.js";
22
25
  //#region src/gateway/scenes/host.ts
23
26
  init_providers();
24
27
  init_scenes_schema();
@@ -61,7 +64,13 @@ var GatewaySceneHost = class {
61
64
  };
62
65
  const grant = async (activation) => authorize(activation);
63
66
  const executor = input.executor ?? new SceneAgentExecutor(() => resolveModel(resolveSceneModelRef(input.config())));
67
+ const slackThread = new SlackThreadSource(db);
68
+ const followUps = new TaskFollowUpService(db, {
69
+ config: input.config,
70
+ sources: new TaskSourceRegistry([slackThread])
71
+ });
64
72
  this.http = {
73
+ followUps,
65
74
  repository,
66
75
  mail,
67
76
  mailDiscovery: mail instanceof GatewaySceneMailContext ? mail : void 0,
@@ -90,6 +99,7 @@ var GatewaySceneHost = class {
90
99
  assertSceneStorageReady(this.db);
91
100
  this.runtime.start();
92
101
  const poll = () => {
102
+ this.http.followUps?.tick().catch((err) => log.error({ err }, "Task follow-up check failed"));
93
103
  try {
94
104
  if (this.clock() >= this.nextMaintenanceAt) {
95
105
  maintainSceneStorage(this.db, this.clock());
@@ -108,7 +118,7 @@ var GatewaySceneHost = class {
108
118
  tick() {
109
119
  if (this.stopped) return Promise.reject(/* @__PURE__ */ new Error("Scene host stopped"));
110
120
  if (this.active) return this.active;
111
- const work = this.runtime.tick().then(() => {
121
+ const work = Promise.all([this.runtime.tick(), this.http.followUps?.tick()]).then(() => {
112
122
  if (!this.stopped) this.notifications.drain();
113
123
  });
114
124
  this.active = work.finally(() => {
@@ -121,6 +131,7 @@ var GatewaySceneHost = class {
121
131
  this.stopped = true;
122
132
  if (this.timer) clearInterval(this.timer);
123
133
  this.timer = void 0;
134
+ await this.http.followUps?.stop();
124
135
  await this.runtime.stop();
125
136
  await this.browserDispatcher.stop();
126
137
  await this.active?.catch(() => void 0);
@@ -1,9 +1,9 @@
1
1
  import { getConnectorConnection, getConnectorInstallation, init_connector_repository } from "../../storage/sqlite/connector-repository.js";
2
2
  import { ComposioSessionsAdapter } from "../../connectors/composio-sessions.js";
3
3
  import { getConnectorDefinition } from "../../connectors/catalog.js";
4
+ import { sceneContentHash } from "../../scenes/contracts.js";
4
5
  import { normalizeConnectedSourceResult } from "../../connectors/connected-source-normalizers.js";
5
6
  import { sanitizeConnectedSourceValue } from "../../connectors/connected-source-sanitization.js";
6
- import { sceneContentHash } from "../../scenes/contracts.js";
7
7
  import { SceneSourceNotReady, sceneSourceFailureReason } from "../../scenes/readiness.js";
8
8
  import { SceneMailContextProvider } from "../../scenes/mailContext.js";
9
9
  import { createHash } from "node:crypto";
@@ -0,0 +1,41 @@
1
+ import type { DatabaseSync } from 'node:sqlite';
2
+ import { z } from 'zod';
3
+ import { ComposioSessionsAdapter } from '../../connectors/composio-sessions.js';
4
+ import { type ScenePrincipal } from '../../scenes/contracts.js';
5
+ import type { TaskSourceAdapter, SourceSnapshot } from '../../scenes/taskFollowUp/contracts.js';
6
+ export declare const slackThreadSchema: z.ZodObject<{
7
+ accountId: z.ZodString;
8
+ teamId: z.ZodString;
9
+ channelId: z.ZodString;
10
+ threadTs: z.ZodString;
11
+ }, z.core.$strict>;
12
+ export type SlackThread = z.infer<typeof slackThreadSchema>;
13
+ /** Parse locally; never fetch a user-supplied URL. Reply links resolve to their root. */
14
+ export declare function parseSlackThreadUrl(value: string): {
15
+ channelId: string;
16
+ threadTs: string;
17
+ };
18
+ /** Read-only connector adapter. Account policy is rechecked before and after every page. */
19
+ export declare class SlackThreadSource implements TaskSourceAdapter {
20
+ private readonly db;
21
+ private readonly adapter;
22
+ readonly id = "slack_thread";
23
+ readonly label = "Slack thread";
24
+ normalize(reference: Record<string, string>): {
25
+ accountId: string;
26
+ teamId: string;
27
+ channelId: string;
28
+ threadTs: string;
29
+ };
30
+ accountIds(reference: Record<string, string>): string[];
31
+ authorized(principal: ScenePrincipal, reference: Record<string, string>): boolean;
32
+ constructor(db: DatabaseSync, adapter?: Pick<ComposioSessionsAdapter, 'executeWithPolicy'>);
33
+ listAccounts(principal: ScenePrincipal): Array<{
34
+ id: string;
35
+ label: string;
36
+ }>;
37
+ private connection;
38
+ private call;
39
+ resolveLink(principal: ScenePrincipal, accountId: string, url: string, signal: AbortSignal): Promise<SlackThread>;
40
+ read(principal: ScenePrincipal, reference: Record<string, string>, signal: AbortSignal): Promise<SourceSnapshot>;
41
+ }
@@ -0,0 +1,168 @@
1
+ import { getConnectorConnection, getConnectorInstallation, init_connector_repository } from "../../storage/sqlite/connector-repository.js";
2
+ import { ComposioSessionsAdapter } from "../../connectors/composio-sessions.js";
3
+ import { getConnectorDefinition } from "../../connectors/catalog.js";
4
+ import { sceneContentHash } from "../../scenes/contracts.js";
5
+ import { sanitizeConnectedSourceValue } from "../../connectors/connected-source-sanitization.js";
6
+ import { z } from "zod";
7
+ //#region src/gateway/scenes/slackThreadSource.ts
8
+ init_connector_repository();
9
+ const slackThreadSchema = z.strictObject({
10
+ accountId: z.string().min(1).max(200),
11
+ teamId: z.string().regex(/^T[A-Z0-9]+$/),
12
+ channelId: z.string().regex(/^[CDG][A-Z0-9]+$/),
13
+ threadTs: z.string().regex(/^\d{10,}\.\d{6}$/)
14
+ });
15
+ /** Parse locally; never fetch a user-supplied URL. Reply links resolve to their root. */
16
+ function parseSlackThreadUrl(value) {
17
+ const url = new URL(value);
18
+ if (url.protocol !== "https:" || !/^[a-z0-9-]+\.slack\.com$/.test(url.hostname) || url.username || url.password || url.port) throw new Error("Expected a Slack message link");
19
+ const match = /^\/archives\/([CDG][A-Z0-9]+)\/p(\d{16,})$/.exec(url.pathname);
20
+ if (!match) throw new Error("Expected a Slack message link");
21
+ const threadTs = url.searchParams.get("thread_ts") ?? `${match[2].slice(0, -6)}.${match[2].slice(-6)}`;
22
+ if (!/^\d{10,}\.\d{6}$/.test(threadTs)) throw new Error("Invalid Slack thread timestamp");
23
+ return {
24
+ channelId: match[1],
25
+ threadTs
26
+ };
27
+ }
28
+ const object = (value) => value && typeof value === "object" && !Array.isArray(value) ? value : {};
29
+ /** Read-only connector adapter. Account policy is rechecked before and after every page. */
30
+ var SlackThreadSource = class {
31
+ id = "slack_thread";
32
+ label = "Slack thread";
33
+ normalize(reference) {
34
+ return slackThreadSchema.parse(reference);
35
+ }
36
+ accountIds(reference) {
37
+ return [this.normalize(reference).accountId];
38
+ }
39
+ authorized(principal, reference) {
40
+ return this.listAccounts(principal).some((account) => account.id === this.normalize(reference).accountId);
41
+ }
42
+ constructor(db, adapter = new ComposioSessionsAdapter()) {
43
+ this.db = db;
44
+ this.adapter = adapter;
45
+ }
46
+ listAccounts(principal) {
47
+ return this.db.prepare(`SELECT a.id, a.label, c.connector_id FROM connector_accounts a
48
+ JOIN connector_connections c ON c.id = a.current_connection_id AND c.account_id = a.id
49
+ AND c.principal_id = a.principal_id AND c.connector_id = a.connector_id
50
+ JOIN connector_installations i ON i.id = c.installation_id AND i.principal_id = a.principal_id AND i.connector_id = a.connector_id
51
+ WHERE a.principal_id = ? AND a.enabled = 1 AND c.status = 'active' AND c.provider = 'composio'
52
+ AND i.enabled = 1 AND i.confirmation_policy <> 'always'
53
+ AND json_array_length(i.allowed_agent_ids_json) = 0 AND a.allowed_agent_ids_json IS NULL
54
+ AND (i.selected_account_ids_json = 'null' OR EXISTS (SELECT 1 FROM json_each(i.selected_account_ids_json) WHERE value = a.id))
55
+ AND (c.expires_at IS NULL OR julianday(c.expires_at) > julianday('now')) ORDER BY a.id LIMIT 100`).all(principal.ownerId).filter((row) => {
56
+ const definition = getConnectorDefinition(String(row.connector_id));
57
+ return definition?.runtime.type === "composio" && definition.runtime.toolkit === "slack";
58
+ }).map((row) => ({
59
+ id: String(row.id),
60
+ label: String(row.label || row.id).slice(0, 300)
61
+ }));
62
+ }
63
+ connection(principal, accountId) {
64
+ if (!this.listAccounts(principal).some((account) => account.id === accountId)) throw new Error("Slack account permission unavailable");
65
+ const row = this.db.prepare("SELECT current_connection_id FROM connector_accounts WHERE id = ?").get(accountId);
66
+ return getConnectorConnection(String(row.current_connection_id));
67
+ }
68
+ async call(principal, accountId, actionId, args, signal) {
69
+ signal.throwIfAborted();
70
+ const connection = this.connection(principal, accountId);
71
+ const installation = getConnectorInstallation(connection.installationId);
72
+ const day = Math.floor(Date.now() / 864e5);
73
+ const usage = this.db.prepare("SELECT request_count FROM scene_connector_usage WHERE owner_id = ? AND workspace_id = ? AND account_id = ? AND utc_day = ?").get(principal.ownerId, principal.workspaceId, accountId, day);
74
+ if (Number(usage?.request_count ?? 0) >= 3e3) throw new Error("Slack daily request budget exhausted");
75
+ this.db.prepare(`INSERT INTO scene_connector_usage VALUES (?, ?, ?, ?, 1)
76
+ ON CONFLICT(owner_id, workspace_id, account_id, utc_day) DO UPDATE SET request_count = request_count + 1`).run(principal.ownerId, principal.workspaceId, accountId, day);
77
+ const result = await this.adapter.executeWithPolicy({
78
+ context: {
79
+ principalId: principal.ownerId,
80
+ toolkits: ["slack"]
81
+ },
82
+ connection,
83
+ installation,
84
+ signal,
85
+ args,
86
+ action: {
87
+ connectorId: connection.connectorId,
88
+ toolkit: "slack",
89
+ actionId,
90
+ scope: "read",
91
+ curated: true,
92
+ cachedAt: (/* @__PURE__ */ new Date()).toISOString()
93
+ }
94
+ });
95
+ signal.throwIfAborted();
96
+ if (this.connection(principal, accountId).id !== connection.id) throw new Error("Slack connection changed");
97
+ if (result.decision !== "allowed") throw new Error("Slack read requires permission");
98
+ const envelope = object(result.result);
99
+ const data = object(envelope.data);
100
+ if (envelope.successful === false || envelope.error || data.ok === false || data.error || !Object.keys(data).length) throw new Error("Slack source unavailable; check connection permissions or rate limit");
101
+ return data;
102
+ }
103
+ async resolveLink(principal, accountId, url, signal) {
104
+ const parsed = parseSlackThreadUrl(url);
105
+ const auth = await this.call(principal, accountId, "SLACK_TEST_AUTH", {}, signal);
106
+ if (typeof auth.team_id !== "string" || !/^T[A-Z0-9]+$/.test(auth.team_id)) throw new Error("Slack workspace identity unavailable");
107
+ return {
108
+ accountId,
109
+ teamId: auth.team_id,
110
+ ...parsed
111
+ };
112
+ }
113
+ async read(principal, reference, signal) {
114
+ const thread = this.normalize(reference);
115
+ if ((await this.call(principal, thread.accountId, "SLACK_TEST_AUTH", {}, signal)).team_id !== thread.teamId) throw new Error("Slack workspace identity changed");
116
+ const messages = /* @__PURE__ */ new Map();
117
+ const cursors = /* @__PURE__ */ new Set();
118
+ let cursor;
119
+ do {
120
+ const data = await this.call(principal, thread.accountId, "SLACK_FETCH_MESSAGE_THREAD_FROM_A_CONVERSATION", {
121
+ channel: thread.channelId,
122
+ ts: thread.threadTs,
123
+ limit: 100,
124
+ ...cursor ? { cursor } : {}
125
+ }, signal);
126
+ if (!Array.isArray(data.messages) || !data.messages.length) throw new Error("Slack thread is missing or incomplete");
127
+ for (const item of data.messages) {
128
+ const message = object(item);
129
+ if (typeof message.ts !== "string" || typeof message.text !== "string" || message.ts !== thread.threadTs && message.thread_ts !== thread.threadTs) throw new Error("Unexpected Slack thread response");
130
+ messages.set(message.ts, {
131
+ ts: message.ts,
132
+ user: String(message.user ?? message.bot_id ?? "unknown"),
133
+ text: String(sanitizeConnectedSourceValue(message.text)),
134
+ ...Array.isArray(message.files) && message.files.length || Array.isArray(message.attachments) && message.attachments.length ? { unreadAttachments: sanitizeConnectedSourceValue({
135
+ files: Array.isArray(message.files) ? message.files.slice(0, 20).map((value) => {
136
+ const file = object(value);
137
+ return {
138
+ id: file.id,
139
+ name: file.name,
140
+ mimetype: file.mimetype
141
+ };
142
+ }) : [],
143
+ richMessageCount: Array.isArray(message.attachments) ? message.attachments.length : 0,
144
+ contentFetched: false
145
+ }) } : {}
146
+ });
147
+ }
148
+ if (messages.size > 200) throw new Error("Slack thread exceeds the 200-message context budget");
149
+ const next = object(data.response_metadata).next_cursor;
150
+ if (next != null && typeof next !== "string") throw new Error("Invalid Slack pagination");
151
+ cursor = typeof next === "string" && next.trim() ? next.trim() : void 0;
152
+ if (data.has_more === true && !cursor) throw new Error("Slack thread pagination is incomplete");
153
+ if (cursor && (cursors.has(cursor) || cursors.size >= 9)) throw new Error("Slack pagination budget exceeded");
154
+ if (cursor) cursors.add(cursor);
155
+ } while (cursor);
156
+ if (!messages.has(thread.threadTs)) throw new Error("Select the root of the Slack thread");
157
+ const ordered = [...messages.values()].sort((a, b) => a.ts.localeCompare(b.ts));
158
+ const text = JSON.stringify(ordered);
159
+ if (text.length > 32e3) throw new Error("Slack thread exceeds the 32,000-character context budget");
160
+ return {
161
+ revision: sceneContentHash(ordered),
162
+ text,
163
+ observedAt: Date.now()
164
+ };
165
+ }
166
+ };
167
+ //#endregion
168
+ export { SlackThreadSource, parseSlackThreadUrl, slackThreadSchema };
@@ -1,5 +1,5 @@
1
1
  import { DEFAULT_BROWSER_EXTENSION_SCOPES, DEFAULT_MOBILE_SCOPES, GATEWAY_SCOPES, isGatewayScope, type GatewayScope } from '@xopcai/gateway-contract';
2
2
  export { DEFAULT_BROWSER_EXTENSION_SCOPES, DEFAULT_MOBILE_SCOPES, GATEWAY_SCOPES, isGatewayScope, type GatewayScope, };
3
3
  export declare function parseGatewayScopes(value: string): GatewayScope[];
4
- export declare function requiredGatewayScope(method: string, path: string): GatewayScope;
4
+ export declare function requiredGatewayScope(method: string, path: string): GatewayScope | undefined;
5
5
  export declare function hasGatewayScope(granted: readonly GatewayScope[], required: GatewayScope): boolean;
@@ -11,6 +11,8 @@ function methodScope(method, read, write) {
11
11
  return method === "GET" ? read : write;
12
12
  }
13
13
  function requiredGatewayScope(method, path) {
14
+ if (/^\/api\/local-app-capabilities\/[^/]+(?:\/[^/]+\/invocations)?$/.test(path)) return void 0;
15
+ if (path === "/api/capabilities/operations" || path.startsWith("/api/capabilities/operations/")) return void 0;
14
16
  if (method === "GET" && path === "/api/mobile/privacy") return "gateway.status";
15
17
  if (path === "/api/realtime/tickets" || path.startsWith("/api/status")) return "gateway.status";
16
18
  if (path === "/api/device-auth/refresh" || path === "/api/devices/me") return "device.self";
@@ -23,7 +25,10 @@ function requiredGatewayScope(method, path) {
23
25
  if (path.startsWith("/api/agents") || path.startsWith("/api/models")) return methodScope(method, "agents.read", "gateway.admin");
24
26
  if (path.startsWith("/api/sessions") || path.startsWith("/api/side-chats")) return methodScope(method, "sessions.read", "sessions.write");
25
27
  if (path.startsWith("/api/tasks")) return methodScope(method, "tasks.read", "tasks.write");
28
+ if (path === "/api/task-runs" || path.startsWith("/api/task-runs/")) return methodScope(method, "tasks.read", "tasks.write");
26
29
  if (path.startsWith("/api/home") || path.startsWith("/api/inbox")) return methodScope(method, "tasks.read", "tasks.write");
30
+ if (method === "POST" && path === "/api/automations/simulate") return "automations.read";
31
+ if (method === "POST" && /^\/api\/notes\/[^/]+\/ai\/edit$/.test(path)) return "workspace.read";
27
32
  if (path.startsWith("/api/automations") || path.startsWith("/api/automation-runs")) return methodScope(method, "automations.read", "automations.write");
28
33
  if (path.startsWith("/api/workflows")) return methodScope(method, "automations.read", "automations.write");
29
34
  if (path === "/api/voice/selection" || path === "/api/voice/catalog/refresh") return "voice.configure";
@@ -0,0 +1,11 @@
1
+ import type { AgentSourceContext } from '../../agent/source-context/types.js';
2
+ import { type CapabilityDispatcher } from '../../capabilities/runtime/dispatcher.js';
3
+ import type { ResolvedGatewayAuth } from '../auth.js';
4
+ import type { GatewayPrincipal } from '../security/gateway-principal.js';
5
+ export interface AppContextGrant {
6
+ principal: GatewayPrincipal;
7
+ authRevision: string;
8
+ }
9
+ /** A queued read retains its original scope ceiling, but never a revoked identity. */
10
+ export declare function checkAppContextAccess(source: AgentSourceContext, dispatcher: CapabilityDispatcher, auth: ResolvedGatewayAuth): Promise<void>;
11
+ export declare function prepareAppContext(input: unknown, principal: GatewayPrincipal, auth: ResolvedGatewayAuth, dispatcher: CapabilityDispatcher, previous?: AgentSourceContext): Promise<AgentSourceContext>;
@@ -0,0 +1,70 @@
1
+ import { parseAppContextEnvelope } from "../../../packages/gateway-contract/src/app-context.js";
2
+ import { init_src } from "../../../packages/gateway-contract/src/index.js";
3
+ import { getDevice } from "../../storage/sqlite/device-access-repository.js";
4
+ import { CapabilityError } from "../../capabilities/runtime/errors.js";
5
+ import { canonicalCapabilityJson } from "../../capabilities/runtime/dispatcher.js";
6
+ import { isBrowserSessionActive } from "../../storage/sqlite/browser-session-repository.js";
7
+ import { appContextToAgentContext } from "../../agent/source-context/app-context.js";
8
+ import { createHmac, randomBytes } from "node:crypto";
9
+ //#region src/gateway/service/app-context-access.ts
10
+ init_src();
11
+ const authorizationEpochKey = randomBytes(32);
12
+ function authRevision(auth) {
13
+ return createHmac("sha256", authorizationEpochKey).update(canonicalCapabilityJson(JSON.parse(JSON.stringify(auth)))).digest("hex");
14
+ }
15
+ /** A queued read retains its original scope ceiling, but never a revoked identity. */
16
+ async function checkAppContextAccess(source, dispatcher, auth) {
17
+ const grant = source.appContextGrant;
18
+ if (!grant || grant.authRevision !== authRevision(auth) || !source.appContext) throw new CapabilityError("FORBIDDEN", "Application context authorization changed");
19
+ const { principal } = grant;
20
+ let scopes = principal.scopes;
21
+ if (principal.kind === "device") {
22
+ const device = principal.deviceId ? getDevice(principal.deviceId) : void 0;
23
+ if (!device || device.revokedAt !== void 0 || device.id !== principal.principalId) throw new CapabilityError("FORBIDDEN", "Application context device access was revoked");
24
+ scopes = scopes.filter((scope) => device.scopes.includes(scope));
25
+ }
26
+ if (principal.browserSessionId && !isBrowserSessionActive(principal.browserSessionId, auth)) throw new CapabilityError("FORBIDDEN", "Application context browser session ended");
27
+ for (const ref of source.appContext.resourceRefs) {
28
+ const domain = ref.kind === "local_app" ? "local_apps" : `${ref.kind}s`;
29
+ await dispatcher.call(`xopc.${domain}.get`, { id: ref.id }, {
30
+ principalId: principal.principalId,
31
+ scopes,
32
+ surface: "http",
33
+ authorize: () => true
34
+ });
35
+ }
36
+ }
37
+ async function prepareAppContext(input, principal, auth, dispatcher, previous) {
38
+ let snapshot;
39
+ try {
40
+ snapshot = parseAppContextEnvelope(input);
41
+ } catch {
42
+ throw new CapabilityError("INVALID_INPUT", "Invalid application context envelope");
43
+ }
44
+ const grant = {
45
+ principal: structuredClone(principal),
46
+ authRevision: authRevision(auth)
47
+ };
48
+ if (previous) {
49
+ if (canonicalCapabilityJson(previous.appContext) !== canonicalCapabilityJson(snapshot) || previous.appContextGrant?.principal.principalId !== principal.principalId) throw new CapabilityError("REVISION_CONFLICT", "Submission identity already belongs to another context");
50
+ await checkAppContextAccess(previous, dispatcher, auth);
51
+ await checkAppContextAccess({
52
+ ...previous,
53
+ appContextGrant: grant
54
+ }, dispatcher, auth);
55
+ return structuredClone(previous);
56
+ }
57
+ const source = {
58
+ ...appContextToAgentContext(await dispatcher.call("xopc.context.resolve", snapshot, {
59
+ principalId: principal.principalId,
60
+ scopes: principal.scopes,
61
+ surface: "http",
62
+ authorize: () => true
63
+ })),
64
+ appContextGrant: grant
65
+ };
66
+ await checkAppContextAccess(source, dispatcher, auth);
67
+ return source;
68
+ }
69
+ //#endregion
70
+ export { checkAppContextAccess, prepareAppContext };
@@ -11,9 +11,9 @@ import { resolveExecutionContext } from "../../tasks/execution-context.js";
11
11
  import { TaskRunCoordinator } from "../../tasks/task-run-coordinator.js";
12
12
  import { formatAgentRunErrorForClient } from "../../agent/client-error-format.js";
13
13
  import "../chat-limits.js";
14
- import { prependEnvelopeTimestamp } from "../../channels/envelope-timestamp.js";
15
14
  import { ChatStreamMapper } from "../chat-stream/mapper.js";
16
15
  import { markdownNotificationPreview } from "../../notifications/plain-text.js";
16
+ import { prependEnvelopeTimestamp } from "../../channels/envelope-timestamp.js";
17
17
  import { resolveWebchatConversationId } from "../resolve-webchat-session-key.js";
18
18
  import { recordExplicitRelationshipFollowUp } from "../../user-context/relationship-continuity.js";
19
19
  import { coalesceThinkingDeltas } from "../chat-stream/thinking-delta-coalescer.js";
@@ -142,7 +142,16 @@ async function* runGatewayAgent(deps, message, channel, chatId, origin, attachme
142
142
  signal: mergedSignal,
143
143
  runId,
144
144
  sourceContexts: runOptions?.sourceContexts,
145
- presentation: runOptions?.presentation
145
+ presentation: runOptions?.presentation,
146
+ onDeferredAudio: (audio) => {
147
+ publishRealtime("sessions", "session.audio_ready", {
148
+ conversationId,
149
+ runId,
150
+ ...audio,
151
+ createdAtMs: Date.now()
152
+ });
153
+ emit("session.transcript_updated", { key: conversationId });
154
+ }
146
155
  });
147
156
  const mappedEvents = (async function* () {
148
157
  for await (const event of eventStream) yield* mapper.map(event);
@@ -9,16 +9,25 @@ import { summarizeSourceContext } from "../../agent/source-context/types.js";
9
9
  import { deleteMediaUrisNoLongerReferenced } from "../../media/session-references.js";
10
10
  import { fitSourceContextsToBudget } from "../../agent/source-context/budget.js";
11
11
  import crypto from "node:crypto";
12
+ import { isDeepStrictEqual } from "node:util";
12
13
  //#region src/gateway/service/session-input-coordinator.ts
13
14
  init_connection_wait_repository();
14
15
  init_session_input_repository();
15
16
  init_logger();
16
17
  const log = createLogger("SessionInputCoordinator");
17
18
  const MAX_PENDING_INPUTS = 10;
19
+ function sameAppContext(input, existing) {
20
+ const identity = (sources) => sources?.filter((source) => source.kind === "app_context").map((source) => ({
21
+ snapshot: source.appContext,
22
+ principal: source.appContextGrant?.principal.principalId
23
+ })) ?? [];
24
+ return isDeepStrictEqual(identity(input.sourceContexts), identity(existing.contextSnapshots));
25
+ }
18
26
  function contextRefsMatchFrozenSnapshot(requested, frozen) {
19
- if (requested.length !== (frozen?.length ?? 0)) return false;
27
+ const editable = frozen?.filter((ref) => ref.kind === "note" || ref.kind === "task") ?? [];
28
+ if (requested.length !== editable.length) return false;
20
29
  return requested.every((ref, index) => {
21
- const snapshot = frozen?.[index];
30
+ const snapshot = editable[index];
22
31
  return snapshot?.kind === ref.kind && snapshot.sourceId === ref.sourceId && ref.expectedVersion === snapshot.version;
23
32
  });
24
33
  }
@@ -53,6 +62,7 @@ var SessionInputCoordinator = class {
53
62
  }
54
63
  }
55
64
  async submit(input) {
65
+ input = structuredClone(input);
56
66
  const conversationId = input.conversationId.trim();
57
67
  try {
58
68
  return await this.runSubmissionExclusive(conversationId, () => this.submitLocked({
@@ -68,6 +78,7 @@ var SessionInputCoordinator = class {
68
78
  }
69
79
  }
70
80
  async replaceLatestTurn(input, beforeReplace) {
81
+ input = structuredClone(input);
71
82
  const conversationId = input.conversationId.trim();
72
83
  return this.runSubmissionExclusive(conversationId, async () => {
73
84
  const clientMessageId = input.clientMessageId.trim();
@@ -81,14 +92,20 @@ var SessionInputCoordinator = class {
81
92
  ok: false,
82
93
  code: "BAD_REQUEST"
83
94
  };
84
- if (findSessionInput(conversationId, clientMessageId)) return {
85
- ok: true,
86
- effectiveDelivery: "next",
87
- state: this.snapshot(conversationId)
88
- };
95
+ const existing = findSessionInput(conversationId, clientMessageId);
96
+ if (existing) {
97
+ if (!sameAppContext(input, existing)) return {
98
+ ok: false,
99
+ code: "CONTEXT_UNAVAILABLE"
100
+ };
101
+ return {
102
+ ok: true,
103
+ effectiveDelivery: "next",
104
+ state: this.snapshot(conversationId)
105
+ };
106
+ }
89
107
  const target = validateLatestSessionTurnTarget(conversationId, targetTurnId);
90
108
  if (target.ok === false) return target;
91
- await beforeReplace();
92
109
  const attachments = await this.deps.prepareAttachments(conversationId, input.attachments);
93
110
  let sourceContexts;
94
111
  try {
@@ -103,6 +120,7 @@ var SessionInputCoordinator = class {
103
120
  code: "CONTEXT_UNAVAILABLE"
104
121
  };
105
122
  }
123
+ await beforeReplace();
106
124
  const result = replaceLatestSessionTurnAndQueueInput({
107
125
  conversationId,
108
126
  targetTurnId,
@@ -149,11 +167,17 @@ var SessionInputCoordinator = class {
149
167
  code: "BAD_REQUEST"
150
168
  };
151
169
  const existing = findSessionInput(conversationId, clientMessageId);
152
- if (existing) return {
153
- ok: true,
154
- effectiveDelivery: existing.effectiveDelivery,
155
- state: this.snapshot(conversationId)
156
- };
170
+ if (existing) {
171
+ if (!sameAppContext(input, existing)) return {
172
+ ok: false,
173
+ code: "CONTEXT_UNAVAILABLE"
174
+ };
175
+ return {
176
+ ok: true,
177
+ effectiveDelivery: existing.effectiveDelivery,
178
+ state: this.snapshot(conversationId)
179
+ };
180
+ }
157
181
  if (this.snapshot(conversationId).inputs.length >= MAX_PENDING_INPUTS) return {
158
182
  ok: false,
159
183
  code: "QUEUE_FULL"
@@ -227,7 +251,21 @@ var SessionInputCoordinator = class {
227
251
  const runId = crypto.randomUUID();
228
252
  const input = claimNextSessionInput(conversationId, runId);
229
253
  if (!input) return;
230
- if (this.deps.beforeExecute && !await this.deps.beforeExecute(input) || !consumeConnectionResume(input) || !consumeClarificationResume(input)) {
254
+ let allowed;
255
+ try {
256
+ allowed = (!this.deps.beforeExecute || await this.deps.beforeExecute(input)) && consumeConnectionResume(input) && consumeClarificationResume(input);
257
+ } catch (err) {
258
+ log.warn({
259
+ err,
260
+ conversationId,
261
+ runId,
262
+ inputId: input.id
263
+ }, "Session input preflight failed");
264
+ finishSessionInputRun(conversationId, runId, "failed", "Input preflight failed");
265
+ this.publish(conversationId);
266
+ continue;
267
+ }
268
+ if (!allowed) {
231
269
  finishSessionInputRun(conversationId, runId, "cancelled");
232
270
  this.publish(conversationId);
233
271
  continue;
@@ -272,7 +310,8 @@ var SessionInputCoordinator = class {
272
310
  if (body.contextRefs !== void 0) {
273
311
  const existing = getSessionInputById(conversationId, id);
274
312
  if (!contextRefsMatchFrozenSnapshot(body.contextRefs, existing?.contextRefs)) try {
275
- sourceContexts = await this.deps.prepareContexts(body.contextRefs) ?? [];
313
+ const resolved = await this.deps.prepareContexts(body.contextRefs) ?? [];
314
+ sourceContexts = fitSourceContextsToBudget([...existing?.contextSnapshots?.filter((source) => source.kind !== "note" && source.kind !== "task") ?? [], ...resolved]);
276
315
  } catch (err) {
277
316
  log.warn({
278
317
  err,
@@ -133,6 +133,7 @@ export declare class GatewaySessionsApi {
133
133
  }>;
134
134
  search(query: string): Promise<import("../../session/types.js").SessionMetadata[]>;
135
135
  searchIn(key: string, keyword: string): Promise<import("../../session/types.js").Message[]>;
136
+ findMessages(key: string, query: string, limit?: number): Promise<import("../../session/session-find.js").SessionFindResult>;
136
137
  export(key: string, format: ExportFormat): Promise<{
137
138
  content: string;
138
139
  }>;
@@ -201,6 +201,9 @@ var GatewaySessionsApi = class {
201
201
  searchIn(key, keyword) {
202
202
  return this.opts.sessionIndex.searchInSession(key, keyword);
203
203
  }
204
+ findMessages(key, query, limit) {
205
+ return this.opts.sessionIndex.getStore().findInSession(key, query, limit);
206
+ }
204
207
  async export(key, format) {
205
208
  return { content: await this.opts.sessionIndex.exportSession(key, format) };
206
209
  }
@@ -1,3 +1,4 @@
1
+ import type { SessionFindResult } from '../../session/session-find.js';
1
2
  import type { SessionTimelineItem } from '../../session/transcript-outline.js';
2
3
  import { TaskConversationRepository } from '../../tasks/task-conversation-repository.js';
3
4
  import type { GatewaySessionsApi } from './sessions-api.js';
@@ -5,7 +6,7 @@ export declare class TaskConversationQueryService {
5
6
  #private;
6
7
  private readonly sessions;
7
8
  private readonly conversations;
8
- constructor(sessions: Pick<GatewaySessionsApi, 'getMessagePage' | 'getTimeline'>, conversations?: Pick<TaskConversationRepository, 'listSessions'>);
9
+ constructor(sessions: Pick<GatewaySessionsApi, 'findMessages' | 'getMessagePage' | 'getTimeline'>, conversations?: Pick<TaskConversationRepository, 'listSessions'>);
9
10
  getMessagePage(taskId: string, options: {
10
11
  limit: number;
11
12
  offset: number;
@@ -56,4 +57,5 @@ export declare class TaskConversationQueryService {
56
57
  };
57
58
  }>;
58
59
  getTimeline(taskId: string): Promise<SessionTimelineItem[] | null>;
60
+ findMessages(taskId: string, query: string, limit?: number): Promise<SessionFindResult | null>;
59
61
  }