@xopcai/xopc 0.0.460 → 0.0.463

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 (319) hide show
  1. package/dist/browser-ext/_locales/en/messages.json +1 -0
  2. package/dist/browser-ext/_locales/zh_CN/messages.json +1 -0
  3. package/dist/browser-ext/dist/assets/{auth-CQmxIyWw.js → auth-YPMDpWOW.js} +32 -1
  4. package/dist/browser-ext/dist/assets/{pcm-capture-worklet-CGN9Mlhg.js → pcm-capture-worklet-Df5TcFw4.js} +4 -2
  5. package/dist/browser-ext/dist/background.js +24 -19
  6. package/dist/browser-ext/dist/sidepanel.html +1 -1
  7. package/dist/browser-ext/dist/sidepanel.js +10 -9
  8. package/dist/browser-ext/manifest.json +1 -1
  9. package/dist/extensions/telegram/xopc.extension.json +1 -1
  10. package/dist/gateway/static/root/assets/agent-plugin-dialog-C_rlXuEe.js +1 -0
  11. package/dist/gateway/static/root/assets/{agents-CGUdvmIT.js → agents-DC0lHtl5.js} +3 -3
  12. package/dist/gateway/static/root/assets/{apps-page-M2XD1Pzu.js → apps-page-D1qzENN_.js} +1 -1
  13. package/dist/gateway/static/root/assets/{automation-task-card-CiJmJ7_h.js → automation-task-card-CJbIHRxN.js} +1 -1
  14. package/dist/gateway/static/root/assets/{automations-page-CVjgENMO.js → automations-page-HYFnPiNG.js} +1 -1
  15. package/dist/gateway/static/root/assets/{automations-workspace-CGPWyL0P.js → automations-workspace-JCQ1IXFk.js} +2 -2
  16. package/dist/gateway/static/root/assets/{block-editor-CmnkluMF.js → block-editor-DrZyRQQ0.js} +5 -5
  17. package/dist/gateway/static/root/assets/{capabilities-DDqDvCBs.js → capabilities-Dr-vvMez.js} +1 -1
  18. package/dist/gateway/static/root/assets/capabilities-hSb-qEgL.js +1 -0
  19. package/dist/gateway/static/root/assets/capabilities-page-kPv2dOzf.js +2 -0
  20. package/dist/gateway/static/root/assets/{capabilities-settings-panel-CvF8VRTv.js → capabilities-settings-panel-B08mjrGB.js} +1 -1
  21. package/dist/gateway/static/root/assets/{channels-BDVQ6Z7A.js → channels-B--IHNs4.js} +1 -1
  22. package/dist/gateway/static/root/assets/{chat-chart-block-stPJEZ90.js → chat-chart-block-ClCZyIi0.js} +1 -1
  23. package/dist/gateway/static/root/assets/chat-page-CalELOKj.js +71 -0
  24. package/dist/gateway/static/root/assets/{chat-terminal-dock-B4uA_W6R.js → chat-terminal-dock-eneTvxV3.js} +1 -1
  25. package/dist/gateway/static/root/assets/{connectors-page-DyzDVVfz.js → connectors-page-B9mpz_Rt.js} +1 -1
  26. package/dist/gateway/static/root/assets/constants-Bg1wM2nv.js +1 -0
  27. package/dist/gateway/static/root/assets/diagnostics-Bo0Z42P_.js +1 -0
  28. package/dist/gateway/static/root/assets/{extension-debug-page-BPwRrP3L.js → extension-debug-page-Bn_5xu_M.js} +1 -1
  29. package/dist/gateway/static/root/assets/{extension-iframe-host-DIH4TcdH.js → extension-iframe-host-Vs6USa0c.js} +1 -1
  30. package/dist/gateway/static/root/assets/{extension-message-router-C9JDpo_7.js → extension-message-router-GIekDj_w.js} +1 -1
  31. package/dist/gateway/static/root/assets/{extension-page-CLDoL5N8.js → extension-page-C_3bIjSB.js} +1 -1
  32. package/dist/gateway/static/root/assets/{extension-provider-BPIoHw4r.js → extension-provider-D-LolObs.js} +1 -1
  33. package/dist/gateway/static/root/assets/{extension-settings-page-BO_UKeG8.js → extension-settings-page-BV51dk16.js} +1 -1
  34. package/dist/gateway/static/root/assets/home-page-DefKShSW.js +8 -0
  35. package/dist/gateway/static/root/assets/index-CChzK_5b.css +1 -0
  36. package/dist/gateway/static/root/assets/index-DUo6H0PC.js +11 -0
  37. package/dist/gateway/static/root/assets/{local-app-workbench-page-D8oqDDAn.js → local-app-workbench-page-CfnixDO3.js} +1 -1
  38. package/dist/gateway/static/root/assets/{markdown-view-BlxIaCCQ.js → markdown-view-CNJaAdNN.js} +39 -39
  39. package/dist/gateway/static/root/assets/mcp-conversation-setup-page-DCIEL5bA.js +1 -0
  40. package/dist/gateway/static/root/assets/note-detail-panel-DsXb1qjW.js +7 -0
  41. package/dist/gateway/static/root/assets/note-image-lightbox-D6mvMSKr.js +1 -0
  42. package/dist/gateway/static/root/assets/{notes-api-CdXA-g9r.js → notes-api-BOIM9Q_D.js} +1 -1
  43. package/dist/gateway/static/root/assets/notes-page-BTpiOw67.js +8 -0
  44. package/dist/gateway/static/root/assets/{page-context-capture-button-Dibmspef.js → page-context-capture-button-B_Vdo2Ai.js} +1 -1
  45. package/dist/gateway/static/root/assets/pcm-capture-worklet-CpXsv44v.js +1 -0
  46. package/dist/gateway/static/root/assets/{personal-page-BwfyW7Hx.js → personal-page-I3IGVSJh.js} +1 -1
  47. package/dist/gateway/static/root/assets/{personal-profile-settings-CQhZjoK6.js → personal-profile-settings-C4CxmQLQ.js} +1 -1
  48. package/dist/gateway/static/root/assets/{personal-settings-panel-peD05ktj.js → personal-settings-panel-CnxI2TL0.js} +1 -1
  49. package/dist/gateway/static/root/assets/{plugin-details-dialog-nSDw8sfo.js → plugin-details-dialog-F08k_k2u.js} +1 -1
  50. package/dist/gateway/static/root/assets/{product-automation-feedback-D51I7Lg3.js → product-automation-feedback-CGso8wGv.js} +1 -1
  51. package/dist/gateway/static/root/assets/{product-preview-content-WkF2j_c-.js → product-preview-content-Dgtb4LF7.js} +1 -1
  52. package/dist/gateway/static/root/assets/product-preview-modal-C35EWUps.js +2 -0
  53. package/dist/gateway/static/root/assets/project-detail-page-Dy46uSEt.js +7 -0
  54. package/dist/gateway/static/root/assets/recording-upload-CFX7CANT.js +1 -0
  55. package/dist/gateway/static/root/assets/route-preload-ChTaYgpA.js +2 -0
  56. package/dist/gateway/static/root/assets/routine-panel-KH1VaEdC.js +2 -0
  57. package/dist/gateway/static/root/assets/{service-recommendation-list-DDlMyPvC.js → service-recommendation-list-BmRtbJz2.js} +1 -1
  58. package/dist/gateway/static/root/assets/session-manager-63NaXb1s.js +25 -0
  59. package/dist/gateway/static/root/assets/{settings-page-BHImcF1q.js → settings-page-C39lKVRv.js} +1 -1
  60. package/dist/gateway/static/root/assets/{share-preview-page-fV5USZb1.js → share-preview-page-Cqy-7-rd.js} +1 -1
  61. package/dist/gateway/static/root/assets/{shares-settings-sl40lqND.js → shares-settings-BDr50uTV.js} +1 -1
  62. package/dist/gateway/static/root/assets/{skills-page-FTd0Z7Ey.js → skills-page-DReUQ4Ug.js} +1 -1
  63. package/dist/gateway/static/root/assets/star-CnYNmpLd.js +1 -0
  64. package/dist/gateway/static/root/assets/task-detail-page-D1dNWTnP.js +3 -0
  65. package/dist/gateway/static/root/assets/{task-result-evidence-CSJeB9AH.js → task-result-evidence-CW_tN93T.js} +1 -1
  66. package/dist/gateway/static/root/assets/{use-composer-attachments-CO7XLI4x.js → use-composer-attachments-Xn6eUus2.js} +1 -1
  67. package/dist/gateway/static/root/assets/{use-file-preview-expanded-BXXeXnT0.js → use-file-preview-expanded-D0IBFhM9.js} +1 -1
  68. package/dist/gateway/static/root/assets/use-realtime-voice-B5IsKrRW.js +1 -0
  69. package/dist/gateway/static/root/assets/{use-workspace-tree-D27u-eoX.js → use-workspace-tree-7X2ydgS8.js} +1 -1
  70. package/dist/gateway/static/root/assets/{voice-settings-BiqJ0tlf.js → voice-settings-57pwZeKD.js} +1 -1
  71. package/dist/gateway/static/root/assets/{work-discovery-overlay-UvWbDUXi.js → work-discovery-overlay-BJ15p4rH.js} +1 -1
  72. package/dist/gateway/static/root/assets/{work-discovery-page-BM1HsYz6.js → work-discovery-page-8XciWNs5.js} +1 -1
  73. package/dist/gateway/static/root/assets/workspace-api-Dd_UDfeo.js +2 -0
  74. package/dist/gateway/static/root/assets/{workspace-file-preview-dialog-NffP-UXC.js → workspace-file-preview-dialog-Clj9hMj5.js} +1 -1
  75. package/dist/gateway/static/root/assets/{workspace-preview-store-Do31QQH5.js → workspace-preview-store-imhtuEIP.js} +1 -1
  76. package/dist/gateway/static/root/index.html +30 -29
  77. package/dist/package.js +1 -1
  78. package/dist/packages/gateway-contract/src/follow-ups.js +97 -0
  79. package/dist/packages/gateway-contract/src/home.js +1 -0
  80. package/dist/packages/gateway-contract/src/index.js +4 -0
  81. package/dist/packages/gateway-contract/src/observation-starters.js +95 -0
  82. package/dist/packages/gateway-contract/src/observation.js +7 -0
  83. package/dist/packages/gateway-contract/src/task-research-result.js +3 -0
  84. package/dist/src/agent/agent-manager.d.ts +1 -1
  85. package/dist/src/agent/background-review/prompts.d.ts +1 -0
  86. package/dist/src/agent/background-review/prompts.js +7 -1
  87. package/dist/src/agent/background-review/run-background-review.js +85 -7
  88. package/dist/src/agent/coding/run-verification.d.ts +14 -7
  89. package/dist/src/agent/coding/run-verification.js +28 -6
  90. package/dist/src/agent/context/coordinator.js +1 -1
  91. package/dist/src/agent/context/deep-recall.js +1 -1
  92. package/dist/src/agent/embedded/execution-tool-policy.d.ts +1 -0
  93. package/dist/src/agent/embedded/execution-tool-policy.js +4 -2
  94. package/dist/src/agent/embedded/run-for-session.d.ts +2 -0
  95. package/dist/src/agent/embedded/run-for-session.js +9 -0
  96. package/dist/src/agent/embedded/run-turn.js +63 -14
  97. package/dist/src/agent/embedded/session-runner.js +2 -2
  98. package/dist/src/agent/embedded/types.d.ts +2 -0
  99. package/dist/src/agent/external-tools/gateway-tools.js +8 -1
  100. package/dist/src/agent/inbound/turn-dispatcher.d.ts +1 -0
  101. package/dist/src/agent/inbound/turn-dispatcher.js +1 -0
  102. package/dist/src/agent/mcp/connection-setup.js +46 -42
  103. package/dist/src/agent/mcp/conversation-setup.js +13 -8
  104. package/dist/src/agent/mcp/discovery.d.ts +22 -1
  105. package/dist/src/agent/mcp/discovery.js +19 -3
  106. package/dist/src/agent/mcp/managed-discovery.d.ts +8 -0
  107. package/dist/src/agent/mcp/managed-discovery.js +77 -0
  108. package/dist/src/agent/mcp/tool-catalog.js +1 -1
  109. package/dist/src/agent/prompt/conversational-configuration-guide.js +1 -1
  110. package/dist/src/agent/service/direct-turn-helpers.d.ts +1 -0
  111. package/dist/src/agent/service/direct-turn-helpers.js +17 -2
  112. package/dist/src/agent/service/process-direct-streaming.d.ts +1 -0
  113. package/dist/src/agent/service/process-direct-streaming.js +1 -0
  114. package/dist/src/agent/service.d.ts +1 -1
  115. package/dist/src/agent/skills/marketplace/adapters/store/store-api-client.d.ts +6 -2
  116. package/dist/src/agent/skills/marketplace/adapters/store/store-api-client.js +10 -7
  117. package/dist/src/agent/tasks/task-judge-service.js +1 -0
  118. package/dist/src/agent/tool-manuals/browser.d.ts +1 -1
  119. package/dist/src/agent/tool-manuals/browser.js +3 -1
  120. package/dist/src/agent/tool-manuals/xopc-configuration.d.ts +1 -1
  121. package/dist/src/agent/tool-manuals/xopc-configuration.js +12 -4
  122. package/dist/src/agent/tools/factory.d.ts +1 -1
  123. package/dist/src/agent/tools/factory.js +1 -1
  124. package/dist/src/agent/tools/personal-request-tool.js +36 -4
  125. package/dist/src/agent/tools/personal-task-tool.d.ts +7 -1
  126. package/dist/src/agent/tools/personal-task-tool.js +68 -3
  127. package/dist/src/agent/tools/session-search-tool.js +1 -1
  128. package/dist/src/agent/tools/task-collaboration-tool.d.ts +1 -1
  129. package/dist/src/agent/tools/task-collaboration-tool.js +54 -3
  130. package/dist/src/agent/tools/task-result-tool.js +31 -0
  131. package/dist/src/agent/tools/xopc-use-tool.js +50 -19
  132. package/dist/src/automations/capabilities/write.d.ts +2 -2
  133. package/dist/src/automations/domain/validation.d.ts +4 -4
  134. package/dist/src/automations/draft/automation-draft-validator.d.ts +1 -1
  135. package/dist/src/browser/drivers/browser-driver.d.ts +1 -0
  136. package/dist/src/browser/drivers/create-driver.js +2 -11
  137. package/dist/src/browser/drivers/playwright-driver.d.ts +5 -2
  138. package/dist/src/browser/drivers/playwright-driver.js +83 -38
  139. package/dist/src/browser/runtime/browser-runtime.d.ts +5 -0
  140. package/dist/src/browser/runtime/browser-runtime.js +71 -9
  141. package/dist/src/cli/commands/doctor/checks/database-schema.js +1 -1
  142. package/dist/src/cli/commands/extension-agent-plugin.js +1 -1
  143. package/dist/src/cli/commands/gateway/lifecycle.js +2 -2
  144. package/dist/src/cli/commands/update.js +1 -1
  145. package/dist/src/computer/diagnostics.d.ts +4 -4
  146. package/dist/src/computer/errors.d.ts +4 -4
  147. package/dist/src/computer/evaluation.d.ts +3 -3
  148. package/dist/src/computer/flows.d.ts +1 -1
  149. package/dist/src/computer/runtime.d.ts +3 -3
  150. package/dist/src/config/schema.d.ts +6 -2
  151. package/dist/src/config/schema.js +3 -0
  152. package/dist/src/connectors/connected-source-understanding.js +11 -3
  153. package/dist/src/connectors/connection-recovery-service.js +38 -5
  154. package/dist/src/connectors/excluded-connectors.d.ts +1 -0
  155. package/dist/src/connectors/excluded-connectors.js +5 -1
  156. package/dist/src/connectors/learning-coordinator.js +45 -11
  157. package/dist/src/connectors/plugin-connection.d.ts +10 -0
  158. package/dist/src/connectors/plugin-connection.js +105 -0
  159. package/dist/src/discussions/recording.js +13 -6
  160. package/dist/src/endpoint-tools/device-host.d.ts +2 -2
  161. package/dist/src/extensions/agent-plugins/setup.js +1 -1
  162. package/dist/src/extensions/agent-plugins/skill-catalog.js +1 -1
  163. package/dist/src/gateway/hono/lib/config-payload.d.ts +4 -0
  164. package/dist/src/gateway/hono/middleware/auth.js +1 -1
  165. package/dist/src/gateway/hono/routes/agent-plugins.js +2 -2
  166. package/dist/src/gateway/hono/routes/auth-registry-extensions.js +1 -1
  167. package/dist/src/gateway/hono/routes/connectors.js +1 -1
  168. package/dist/src/gateway/hono/routes/desktop-host.js +1 -1
  169. package/dist/src/gateway/hono/routes/home.js +51 -0
  170. package/dist/src/gateway/hono/routes/imports.js +1 -1
  171. package/dist/src/gateway/hono/routes/personal-agent.js +3 -3
  172. package/dist/src/gateway/hono/routes/projects.js +1 -1
  173. package/dist/src/gateway/hono/routes/session-command-handler.js +15 -1
  174. package/dist/src/gateway/hono/routes/update.js +2 -2
  175. package/dist/src/gateway/hono/routes/user-model.js +1 -1
  176. package/dist/src/gateway/index.js +1 -1
  177. package/dist/src/gateway/run-loop.js +2 -2
  178. package/dist/src/gateway/security/gateway-scopes.js +1 -0
  179. package/dist/src/gateway/service/agent-runner.d.ts +2 -8
  180. package/dist/src/gateway/service/agent-runner.js +2 -1
  181. package/dist/src/gateway/service/config-coordinator.d.ts +5 -1
  182. package/dist/src/gateway/service/run-gateway-agent.d.ts +13 -8
  183. package/dist/src/gateway/service/run-gateway-agent.js +6 -3
  184. package/dist/src/gateway/service/session-input-coordinator.d.ts +4 -0
  185. package/dist/src/gateway/service/session-input-coordinator.js +6 -1
  186. package/dist/src/gateway/service.d.ts +1 -0
  187. package/dist/src/gateway/service.js +19 -12
  188. package/dist/src/home-intelligence/follow-ups.d.ts +36 -0
  189. package/dist/src/home-intelligence/follow-ups.js +496 -0
  190. package/dist/src/home-intelligence/host.d.ts +80 -4
  191. package/dist/src/home-intelligence/host.js +124 -4
  192. package/dist/src/home-intelligence/observation-starters.d.ts +3 -0
  193. package/dist/src/home-intelligence/observation-starters.js +27 -0
  194. package/dist/src/home-intelligence/observation.d.ts +1 -1
  195. package/dist/src/home-intelligence/observation.js +16 -4
  196. package/dist/src/infra/gateway-processes.js +1 -1
  197. package/dist/src/infra/update-restart.js +2 -2
  198. package/dist/src/infra/update-runner.js +2 -2
  199. package/dist/src/infra/update-startup.js +1 -1
  200. package/dist/src/local-apps/automation-proposals.d.ts +4 -4
  201. package/dist/src/local-apps/capabilities/projections.d.ts +38 -38
  202. package/dist/src/memory-learning/choice-observations.d.ts +9 -0
  203. package/dist/src/memory-learning/choice-observations.js +155 -0
  204. package/dist/src/memory-learning/evidence-repair.d.ts +12 -0
  205. package/dist/src/memory-learning/evidence-repair.js +31 -0
  206. package/dist/src/memory-learning/repository.d.ts +1 -0
  207. package/dist/src/memory-learning/repository.js +43 -5
  208. package/dist/src/memory-learning/source-learning.js +52 -7
  209. package/dist/src/memory-learning/task-receipts.js +19 -10
  210. package/dist/src/memory-learning/transcript-source.js +7 -0
  211. package/dist/src/memory-learning/work-candidate.d.ts +14 -0
  212. package/dist/src/memory-learning/work-candidate.js +17 -2
  213. package/dist/src/memory-learning/work-capture.d.ts +1 -0
  214. package/dist/src/memory-learning/work-capture.js +28 -10
  215. package/dist/src/memory-learning/work-review.d.ts +46 -0
  216. package/dist/src/memory-learning/work-review.js +209 -0
  217. package/dist/src/notes/agent-context.js +1 -1
  218. package/dist/src/notifications/service.js +2 -2
  219. package/dist/src/personal-agent/communication.d.ts +1 -1
  220. package/dist/src/personal-agent/communication.js +1 -1
  221. package/dist/src/personal-agent/default-style.d.ts +1 -1
  222. package/dist/src/personal-agent/default-style.js +1 -1
  223. package/dist/src/personal-agent/proactivity/repository.d.ts +1 -1
  224. package/dist/src/personal-agent/prompts.js +4 -4
  225. package/dist/src/personal-agent/reply-composer.d.ts +1 -1
  226. package/dist/src/personal-agent/reply-composer.js +52 -34
  227. package/dist/src/personal-agent/reply-style.d.ts +2 -2
  228. package/dist/src/personal-agent/reply-style.js +3 -2
  229. package/dist/src/personal-agent/request-repository.d.ts +3 -0
  230. package/dist/src/personal-agent/request-service.d.ts +2 -0
  231. package/dist/src/personal-agent/request-service.js +8 -2
  232. package/dist/src/phone/contracts.d.ts +1 -1
  233. package/dist/src/phone/stream-gateway.js +1 -1
  234. package/dist/src/projects/capabilities/write.js +1 -1
  235. package/dist/src/projects/index.js +1 -1
  236. package/dist/src/projects/project-service.js +1 -1
  237. package/dist/src/storage/sqlite/schema.d.ts +2 -2
  238. package/dist/src/storage/sqlite/schema.js +7 -7
  239. package/dist/src/storage/sqlite/schema.sql +22 -0
  240. package/dist/src/storage/sqlite/upgrades/274_home_followups.sql +21 -0
  241. package/dist/src/tasks/capabilities/management.d.ts +3 -3
  242. package/dist/src/tasks/capabilities/relations.d.ts +3 -3
  243. package/dist/src/tasks/capabilities/write.d.ts +4 -4
  244. package/dist/src/tasks/capabilities/write.js +2 -0
  245. package/dist/src/tasks/home-query-service.js +4 -2
  246. package/dist/src/tasks/task-allocation-service.js +10 -2
  247. package/dist/src/tasks/task-application-service.d.ts +4 -0
  248. package/dist/src/tasks/task-application-service.js +6 -1
  249. package/dist/src/tasks/task-context-assembler.js +7 -2
  250. package/dist/src/tasks/task-contract-planner.js +3 -3
  251. package/dist/src/tasks/task-conversation-summary.d.ts +64 -0
  252. package/dist/src/tasks/task-conversation-summary.js +105 -0
  253. package/dist/src/tasks/task-delay-notice.d.ts +4 -0
  254. package/dist/src/tasks/task-delay-notice.js +113 -0
  255. package/dist/src/tasks/task-deletion-service.js +6 -1
  256. package/dist/src/tasks/task-handoff.d.ts +21 -0
  257. package/dist/src/tasks/task-handoff.js +77 -1
  258. package/dist/src/tasks/task-json-acceptance.d.ts +22 -0
  259. package/dist/src/tasks/task-json-acceptance.js +96 -0
  260. package/dist/src/tasks/task-main-update-decision-service.js +17 -21
  261. package/dist/src/tasks/task-main-update-delivery.js +34 -7
  262. package/dist/src/tasks/task-notification-preference.d.ts +16 -0
  263. package/dist/src/tasks/task-notification-preference.js +42 -0
  264. package/dist/src/tasks/task-origin-repository.d.ts +1 -0
  265. package/dist/src/tasks/task-origin-repository.js +3 -0
  266. package/dist/src/tasks/task-read-model-projector.js +1 -1
  267. package/dist/src/tasks/task-repository.js +1 -0
  268. package/dist/src/tasks/task-research-repair.d.ts +19 -1
  269. package/dist/src/tasks/task-research-repair.js +14 -4
  270. package/dist/src/tasks/task-research-result.d.ts +12 -0
  271. package/dist/src/tasks/task-research-result.js +5 -0
  272. package/dist/src/tasks/task-result-delivery-repository.d.ts +4 -1
  273. package/dist/src/tasks/task-result-delivery-repository.js +8 -5
  274. package/dist/src/tasks/task-result-delivery-service.js +9 -1
  275. package/dist/src/tasks/task-run-coordinator.js +45 -10
  276. package/dist/src/tui/tui-management.js +2 -2
  277. package/dist/src/usage/cloud-wire.d.ts +1 -0
  278. package/dist/src/user-context/config.d.ts +8 -0
  279. package/dist/src/user-context/config.js +10 -0
  280. package/dist/src/user-model/capture/evidence-policy.d.ts +2 -0
  281. package/dist/src/user-model/capture/evidence-policy.js +8 -1
  282. package/dist/src/user-model/capture/executor.js +16 -4
  283. package/dist/src/user-model/capture/semantic.d.ts +4 -0
  284. package/dist/src/user-model/capture/semantic.js +3 -0
  285. package/dist/src/user-model/index.js +1 -1
  286. package/dist/src/user-model/observation-repository.d.ts +6 -0
  287. package/dist/src/user-model/observation-repository.js +12 -0
  288. package/dist/src/user-model/repository.js +10 -1
  289. package/dist/src/voice/realtime/agentEngine.js +29 -7
  290. package/dist/src/voice/realtime/pcmPlaybackEcho.d.ts +10 -0
  291. package/dist/src/voice/realtime/pcmPlaybackEcho.js +56 -0
  292. package/dist/src/voice/realtime/playback-echo.d.ts +3 -0
  293. package/dist/src/voice/realtime/playback-echo.js +35 -5
  294. package/dist/src/voice/realtime/runtime.js +6 -1
  295. package/dist/src/voice/realtime/turnPolicy.js +1 -1
  296. package/package.json +14 -8
  297. package/dist/gateway/static/root/assets/agent-plugin-dialog-CikzCYAG.js +0 -1
  298. package/dist/gateway/static/root/assets/capabilities-DB713nRi.js +0 -1
  299. package/dist/gateway/static/root/assets/capabilities-page-D2hq4cgE.js +0 -2
  300. package/dist/gateway/static/root/assets/chat-page-BhPw56Vc.js +0 -71
  301. package/dist/gateway/static/root/assets/constants-DpkUgykJ.js +0 -1
  302. package/dist/gateway/static/root/assets/discussion-annotation-sync-fwPPMPv9.js +0 -1
  303. package/dist/gateway/static/root/assets/home-page-BPPe4JXB.js +0 -7
  304. package/dist/gateway/static/root/assets/index-DjzrnmBA.js +0 -11
  305. package/dist/gateway/static/root/assets/index-YQxumvaS.css +0 -1
  306. package/dist/gateway/static/root/assets/mcp-conversation-setup-page-CsTSmjmX.js +0 -1
  307. package/dist/gateway/static/root/assets/note-detail-panel-BbHlfAju.js +0 -7
  308. package/dist/gateway/static/root/assets/note-image-lightbox-CqK_uJ6Y.js +0 -1
  309. package/dist/gateway/static/root/assets/notes-page-8w2Stfak.js +0 -8
  310. package/dist/gateway/static/root/assets/pcm-capture-worklet-uW_SEACy.js +0 -1
  311. package/dist/gateway/static/root/assets/product-preview-modal-DMHOKocl.js +0 -2
  312. package/dist/gateway/static/root/assets/project-detail-page-CNFuzmRr.js +0 -7
  313. package/dist/gateway/static/root/assets/recording-upload-CyZSl2DJ.js +0 -1
  314. package/dist/gateway/static/root/assets/route-preload-CuxNu-LB.js +0 -2
  315. package/dist/gateway/static/root/assets/routine-panel-CXs4PjW0.js +0 -2
  316. package/dist/gateway/static/root/assets/session-manager-D2LaQymu.js +0 -25
  317. package/dist/gateway/static/root/assets/task-detail-page-_5TEldtl.js +0 -3
  318. package/dist/gateway/static/root/assets/use-realtime-voice-C7iWQuUv.js +0 -1
  319. package/dist/gateway/static/root/assets/workspace-api-LghfbP5g.js +0 -2
