@xopcai/xopc 0.0.187 → 0.0.189

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 (385) hide show
  1. package/README.md +1 -1
  2. package/dist/browser-ext/manifest.json +1 -1
  3. package/dist/extensions/demo-memory/src/index.js +1 -0
  4. package/dist/extensions/feishu/src/streaming/streaming-adapter.js +1 -3
  5. package/dist/extensions/telegram/src/adapters/streaming-adapter.js +0 -2
  6. package/dist/extensions/telegram/src/draft-stream.d.ts +0 -4
  7. package/dist/extensions/telegram/src/draft-stream.js +1 -53
  8. package/dist/extensions/telegram/xopc.extension.json +1 -1
  9. package/dist/gateway/static/root/assets/{activity-store-WlR2zEvA.js → activity-store-DTFKTPs8.js} +1 -1
  10. package/dist/gateway/static/root/assets/{agent-avatar-dicebear-RedDszrG.js → agent-avatar-dicebear-DqO25Qe5.js} +1 -1
  11. package/dist/gateway/static/root/assets/agents-BvdqdER9.js +2 -0
  12. package/dist/gateway/static/root/assets/{api-tVOllncq.js → api-DWeXfwVU.js} +1 -1
  13. package/dist/gateway/static/root/assets/{app-management-settings-panel-C9hKBzaF.js → app-management-settings-panel-BRpV8PXG.js} +1 -1
  14. package/dist/gateway/static/root/assets/{appearance-settings-5cQvq7hd.js → appearance-settings-3ntKM9nQ.js} +1 -1
  15. package/dist/gateway/static/root/assets/apps-page-nKLsfy6C.js +1 -0
  16. package/dist/gateway/static/root/assets/{archive-plugin-Ct-shK4n.js → archive-plugin-Df7Ycj_7.js} +1 -1
  17. package/dist/gateway/static/root/assets/{attachment-load-CpPj3m-q.js → attachment-load-UHgfZYtj.js} +1 -1
  18. package/dist/gateway/static/root/assets/automations-page-Dh5bdZiN.js +6 -0
  19. package/dist/gateway/static/root/assets/{binary-plugins-BpSXZBle.js → binary-plugins-BJah99wE.js} +1 -1
  20. package/dist/gateway/static/root/assets/{block-editor-B8hR2tXc.js → block-editor-DNlY5KqF.js} +46 -46
  21. package/dist/gateway/static/root/assets/browser-settings-page-CRJ_nAuh.js +8 -0
  22. package/dist/gateway/static/root/assets/{browser-workflow-inputs-D_LAXUrh.js → browser-workflow-inputs-vyUfdzAd.js} +1 -1
  23. package/dist/gateway/static/root/assets/{browser-workflows-page-CPAs7-6s.js → browser-workflows-page-C1cKZjx-.js} +2 -2
  24. package/dist/gateway/static/root/assets/capabilities-settings-panel-DeQR5BZt.js +7 -0
  25. package/dist/gateway/static/root/assets/{capability-presets-api-CKklVY2p.js → capability-presets-api-D7tkhDMv.js} +1 -1
  26. package/dist/gateway/static/root/assets/capability-presets-settings-panel-D7uK3q1p.js +1 -0
  27. package/dist/gateway/static/root/assets/{channel-recipient-api-WWN-nbFL.js → channel-recipient-api-BGG2kpJB.js} +1 -1
  28. package/dist/gateway/static/root/assets/channels-settings-Bw6Dniyq.js +1 -0
  29. package/dist/gateway/static/root/assets/channels-status-swr-BrUTz4uU.js +1 -0
  30. package/dist/gateway/static/root/assets/{connector-logo-CdNkVFdB.js → connector-logo-8YU53RUT.js} +1 -1
  31. package/dist/gateway/static/root/assets/connectors-page-k9tMiOL5.js +2 -0
  32. package/dist/gateway/static/root/assets/{desktop-pet-Bm_IEAf3.js → desktop-pet-BUuBEJuP.js} +1 -1
  33. package/dist/gateway/static/root/assets/{desktop-pet-settings-C0Ve04-G.js → desktop-pet-settings-BGfVIJM3.js} +1 -1
  34. package/dist/gateway/static/root/assets/{directory-picker-path-field-B2cvhvAI.js → directory-picker-path-field-DrQFfHH_.js} +1 -1
  35. package/dist/gateway/static/root/assets/{extension-debug-page-DNashgGu.js → extension-debug-page-CEnIFOX-.js} +1 -1
  36. package/dist/gateway/static/root/assets/{extension-page-Bvo-5htX.js → extension-page-CCqHbexs.js} +1 -1
  37. package/dist/gateway/static/root/assets/{extension-settings-page-BBESdISV.js → extension-settings-page-DEZw_7zN.js} +1 -1
  38. package/dist/gateway/static/root/assets/{gateway-config-api-ClQvokMo.js → gateway-config-api-CgUE2Ii1.js} +1 -1
  39. package/dist/gateway/static/root/assets/gateway-settings-Dg8qCiIp.js +1 -0
  40. package/dist/gateway/static/root/assets/{gateway-startup-retry-CntXJF6W.js → gateway-startup-retry-DxhKNiCF.js} +1 -1
  41. package/dist/gateway/static/root/assets/{heartbeat-settings-CWKcZuvc.js → heartbeat-settings-27tRzDEo.js} +1 -1
  42. package/dist/gateway/static/root/assets/home-page-VA511kMr.js +3 -0
  43. package/dist/gateway/static/root/assets/{image-generation-api-DjSAQwGy.js → image-generation-api-DCFdc-HD.js} +1 -1
  44. package/dist/gateway/static/root/assets/index-BvR-i-m6.js +216 -0
  45. package/dist/gateway/static/root/assets/index-zybP34zk.css +1 -0
  46. package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-ahKHpjoW.js → keyboard-shortcuts-settings-Bf2VLtXW.js} +1 -1
  47. package/dist/gateway/static/root/assets/local-app-workbench-page-CaJq4-wV.js +2 -0
  48. package/dist/gateway/static/root/assets/{local-apps-page-B6GKdgza.js → local-apps-page-Ca1RuI13.js} +1 -1
  49. package/dist/gateway/static/root/assets/{locale-store-Bff30u5V.js → locale-store-DUW5YE3R.js} +1 -1
  50. package/dist/gateway/static/root/assets/logs-page-BLTCg69e.js +2 -0
  51. package/dist/gateway/static/root/assets/management-settings-B3Eop1zn.js +1 -0
  52. package/dist/gateway/static/root/assets/{markdown-split-BeNMJm_i.js → markdown-split-BGOYjgnM.js} +1 -1
  53. package/dist/gateway/static/root/assets/{media-plugins-Bdzrj_-6.js → media-plugins-CT0txyM4.js} +1 -1
  54. package/dist/gateway/static/root/assets/messages-CMjnbdbn.js +3 -0
  55. package/dist/gateway/static/root/assets/{notes-page-MYIi-9S9.js → notes-page-DfKgAe78.js} +1 -1
  56. package/dist/gateway/static/root/assets/notes-workbench-Bp1w9UM1.js +4 -0
  57. package/dist/gateway/static/root/assets/{page-tabs-3t88bbGx.js → page-tabs-DNrbCgmC.js} +1 -1
  58. package/dist/gateway/static/root/assets/{preview-open-alternatives-Cf_BWbeE.js → preview-open-alternatives-BTqViDOR.js} +1 -1
  59. package/dist/gateway/static/root/assets/product-delivery-tRr-7IxY.js +1 -0
  60. package/dist/gateway/static/root/assets/{product-open-page-CKq73c98.js → product-open-page-C_2L4_Iu.js} +1 -1
  61. package/dist/gateway/static/root/assets/project-detail-page-CZmbPDQN.js +1 -0
  62. package/dist/gateway/static/root/assets/projects-page-D5pzqfm5.js +1 -0
  63. package/dist/gateway/static/root/assets/remote-access-hub-CC-XhVGI.js +1 -0
  64. package/dist/gateway/static/root/assets/{schema-form-NqOm-OG1.js → schema-form-BFLfkDGG.js} +1 -1
  65. package/dist/gateway/static/root/assets/{schemas-C6onAggk.js → schemas-zIBW3wiV.js} +1 -1
  66. package/dist/gateway/static/root/assets/sessions-page-B2eTLVDV.js +1 -0
  67. package/dist/gateway/static/root/assets/settings-advanced-gate-CRuZ_bl0.js +1 -0
  68. package/dist/gateway/static/root/assets/{settings-form-section-DYAS8p8z.js → settings-form-section-C4GXGeA4.js} +1 -1
  69. package/dist/gateway/static/root/assets/{settings-loading-skeleton-DZFhxihA.js → settings-loading-skeleton-C9a-EbTZ.js} +1 -1
  70. package/dist/gateway/static/root/assets/settings-page-DI9qDH5x.js +1 -0
  71. package/dist/gateway/static/root/assets/{settings-page-layout-DfFfkdED.js → settings-page-layout-D-LWQdI5.js} +1 -1
  72. package/dist/gateway/static/root/assets/setup-status-panel-CJwmPvgs.js +1 -0
  73. package/dist/gateway/static/root/assets/{share-preview-page-CYtrQaZN.js → share-preview-page-BKSMG9r5.js} +1 -1
  74. package/dist/gateway/static/root/assets/shares-settings-YzSDS4G_.js +1 -0
  75. package/dist/gateway/static/root/assets/skill-reload-api-CwOo8zZk.js +1 -0
  76. package/dist/gateway/static/root/assets/skills-page-xd1cgSGN.js +2 -0
  77. package/dist/gateway/static/root/assets/{skills-page.utils-BBXirAjc.js → skills-page.utils-zsz2HIlZ.js} +1 -1
  78. package/dist/gateway/static/root/assets/{system-settings-panel-DLf5YvFl.js → system-settings-panel-IWNDBI1O.js} +1 -1
  79. package/dist/gateway/static/root/assets/{task-detail-page-DFGkuYfl.js → task-detail-page-CgtK02kP.js} +1 -1
  80. package/dist/gateway/static/root/assets/{theme-store-y7e_tvYi.js → theme-store-BkJe7UDo.js} +1 -1
  81. package/dist/gateway/static/root/assets/time-picker-CstQ___Y.js +1 -0
  82. package/dist/gateway/static/root/assets/{typed-models-lib-DR12j_dr.js → typed-models-lib-C07LGthO.js} +1 -1
  83. package/dist/gateway/static/root/assets/{use-save-bar-registration-BsvcJgZl.js → use-save-bar-registration-CQYE0l6z.js} +1 -1
  84. package/dist/gateway/static/root/assets/user-context-page-BnQAWS_B.js +1 -0
  85. package/dist/gateway/static/root/assets/{voice-api-key-field-DKADXFWD.js → voice-api-key-field-Boue1D46.js} +1 -1
  86. package/dist/gateway/static/root/assets/{work-discovery-overlay-BC1nExf8.js → work-discovery-overlay-bbmvCmc8.js} +1 -1
  87. package/dist/gateway/static/root/assets/work-discovery-page-CAszL1y8.js +1 -0
  88. package/dist/gateway/static/root/assets/{workflow-run-setup-panel-C8X5W-8k.js → workflow-run-setup-panel-DlHv-GZC.js} +2 -2
  89. package/dist/gateway/static/root/assets/workflows-page-DxGzo3-x.js +11 -0
  90. package/dist/gateway/static/root/index.html +9 -9
  91. package/dist/package.js +1 -1
  92. package/dist/packages/endpoint-tools-protocol/src/index.js +184 -0
  93. package/dist/packages/gateway-contract/src/tool-activity.js +223 -0
  94. package/dist/packages/realtime-client/src/index.js +199 -0
  95. package/dist/packages/realtime-protocol/src/index.js +83 -0
  96. package/dist/src/agent/agent-manager.d.ts +1 -0
  97. package/dist/src/agent/agent-manager.js +3 -8
  98. package/dist/src/agent/background-review/prompts.d.ts +1 -1
  99. package/dist/src/agent/background-review/prompts.js +3 -1
  100. package/dist/src/agent/background-review/run-background-review.d.ts +2 -0
  101. package/dist/src/agent/background-review/run-background-review.js +5 -2
  102. package/dist/src/agent/client-error-format.d.ts +1 -1
  103. package/dist/src/agent/client-error-format.js +1 -1
  104. package/dist/src/agent/code-intelligence/binary.js +1 -1
  105. package/dist/src/agent/embedded/run-for-session.d.ts +0 -2
  106. package/dist/src/agent/embedded/run-for-session.js +99 -112
  107. package/dist/src/agent/external-tools/composio-provider.d.ts +29 -0
  108. package/dist/src/agent/external-tools/composio-provider.js +307 -0
  109. package/dist/src/agent/external-tools/endpoint-provider.d.ts +17 -0
  110. package/dist/src/agent/external-tools/endpoint-provider.js +93 -0
  111. package/dist/src/agent/external-tools/extension-provider.d.ts +20 -0
  112. package/dist/src/agent/external-tools/extension-provider.js +68 -0
  113. package/dist/src/agent/external-tools/gateway-tools.d.ts +8 -0
  114. package/dist/src/agent/external-tools/gateway-tools.js +89 -0
  115. package/dist/src/agent/external-tools/index.d.ts +23 -0
  116. package/dist/src/agent/external-tools/index.js +46 -0
  117. package/dist/src/agent/external-tools/mcp-provider.d.ts +29 -0
  118. package/dist/src/agent/external-tools/mcp-provider.js +118 -0
  119. package/dist/src/agent/external-tools/memory-provider.d.ts +21 -0
  120. package/dist/src/agent/external-tools/memory-provider.js +56 -0
  121. package/dist/src/agent/external-tools/refs.d.ts +5 -0
  122. package/dist/src/agent/external-tools/refs.js +18 -0
  123. package/dist/src/agent/external-tools/service.d.ts +26 -0
  124. package/dist/src/agent/external-tools/service.js +117 -0
  125. package/dist/src/agent/external-tools/types.d.ts +35 -0
  126. package/dist/src/agent/external-tools/types.js +10 -0
  127. package/dist/src/agent/inbound/inbound-loop.d.ts +0 -2
  128. package/dist/src/agent/inbound/inbound-loop.js +4 -3
  129. package/dist/src/agent/inbound/turn-dispatcher.d.ts +9 -8
  130. package/dist/src/agent/inbound/turn-dispatcher.js +13 -11
  131. package/dist/src/agent/mcp/{bundle-mcp-materialize.d.ts → bundle-mcp-gateway.d.ts} +1 -19
  132. package/dist/src/agent/mcp/bundle-mcp-gateway.js +60 -0
  133. package/dist/src/agent/mcp/bundle-mcp-names.d.ts +0 -8
  134. package/dist/src/agent/mcp/bundle-mcp-names.js +2 -29
  135. package/dist/src/agent/mcp/bundle-mcp-policy.d.ts +4 -7
  136. package/dist/src/agent/mcp/bundle-mcp-policy.js +6 -20
  137. package/dist/src/agent/mcp/bundle-mcp-runtime.js +2 -2
  138. package/dist/src/agent/mcp/bundle-mcp-tools.d.ts +1 -2
  139. package/dist/src/agent/mcp/bundle-mcp-tools.js +1 -2
  140. package/dist/src/agent/mcp/bundle-mcp-types.d.ts +0 -5
  141. package/dist/src/agent/mcp/index.d.ts +0 -2
  142. package/dist/src/agent/mcp/index.js +2 -5
  143. package/dist/src/agent/mcp/mcp-stdio-transport.js +1 -1
  144. package/dist/src/agent/mcp/mcp-transport.js +1 -1
  145. package/dist/src/agent/memory/context/planner.d.ts +1 -0
  146. package/dist/src/agent/memory/context/planner.js +22 -7
  147. package/dist/src/agent/memory/manager.d.ts +4 -1
  148. package/dist/src/agent/memory/manager.js +5 -2
  149. package/dist/src/agent/memory/types.d.ts +2 -0
  150. package/dist/src/agent/messaging/command-handler.d.ts +2 -2
  151. package/dist/src/agent/messaging/command-handler.js +3 -3
  152. package/dist/src/agent/messaging/stream-manager.d.ts +2 -14
  153. package/dist/src/agent/messaging/stream-manager.js +0 -12
  154. package/dist/src/agent/orchestration/agent-event-handler.d.ts +1 -3
  155. package/dist/src/agent/orchestration/agent-event-handler.js +0 -36
  156. package/dist/src/agent/orchestration/agent-orchestrator.d.ts +0 -5
  157. package/dist/src/agent/orchestration/agent-orchestrator.js +0 -5
  158. package/dist/src/agent/prompt/sections/behavior.js +6 -4
  159. package/dist/src/agent/service/async-queue.d.ts +1 -1
  160. package/dist/src/agent/service/async-queue.js +1 -1
  161. package/dist/src/agent/service/direct-turn-helpers.d.ts +1 -1
  162. package/dist/src/agent/service/direct-turn-helpers.js +1 -1
  163. package/dist/src/agent/service/process-direct-one-shot.d.ts +3 -1
  164. package/dist/src/agent/service/process-direct-one-shot.js +1 -1
  165. package/dist/src/agent/service/process-direct-streaming.d.ts +7 -5
  166. package/dist/src/agent/service/process-direct-streaming.js +5 -5
  167. package/dist/src/agent/service.d.ts +1 -4
  168. package/dist/src/agent/service.js +6 -32
  169. package/dist/src/agent/service.types.d.ts +2 -3
  170. package/dist/src/agent/session/index.d.ts +1 -1
  171. package/dist/src/agent/session/session-context.d.ts +2 -0
  172. package/dist/src/agent/session/session-context.js +4 -0
  173. package/dist/src/agent/session/session-state-bag.d.ts +4 -4
  174. package/dist/src/agent/session/session-state-bag.js +1 -1
  175. package/dist/src/agent/skills/hub-pull.js +1 -1
  176. package/dist/src/agent/starter-agents.js +2 -2
  177. package/dist/src/agent/streaming/reasoning-visibility.d.ts +6 -0
  178. package/dist/src/agent/streaming/{reasoning-visibility-sse.js → reasoning-visibility.js} +3 -6
  179. package/dist/src/agent/tools/delegate-tool.js +5 -1
  180. package/dist/src/agent/tools/executor.js +1 -1
  181. package/dist/src/agent/tools/factory.d.ts +6 -1
  182. package/dist/src/agent/tools/factory.js +17 -22
  183. package/dist/src/agent/tools/index.d.ts +0 -1
  184. package/dist/src/agent/tools/index.js +1 -2
  185. package/dist/src/agent/workflow/workflow-child-tools.js +7 -1
  186. package/dist/src/automations/domain/types.d.ts +2 -1
  187. package/dist/src/automations/domain/validation.d.ts +1 -1
  188. package/dist/src/automations/service/action-executor.js +4 -1
  189. package/dist/src/browser/providers/cloakbrowser.js +1 -1
  190. package/dist/src/channels/channel-domain.d.ts +0 -4
  191. package/dist/src/channels/pairing/pairing-challenge.d.ts +1 -1
  192. package/dist/src/channels/pairing/pairing-challenge.js +1 -1
  193. package/dist/src/channels/plugin-types.d.ts +0 -2
  194. package/dist/src/cli/commands/agent/stream-renderer.js +4 -1
  195. package/dist/src/cli/commands/doctor/checks/database-schema.js +1 -1
  196. package/dist/src/config/rules.js +0 -5
  197. package/dist/src/config/schema.d.ts +3 -5
  198. package/dist/src/config/schema.js +0 -3
  199. package/dist/src/config/web-patch.js +0 -1
  200. package/dist/src/connectors/health.js +1 -1
  201. package/dist/src/endpoint-tools/auth.d.ts +20 -0
  202. package/dist/src/endpoint-tools/auth.js +51 -0
  203. package/dist/src/endpoint-tools/index.d.ts +5 -0
  204. package/dist/src/endpoint-tools/index.js +6 -0
  205. package/dist/src/endpoint-tools/invocation-service.d.ts +68 -0
  206. package/dist/src/endpoint-tools/invocation-service.js +190 -0
  207. package/dist/src/endpoint-tools/policy.d.ts +10 -0
  208. package/dist/src/endpoint-tools/policy.js +18 -0
  209. package/dist/src/endpoint-tools/registry.d.ts +45 -0
  210. package/dist/src/endpoint-tools/registry.js +121 -0
  211. package/dist/src/endpoint-tools/runtime.d.ts +23 -0
  212. package/dist/src/endpoint-tools/runtime.js +86 -0
  213. package/dist/src/endpoint-tools/upload-service.d.ts +41 -0
  214. package/dist/src/endpoint-tools/upload-service.js +103 -0
  215. package/dist/src/extensions/extension-registry-impl.d.ts +3 -1
  216. package/dist/src/extensions/extension-registry-impl.js +7 -1
  217. package/dist/src/extensions/loader.js +1 -1
  218. package/dist/src/extensions/types/core.d.ts +2 -1
  219. package/dist/src/extensions/types/hooks.d.ts +1 -1
  220. package/dist/src/gateway/agent-builtin-tools.d.ts +1 -1
  221. package/dist/src/gateway/agent-builtin-tools.js +5 -2
  222. package/dist/src/gateway/chat-stream/mapper.js +16 -1
  223. package/dist/src/gateway/chat-stream/protocol.d.ts +4 -1
  224. package/dist/src/gateway/clarify-bridge.d.ts +5 -4
  225. package/dist/src/gateway/clarify-bridge.js +3 -4
  226. package/dist/src/gateway/file-reference-errors.d.ts +6 -0
  227. package/dist/src/gateway/file-reference-errors.js +21 -0
  228. package/dist/src/gateway/heartbeat/service.js +5 -2
  229. package/dist/src/gateway/hono/app.js +1 -5
  230. package/dist/src/gateway/hono/index.d.ts +0 -1
  231. package/dist/src/gateway/hono/index.js +1 -2
  232. package/dist/src/gateway/hono/lib/config-payload.d.ts +1 -2
  233. package/dist/src/gateway/hono/lib/config-payload.js +1 -2
  234. package/dist/src/gateway/hono/middleware/auth.js +3 -5
  235. package/dist/src/gateway/hono/routes/agent-stream.js +49 -6
  236. package/dist/src/gateway/hono/routes/config-patch/gateway.d.ts +2 -2
  237. package/dist/src/gateway/hono/routes/config-patch/gateway.js +0 -19
  238. package/dist/src/gateway/hono/routes/config-patch/misc.js +1 -1
  239. package/dist/src/gateway/hono/routes/deps.d.ts +0 -2
  240. package/dist/src/gateway/hono/routes/endpoint-tools.d.ts +3 -0
  241. package/dist/src/gateway/hono/routes/endpoint-tools.js +196 -0
  242. package/dist/src/gateway/hono/routes/index.js +4 -0
  243. package/dist/src/gateway/hono/routes/logs.js +0 -4
  244. package/dist/src/gateway/hono/routes/mcp.js +1 -1
  245. package/dist/src/gateway/hono/routes/projects.js +34 -13
  246. package/dist/src/gateway/hono/routes/public-gateway.js +2 -2
  247. package/dist/src/gateway/hono/routes/realtime.d.ts +3 -0
  248. package/dist/src/gateway/hono/routes/realtime.js +35 -0
  249. package/dist/src/gateway/hono/routes/workspace.js +34 -13
  250. package/dist/src/gateway/hono/routes/you.d.ts +0 -9
  251. package/dist/src/gateway/hono/routes/you.js +81 -128
  252. package/dist/src/gateway/index.d.ts +1 -1
  253. package/dist/src/gateway/index.js +1 -2
  254. package/dist/src/gateway/protocol.d.ts +1 -7
  255. package/dist/src/gateway/security/index.js +1 -1
  256. package/dist/src/gateway/security/operator-scopes.js +1 -1
  257. package/dist/src/gateway/server.js +4 -4
  258. package/dist/src/gateway/service/agent-runner.d.ts +11 -9
  259. package/dist/src/gateway/service/agent-runner.js +18 -18
  260. package/dist/src/gateway/service/config-coordinator.d.ts +2 -2
  261. package/dist/src/gateway/service/config-coordinator.js +1 -1
  262. package/dist/src/gateway/service/run-gateway-agent.d.ts +4 -3
  263. package/dist/src/gateway/service/run-gateway-agent.js +17 -14
  264. package/dist/src/gateway/service/session-input-coordinator.d.ts +3 -0
  265. package/dist/src/gateway/service/session-input-coordinator.js +4 -2
  266. package/dist/src/gateway/service/types.d.ts +0 -5
  267. package/dist/src/gateway/service.d.ts +7 -6
  268. package/dist/src/gateway/service.js +39 -22
  269. package/dist/src/heartbeat/index.js +1 -1
  270. package/dist/src/mcp/channel-bridge.d.ts +6 -9
  271. package/dist/src/mcp/channel-bridge.js +48 -76
  272. package/dist/src/mcp/channel-server.js +2 -6
  273. package/dist/src/realtime/broker.d.ts +30 -0
  274. package/dist/src/realtime/broker.js +97 -0
  275. package/dist/src/realtime/runtime.d.ts +20 -0
  276. package/dist/src/realtime/runtime.js +258 -0
  277. package/dist/src/realtime/tickets.d.ts +15 -0
  278. package/dist/src/realtime/tickets.js +38 -0
  279. package/dist/src/realtime/writer.d.ts +15 -0
  280. package/dist/src/realtime/writer.js +78 -0
  281. package/dist/src/share/share-config.js +0 -1
  282. package/dist/src/share/share-zip.js +1 -1
  283. package/dist/src/share/site-share-config.js +0 -1
  284. package/dist/src/storage/sqlite/endpoint-principal-repository.d.ts +17 -0
  285. package/dist/src/storage/sqlite/endpoint-principal-repository.js +54 -0
  286. package/dist/src/storage/sqlite/endpoint-tool-invocation-repository.d.ts +25 -0
  287. package/dist/src/storage/sqlite/endpoint-tool-invocation-repository.js +42 -0
  288. package/dist/src/storage/sqlite/index.d.ts +2 -0
  289. package/dist/src/storage/sqlite/index.js +3 -1
  290. package/dist/src/storage/sqlite/memory-records-repository.js +3 -1
  291. package/dist/src/storage/sqlite/migrations/108_repair_user_memory_provider.sql +18 -0
  292. package/dist/src/storage/sqlite/migrations/109_endpoint_principals.sql +14 -0
  293. package/dist/src/storage/sqlite/migrations/110_session_input_origin.sql +43 -0
  294. package/dist/src/storage/sqlite/migrations/111_endpoint_tool_invocations.sql +18 -0
  295. package/dist/src/storage/sqlite/migrations/112_endpoint_instance_bindings.sql +8 -0
  296. package/dist/src/storage/sqlite/migrations/runner.d.ts +1 -1
  297. package/dist/src/storage/sqlite/migrations/runner.js +3 -3
  298. package/dist/src/storage/sqlite/migrations/runner.ts +1 -1
  299. package/dist/src/storage/sqlite/schema.js +1 -1
  300. package/dist/src/storage/sqlite/session-input-repository.d.ts +3 -0
  301. package/dist/src/storage/sqlite/session-input-repository.js +5 -3
  302. package/dist/src/tasks/home-query-service.d.ts +1 -1
  303. package/dist/src/tui/backends/embedded-backend.js +5 -2
  304. package/dist/src/tui/backends/{gateway-sse-backend.d.ts → gateway-realtime-backend.d.ts} +13 -10
  305. package/dist/src/tui/backends/{gateway-sse-backend.js → gateway-realtime-backend.js} +114 -151
  306. package/dist/src/tui/tool-summary.d.ts +1 -2
  307. package/dist/src/tui/tool-summary.js +2 -18
  308. package/dist/src/tui/tui-agent-events.d.ts +0 -1
  309. package/dist/src/tui/tui-agent-events.js +2 -15
  310. package/dist/src/tui/tui-backend.d.ts +4 -4
  311. package/dist/src/tui/tui-run-state.js +0 -4
  312. package/dist/src/tui/tui-types.d.ts +2 -9
  313. package/dist/src/tui/tui-types.js +0 -1
  314. package/dist/src/tui/tui.js +5 -5
  315. package/dist/src/tunnel/frpc-binary.js +1 -1
  316. package/dist/src/tunnel/gateway-lifecycle.d.ts +1 -1
  317. package/dist/src/tunnel/gateway-lifecycle.js +1 -1
  318. package/dist/src/user-context/actionableInsights.d.ts +14 -0
  319. package/dist/src/user-context/actionableInsights.js +34 -0
  320. package/dist/src/user-context/manual-understanding.js +6 -1
  321. package/dist/src/user-context/projection.d.ts +2 -1
  322. package/dist/src/user-context/projection.js +2 -1
  323. package/dist/src/user-context/understandingQuality.d.ts +5 -0
  324. package/dist/src/user-context/understandingQuality.js +44 -0
  325. package/dist/src/utils/logger/log-stream.d.ts +3 -10
  326. package/dist/src/utils/logger/log-stream.js +2 -73
  327. package/dist/src/utils/logger/pino-record.d.ts +1 -1
  328. package/dist/src/utils/logger/streams.js +1 -1
  329. package/dist/src/voice/local/model-files.js +1 -1
  330. package/dist/src/work-discovery/service.js +1 -1
  331. package/package.json +6 -3
  332. package/dist/gateway/static/root/assets/agents-Df9mTa-K.js +0 -2
  333. package/dist/gateway/static/root/assets/apps-page-Bd3tN-k2.js +0 -1
  334. package/dist/gateway/static/root/assets/automations-page-w6K9GZQ7.js +0 -6
  335. package/dist/gateway/static/root/assets/browser-settings-page-jb5Hf-hm.js +0 -8
  336. package/dist/gateway/static/root/assets/capabilities-settings-panel-BjUe4raq.js +0 -7
  337. package/dist/gateway/static/root/assets/capability-presets-settings-panel-DiWIMYRr.js +0 -1
  338. package/dist/gateway/static/root/assets/channels-settings-D8IkjMuX.js +0 -1
  339. package/dist/gateway/static/root/assets/channels-status-swr-CySs1GQX.js +0 -1
  340. package/dist/gateway/static/root/assets/connectors-page-BT2ahw52.js +0 -2
  341. package/dist/gateway/static/root/assets/gateway-settings-CIRs2QVy.js +0 -1
  342. package/dist/gateway/static/root/assets/home-page-C59f8UJw.js +0 -3
  343. package/dist/gateway/static/root/assets/index-D-YfWVyS.css +0 -1
  344. package/dist/gateway/static/root/assets/index-vi5KlR5_.js +0 -222
  345. package/dist/gateway/static/root/assets/local-app-workbench-page-DRB4UQBE.js +0 -2
  346. package/dist/gateway/static/root/assets/logs-page-CNp4XiBN.js +0 -7
  347. package/dist/gateway/static/root/assets/messages-CPxz48hr.js +0 -3
  348. package/dist/gateway/static/root/assets/notes-workbench-DqSkeDXX.js +0 -4
  349. package/dist/gateway/static/root/assets/product-delivery-C8JbSj5Y.js +0 -1
  350. package/dist/gateway/static/root/assets/project-detail-page-BrbHs4Wp.js +0 -1
  351. package/dist/gateway/static/root/assets/projects-page-B80rtkj6.js +0 -1
  352. package/dist/gateway/static/root/assets/remote-access-hub-_Q3GEznb.js +0 -1
  353. package/dist/gateway/static/root/assets/sessions-page-55dJOUVg.js +0 -1
  354. package/dist/gateway/static/root/assets/settings-advanced-gate-CSFCZj14.js +0 -1
  355. package/dist/gateway/static/root/assets/settings-page-BSIiMLi-.js +0 -1
  356. package/dist/gateway/static/root/assets/setup-status-panel-q_yE6-H1.js +0 -1
  357. package/dist/gateway/static/root/assets/shares-settings-gYkRX9Ik.js +0 -1
  358. package/dist/gateway/static/root/assets/skill-reload-api-BoNBMKW6.js +0 -1
  359. package/dist/gateway/static/root/assets/skills-page-GZHKDFSb.js +0 -2
  360. package/dist/gateway/static/root/assets/time-picker-5sHEZ5w5.js +0 -1
  361. package/dist/gateway/static/root/assets/user-context-page-q5dr8JFG.js +0 -1
  362. package/dist/gateway/static/root/assets/work-discovery-page-fNvSg40M.js +0 -1
  363. package/dist/gateway/static/root/assets/workflows-page-YJBKmPYK.js +0 -11
  364. package/dist/src/agent/feedback/feedback-coordinator.d.ts +0 -73
  365. package/dist/src/agent/feedback/feedback-coordinator.js +0 -156
  366. package/dist/src/agent/feedback/index.d.ts +0 -4
  367. package/dist/src/agent/feedback/index.js +0 -2
  368. package/dist/src/agent/lifecycle/progress.d.ts +0 -90
  369. package/dist/src/agent/lifecycle/progress.js +0 -339
  370. package/dist/src/agent/mcp/bundle-mcp-materialize.js +0 -183
  371. package/dist/src/agent/mcp/mcp-tool-meta.d.ts +0 -8
  372. package/dist/src/agent/mcp/mcp-tool-meta.js +0 -13
  373. package/dist/src/agent/mcp/resolve-embedded-mcp-tools.d.ts +0 -14
  374. package/dist/src/agent/mcp/resolve-embedded-mcp-tools.js +0 -48
  375. package/dist/src/agent/streaming/reasoning-visibility-sse.d.ts +0 -15
  376. package/dist/src/agent/tools/composio-tool.d.ts +0 -21
  377. package/dist/src/agent/tools/composio-tool.js +0 -261
  378. package/dist/src/gateway/agent-run-relay.d.ts +0 -19
  379. package/dist/src/gateway/agent-run-relay.js +0 -169
  380. package/dist/src/gateway/hono/sse.d.ts +0 -53
  381. package/dist/src/gateway/hono/sse.js +0 -207
  382. package/dist/src/gateway/service/sse-hub.d.ts +0 -10
  383. package/dist/src/gateway/service/sse-hub.js +0 -53
  384. package/dist/src/tui/sse-consumer.d.ts +0 -15
  385. package/dist/src/tui/sse-consumer.js +0 -73