@@ -11,6 +11,7 @@ import { listConnectorInstances } from "../../connectors/instances.js";
11
11
  import { parseExternalToolRef } from "./refs.js";
12
12
  import { getStoreConnectorInstallPlan, parseStoreConnectorCandidateRef } from "../../capabilities/store-connector.js";
13
13
  import { createPersonalRequestExecutionAuthorizer } from "../../personal-agent/request-access.js";
14
+ import { resolvePluginConnectionCandidate } from "../../connectors/plugin-connection.js";
14
15
  import { resolveConnectionCandidate } from "../../connectors/connection-candidates.js";
15
16
  import { ExternalToolService } from "./service.js";
16
17
  import { EXTERNAL_TOOL_SOURCES } from "./types.js";
@@ -203,7 +204,7 @@ function createExternalToolGatewayTools(providers, getContext, getConfig, getExe
203
204
  name: EXTERNAL_TOOL_NAMES.requireConnection,
204
205
  label: "Connect app",
205
206
  parameters: requireSchema,
206
- description: "Use only when a requested read cannot proceed because authorization, installation or account selection is required. Available authorized tools should be executed directly without asking the user to confirm the read. Request an exact connectionCandidates or installCandidates entry returned by tool_search. Explain the verified need once before calling. This saves and pauses the objective, displays one action area above the input, and lets the host resume automatically after the required user action. Stop this turn after connection_required; never ask the user to reply continue after authorization. Never invent a candidate reference, return OAuth URLs, or repeat a skipped request. If another objective is waiting, do not create a duplicate objective.",
207
+ description: "Use when the user asks to connect a specific integration, or a requested read cannot proceed because authorization, installation or account selection is required. Available authorized tools should be executed directly without asking the user to confirm the read. Request an exact connectionCandidates or installCandidates entry returned by tool_search, or an exact managedIntegrations entry returned by mcp_setup discover. Explain the verified need once before calling. This saves and pauses the objective, displays one action area above the input, and lets the host resume automatically after the required user action. Stop this turn after connection_required; never ask the user to reply continue after authorization. Never invent a candidate reference, return OAuth URLs, or repeat a skipped request. If another objective is waiting, do not create a duplicate objective.",
207
208
  async execute(_id, params) {
208
209
  const context = getContext?.();
209
210
  if (!context) throw new Error("No active conversation.");
@@ -219,6 +220,7 @@ function createExternalToolGatewayTools(providers, getContext, getConfig, getExe
219
220
  principalId: principal.principalId,
220
221
  connectorId: need.target.connectorId
221
222
  }).some((connection) => connection.id === need.connectionId && connection.status === "active");
223
+ if (need.target.type === "plugin") return need.key === item.candidateRef && Boolean(need.connectionId);
222
224
  const storeTarget = parseStoreConnectorCandidateRef(item.candidateRef);
223
225
  return Boolean(storeTarget && need.target.packageName === storeTarget.packageName && need.target.version === storeTarget.version && need.connectionId);
224
226
  });