@@ -21,12 +21,12 @@ import { listConnectorCatalog } from "../../../connectors/catalog.js";
21
21
  import { nextDreamingRunTimes } from "../../../agent/memory/dreaming/schedule.js";
22
22
  import { resolveDreamingSettings } from "../../../agent/memory/dreaming/config.js";
23
23
  import { readUserProfileFile, writeUserProfileFile } from "../../agents-admin.js";
24
- import { TaskApplicationService } from "../../../tasks/task-application-service.js";
25
- import { defineTaskContract } from "../../../tasks/task-contract-definition.js";
24
+ import { TaskContextRepository } from "../../../tasks/task-context-repository.js";
26
25
  import "../../../tasks/index.js";
27
- import { nextMemoryReviewAt, resolveMemoryStability } from "../../../agent/memory/lifecycle.js";
28
- import { PERSONAL_PLAYBOOK_DISABLED_TAG, PERSONAL_PLAYBOOK_ORDER_PREFIX, PERSONAL_PLAYBOOK_RULE_TAG, patchPersonalPlaybookContextTags, personalPlaybookContext } from "../../../user-context/personal-playbook.js";
26
+ import { nextMemoryReviewAt } from "../../../agent/memory/lifecycle.js";
29
27
  import { isUserContextMemoryKind, isUserContextRecord, projectPersonalContextSources, projectUserContextRecord, recordsDerivedFromPersonalContextSource } from "../../../user-context/projection.js";
28
+ import { PERSONAL_PLAYBOOK_DISABLED_TAG, PERSONAL_PLAYBOOK_ORDER_PREFIX, PERSONAL_PLAYBOOK_RULE_TAG, patchPersonalPlaybookContextTags, personalPlaybookContext } from "../../../user-context/personal-playbook.js";
29
+ import { INSIGHT_ACCEPTED_TAG, INSIGHT_DISMISSED_TAG, USER_CONFIRMED_MEMORY_TAG, buildActionableInsightSuggestions } from "../../../user-context/actionableInsights.js";
30
30
  import { createManualUnderstanding } from "../../../user-context/manual-understanding.js";
31
31
  import { resolveDreamingAgentScope } from "../../../agent/memory/dreaming/scope.js";
32
32
  import { runDreamingPhase } from "../../../agent/memory/dreaming/runner.js";
@@ -36,7 +36,6 @@ import { renderUserClaim } from "../../../knowledge/connected-understanding-pipe
36
36
  import { prepareUserContextImport } from "../../../user-context/import.js";
37
37
  import { buildUserProfileSetup, parseUserProfileMarkdown, patchUserProfileMarkdown } from "../../../user-context/profile.js";
38
38
  import { buildTaskSourceRecommendations } from "../../../user-context/source-recommendations.js";