@@ -236,6 +238,11 @@ function createExternalToolGatewayTools(providers, getContext, getConfig, getExe
236
238
  needs: await Promise.all(params.requirements.map(async (item) => {
237
239
  const storeRef = parseStoreConnectorCandidateRef(item.candidateRef);
238
240
  const config = getConfig?.();
241
+ const plugin = await resolvePluginConnectionCandidate(item.candidateRef, config);
242
+ if (plugin) {
243
+ if (item.accountId || item.accountSelector) throw new Error("Choose the plugin account in its connection form.");
244
+ return plugin;
245
+ }
239
246
  const plan = storeRef && config ? await getStoreConnectorInstallPlan(config, storeRef.packageName, storeRef.version) : void 0;
240
247
  if (plan && !plan.definition.provenance) throw new Error("Store Connector provenance is unavailable.");
241
248
  const need = plan ? {
@@ -75,6 +75,7 @@ export declare class TurnDispatcher {
75
75
  processDirectStreaming(content: string, conversationId: string, origin: TurnOrigin, attachments?: DirectAttachment[], thinking?: string, options?: {
76
76
  signal?: AbortSignal;
77
77
  runId?: string;
78
+ gatewayRunStartedMonotonic?: number;
78
79
  sourceContexts?: AgentSourceContext[];
79
80
  presentation?: 'voice';
80
81
  onDeferredAudio?: (audio: WebchatTtsResult) => void;
@@ -38,6 +38,7 @@ var TurnDispatcher = class {
38
38
  thinking,
39
39
  signal: options?.signal,
40
40
  runId: options?.runId,
41
+ gatewayRunStartedMonotonic: options?.gatewayRunStartedMonotonic,
41
42
  sourceContexts: options?.sourceContexts,
42
43
  presentation: options?.presentation,
43
44
  onDeferredAudio: options?.onDeferredAudio
@@ -3,13 +3,14 @@ import { init_logger } from "../../utils/logger.js";
3
3
  import { checkUrlSafety } from "../tools/url-safety.js";
4
4
  import { isManagedConnectorServer } from "../../connectors/materialize.js";
5
5
  import { resolveMcpSetupConfig } from "./effective-server.js";
6
+ import { classifyMcpConnectionError } from "./connection-errors.js";
6
7
  import { prepareNativeMcpConfig } from "./native-mcp.js";
7
8
  import { retryAfter } from "./transport.js";
8
9
  import { McpAuthenticationRequiredError, discoverMcpTools, signInNativeMcp } from "./tool-catalog.js";
9
- import { classifyMcpConnectionError } from "./connection-errors.js";
10
10
  import { createHash, randomUUID } from "node:crypto";
11
11
  import { lookup } from "node:dns";
12
12
  import { Agent } from "undici";
13
+ import { buildAuthorizationServerDiscoveryUrls, parseWwwAuthenticate, selectResource } from "@earendil-works/pi-mcp/oauth";
13
14
  //#region src/agent/mcp/connection-setup.ts
14
15
  init_logger();
15
16
  const log = createLogger("McpConnectionSetup");
@@ -79,7 +80,7 @@ async function metadata(url, endpoint, signal, publicOnly = false) {
79
80
  await dispatcher.close();
80
81
  }
81
82
  }
82
- async function authentication(config, workspace, serverId, challenge, options) {
83
+ async function authentication(config, workspace, serverId, failure, options) {
83
84
  const entry = (await prepareNativeMcpConfig(config, workspace)).servers.find((s) => s.name === serverId);
84
85
  if (!entry || !("url" in entry.config)) return {
85
86
  method: "unknown",
@@ -91,65 +92,68 @@ async function authentication(config, workspace, serverId, challenge, options) {
91
92
  try {
92
93
  if (typeof value !== "string") return false;
93
94
  const issuer = httpUrl(value);
94
- return issuer.protocol === "https:" && checkUrlSafety(issuer.href).safe || !publicOnly && issuer.origin === url.origin && [
95
+ return !issuer.hash && (issuer.protocol === "https:" && checkUrlSafety(issuer.href).safe || !publicOnly && issuer.origin === url.origin && [
95
96
  "localhost",
96
97
  "127.0.0.1",
97
98
  "[::1]"
98
- ].includes(issuer.hostname);
99
+ ].includes(issuer.hostname));
99
100
  } catch {
100
101
  return false;
101
102
  }
102
103
  };
103
- challenge ??= "";
104
- const reference = /resource_metadata\s*=\s*"([^"\s]+)"/i.exec(challenge)?.[1];
105
- const candidates = [
106
- ...reference ? [httpUrl(reference)] : [],
107
- new URL(`/.well-known/oauth-protected-resource${url.pathname === "/" ? "" : url.pathname}`, url),
108
- new URL("/.well-known/oauth-protected-resource", url)
109
- ];
104
+ const challenge = failure?.challenge;
105
+ const { resourceMetadataUrl } = parseWwwAuthenticate(challenge);
106
+ const suffix = url.pathname.replace(/\/$/, "");
107
+ const candidates = resourceMetadataUrl ? [resourceMetadataUrl] : [new URL(`/.well-known/oauth-protected-resource${suffix}`, url), new URL("/.well-known/oauth-protected-resource", url)];
110
108
  let state = "absent";
111
- for (const candidate of [...new Map(candidates.map((c) => [c.href, c])).values()]) {
109
+ const unknown = (metadata, retryAt) => ({
110
+ method: "unknown",
111
+ metadata,
112
+ retryAt
113
+ });
114
+ const read = async (target) => {
112
115
  options?.signal?.throwIfAborted();
113
116
  options?.diagnostics?.beforeRequest?.({
114
117
  method: "GET",
115
118
  stage: "authorization_metadata"
116
119
  });
117
- const result = await metadata(candidate, url, options?.signal, publicOnly);
118
- if (result.retryAt) return {
119
- method: "unknown",
120
- metadata: result.state,
121
- retryAt: result.retryAt
122
- };
120
+ return metadata(target, url, options?.signal, publicOnly);
121
+ };
122
+ let issuer;
123
+ for (const candidate of new Map(candidates.map((c) => [c.href, c])).values()) {
124
+ if (!allowedIssuer(candidate.href)) {
125
+ state = "invalid";
126
+ continue;
127
+ }
128
+ const result = await read(candidate);
129
+ if (result.retryAt) return unknown(result.state, result.retryAt);
123
130
  if (result.state !== "absent") state = result.state;
124
- const data = result.data;
125
- if (data && typeof data.resource === "string" && data.resource === url.href && Array.isArray(data.authorization_servers) && data.authorization_servers.some(allowedIssuer)) return {
126
- method: "oauth",
127
- metadata: "valid"
128
- };
129
- if (data) state = "invalid";
131
+ if (!result.data) continue;
132
+ const { resource, authorization_servers: servers } = result.data;
133
+ const advertisedIssuer = Array.isArray(servers) ? servers[0] : void 0;
134
+ if (typeof resource === "string" && typeof advertisedIssuer === "string" && allowedIssuer(advertisedIssuer)) try {
135
+ selectResource(url, { resource });
136
+ issuer = advertisedIssuer;
137
+ break;
138
+ } catch {}
139
+ state = "invalid";
130
140
  }
131
- if (/\bBearer\b/i.test(challenge)) {
132
- options?.diagnostics?.beforeRequest?.({
133
- method: "GET",
134
- stage: "authorization_metadata"
135
- });
136
- const result = await metadata(new URL("/.well-known/oauth-authorization-server", url), url, options?.signal, publicOnly);
137
- if (result.retryAt) return {
138
- method: "unknown",
139
- metadata: result.state,
140
- retryAt: result.retryAt
141
- };
141
+ if (!issuer && failure?.status === 401 && !resourceMetadataUrl && state === "absent" && /^\s*Bearer(?:\s|$)/i.test(challenge ?? "") && allowedIssuer(url.origin)) issuer = url.origin;
142
+ if (!issuer) return unknown(resourceMetadataUrl && state === "absent" ? "invalid" : state);
143
+ const fromResource = state === "valid";
144
+ state = "absent";
145
+ for (const { url: target } of buildAuthorizationServerDiscoveryUrls(issuer)) {
146
+ const result = await read(target);
147
+ if (result.retryAt) return unknown(result.state, result.retryAt);
148
+ if (result.state !== "absent") state = result.state;
142
149
  const data = result.data;
143
- if (data && data.issuer === url.origin && allowedIssuer(data.issuer) && typeof data.authorization_endpoint === "string" && typeof data.token_endpoint === "string" && allowedIssuer(data.authorization_endpoint) && allowedIssuer(data.token_endpoint)) return {
150
+ if (data && typeof data.issuer === "string" && data.issuer.replace(/\/$/, "") === issuer.replace(/\/$/, "") && allowedIssuer(data.authorization_endpoint) && allowedIssuer(data.token_endpoint) && (!Array.isArray(data.code_challenge_methods_supported) || data.code_challenge_methods_supported.includes("S256"))) return {
144
151
  method: "oauth",
145
152
  metadata: "valid"
146
153
  };
147
- if (result.state !== "absent") state = result.data ? "invalid" : result.state;
154
+ if (data) return unknown("invalid");
148
155
  }
149
- return {
150
- method: "unknown",
151
- metadata: state
152
- };
156
+ return unknown(fromResource && state === "absent" ? "invalid" : state);
153
157
  }
154
158
  async function probeMcpConnection(config, workspace, serverId, options) {
155
159
  config = resolveMcpSetupConfig(config, serverId);
@@ -204,7 +208,7 @@ async function probeMcpConnection(config, workspace, serverId, options) {
204
208
  };
205
209
  }
206
210
  try {
207
- const auth = await authentication(config, workspace, serverId, last ? last.challenge ?? "" : void 0, options);
211
+ const auth = await authentication(config, workspace, serverId, failed, options);
208
212
  return {
209
213
  state: auth.method === "oauth" ? "oauth_required" : "auth_unknown",
210
214
  auth: {
@@ -13,6 +13,7 @@ import { McpConnectionDrafts, McpDraftError, mcpConfigRevision } from "./connect
13
13
  import { weixinSetupScope } from "./weixin-setup-scope.js";
14
14
  import { localExecutionSchema, secretFieldsSchema } from "./setup-plan.js";
15
15
  import { McpDiscovery, createMcpResearch } from "./discovery.js";
16
+ import { findManagedMcpIntegrations } from "./managed-discovery.js";
16
17
  import { createHash, randomUUID } from "node:crypto";
17
18
  import { z } from "zod";
18
19
  import { setTimeout as setTimeout$1 } from "node:timers/promises";
@@ -76,7 +77,7 @@ var McpConversationSetup = class {
76
77
  readConfig: options.readConfig,
77
78
  saveConfig: options.saveConfig
78
79
  });
79
- this.discovery = new McpDiscovery(options.research ?? createMcpResearch(options.readConfig));
80
+ this.discovery = new McpDiscovery(options.research ?? createMcpResearch(options.readConfig), (name, context) => findManagedMcpIntegrations(options.readConfig(), name, context.signal, !context.managementOrigin));
80
81
  }
81
82
  notify(goal) {
82
83
  try {
@@ -111,7 +112,7 @@ var McpConversationSetup = class {
111
112
  }
112
113
  canProvideToken(goal) {
113
114
  const url = new URL(goal.url);
114
- return (goal.phase === "auth_unknown" || goal.phase === "blocked" && goal.errorCode === "access_denied") && !goal.tokenProvider && !goal.secretProviders && (url.protocol === "https:" || [
115
+ return !goal.publicOnly && (goal.phase === "auth_unknown" || goal.phase === "blocked" && goal.errorCode === "access_denied") && !goal.tokenProvider && !goal.secretProviders && (url.protocol === "https:" || [
115
116
  "127.0.0.1",
116
117
  "localhost",
117
118
  "[::1]"
@@ -150,7 +151,7 @@ var McpConversationSetup = class {
150
151
  managementPath: goal.channel ? `${goal.channel.origin}/#/capabilities/connectors?tab=connected` : "/capabilities/connectors?tab=connected",
151
152
  continuationQueued: goal.resumed === true,
152
153
  replyDelivery: goal.reply?.status,
153
- instruction: goal.phase === "cancelled" ? "This setup is cancelled. Do not continue or revive it. Cancellation does not undo configuration already saved." : expired ? "This request expired. Start a new objective instead of reusing authorization." : goal.phase === "approval_required" ? goal.channel ? "Send the exact trusted interactionPath to the user. The paired Weixin user has requested this service; an authenticated Gateway owner must approve this exact request on that page before any probe, credential submission or configuration change. Never ask for keys, callback URLs or a continue reply in chat. The result returns to this original Weixin conversation automatically." : `Copy ${interactionLink} verbatim. The owner must review this exact publisher source or local execution plan before any probe, credential submission or execution. Do not ask for secrets or an additional continue reply in chat.` : this.canProvideToken(goal) ? `The service refused access. Copy this Markdown link verbatim for secure first-time Token input: ${interactionLink} . Never rewrite its destination as xopc://workspace or add an origin. A refusal alone does not prove a missing Token; service or account permissions may also block access. Do not request secrets in chat or repeatedly retry.` : goal.phase === "blocked" ? "The connection check failed. Report the safe error code and the remaining blocker. Do not repeatedly retry without resolving the cause." : goal.reloadRequired ? "Configuration is saved but runtime reload failed. Report the partial result and require a Gateway restart; do not claim the tools are active or tested." : goal.phase === "ready" ? "Configuration is saved. The host queues the original objective once in a fresh turn. If this is that continuation, discover native tools by the exact server namespace and finish the original objective; otherwise stop and let the queued continuation run. Do not repeat installation or invent a successful read." : goal.phase === "planned" ? "Continue automatic steps with advance and the returned version." : `Copy this Markdown link verbatim for authorization or Token input: ${interactionLink} . Never rewrite its destination as xopc://workspace or add an origin. Then stop this turn. The host resumes automatically; never ask for credentials, callback URLs or a continue reply in chat.`
154
+ instruction: goal.phase === "cancelled" ? "This setup is cancelled. Do not continue or revive it. Cancellation does not undo configuration already saved." : expired ? "This request expired. Start a new objective instead of reusing authorization." : goal.phase === "approval_required" ? goal.channel ? "Send the exact trusted interactionPath to the user. The paired Weixin user has requested this service; an authenticated Gateway owner must approve this exact request on that page before any probe, credential submission or configuration change. Never ask for keys, callback URLs or a continue reply in chat. The result returns to this original Weixin conversation automatically." : `Copy ${interactionLink} verbatim. The owner must review this exact publisher source or local execution plan before any probe, credential submission or execution. Do not ask for secrets or an additional continue reply in chat.` : this.canProvideToken(goal) ? `The service refused access. Copy this Markdown link verbatim for secure first-time Token input: ${interactionLink} . Never rewrite its destination as xopc://workspace or add an origin. A refusal alone does not prove a missing Token; service or account permissions may also block access. Do not request secrets in chat or repeatedly retry.` : goal.phase === "auth_unknown" ? `Authentication could not be verified. Link ${interactionLink} to review the connection, but do not ask for a Token or claim OAuth works. Check the official guide and exact endpoint.` : goal.phase === "blocked" ? "The connection check failed. Report the safe error code and the remaining blocker. Do not repeatedly retry without resolving the cause." : goal.reloadRequired ? "Configuration is saved but runtime reload failed. Report the partial result and require a Gateway restart; do not claim the tools are active or tested." : goal.phase === "ready" ? "Configuration is saved. The host queues the original objective once in a fresh turn. If this is that continuation, discover native tools by the exact server namespace and finish the original objective; otherwise stop and let the queued continuation run. Do not repeat installation or invent a successful read." : goal.phase === "planned" ? "Continue automatic steps with advance and the returned version." : `Copy this Markdown link verbatim for authorization or Token input: ${interactionLink} . Never rewrite its destination as xopc://workspace or add an origin. Then stop this turn. The host resumes automatically; never ask for credentials, callback URLs or a continue reply in chat.`
154
155
  };
155
156
  }
156
157
  cancelGoal(goal) {
@@ -223,7 +224,10 @@ var McpConversationSetup = class {
223
224
  dryRun: true,
224
225
  instruction: "Discovery and candidate state were not changed."
225
226
  };
226
- return this.discovery.command(command, input, context);
227
+ return this.discovery.command(command, input, {
228
+ ...context,
229
+ managementOrigin: channel?.origin
230
+ });
227
231
  }
228
232
  if (command === "inspect") {
229
233
  z.object({}).strict().parse(input);
@@ -471,7 +475,8 @@ var McpConversationSetup = class {
471
475
  this.save(goal);
472
476
  }
473
477
  }
474
- if (goal.authentication === "bearer" && !goal.secretFields?.length && !goal.tokenProvider && !goal.secretProviders?.token || goal.secretFields?.some((field) => !goal.secretProviders?.[field.id])) {
478
+ const missingDocumentedCredential = goal.authentication === "bearer" && !goal.secretFields?.length && !goal.tokenProvider && !goal.secretProviders?.token || goal.secretFields?.some((field) => !goal.secretProviders?.[field.id]);
479
+ if (!goal.publicOnly && missingDocumentedCredential) {
475
480
  goal.phase = "token_required";
476
481
  goal.errorCode = void 0;
477
482
  this.save(goal);
@@ -507,7 +512,7 @@ var McpConversationSetup = class {
507
512
  this.current(goal);
508
513
  const key = `${request?.method ?? "GET"}:${request?.stage ?? "metadata"}`;
509
514
  goal.requestCounts ??= {};
510
- if ((goal.requestCounts[key] ?? 0) >= 3) throw new Error("MCP retry budget exhausted for this protocol stage");
515
+ if ((goal.requestCounts[key] ?? 0) >= (request?.stage === "authorization_metadata" ? 8 : 3)) throw new Error("MCP retry budget exhausted for this protocol stage");
511
516
  goal.requestCounts[key] = (goal.requestCounts[key] ?? 0) + 1;
512
517
  this.goals.set(goal.id, goal);
513
518
  } });
@@ -518,7 +523,7 @@ var McpConversationSetup = class {
518
523
  recovery: probe.recovery
519
524
  };
520
525
  if (probe.state !== "connected") {
521
- goal.phase = probe.state === "error" ? "blocked" : probe.state;
526
+ goal.phase = goal.publicOnly && missingDocumentedCredential && probe.state === "auth_unknown" && probe.auth?.metadata === "absent" && [401, 403].includes(probe.observation?.status ?? 0) && !probe.observation?.contentType.includes("html") ? "token_required" : probe.state === "error" ? "blocked" : probe.state;
522
527
  goal.errorCode = probe.state === "token_required" && (goal.tokenProvider || goal.secretProviders) ? "credential_rejected" : probe.errorCode;
523
528
  if ((probe.recovery?.kind === "wait" || [
524
529
  "network",
@@ -833,7 +838,7 @@ var McpConversationSetup = class {
833
838
  }
834
839
  }
835
840
  async resumePending(runtimeReloaded = false) {
836
- for (const goal of this.goals.values().filter((item) => item.phase === "blocked" && item.nextRetryAt)) try {
841
+ for (const goal of this.goals.values().filter((item) => (item.phase === "blocked" || item.phase === "auth_unknown") && item.nextRetryAt)) try {
837
842
  this.current(goal);
838
843
  this.scheduleRetry(goal);
839
844
  } catch {}
@@ -1,6 +1,8 @@
1
1
  import type { Config } from '../../config/schema.js';
2
+ import type { ManagedMatch } from './managed-discovery.js';
2
3
  import { type ConnectionPlan } from './setup-plan.js';
3
4
  type Context = {
5
+ managementOrigin?: string;
4
6
  conversationId: string;
5
7
  agentId: string;
6
8
  authorizeResearch?: (tool: 'web_search' | 'web_fetch', args: Record<string, unknown>) => Promise<boolean>;
@@ -26,11 +28,27 @@ export declare function createMcpResearch(config: () => Config): McpResearch;
26
28
  /** Search results are evidence to inspect, never configuration authority. */
27
29
  export declare class McpDiscovery {
28
30
  private readonly research;
31
+ private readonly findManaged?;
29
32
  private readonly records;
30
- constructor(research: McpResearch);
33
+ constructor(research: McpResearch, findManaged?: (name: string, context: Context) => Promise<ManagedMatch[]>);
31
34
  private current;
32
35
  private authorized;
33
36
  command(command: string, input: Record<string, unknown>, context: Context): Promise<{
37
+ managedIntegrations: {
38
+ managementPath: string;
39
+ label: string;
40
+ kind: "plugin" | "connector";
41
+ candidateRef?: string;
42
+ }[];
43
+ instruction: string;
44
+ discoveryId?: undefined;
45
+ version?: undefined;
46
+ documents?: undefined;
47
+ failures?: undefined;
48
+ candidates?: undefined;
49
+ planId?: undefined;
50
+ expectedPlanVersion?: undefined;
51
+ } | {
34
52
  discoveryId: string;
35
53
  version: number;
36
54
  documents: Document[];
@@ -39,6 +57,7 @@ export declare class McpDiscovery {
39
57
  reason: string;
40
58
  }[];
41
59
  instruction: string;
60
+ managedIntegrations?: undefined;
42
61
  candidates?: undefined;
43
62
  planId?: undefined;
44
63
  expectedPlanVersion?: undefined;
@@ -69,6 +88,7 @@ export declare class McpDiscovery {
69
88
  candidateId: string;
70
89
  }[];
71
90
  instruction: string;
91
+ managedIntegrations?: undefined;
72
92
  documents?: undefined;
73
93
  failures?: undefined;
74
94
  planId?: undefined;
@@ -77,6 +97,7 @@ export declare class McpDiscovery {
77
97
  planId: string;
78
98
  expectedPlanVersion: number;
79
99
  instruction: string;
100
+ managedIntegrations?: undefined;
80
101
  discoveryId?: undefined;
81
102
  version?: undefined;
82
103
  documents?: undefined;
@@ -44,8 +44,9 @@ function createMcpResearch(config) {
44
44
  /** Search results are evidence to inspect, never configuration authority. */
45
45
  var McpDiscovery = class {
46
46
  records = new DurableState("mcp.discovery");
47
- constructor(research) {
47
+ constructor(research, findManaged) {
48
48
  this.research = research;
49
+ this.findManaged = findManaged;
49
50
  }
50
51
  current(id, context, revision) {
51
52
  const record = this.records.get(id), session = getSessionMetadata(context.conversationId);
@@ -83,6 +84,18 @@ var McpDiscovery = class {
83
84
  };
84
85
  record.originalUserEntry = lastUserEntry(context.conversationId);
85
86
  this.records.set(record.id, record);
87
+ const managed = await this.findManaged?.(args.serviceName, context);
88
+ this.current(record.id, context);
89
+ if (managed?.length) {
90
+ this.records.delete(record.id);
91
+ return {
92
+ managedIntegrations: managed.map((match) => ({
93
+ ...match,
94
+ managementPath: context.managementOrigin ? `${context.managementOrigin}/#${match.managementPath}` : match.managementPath
95
+ })),
96
+ instruction: "Use the matching xopc plugin or connector before custom MCP. Try its existing tools first. If it needs installation or authorization for an owner chat task, pass the exact candidateRef to xopc_require_connection so the original objective resumes after setup. Use managementPath when no candidateRef or recovery tool is available. Do not create a duplicate custom MCP connection."
97
+ };
98
+ }
86
99
  const query = `${args.serviceName} official MCP integration authentication`;
87
100
  await this.authorized(context, "web_search", { query });
88
101
  const searched = await this.research.search(query, context.signal);
@@ -156,9 +169,12 @@ var McpDiscovery = class {
156
169
  args.plan.execution?.cwd,
157
170
  ...args.plan.execution?.args ?? []
158
171
  ].filter((v) => Boolean(v)).some((value) => !text.includes(value))) throw new Error("Every endpoint, credential field and execution argument needs exact document evidence");
159
- if (args.plan.authentication === "bearer" && !/bearer/i.test(text) || args.plan.transport === "sse" && !/\bsse\b/i.test(text) || args.plan.transport === "stdio" && !/stdio|command/i.test(text)) throw new Error("Authentication or transport lacks documented evidence");
172
+ if (args.plan.transport === "sse" && !/\bsse\b/i.test(text) || args.plan.transport === "stdio" && !/stdio|command/i.test(text)) throw new Error("Authentication or transport lacks documented evidence");
160
173
  if (args.plan.authentication === "none" && !/no authentication|unauthenticated|无需认证|无需鉴权|公开服务/i.test(text)) throw new Error("No-authentication requires positive document evidence");
161
- if (args.plan.secretFields.some((field) => field.prefix === "Bearer " && !/bearer/i.test(text))) throw new Error("The credential prefix is not documented");
174
+ if (args.plan.authentication === "bearer" || args.plan.secretFields.some((field) => field.prefix === "Bearer ")) {
175
+ const headerName = args.plan.secretFields.find((field) => field.prefix === "Bearer ")?.name ?? "Authorization";
176
+ if (!new RegExp(`\\b${headerName}\\s*:\\s*Bearer\\b`, "i").test(text) || !/personal access token|integration token|api[ -]?key|static token|(?:create|generate|copy|get) (?:an? |your )?(?:access )?token (?:from|in) |个人访问令牌|集成令牌|访问密钥|(?:创建|生成|复制|获取).{0,12}(?:密钥|令牌)/i.test(text)) throw new Error("A Bearer header does not establish a manually supplied credential. Document how to obtain the key manually, or use auto.");
177
+ }
162
178
  if (args.plan.execution && !documents.some((document) => document.url === args.plan.execution.sourceUrl)) throw new Error("The execution source must be one of the fetched documents");
163
179
  if (args.plan.url && !checkUrlSafety(args.plan.url).safe) throw new Error("Search-discovered endpoints must be public. Local endpoints require an explicit user-supplied address.");
164
180
  const candidate = {
@@ -0,0 +1,8 @@
1
+ import type { Config } from '../../config/schema.js';
2
+ export type ManagedMatch = {
3
+ label: string;
4
+ kind: 'plugin' | 'connector';
5
+ managementPath: string;
6
+ candidateRef?: string;
7
+ };
8
+ export declare function findManagedMcpIntegrations(config: Config, serviceName: string, signal?: AbortSignal, includeInstalled?: boolean): Promise<ManagedMatch[]>;
@@ -0,0 +1,77 @@
1
+ import { AgentPluginStore } from "../../extensions/agent-plugins/store.js";
2
+ import { isExcludedStoreConnector, preferredStorePlugin } from "../../connectors/excluded-connectors.js";
3
+ import { getConnectorDefinition, listConnectorCatalog } from "../../connectors/catalog.js";
4
+ import { listConnectorInstances } from "../../connectors/instances.js";
5
+ import { listIntegrationPackages, resolveExtensionsStoreBaseUrl, resolveSkillsStoreBaseUrl } from "../skills/marketplace/adapters/store/store-api-client.js";
6
+ import { storeConnectorCandidateRef } from "../../capabilities/store-connector.js";
7
+ import { connectionCandidates } from "../../connectors/connection-candidates.js";
8
+ //#region src/agent/mcp/managed-discovery.ts
9
+ function matches(serviceName, ...names) {
10
+ const normalize = (name) => name.toLowerCase().replace(/[^\p{L}\p{N}]/gu, "");
11
+ const target = normalize(serviceName);
12
+ return Boolean(target) && names.some((name) => name && normalize(name) === target);
13
+ }
14
+ async function findManagedMcpIntegrations(config, serviceName, signal, includeInstalled = true) {
15
+ const pluginPackage = preferredStorePlugin(serviceName);
16
+ const installed = (includeInstalled ? new AgentPluginStore().list() : []).filter((plugin) => matches(serviceName, plugin.id, plugin.manifest.name, plugin.receipt.provenance?.packageName) || Boolean(pluginPackage && [plugin.id, plugin.receipt.provenance?.packageName].includes(pluginPackage)));
17
+ if (installed.length) return installed.map((plugin) => ({
18
+ label: plugin.manifest.name,
19
+ kind: "plugin",
20
+ candidateRef: `agent-plugin:${plugin.id}`,
21
+ managementPath: `/capabilities/extensions?tab=user&plugin=${encodeURIComponent(plugin.id)}`
22
+ }));
23
+ const connected = (includeInstalled ? listConnectorInstances(config) : []).filter((instance) => matches(serviceName, instance.connectorId, instance.displayName, getConnectorDefinition(instance.connectorId)?.displayName));
24
+ if (connected.length) return connected.map((instance) => ({
25
+ kind: "connector",
26
+ label: instance.displayName ?? instance.connectorId,
27
+ managementPath: `/capabilities/connectors?tab=connected&instance=${encodeURIComponent(instance.instanceId)}`
28
+ }));
29
+ if (pluginPackage) return [{
30
+ kind: "plugin",
31
+ label: serviceName,
32
+ candidateRef: `store-plugin:${pluginPackage}`,
33
+ managementPath: `/capabilities/extensions?tab=marketplace&q=${encodeURIComponent(pluginPackage)}`
34
+ }];
35
+ const builtin = listConnectorCatalog().filter((entry) => matches(serviceName, entry.id, entry.displayName, entry.runtime.type === "composio" ? entry.runtime.toolkit : void 0));
36
+ if (builtin.length) {
37
+ const supported = new Set(connectionCandidates(serviceName).map((candidate) => candidate.candidateRef));
38
+ return builtin.map((entry) => ({
39
+ kind: "connector",
40
+ label: entry.displayName,
41
+ ...supported.has(entry.id) ? { candidateRef: entry.id } : {},
42
+ managementPath: `/capabilities/connectors?tab=discover&connector=${encodeURIComponent(entry.id)}`
43
+ }));
44
+ }
45
+ const catalogSignal = signal ? AbortSignal.any([signal, AbortSignal.timeout(6e3)]) : AbortSignal.timeout(6e3);
46
+ const results = await Promise.allSettled(["plugin", "connector"].map(async (kind) => {
47
+ const { items } = await listIntegrationPackages(kind === "plugin" ? resolveExtensionsStoreBaseUrl(config) : resolveSkillsStoreBaseUrl(config), {
48
+ q: serviceName,
49
+ page: 1,
50
+ pageSize: 20
51
+ }, {
52
+ type: kind,
53
+ signal: catalogSignal
54
+ });
55
+ return items.flatMap((item) => {
56
+ if (item.type !== kind || !item.latestVersion || kind === "connector" && isExcludedStoreConnector(item.name)) return [];
57
+ const manifest = item.connectorManifest;
58
+ const label = typeof manifest?.displayName === "string" ? manifest.displayName : item.localizations?.en?.displayName ?? item.name;
59
+ if (!matches(serviceName, item.name, label, item.localizations?.["zh-CN"]?.displayName)) return [];
60
+ return [{
61
+ kind,
62
+ label,
63
+ ...kind === "plugin" ? {
64
+ candidateRef: `store-plugin:${item.name}`,
65
+ managementPath: `/capabilities/extensions?tab=marketplace&q=${encodeURIComponent(item.name)}`
66
+ } : {
67
+ managementPath: `/capabilities/connectors?tab=discover&storeConnector=${encodeURIComponent(item.name)}`,
68
+ candidateRef: storeConnectorCandidateRef(item.name, item.latestVersion)
69
+ }
70
+ }];
71
+ });
72
+ }));
73
+ signal?.throwIfAborted();
74
+ return results.flatMap((result) => result.status === "fulfilled" ? result.value : []);
75
+ }
76
+ //#endregion
77
+ export { findManagedMcpIntegrations };
@@ -1,6 +1,6 @@
1
1
  import { resolveMcpSetupConfig } from "./effective-server.js";
2
- import { createEmbeddedModelRuntime } from "../embedded/model-runtime.js";
3
2
  import { getNativePiAgentDir, prepareNativeMcpConfig } from "./native-mcp.js";
3
+ import { createEmbeddedModelRuntime } from "../embedded/model-runtime.js";
4
4
  import { createXopcMcpTransport } from "./transport.js";
5
5
  import { join } from "node:path";
6
6
  import { InMemoryCredentialStore, InMemoryModelsStore } from "@earendil-works/pi-ai";
@@ -19,7 +19,7 @@ or topic:"settings", "automation", "connections" as relevant; no need to load a
19
19
  /** Tool registration already reflects the host's allowlist and deny policy. */
20
20
  function getConversationalConfigurationGuide(toolNames) {
21
21
  if (!toolNames.includes("xopc_use")) return "";
22
- const guide = `${toolNames.includes("tool_manual") ? conversationalConfigurationGuide : conversationalConfigurationGuide.replace(manualRouting, "No tool_manual is registered. Use documented registered parameters; report a blocker if required details are unavailable.\n")}\nxopc_use is registered and may be deferred. If its schema is absent and tool_search is available, discover the exact name before reporting it missing. Never bypass policy.\n${toolNames.includes("mcp_setup") ? "MCP: a clear request to connect a named service requires mcp_setup discover {serviceName: exact requested name,purpose: original objective} before claiming the service is unavailable or asking for its URL. The registered tool list is only already-connected services, not a catalogue of connectable services. Similar saved names never justify a refusal or substitution. Read manual topic mcp to propose documented candidates; do not guess an endpoint. Explicit loopback addresses remain supported. Use connect_only for connection alone; otherwise preserve the original task. Secrets use the exact host interaction link; authentication uncertainty is not proof of Token or OAuth.\n" : ""}`;
22
+ const guide = `${toolNames.includes("tool_manual") ? conversationalConfigurationGuide : conversationalConfigurationGuide.replace(manualRouting, "No tool_manual is registered. Use documented registered parameters; report a blocker if required details are unavailable.\n")}\nxopc_use is registered and may be deferred. If its schema is absent and tool_search is available, discover the exact name before reporting it missing. Never bypass policy.\n${toolNames.includes("mcp_setup") ? "MCP: a clear request to connect a named service requires mcp_setup discover {serviceName: exact requested name,purpose: original objective} before claiming the service is unavailable or asking for its URL. The registered tool list is only already-connected services, not a catalogue of connectable services. Similar saved names never justify a refusal or substitution. Use matching managedIntegrations before proposing custom MCP. Read manual topic mcp for public discovery; do not guess an endpoint. Explicit loopback addresses remain supported. Use connect_only for connection alone; otherwise preserve the original task. Secrets use the exact host interaction link; authentication uncertainty is not proof of Token or OAuth.\n" : ""}`;
23
23
  return toolNames.includes("skill_manage") ? `${guide}\nFor Skill configuration use skill_manage status/enable/disable/delete and skill_install; never edit product storage through shell/file tools. A clear request to install a specified source already authorizes that installation: do not ask for the same confirmation again. Search or a pasted URL alone does not authorize installation; overwrites or additional permissions require their own authorization. Load the skills manual topic when needed. Installation is not a verified first use. For an explicit HTTP MCP service address, use xopc_use mode mcp_setup and manual topic mcp; credentials use its trusted interaction page.\n` : guide;
24
24
  }
25
25
  //#endregion
@@ -59,6 +59,7 @@ export interface RunDirectAgentTurnDeps {
59
59
  export interface RunDirectAgentTurnInput {
60
60
  conversationId: string;
61
61
  runId?: string;
62
+ gatewayRunStartedMonotonic?: number;
62
63
  userMessage: AgentMessage;
63
64
  abortSignal?: AbortSignal;
64
65
  deadlineAtMs?: number;
@@ -116,15 +116,25 @@ async function tryRunSlashCommand(deps, ctx, content, options) {
116
116
  * planning and background-review wiring used by every direct entry point.
117
117
  */
118
118
  async function runDirectAgentTurn(deps, input) {
119
+ const directStartedAt = performance.now();
119
120
  const turnId = input.runId ?? crypto.randomUUID();
120
121
  const isConnectionResume = Boolean(getConnectionResumeInput(input.conversationId, turnId));
121
122
  const isClarificationResume = Boolean(getClarificationResumeInput(input.conversationId, turnId));
122
123
  const isResume = Boolean(phoneResumeForRun(input.conversationId, turnId)) || isConnectionResume || isClarificationResume || Boolean(getTaskContinuation(input.conversationId, turnId)) || Boolean(getMcpSetupResumeInput(input.conversationId, turnId));
123
124
  const modelRef = deps.modelManager.getModelForSession(input.conversationId);
124
- const [contextResult, mediaResult] = await Promise.allSettled([deps.agentManager.prepareUserTurnContext(input.userMessage, input.conversationId, turnId), hydrateUserTurnForLlm({
125
+ const preparationTimings = {};
126
+ const contextStartedAt = performance.now();
127
+ const context = Promise.resolve(deps.agentManager.prepareUserTurnContext(input.userMessage, input.conversationId, turnId)).finally(() => {
128
+ preparationTimings.userContextMs = performance.now() - contextStartedAt;
129
+ });
130
+ const mediaStartedAt = performance.now();
131
+ const media = Promise.resolve(hydrateUserTurnForLlm({
125
132
  message: input.userMessage,
126
133
  modelRef
127
- })]);
134
+ })).finally(() => {
135
+ preparationTimings.mediaHydrationMs = performance.now() - mediaStartedAt;
136
+ });
137
+ const [contextResult, mediaResult] = await Promise.allSettled([context, media]);
128
138
  if (contextResult.status === "rejected") throw contextResult.reason;
129
139
  if (mediaResult.status === "rejected") throw mediaResult.reason;
130
140
  const userContext = contextResult.value;
@@ -138,6 +148,11 @@ async function runDirectAgentTurn(deps, input) {
138
148
  const result = await runEmbeddedTurnForSession({
139
149
  conversationId: input.conversationId,
140
150
  runId: turnId,
151
+ gatewayRunStartedMonotonic: input.gatewayRunStartedMonotonic,
152
+ preparationTimings: {
153
+ ...preparationTimings,
154
+ directPreparationMs: performance.now() - directStartedAt
155
+ },
141
156
  userMessage: sourceEnrichedMessage,
142
157
  dynamicSystemContext: [userContext.dynamicSystemContext, taskContext].filter(Boolean).join("\n\n"),
143
158
  llmImages,
@@ -68,6 +68,7 @@ export interface ProcessDirectStreamingInput {
68
68
  thinking?: string;
69
69
  signal?: AbortSignal;
70
70
  runId?: string;
71
+ gatewayRunStartedMonotonic?: number;
71
72
  sourceContexts?: AgentSourceContext[];
72
73
  presentation?: 'voice';
73
74
  /** Delivers durable audio independently of the completed text run. */
@@ -345,6 +345,7 @@ async function* runProcessDirectStreamingInner(deps, input) {
345
345
  sourceContexts,
346
346
  presentation: input.presentation,
347
347
  requireVisibleReply: input.origin.type === "endpoint" || input.origin.type === "system" && input.origin.source === "cli",
348
+ gatewayRunStartedMonotonic: input.gatewayRunStartedMonotonic,
348
349
  runId: input.runId,
349
350
  onEvent: (embeddedEvent) => {
350
351
  const event = { ...embeddedEvent };
@@ -106,7 +106,7 @@ export declare class AgentService {
106
106
  getSkillCatalogSnapshot(): SkillCatalogSnapshot;
107
107
  getAgentToolAvailability(agentId: string, name: string): {
108
108
  condition: string;
109
- state: "blocked" | "verified";
109
+ state: "verified" | "blocked";
110
110
  reasonCode: string;
111
111
  detail: string;
112
112
  };
@@ -84,8 +84,12 @@ export declare function getStoreOrigin(baseUrl: string): string;
84
84
  export declare function assertDownloadUrlAllowed(downloadUrl: string, storeBaseUrl: string): URL;
85
85
  export declare function listSkillPackages(storeBaseUrl: string, params: SkillsStoreListParams): Promise<SkillsStoreListResponse>;
86
86
  export declare function listSkillCategories(storeBaseUrl: string, locale?: string): Promise<MarketplaceCategoryOption[]>;
87
- /** Public connector catalog exposed by xopc-store. */
87
+ /** Public integration catalog exposed by xopc-store. */
88
88
  export declare function listConnectorPackages(storeBaseUrl: string, params: SkillsStoreListParams): Promise<SkillsStoreListResponse>;
89
+ export declare function listIntegrationPackages(storeBaseUrl: string, params: SkillsStoreListParams, options?: {
90
+ type?: 'connector' | 'plugin';
91
+ signal?: AbortSignal;
92
+ }): Promise<SkillsStoreListResponse>;
89
93
  /** GET /api/v1/packages/:name — published skill package (public). */
90
94
  export interface MarketplacePackageDetail {
91
95
  id: string;
@@ -145,7 +149,7 @@ export interface StoreConnectorPackageDetail {
145
149
  };
146
150
  }
147
151
  export declare function fetchStoreConnectorPackageDetail(storeBaseUrl: string, packageName: string, version?: string): Promise<StoreConnectorPackageDetail>;
148
- export declare function fetchMarketplacePackageDetail(storeBaseUrl: string, packageName: string): Promise<MarketplacePackageDetail>;
152
+ export declare function fetchMarketplacePackageDetail(storeBaseUrl: string, packageName: string, signal?: AbortSignal): Promise<MarketplacePackageDetail>;
149
153
  export declare function resolveSkillZipDownloadUrl(storeBaseUrl: string, packageName: string, version?: string): Promise<{
150
154
  downloadUrl: string;
151
155
  version: string;