39
- import { randomUUID } from "node:crypto";
40
39
  //#region src/gateway/hono/routes/you.ts
41
40
  init_agent_scope();
42
41
  init_config();
@@ -54,15 +53,6 @@ const FEEDBACK_RATINGS = new Set([
54
53
  "outdated",
55
54
  "sensitive"
56
55
  ]);
57
- const ACTIONABLE_INSIGHT_KINDS = new Set([
58
- "routine",
59
- "commitment",
60
- "long_term_goal",
61
- "derived_insight",
62
- "task_lesson"
63
- ]);
64
- const INSIGHT_ACCEPTED_TAG = "insight-action:accepted";
65
- const INSIGHT_DISMISSED_TAG = "insight-action:dismissed";
66
56
  const PLAYBOOK_IDS = [
67
57
  "communication",
68
58
  "execution",
@@ -239,20 +229,6 @@ function buildPersonalPlaybooks(records) {
239
229
  };
240
230
  });
241
231
  }
242
- function buildInsightSuggestions(records) {
243
- return records.filter((record) => record.status === "active").filter((record) => ACTIONABLE_INSIGHT_KINDS.has(record.kind)).filter((record) => !record.tags?.includes(INSIGHT_ACCEPTED_TAG) && !record.tags?.includes(INSIGHT_DISMISSED_TAG)).filter((record) => {
244
- const stability = resolveMemoryStability(record);
245
- return record.explicitness === "explicit" || (record.evidence?.length ?? 0) >= 2 || stability.band === "strong";
246
- }).sort((left, right) => right.importance - left.importance || Date.parse(right.updatedAt) - Date.parse(left.updatedAt)).slice(0, 5).map((record) => ({
247
- id: record.id,
248
- insight: record.content,
249
- kind: record.kind,
250
- action: record.kind === "routine" ? "make_repeatable" : record.kind === "task_lesson" || record.kind === "derived_insight" ? "add_playbook" : "start_progress",
251
- evidenceCount: record.evidence?.length ?? 0,
252
- confidence: record.confidence,
253
- sourceName: record.source.provider ?? "local"
254
- }));
255
- }
256
232
  function buildRoutineAutomationDraftHref(record) {
257
233
  return `/automations?${new URLSearchParams({
258
234
  draft: record.content,
@@ -270,7 +246,7 @@ function editableRecord(recordId) {
270
246
  }
271
247
  function memoryRecordInput(record) {
272
248
  return {
273
- providerId: record.source.provider ?? "local",
249
+ providerId: record.providerId,
274
250
  kind: record.kind,
275
251
  userId: record.scope.userId,
276
252
  sourceAgentId: record.provenance.sourceAgentId,
@@ -350,13 +326,13 @@ function registerYouRoutes(authenticated, deps) {
350
326
  learningJobs: listConnectorLearningJobs({ limit: 500 }),
351
327
  claimStatsBySource: listUserClaimStatsBySource()
352
328
  });
353
- const activeTasks = new TaskRepository().list({ limit: 20 }).flatMap((task) => {
354
- if (task.delegateAgentId !== agentId || task.phase === "closed") return [];
355
- return [{
329
+ const openTasks = new TaskRepository().list({ limit: 500 }).filter((task) => task.delegateAgentId === agentId && task.phase !== "closed");
330
+ const activeTasks = openTasks.slice(0, 20).map((task) => {
331
+ return {
356
332
  id: task.id,
357
333
  title: task.title,
358
334
  body: task.body
359
- }];
335
+ };
360
336
  });
361
337
  return c.json({
362
338
  scope: {
@@ -382,7 +358,10 @@ function registerYouRoutes(authenticated, deps) {
382
358
  return record ? [projectReferenceConsent(consent, record)] : [];
383
359
  }),
384
360
  conflictGroups: buildConflictGroups(allUserContextRecords),
385
- insights: buildInsightSuggestions(records),
361
+ insights: buildActionableInsightSuggestions(records, openTasks.map((task) => [task.title, task.body].filter(Boolean).join("\n"))).map((insight) => ({
362
+ ...insight,
363
+ delegateAgentId: agentId
364
+ })),
386
365
  playbooks: buildPersonalPlaybooks(allUserContextRecords),
387
366
  sources,
388
367
  sourceRecommendations: buildTaskSourceRecommendations(sourceDefinitions, new Set(sourceInstances.map((instance) => instance.connectorId)), activeTasks),
@@ -599,7 +578,7 @@ function registerYouRoutes(authenticated, deps) {
599
578
  const candidate = renderUserClaim(updated);
600
579
  const evidence = listUserClaimEvidence(updated.id);
601
580
  const record = upsertMemoryRecord({
602
- providerId: "connected-understanding",
581
+ providerId: "local",
603
582
  kind: candidate.kind,
604
583
  sourceAgentId: updated.agentId,
605
584
  content: candidate.content,
@@ -615,7 +594,7 @@ function registerYouRoutes(authenticated, deps) {
615
594
  tags: [...new Set([
616
595
  "user-understanding",
617
596
  ...candidate.tags ?? [],
618
- "user-confirmed"
597
+ USER_CONFIRMED_MEMORY_TAG
619
598
  ])],
620
599
  evidence: evidence.map((item) => ({
621
600
  sourceItemId: item.sourceItemId,
@@ -766,7 +745,10 @@ function registerYouRoutes(authenticated, deps) {
766
745
  if (action === "forget") deleteMemoryRecord(id);
767
746
  else preserveRecord(record, {
768
747
  status: action === "confirm" ? "active" : "rejected",
769
- ...action === "confirm" ? { reviewAfter: nextMemoryReviewAt(record) } : {}
748
+ ...action === "confirm" ? {
749
+ reviewAfter: nextMemoryReviewAt(record),
750
+ tags: [...new Set([...record.tags ?? [], USER_CONFIRMED_MEMORY_TAG])]
751
+ } : {}
770
752
  });
771
753
  updatedCount += 1;
772
754
  }
@@ -786,7 +768,8 @@ function registerYouRoutes(authenticated, deps) {
786
768
  runSqliteWriteTransaction(() => {
787
769
  for (const record of group) preserveRecord(record, record.id === winnerId ? {
788
770
  status: "active",
789
- reviewAfter: nextMemoryReviewAt(record)
771
+ reviewAfter: nextMemoryReviewAt(record),
772
+ tags: [...new Set([...record.tags ?? [], USER_CONFIRMED_MEMORY_TAG])]
790
773
  } : {
791
774
  status: "archived",
792
775
  validTo: record.validTo ?? now
@@ -950,106 +933,74 @@ function registerYouRoutes(authenticated, deps) {
950
933
  rule: buildPersonalPlaybooks([...all, rolledBack]).find((playbook) => playbook.id === id)?.rules.find((rule) => rule.id === rolledBack.id)
951
934
  });
952
935
  });
953
- authenticated.patch("/api/you/insights/:id", deps.strictRateLimitMiddleware, async (c) => {
936
+ authenticated.post("/api/you/insights/:id/apply", deps.strictRateLimitMiddleware, async (c) => {
954
937
  const config = deps.service.currentConfig;
955
938
  const existing = editableRecord(c.req.param("id"));
956
- if (!existing || existing.status !== "active" || !ACTIONABLE_INSIGHT_KINDS.has(existing.kind)) return c.json({ error: "Insight not found" }, 404);
957
- const body = await c.req.json().catch(() => ({}));
958
- const action = typeof body.action === "string" ? body.action : "";
959
- if (action === "dismiss") {
960
- preserveRecord(existing, { tags: [...new Set([...existing.tags ?? [], INSIGHT_DISMISSED_TAG])] });
961
- return c.json({
962
- ok: true,
963
- status: "dismissed"
964
- });
965
- }
966
- if (action === "complete" && existing.kind === "routine") {
939
+ const suggestion = existing ? buildActionableInsightSuggestions([existing], [])[0] : void 0;
940
+ if (!existing || !suggestion) return c.json({ error: "Insight not found" }, 404);
941
+ if (suggestion.action === "start_progress") return c.json({ error: "Progress insights must be reviewed as task drafts" }, 400);
942
+ if (existing.kind === "routine") {
967
943
  preserveRecord(existing, { tags: [...new Set([...existing.tags ?? [], INSIGHT_ACCEPTED_TAG])] });
968
944
  return c.json({
969
945
  ok: true,
970
- status: "saved"
946
+ status: "drafting",
947
+ href: buildRoutineAutomationDraftHref(existing)
971
948
  });
972
949
  }
973
- if (action !== "apply") return c.json({ error: "Action must be apply, complete, or dismiss" }, 400);
974
- if (existing.kind === "routine") return c.json({
950
+ upsertMemoryRecord({
951
+ providerId: "local",
952
+ kind: "task_lesson",
953
+ sourceAgentId: selectedAgentId(config),
954
+ content: existing.content,
955
+ source: {
956
+ provider: "local",
957
+ path: "you://insight-proposal"
958
+ },
959
+ confidence: 1,
960
+ tags: [
961
+ "user-understanding",
962
+ USER_CONFIRMED_MEMORY_TAG,
963
+ PERSONAL_PLAYBOOK_RULE_TAG,
964
+ `${PERSONAL_PLAYBOOK_ORDER_PREFIX}1000`
965
+ ],
966
+ status: "active",
967
+ sensitivity: existing.sensitivity,
968
+ explicitness: "explicit",
969
+ durability: "durable",
970
+ importance: existing.importance,
971
+ disclosurePolicy: existing.disclosurePolicy,
972
+ evidence: existing.evidence
973
+ });
974
+ preserveRecord(existing, { tags: [...new Set([...existing.tags ?? [], INSIGHT_ACCEPTED_TAG])] });
975
+ return c.json({
975
976
  ok: true,
976
- status: "drafting",
977
- href: buildRoutineAutomationDraftHref(existing)
977
+ status: "saved"
978
978
  });
979
- if (existing.kind === "task_lesson" || existing.kind === "derived_insight") {
980
- upsertMemoryRecord({
981
- providerId: "local",
982
- kind: "task_lesson",
983
- sourceAgentId: selectedAgentId(config),
984
- content: existing.content,
985
- source: {
986
- provider: "local",
987
- path: "you://insight-proposal"
988
- },
989
- confidence: 1,
990
- tags: [
991
- "user-understanding",
992
- PERSONAL_PLAYBOOK_RULE_TAG,
993
- `${PERSONAL_PLAYBOOK_ORDER_PREFIX}1000`
994
- ],
995
- status: "active",
996
- sensitivity: existing.sensitivity,
997
- explicitness: "explicit",
998
- durability: "durable",
999
- importance: existing.importance,
1000
- disclosurePolicy: existing.disclosurePolicy,
1001
- evidence: existing.evidence
1002
- });
1003
- preserveRecord(existing, { tags: [...new Set([...existing.tags ?? [], INSIGHT_ACCEPTED_TAG])] });
1004
- return c.json({
1005
- ok: true,
1006
- status: "saved"
1007
- });
1008
- }
1009
- const title = existing.content.trim().split(/\r?\n/)[0].slice(0, 72);
1010
- const uiLocale = body.uiLocale === "zh" ? "zh" : "en";
1011
- const contract = defineTaskContract(title);
1012
- const created = new TaskApplicationService().create({
1013
- idempotencyKey: randomUUID(),
1014
- title,
1015
- body: existing.content,
1016
- priority: "normal",
1017
- delegateAgentId: selectedAgentId(config),
1018
- locale: uiLocale,
1019
- contract: {
1020
- ...contract,
1021
- acceptancePolicy: "verified_auto",
1022
- outputDestinations: []
1023
- },
1024
- dependencies: [],
1025
- context: [{
1026
- targetKind: "memory",
1027
- targetId: existing.id,
1028
- role: "input",
1029
- pinned: true,
1030
- retrievalPolicy: {},
1031
- metadata: {}
1032
- }],
1033
- authorityGrants: [],
1034
- activation: {
1035
- mode: "start",
1036
- executor: {
1037
- kind: "agent",
1038
- agentId: selectedAgentId(config)
1039
- }
1040
- }
979
+ });
980
+ authenticated.delete("/api/you/insights/:id", deps.strictRateLimitMiddleware, (c) => {
981
+ const existing = editableRecord(c.req.param("id"));
982
+ const suggestion = existing ? buildActionableInsightSuggestions([existing], [])[0] : void 0;
983
+ if (!existing || !suggestion) return c.json({ error: "Insight not found" }, 404);
984
+ preserveRecord(existing, { tags: [...new Set([...existing.tags ?? [], INSIGHT_DISMISSED_TAG])] });
985
+ return c.json({
986
+ ok: true,
987
+ status: "dismissed"
1041
988
  });
1042
- if (created.ok === false) return c.json({
1043
- ok: false,
1044
- error: created.reason
1045
- }, 409);
1046
- if (created.runId) deps.service.dispatchTaskRuns();
989
+ });
990
+ authenticated.post("/api/you/insights/:id/complete", deps.strictRateLimitMiddleware, async (c) => {
991
+ const existing = editableRecord(c.req.param("id"));
992
+ const suggestion = existing ? buildActionableInsightSuggestions([existing], [])[0] : void 0;
993
+ if (!existing || suggestion?.action !== "start_progress") return c.json({ error: "Insight not found" }, 404);
994
+ const body = await c.req.json().catch(() => ({}));
995
+ const taskId = typeof body.taskId === "string" ? body.taskId.trim() : "";
996
+ const task = taskId ? new TaskRepository().get(taskId) : null;
997
+ const linked = task && new TaskContextRepository().list(task.id).some((edge) => edge.targetKind === "memory" && edge.targetId === existing.id);
998
+ if (!task || !linked) return c.json({ error: "A linked task draft is required" }, 400);
1047
999
  preserveRecord(existing, { tags: [...new Set([...existing.tags ?? [], INSIGHT_ACCEPTED_TAG])] });
1048
1000
  return c.json({
1049
1001
  ok: true,
1050
- status: created.runId ? "queued" : "saved",
1051
- taskId: created.model.task.id,
1052
- href: `/tasks/${encodeURIComponent(created.model.task.id)}`
1002
+ status: "saved",
1003
+ taskId: task.id
1053
1004
  });
1054
1005
  });
1055
1006
  authenticated.patch("/api/you/controls", deps.strictRateLimitMiddleware, async (c) => {
@@ -1160,7 +1111,8 @@ function registerYouRoutes(authenticated, deps) {
1160
1111
  const action = typeof body.action === "string" ? body.action : "";
1161
1112
  if (action === "confirm") return c.json({ understanding: projectUserContextRecord(preserveRecord(existing, {
1162
1113
  status: "active",
1163
- reviewAfter: nextMemoryReviewAt(existing)
1114
+ reviewAfter: nextMemoryReviewAt(existing),
1115
+ tags: [...new Set([...existing.tags ?? [], USER_CONFIRMED_MEMORY_TAG])]
1164
1116
  })) });
1165
1117
  if (action === "reject") return c.json({ understanding: projectUserContextRecord(preserveRecord(existing, { status: "rejected" })) });
1166
1118
  if (action === "update") {
@@ -1179,7 +1131,8 @@ function registerYouRoutes(authenticated, deps) {
1179
1131
  tags: [...new Set([
1180
1132
  ...existing.tags ?? [],
1181
1133
  "user-understanding",
1182
- "explicit-user-correction"
1134
+ "explicit-user-correction",
1135
+ USER_CONFIRMED_MEMORY_TAG
1183
1136
  ])],
1184
1137
  status: "active",
1185
1138
  sensitivity: existing.sensitivity,
@@ -1211,4 +1164,4 @@ function registerYouRoutes(authenticated, deps) {
1211
1164
  });
1212
1165
  }
1213
1166
  //#endregion
1214
- export { buildInsightSuggestions, buildPersonalPlaybooks, buildRoutineAutomationDraftHref, registerYouRoutes };
1167
+ export { buildPersonalPlaybooks, buildRoutineAutomationDraftHref, registerYouRoutes };
@@ -1,5 +1,5 @@
1
1
  export { GatewayServer, type GatewayServerConfig } from './server.js';
2
- export { GatewayService, type GatewayChannelStartupPhase1Metrics, type GatewayChannelStartupPhase2Metrics, type GatewayServiceConfig, type ServiceEvent, } from './service.js';
2
+ export { GatewayService, type GatewayChannelStartupPhase1Metrics, type GatewayChannelStartupPhase2Metrics, type GatewayServiceConfig, } from './service.js';
3
3
  export { acquireGatewayLock, GatewayLockError, type GatewayLockHandle } from './lock.js';
4
4
  export { runGatewayLoop, type RunGatewayLoopOptions } from './run-loop.js';
5
5
  export { restartGatewayProcessWithFreshPid, type GatewayRespawnResult } from './respawn.js';
@@ -8,7 +8,6 @@ import { resolveGatewayListenHost, resolveGatewayListenPlan } from "./listen.js"
8
8
  import { assertGatewayRuntimeConfig } from "./runtime-config.js";
9
9
  import { restartGatewayProcessWithFreshPid } from "./respawn.js";
10
10
  import { GatewayService } from "./service.js";
11
- import { createAgentResumeHandler, createEventsSSEHandler, createSendHandler } from "./hono/sse.js";
12
11
  import { createHonoApp } from "./hono/app.js";
13
12
  import { GatewayServer } from "./server.js";
14
13
  import { GatewayLockError, acquireGatewayLock } from "./lock.js";
@@ -17,4 +16,4 @@ import { checkPortAvailable, forceFreePortAndWait, listPortListeners, parseLsofO
17
16
  import { apiError, apiOk } from "./protocol.js";
18
17
  import "./hono/index.js";
19
18
  import { assertSecureGatewayHttpUrl, assertSecureWebSocketUrl, isInsecurePrivateWsAllowed, isSecureWebSocketUrl } from "./ws-security.js";
20
- export { GatewayLockError, GatewayServer, GatewayService, acquireGatewayLock, apiError, apiOk, assertGatewayAuthConfigured, assertGatewayRuntimeConfig, assertSecureGatewayHttpUrl, assertSecureWebSocketUrl, buckets, buildDefaultCorsOrigins, checkPortAvailable, createAgentResumeHandler, createEventsSSEHandler, createHonoApp, createSendHandler, defaultGatewayBindMode, extractToken, forceFreePortAndWait, isAllInterfacesHost, isContainerEnvironment, isGatewayStrictSecurityEnabled, isInsecurePrivateWsAllowed, isLoopbackHost, isSecureWebSocketUrl, listPortListeners, parseLsofOutput, resolveEffectiveGatewayPort, resolveGatewayAuth, resolveGatewayBindHost, resolveGatewayBindHostSync, resolveGatewayBindMode, resolveGatewayEffectiveHost, resolveGatewayListenHost, resolveGatewayListenPlan, resolveGatewayServiceListenPort, restartGatewayProcessWithFreshPid, runGatewayLoop, validateToken };
19
+ export { GatewayLockError, GatewayServer, GatewayService, acquireGatewayLock, apiError, apiOk, assertGatewayAuthConfigured, assertGatewayRuntimeConfig, assertSecureGatewayHttpUrl, assertSecureWebSocketUrl, buckets, buildDefaultCorsOrigins, checkPortAvailable, createHonoApp, defaultGatewayBindMode, extractToken, forceFreePortAndWait, isAllInterfacesHost, isContainerEnvironment, isGatewayStrictSecurityEnabled, isInsecurePrivateWsAllowed, isLoopbackHost, isSecureWebSocketUrl, listPortListeners, parseLsofOutput, resolveEffectiveGatewayPort, resolveGatewayAuth, resolveGatewayBindHost, resolveGatewayBindHostSync, resolveGatewayBindMode, resolveGatewayEffectiveHost, resolveGatewayListenHost, resolveGatewayListenPlan, resolveGatewayServiceListenPort, restartGatewayProcessWithFreshPid, runGatewayLoop, validateToken };
@@ -1,8 +1,7 @@
1
1
  /**
2
- * Gateway protocol types — Streamable HTTP / SSE transport.
2
+ * Gateway HTTP protocol types.
3
3
  *
4
4
  * All client → server communication uses standard HTTP (POST/GET/PATCH/DELETE).
5
- * Server → client streaming uses SSE (text/event-stream).
6
5
  */
7
6
  export interface ApiResponse<T = unknown> {
8
7
  ok: boolean;
@@ -13,11 +12,6 @@ export interface ApiError {
13
12
  code: string;
14
13
  message: string;
15
14
  }
16
- export interface SSEEvent {
17
- id: string;
18
- event: string;
19
- data: unknown;
20
- }
21
15
  export interface GatewayConfig {
22
16
  host: string;
23
17
  port: number;
@@ -2,9 +2,9 @@ import { safeEqualSecret } from "./secret-equal.js";
2
2
  import { KNOWN_WEAK_GATEWAY_TOKEN_PLACEHOLDERS, assertGatewayAuthNotKnownWeak } from "./known-weak-secrets.js";
3
3
  import { auditGatewayConfig, collectGatewayConfigFindings, collectGatewaySecurityFindings, collectGatewayStartupGuardFindings } from "./audit.js";
4
4
  import { detectSuspiciousPatterns, wrapExternalContent, wrapWebContent } from "./external-content.js";
5
+ import { createPreauthConnectionBudget, getMaxPreauthConnectionsPerIp } from "./preauth-connection-budget.js";
5
6
  import { buildGatewayConsoleCspHeader, computeInlineScriptHashes } from "./csp.js";
6
7
  import { checkBrowserOrigin } from "./origin-check.js";
7
8
  import { ADMIN_SCOPE, DEFAULT_OPERATOR_SCOPES, KNOWN_OPERATOR_SCOPES, READ_SCOPE, WRITE_SCOPE, authorizeRouteScope, authorizeScope, isOperatorScope, parseScopesHeader } from "./operator-scopes.js";
8
9
  import { DEFAULT_GATEWAY_HTTP_TOOL_DENY, filterDangerousHttpTools, isDangerousHttpTool } from "./dangerous-tools.js";
9
- import { createPreauthConnectionBudget, getMaxPreauthConnectionsPerIp } from "./preauth-connection-budget.js";
10
10
  export { ADMIN_SCOPE, DEFAULT_GATEWAY_HTTP_TOOL_DENY, DEFAULT_OPERATOR_SCOPES, KNOWN_OPERATOR_SCOPES, KNOWN_WEAK_GATEWAY_TOKEN_PLACEHOLDERS, READ_SCOPE, WRITE_SCOPE, assertGatewayAuthNotKnownWeak, auditGatewayConfig, authorizeRouteScope, authorizeScope, buildGatewayConsoleCspHeader, checkBrowserOrigin, collectGatewayConfigFindings, collectGatewaySecurityFindings, collectGatewayStartupGuardFindings, computeInlineScriptHashes, createPreauthConnectionBudget, detectSuspiciousPatterns, filterDangerousHttpTools, getMaxPreauthConnectionsPerIp, isDangerousHttpTool, isOperatorScope, parseScopesHeader, safeEqualSecret, wrapExternalContent, wrapWebContent };
@@ -105,7 +105,7 @@ const ROUTE_SCOPE_REQUIREMENTS = [
105
105
  scope: READ_SCOPE
106
106
  },
107
107
  {
108
- prefix: "/api/events",
108
+ prefix: "/api/realtime",
109
109
  scope: READ_SCOPE
110
110
  }
111
111
  ];
@@ -2,7 +2,6 @@ import { resolveGatewayBindHost, resolveGatewayListenHosts } from "../config/gat
2
2
  import { ensureXopcCliOnPath } from "../infra/path-env.js";
3
3
  import { resolveGatewayListenPlan } from "./listen.js";
4
4
  import { GatewayService } from "./service.js";
5
- import { closeAllEventStreams } from "./hono/sse.js";
6
5
  import { handleSiteShareUpgrade } from "../share/site-share-router.js";
7
6
  import { createHonoApp } from "./hono/app.js";
8
7
  import { serve } from "@hono/node-server";
@@ -57,9 +56,11 @@ var GatewayServer = class {
57
56
  const attachUpgrade = (server) => {
58
57
  server.on("upgrade", (req, socket, head) => {
59
58
  try {
60
- handleSiteShareUpgrade(this.service, req, socket, head);
59
+ if (this.service.realtime.handleUpgrade(req, socket, head)) return;
60
+ if (handleSiteShareUpgrade(this.service, req, socket, head)) return;
61
+ socket.destroy();
61
62
  } catch (err) {
62
- console.error("[GatewayServer] site-share upgrade error:", err);
63
+ console.error("[GatewayServer] WebSocket upgrade error:", err);
63
64
  try {
64
65
  socket.destroy();
65
66
  } catch {}
@@ -95,7 +96,6 @@ var GatewayServer = class {
95
96
  }
96
97
  async stop() {
97
98
  console.log("[GatewayServer] Stopping gateway server...");
98
- closeAllEventStreams();
99
99
  const closeServer = async (server) => {
100
100
  if (!server) return;
101
101
  const forceClose = setTimeout(() => {
@@ -1,3 +1,4 @@
1
+ import type { TurnOrigin } from '@xopcai/endpoint-tools-protocol';
1
2
  /**
2
3
  * GatewayAgentRunner — webchat agent invocation and the surrounding control
3
4
  * surface (abort, steer, clarify-bridge plumbing, scheduled Task continuations).
@@ -23,7 +24,7 @@ import type { MessageBus } from '../../infra/bus/index.js';
23
24
  import type { AgentService } from '../../agent/service.js';
24
25
  import type { ChannelManager } from '../../channels/manager.js';
25
26
  import type { SessionIndex } from '../../session/index.js';
26
- import { AgentRunRelay, type RelayEvent } from '../agent-run-relay.js';
27
+ import type { ClarifyStreamEvent } from '../clarify-bridge.js';
27
28
  import { ClarifyBridge, type ClarifyBridgeRequest } from '../clarify-bridge.js';
28
29
  import type { UserTurnAttachment, UserTurnInput } from '../user-turn-input.js';
29
30
  import { SessionInputCoordinator, type SubmitSessionInput } from './session-input-coordinator.js';
@@ -34,12 +35,13 @@ export interface GatewayAgentRunnerOptions {
34
35
  getAgentService: () => AgentService;
35
36
  getChannelManager: () => ChannelManager;
36
37
  getConfig: () => Config;
37
- /** SSE emit (re-used so `runAgent` events broadcast to subscribers). */
38
+ /** Publish low-frequency gateway state changes. */
38
39
  emit: (type: string, payload: unknown) => void;
40
+ publishRealtime: (topic: string, event: string, data: unknown) => void;
41
+ completeRealtimeTopic: (topic: string) => void;
39
42
  }
40
43
  export declare class GatewayAgentRunner {
41
44
  private readonly opts;
42
- readonly runRelay: AgentRunRelay;
43
45
  /** Per-run abort for webchat (POST /api/agent/abort or client disconnect). */
44
46
  private readonly runAbortControllers;
45
47
  private readonly runCompletions;
@@ -55,7 +57,7 @@ export declare class GatewayAgentRunner {
55
57
  getClarifyBridge(): ClarifyBridge;
56
58
  /** Called from `GatewayService.stop()` so the bridge gets cleaned up. */
57
59
  disposeClarifyBridge(): void;
58
- runAgent(message: string, channel: string, chatId: string, attachments?: UserTurnAttachment[], thinking?: string, runOptions?: {
60
+ runAgent(message: string, channel: string, chatId: string, origin: TurnOrigin, attachments?: UserTurnAttachment[], thinking?: string, runOptions?: {
59
61
  signal?: AbortSignal;
60
62
  runId?: string;
61
63
  }): AsyncGenerator<{
@@ -89,7 +91,7 @@ export declare class GatewayAgentRunner {
89
91
  state: import("../../storage/sqlite/session-input-repository.js").SessionInputState;
90
92
  };
91
93
  recoverSessionInputs(): void;
92
- /** Abort an in-flight webchat agent run (matches `runId` from SSE `run_start`). */
94
+ /** Abort an in-flight webchat agent run. */
93
95
  abortAgentRun(runId: string): Promise<{
94
96
  aborted: boolean;
95
97
  idle: boolean;
@@ -103,17 +105,17 @@ export declare class GatewayAgentRunner {
103
105
  drainScheduledWebchatContinuation(sessionKey: string, message: string): Promise<void>;
104
106
  /**
105
107
  * Resolve clarify-bridge config for `sessionKey`: who delivers the question
106
- * (webchat SSE, Telegram message, or both), then start the bridge request.
108
+ * (webchat stream, Telegram message, or both), then start the bridge request.
107
109
  * Rejects when neither path is available (e.g. CLI without webchat or TG).
108
110
  *
109
- * `publishSseFor(runId)` is the bridge into AgentService's
110
- * `turnDispatcher.enqueueWebchatSseEvent`. We take it as a callback so the
111
+ * `publishStreamFor(runId)` is the bridge into AgentService's
112
+ * `turnDispatcher.enqueueWebchatStreamEvent`. We take it as a callback so the
111
113
  * runner does not import AgentService statically.
112
114
  */
113
115
  requestClarification(opts: {
114
116
  sessionKey: string;
115
117
  request: ClarifyBridgeRequest;
116
- publishSseFor: (runId: string) => (e: RelayEvent) => void;
118
+ publishStreamFor: (runId: string) => (event: ClarifyStreamEvent) => void;
117
119
  }): Promise<string>;
118
120
  private deliverTelegramClarify;
119
121
  }
@@ -1,6 +1,5 @@
1
1
  import { createLogger } from "../../utils/logger/index.js";
2
2
  import { init_logger } from "../../utils/logger.js";
3
- import { AgentRunRelay } from "../agent-run-relay.js";
4
3
  import { ClarifyBridge } from "../clarify-bridge.js";
5
4
  import { runGatewayAgent } from "./run-gateway-agent.js";
6
5
  import { SessionInputCoordinator } from "./session-input-coordinator.js";
@@ -10,7 +9,6 @@ init_logger();
10
9
  const log = createLogger("Gateway:AgentRunner");
11
10
  var GatewayAgentRunner = class {
12
11
  opts;
13
- runRelay = new AgentRunRelay();
14
12
  /** Per-run abort for webchat (POST /api/agent/abort or client disconnect). */
15
13
  runAbortControllers = /* @__PURE__ */ new Map();
16
14
  runCompletions = /* @__PURE__ */ new Map();
@@ -24,7 +22,7 @@ var GatewayAgentRunner = class {
24
22
  this.inputs = new SessionInputCoordinator({
25
23
  sessionExists: async (sessionKey) => Boolean(await opts.sessionIndex.getSessionMetadata(sessionKey)),
26
24
  execute: async (input) => {
27
- const generator = this.runAgent(input.content, "webchat", input.sessionKey, input.attachments, input.thinking, { runId: input.runId });
25
+ const generator = this.runAgent(input.content, "webchat", input.sessionKey, input.origin, input.attachments, input.thinking, { runId: input.runId });
28
26
  let result;
29
27
  while (true) {
30
28
  const step = await generator.next();
@@ -65,7 +63,7 @@ var GatewayAgentRunner = class {
65
63
  disposeClarifyBridge() {
66
64
  this.clarifyBridge.dispose();
67
65
  }
68
- async *runAgent(message, channel, chatId, attachments, thinking, runOptions) {
66
+ async *runAgent(message, channel, chatId, origin, attachments, thinking, runOptions) {
69
67
  const trackedRunId = runOptions?.runId;
70
68
  if (trackedRunId) {
71
69
  let resolve = () => {};
@@ -78,12 +76,13 @@ var GatewayAgentRunner = class {
78
76
  config: this.opts.getConfig(),
79
77
  agentService: this.opts.getAgentService(),
80
78
  bus: this.opts.bus,
81
- runRelay: this.runRelay,
82
79
  runAbortControllers: this.runAbortControllers,
83
80
  activeWebchatRunBySession: this.activeWebchatRunBySession,
84
81
  sessionIndex: this.opts.sessionIndex,
85
- emit: this.opts.emit
86
- }, message, channel, chatId, attachments, thinking, runOptions);
82
+ emit: this.opts.emit,
83
+ publishRealtime: this.opts.publishRealtime,
84
+ completeRealtimeTopic: this.opts.completeRealtimeTopic
85
+ }, message, channel, chatId, origin, attachments, thinking, runOptions);
87
86
  try {
88
87
  let step = await iter.next();
89
88
  while (!step.done) {
@@ -114,13 +113,11 @@ var GatewayAgentRunner = class {
114
113
  recoverSessionInputs() {
115
114
  this.inputs.recover();
116
115
  }
117
- /** Abort an in-flight webchat agent run (matches `runId` from SSE `run_start`). */
116
+ /** Abort an in-flight webchat agent run. */
118
117
  async abortAgentRun(runId) {
119
118
  this.clarifyBridge.cancelForRun(runId);
120
119
  const keysToMark = [];
121
120
  for (const [sk, id] of this.activeWebchatRunBySession) if (id === runId) keysToMark.push(sk);
122
- const relaySk = this.runRelay.getSessionKey(runId);
123
- if (relaySk && !keysToMark.includes(relaySk)) keysToMark.push(relaySk);
124
121
  const c = this.runAbortControllers.get(runId);
125
122
  if (!c) return {
126
123
  aborted: false,
@@ -152,7 +149,11 @@ var GatewayAgentRunner = class {
152
149
  clientMessageId,
153
150
  delivery: "next",
154
151
  content: userTurn.text,
155
- attachments: userTurn.attachments
152
+ attachments: userTurn.attachments,
153
+ origin: {
154
+ type: "system",
155
+ source: "workflow"
156
+ }
156
157
  });
157
158
  if (accepted.ok === false) throw new Error(`Scheduled session input was rejected: ${accepted.code}`);
158
159
  await this.inputs.waitForCompletion(sessionKey, clientMessageId);
@@ -173,17 +174,17 @@ var GatewayAgentRunner = class {
173
174
  }
174
175
  /**
175
176
  * Resolve clarify-bridge config for `sessionKey`: who delivers the question
176
- * (webchat SSE, Telegram message, or both), then start the bridge request.
177
+ * (webchat stream, Telegram message, or both), then start the bridge request.
177
178
  * Rejects when neither path is available (e.g. CLI without webchat or TG).
178
179
  *
179
- * `publishSseFor(runId)` is the bridge into AgentService's
180
- * `turnDispatcher.enqueueWebchatSseEvent`. We take it as a callback so the
180
+ * `publishStreamFor(runId)` is the bridge into AgentService's
181
+ * `turnDispatcher.enqueueWebchatStreamEvent`. We take it as a callback so the
181
182
  * runner does not import AgentService statically.
182
183
  */
183
184
  async requestClarification(opts) {
184
- const { sessionKey, request, publishSseFor } = opts;
185
+ const { sessionKey, request, publishStreamFor } = opts;
185
186
  const runId = this.activeWebchatRunBySession.get(sessionKey);
186
- const publishSse = runId ? publishSseFor(runId) : void 0;
187
+ const publishStream = runId ? publishStreamFor(runId) : void 0;
187
188
  const deliver = ((await this.opts.sessionIndex.getSessionMetadata(sessionKey).catch(() => null))?.routing)?.source === "telegram" ? async (ctx) => {
188
189
  await this.deliverTelegramClarify(ctx);
189
190
  } : void 0;
@@ -191,8 +192,7 @@ var GatewayAgentRunner = class {
191
192
  return this.clarifyBridge.startRequest({
192
193
  sessionKey,
193
194
  runId,
194
- relay: this.runRelay,
195
- publishSse,
195
+ publishStream,
196
196
  request,
197
197
  deliver
198
198
  });
@@ -45,9 +45,9 @@ export interface GatewayConfigCoordinatorOptions {
45
45
  reconcileBrowserExtensionServer: () => Promise<void>;
46
46
  /** Sync built-in dreaming automations after memory.dreaming changes. */
47
47
  reconcileDreamingAutomations: () => Promise<void>;
48
- /** Latest channel status snapshot for the `channels.status` SSE event. */
48
+ /** Latest channel status snapshot for the `channels.status` event. */
49
49
  getChannelsStatus: () => unknown;
50
- /** SSE emit (used for `config.reload` + `channels.status`). */
50
+ /** Realtime emit used for `config.reload` and `channels.status`. */
51
51
  emit: (type: string, payload: unknown) => void;
52
52
  }
53
53
  export declare class GatewayConfigCoordinator {
@@ -3,9 +3,9 @@ import { init_logger } from "../../utils/logger.js";
3
3
  import { loadConfig, saveConfig } from "../../config/loader.js";
4
4
  import { getModelRegistry } from "../../providers/model-registry.js";
5
5
  import { init_providers } from "../../providers/index.js";
6
+ import { disposeAllSessionMcpRuntimes } from "../../agent/mcp/bundle-mcp-runtime.js";
6
7
  import { sanitizeTunnelConfig } from "../../tunnel/tunnel-config.js";
7
8
  import { reloadImageGenerationProviders } from "../../agent/image/generation/provider-registry.js";
8
- import { disposeAllSessionMcpRuntimes } from "../../agent/mcp/bundle-mcp-runtime.js";
9
9
  import "../../agent/mcp/bundle-mcp-tools.js";
10
10
  import { ConfigHotReloader } from "../../config/reload.js";
11
11
  import "../../config/index.js";