@xopcai/xopc 0.0.409 → 0.0.411

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 (703) hide show
  1. package/README.md +12 -6
  2. package/README.zh-CN.md +12 -6
  3. package/dist/browser-ext/dist/assets/{page-context-A5RCibM_.js → page-context-MuzjMBlJ.js} +1 -1
  4. package/dist/browser-ext/dist/background.js +1 -1
  5. package/dist/browser-ext/dist/sidepanel.html +1 -1
  6. package/dist/browser-ext/dist/sidepanel.js +1 -1
  7. package/dist/browser-ext/manifest.json +1 -1
  8. package/dist/extensions/feishu/src/adapters/gateway-setup.js +9 -3
  9. package/dist/extensions/feishu/src/plugin.d.ts +0 -3
  10. package/dist/extensions/feishu/src/plugin.js +1 -11
  11. package/dist/extensions/feishu/src/schema/config-schema.d.ts +0 -2
  12. package/dist/extensions/feishu/src/schema/config-schema.js +9 -21
  13. package/dist/extensions/feishu/src/state/accounts.js +3 -7
  14. package/dist/extensions/telegram/src/plugin.d.ts +0 -3
  15. package/dist/extensions/telegram/src/plugin.js +0 -9
  16. package/dist/extensions/telegram/xopc.extension.json +1 -1
  17. package/dist/extensions/weixin/src/plugin.d.ts +0 -3
  18. package/dist/extensions/weixin/src/plugin.js +1 -12
  19. package/dist/gateway/static/root/assets/agent-avatar-dicebear-sGJnq-SA.js +1 -0
  20. package/dist/gateway/static/root/assets/agent-defaults-settings-panel-BI7OTo-T.js +1 -0
  21. package/dist/gateway/static/root/assets/agents-RIXL0p7_.js +77 -0
  22. package/dist/gateway/static/root/assets/{agents-admin-api-D0UyB0Y_.js → agents-admin-api-uGDeJR1f.js} +1 -1
  23. package/dist/gateway/static/root/assets/app-management-settings-panel-BGzhSS6H.js +1 -0
  24. package/dist/gateway/static/root/assets/{appearance-settings-Dzhmj_ZO.js → appearance-settings-DtEZq4b2.js} +1 -1
  25. package/dist/gateway/static/root/assets/apps-page-DZqBof2D.js +1 -0
  26. package/dist/gateway/static/root/assets/{archive-plugin-D4r4P5uG.js → archive-plugin-CGdU_E5B.js} +1 -1
  27. package/dist/gateway/static/root/assets/{automation-display-DCkjVzA0.js → automation-display-BFN7zWBg.js} +1 -1
  28. package/dist/gateway/static/root/assets/{automations-page-BlNe3DXU.js → automations-page-BAPZY56r.js} +1 -1
  29. package/dist/gateway/static/root/assets/automations-workspace-CI-yQnSj.js +8 -0
  30. package/dist/gateway/static/root/assets/{binary-plugins-DuN5L6lm.js → binary-plugins-B0ispXo2.js} +1 -1
  31. package/dist/gateway/static/root/assets/{block-editor-DUSVn51h.js → block-editor-B9Ci-prO.js} +40 -40
  32. package/dist/gateway/static/root/assets/{browser-automation-inputs-D8bZ9iz2.js → browser-automation-inputs-D4-vQc4g.js} +1 -1
  33. package/dist/gateway/static/root/assets/browser-automations-page-Xzdif447.js +3 -0
  34. package/dist/gateway/static/root/assets/browser-settings-page-Bhu-83eC.js +3 -0
  35. package/dist/gateway/static/root/assets/capabilities-B9b5KCBb.js +1 -0
  36. package/dist/gateway/static/root/assets/capabilities-page-BIc0Zlsw.js +2 -0
  37. package/dist/gateway/static/root/assets/capabilities-settings-panel-CQEfpLdj.js +8 -0
  38. package/dist/gateway/static/root/assets/{capability-header-actions-oBPqUlbj.js → capability-header-actions-Cic05oWh.js} +1 -1
  39. package/dist/gateway/static/root/assets/channels-DQbEoo_o.js +1 -0
  40. package/dist/gateway/static/root/assets/{chat-terminal-dock-BLs3NaOP.js → chat-terminal-dock-Bm-IGeDe.js} +2 -2
  41. package/dist/gateway/static/root/assets/{chunk-KS7C4IRE-B2HK1psj.js → chunk-KS7C4IRE-BvcCCgTW.js} +2 -2
  42. package/dist/gateway/static/root/assets/computer-settings-page-C9xMfwXK.js +1 -0
  43. package/dist/gateway/static/root/assets/connector-service-page-DcdASUU9.js +1 -0
  44. package/dist/gateway/static/root/assets/connectors-page-eh-xpMPK.js +1 -0
  45. package/dist/gateway/static/root/assets/date-formatters-DukWSVwc.js +1 -0
  46. package/dist/gateway/static/root/assets/{date-picker-DVlbwrYg.js → date-picker-gVLWu9R0.js} +1 -1
  47. package/dist/gateway/static/root/assets/dependency-picker-C0LARyok.js +1 -0
  48. package/dist/gateway/static/root/assets/desktop-pet-settings-B_-j-D4W.js +1 -0
  49. package/dist/gateway/static/root/assets/desktop-pet-v_le3sCs.js +1 -0
  50. package/dist/gateway/static/root/assets/device-pairing-wizard-CxG_FcQ6.js +1 -0
  51. package/dist/gateway/static/root/assets/{directory-picker-path-field-QZ0p-uNa.js → directory-picker-path-field-CBefVUPR.js} +1 -1
  52. package/dist/gateway/static/root/assets/electron-env-Dit0bHgy.js +1 -0
  53. package/dist/gateway/static/root/assets/{extension-debug-page-DoVPUHu_.js → extension-debug-page-CTe7Molh.js} +1 -1
  54. package/dist/gateway/static/root/assets/{extension-page-BNe8n3iJ.js → extension-page-C0-oP7S_.js} +1 -1
  55. package/dist/gateway/static/root/assets/{extension-settings-page-DxNpjGJD.js → extension-settings-page-DYJmgMUg.js} +1 -1
  56. package/dist/gateway/static/root/assets/files-Bw4SBGdM.js +1 -0
  57. package/dist/gateway/static/root/assets/{gateway-config-swr-CTXr917C.js → gateway-config-swr-BVqYVaGy.js} +1 -1
  58. package/dist/gateway/static/root/assets/gateway-realtime-CY1LBGBS.js +1 -0
  59. package/dist/gateway/static/root/assets/gateway-realtime-store-Dafw95ol.js +1 -0
  60. package/dist/gateway/static/root/assets/gateway-settings-C13P4lQd.js +1 -0
  61. package/dist/gateway/static/root/assets/{gateway-startup-retry-DD2fsxdd.js → gateway-startup-retry-CPKGkr6D.js} +1 -1
  62. package/dist/gateway/static/root/assets/highlight-code-CslBKXdS.js +1 -0
  63. package/dist/gateway/static/root/assets/{highlighted-body-KQOG7T2V-DrZq5KTj.js → highlighted-body-KQOG7T2V-CN5PNRN3.js} +1 -1
  64. package/dist/gateway/static/root/assets/home-page-B_XrkGmA.js +2 -0
  65. package/dist/gateway/static/root/assets/image-generation-api-DRLXG9Ws.js +1 -0
  66. package/dist/gateway/static/root/assets/imports-page--cuF5vwU.js +1 -0
  67. package/dist/gateway/static/root/assets/index-6YjAt50A.js +710 -0
  68. package/dist/gateway/static/root/assets/index-caRW34rg.css +1 -0
  69. package/dist/gateway/static/root/assets/keyboard-shortcuts-settings-5g2PxgBs.js +1 -0
  70. package/dist/gateway/static/root/assets/languages-byq_L2Ae.js +2 -0
  71. package/dist/gateway/static/root/assets/local-app-workbench-page-B6U1HQpp.js +1 -0
  72. package/dist/gateway/static/root/assets/local-apps-page-BChE6nUD.js +1 -0
  73. package/dist/gateway/static/root/assets/{local-session-drafts-TqLFKwYo.js → local-session-drafts-BCaC-1rH.js} +1 -1
  74. package/dist/gateway/static/root/assets/locale-store-DAgpZxAS.js +1 -0
  75. package/dist/gateway/static/root/assets/logs-page-B9mq03SK.js +2 -0
  76. package/dist/gateway/static/root/assets/management-settings-2W_qJsha.js +1 -0
  77. package/dist/gateway/static/root/assets/markdown-editor-phTQ0mox.js +1 -0
  78. package/dist/gateway/static/root/assets/{media-plugins-s6EqtAUQ.js → media-plugins-BmLuWkkZ.js} +1 -1
  79. package/dist/gateway/static/root/assets/mermaid-MCJ5UELQ-61Il2HQR.js +1 -0
  80. package/dist/gateway/static/root/assets/messages-DMXSIJUO.js +3 -0
  81. package/dist/gateway/static/root/assets/note-detail-panel-C4gZsNBL.js +5 -0
  82. package/dist/gateway/static/root/assets/note-image-lightbox-XqJIaaRV.js +1 -0
  83. package/dist/gateway/static/root/assets/notes-page-Chdwrjni.js +8 -0
  84. package/dist/gateway/static/root/assets/page-context-capture-button-B7rDRlS7.js +1 -0
  85. package/dist/gateway/static/root/assets/personal-page-mQl9BftY.js +1 -0
  86. package/dist/gateway/static/root/assets/personal-settings-panel-BgcJLmZN.js +1 -0
  87. package/dist/gateway/static/root/assets/plugin-details-dialog-FvwSxZPB.js +1 -0
  88. package/dist/gateway/static/root/assets/preview-open-alternatives-Z4NM7_Dn.js +1 -0
  89. package/dist/gateway/static/root/assets/product-delivery-BqNm-8S5.js +1 -0
  90. package/dist/gateway/static/root/assets/{product-open-page-BPWSqtRt.js → product-open-page-C5TcIaJj.js} +1 -1
  91. package/dist/gateway/static/root/assets/product-preview-content-5xID6jIj.js +1 -0
  92. package/dist/gateway/static/root/assets/project-detail-page-CGOyx7zX.js +7 -0
  93. package/dist/gateway/static/root/assets/projects-page-Dd11tbRX.js +1 -0
  94. package/dist/gateway/static/root/assets/{registry-api-4NZOh0iz.js → registry-api-B6kqbuw8.js} +1 -1
  95. package/dist/gateway/static/root/assets/remote-access-hub-Bintk9nL.js +1 -0
  96. package/dist/gateway/static/root/assets/runtime-tools-api-CY3R7unQ.js +5 -0
  97. package/dist/gateway/static/root/assets/{runtime-tools-settings-panel-CNCx2RnO.js → runtime-tools-settings-panel-CbmiiLsq.js} +1 -1
  98. package/dist/gateway/static/root/assets/{schema-form-nRDA2XfI.js → schema-form-DtPkiYwm.js} +1 -1
  99. package/dist/gateway/static/root/assets/session-api-D6-Vz8xK.js +1 -0
  100. package/dist/gateway/static/root/assets/{session-manager-D2sLfkw-.js → session-manager-DWbcMHcj.js} +3 -3
  101. package/dist/gateway/static/root/assets/sessions-page-BBlEP7y3.js +1 -0
  102. package/dist/gateway/static/root/assets/settings-advanced-gate-BCQUth4g.js +1 -0
  103. package/dist/gateway/static/root/assets/{settings-form-section-_ALUREPr.js → settings-form-section-DD3iD5t5.js} +1 -1
  104. package/dist/gateway/static/root/assets/{settings-page-29ptuMYZ.js → settings-page-iLY3LRDq.js} +1 -1
  105. package/dist/gateway/static/root/assets/setup-status-panel-v4P0IAkG.js +1 -0
  106. package/dist/gateway/static/root/assets/share-preview-page-B8h9lqDL.js +2 -0
  107. package/dist/gateway/static/root/assets/shares-settings-DMzej6z2.js +1 -0
  108. package/dist/gateway/static/root/assets/{skill-api-C-T0K7Oo.js → skill-api-C9RsrvOp.js} +1 -1
  109. package/dist/gateway/static/root/assets/skill-reload-api-B20x7EE9.js +1 -0
  110. package/dist/gateway/static/root/assets/skills-page-C_ulsnv7.js +2 -0
  111. package/dist/gateway/static/root/assets/source-workspace-editor-BIvi89Zx.js +1 -0
  112. package/dist/gateway/static/root/assets/system-settings-panel-PTRGMKkq.js +1 -0
  113. package/dist/gateway/static/root/assets/task-detail-page-DEPwo4vf.js +2 -0
  114. package/dist/gateway/static/root/assets/task-result-evidence-DjNWPpn_.js +1 -0
  115. package/dist/gateway/static/root/assets/tasks-TVRjEggr.js +1 -0
  116. package/dist/gateway/static/root/assets/tracing-settings-page-CVJt7IXC.js +1 -0
  117. package/dist/gateway/static/root/assets/{tunnel-api-DcDUSAjv.js → tunnel-api-C6XfsSWy.js} +1 -1
  118. package/dist/gateway/static/root/assets/{usage-page-Hut0SDqn.js → usage-page-DgqLD8Y5.js} +1 -1
  119. package/dist/gateway/static/root/assets/{use-autosave-C4TUlpsu.js → use-autosave-DO-Twmbm.js} +1 -1
  120. package/dist/gateway/static/root/assets/user-model-page-BwK37aob.js +2 -0
  121. package/dist/gateway/static/root/assets/{vendor-codemirror-DFxP3B9T.js → vendor-codemirror-Qdcjid65.js} +16 -16
  122. package/dist/gateway/static/root/assets/{voice-api-key-field-CMdihbPb.js → voice-api-key-field-MGe3HkS_.js} +1 -1
  123. package/dist/gateway/static/root/assets/{voice-config-api-4yGMrp7J.js → voice-config-api-CPKzUb4R.js} +1 -1
  124. package/dist/gateway/static/root/assets/work-discovery-overlay-DptHqYh5.js +1 -0
  125. package/dist/gateway/static/root/assets/{xopc-cloud-account-card-ClQKM2RA.js → xopc-cloud-account-card-Y_UIryBH.js} +1 -1
  126. package/dist/gateway/static/root/index.html +27 -35
  127. package/dist/package.js +1 -1
  128. package/dist/packages/endpoint-tools-protocol/src/index.js +1 -1
  129. package/dist/packages/gateway-contract/src/automations.js +0 -12
  130. package/dist/packages/gateway-contract/src/home.js +3 -3
  131. package/dist/packages/gateway-contract/src/product-delivery.js +0 -4
  132. package/dist/packages/gateway-contract/src/project-operating.js +0 -6
  133. package/dist/packages/gateway-contract/src/session-identity.js +0 -1
  134. package/dist/packages/gateway-contract/src/task-runs.js +0 -1
  135. package/dist/packages/gateway-contract/src/tasks.js +0 -6
  136. package/dist/src/activity/types.d.ts +4 -4
  137. package/dist/src/agent/agent-manager.d.ts +0 -3
  138. package/dist/src/agent/agent-manager.js +0 -43
  139. package/dist/src/agent/background-review/prompts.d.ts +8 -0
  140. package/dist/src/agent/background-review/prompts.js +9 -2
  141. package/dist/src/agent/background-review/run-background-review.js +73 -11
  142. package/dist/src/agent/capabilities/definitions.d.ts +2 -18
  143. package/dist/src/agent/capabilities/definitions.js +0 -17
  144. package/dist/src/agent/child-agent-factory.d.ts +1 -1
  145. package/dist/src/agent/client-error-format.d.ts +1 -1
  146. package/dist/src/agent/client-error-format.js +1 -1
  147. package/dist/src/agent/commands/command-registry.js +1 -1
  148. package/dist/src/agent/context/execution-scope.d.ts +2 -8
  149. package/dist/src/agent/context/execution-scope.js +6 -23
  150. package/dist/src/agent/embedded/index.d.ts +0 -1
  151. package/dist/src/agent/embedded/index.js +1 -2
  152. package/dist/src/agent/embedded/run-turn.js +25 -2
  153. package/dist/src/agent/embedded/sqlite-hydrating-session-manager.js +0 -2
  154. package/dist/src/agent/external-tools/gateway-tools.js +6 -6
  155. package/dist/src/agent/inbound/attachment-pipeline.d.ts +2 -0
  156. package/dist/src/agent/inbound/attachment-pipeline.js +10 -5
  157. package/dist/src/agent/mcp/connection-setup.js +2 -2
  158. package/dist/src/agent/memory/compaction-ledger.d.ts +1 -1
  159. package/dist/src/agent/memory/compaction-ledger.js +1 -1
  160. package/dist/src/agent/memory/compaction-promotion.js +1 -1
  161. package/dist/src/agent/memory/source-origin.js +1 -5
  162. package/dist/src/agent/memory/turn-provenance.js +1 -3
  163. package/dist/src/agent/memory/types.d.ts +1 -1
  164. package/dist/src/agent/messaging/command-handler.d.ts +0 -3
  165. package/dist/src/agent/messaging/command-handler.js +1 -4
  166. package/dist/src/agent/prompt/sections/behavior.js +2 -2
  167. package/dist/src/agent/prompt/sections/tooling.js +1 -5
  168. package/dist/src/agent/prompt/voice-presentation.d.ts +1 -1
  169. package/dist/src/agent/prompt/voice-presentation.js +1 -1
  170. package/dist/src/agent/service/direct-turn-helpers.js +1 -1
  171. package/dist/src/agent/service/process-direct-streaming.js +0 -6
  172. package/dist/src/agent/service.d.ts +0 -2
  173. package/dist/src/agent/service.js +0 -11
  174. package/dist/src/agent/service.types.d.ts +0 -2
  175. package/dist/src/agent/session/session-config-service.d.ts +0 -2
  176. package/dist/src/agent/session/session-config-service.js +1 -1
  177. package/dist/src/agent/session/session-inspector.d.ts +0 -1
  178. package/dist/src/agent/session/session-inspector.js +0 -1
  179. package/dist/src/agent/skills/required-env-vars.d.ts +1 -1
  180. package/dist/src/agent/skills/required-env-vars.js +1 -1
  181. package/dist/src/agent/tool-manuals/xopc-use.d.ts +1 -1
  182. package/dist/src/agent/tool-manuals/xopc-use.js +2 -5
  183. package/dist/src/agent/tools/automation-tool.js +1 -1
  184. package/dist/src/agent/tools/factory.d.ts +0 -3
  185. package/dist/src/agent/tools/factory.js +21 -10
  186. package/dist/src/agent/tools/index.d.ts +0 -2
  187. package/dist/src/agent/tools/index.js +1 -3
  188. package/dist/src/agent/tools/knowledge-memory-tool.d.ts +1 -0
  189. package/dist/src/agent/tools/knowledge-memory-tool.js +13 -4
  190. package/dist/src/agent/tools/personal-task-tool.js +8 -22
  191. package/dist/src/agent/tools/search/errors.js +2 -2
  192. package/dist/src/agent/tools/session-recall-tool.d.ts +3 -0
  193. package/dist/src/agent/tools/session-recall-tool.js +7 -0
  194. package/dist/src/agent/tools/session-search-tool.d.ts +3 -0
  195. package/dist/src/agent/tools/session-search-tool.js +20 -4
  196. package/dist/src/agent/tools/user-context-tool.js +7 -1
  197. package/dist/src/agent/tools/xopc-use-tool.js +1 -1
  198. package/dist/src/agent-catalog/index.d.ts +0 -1
  199. package/dist/src/agent-catalog/index.js +1 -2
  200. package/dist/src/agent-config/index.js +2 -2
  201. package/dist/src/agent-config/resolver.js +0 -6
  202. package/dist/src/agent-config/schema.d.ts +0 -16
  203. package/dist/src/agent-config/schema.js +2 -9
  204. package/dist/src/agent-matching/selection-repository.d.ts +1 -1
  205. package/dist/src/agent-matching/selection-repository.js +1 -1
  206. package/dist/src/agent-matching/service.d.ts +1 -2
  207. package/dist/src/agent-matching/service.js +3 -7
  208. package/dist/src/ai-assist/text-assist.d.ts +1 -1
  209. package/dist/src/ai-assist/text-assist.js +0 -72
  210. package/dist/src/automations/capabilities/write.d.ts +0 -40
  211. package/dist/src/automations/domain/types.d.ts +0 -15
  212. package/dist/src/automations/domain/validation.d.ts +0 -80
  213. package/dist/src/automations/domain/validation.js +0 -17
  214. package/dist/src/automations/draft/automation-draft-prompt.js +0 -3
  215. package/dist/src/automations/draft/automation-draft-validator.d.ts +0 -20
  216. package/dist/src/automations/draft/automation-draft-validator.js +0 -1
  217. package/dist/src/automations/events/event-catalog.js +0 -6
  218. package/dist/src/automations/service/action-executor.d.ts +0 -1
  219. package/dist/src/automations/service/action-executor.js +1 -110
  220. package/dist/src/automations/service/automation-service.js +0 -2
  221. package/dist/src/automations/storage/automation-run-repository.js +6 -7
  222. package/dist/src/backup/archive.js +1 -1
  223. package/dist/src/bootstrap/application-state.d.ts +2 -10
  224. package/dist/src/bootstrap/application-state.js +5 -18
  225. package/dist/src/channels/manager.d.ts +0 -2
  226. package/dist/src/channels/manager.js +0 -4
  227. package/dist/src/channels/pairing/index.d.ts +2 -1
  228. package/dist/src/channels/pairing/pairing-service.d.ts +0 -1
  229. package/dist/src/chat-commands/context.d.ts +0 -3
  230. package/dist/src/chat-commands/context.js +0 -5
  231. package/dist/src/chat-commands/index.d.ts +0 -1
  232. package/dist/src/chat-commands/index.js +1 -3
  233. package/dist/src/chat-commands/types.d.ts +0 -5
  234. package/dist/src/cli/command-manifest.js +1 -1
  235. package/dist/src/cli/commands/config.js +2 -10
  236. package/dist/src/cli/commands/doctor/checks/database-relations.js +0 -3
  237. package/dist/src/cli/commands/doctor/checks/database-schema.js +4 -25
  238. package/dist/src/cli/commands/gateway/run-foreground.js +1 -1
  239. package/dist/src/cli/commands/setup-shared/prompts.d.ts +2 -2
  240. package/dist/src/cli/commands/setup-shared/prompts.js +2 -2
  241. package/dist/src/cli/commands/tui-runner.js +2 -2
  242. package/dist/src/cli/extension-cli-register.js +1 -1
  243. package/dist/src/cli/index.d.ts +0 -1
  244. package/dist/src/cli/index.js +2 -2
  245. package/dist/src/cli/utils/init-workspace-core.js +3 -6
  246. package/dist/src/config/index.js +2 -2
  247. package/dist/src/config/loader.d.ts +0 -1
  248. package/dist/src/config/loader.js +1 -13
  249. package/dist/src/config/paths.d.ts +1 -1
  250. package/dist/src/config/paths.js +1 -1
  251. package/dist/src/connectors/composio-catalog.js +1 -3
  252. package/dist/src/connectors/composio.js +1 -2
  253. package/dist/src/connectors/connected-source-ingestion.js +1 -1
  254. package/dist/src/connectors/connected-source-understanding.js +1 -1
  255. package/dist/src/connectors/learning-coordinator.js +1 -1
  256. package/dist/src/connectors/principal.js +1 -22
  257. package/dist/src/connectors/{workflow-preflight.d.ts → requirements-preflight.d.ts} +9 -8
  258. package/dist/src/connectors/{workflow-preflight.js → requirements-preflight.js} +2 -10
  259. package/dist/src/connectors/types.d.ts +1 -1
  260. package/dist/src/daemon/types.d.ts +0 -9
  261. package/dist/src/discussions/long-review.js +0 -11
  262. package/dist/src/endpoint-tools/policy.js +13 -14
  263. package/dist/src/extensions/agent-plugins/auth.js +1 -3
  264. package/dist/src/extensions/agent-plugins/formats.js +2 -4
  265. package/dist/src/extensions/agent-plugins/mcp-format.d.ts +1 -1
  266. package/dist/src/extensions/agent-plugins/mcp-format.js +2 -2
  267. package/dist/src/extensions/bundled-extension-activation.d.ts +0 -2
  268. package/dist/src/extensions/bundled-extension-activation.js +1 -3
  269. package/dist/src/extensions/install.js +1 -1
  270. package/dist/src/extensions/types/tui.d.ts +1 -2
  271. package/dist/src/gateway/agent-builtin-tools.d.ts +1 -7
  272. package/dist/src/gateway/agent-builtin-tools.js +0 -7
  273. package/dist/src/gateway/agents-admin.d.ts +0 -1
  274. package/dist/src/gateway/agents-admin.js +0 -1
  275. package/dist/src/gateway/global-defaults-admin.js +1 -1
  276. package/dist/src/gateway/hono/lib/config-payload.d.ts +0 -8
  277. package/dist/src/gateway/hono/lib/config-payload.js +1 -2
  278. package/dist/src/gateway/hono/lib/config-write-lock.d.ts +1 -1
  279. package/dist/src/gateway/hono/lib/config-write-lock.js +1 -1
  280. package/dist/src/gateway/hono/middleware/auth.js +2 -2
  281. package/dist/src/gateway/hono/routes/activity.js +0 -1
  282. package/dist/src/gateway/hono/routes/agents.js +2 -9
  283. package/dist/src/gateway/hono/routes/auth-registry-extensions.js +0 -22
  284. package/dist/src/gateway/hono/routes/chat-model-config.d.ts +0 -1
  285. package/dist/src/gateway/hono/routes/config-patch/misc.js +2 -3
  286. package/dist/src/gateway/hono/routes/config.js +2 -21
  287. package/dist/src/gateway/hono/routes/connectors.js +1 -1
  288. package/dist/src/gateway/hono/routes/context-sources.js +1 -1
  289. package/dist/src/gateway/hono/routes/devices.js +2 -2
  290. package/dist/src/gateway/hono/routes/home.js +3 -20
  291. package/dist/src/gateway/hono/routes/lazy-bundles.js +0 -8
  292. package/dist/src/gateway/hono/routes/memory-learning.js +1 -1
  293. package/dist/src/gateway/hono/routes/personal-agent.js +1 -1
  294. package/dist/src/gateway/hono/routes/projects.js +0 -16
  295. package/dist/src/gateway/hono/routes/session-input-handler.d.ts +2 -2
  296. package/dist/src/gateway/hono/routes/sessions.js +0 -3
  297. package/dist/src/gateway/hono/routes/user-model-refresh.js +1 -1
  298. package/dist/src/gateway/hono/routes/user-model.js +1 -1
  299. package/dist/src/gateway/index.js +1 -1
  300. package/dist/src/gateway/run-loop.js +2 -2
  301. package/dist/src/gateway/security/device-request-proof.js +1 -1
  302. package/dist/src/gateway/security/gateway-scopes.js +0 -1
  303. package/dist/src/gateway/service/active-execution.d.ts +1 -1
  304. package/dist/src/gateway/service/active-execution.js +1 -1
  305. package/dist/src/gateway/service/agent-runner.js +1 -1
  306. package/dist/src/gateway/service/session-input-coordinator.d.ts +1 -1
  307. package/dist/src/gateway/service/sessions-api.d.ts +1 -2
  308. package/dist/src/gateway/service/sessions-api.js +1 -1
  309. package/dist/src/gateway/service/task-conversation-query-service.d.ts +0 -4
  310. package/dist/src/gateway/service/types.d.ts +2 -0
  311. package/dist/src/gateway/service.d.ts +1 -8
  312. package/dist/src/gateway/service.js +20 -67
  313. package/dist/src/history/ctx/format.js +1 -1
  314. package/dist/src/home-intelligence/capability-preflight.js +1 -1
  315. package/dist/src/infra/unhandled-rejections.js +2 -2
  316. package/dist/src/infra/update-runner.d.ts +1 -2
  317. package/dist/src/infra/update-runner.js +2 -2
  318. package/dist/src/knowledge/connected-knowledge-pipeline.js +1 -1
  319. package/dist/src/knowledge/local-folder-adapter.js +2 -5
  320. package/dist/src/knowledge-memory/repository.d.ts +3 -1
  321. package/dist/src/knowledge-memory/repository.js +10 -3
  322. package/dist/src/knowledge-memory/usage-policy.js +1 -1
  323. package/dist/src/local-apps/service.js +1 -1
  324. package/dist/src/memory-learning/forget-capture.d.ts +14 -0
  325. package/dist/src/memory-learning/forget-capture.js +101 -0
  326. package/dist/src/memory-learning/forgotten-history.d.ts +15 -0
  327. package/dist/src/memory-learning/forgotten-history.js +137 -0
  328. package/dist/src/memory-learning/owner-directive.d.ts +2 -0
  329. package/dist/src/memory-learning/owner-directive.js +10 -0
  330. package/dist/src/memory-learning/service.js +0 -2
  331. package/dist/src/memory-learning/source-learning.js +1 -1
  332. package/dist/src/memory-learning/task-receipts.js +1 -1
  333. package/dist/src/memory-learning/work-capture.js +2 -1
  334. package/dist/src/migrations/index.js +2 -2
  335. package/dist/src/migrations/runner.d.ts +1 -2
  336. package/dist/src/migrations/runner.js +2 -5
  337. package/dist/src/notes/service.js +3 -3
  338. package/dist/src/notes/types.d.ts +1 -2
  339. package/dist/src/personal-agent/communication.d.ts +0 -3
  340. package/dist/src/personal-agent/communication.js +1 -12
  341. package/dist/src/personal-agent/persona.d.ts +0 -4
  342. package/dist/src/personal-agent/persona.js +1 -5
  343. package/dist/src/personal-agent/proactivity/repository.js +2 -6
  344. package/dist/src/personal-agent/prompt-context.js +1 -1
  345. package/dist/src/personal-agent/prompts.d.ts +0 -3
  346. package/dist/src/personal-agent/prompts.js +7 -146
  347. package/dist/src/personal-agent/reply-composer.js +3 -3
  348. package/dist/src/personal-agent/reply-style.d.ts +1 -13
  349. package/dist/src/personal-agent/reply-style.js +3 -123
  350. package/dist/src/personal-agent/request-delivery.d.ts +1 -1
  351. package/dist/src/personal-agent/request-delivery.js +1 -1
  352. package/dist/src/personal-agent/request-service.js +2 -2
  353. package/dist/src/personal-agent/specialist-capabilities.js +0 -1
  354. package/dist/src/personal-agent/task-cancel.js +2 -1
  355. package/dist/src/platform/client.d.ts +0 -1
  356. package/dist/src/platform/contracts.d.ts +0 -1
  357. package/dist/src/platform/contracts.js +1 -4
  358. package/dist/src/projects/index.d.ts +0 -1
  359. package/dist/src/projects/index.js +1 -2
  360. package/dist/src/projects/project-loop.d.ts +2 -12
  361. package/dist/src/projects/project-loop.js +19 -42
  362. package/dist/src/projects/project-store.d.ts +0 -1
  363. package/dist/src/projects/project-store.js +0 -11
  364. package/dist/src/projects/types.d.ts +0 -6
  365. package/dist/src/providers/model-usage.js +0 -5
  366. package/dist/src/realtime/runtime.js +0 -1
  367. package/dist/src/routing/agent-session-key.js +1 -1
  368. package/dist/src/session/manager.js +1 -1
  369. package/dist/src/session/store.d.ts +1 -0
  370. package/dist/src/session/types.d.ts +2 -6
  371. package/dist/src/storage/sqlite/connection-wait-repository.js +0 -33
  372. package/dist/src/storage/sqlite/connection.js +2 -2
  373. package/dist/src/storage/sqlite/device-access-repository.d.ts +2 -2
  374. package/dist/src/storage/sqlite/device-access-repository.js +4 -8
  375. package/dist/src/storage/sqlite/fts.d.ts +4 -0
  376. package/dist/src/storage/sqlite/fts.js +13 -4
  377. package/dist/src/storage/sqlite/home-attention-repository.d.ts +1 -1
  378. package/dist/src/storage/sqlite/index.d.ts +1 -3
  379. package/dist/src/storage/sqlite/index.js +4 -8
  380. package/dist/src/storage/sqlite/{migrations/conversation-backup.d.ts → offline-access.d.ts} +1 -4
  381. package/dist/src/storage/sqlite/{migrations/conversation-backup.js → offline-access.js} +6 -25
  382. package/dist/src/storage/sqlite/row-mappers.d.ts +0 -8
  383. package/dist/src/storage/sqlite/row-mappers.js +0 -8
  384. package/dist/src/storage/sqlite/{migrations/errors.d.ts → schema-errors.d.ts} +0 -6
  385. package/dist/src/storage/sqlite/schema-errors.js +28 -0
  386. package/dist/src/storage/sqlite/schema.d.ts +4 -5
  387. package/dist/src/storage/sqlite/schema.js +23 -19
  388. package/dist/src/storage/sqlite/schema.sql +1099 -427
  389. package/dist/src/storage/sqlite/session-identity-sql.js +1 -2
  390. package/dist/src/storage/sqlite/session-read-repository.d.ts +1 -1
  391. package/dist/src/storage/sqlite/session-read-repository.js +1 -2
  392. package/dist/src/storage/sqlite/session-repository.js +10 -36
  393. package/dist/src/storage/sqlite/transcript-repository.d.ts +1 -0
  394. package/dist/src/storage/sqlite/transcript-repository.js +14 -12
  395. package/dist/src/storage/sqlite/{migrations/conversation-windows-owners.js → windows-database-owners.js} +3 -3
  396. package/dist/src/tasks/attention-governor.d.ts +1 -0
  397. package/dist/src/tasks/attention-governor.js +2 -2
  398. package/dist/src/tasks/capabilities/management.d.ts +0 -1
  399. package/dist/src/tasks/capabilities/relations.d.ts +2 -2
  400. package/dist/src/tasks/execution-context.d.ts +1 -1
  401. package/dist/src/tasks/execution-context.js +0 -2
  402. package/dist/src/tasks/home-query-service.d.ts +2 -16
  403. package/dist/src/tasks/home-query-service.js +37 -67
  404. package/dist/src/tasks/index.d.ts +0 -1
  405. package/dist/src/tasks/index.js +1 -2
  406. package/dist/src/tasks/project-operating-view-service.js +0 -1
  407. package/dist/src/tasks/task-application-service.js +0 -5
  408. package/dist/src/tasks/task-repository.d.ts +1 -1
  409. package/dist/src/tasks/task-run-coordinator.js +4 -2
  410. package/dist/src/tui/backends/embedded-backend.d.ts +1 -4
  411. package/dist/src/tui/backends/embedded-backend.js +3 -59
  412. package/dist/src/tui/backends/gateway-realtime-backend.d.ts +1 -2
  413. package/dist/src/tui/backends/gateway-realtime-backend.js +1 -27
  414. package/dist/src/tui/components/chat-log.d.ts +0 -2
  415. package/dist/src/tui/components/chat-log.js +0 -18
  416. package/dist/src/tui/extension-host/runtime-context.js +0 -1
  417. package/dist/src/tui/tui-backend.d.ts +0 -15
  418. package/dist/src/tui/tui-command-formatters.d.ts +0 -3
  419. package/dist/src/tui/tui-command-formatters.js +1 -28
  420. package/dist/src/tui/tui-commands.d.ts +1 -14
  421. package/dist/src/tui/tui-commands.js +4 -89
  422. package/dist/src/tui/tui-startup-resources.js +0 -2
  423. package/dist/src/tui/tui-startup-text.js +2 -3
  424. package/dist/src/tui/tui.js +1 -49
  425. package/dist/src/user-context/trust-policy.js +1 -1
  426. package/dist/src/user-model/capture/semantic.d.ts +18 -1
  427. package/dist/src/user-model/capture/semantic.js +26 -1
  428. package/dist/src/user-model/usage-policy.js +1 -1
  429. package/dist/src/utils/index.js +1 -1
  430. package/dist/src/utils/logger/index.js +1 -1
  431. package/dist/src/utils/logger.js +1 -1
  432. package/dist/src/voice/realtime/agentBroker.js +2 -3
  433. package/dist/src/voice/realtime/memory-context.js +2 -2
  434. package/dist/src/work-discovery/incremental-repository.js +1 -1
  435. package/dist/src/work-discovery/service.js +2 -2
  436. package/package.json +5 -6
  437. package/dist/extensions/feishu/src/workflow-progress.d.ts +0 -27
  438. package/dist/extensions/feishu/src/workflow-progress.js +0 -98
  439. package/dist/extensions/telegram/src/workflow-progress.d.ts +0 -24
  440. package/dist/extensions/telegram/src/workflow-progress.js +0 -72
  441. package/dist/extensions/weixin/src/workflow-progress.d.ts +0 -26
  442. package/dist/extensions/weixin/src/workflow-progress.js +0 -98
  443. package/dist/gateway/static/root/assets/agent-avatar-dicebear-lMrejpsz.js +0 -1
  444. package/dist/gateway/static/root/assets/agent-defaults-settings-panel-lXwR3Rff.js +0 -1
  445. package/dist/gateway/static/root/assets/agents-DFwBf95X.js +0 -77
  446. package/dist/gateway/static/root/assets/app-link-BV_eGr7l.js +0 -1
  447. package/dist/gateway/static/root/assets/app-management-settings-panel-Cja3eV7H.js +0 -1
  448. package/dist/gateway/static/root/assets/apps-page-C3xbCdYa.js +0 -1
  449. package/dist/gateway/static/root/assets/automations-workspace-CWvHbJBK.js +0 -6
  450. package/dist/gateway/static/root/assets/browser-automations-page-BtvOURHQ.js +0 -3
  451. package/dist/gateway/static/root/assets/browser-settings-page-C_OeE79S.js +0 -3
  452. package/dist/gateway/static/root/assets/capabilities-CD6PzNK7.js +0 -1
  453. package/dist/gateway/static/root/assets/capabilities-page-BKF6q_tC.js +0 -2
  454. package/dist/gateway/static/root/assets/capabilities-settings-panel-B7qOaUZs.js +0 -8
  455. package/dist/gateway/static/root/assets/channels-3M9-anCN.js +0 -1
  456. package/dist/gateway/static/root/assets/code-editor-CXIH8jQw.js +0 -1
  457. package/dist/gateway/static/root/assets/computer-settings-page-LaekhDG6.js +0 -1
  458. package/dist/gateway/static/root/assets/connector-service-page-DJP1n1_n.js +0 -1
  459. package/dist/gateway/static/root/assets/connectors-page-DmQqMy6l.js +0 -1
  460. package/dist/gateway/static/root/assets/dependency-picker-BhElpD_6.js +0 -1
  461. package/dist/gateway/static/root/assets/desktop-pet-ByvV-cDD.js +0 -1
  462. package/dist/gateway/static/root/assets/desktop-pet-settings-BBruQu-_.js +0 -1
  463. package/dist/gateway/static/root/assets/device-pairing-wizard-C3zOy8PO.js +0 -1
  464. package/dist/gateway/static/root/assets/dist-BGTk37IG.js +0 -1
  465. package/dist/gateway/static/root/assets/file-archive-DanfQJNe.js +0 -1
  466. package/dist/gateway/static/root/assets/file-braces-BoAMI_k9.js +0 -1
  467. package/dist/gateway/static/root/assets/gateway-realtime-CP6L2jIR.js +0 -1
  468. package/dist/gateway/static/root/assets/gateway-realtime-store-yXB4a40_.js +0 -1
  469. package/dist/gateway/static/root/assets/gateway-settings-CzrFZ0lB.js +0 -1
  470. package/dist/gateway/static/root/assets/highlight-code-BH65IIbJ.js +0 -1
  471. package/dist/gateway/static/root/assets/home-page-cXmd8x0S.js +0 -2
  472. package/dist/gateway/static/root/assets/image-generation-api-C6su4n9B.js +0 -1
  473. package/dist/gateway/static/root/assets/imports-page-CsXYryWS.js +0 -1
  474. package/dist/gateway/static/root/assets/index-BZlryZm8.css +0 -1
  475. package/dist/gateway/static/root/assets/index-uAJlrGvo.js +0 -267
  476. package/dist/gateway/static/root/assets/keyboard-shortcuts-settings-GYKLt0oF.js +0 -1
  477. package/dist/gateway/static/root/assets/languages-BFe8nIOO.js +0 -2
  478. package/dist/gateway/static/root/assets/local-app-workbench-page-Dw-i6VkX.js +0 -1
  479. package/dist/gateway/static/root/assets/local-apps-page-DslilwNE.js +0 -1
  480. package/dist/gateway/static/root/assets/locale-store-D_migb9R.js +0 -1
  481. package/dist/gateway/static/root/assets/logs-page-4N8bGPIE.js +0 -2
  482. package/dist/gateway/static/root/assets/management-settings-CPmxI1k0.js +0 -1
  483. package/dist/gateway/static/root/assets/markdown-editor-BhBJANcx.js +0 -1
  484. package/dist/gateway/static/root/assets/markdown-view-Ljt0bhfF.js +0 -324
  485. package/dist/gateway/static/root/assets/markdown-view-ixUWAmoy.css +0 -1
  486. package/dist/gateway/static/root/assets/mermaid-MCJ5UELQ-Ba-WQCki.js +0 -1
  487. package/dist/gateway/static/root/assets/mermaid-render-604gISVe.js +0 -134
  488. package/dist/gateway/static/root/assets/messages-D__oW2yE.js +0 -3
  489. package/dist/gateway/static/root/assets/note-detail-panel-CjTm5gxS.js +0 -5
  490. package/dist/gateway/static/root/assets/note-image-lightbox-hbSbEEfN.js +0 -1
  491. package/dist/gateway/static/root/assets/notes-page-DkESStKc.js +0 -8
  492. package/dist/gateway/static/root/assets/page-context-capture-button-eyzTNrCe.js +0 -1
  493. package/dist/gateway/static/root/assets/personal-page-DZxbFQvF.js +0 -1
  494. package/dist/gateway/static/root/assets/personal-settings-panel-DzubCRqj.js +0 -1
  495. package/dist/gateway/static/root/assets/plugin-details-dialog-BjVLbxZM.js +0 -1
  496. package/dist/gateway/static/root/assets/plus-Q2yW6OE7.js +0 -1
  497. package/dist/gateway/static/root/assets/preview-open-alternatives-7pUtUL4O.js +0 -1
  498. package/dist/gateway/static/root/assets/product-delivery-DwmnNJvk.js +0 -1
  499. package/dist/gateway/static/root/assets/product-preview-content-COo4zwp9.js +0 -1
  500. package/dist/gateway/static/root/assets/project-detail-page-CrIH6nEy.js +0 -1
  501. package/dist/gateway/static/root/assets/projects-page-D4swvBmH.js +0 -1
  502. package/dist/gateway/static/root/assets/remote-access-hub-DltfIMtv.js +0 -1
  503. package/dist/gateway/static/root/assets/runtime-tools-api-CmEWVrOg.js +0 -5
  504. package/dist/gateway/static/root/assets/session-api-aQLptIs9.js +0 -1
  505. package/dist/gateway/static/root/assets/sessions-page-CfYU53aw.js +0 -1
  506. package/dist/gateway/static/root/assets/settings-advanced-gate-BJBoWYbO.js +0 -1
  507. package/dist/gateway/static/root/assets/setup-status-panel-DZgVMRXr.js +0 -1
  508. package/dist/gateway/static/root/assets/share-preview-page-C2LHd_Nl.js +0 -2
  509. package/dist/gateway/static/root/assets/shares-settings-C5MTc6t-.js +0 -1
  510. package/dist/gateway/static/root/assets/skill-reload-api-BcdA9ezU.js +0 -1
  511. package/dist/gateway/static/root/assets/skills-page-BMw8XbKL.js +0 -2
  512. package/dist/gateway/static/root/assets/source-workspace-editor-DunRD1gY.js +0 -1
  513. package/dist/gateway/static/root/assets/style-DR0-RKaL.js +0 -7
  514. package/dist/gateway/static/root/assets/system-settings-panel-2Kr9Y-FJ.js +0 -1
  515. package/dist/gateway/static/root/assets/tab-completion-input.utils-BP3NH_du.js +0 -1
  516. package/dist/gateway/static/root/assets/task-detail-page-7kPco8Ys.js +0 -2
  517. package/dist/gateway/static/root/assets/task-expandable-content-4s_FTl-9.js +0 -1
  518. package/dist/gateway/static/root/assets/tasks-B4bZpO6O.js +0 -1
  519. package/dist/gateway/static/root/assets/tracing-settings-page-D53wxq60.js +0 -1
  520. package/dist/gateway/static/root/assets/user-model-page-KRy50OBd.js +0 -2
  521. package/dist/gateway/static/root/assets/work-discovery-overlay-Bd9HLsds.js +0 -1
  522. package/dist/gateway/static/root/assets/workflow-run-setup-panel-C9mAiHBd.js +0 -3
  523. package/dist/gateway/static/root/assets/workflows-page-CGg4GWwt.js +0 -6
  524. package/dist/gateway/static/root/assets/x-B_N4OPjy.js +0 -1
  525. package/dist/gateway/static/root/assets/xml-_d7dTN2Q.js +0 -3
  526. package/dist/src/agent/embedded/session-manager-init.d.ts +0 -4
  527. package/dist/src/agent/embedded/session-manager-init.js +0 -48
  528. package/dist/src/agent/tools/workflow-manage-tool.d.ts +0 -2
  529. package/dist/src/agent/tools/workflow-manage-tool.js +0 -225
  530. package/dist/src/agent/tools/workflow-tool.d.ts +0 -20
  531. package/dist/src/agent/tools/workflow-tool.js +0 -155
  532. package/dist/src/agent/workflow/agent-progress.d.ts +0 -5
  533. package/dist/src/agent/workflow/agent-progress.js +0 -65
  534. package/dist/src/agent/workflow/builtins/index.d.ts +0 -2
  535. package/dist/src/agent/workflow/builtins/index.js +0 -374
  536. package/dist/src/agent/workflow/catalog.d.ts +0 -52
  537. package/dist/src/agent/workflow/catalog.js +0 -150
  538. package/dist/src/agent/workflow/channel-capability.d.ts +0 -76
  539. package/dist/src/agent/workflow/channel-capability.js +0 -1
  540. package/dist/src/agent/workflow/index.d.ts +0 -10
  541. package/dist/src/agent/workflow/index.js +0 -9
  542. package/dist/src/agent/workflow/progress-broker.d.ts +0 -80
  543. package/dist/src/agent/workflow/progress-broker.js +0 -261
  544. package/dist/src/agent/workflow/snapshot-empty.d.ts +0 -2
  545. package/dist/src/agent/workflow/snapshot-empty.js +0 -17
  546. package/dist/src/agent/workflow/snapshot.d.ts +0 -28
  547. package/dist/src/agent/workflow/snapshot.js +0 -267
  548. package/dist/src/agent/workflow/step-labels.d.ts +0 -8
  549. package/dist/src/agent/workflow/step-labels.js +0 -50
  550. package/dist/src/agent/workflow/structured-output-tool.d.ts +0 -33
  551. package/dist/src/agent/workflow/structured-output-tool.js +0 -56
  552. package/dist/src/agent/workflow/subagent-runner.d.ts +0 -46
  553. package/dist/src/agent/workflow/subagent-runner.js +0 -221
  554. package/dist/src/agent/workflow/types.d.ts +0 -252
  555. package/dist/src/agent/workflow/types.js +0 -1
  556. package/dist/src/agent/workflow/workflow-child-tools.d.ts +0 -4
  557. package/dist/src/agent/workflow/workflow-child-tools.js +0 -38
  558. package/dist/src/agent-catalog/migrations/identity-markdown-cutover.d.ts +0 -5
  559. package/dist/src/agent-catalog/migrations/identity-markdown-cutover.js +0 -94
  560. package/dist/src/agent-catalog/migrations/legacy-config-cutover.d.ts +0 -11
  561. package/dist/src/agent-catalog/migrations/legacy-config-cutover.js +0 -194
  562. package/dist/src/chat-commands/builtins/workflow.d.ts +0 -18
  563. package/dist/src/chat-commands/builtins/workflow.js +0 -249
  564. package/dist/src/gateway/gateway-workflow-host.types.d.ts +0 -23
  565. package/dist/src/gateway/gateway-workflow-host.types.js +0 -1
  566. package/dist/src/gateway/hono/routes/workflows.d.ts +0 -3
  567. package/dist/src/gateway/hono/routes/workflows.js +0 -572
  568. package/dist/src/knowledge-memory/repair-evidence.d.ts +0 -2
  569. package/dist/src/knowledge-memory/repair-evidence.js +0 -57
  570. package/dist/src/migrations/cloud-public-models.d.ts +0 -7
  571. package/dist/src/migrations/cloud-public-models.js +0 -157
  572. package/dist/src/migrations/memory-config.d.ts +0 -2
  573. package/dist/src/migrations/memory-config.js +0 -76
  574. package/dist/src/migrations/retired-local-stt.d.ts +0 -2
  575. package/dist/src/migrations/retired-local-stt.js +0 -52
  576. package/dist/src/projects/workflow-bind.d.ts +0 -1
  577. package/dist/src/projects/workflow-bind.js +0 -15
  578. package/dist/src/storage/sqlite/migrations/218_core_relation_indexes.sql +0 -26
  579. package/dist/src/storage/sqlite/migrations/219_json_contracts.sql +0 -123
  580. package/dist/src/storage/sqlite/migrations/220_normalize_timestamps.sql +0 -339
  581. package/dist/src/storage/sqlite/migrations/221_ai_usage_retention_index.sql +0 -2
  582. package/dist/src/storage/sqlite/migrations/222_session_config_authority.sql +0 -13
  583. package/dist/src/storage/sqlite/migrations/223_session_creation_receipts.sql +0 -59
  584. package/dist/src/storage/sqlite/migrations/224_task_origin_links.sql +0 -8
  585. package/dist/src/storage/sqlite/migrations/225_task_collaboration.sql +0 -32
  586. package/dist/src/storage/sqlite/migrations/226_task_main_updates.sql +0 -9
  587. package/dist/src/storage/sqlite/migrations/227_task_main_update_decisions.sql +0 -8
  588. package/dist/src/storage/sqlite/migrations/228_task_main_agent_links.sql +0 -14
  589. package/dist/src/storage/sqlite/migrations/229_task_criterion_reviews.sql +0 -12
  590. package/dist/src/storage/sqlite/migrations/230_personal_agent_onboarding.sql +0 -8
  591. package/dist/src/storage/sqlite/migrations/231_task_result_deliveries.sql +0 -32
  592. package/dist/src/storage/sqlite/migrations/232_personal_requests.sql +0 -28
  593. package/dist/src/storage/sqlite/migrations/233_observability_usage_links.sql +0 -3
  594. package/dist/src/storage/sqlite/migrations/234_task_result_reply.sql +0 -14
  595. package/dist/src/storage/sqlite/migrations/235_personal_conversation_priority.sql +0 -3
  596. package/dist/src/storage/sqlite/migrations/236_personal_proactivity.sql +0 -53
  597. package/dist/src/storage/sqlite/migrations/237_personal_strategy_versions.sql +0 -18
  598. package/dist/src/storage/sqlite/migrations/238_browser_record_replay.sql +0 -45
  599. package/dist/src/storage/sqlite/migrations/239_clarification_notifications.sql +0 -26
  600. package/dist/src/storage/sqlite/migrations/240_device_settings.sql +0 -5
  601. package/dist/src/storage/sqlite/migrations/241_device_grant_audit.sql +0 -13
  602. package/dist/src/storage/sqlite/migrations/242_cloud_usage_receipts.sql +0 -5
  603. package/dist/src/storage/sqlite/migrations/243_voice_opening_greetings.sql +0 -12
  604. package/dist/src/storage/sqlite/migrations/244_device_request_proofs.sql +0 -8
  605. package/dist/src/storage/sqlite/migrations/245_memory_learning.sql +0 -125
  606. package/dist/src/storage/sqlite/migrations/246_personal_session_thinking.sql +0 -22
  607. package/dist/src/storage/sqlite/migrations/247_agent_selection_records.sql +0 -32
  608. package/dist/src/storage/sqlite/migrations/248_next_turn_suggestions.sql +0 -20
  609. package/dist/src/storage/sqlite/migrations/249_task_allocations.sql +0 -17
  610. package/dist/src/storage/sqlite/migrations/250_research_checkpoints.sql +0 -15
  611. package/dist/src/storage/sqlite/migrations/251_personal_result_reads.sql +0 -40
  612. package/dist/src/storage/sqlite/migrations/252_task_work_revisions.sql +0 -15
  613. package/dist/src/storage/sqlite/migrations/253_discussion_processing_recovery.sql +0 -20
  614. package/dist/src/storage/sqlite/migrations/254_discussion_annotations.sql +0 -17
  615. package/dist/src/storage/sqlite/migrations/255_discussion_chapter_progress.sql +0 -10
  616. package/dist/src/storage/sqlite/migrations/256_task_main_update_retries.sql +0 -21
  617. package/dist/src/storage/sqlite/migrations/257_session_composer_history.sql +0 -11
  618. package/dist/src/storage/sqlite/migrations/258_task_phase_changes.sql +0 -20
  619. package/dist/src/storage/sqlite/migrations/259_personal_default_style.sql +0 -10
  620. package/dist/src/storage/sqlite/migrations/discover.d.ts +0 -4
  621. package/dist/src/storage/sqlite/migrations/discover.js +0 -40
  622. package/dist/src/storage/sqlite/migrations/errors.js +0 -40
  623. package/dist/src/storage/sqlite/migrations/runner.d.ts +0 -22
  624. package/dist/src/storage/sqlite/migrations/runner.js +0 -112
  625. package/dist/src/storage/sqlite/migrations/types.d.ts +0 -12
  626. package/dist/src/storage/sqlite/migrations/types.js +0 -1
  627. package/dist/src/tasks/task-workflow-coordinator.d.ts +0 -5
  628. package/dist/src/tasks/task-workflow-coordinator.js +0 -55
  629. package/dist/src/tui/tui-workflow-slash.d.ts +0 -29
  630. package/dist/src/tui/tui-workflow-slash.js +0 -58
  631. package/dist/src/workflows/authoring/index.d.ts +0 -2
  632. package/dist/src/workflows/authoring/index.js +0 -3
  633. package/dist/src/workflows/authoring/workflow-draft-defaults.d.ts +0 -3
  634. package/dist/src/workflows/authoring/workflow-draft-defaults.js +0 -63
  635. package/dist/src/workflows/authoring/workflow-draft-store.d.ts +0 -29
  636. package/dist/src/workflows/authoring/workflow-draft-store.js +0 -52
  637. package/dist/src/workflows/context/workflow-context-snapshot-repository.d.ts +0 -21
  638. package/dist/src/workflows/context/workflow-context-snapshot-repository.js +0 -41
  639. package/dist/src/workflows/context/workflow-context.d.ts +0 -18
  640. package/dist/src/workflows/context/workflow-context.js +0 -164
  641. package/dist/src/workflows/domain/command.d.ts +0 -19
  642. package/dist/src/workflows/domain/command.js +0 -1
  643. package/dist/src/workflows/domain/definition-utils.d.ts +0 -18
  644. package/dist/src/workflows/domain/definition-utils.js +0 -90
  645. package/dist/src/workflows/domain/definition.d.ts +0 -164
  646. package/dist/src/workflows/domain/definition.js +0 -1
  647. package/dist/src/workflows/domain/event.d.ts +0 -88
  648. package/dist/src/workflows/domain/event.js +0 -1
  649. package/dist/src/workflows/domain/index.d.ts +0 -8
  650. package/dist/src/workflows/domain/index.js +0 -5
  651. package/dist/src/workflows/domain/result.d.ts +0 -68
  652. package/dist/src/workflows/domain/result.js +0 -1
  653. package/dist/src/workflows/domain/run.d.ts +0 -257
  654. package/dist/src/workflows/domain/run.js +0 -12
  655. package/dist/src/workflows/domain/schema-validation.d.ts +0 -8
  656. package/dist/src/workflows/domain/schema-validation.js +0 -26
  657. package/dist/src/workflows/domain/validation.d.ts +0 -22
  658. package/dist/src/workflows/domain/validation.js +0 -318
  659. package/dist/src/workflows/engine/index.d.ts +0 -2
  660. package/dist/src/workflows/engine/index.js +0 -3
  661. package/dist/src/workflows/engine/projector.d.ts +0 -3
  662. package/dist/src/workflows/engine/projector.js +0 -276
  663. package/dist/src/workflows/engine/workflow-engine.d.ts +0 -88
  664. package/dist/src/workflows/engine/workflow-engine.js +0 -719
  665. package/dist/src/workflows/index.d.ts +0 -11
  666. package/dist/src/workflows/index.js +0 -19
  667. package/dist/src/workflows/project-presets/project-workflow-preset-repository.d.ts +0 -20
  668. package/dist/src/workflows/project-presets/project-workflow-preset-repository.js +0 -39
  669. package/dist/src/workflows/registry/catalog-workflow-definition-registry.d.ts +0 -9
  670. package/dist/src/workflows/registry/catalog-workflow-definition-registry.js +0 -30
  671. package/dist/src/workflows/registry/index.d.ts +0 -2
  672. package/dist/src/workflows/registry/index.js +0 -2
  673. package/dist/src/workflows/registry/workflow-definition-registry.d.ts +0 -15
  674. package/dist/src/workflows/registry/workflow-definition-registry.js +0 -1
  675. package/dist/src/workflows/runtime/graph-workflow-runtime.d.ts +0 -10
  676. package/dist/src/workflows/runtime/graph-workflow-runtime.js +0 -289
  677. package/dist/src/workflows/runtime/index.d.ts +0 -2
  678. package/dist/src/workflows/runtime/index.js +0 -2
  679. package/dist/src/workflows/runtime/workflow-runtime-port.d.ts +0 -13
  680. package/dist/src/workflows/runtime/workflow-runtime-port.js +0 -1
  681. package/dist/src/workflows/service/run-view-to-snapshot.d.ts +0 -4
  682. package/dist/src/workflows/service/run-view-to-snapshot.js +0 -64
  683. package/dist/src/workflows/service/workflow-run-service.d.ts +0 -63
  684. package/dist/src/workflows/service/workflow-run-service.js +0 -892
  685. package/dist/src/workflows/service/workflow-run-service.types.d.ts +0 -62
  686. package/dist/src/workflows/service/workflow-run-service.types.js +0 -1
  687. package/dist/src/workflows/service/workflow-session-bridge.d.ts +0 -33
  688. package/dist/src/workflows/service/workflow-session-bridge.js +0 -244
  689. package/dist/src/workflows/service/workflow-session-key.d.ts +0 -3
  690. package/dist/src/workflows/service/workflow-session-key.js +0 -19
  691. package/dist/src/workflows/service/workflow-writeback-service.d.ts +0 -9
  692. package/dist/src/workflows/service/workflow-writeback-service.js +0 -107
  693. package/dist/src/workflows/store/event-store.d.ts +0 -16
  694. package/dist/src/workflows/store/event-store.js +0 -38
  695. package/dist/src/workflows/store/paths.d.ts +0 -5
  696. package/dist/src/workflows/store/paths.js +0 -18
  697. package/dist/src/workflows/store/run-index-store.d.ts +0 -9
  698. package/dist/src/workflows/store/run-index-store.js +0 -64
  699. package/dist/src/workflows/store/run-store.d.ts +0 -16
  700. package/dist/src/workflows/store/run-store.js +0 -40
  701. package/skills/engineering/workflow-authoring/SKILL.md +0 -32
  702. /package/dist/gateway/static/root/assets/{style-DLioOiRN.css → project-detail-page-DLioOiRN.css} +0 -0
  703. /package/dist/src/storage/sqlite/{migrations/conversation-windows-owners.d.ts → windows-database-owners.d.ts} +0 -0
@@ -1 +0,0 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{f as i,g as a}from"./chunk-KS7C4IRE-B2HK1psj.js";import{n as o,r as s,t as c}from"./popover-select-DGKUpVsz.js";import{t as l}from"./circle-check-C23XjkUj.js";import{t as u}from"./external-link-DjqjBmc3.js";import{t as d}from"./loader-circle-CifKLtgG.js";import{t as f}from"./plus-Q2yW6OE7.js";import{t as p}from"./x-B_N4OPjy.js";import{t as m}from"./messages-D__oW2yE.js";import{t as h}from"./cn-0WouolD0.js";import{a as g,c as _,n as v,r as y}from"./locale-store-D_migb9R.js";import{a as b,i as x,n as S,o as C,r as w,s as T,t as E}from"./dist-BGTk37IG.js";import{n as D}from"./copy-to-clipboard-HOJ79TWv.js";import{i as O}from"./vendor-swr-BIWyz7Rc.js";import{t as k}from"./button-aIC072nz.js";import{t as A}from"./skeleton-BI5TyibZ.js";import{n as j,r as M}from"./gateway-config-swr-CTXr917C.js";import{$s as N,Ac as P,Ca as F,Cc as I,Dc as L,Ec as R,Eu as z,Fl as B,Fs as V,Go as H,Id as U,J as W,Jd as G,Kd as K,Md as ee,Ml as q,Nc as te,Nd as J,Oc as ne,Ol as Y,Ql as re,Sc as ie,Ss as ae,Tc as oe,Xl as se,Y as X,_l as ce,ac as le,ad as ue,af as de,ba as fe,bs as Z,cc as pe,dc as me,dr as he,dt as ge,ec as _e,ef as ve,es as ye,fc as be,fo as xe,fr as Se,ft as Ce,gc as we,hc as Te,ht as Ee,ic as De,if as Oe,it as ke,jc as Ae,jd as je,kc as Me,lr as Ne,lt as Pe,mc as Fe,mt as Ie,nc as Le,nt as Re,nu as ze,oc as Be,os as Ve,ou as He,pc as Ue,pt as We,pu as Ge,rc as Ke,sc as qe,sf as Je,st as Ye,tc as Xe,tt as Ze,uc as Qe,ur as $e,ut as et,va as tt,vc as nt,wc as rt,xa as it,xc as at,ya as ot,yc as st}from"./index-uAJlrGvo.js";import{n as ct,t as lt}from"./capability-header-actions-oBPqUlbj.js";import{t as ut}from"./connector-service-page-DJP1n1_n.js";import{t as dt}from"./number-input-DDeqHK-G.js";var Q=e(t(),1),ft=n(),$=r();function pt(e){let t=(0,ft.c)(57),{connector:n,installed:r,onInstall:i,onOpenDetails:a,t:o}=e,s,c,u,d,f,p;if(t[0]!==n||t[1]!==r||t[2]!==i||t[3]!==a||t[4]!==o){let e=n.capabilities.filter(mt),m=e.slice(0,2),g=Math.max(0,e.length-m.length),_=o.connect,v;t[11]!==n||t[12]!==o?(v=Ce(n,o),t[11]=n,t[12]=o,t[13]=v):v=t[13];let y=v,b=n.verificationLevel===`verified`?o.connectorVerified:n.verificationLevel===`beta`?o.connectorBeta:n.verificationLevel===`experimental`?o.connectorExperimental:null,x;t[14]!==_||t[15]!==n||t[16]!==i?(x=e=>(0,$.jsxs)(k,{type:`button`,variant:`secondary`,className:h(`h-8 justify-center px-2.5 text-xs font-medium`,e),onClick:()=>i(n),children:[(0,$.jsx)(z,{className:`size-4`}),_]}),t[14]=_,t[15]=n,t[16]=i,t[17]=x):x=t[17],s=x,p=`group flex min-h-[8.75rem] flex-col rounded-xl border border-edge bg-surface-panel p-4 transition-colors hover:bg-surface-hover/45 focus-within:ring-2 focus-within:ring-accent/30`,c=`flex min-w-0 flex-1 flex-col`;let S;t[18]===n?S=t[19]:(S=(0,$.jsx)(et,{connector:n}),t[18]=n,t[19]=S);let C;t[20]!==n||t[21]!==a?(C=a?(0,$.jsx)(`button`,{type:`button`,className:`block max-w-full truncate text-left text-sm font-semibold text-fg hover:underline`,onClick:()=>a(n),children:n.displayName}):(0,$.jsx)(`h3`,{className:`truncate text-sm font-semibold text-fg`,children:n.displayName}),t[20]=n,t[21]=a,t[22]=C):C=t[22];let w;t[23]===b?w=t[24]:(w=b?(0,$.jsx)(`span`,{className:`mt-1 inline-flex rounded-full border border-edge px-1.5 py-0.5 text-[10px] font-medium text-fg-subtle`,children:b}):null,t[23]=b,t[24]=w);let T;t[25]!==w||t[26]!==C?(T=(0,$.jsxs)(`div`,{className:`min-w-0`,children:[C,w]}),t[25]=w,t[26]=C,t[27]=T):T=t[27];let E;t[28]!==T||t[29]!==S?(E=(0,$.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[S,T]}),t[28]=T,t[29]=S,t[30]=E):E=t[30];let D;t[31]!==r||t[32]!==s?(D=r?null:(0,$.jsx)(`div`,{className:`hidden shrink-0 items-center gap-1 sm:flex`,children:s()}),t[31]=r,t[32]=s,t[33]=D):D=t[33];let O;t[34]!==r||t[35]!==o.connectedBadge?(O=r?(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full border border-emerald-500/30 bg-emerald-500/10 px-2 py-0.5 text-[11px] font-medium text-emerald-700 dark:text-emerald-300`,children:[(0,$.jsx)(l,{className:`size-3`,"aria-hidden":!0}),o.connectedBadge]}):null,t[34]=r,t[35]=o.connectedBadge,t[36]=O):O=t[36];let A;t[37]!==D||t[38]!==O?(A=(0,$.jsxs)(`div`,{className:`flex shrink-0 items-start gap-2`,children:[D,O]}),t[37]=D,t[38]=O,t[39]=A):A=t[39],t[40]!==E||t[41]!==A?(u=(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[E,A]}),t[40]=E,t[41]=A,t[42]=u):u=t[42],t[43]===y?d=t[44]:(d=(0,$.jsx)(`p`,{className:`mt-3 line-clamp-2 text-sm leading-6 text-fg-muted`,title:y,children:y}),t[43]=y,t[44]=d),f=m.length>0?(0,$.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-1.5`,children:[m.map(e=>(0,$.jsx)(`span`,{className:`rounded-md bg-surface-base px-2 py-0.5 text-[11px] text-fg-muted`,children:o.connectorCapabilityLabels[e]??e},e)),g>0?(0,$.jsxs)(`span`,{className:`rounded-md bg-surface-base px-2 py-0.5 text-[11px] text-fg-subtle`,children:[`+`,g]}):null]}):null,t[0]=n,t[1]=r,t[2]=i,t[3]=a,t[4]=o,t[5]=s,t[6]=c,t[7]=u,t[8]=d,t[9]=f,t[10]=p}else s=t[5],c=t[6],u=t[7],d=t[8],f=t[9],p=t[10];let m;t[45]!==c||t[46]!==u||t[47]!==d||t[48]!==f?(m=(0,$.jsxs)(`div`,{className:c,children:[u,d,f]}),t[45]=c,t[46]=u,t[47]=d,t[48]=f,t[49]=m):m=t[49];let g;t[50]!==r||t[51]!==s?(g=r?null:(0,$.jsx)(`div`,{className:`mt-4 flex flex-col gap-2 border-t border-edge pt-3 sm:hidden`,children:s(`w-full`)}),t[50]=r,t[51]=s,t[52]=g):g=t[52];let _;return t[53]!==p||t[54]!==m||t[55]!==g?(_=(0,$.jsxs)(`div`,{className:p,children:[m,g]}),t[53]=p,t[54]=m,t[55]=g,t[56]=_):_=t[56],_}function mt(e){return!e.startsWith(`runtime.`)&&!e.startsWith(`auth.`)}var ht=[`c0`,`c1`,`c2`,`c3`,`c4`,`c5`];function gt(e,t){return t.some(t=>t.connectorId===e.id)}var _t=`animate-pulse motion-reduce:animate-none rounded-md bg-surface-hover dark:bg-surface-active/50`;function vt(){let e=(0,ft.c)(2),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(`div`,{className:h(`size-10 shrink-0 rounded-xl`,_t)}),e[0]=t):t=e[0];let n;return e[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,$.jsx)(`div`,{className:`flex h-full min-h-[9.5rem] flex-col rounded-xl bg-surface-panel p-4 shadow-surface`,"aria-hidden":!0,children:(0,$.jsxs)(`div`,{className:`flex min-h-0 flex-1 items-start gap-3`,children:[t,(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,$.jsx)(`div`,{className:h(`h-4 min-w-0 flex-1`,_t)}),(0,$.jsx)(`div`,{className:h(`h-8 w-[4.5rem] shrink-0 rounded-lg`,_t)})]}),(0,$.jsx)(`div`,{className:h(`h-3 w-full`,_t)}),(0,$.jsx)(`div`,{className:h(`h-3 w-[88%]`,_t)})]})]})}),e[1]=n):n=e[1],n}function yt(){let e=(0,ft.c)(2),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(A,{className:`size-9 shrink-0 rounded-lg`}),e[0]=t):t=e[0];let n;return e[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,$.jsxs)(`div`,{className:`flex min-h-[8.75rem] min-w-0 flex-col rounded-xl border border-edge bg-surface-panel p-4`,"aria-hidden":!0,children:[(0,$.jsxs)(`div`,{className:`flex items-start gap-3`,children:[t,(0,$.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-2`,children:[(0,$.jsx)(A,{className:`h-4 w-28 max-w-full`}),(0,$.jsx)(A,{className:`h-3 w-20 max-w-full`})]})]}),(0,$.jsx)(A,{className:`mt-2 h-3 w-48 max-w-full`}),(0,$.jsx)(A,{className:`ml-auto mt-auto h-3 w-16`})]}),e[1]=n):n=e[1],n}var bt=[`understand`,`act`,`reach`];function xt(e){if(e.benefits?.length)return[...new Set(e.benefits)];let t=new Set(e.capabilities),n=[e.id,e.displayName,...e.tags??[]].join(` `).toLowerCase(),r=[];return(t.has(`context`)||t.has(`memory_source`)||t.has(`resources`)||e.category===`docs`||e.category===`data`||/notion|drive|document|confluence|airtable|database|knowledge|wiki/.test(n))&&r.push(`understand`),t.has(`tools`)&&r.push(`act`),(t.has(`channel`)||/slack|telegram|discord|teams|mail|message|wechat|weixin/.test(n))&&r.push(`reach`),r.length?[...new Set(r)]:[`act`]}function St(e){return xt(e)[0]??`act`}function Ct(e,t){let n=t?St(t):`act`,r=e.connectionStatus===`connected`||e.status===`connected`||e.usage.lastHealthStatus===`ok`,i=e.status===`not_configured`||e.status===`failed`||e.status===`degraded`||e.status===`unauthorized`||e.connectionStatus===`unauthorized`||e.connectionStatus===`error`,a=n===`understand`?e.usage.lastResourceCount:n===`act`?e.usage.lastToolCount:void 0;return{benefit:n,state:r?`ready`:i?`needs_setup`:`checking`,availableCount:a}}function wt(e,t){return t.connectorCapabilityLabels[e]??e}function Tt(e,t){if(e.runtime.type===`mcp`)return We(t.connectorRuntimeMcp,{serverId:e.runtime.serverId});let n=e.runtime.type===`composio`?e.runtime.toolkit:e.runtime.type===`cli`?e.runtime.adapterId:e.runtime.sourceKind;return We(t.connectorRuntimeGeneric,{runtime:e.runtime.type,id:n??e.runtime.type})}function Et(e,t){return e.auth.mode===`cli`?t.connectorAuthCli:e.auth.mode===`oauth`?t.connectorAuthOAuth:e.auth.mode===`apiKey`?t.connectorAuthApiKey:t.connectorAuthNone}function Dt(e){let t=(0,ft.c)(133),{connector:n,installed:r,onClose:i,onInstall:a,t:o}=e,s;t[0]!==n||t[1]!==o?(s=Ce(n,o),t[0]=n,t[1]=o,t[2]=s):s=t[2];let c=s,u,d,f,m,g,_,v,y,D,O,A,j,M,N,P,F;if(t[3]!==n||t[4]!==c||t[5]!==r||t[6]!==i||t[7]!==o){let e=xt(n),a;t[24]!==n.setup.config||t[25]!==n.setup.secrets?(a=[...(n.setup.secrets??[]).filter(At),...(n.setup.config??[]).filter(kt)],t[24]=n.setup.config,t[25]=n.setup.secrets,t[26]=a):a=t[26];let s=a,k=n.capabilities.filter(Ot);f=E,v=!0,t[27]===i?y=t[28]:(y=e=>{e||i()},t[27]=i,t[28]=y),d=C,t[29]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,$.jsx)(b,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),t[29]=_):_=t[29],u=w,t[30]===Symbol.for(`react.memo_cache_sentinel`)?(m=h(`xopc-dialog-content fixed left-1/2 top-1/2 z-[60] flex h-[min(100vh-2rem,42rem)] w-[min(100%-2rem,min(92vw,44rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden`,`rounded-2xl border border-edge bg-surface-overlay shadow-float outline-none dark:border-edge`),t[30]=m):m=t[30];let I;t[31]===n?I=t[32]:(I=(0,$.jsx)(et,{connector:n,size:`lg`}),t[31]=n,t[32]=I);let L;t[33]===n.displayName?L=t[34]:(L=(0,$.jsx)(T,{className:`text-base font-semibold text-fg`,children:n.displayName}),t[33]=n.displayName,t[34]=L);let R;t[35]!==r||t[36]!==o.connectedBadge?(R=r?(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full bg-emerald-500/10 px-2 py-0.5 text-[11px] font-medium text-emerald-700 dark:text-emerald-300`,children:[(0,$.jsx)(l,{className:`size-3`,"aria-hidden":!0}),o.connectedBadge]}):null,t[35]=r,t[36]=o.connectedBadge,t[37]=R):R=t[37];let z;t[38]!==L||t[39]!==R?(z=(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[L,R]}),t[38]=L,t[39]=R,t[40]=z):z=t[40];let B;t[41]===c?B=t[42]:(B=(0,$.jsx)(x,{className:`mt-1 line-clamp-3 text-sm leading-6 text-fg-muted`,children:c}),t[41]=c,t[42]=B);let V;t[43]!==z||t[44]!==B?(V=(0,$.jsxs)(`div`,{className:`min-w-0`,children:[z,B]}),t[43]=z,t[44]=B,t[45]=V):V=t[45];let H;t[46]!==I||t[47]!==V?(H=(0,$.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[I,V]}),t[46]=I,t[47]=V,t[48]=H):H=t[48];let U;t[49]===Symbol.for(`react.memo_cache_sentinel`)?(U=h(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,te.focusRingPanel),t[49]=U):U=t[49];let W;t[50]===Symbol.for(`react.memo_cache_sentinel`)?(W=(0,$.jsx)(p,{className:`size-5`,strokeWidth:1.75,"aria-hidden":!0}),t[50]=W):W=t[50];let G;t[51]===o.modalClose?G=t[52]:(G=(0,$.jsx)(S,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:U,"aria-label":o.modalClose,children:W})}),t[51]=o.modalClose,t[52]=G),t[53]!==H||t[54]!==G?(g=(0,$.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge-subtle px-5 py-5 sm:px-6`,children:[H,G]}),t[53]=H,t[54]=G,t[55]=g):g=t[55],N=`min-h-0 flex-1 space-y-5 overflow-y-auto px-5 py-5 sm:px-6`,P=e.length?(0,$.jsxs)(`section`,{children:[(0,$.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:o.connectorWhyConnect}),(0,$.jsx)(`div`,{className:`mt-3 divide-y divide-edge-subtle overflow-hidden rounded-xl border border-edge bg-surface-base`,children:e.map(e=>(0,$.jsxs)(`div`,{className:`px-4 py-3`,children:[(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:o.connectorBenefitHeadings[e]}),(0,$.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:o.connectorBenefitHints[e]})]},e))})]}):null;let K;t[56]===Symbol.for(`react.memo_cache_sentinel`)?(K=(0,$.jsx)(ue,{className:`mt-0.5 size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}),t[56]=K):K=t[56];let ee;t[57]===o.detailPermissions?ee=t[58]:(ee=(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:o.detailPermissions}),t[57]=o.detailPermissions,t[58]=ee);let q;t[59]!==n||t[60]!==o?(q=Et(n,o),t[59]=n,t[60]=o,t[61]=q):q=t[61];let J;t[62]===q?J=t[63]:(J=(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:q}),t[62]=q,t[63]=J);let ne;t[64]!==ee||t[65]!==J?(ne=(0,$.jsxs)(`div`,{className:`flex items-start gap-3 border-b border-edge-subtle px-4 py-3`,children:[K,(0,$.jsxs)(`div`,{children:[ee,J]})]}),t[64]=ee,t[65]=J,t[66]=ne):ne=t[66];let Y;t[67]===o.connectorSetupTitle?Y=t[68]:(Y=(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:o.connectorSetupTitle}),t[67]=o.connectorSetupTitle,t[68]=Y);let ie;t[69]!==s.length||t[70]!==o.connectorRequiredInputsCount||t[71]!==o.connectorSetupNone?(ie=s.length?We(o.connectorRequiredInputsCount,{count:String(s.length)}):o.connectorSetupNone,t[69]=s.length,t[70]=o.connectorRequiredInputsCount,t[71]=o.connectorSetupNone,t[72]=ie):ie=t[72];let ae;t[73]===ie?ae=t[74]:(ae=(0,$.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:ie}),t[73]=ie,t[74]=ae);let oe;t[75]!==Y||t[76]!==ae?(oe=(0,$.jsxs)(`div`,{className:`px-4 py-3`,children:[Y,ae]}),t[75]=Y,t[76]=ae,t[77]=oe):oe=t[77],t[78]!==ne||t[79]!==oe?(F=(0,$.jsxs)(`section`,{className:`overflow-hidden rounded-xl border border-edge bg-surface-base`,children:[ne,oe]}),t[78]=ne,t[79]=oe,t[80]=F):F=t[80],j=`rounded-xl border border-edge bg-surface-base`,t[81]===o.connectorTechnicalDetails?M=t[82]:(M=(0,$.jsx)(`summary`,{className:`cursor-pointer px-4 py-3 text-sm font-medium text-fg-muted hover:text-fg`,children:o.connectorTechnicalDetails}),t[81]=o.connectorTechnicalDetails,t[82]=M),D=`space-y-5 border-t border-edge-subtle px-4 py-4`;let se;t[83]===Symbol.for(`react.memo_cache_sentinel`)?(se=(0,$.jsx)(re,{className:`size-3.5`,"aria-hidden":!0}),t[83]=se):se=t[83];let X;t[84]===o.connectorRuntimeTitle?X=t[85]:(X=(0,$.jsxs)(`p`,{className:`flex items-center gap-2 text-xs font-medium text-fg-muted`,children:[se,o.connectorRuntimeTitle]}),t[84]=o.connectorRuntimeTitle,t[85]=X);let ce;t[86]!==n||t[87]!==o?(ce=Tt(n,o),t[86]=n,t[87]=o,t[88]=ce):ce=t[88];let le;t[89]===ce?le=t[90]:(le=(0,$.jsx)(`p`,{className:`mt-1 break-words text-xs text-fg-subtle`,children:ce}),t[89]=ce,t[90]=le),t[91]!==X||t[92]!==le?(O=(0,$.jsxs)(`div`,{children:[X,le]}),t[91]=X,t[92]=le,t[93]=O):O=t[93],A=k.length?(0,$.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:k.map(e=>(0,$.jsx)(`span`,{className:`rounded-md bg-surface-panel px-2 py-1 text-xs text-fg-muted`,children:wt(e,o)},e))}):null,t[3]=n,t[4]=c,t[5]=r,t[6]=i,t[7]=o,t[8]=u,t[9]=d,t[10]=f,t[11]=m,t[12]=g,t[13]=_,t[14]=v,t[15]=y,t[16]=D,t[17]=O,t[18]=A,t[19]=j,t[20]=M,t[21]=N,t[22]=P,t[23]=F}else u=t[8],d=t[9],f=t[10],m=t[11],g=t[12],_=t[13],v=t[14],y=t[15],D=t[16],O=t[17],A=t[18],j=t[19],M=t[20],N=t[21],P=t[22],F=t[23];let I;t[94]!==D||t[95]!==O||t[96]!==A?(I=(0,$.jsxs)(`div`,{className:D,children:[O,A]}),t[94]=D,t[95]=O,t[96]=A,t[97]=I):I=t[97];let L;t[98]!==I||t[99]!==j||t[100]!==M?(L=(0,$.jsxs)(`details`,{className:j,children:[M,I]}),t[98]=I,t[99]=j,t[100]=M,t[101]=L):L=t[101];let R;t[102]!==L||t[103]!==N||t[104]!==P||t[105]!==F?(R=(0,$.jsxs)(`div`,{className:N,children:[P,F,L]}),t[102]=L,t[103]=N,t[104]=P,t[105]=F,t[106]=R):R=t[106];let B;t[107]===o.modalClose?B=t[108]:(B=(0,$.jsx)(S,{asChild:!0,children:(0,$.jsx)(k,{variant:`secondary`,children:o.modalClose})}),t[107]=o.modalClose,t[108]=B);let V;t[109]!==n||t[110]!==r||t[111]!==i||t[112]!==a||t[113]!==o.connect?(V=r?null:(0,$.jsxs)(k,{variant:`primary`,onClick:()=>{a(n),i()},children:[(0,$.jsx)(z,{className:`size-4`}),o.connect]}),t[109]=n,t[110]=r,t[111]=i,t[112]=a,t[113]=o.connect,t[114]=V):V=t[114];let H;t[115]!==B||t[116]!==V?(H=(0,$.jsxs)(`div`,{className:`flex shrink-0 justify-end gap-2 border-t border-edge-subtle px-5 py-4 sm:px-6`,children:[B,V]}),t[115]=B,t[116]=V,t[117]=H):H=t[117];let U;t[118]!==u||t[119]!==m||t[120]!==g||t[121]!==R||t[122]!==H?(U=(0,$.jsxs)(u,{className:m,children:[g,R,H]}),t[118]=u,t[119]=m,t[120]=g,t[121]=R,t[122]=H,t[123]=U):U=t[123];let W;t[124]!==d||t[125]!==_||t[126]!==U?(W=(0,$.jsxs)(d,{children:[_,U]}),t[124]=d,t[125]=_,t[126]=U,t[127]=W):W=t[127];let G;return t[128]!==f||t[129]!==v||t[130]!==y||t[131]!==W?(G=(0,$.jsx)(f,{open:v,onOpenChange:y,children:W}),t[128]=f,t[129]=v,t[130]=y,t[131]=W,t[132]=G):G=t[132],G}function Ot(e){return!e.startsWith(`runtime.`)&&!e.startsWith(`auth.`)}function kt(e){return e.required}function At(e){return e.required}var jt=(0,Q.memo)(function(e){let t=(0,ft.c)(45),{onRefresh:n,refreshing:r,refreshLabel:i,onBrowseCatalog:a,onAddCustomServer:o,addLabel:s,browseLabel:c,customLabel:l,serviceLabel:u,moreActionsLabel:p}=e,[m,g]=(0,Q.useState)(!1),_;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(_=h(`touch-target flex cursor-pointer items-center gap-2 rounded-lg px-3 py-2 text-sm text-fg outline-none data-[disabled]:cursor-not-allowed data-[disabled]:opacity-50 data-[highlighted]:bg-surface-hover`,te.transition),t[0]=_):_=t[0];let v=_,y;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,$.jsx)(f,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),t[1]=y):y=t[1];let b;t[2]===s?b=t[3]:(b=(0,$.jsx)(`span`,{className:`hidden sm:inline`,children:s}),t[2]=s,t[3]=b);let x;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(x=(0,$.jsx)(Je,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}),t[4]=x):x=t[4];let S;t[5]!==s||t[6]!==b?(S=(0,$.jsx)(F,{asChild:!0,children:(0,$.jsxs)(k,{type:`button`,variant:`primary`,className:`shrink-0 gap-2`,"aria-label":s,children:[y,b,x]})}),t[5]=s,t[6]=b,t[7]=S):S=t[7];let C;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(C=(0,$.jsx)(B,{className:`size-4 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),t[8]=C):C=t[8];let w;t[9]!==c||t[10]!==a?(w=(0,$.jsxs)(ot,{className:v,onSelect:a,children:[C,c]}),t[9]=c,t[10]=a,t[11]=w):w=t[11];let T;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(T=(0,$.jsx)(ce,{className:`size-4 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),t[12]=T):T=t[12];let E;t[13]!==l||t[14]!==o?(E=(0,$.jsxs)(ot,{className:v,onSelect:o,children:[T,l]}),t[13]=l,t[14]=o,t[15]=E):E=t[15];let D;t[16]!==w||t[17]!==E?(D=(0,$.jsx)(fe,{children:(0,$.jsxs)(tt,{className:`z-50 min-w-[14rem] rounded-xl border border-edge bg-surface-overlay p-1 shadow-popover dark:border-edge`,sideOffset:6,align:`end`,children:[w,E]})}),t[16]=w,t[17]=E,t[18]=D):D=t[18];let O;t[19]!==D||t[20]!==S?(O=(0,$.jsxs)(it,{children:[S,D]}),t[19]=D,t[20]=S,t[21]=O):O=t[21];let A;t[22]===m?A=t[23]:(A=(0,$.jsx)(ut,{open:m,onOpenChange:g,hideTrigger:!0}),t[22]=m,t[23]=A);let j;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(j=(0,$.jsx)(J,{className:`size-4`,"aria-hidden":!0}),t[24]=j):j=t[24];let M;t[25]===p?M=t[26]:(M=(0,$.jsx)(F,{asChild:!0,children:(0,$.jsx)(k,{type:`button`,variant:`secondary`,className:`size-9 shrink-0 p-0`,"aria-label":p,title:p,children:j})}),t[25]=p,t[26]=M);let N;t[27]!==n||t[28]!==i||t[29]!==r?(N=n?(0,$.jsxs)(ot,{className:v,disabled:r,onSelect:n,children:[r?(0,$.jsx)(d,{className:`size-4 animate-spin text-fg-muted`,"aria-hidden":!0}):(0,$.jsx)(He,{className:`size-4 text-fg-muted`,"aria-hidden":!0}),i]}):null,t[27]=n,t[28]=i,t[29]=r,t[30]=N):N=t[30];let P,I;t[31]===Symbol.for(`react.memo_cache_sentinel`)?(P=()=>g(!0),I=(0,$.jsx)(se,{className:`size-4 text-fg-muted`,"aria-hidden":!0}),t[31]=P,t[32]=I):(P=t[31],I=t[32]);let L;t[33]===u?L=t[34]:(L=(0,$.jsxs)(ot,{className:v,onSelect:P,children:[I,u]}),t[33]=u,t[34]=L);let R;t[35]!==N||t[36]!==L?(R=(0,$.jsx)(fe,{children:(0,$.jsxs)(tt,{className:`z-50 min-w-[14rem] rounded-xl border border-edge bg-surface-overlay p-1 shadow-popover dark:border-edge`,sideOffset:6,align:`end`,children:[N,L]})}),t[35]=N,t[36]=L,t[37]=R):R=t[37];let z;t[38]!==M||t[39]!==R?(z=(0,$.jsxs)(it,{children:[M,R]}),t[38]=M,t[39]=R,t[40]=z):z=t[40];let V;return t[41]!==O||t[42]!==A||t[43]!==z?(V=(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center justify-end gap-2`,children:[O,A,z]}),t[41]=O,t[42]=A,t[43]=z,t[44]=V):V=t[44],V});function Mt(e=``,t=``){return{clientKey:crypto.randomUUID(),key:e,value:t}}var Nt=/^([^:=]+)[:=](.*)$/;function Pt(e){let t=e.trim();if(!t)return null;try{let e=JSON.parse(t);if(e&&typeof e==`object`&&!Array.isArray(e))return It(e)}catch{}let n=[];for(let e of t.split(/\r?\n/)){let t=e.trim();if(!t)continue;let r=Nt.exec(t);r&&n.push(Mt(r[1].trim(),r[2].trim()))}return n.length>0?n:null}function Ft(e){let t=Object.create(null);for(let n of e){let e=n.key.trim();e&&(t[e]=n.reference??n.value)}return Object.keys(t).length>0?t:void 0}function It(e){if(!e||typeof e!=`object`)return[Mt()];let t=Object.entries(e).map(([e,t])=>typeof t==`object`&&t&&!Array.isArray(t)?{...Mt(e),reference:t}:Mt(e,t==null?``:String(t)));return t.length>0?t:[Mt()]}function Lt(e){if(!e||typeof e!=`object`||Array.isArray(e))return!1;let t=e.xopcConnector;return!!(t&&typeof t==`object`&&!Array.isArray(t)&&t.managed===!0)}function Rt(e){let t=e.trim();if(!t)return;if(t.startsWith(`[`)){let e=JSON.parse(t);if(!Array.isArray(e)||e.some(e=>typeof e!=`string`))throw Error(`Command arguments must be a JSON array of strings.`);return e}let n=[],r=``,i=``,a=!1;for(let e=0;e<t.length;e++){let o=t[e];o===`\\`&&t[e+1]&&i!==`'`&&/[\s"'\\]/.test(t[e+1])?(r+=t[++e],a=!0):i?o===i?i=``:r+=o:o===`"`||o===`'`?(i=o,a=!0):/\s/.test(o)?a&&=(n.push(r),r=``,!1):(r+=o,a=!0)}if(i)throw Error(`Command arguments contain an unclosed quote.`);return a&&n.push(r),n}function zt(e){let t=e.trim();if(!t)return;let n=JSON.parse(t);if(!n||typeof n!=`object`||Array.isArray(n))throw Error(`Expected a JSON object`);return n}function Bt(e){let t={...e.extra,exposure:e.exposure};if(e.displayName?.trim()?t.displayName=e.displayName.trim():delete t.displayName,delete t.command,delete t.args,delete t.env,delete t.cwd,delete t.url,delete t.headers,delete t.type,e.transport===`stdio`){t.type=`stdio`,t.command=e.command.trim();let n=Rt(e.argsText);if(n&&(t.args=n),e.cwd.trim()&&(t.cwd=e.cwd.trim()),e.envEntries){let n=new Set;for(let t of e.envEntries)if(!(!t.key.trim()&&!t.value&&!t.reference)){if(!t.key.trim()||n.has(t.key.trim()))throw Error(`Environment variable names must be non-empty and unique.`);n.add(t.key.trim())}let r=Ft(e.envEntries);r&&(t.env=r)}else e.envJson.trim()&&(t.env=zt(e.envJson));delete t.oauth,delete t.auth}else{t.type=`http`,t.url=e.url.trim();let n=Ft(e.headers);n&&(t.headers=n);let r={...t.oauth??{}};e.oauthClientId.trim()?r.clientId=e.oauthClientId.trim():delete r.clientId,Object.keys(r).length?t.oauth=r:delete t.oauth}return e.timeout===void 0?delete t.timeout:t.timeout=e.timeout,t}function Vt(e,t){let n=t.oauth;return{clientKey:e,id:e,displayName:typeof t.displayName==`string`?t.displayName:``,transport:typeof t.url==`string`?`streamable-http`:`stdio`,command:typeof t.command==`string`?t.command:``,argsText:Array.isArray(t.args)?JSON.stringify(t.args):``,envJson:t.env?JSON.stringify(t.env,null,2):``,cwd:typeof t.cwd==`string`?t.cwd:``,url:typeof t.url==`string`?t.url:``,headers:It(t.headers),oauthClientId:typeof n?.clientId==`string`?n.clientId:``,timeout:typeof t.timeout==`number`?t.timeout:void 0,exposure:t.exposure??`codemode`,extra:t}}function Ht(e,t){let n=`mcp`;try{n=e.transport===`streamable-http`?new URL(e.url).hostname:e.command.split(/[\\/]/).pop()||n}catch{}let r=n.replace(/[^a-zA-Z0-9_-]+/g,`_`).replace(/^_+|_+$/g,``)||`mcp`,i=new Set([...t].map(e=>e.replace(/-/g,`_`))),a=r;for(let e=2;i.has(a.replace(/-/g,`_`));e++)a=`${r}_${e}`;return a}function Ut(e){let t=e.trim(),n=new URL(/^[a-z][a-z\d+.-]*:/i.test(t)&&!/^[^/]+:\d+(?:[/?#]|$)/.test(t)?t:`${/^(localhost|127\.0\.0\.1)(:|\/|$)/i.test(t)?`http`:`https`}://${t}`);if(![`http:`,`https:`].includes(n.protocol)||n.username||n.password)throw Error(`Use an HTTP or HTTPS MCP address without embedded credentials.`);return n.href}function Wt(e){let t=JSON.parse(e);if(!t||typeof t!=`object`||Array.isArray(t))throw Error(`Expected a JSON object.`);let n=t.mcpServers??t.mcp?.servers??t.servers;if(n!==void 0&&(!n||typeof n!=`object`||Array.isArray(n)))throw Error(`Expected a server configuration object.`);let r=n?Object.entries(n):[[``,t]];if(!r.length)throw Error(`No MCP servers found.`);return r.map(([e,t])=>{if(!t||typeof t!=`object`||Array.isArray(t))throw Error(`Invalid MCP server configuration.`);let n=t;if(typeof n.url!=`string`&&typeof n.command!=`string`)throw Error(`The configuration needs an MCP URL or command.`);if(n.args!==void 0&&(!Array.isArray(n.args)||n.args.some(e=>typeof e!=`string`)))throw Error(`Command arguments must be strings.`);let r=Vt(e,n);return r.clientKey=crypto.randomUUID(),r.url&&=Ut(r.url),r})}function Gt(e=``){return{clientKey:crypto.randomUUID(),id:e,transport:`streamable-http`,command:``,argsText:``,envJson:``,cwd:``,url:``,headers:[],oauthClientId:``,timeout:void 0,exposure:`codemode`,extra:{}}}function Kt(e){let t=e?.mcp?.servers??{};return{servers:Object.entries(t).filter(([,e])=>!Lt(e)).map(([e,t])=>Vt(e,t)).sort((e,t)=>e.id.localeCompare(t.id))}}function qt(e){return Bt(e)}async function Jt(e,t){return(await g(y(`/api/mcp/servers/${encodeURIComponent(e)}/tools`),{method:`POST`,signal:AbortSignal.any([t,AbortSignal.timeout(95e3)])})).payload.tools}async function Yt(e,t,n,r){return(await g(y(`/api/mcp/drafts`),{method:`POST`,signal:r,body:JSON.stringify({serverId:e.id,sourceServerId:t,expectedServer:n,server:Bt(e)})})).payload}async function Xt(e,t){return(await g(y(`/api/mcp/drafts/${encodeURIComponent(e)}/probe`),{method:`POST`,signal:AbortSignal.any([t,AbortSignal.timeout(95e3)])})).payload}async function Zt(e){await g(y(`/api/mcp/drafts/${encodeURIComponent(e)}`),{method:`DELETE`})}async function Qt(e,t=!1){let n=await g(y(`/api/mcp/drafts/${encodeURIComponent(e)}/commit`),{method:`POST`,body:JSON.stringify({enable:t})});return j(),n.payload}async function $t(e){return(await g(y(`/api/mcp/drafts/${encodeURIComponent(e)}/auth`),{method:`POST`})).payload}async function en(e,t){return(await g(y(`/api/mcp/drafts/${encodeURIComponent(e)}/auth`),{signal:t})).payload}async function tn(e){await g(y(`/api/mcp/drafts/${encodeURIComponent(e)}/auth`),{method:`DELETE`})}async function nn(e,t){await g(y(`/api/mcp/drafts/${encodeURIComponent(e)}/auth/redirect`),{method:`POST`,body:JSON.stringify({url:t})})}async function rn(e,t){return(await g(y(`/api/mcp/drafts/${encodeURIComponent(e)}/tools`),{signal:t})).payload.tools}async function an(e){let t=await g(y(`/api/mcp/servers`),{signal:e});return Object.fromEntries(t.payload.servers.filter(e=>e.lastCheck&&Number.isFinite(Date.parse(e.lastCheck.checkedAt))).map(e=>[e.id,e.lastCheck]))}async function on(e){let t=await g(y(`/api/mcp/servers/${encodeURIComponent(e.id)}`),{method:`DELETE`,body:JSON.stringify({expectedServer:e.extra})});return j(),t.payload}function sn(e){let t=(0,ft.c)(111),{serverId:n,displayName:r,returnFocusTo:i,draftId:a,t:o,onClose:s,onConfigure:c}=e,l;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(l=[],t[0]=l):l=t[0];let[u,d]=(0,Q.useState)(l),[f,p]=(0,Q.useState)(!0),[m,h]=(0,Q.useState)(``),[g,_]=(0,Q.useState)(``),[v,y]=(0,Q.useState)(0),D=(0,Q.useRef)(!1),O;t[1]!==a||t[2]!==n||t[3]!==o.setupAccessDenied||t[4]!==o.setupConflict||t[5]!==o.setupGatewayUnauthorized||t[6]!==o.setupRateLimited||t[7]!==o.toolsLoadFailed?(O=()=>{let e=new AbortController,t=!0;return p(!0),h(``),d([]),(a?rn(a,e.signal):Jt(n,e.signal)).then(e=>{t&&d(e)}).catch(e=>{let n=e?.status;t&&h(n===401?o.setupGatewayUnauthorized:n===403?o.setupAccessDenied:n===429?o.setupRateLimited:n===404||n===409?o.setupConflict:o.toolsLoadFailed)}).finally(()=>{t&&p(!1)}),()=>{t=!1,e.abort()}},t[1]=a,t[2]=n,t[3]=o.setupAccessDenied,t[4]=o.setupConflict,t[5]=o.setupGatewayUnauthorized,t[6]=o.setupRateLimited,t[7]=o.toolsLoadFailed,t[8]=O):O=t[8];let A;t[9]!==a||t[10]!==v||t[11]!==n||t[12]!==o?(A=[n,a,v,o],t[9]=a,t[10]=v,t[11]=n,t[12]=o,t[13]=A):A=t[13],(0,Q.useEffect)(O,A);let j,M,N,P,F,I,L,R,z,B,V,H,U;if(t[14]!==r||t[15]!==m||t[16]!==f||t[17]!==s||t[18]!==c||t[19]!==g||t[20]!==i||t[21]!==n||t[22]!==o.exposureLabels||t[23]!==o.setupConfigure||t[24]!==o.toolDetails||t[25]!==o.toolsClearSearch||t[26]!==o.toolsDialogSearchEmpty||t[27]!==o.toolsDialogSearchPlaceholder||t[28]!==o.toolsDialogSubtitle||t[29]!==o.toolsDialogTitle||t[30]!==o.toolsEmpty||t[31]!==o.toolsLoading||t[32]!==o.toolsRetryHint||t[33]!==o.toolsSearchSummary||t[34]!==o.toolsTitle||t[35]!==u){let e=g.trim().toLowerCase(),a;if(t[49]!==n){let e;t[51]===Symbol.for(`react.memo_cache_sentinel`)?(e=/-/g,t[51]=e):e=t[51],a=n.replace(e,`_`),t[49]=n,t[50]=a}else a=t[50];let l=`mcp__${a}__`,d=u.filter(t=>`${t.name} ${t.description}`.toLowerCase().includes(e));N=E,I=!0,t[52]===s?L=t[53]:(L=e=>{e||s()},t[52]=s,t[53]=L),M=C,t[54]===Symbol.for(`react.memo_cache_sentinel`)?(F=(0,$.jsx)(b,{className:`fixed inset-0 z-[60] bg-scrim`}),t[54]=F):F=t[54],j=w,t[55]===i?H=t[56]:(H=e=>{(D.current||i)&&e.preventDefault(),!D.current&&i?.isConnected&&i.focus()},t[55]=i,t[56]=H),U=`fixed left-1/2 top-1/2 z-[60] flex h-[min(42rem,calc(100dvh-2rem))] w-[min(48rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-2xl border border-edge bg-surface-overlay`;let p;t[57]===o.toolsDialogTitle?p=t[58]:(p=(0,$.jsx)(T,{className:`font-semibold`,children:o.toolsDialogTitle}),t[57]=o.toolsDialogTitle,t[58]=p);let h;t[59]!==r||t[60]!==m||t[61]!==f||t[62]!==n||t[63]!==o.toolsDialogSubtitle||t[64]!==u.length?(h=f||m?r||n:o.toolsDialogSubtitle.replace(`{{serverId}}`,r||n).replace(`{{count}}`,String(u.length)),t[59]=r,t[60]=m,t[61]=f,t[62]=n,t[63]=o.toolsDialogSubtitle,t[64]=u.length,t[65]=h):h=t[65];let v;t[66]===h?v=t[67]:(v=(0,$.jsx)(x,{className:`mt-1 break-words text-sm text-fg-muted`,children:h}),t[66]=h,t[67]=v);let y;t[68]===Symbol.for(`react.memo_cache_sentinel`)?(y=e=>_(e.target.value),t[68]=y):y=t[68];let S;t[69]!==g||t[70]!==o.toolsDialogSearchPlaceholder?(S=(0,$.jsx)(`input`,{className:`mt-4 w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,value:g,onChange:y,placeholder:o.toolsDialogSearchPlaceholder,"aria-label":o.toolsDialogSearchPlaceholder}),t[69]=g,t[70]=o.toolsDialogSearchPlaceholder,t[71]=S):S=t[71];let O=e&&!f&&!m?(0,$.jsx)(`p`,{role:`status`,className:`mt-2 text-xs text-fg-muted`,children:o.toolsSearchSummary.replace(`{{visible}}`,String(d.length)).replace(`{{count}}`,String(u.length))}):null;t[72]!==p||t[73]!==v||t[74]!==S||t[75]!==O?(P=(0,$.jsxs)(`div`,{className:`shrink-0 border-b border-edge p-5`,children:[p,v,S,O]}),t[72]=p,t[73]=v,t[74]=S,t[75]=O,t[76]=P):P=t[76],R=`min-h-0 flex-1 overflow-y-auto p-5`,z=f,t[77]!==o.toolsTitle||t[78]!==u.length?(B=o.toolsTitle.replace(`{{count}}`,String(u.length)),t[77]=o.toolsTitle,t[78]=u.length,t[79]=B):B=t[79],V=f?(0,$.jsx)(`div`,{role:`status`,"aria-label":o.toolsLoading,className:`space-y-3`,children:[0,1,2].map(ln)}):m?(0,$.jsxs)(`div`,{role:`alert`,className:`space-y-3`,children:[(0,$.jsx)(`p`,{className:`whitespace-pre-wrap break-words text-sm text-danger`,children:m}),(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:o.toolsRetryHint}),c?(0,$.jsx)(k,{variant:`secondary`,onClick:()=>{D.current=!0,c()},children:o.setupConfigure}):null]}):d.length?(0,$.jsx)(`div`,{className:`space-y-3`,children:d.map(e=>(0,$.jsxs)(`article`,{className:`rounded-lg border border-edge p-4`,children:[(0,$.jsx)(`h3`,{className:`break-all font-mono text-sm font-semibold text-fg`,children:e.name.startsWith(l)?e.name.slice(l.length):e.name}),e.exposure&&Object.hasOwn(o.exposureLabels,e.exposure)?(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:o.exposureLabels[e.exposure]}):null,e.description?(0,$.jsx)(`p`,{className:`mt-2 whitespace-pre-wrap break-words text-sm text-fg-muted`,children:e.description}):null,(0,$.jsxs)(`details`,{className:`mt-3`,children:[(0,$.jsx)(`summary`,{className:`cursor-pointer text-sm text-accent-fg`,children:o.toolDetails}),(0,$.jsx)(`p`,{className:`mt-2 break-all font-mono text-xs text-fg-muted`,children:e.name}),(0,$.jsx)(`pre`,{className:`mt-2 overflow-x-auto rounded-md bg-surface-panel p-3 text-xs text-fg`,children:JSON.stringify(e.inputSchema,null,2)})]})]},e.name))}):(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:u.length?o.toolsDialogSearchEmpty:o.toolsEmpty}),e?(0,$.jsx)(k,{variant:`secondary`,onClick:()=>_(``),children:o.toolsClearSearch}):null]}),t[14]=r,t[15]=m,t[16]=f,t[17]=s,t[18]=c,t[19]=g,t[20]=i,t[21]=n,t[22]=o.exposureLabels,t[23]=o.setupConfigure,t[24]=o.toolDetails,t[25]=o.toolsClearSearch,t[26]=o.toolsDialogSearchEmpty,t[27]=o.toolsDialogSearchPlaceholder,t[28]=o.toolsDialogSubtitle,t[29]=o.toolsDialogTitle,t[30]=o.toolsEmpty,t[31]=o.toolsLoading,t[32]=o.toolsRetryHint,t[33]=o.toolsSearchSummary,t[34]=o.toolsTitle,t[35]=u,t[36]=j,t[37]=M,t[38]=N,t[39]=P,t[40]=F,t[41]=I,t[42]=L,t[43]=R,t[44]=z,t[45]=B,t[46]=V,t[47]=H,t[48]=U}else j=t[36],M=t[37],N=t[38],P=t[39],F=t[40],I=t[41],L=t[42],R=t[43],z=t[44],B=t[45],V=t[46],H=t[47],U=t[48];let W;t[80]!==R||t[81]!==z||t[82]!==B||t[83]!==V?(W=(0,$.jsx)(`div`,{className:R,"aria-busy":z,"aria-label":B,children:V}),t[80]=R,t[81]=z,t[82]=B,t[83]=V,t[84]=W):W=t[84];let G;t[85]===Symbol.for(`react.memo_cache_sentinel`)?(G=()=>y(cn),t[85]=G):G=t[85];let K;t[86]!==f||t[87]!==o.refreshTools?(K=(0,$.jsx)(k,{variant:`secondary`,disabled:f,onClick:G,children:o.refreshTools}),t[86]=f,t[87]=o.refreshTools,t[88]=K):K=t[88];let ee;t[89]!==s||t[90]!==o.toolsDialogClose?(ee=(0,$.jsx)(S,{asChild:!0,children:(0,$.jsx)(k,{onClick:s,children:o.toolsDialogClose})}),t[89]=s,t[90]=o.toolsDialogClose,t[91]=ee):ee=t[91];let q;t[92]!==K||t[93]!==ee?(q=(0,$.jsxs)(`div`,{className:`flex shrink-0 justify-end gap-2 border-t border-edge p-4`,children:[K,ee]}),t[92]=K,t[93]=ee,t[94]=q):q=t[94];let te;t[95]!==j||t[96]!==P||t[97]!==W||t[98]!==q||t[99]!==H||t[100]!==U?(te=(0,$.jsxs)(j,{onCloseAutoFocus:H,className:U,children:[P,W,q]}),t[95]=j,t[96]=P,t[97]=W,t[98]=q,t[99]=H,t[100]=U,t[101]=te):te=t[101];let J;t[102]!==M||t[103]!==F||t[104]!==te?(J=(0,$.jsxs)(M,{children:[F,te]}),t[102]=M,t[103]=F,t[104]=te,t[105]=J):J=t[105];let ne;return t[106]!==N||t[107]!==I||t[108]!==L||t[109]!==J?(ne=(0,$.jsx)(N,{open:I,onOpenChange:L,children:J}),t[106]=N,t[107]=I,t[108]=L,t[109]=J,t[110]=ne):ne=t[110],ne}function cn(e){return e+1}function ln(e){return(0,$.jsx)(A,{className:`h-24 w-full`},e)}function un(e){if(e.transport===`stdio`)return e.command.trim();try{let t=new URL(e.url);return`${t.protocol}//${t.host}${t.pathname}`}catch{return e.url.trim().split(/[?#]/,1)[0].replace(/\/\/[^/]*@/,`//`)}}function dn({row:e,lastCheck:t,t:n,cs:r,onEdit:i,onRemove:a}){let o=v(e=>e.language),[s,c]=(0,Q.useState)(!1),u=(0,Q.useRef)(null),[d,f]=(0,Q.useState)(!1),[p,m]=(0,Q.useState)(``),g=e.displayName||e.id,_=un(e),y=e.extra.enabled===!1,b=y?ve:t?l:K,x=e.transport===`stdio`?q:re,S=y?n.setupDisabled:t?r.customCheckSucceeded:r.customUnchecked,C=t?new Intl.DateTimeFormat(o,{dateStyle:`medium`,timeStyle:`short`}).format(new Date(t.checkedAt)):null;return(0,$.jsxs)(`li`,{className:`flex min-h-[8.75rem] min-w-0 flex-col rounded-xl border border-edge bg-surface-panel p-4 transition-colors hover:bg-surface-hover/45 focus-within:ring-2 focus-within:ring-accent/30`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[(0,$.jsx)(`div`,{title:n.transportLabels[e.transport],className:`flex size-9 shrink-0 items-center justify-center rounded-xl border border-edge-subtle bg-surface-inset text-fg-muted`,children:(0,$.jsx)(x,{className:`size-4`,"aria-hidden":!0})}),(0,$.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-col items-start gap-1`,children:[(0,$.jsx)(`h3`,{className:`min-w-0 max-w-full text-sm font-semibold text-fg`,children:(0,$.jsx)(`button`,{type:`button`,onClick:i,title:g,className:`block max-w-full truncate rounded text-left hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:g})}),(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1 text-[11px]`,children:[(0,$.jsxs)(`span`,{title:C?r.customLastChecked.replace(`{{time}}`,C):void 0,"aria-label":C?`${S} · ${r.customLastChecked.replace(`{{time}}`,C)}`:S,className:h(`inline-flex shrink-0 items-center gap-1`,!y&&t?`text-emerald-700 dark:text-emerald-300`:`text-fg-muted`),children:[(0,$.jsx)(b,{className:`size-3.5`,"aria-hidden":!0}),S]}),t?(0,$.jsx)(`span`,{className:`text-fg-muted`,children:r.customToolCount.replace(`{{count}}`,String(t.toolCount))}):null]})]})})]}),(0,$.jsx)(`p`,{title:_,className:`mt-2 truncate font-mono text-xs leading-5 text-fg-muted`,children:_})]}),(0,$.jsxs)(`div`,{className:`mt-2 flex shrink-0 items-center gap-1`,children:[(0,$.jsx)(`span`,{className:`mr-auto text-[11px] text-fg-subtle`,children:n.transportLabels[e.transport]}),(0,$.jsx)(k,{variant:`ghost`,className:`h-8 px-2 py-1 text-xs`,onClick:i,children:n.setupConfigure}),(0,$.jsx)(k,{ref:u,variant:`secondary`,className:`h-8 px-2 py-1 text-xs shadow-none sm:shadow-none`,disabled:y,onClick:()=>c(!0),children:n.viewTools}),(0,$.jsxs)(it,{children:[(0,$.jsx)(F,{asChild:!0,children:(0,$.jsx)(k,{variant:`ghost`,className:`size-8 p-0`,"aria-label":r.customManage.replace(`{{name}}`,g),title:r.customManage.replace(`{{name}}`,g),children:(0,$.jsx)(J,{className:`size-4`,"aria-hidden":!0})})}),(0,$.jsx)(fe,{children:(0,$.jsx)(tt,{align:`end`,sideOffset:6,className:`z-50 min-w-36 rounded-xl border border-edge bg-surface-overlay p-1 shadow-popover`,children:(0,$.jsxs)(ot,{onSelect:()=>f(!0),className:`flex cursor-pointer items-center gap-2 rounded-lg px-3 py-2 text-sm text-danger outline-none data-[highlighted]:bg-surface-hover`,children:[(0,$.jsx)(Y,{className:`size-4`,"aria-hidden":!0}),n.removeServer]})})})]})]}),p?(0,$.jsx)(`p`,{role:`alert`,className:`mt-2 text-sm text-danger`,children:p}):null,s?(0,$.jsx)(sn,{serverId:e.id,displayName:e.displayName,returnFocusTo:u.current,t:n,onClose:()=>c(!1),onConfigure:()=>{c(!1),i()}}):null,(0,$.jsx)(xe,{open:d,title:r.removeConfirmTitle.replace(`{{name}}`,g),description:r.removeConfirmDescription,confirmLabel:n.removeServer,cancelLabel:r.modalCancel,destructive:!0,onCancel:()=>f(!1),onConfirm:()=>{f(!1),m(``),a().catch(()=>m(n.setupRemoveFailed))}})]})}function fn(e){let t=(0,ft.c)(30),{servers:n,lastChecks:r,t:i,cs:a,onAdd:o,onEdit:s,onRemove:c}=e,l;t[0]===a.customIntegrationsTitle?l=t[1]:(l=(0,$.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:a.customIntegrationsTitle}),t[0]=a.customIntegrationsTitle,t[1]=l);let u;t[2]===n.length?u=t[3]:(u=(0,$.jsx)(`span`,{className:`rounded-md bg-surface-inset px-1.5 py-0.5 text-xs tabular-nums text-fg-muted`,children:n.length}),t[2]=n.length,t[3]=u);let d;t[4]!==l||t[5]!==u?(d=(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[l,u]}),t[4]=l,t[5]=u,t[6]=d):d=t[6];let p;t[7]===a.customIntegrationsHint?p=t[8]:(p=(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:a.customIntegrationsHint}),t[7]=a.customIntegrationsHint,t[8]=p);let m;t[9]!==d||t[10]!==p?(m=(0,$.jsxs)(`div`,{className:`min-w-0`,children:[d,p]}),t[9]=d,t[10]=p,t[11]=m):m=t[11];let h;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,$.jsx)(f,{className:`size-3.5`,"aria-hidden":!0}),t[12]=h):h=t[12];let g;t[13]!==a.customAdd||t[14]!==o?(g=(0,$.jsxs)(k,{variant:`secondary`,className:`shrink-0 text-xs shadow-none sm:shadow-none`,onClick:o,children:[h,a.customAdd]}),t[13]=a.customAdd,t[14]=o,t[15]=g):g=t[15];let _;t[16]!==m||t[17]!==g?(_=(0,$.jsxs)(`div`,{className:`mb-4 flex flex-wrap items-center justify-between gap-3`,children:[m,g]}),t[16]=m,t[17]=g,t[18]=_):_=t[18];let v;t[19]!==a||t[20]!==r||t[21]!==s||t[22]!==c||t[23]!==n||t[24]!==i?(v=n.length?(0,$.jsx)(`ul`,{className:`grid gap-4 sm:grid-cols-2 xl:grid-cols-3`,children:n.map(e=>(0,$.jsx)(dn,{row:e,lastCheck:r[e.id],t:i,cs:a,onEdit:()=>s(e),onRemove:()=>c(e)},e.clientKey))}):(0,$.jsx)(`p`,{className:`rounded-xl border border-dashed border-edge px-5 py-8 text-center text-sm text-fg-muted`,children:a.customEmpty}),t[19]=a,t[20]=r,t[21]=s,t[22]=c,t[23]=n,t[24]=i,t[25]=v):v=t[25];let y;return t[26]!==a.customIntegrationsTitle||t[27]!==_||t[28]!==v?(y=(0,$.jsxs)(`section`,{"aria-label":a.customIntegrationsTitle,children:[_,v]}),t[26]=a.customIntegrationsTitle,t[27]=_,t[28]=v,t[29]=y):y=t[29],y}function pn(e){return e.format===`agent-plugin`&&!!e.pluginId&&(!!e.setup?.authorizations?.length||e.authorizationStatus===`required`||!!e.components?.mcp.some(e=>e.type!==`stdio`))}function mn(e){let t=(0,ft.c)(54),{extension:n,language:r,onOpen:i}=e,a;t[0]===r?a=t[1]:(a=r.startsWith(`zh`),t[0]=r,t[1]=a);let o=a,s;t[2]===o?s=t[3]:(s=(e,t)=>o?e:t,t[2]=o,t[3]=s);let c=s,u=n.installationState===`preparing`,d=n.activationEligible===!1,f=n.authorizationStatus===`required`,p;t[4]!==d||t[5]!==n.readiness||t[6]!==f||t[7]!==u||t[8]!==c?(p=u?c(`准备未完成`,`Setup incomplete`):d?c(`已停用`,`Disabled`):f?c(`需要授权`,`Authorization required`):n.readiness===`blocked`||n.readiness===`degraded`?c(`需要处理`,`Needs attention`):c(`已连接`,`Connected`),t[4]=d,t[5]=n.readiness,t[6]=f,t[7]=u,t[8]=c,t[9]=p):p=t[9];let m=p,g;t[10]!==d||t[11]!==f||t[12]!==u||t[13]!==c?(g=u?c(`继续安装`,`Continue setup`):!d&&f?c(`去授权`,`Connect account`):c(`查看详情`,`View details`),t[10]=d,t[11]=f,t[12]=u,t[13]=c,t[14]=g):g=t[14];let _=g,v;t[15]===n.setup?.authorizations?v=t[16]:(v=n.setup?.authorizations??[],t[15]=n.setup?.authorizations,t[16]=v);let y=v,b=y.length===1?y[0].title:n.name,x=u||!d&&(f||n.readiness===`blocked`||n.readiness===`degraded`),S=u?K:d?ve:x?Oe:l,C=x&&`border-amber-500/25`,w;t[17]===C?w=t[18]:(w=h(`flex min-h-[8.75rem] w-full min-w-0 flex-col rounded-xl border border-edge bg-surface-panel p-4 text-left transition-colors hover:bg-surface-hover/45 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-accent`,C),t[17]=C,t[18]=w);let T=n.branding?.iconUrl,E;t[19]===T?E=t[20]:(E=(0,$.jsx)(ke,{iconUrl:T,fallback:Ge,className:`size-9`}),t[19]=T,t[20]=E);let D;t[21]===b?D=t[22]:(D=(0,$.jsx)(`span`,{className:`block truncate text-sm font-semibold text-fg`,title:b,children:b}),t[21]=b,t[22]=D);let O=x?`text-amber-700 dark:text-amber-300`:d?`text-fg-muted`:`text-emerald-700 dark:text-emerald-300`,k;t[23]===O?k=t[24]:(k=h(`mt-1 inline-flex items-center gap-1 text-[11px]`,O),t[23]=O,t[24]=k);let A;t[25]===S?A=t[26]:(A=(0,$.jsx)(S,{className:`size-3.5`,"aria-hidden":!0}),t[25]=S,t[26]=A);let j;t[27]!==m||t[28]!==k||t[29]!==A?(j=(0,$.jsxs)(`span`,{className:k,children:[A,m]}),t[27]=m,t[28]=k,t[29]=A,t[30]=j):j=t[30];let M;t[31]!==D||t[32]!==j?(M=(0,$.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[D,j]}),t[31]=D,t[32]=j,t[33]=M):M=t[33];let N;t[34]!==M||t[35]!==E?(N=(0,$.jsxs)(`span`,{className:`flex w-full min-w-0 items-start gap-3`,children:[E,M]}),t[34]=M,t[35]=E,t[36]=N):N=t[36];let P=n.name,F;t[37]===c?F=t[38]:(F=c(`由插件提供`,`Provided by plugin`),t[37]=c,t[38]=F);let I;t[39]!==n.name||t[40]!==F?(I=(0,$.jsxs)(`span`,{className:`mt-2 block w-full truncate text-xs leading-5 text-fg-muted`,title:P,children:[F,` · `,n.name]}),t[39]=n.name,t[40]=F,t[41]=I):I=t[41];let L=x?`text-accent-fg`:`text-fg-muted`,R;t[42]===L?R=t[43]:(R=h(`mt-auto flex w-full items-center justify-end gap-1 pt-2 text-xs`,L),t[42]=L,t[43]=R);let z;t[44]===Symbol.for(`react.memo_cache_sentinel`)?(z=(0,$.jsx)(de,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),t[44]=z):z=t[44];let B;t[45]!==_||t[46]!==R?(B=(0,$.jsxs)(`span`,{className:R,children:[_,z]}),t[45]=_,t[46]=R,t[47]=B):B=t[47];let V;return t[48]!==i||t[49]!==N||t[50]!==I||t[51]!==B||t[52]!==w?(V=(0,$.jsxs)(`button`,{type:`button`,onClick:i,className:w,children:[N,I,B]}),t[48]=i,t[49]=N,t[50]=I,t[51]=B,t[52]=w,t[53]=V):V=t[53],V}function hn(e){let t=e.connectedAt?Date.parse(e.connectedAt):0;return Number.isFinite(t)?t:0}function gn(e,t){return e.status===`active`&&t.status!==`active`?-1:e.status!==`active`&&t.status===`active`?1:e.isCurrentAuthorization===t.isCurrentAuthorization?hn(t)-hn(e):e.isCurrentAuthorization?-1:1}function _n(e){let t=new Map;for(let n of e){let e=n.accountId??n.identityKey??`authorization:${n.id}`;t.set(e,[...t.get(e)??[],n])}return[...t.entries()].map(([e,t])=>{let n=[...t].sort(gn);return{key:e,primary:n[0],authorizations:n}}).sort((e,t)=>gn(e.primary,t.primary))}var vn=h(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,V);function yn(e){return e.materialized.type===`composio`?e.materialized.toolkit:null}function bn(e,t){return e===`write`?t.composioScopeWrite:e===`admin`?t.composioScopeAdmin:t.composioScopeRead}function xn(e,t,n){return e.status===`connected`?We(n.composioHealthConnected,{count:String(t)}):e.status===`reauthorization_required`?n.composioHealthReconnect:e.status===`disconnected`?n.composioHealthDisconnected:e.errorCode===`missing_credential`?n.composioHealthMissingCredential:e.errorCode===`unauthorized`?n.composioHealthUnauthorized:e.errorCode===`forbidden`?n.composioHealthForbidden:e.errorCode===`network`?n.composioHealthNetwork:e.errorCode===`timeout`?n.composioHealthTimeout:n.composioHealthDegraded}function Sn(e,t){return e===`active`?t.composioConnectionHealthy:e===`pending`?t.composioConnectionPending:e===`expired`?t.composioConnectionExpired:e===`failed`?t.composioConnectionFailed:e===`revoked`||e===`disabled`?t.composioConnectionRevoked:t.composioConnectionUnknown}function Cn(e,t,n){return e.status===`paused`?t?.scanEnabled===!1?n.connectorLearningPausedByPolicy:n.connectorLearningPausedByFailure:e.status===`queued`?n.connectorLearningQueued:e.status===`running`?n.connectorLearningRunning:e.status===`completed`?n.connectorLearningCompleted:n.connectorLearningFailed}function wn({instance:e,t,onChanged:n}){let r=yn(e),i=v(e=>e.language)===`zh`,[a,c]=(0,Q.useState)([]),[u,f]=(0,Q.useState)([]),[p,m]=(0,Q.useState)([]),[g,_]=(0,Q.useState)(null),[y,b]=(0,Q.useState)([]),[x,S]=(0,Q.useState)(null),[C,w]=(0,Q.useState)(null),[T,E]=(0,Q.useState)([]),[D,O]=(0,Q.useState)({}),[j,M]=(0,Q.useState)(`read`),[F,z]=(0,Q.useState)(!1),[B,V]=(0,Q.useState)(null),[H,U]=(0,Q.useState)(!1),[W,G]=(0,Q.useState)(null),[K,ee]=(0,Q.useState)(null),[q,te]=(0,Q.useState)(!1),[J,re]=(0,Q.useState)(!1),[oe,se]=(0,Q.useState)(!1),X=(0,Q.useRef)(0),ce=(0,Q.useRef)(0),de=(0,Q.useMemo)(()=>_n(a),[a]),fe=(0,Q.useCallback)(e=>new Promise((t,n)=>{let r=window.setTimeout(()=>n(Error(i?`连接服务响应超时,请重试。`:`The connection service timed out. Please retry.`)),15e3);e.then(t,n).finally(()=>window.clearTimeout(r))}),[i]),Z=(0,Q.useCallback)(async()=>{if(!r||e.materialized.type!==`composio`||e.materialized.role===`credential`)return;z(!0),V(null);let t=++X.current;try{let e=(await Promise.allSettled([fe(be()).then(e=>{t===X.current&&(c(e.filter(e=>e.toolkit.toLowerCase()===r.toLowerCase())),te(!0))}),fe(pe(r)).then(e=>{t===X.current&&M(e)}),fe(qe(r)).then(e=>{t===X.current&&(_(e.policy),b(e.agents))})])).find(e=>e.status===`rejected`);t===X.current&&e?.status===`rejected`&&V(String(e.reason instanceof Error?e.reason.message:e.reason))}finally{t===X.current&&z(!1)}},[e.materialized,r,fe]);(0,Q.useEffect)(()=>(Z(),()=>{X.current++}),[Z]);let he=(0,Q.useCallback)(async()=>{if(!r)return;let e=++ce.current;se(!0),U(!1);let t=t=>n=>{e===ce.current&&t(n)},n=await Promise.allSettled([fe(Ue(r)).then(t(f)),fe(Fe(20)).then(t(e=>m(e.filter(e=>!e.toolkit||e.toolkit.toLowerCase()===r.toLowerCase())))),fe(Qe(r)).then(t(w)),fe(Be(r)).then(t(S))]);e===ce.current&&(U(n.some(e=>e.status===`rejected`)),se(!1))},[r,fe]);(0,Q.useEffect)(()=>(J&&he(),()=>{ce.current++}),[J,he]),(0,Q.useEffect)(()=>{let e=!1,t=_n(a).map(e=>e.primary).filter(e=>e.supportsLearning&&e.accountId);if(t.length)return fe(Te()).then(t=>{e||E(t)}).catch(()=>{}),Promise.allSettled(t.map(async e=>[e.accountId,await fe(me(e.accountId))])).then(t=>{e||O(Object.fromEntries(t.flatMap(e=>e.status===`fulfilled`?[e.value]:[])))}),()=>{e=!0}},[a,fe]);let _e=(0,Q.useCallback)(async i=>{if(!r)return;let a=ae()?null:window.open(`about:blank`,`_blank`);a&&(a.opener=null),z(!0),V(null);try{if(!ae()&&!a)throw Error(`Allow popups to open the authorization page.`);let t=await I(e.connectorId,i);if(!t.authorizationUrl)throw Error(`The authorization provider did not return an authorization URL.`);if(ae()){let e=await window.electronAPI?.shell?.openExternalUrl(t.authorizationUrl);if(!e?.ok)throw Error(e?.error??`Could not open the system browser.`)}else a.location.href=t.authorizationUrl;let o=await Ae(r,t.connectionId,12e4,t.attemptId);if(i&&o.accountId!==i)throw Error(`A different account was authorized. The original account and its task bindings were not changed.`);await Promise.all([n?.(),Z()])}catch(e){V(ge(e,t))}finally{a?.close(),z(!1)}},[e.connectorId,Z,n,t,r]),ve=(0,Q.useCallback)(async t=>{z(!0),V(null);try{await Me(e.instanceId,{config:{...e.config??{},authConfigId:t||void 0}}),await Promise.all([n?.(),Z()])}catch(e){V(e instanceof Error?e.message:String(e))}finally{z(!1)}},[e.config,e.instanceId,Z,n]),ye=async e=>{let t=ae()?null:window.open(`about:blank`,`_blank`);t&&(t.opener=null),V(null);try{let n=await le(e.id);if(n.authorizationUrl)if(ae())await window.electronAPI?.shell?.openExternalUrl(n.authorizationUrl);else if(t)t.location.href=n.authorizationUrl;else throw Error(`Allow popups to reopen authorization.`);else t?.close(),await Z()}catch(e){t?.close(),V(e instanceof Error?e.message:String(e))}},Se=(0,Q.useCallback)(async e=>{if(r){M(e),V(null);try{await at(r,e)}catch(e){V(e instanceof Error?e.message:String(e)),await Z()}}},[Z,r]),Ce=(0,Q.useCallback)(async e=>{if(r){V(null);try{_(await ne(r,e))}catch(e){V(e instanceof Error?e.message:String(e))}}},[r]),Ee=(0,Q.useCallback)(e=>{if(!g)return;let t=g.allowedAgentIds.includes(e);t&&g.allowedAgentIds.length===1||Ce({allowedAgentIds:t?g.allowedAgentIds.filter(t=>t!==e):[...g.allowedAgentIds,e]})},[Ce,g]),De=(0,Q.useCallback)(async e=>{z(!0),V(null);try{await e(),await Z()}catch(e){V(e instanceof Error?e.message:String(e))}finally{z(!1)}},[Z]);if(!r)return null;if(e.materialized.type===`composio`&&e.materialized.role===`credential`)return(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.composioApiKeyStored});let ke=de.filter(e=>e.primary.status===`active`).length,je=ke>0?t.composioAddAccount:t.composioConnectAccount,Ne=q&&ke>0,Pe=C?.requiresCustomAuthConfig===!0,Ie=C?.authConfigs.filter(e=>e.status===`ENABLED`&&e.isEnabledForToolRouter)??[];return(0,$.jsxs)(`div`,{className:`space-y-5`,children:[(0,$.jsxs)(`section`,{className:`flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between`,children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsxs)(`span`,{className:h(`inline-flex items-center gap-1.5 rounded-full px-2.5 py-1 text-xs font-medium`,Ne?`bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`:`bg-amber-500/10 text-amber-700 dark:text-amber-300`),children:[Ne?(0,$.jsx)(l,{className:`size-3.5`}):(0,$.jsx)(Oe,{className:`size-3.5`}),Ne?t.connectionReady:q||B?t.connectionNeedsSetup:t.connectionChecking]}),q&&(0,$.jsx)(`p`,{className:`mt-2 text-sm text-fg-muted`,children:We(t.composioAccountCount,{count:String(de.length)})})]}),(0,$.jsxs)(k,{variant:`primary`,className:`shrink-0`,disabled:F,onClick:()=>void _e(),children:[F?(0,$.jsx)(d,{className:`size-4 animate-spin`}):(0,$.jsx)(ue,{className:`size-4`}),je]})]}),B?(0,$.jsxs)(`div`,{role:`alert`,className:`flex flex-wrap items-center justify-between gap-2 rounded-xl border border-danger/20 bg-danger/5 px-3 py-2 text-sm text-danger`,children:[(0,$.jsx)(`p`,{children:B}),(0,$.jsx)(k,{variant:`secondary`,disabled:F,onClick:()=>void Z(),children:t.composioRetry})]}):null,x&&!Ne?(0,$.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-xl border border-amber-500/25 bg-amber-500/5 p-4 sm:flex-row sm:items-center sm:justify-between`,children:[(0,$.jsx)(`p`,{className:`text-sm text-amber-800 dark:text-amber-200`,children:xn(x,ke,t)}),x.recovery===`none`?null:(0,$.jsx)(k,{variant:`secondary`,disabled:F,onClick:()=>void(x.recovery===`retry`?Z():_e()),children:x.recovery===`retry`?t.composioRetry:t.composioReconnectAccount})]}):null,Pe&&Ie.length===0?(0,$.jsx)(`p`,{className:`rounded-xl border border-amber-500/25 bg-amber-500/5 px-4 py-3 text-sm text-amber-800 dark:text-amber-200`,children:t.composioAuthConfigEmpty}):null,g?(0,$.jsxs)(`section`,{className:`overflow-hidden rounded-xl border border-edge bg-surface-base`,children:[(0,$.jsxs)(`div`,{className:`grid gap-3 border-b border-edge-subtle px-4 py-4 sm:grid-cols-[minmax(0,1fr)_15rem] sm:items-start`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:t.composioAccessTitle}),(0,$.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:j===`read`?t.composioAccessReadHint:j===`admin`?t.composioAccessAdminHint:t.composioAccessWriteHint})]}),(0,$.jsxs)(o,{value:j,onChange:e=>void Se(e.currentTarget.value),children:[(0,$.jsx)(s,{value:`read`,children:t.composioAccessReadOnly}),(0,$.jsx)(s,{value:`write`,children:t.composioAccessReadWrite}),j===`admin`?(0,$.jsx)(s,{value:`admin`,children:t.composioAccessAdminCurrent}):null]})]}),(0,$.jsxs)(`details`,{children:[(0,$.jsx)(`summary`,{className:`cursor-pointer px-4 py-3 text-sm text-fg-muted`,children:t.composioAdvancedSettings}),(0,$.jsxs)(`div`,{className:`grid gap-3 border-b border-edge-subtle px-4 py-4 sm:grid-cols-[minmax(0,1fr)_15rem] sm:items-center`,children:[(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:t.composioConfirmationPolicy}),(0,$.jsxs)(o,{value:g.confirmationPolicy,onChange:e=>void Ce({confirmationPolicy:e.currentTarget.value}),children:[(0,$.jsx)(s,{value:`writes`,children:t.composioConfirmWrites}),(0,$.jsx)(s,{value:`always`,children:t.composioConfirmAlways}),g.confirmationPolicy===`never`?(0,$.jsx)(s,{value:`never`,children:t.composioConfirmNever}):null]})]}),(0,$.jsxs)(`div`,{className:`px-4 py-4`,children:[(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:t.composioAllowedAgents}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:g.allowedAgentIds.length?t.composioAllowedAgentsSelected:t.composioAllowedAgentsAll}),(0,$.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[(0,$.jsx)(`button`,{type:`button`,className:h(`rounded-full border px-2.5 py-1 text-xs transition-colors`,g.allowedAgentIds.length===0?`border-accent bg-accent/10 text-accent`:`border-edge bg-surface-panel text-fg-muted hover:text-fg`),onClick:()=>void Ce({allowedAgentIds:[]}),children:t.composioAllowedAgentsAllOption}),y.map(e=>(0,$.jsx)(`button`,{type:`button`,className:h(`rounded-full border px-2.5 py-1 text-xs transition-colors`,g.allowedAgentIds.includes(e.id)?`border-accent bg-accent/10 text-accent`:`border-edge bg-surface-panel text-fg-muted hover:text-fg`),onClick:()=>Ee(e.id),children:e.name},e.id))]})]}),(0,$.jsxs)(`fieldset`,{className:`space-y-2 border-t border-edge-subtle p-4 text-xs text-fg-muted`,children:[(0,$.jsx)(`legend`,{children:i?`可用账号范围`:`Available accounts`}),(0,$.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:g.selectedAccountIds===null,disabled:F,onChange:e=>void Ce({selectedAccountIds:e.currentTarget.checked?null:[]})}),i?`所有账号(包括以后新增)`:`All accounts, including new ones`]}),g.selectedAccountIds!==null&&de.map(({primary:e})=>e.accountId&&(0,$.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`input`,{type:`checkbox`,disabled:F,checked:g.selectedAccountIds.includes(e.accountId),onChange:t=>void Ce({selectedAccountIds:t.currentTarget.checked?[...g.selectedAccountIds,e.accountId]:g.selectedAccountIds.filter(t=>t!==e.accountId)})}),e.alias??e.accountEmail??e.accountId]},e.accountId)),g.selectedAccountIds?.length===0&&(0,$.jsx)(`p`,{children:i?`未选择账号,Agent 无法使用此应用。`:`No accounts selected. Agents cannot use this app.`})]})]})]}):null,(0,$.jsxs)(`section`,{children:[(0,$.jsxs)(`div`,{className:`mb-3 flex items-center justify-between gap-3`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:t.composioConnectedAccounts}),q&&(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:We(t.composioAccountCount,{count:String(de.length)})})]}),(0,$.jsxs)(k,{variant:`ghost`,className:`h-8 px-2 text-xs`,disabled:F,onClick:()=>void Z(),children:[(0,$.jsx)(He,{className:h(`size-3.5`,F&&`animate-spin`)}),t.refresh]})]}),de.length?(0,$.jsx)(`div`,{className:`divide-y divide-edge-subtle overflow-hidden rounded-xl border border-edge bg-surface-base`,children:de.map(e=>{let r=e.primary,a=T.find(e=>r.accountId?e.accountId===r.accountId:e.connectionId===r.id),c=r.accountId?D[r.accountId]:void 0;return(0,$.jsxs)(`article`,{className:`px-4 py-4`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col items-start justify-between gap-3 sm:flex-row`,children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`div`,{className:`flex flex-wrap items-center gap-2`,children:(0,$.jsx)(`p`,{className:`truncate text-sm font-medium text-fg`,children:r.alias??r.workspace??r.accountEmail??r.username??t.composioUnnamedAuthorization})}),(0,$.jsx)(`p`,{className:`mt-1 break-all text-xs text-fg-muted`,children:r.accountEmail??r.username??r.workspace??r.accountId}),r.backendLabel&&(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:r.backendLabel}),(0,$.jsx)(`p`,{className:h(`mt-1 text-xs`,r.status===`active`?`text-emerald-700 dark:text-emerald-300`:`text-amber-700 dark:text-amber-300`),children:r.accountEnabled===!1?i?`已暂停`:`Paused`:Sn(r.status,t)}),a?(0,$.jsx)(`p`,{className:h(`mt-1 text-xs`,a.status===`failed`?`text-red-600`:`text-fg-subtle`),children:We(t.connectorLearningStatus,{status:Cn(a,c,t),count:String(a.candidatesCreated)})}):null]}),(0,$.jsxs)(`div`,{className:`flex shrink-0 flex-wrap gap-2`,children:[r.status===`pending`&&(0,$.jsx)(k,{variant:`secondary`,className:`h-8 px-2.5 text-xs`,onClick:()=>void ye(r),children:i?`继续授权`:`Continue authorization`}),r.accountId&&(0,$.jsx)(k,{variant:`ghost`,className:`h-8 px-2.5 text-xs text-danger`,disabled:F,onClick:()=>ee(r.accountId),children:i?`断开`:`Disconnect`}),r.accountId&&r.status!==`active`&&(0,$.jsx)(k,{variant:`secondary`,className:`h-8 px-2.5 text-xs`,disabled:F,onClick:()=>void _e(r.accountId),children:t.composioReconnectAccount}),r.accountId&&(0,$.jsx)(k,{variant:`secondary`,className:`h-8 px-2.5 text-xs`,disabled:F,onClick:()=>void De(()=>R(r.accountId,{enabled:r.accountEnabled===!1})),children:r.accountEnabled===!1?i?`启用`:`Enable`:i?`暂停`:`Pause`}),r.supportsLearning&&r.status===`active`&&r.accountEnabled!==!1?(0,$.jsxs)(k,{variant:`secondary`,className:`h-8 shrink-0 px-2.5 text-xs`,disabled:F,onClick:()=>void De(async()=>{if(!r.accountId)throw Error(`Connector account is unavailable.`);await ie(r.accountId),await n?.()}),children:[(0,$.jsx)(He,{className:`size-3.5`}),t.composioSyncNow]}):null]})]}),(0,$.jsxs)(`details`,{className:`mt-3 text-xs text-fg-muted`,children:[(0,$.jsx)(`summary`,{className:`w-fit cursor-pointer font-medium hover:text-fg`,children:t.composioAccountSettings}),(0,$.jsxs)(`div`,{className:`mt-3 space-y-4 rounded-lg bg-surface-panel p-3`,children:[r.accountId&&(0,$.jsxs)(`fieldset`,{className:`space-y-2`,children:[(0,$.jsx)(`legend`,{className:`mb-2 font-medium`,children:t.composioAllowedAgents}),(0,$.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`input`,{type:`checkbox`,disabled:F,checked:r.allowedAgentIds==null,onChange:e=>void De(()=>R(r.accountId,{allowedAgentIds:e.currentTarget.checked?null:[]}))}),t.composioAllowedAgentsAllOption]}),r.allowedAgentIds!=null&&y.map(e=>(0,$.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`input`,{type:`checkbox`,disabled:F,checked:r.allowedAgentIds.includes(e.id),onChange:t=>{let n=t.currentTarget.checked;De(()=>R(r.accountId,{allowedAgentIds:n?[...r.allowedAgentIds,e.id]:r.allowedAgentIds.filter(t=>t!==e.id)}))}}),e.name]},e.id)),r.allowedAgentIds?.length===0&&(0,$.jsx)(`p`,{children:i?`未选择 Agent:任何 Agent 都不能使用此账号。`:`No agents selected: this account is unavailable to all agents.`})]}),r.supportsLearning&&c?(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,$.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:c.scanEnabled,disabled:F,onChange:e=>void De(()=>P(r.accountId,{scanEnabled:e.currentTarget.checked}))}),t.connectorScheduledScan]}),c.scanEnabled?(0,$.jsxs)(`label`,{className:`sm:col-span-2`,children:[t.connectorScanInterval,(0,$.jsxs)(o,{className:`mt-1`,value:String(c.intervalMinutes??30),disabled:F,onChange:e=>void De(()=>P(r.accountId,{intervalMinutes:Number(e.currentTarget.value)})),children:[(0,$.jsxs)(s,{value:`5`,children:[`5 `,t.connectorMinutes]}),(0,$.jsxs)(s,{value:`15`,children:[`15 `,t.connectorMinutes]}),(0,$.jsxs)(s,{value:`30`,children:[`30 `,t.connectorMinutes]}),(0,$.jsxs)(s,{value:`60`,children:[`60 `,t.connectorMinutes]})]})]}):null]}):null,(0,$.jsxs)(`label`,{className:`block`,children:[t.composioAccountAlias,(0,$.jsx)(`input`,{className:h(vn,`mt-1 h-8 py-1 text-xs`),defaultValue:r.alias??``,onBlur:e=>{e.currentTarget.value!==(r.alias??``)&&De(()=>L(r.id,{alias:e.currentTarget.value}))}})]}),(0,$.jsx)(`div`,{className:`space-y-2`,children:e.authorizations.map(e=>(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,$.jsxs)(`p`,{className:`min-w-0 break-all font-mono text-fg-subtle`,children:[t.composioAuthorizationId,`: `,e.providerConnectionId]}),(0,$.jsx)(k,{variant:`ghost`,className:`size-7 shrink-0 p-0 text-danger`,title:t.composioRevoke,disabled:F,onClick:()=>G(e.id),children:(0,$.jsx)(Y,{className:`size-3.5`})})]},e.id))}),(0,$.jsx)(`div`,{className:`flex justify-end gap-1`,children:(0,$.jsx)(k,{variant:`ghost`,className:`size-8 p-0`,title:t.refresh,disabled:F,onClick:()=>void De(()=>we(r.id)),children:(0,$.jsx)(He,{className:`size-4`})})})]})]})]},e.key)})}):F&&!q?(0,$.jsxs)(`div`,{"aria-busy":`true`,"aria-label":t.connectionChecking,className:`space-y-3`,children:[(0,$.jsx)(A,{className:`h-16 w-full`}),(0,$.jsx)(A,{className:`h-16 w-full`})]}):q?(0,$.jsx)(`div`,{className:`rounded-xl border border-dashed border-edge px-4 py-8 text-center`,children:(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.composioConnectionsEmpty})}):null]}),(0,$.jsxs)(`details`,{className:`rounded-xl border border-edge bg-surface-base`,onToggle:e=>re(e.currentTarget.open),children:[(0,$.jsx)(`summary`,{className:`cursor-pointer px-4 py-3 text-sm font-medium text-fg-muted hover:text-fg`,children:t.composioAdvancedSettings}),(0,$.jsxs)(`div`,{className:`space-y-5 border-t border-edge-subtle px-4 py-4`,children:[oe?(0,$.jsx)(A,{"aria-label":t.connectionChecking,className:`h-16 w-full`}):null,H?(0,$.jsxs)(`p`,{className:`rounded-lg bg-amber-500/10 px-3 py-2 text-xs text-amber-800 dark:text-amber-200`,children:[t.composioDiagnosticsUnavailable,(0,$.jsx)(k,{variant:`ghost`,disabled:oe,onClick:()=>void he(),children:t.composioRetry})]}):null,C?.mode===`byok`?(0,$.jsxs)(`section`,{children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-2`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:t.composioAuthConfigTitle}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:Pe?t.composioAuthConfigRequiredHint:t.composioAuthConfigOptionalHint})]}),(0,$.jsx)(`a`,{className:`text-xs font-medium text-accent-fg hover:underline`,href:`https://app.composio.dev`,target:`_blank`,rel:`noreferrer`,children:t.composioAuthConfigManage})]}),(0,$.jsxs)(o,{className:`mt-3`,value:typeof e.config?.authConfigId==`string`?e.config.authConfigId:``,disabled:F,onChange:e=>void ve(e.currentTarget.value),children:[Pe?null:(0,$.jsx)(s,{value:``,children:t.composioAuthConfigManaged}),Pe&&typeof e.config?.authConfigId!=`string`?(0,$.jsx)(s,{value:``,disabled:!0,children:t.composioAuthConfigSelect}):null,Ie.map(e=>(0,$.jsxs)(s,{value:e.id,children:[e.name,` · `,e.authScheme??`OAuth`]},e.id))]})]}):null,(0,$.jsxs)(`div`,{className:`grid gap-5 sm:grid-cols-2`,children:[(0,$.jsxs)(`section`,{children:[(0,$.jsx)(`p`,{className:`mb-2 text-xs font-medium uppercase tracking-wide text-fg-subtle`,children:t.composioAgentTools}),(0,$.jsx)(`div`,{className:`space-y-2`,children:u.length?u.slice(0,8).map(e=>(0,$.jsxs)(`div`,{className:`rounded-lg bg-surface-panel px-3 py-2`,children:[(0,$.jsx)(`p`,{className:`truncate font-mono text-xs text-fg`,children:e.slug}),(0,$.jsxs)(`p`,{className:`mt-0.5 text-xs text-fg-subtle`,children:[bn(e.scope,t),e.curated?``:` ${t.composioUncuratedSuffix}`]})]},e.slug)):(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.composioToolsEmpty})})]}),(0,$.jsxs)(`section`,{children:[(0,$.jsx)(`p`,{className:`mb-2 text-xs font-medium uppercase tracking-wide text-fg-subtle`,children:t.composioRecentTriggers}),(0,$.jsx)(`div`,{className:`space-y-2`,children:p.length?p.slice(0,5).map(e=>(0,$.jsxs)(`div`,{className:`rounded-lg bg-surface-panel px-3 py-2`,children:[(0,$.jsx)(`p`,{className:`truncate text-xs text-fg`,children:e.trigger??e.id}),(0,$.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-subtle`,children:new Date(e.at).toLocaleString()})]},`${e.id}-${e.at}`)):(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.composioTriggersEmpty})})]})]})]})]}),(0,$.jsx)(xe,{open:K!==null,title:i?`断开账号`:`Disconnect account`,description:i?`停止此账号的工具使用和学习,并撤销其全部授权。已保存的数据不会删除。`:`Stop tool access and learning for this account and revoke all its authorizations. Saved data will not be deleted.`,confirmLabel:i?`断开`:`Disconnect`,cancelLabel:t.modalCancel,destructive:!0,onConfirm:()=>{let e=K;ee(null),e&&De(()=>N(e))},onCancel:()=>ee(null)}),(0,$.jsx)(xe,{open:W!==null,title:t.composioRevoke,description:t.composioRevokeConfirm,confirmLabel:t.composioRevoke,cancelLabel:t.modalCancel,destructive:!0,onConfirm:()=>{let e=W;G(null),e&&De(()=>st(e))},onCancel:()=>G(null)})]})}var Tn=h(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,V);function En(e,t){let n={};for(let r of e?.setup.config??[]){let e=t.config?.[r.key]??r.defaultValue??``;n[r.key]=typeof e==`string`?e:JSON.stringify(e,null,2)}return n}function Dn(e,t){let n=t.trim();return e===`json`?n?JSON.parse(n):void 0:e===`number`?n?Number(n):void 0:e===`boolean`?n===`true`:n||void 0}function On({instance:e,definition:t,onClose:n,onChanged:r,t:i}){let[a,o]=(0,Q.useState)(!1),[s,c]=(0,Q.useState)(!1),[l,u]=(0,Q.useState)(!1),[f,m]=(0,Q.useState)(!1),[g,_]=(0,Q.useState)(null),[v,y]=(0,Q.useState)(()=>En(t,e)),[D,O]=(0,Q.useState)(null),[A,j]=(0,Q.useState)(!1),[M,N]=(0,Q.useState)(null),P=t?.setup.config??[],F=(e.materialized.type===`mcp`||e.materialized.type===`memorySource`)&&P.length>0&&(t?.setup.secrets??[]).length===0,I=e.materialized.type===`mcp`,L=e.materialized.type===`composio`,R=e.materialized.type===`memorySource`,z=t?Ce(t,i):null,B=(0,Q.useCallback)(async()=>{j(!0),O(null);try{let t=await oe(e.instanceId);N(t),t.ok||O(t.error??t.action??i.healthStatusLabels[t.status]),await r()}catch(e){O(e instanceof Error?e.message:String(e))}finally{j(!1)}},[e.instanceId,r,i.healthStatusLabels]),V=(0,Q.useCallback)(async()=>{o(!0),O(null);try{await nt(e.instanceId),await r(),n()}catch(e){O(e instanceof Error?e.message:String(e)),o(!1)}},[e.instanceId,r,n]),H=(0,Q.useCallback)(async()=>{if(!(!t||!F)){u(!0),O(null);try{let n={};for(let e of t.setup.config??[]){let t=Dn(e.type,v[e.key]??``);t!==void 0&&(n[e.key]=t)}await Me(e.instanceId,{config:n}),await r()}catch(e){O(e instanceof Error?e.message:String(e))}finally{u(!1)}}},[v,t,e.instanceId,r,F]),W=(0,Q.useCallback)(async()=>{m(!0),_(null),O(null);try{_((await rt(e.connectorId)).recordIds.length),await r()}catch(e){O(e instanceof Error?e.message:String(e))}finally{m(!1)}},[e.connectorId,r]);return(0,$.jsxs)(E,{open:!0,onOpenChange:e=>{e||n()},children:[(0,$.jsxs)(C,{children:[(0,$.jsx)(b,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),(0,$.jsxs)(w,{className:h(`xopc-dialog-content fixed left-1/2 top-1/2 z-[60] flex -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden`,L?`h-[min(100dvh-2rem,36rem)] w-[min(100%-2rem,40rem)]`:`h-[min(100dvh-2rem,44rem)] w-[min(100%-2rem,min(92vw,54rem))]`,`rounded-2xl border border-edge bg-surface-overlay shadow-float outline-none dark:border-edge`),children:[(0,$.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge-subtle px-6 py-5`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[(0,$.jsx)(et,{connector:t,size:`lg`}),(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(T,{className:`text-base font-semibold text-fg`,children:e.displayName}),(0,$.jsx)(x,{className:`mt-1 text-sm text-fg-muted`,children:z??(e.materialized.type===`mcp`?We(i.mcpServerRuntime,{serverId:e.materialized.serverId}):We(i.runtimeLabel,{runtime:e.materialized.type}))})]})]}),(0,$.jsx)(S,{asChild:!0,children:(0,$.jsxs)(`button`,{type:`button`,className:h(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,te.focusRingPanel),"aria-label":i.modalClose,children:[(0,$.jsx)(p,{className:`size-5`,strokeWidth:1.75,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`sr-only`,children:i.modalClose})]})})]}),(0,$.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-6 py-5`,children:[D?(0,$.jsx)(`p`,{className:`mb-4 rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:D}):null,I?(0,$.jsxs)(`div`,{className:`space-y-3 rounded-xl border border-edge bg-surface-base p-3 text-sm`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,$.jsx)(`p`,{className:`text-fg-muted`,role:`status`,children:M?.ok?We(i.toolsAvailable,{count:String(M.toolCount)}):M?i.healthStatusLabels[M.status]:e.usage.lastHealthStatus?i.healthStatusLabels[e.usage.lastHealthStatus]:i.healthNotTested}),(0,$.jsxs)(k,{variant:`secondary`,"aria-busy":A,disabled:A||!e.enabled,onClick:()=>void B(),children:[A?(0,$.jsx)(d,{className:`size-4 animate-spin`,"aria-hidden":!0}):(0,$.jsx)(He,{className:`size-4`,"aria-hidden":!0}),i.test]})]}),F?P.map(e=>(0,$.jsxs)(`label`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(`span`,{className:`font-medium text-fg`,children:e.label}),e.description?(0,$.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:e.description}):null,(0,$.jsx)(`input`,{className:Tn,value:v[e.key]??``,placeholder:e.placeholder,onChange:t=>y(n=>({...n,[e.key]:t.currentTarget.value}))})]},e.key)):null]}):null,L?(0,$.jsx)(wn,{instance:e,t:i,onChanged:r}):null,R?(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3 rounded-xl border border-edge bg-surface-base p-4 text-sm`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`p`,{className:`font-medium text-fg`,children:i.connectedSourceSync}),z?(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:z}):null,g===null?null:(0,$.jsx)(`p`,{className:`mt-1 text-xs text-emerald-600`,children:We(i.connectedSourceSynced,{count:String(g)})})]}),(0,$.jsxs)(k,{disabled:f,onClick:()=>void W(),children:[f?(0,$.jsx)(d,{className:`size-4 animate-spin`}):(0,$.jsx)(U,{className:`size-4`}),i.composioSyncNow]})]}),F?(0,$.jsx)(`div`,{className:`grid gap-3 rounded-xl border border-edge bg-surface-base p-4`,children:P.map(e=>(0,$.jsxs)(`label`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:e.label}),e.description?(0,$.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:e.description}):null,(0,$.jsx)(`input`,{className:Tn,value:v[e.key]??``,placeholder:e.placeholder,onChange:t=>y(n=>({...n,[e.key]:t.currentTarget.value}))})]},e.key))}):null]}):null,!I&&!L&&!R?(0,$.jsx)(`div`,{className:`rounded-xl border border-edge bg-surface-base p-4 text-sm text-fg-muted`,children:(0,$.jsx)(`p`,{children:i.connectorPolicyHint})}):null,(0,$.jsxs)(`details`,{className:`mt-5 rounded-xl border border-edge`,children:[(0,$.jsx)(`summary`,{className:`cursor-pointer px-4 py-3 text-sm font-medium text-fg-muted hover:text-danger`,children:i.dangerZone}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-3 border-t border-danger/15 px-4 py-4 sm:flex-row sm:items-center sm:justify-between`,children:[(0,$.jsx)(`p`,{className:`text-xs leading-5 text-fg-muted`,children:i.removeConnectorHint}),(0,$.jsxs)(k,{variant:`secondary`,className:`shrink-0 border-danger/30 text-danger hover:bg-danger/10`,disabled:a,onClick:()=>c(!0),children:[a?(0,$.jsx)(d,{className:`size-4 animate-spin`}):(0,$.jsx)(Y,{className:`size-4`}),i.remove]})]})]})]}),(0,$.jsxs)(`div`,{className:`flex shrink-0 flex-wrap justify-end gap-2 border-t border-edge-subtle px-6 py-4`,children:[(0,$.jsx)(k,{variant:`secondary`,onClick:n,children:i.modalClose}),(I||R)&&F?(0,$.jsxs)(k,{variant:`primary`,disabled:l,onClick:()=>void H(),children:[l?(0,$.jsx)(d,{className:`size-4 animate-spin`}):(0,$.jsx)(ze,{className:`size-4`}),i.modalSave]}):null]})]})]}),(0,$.jsx)(xe,{open:s,title:We(i.removeConfirmTitle,{name:e.displayName}),description:i.removeConfirmDescription,confirmLabel:i.removeConfirmAction,cancelLabel:i.modalCancel,destructive:!0,onConfirm:()=>{c(!1),V()},onCancel:()=>{a||c(!1)}})]})}function kn(e){let t=(0,ft.c)(2),n;return t[0]===e?n=t[1]:(n=e.instance.materialized.type===`cli`&&e.definition?(0,$.jsx)(Ie,{definition:e.definition,instance:e.instance,onClose:e.onClose,onChanged:e.onChanged}):(0,$.jsx)(On,{...e}),t[0]=e,t[1]=n),n}function An(e){let t=(0,ft.c)(59),{instance:n,definition:r,highlighted:i,onOpenDetails:a,t:o}=e,s=i===void 0?!1:i,c;t[0]!==r||t[1]!==n?(c=Ct(n,r),t[0]=r,t[1]=n,t[2]=c):c=t[2];let u=c.state,d;t[3]!==r||t[4]!==o?(d=r?Ce(r,o):null,t[3]=r,t[4]=o,t[5]=d):d=t[5];let f=d,p,m,g,_,v,y,b,x,S;if(t[6]!==u||t[7]!==r||t[8]!==s||t[9]!==n||t[10]!==a||t[11]!==o.connectionChecking||t[12]!==o.connectionNeedsSetup||t[13]!==o.connectionReady){p=u===`ready`?{label:o.connectionReady,Icon:l,className:`text-emerald-700 dark:text-emerald-300`}:u===`needs_setup`?{label:o.connectionNeedsSetup,Icon:Oe,className:`text-amber-700 dark:text-amber-300`}:{label:o.connectionChecking,Icon:K,className:`text-fg-muted`},S=`button`;let e=u===`needs_setup`&&`border-amber-500/25`,i=s&&`bg-accent-soft`;t[23]!==e||t[24]!==i?(m=h(`flex min-h-[8.75rem] w-full min-w-0 flex-col rounded-xl border border-edge bg-surface-panel p-4 text-left hover:bg-surface-hover/45`,te.transition,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-accent`,e,i),t[23]=e,t[24]=i,t[25]=m):m=t[25],t[26]!==n||t[27]!==a?(g=()=>a(n),t[26]=n,t[27]=a,t[28]=g):g=t[28],b=`flex w-full min-w-0 items-start gap-3`,t[29]===r?x=t[30]:(x=(0,$.jsx)(et,{connector:r,size:`sm`}),t[29]=r,t[30]=x),v=`min-w-0 flex-1`,t[31]===n.displayName?y=t[32]:(y=(0,$.jsx)(`h3`,{className:`truncate text-sm font-semibold text-fg`,title:n.displayName,children:n.displayName}),t[31]=n.displayName,t[32]=y),_=h(`mt-1 inline-flex items-center gap-1 text-[11px]`,p.className),t[6]=u,t[7]=r,t[8]=s,t[9]=n,t[10]=a,t[11]=o.connectionChecking,t[12]=o.connectionNeedsSetup,t[13]=o.connectionReady,t[14]=p,t[15]=m,t[16]=g,t[17]=_,t[18]=v,t[19]=y,t[20]=b,t[21]=x,t[22]=S}else p=t[14],m=t[15],g=t[16],_=t[17],v=t[18],y=t[19],b=t[20],x=t[21],S=t[22];let C;t[33]===p.Icon?C=t[34]:(C=(0,$.jsx)(p.Icon,{className:`size-3.5`,"aria-hidden":!0}),t[33]=p.Icon,t[34]=C);let w;t[35]!==p.label||t[36]!==C||t[37]!==_?(w=(0,$.jsxs)(`span`,{className:_,children:[C,p.label]}),t[35]=p.label,t[36]=C,t[37]=_,t[38]=w):w=t[38];let T;t[39]!==w||t[40]!==v||t[41]!==y?(T=(0,$.jsxs)(`div`,{className:v,children:[y,w]}),t[39]=w,t[40]=v,t[41]=y,t[42]=T):T=t[42];let E;t[43]!==T||t[44]!==b||t[45]!==x?(E=(0,$.jsxs)(`div`,{className:b,children:[x,T]}),t[43]=T,t[44]=b,t[45]=x,t[46]=E):E=t[46];let D;t[47]===f?D=t[48]:(D=f?(0,$.jsx)(`p`,{className:`mt-2 w-full line-clamp-2 text-xs leading-5 text-fg-muted`,title:f,children:f}):null,t[47]=f,t[48]=D);let O;t[49]===Symbol.for(`react.memo_cache_sentinel`)?(O=(0,$.jsx)(de,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),t[49]=O):O=t[49];let k;t[50]===o.installedDetails?k=t[51]:(k=(0,$.jsxs)(`span`,{className:`mt-auto flex w-full items-center justify-end gap-1 pt-2 text-xs text-fg-muted`,children:[o.installedDetails,O]}),t[50]=o.installedDetails,t[51]=k);let A;return t[52]!==m||t[53]!==g||t[54]!==E||t[55]!==D||t[56]!==k||t[57]!==S?(A=(0,$.jsxs)(`button`,{type:S,className:m,onClick:g,children:[E,D,k]}),t[52]=m,t[53]=g,t[54]=E,t[55]=D,t[56]=k,t[57]=S,t[58]=A):A=t[58],A}function jn(e,t){return Gt()}function Mn(e){let t=e.headers.filter(e=>e.key.trim()),n=t.find(e=>e.key.toLowerCase()===`authorization`&&!e.reference&&/^Bearer\s/i.test(e.value)),r=e.extra.auth||t.some(e=>e.reference)||e.extra.oauth&&t.some(e=>e.key.toLowerCase()===`authorization`)?`existing`:e.extra.oauth?`oauth`:n?`bearer`:t.length?`headers`:`auto`;return{mode:r,token:n?.value.replace(/^Bearer\s+/i,``)??``,apiKey:``,headerName:``,customHeaders:t.length?t:[Mt()],additionalHeaders:r===`bearer`?t.filter(e=>e!==n):r===`oauth`?t:[]}}function Nn(e,t){if(e.transport===`stdio`||t.mode===`existing`)return{...e,extra:{...e.extra}};let n={...e.extra};delete n.auth,t.mode!==`oauth`&&delete n.oauth;let r=t.mode===`headers`?t.customHeaders:t.additionalHeaders;if(t.mode===`bearer`){let e=t.token.trim().replace(/^Bearer\s+/i,``);r=[...r,Mt(`Authorization`,`Bearer ${e}`)]}return t.mode===`apiKey`&&(r=[...r,Mt(t.headerName.trim(),t.apiKey.trim())]),{...e,extra:n,headers:r,oauthClientId:t.mode===`oauth`?e.oauthClientId:``}}function Pn(e){let t=new Set;return e.findIndex(e=>{let n=e.key.trim();if(!n&&!e.value&&!e.reference)return!1;if(!/^[!#$%&'*+.^_`|~\da-z-]+$/i.test(n)||/[\r\n]/.test(e.value))return!0;let r=n.toLowerCase();return t.has(r)?!0:(t.add(r),!1)})}function Fn(){return h(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,V)}function In({label:e,optionalLabel:t,addLabel:n,removeHeaderAria:r,pasteLabel:i,pasteFailed:a,pasteFailedTitle:o,dismissLabel:s,keyPlaceholder:c,valuePlaceholder:l,headers:u,onChange:d,referenceLabel:f=`Existing credential reference`,showValueLabel:p=`Show value`,hideValueLabel:m=`Hide value`,allowPaste:g=!0}){let[_,v]=(0,Q.useState)(new Set),[y,b]=(0,Q.useState)(!1),x=(e,t)=>{d(u.map((n,r)=>r===e?{...n,...t}:n))},S=()=>{d([...u,Mt()])},C=e=>{let t=u.filter((t,n)=>n!==e);d(t.length>0?t:[Mt()])},w=async()=>{try{let e=await D();if(!e){b(!0);return}let t=Pt(e);if(!t?.length){b(!0);return}d(t)}catch{b(!0)}};return(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 md:col-span-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 text-sm font-medium text-fg`,children:[(0,$.jsx)(`span`,{children:e}),t?(0,$.jsx)(`span`,{className:`font-normal text-fg-subtle`,children:t}):null]}),g?(0,$.jsxs)(k,{type:`button`,variant:`ghost`,className:`h-8 gap-1.5 px-2 text-xs`,onClick:()=>void w(),children:[(0,$.jsx)(G,{className:`size-3.5`,"aria-hidden":!0}),i]}):null]}),(0,$.jsx)(`div`,{className:`flex flex-col gap-2`,children:u.map((e,t)=>(0,$.jsxs)(`div`,{className:`grid min-w-0 grid-cols-[minmax(0,1fr)_auto_auto] items-center gap-2 sm:grid-cols-[minmax(0,1fr)_minmax(0,1.4fr)_auto_auto]`,children:[(0,$.jsx)(`input`,{className:h(Fn(),`col-span-3 min-w-0 font-mono text-xs sm:col-span-1`),"aria-label":`${c} ${t+1}`,value:e.key,placeholder:c,onChange:e=>x(t,{key:e.target.value})}),(0,$.jsx)(`input`,{className:h(Fn(),`min-w-0 font-mono text-xs`),type:_.has(e.clientKey)?`text`:`password`,autoComplete:`off`,"aria-label":`${l} ${t+1}`,readOnly:!!e.reference,value:e.reference?f:e.value,placeholder:e.reference?f:l,onChange:e=>x(t,{value:e.target.value})}),(0,$.jsx)(k,{type:`button`,variant:`ghost`,className:`size-10 shrink-0 px-0`,disabled:!!e.reference,"aria-label":_.has(e.clientKey)?m:p,onClick:()=>v(t=>{let n=new Set(t);return n.has(e.clientKey)?n.delete(e.clientKey):n.add(e.clientKey),n}),children:_.has(e.clientKey)?(0,$.jsx)(ee,{className:`size-4`,"aria-hidden":!0}):(0,$.jsx)(je,{className:`size-4`,"aria-hidden":!0})}),(0,$.jsx)(k,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 px-0`,disabled:u.length<=1&&!e.key&&!e.value,onClick:()=>C(t),"aria-label":r,children:(0,$.jsx)(Y,{className:`size-4 text-fg-subtle`,"aria-hidden":!0})}),e.reference?(0,$.jsx)(`p`,{className:`col-span-3 break-words text-xs text-fg-muted sm:col-span-4`,children:f}):null]},e.clientKey))}),(0,$.jsx)(xe,{open:y,title:o,description:a,confirmLabel:s,onConfirm:()=>b(!1),onCancel:()=>b(!1)}),(0,$.jsxs)(`button`,{type:`button`,className:h(`self-start text-sm text-accent hover:underline`,te.press),onClick:S,children:[`+ `,n]})]})}var Ln=h(`w-full min-w-0 rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,V);function Rn(e){let t=(0,ft.c)(20),{value:n,onChange:r,label:i,t:a,required:o}=e,s=o===void 0?!1:o,[c,l]=(0,Q.useState)(!1),u;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(u=h(Ln,`mt-1.5`),t[0]=u):u=t[0];let d=c?`text`:`password`,f;t[1]===r?f=t[2]:(f=e=>r(e.target.value),t[1]=r,t[2]=f);let p;t[3]!==s||t[4]!==d||t[5]!==f||t[6]!==n?(p=(0,$.jsx)(`input`,{className:u,type:d,value:n,required:s,autoComplete:`off`,onChange:f}),t[3]=s,t[4]=d,t[5]=f,t[6]=n,t[7]=p):p=t[7];let m;t[8]!==i||t[9]!==p?(m=(0,$.jsxs)(`label`,{className:`block text-sm font-medium text-fg`,children:[i,p]}),t[8]=i,t[9]=p,t[10]=m):m=t[10];let g;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(g=()=>l(zn),t[11]=g):g=t[11];let _;t[12]===c?_=t[13]:(_=c?(0,$.jsx)(ee,{className:`size-4`,"aria-hidden":!0}):(0,$.jsx)(je,{className:`size-4`,"aria-hidden":!0}),t[12]=c,t[13]=_);let v=c?a.setupHideValue:a.setupShowValue,y;t[14]!==_||t[15]!==v?(y=(0,$.jsxs)(k,{type:`button`,variant:`ghost`,className:`gap-1.5 text-xs`,onClick:g,children:[_,v]}),t[14]=_,t[15]=v,t[16]=y):y=t[16];let b;return t[17]!==y||t[18]!==m?(b=(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[m,y]}),t[17]=y,t[18]=m,t[19]=b):b=t[19],b}function zn(e){return!e}function Bn(e){let t=(0,ft.c)(17),{headers:n,onChange:r,t:i,additional:a,environment:o}=e,s=a===void 0?!1:a,c=o===void 0?!1:o,l=c?i.envLabel:s?i.setupAdditionalHeaders:i.headersLabel,u=c?i.setupAddEnv:i.addHeader,d=c?i.setupRemoveEnv:i.removeHeader,f=c?i.setupEnvName:i.headerKeyPlaceholder,p=c?i.setupEnvValue:i.headerValuePlaceholder,m=!c,h;return t[0]!==n||t[1]!==r||t[2]!==i.optionalSuffix||t[3]!==i.pasteHeaders||t[4]!==i.pasteHeadersDismiss||t[5]!==i.pasteHeadersFailed||t[6]!==i.pasteHeadersFailedTitle||t[7]!==i.setupHideValue||t[8]!==i.setupReference||t[9]!==i.setupShowValue||t[10]!==l||t[11]!==u||t[12]!==d||t[13]!==f||t[14]!==p||t[15]!==m?(h=(0,$.jsx)(In,{label:l,optionalLabel:i.optionalSuffix,addLabel:u,removeHeaderAria:d,pasteLabel:i.pasteHeaders,pasteFailed:i.pasteHeadersFailed,pasteFailedTitle:i.pasteHeadersFailedTitle,dismissLabel:i.pasteHeadersDismiss,keyPlaceholder:f,valuePlaceholder:p,headers:n,onChange:r,referenceLabel:i.setupReference,showValueLabel:i.setupShowValue,hideValueLabel:i.setupHideValue,allowPaste:m}),t[0]=n,t[1]=r,t[2]=i.optionalSuffix,t[3]=i.pasteHeaders,t[4]=i.pasteHeadersDismiss,t[5]=i.pasteHeadersFailed,t[6]=i.pasteHeadersFailedTitle,t[7]=i.setupHideValue,t[8]=i.setupReference,t[9]=i.setupShowValue,t[10]=l,t[11]=u,t[12]=d,t[13]=f,t[14]=p,t[15]=m,t[16]=h):h=t[16],h}function Vn(e){let t=(0,ft.c)(52),{draft:n,onChange:r,t:i,allowExisting:a}=e,c=i.setupAuthLabel,l=i.setupAuthLabel,u;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(u=h(Ln,`mt-1.5`),t[0]=u):u=t[0];let d=n.mode,f;t[1]===r?f=t[2]:(f=e=>r({mode:e.target.value}),t[1]=r,t[2]=f);let p;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(p=[`auto`,`oauth`,`bearer`,`apiKey`,`headers`,`none`],t[3]=p):p=t[3];let m;t[4]===i.setupAuthModes?m=t[5]:(m=p.map(e=>(0,$.jsx)(s,{value:e,children:i.setupAuthModes[e]},e)),t[4]=i.setupAuthModes,t[5]=m);let g;t[6]!==a||t[7]!==n.mode||t[8]!==i.setupAuthModes?(g=a||n.mode===`existing`?(0,$.jsx)(s,{value:`existing`,children:i.setupAuthModes.existing}):null,t[6]=a,t[7]=n.mode,t[8]=i.setupAuthModes,t[9]=g):g=t[9];let _;t[10]!==n.mode||t[11]!==i.setupAuthLabel||t[12]!==f||t[13]!==m||t[14]!==g?(_=(0,$.jsxs)(o,{"aria-label":l,className:u,value:d,onChange:f,children:[m,g]}),t[10]=n.mode,t[11]=i.setupAuthLabel,t[12]=f,t[13]=m,t[14]=g,t[15]=_):_=t[15];let v;t[16]!==i.setupAuthLabel||t[17]!==_?(v=(0,$.jsxs)(`label`,{className:`block text-sm font-medium text-fg`,children:[c,_]}),t[16]=i.setupAuthLabel,t[17]=_,t[18]=v):v=t[18];let y;t[19]!==n.mode||t[20]!==i.setupAuthAutoHint?(y=n.mode===`auto`?(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:i.setupAuthAutoHint}):null,t[19]=n.mode,t[20]=i.setupAuthAutoHint,t[21]=y):y=t[21];let b;t[22]!==n.mode||t[23]!==i.setupAuthOAuthHint?(b=n.mode===`oauth`?(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:i.setupAuthOAuthHint}):null,t[22]=n.mode,t[23]=i.setupAuthOAuthHint,t[24]=b):b=t[24];let x;t[25]!==n.mode||t[26]!==i.setupExistingHint?(x=n.mode===`existing`?(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:i.setupExistingHint}):null,t[25]=n.mode,t[26]=i.setupExistingHint,t[27]=x):x=t[27];let S;t[28]!==n.mode||t[29]!==n.token||t[30]!==r||t[31]!==i?(S=n.mode===`bearer`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Rn,{value:n.token,onChange:e=>r({token:e}),label:i.setupTokenLabel,t:i,required:!0}),(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:i.setupTokenHint})]}):null,t[28]=n.mode,t[29]=n.token,t[30]=r,t[31]=i,t[32]=S):S=t[32];let C;t[33]!==n.apiKey||t[34]!==n.headerName||t[35]!==n.mode||t[36]!==r||t[37]!==i?(C=n.mode===`apiKey`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`label`,{className:`block text-sm font-medium text-fg`,children:[i.setupApiKeyHeader,(0,$.jsx)(`input`,{className:h(Ln,`mt-1.5`),placeholder:`x-api-key`,value:n.headerName,required:!0,onChange:e=>r({headerName:e.target.value})})]}),(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:i.setupApiKeyHint}),(0,$.jsx)(Rn,{value:n.apiKey,onChange:e=>r({apiKey:e}),label:`API Key`,t:i,required:!0})]}):null,t[33]=n.apiKey,t[34]=n.headerName,t[35]=n.mode,t[36]=r,t[37]=i,t[38]=C):C=t[38];let w;t[39]!==n.customHeaders||t[40]!==n.mode||t[41]!==r||t[42]!==i?(w=n.mode===`headers`?(0,$.jsx)(Bn,{headers:n.customHeaders,onChange:e=>r({customHeaders:e}),t:i}):null,t[39]=n.customHeaders,t[40]=n.mode,t[41]=r,t[42]=i,t[43]=w):w=t[43];let T;return t[44]!==v||t[45]!==y||t[46]!==b||t[47]!==x||t[48]!==S||t[49]!==C||t[50]!==w?(T=(0,$.jsxs)(`div`,{className:`space-y-4`,children:[v,y,b,x,S,C,w]}),t[44]=v,t[45]=y,t[46]=b,t[47]=x,t[48]=S,t[49]=C,t[50]=w,t[51]=T):T=t[51],T}function Hn(e){let t=(0,ft.c)(8),{label:n,children:r,hint:i}=e,a;t[0]===n?a=t[1]:(a=(0,$.jsx)(`span`,{children:n}),t[0]=n,t[1]=a);let o;t[2]===i?o=t[3]:(o=i?(0,$.jsx)(`span`,{className:`block text-xs font-normal text-fg-muted`,children:i}):null,t[2]=i,t[3]=o);let s;return t[4]!==r||t[5]!==a||t[6]!==o?(s=(0,$.jsxs)(`label`,{className:`block space-y-1.5 text-sm font-medium text-fg`,children:[a,r,o]}),t[4]=r,t[5]=a,t[6]=o,t[7]=s):s=t[7],s}function Un({row:e,t,onUpdate:n}){let[r,i]=(0,Q.useState)(()=>It(e.envJson?JSON.parse(e.envJson):void 0)),[a,o]=(0,Q.useState)(!1),s=[];try{s=Rt(e.argsText)??[]}catch{}let c=e=>n({argsText:JSON.stringify(e)});return(0,$.jsxs)(`div`,{"data-field":`commandOptions`,className:`space-y-4`,children:[(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,$.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:t.argsLabel}),(0,$.jsx)(k,{type:`button`,variant:`ghost`,onClick:()=>o(e=>!e),children:a?t.setupArgsRows:t.setupArgsPaste})]}),a?(0,$.jsx)(Hn,{label:t.setupArgsPaste,hint:t.argsHint,children:(0,$.jsx)(`input`,{className:Ln,value:e.argsText,onChange:e=>n({argsText:e.target.value})})}):s.map((e,n)=>(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,$.jsx)(`input`,{className:Ln,"aria-label":`${t.argsLabel} ${n+1}`,value:e,onChange:e=>c(s.map((t,r)=>r===n?e.target.value:t))}),(0,$.jsx)(k,{type:`button`,variant:`ghost`,"aria-label":t.setupRemoveArg,onClick:()=>c(s.filter((e,t)=>t!==n)),children:(0,$.jsx)(Y,{className:`size-4`,"aria-hidden":!0})})]},n)),a?null:(0,$.jsxs)(k,{type:`button`,variant:`ghost`,onClick:()=>c([...s,``]),children:[(0,$.jsx)(f,{className:`size-4`,"aria-hidden":!0}),t.setupAddArg]})]}),(0,$.jsx)(Bn,{environment:!0,headers:r,t,onChange:e=>{i(e),n({envEntries:e,envJson:JSON.stringify(Ft(e)??{})})}})]})}function Wn(e){let t=(0,ft.c)(15),{row:n,t:r,onUpdate:i,variant:a,showOAuth:c,idReadOnly:l}=e,u=a===void 0?`all`:a,d=c===void 0?!1:c,f=l===void 0?!1:l,p=u!==`advanced`,m=u!==`basic`,h;t[0]!==p||t[1]!==i||t[2]!==n||t[3]!==r?(h=p?(0,$.jsxs)($.Fragment,{children:[n.transport===`stdio`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Hn,{label:`${r.commandLabel} *`,children:(0,$.jsx)(`input`,{"data-field":`command`,className:Ln,value:n.command,required:!0,onChange:e=>i({command:e.target.value})})}),(0,$.jsx)(Un,{row:n,t:r,onUpdate:i})]}):(0,$.jsx)(Hn,{label:`${r.urlLabel} *`,children:(0,$.jsx)(`input`,{"data-field":`url`,className:Ln,value:n.url,placeholder:`https://example.com/mcp`,required:!0,onChange:e=>i({url:e.target.value})})}),(0,$.jsx)(Hn,{label:r.setupNameLabel,hint:r.setupNameHint,children:(0,$.jsx)(`input`,{className:Ln,value:n.displayName??``,placeholder:r.setupNamePlaceholder,onChange:e=>i({displayName:e.target.value})})})]}):null,t[0]=p,t[1]=i,t[2]=n,t[3]=r,t[4]=h):h=t[4];let g;t[5]!==m||t[6]!==f||t[7]!==i||t[8]!==n||t[9]!==d||t[10]!==r?(g=m?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Hn,{label:r.serverIdLabel,hint:r.setupIdHint,children:(0,$.jsx)(`input`,{className:Ln,readOnly:f,value:n.id,onChange:e=>i({id:e.target.value}),placeholder:r.serverIdPlaceholder})}),n.transport===`stdio`?(0,$.jsx)(Hn,{label:r.cwdLabel,children:(0,$.jsx)(`input`,{className:Ln,value:n.cwd,onChange:e=>i({cwd:e.target.value})})}):null,n.transport!==`stdio`&&d?(0,$.jsx)(Hn,{label:r.oauthClientIdLabel,hint:r.oauthClientIdHint,children:(0,$.jsx)(`input`,{className:Ln,value:n.oauthClientId,onChange:e=>i({oauthClientId:e.target.value})})}):null,(0,$.jsx)(Hn,{label:r.exposureLabel,hint:r.setupExposureHint,children:(0,$.jsx)(o,{"aria-label":r.exposureLabel,className:Ln,value:n.exposure,onChange:e=>i({exposure:e.target.value}),children:[`codemode`,`deferred`,`direct`,`hidden`].map(e=>(0,$.jsx)(s,{value:e,children:r.exposureLabels[e]},e))})}),(0,$.jsx)(Hn,{label:r.requestTimeoutLabel,children:(0,$.jsx)(dt,{allowEmpty:!0,type:`number`,min:1,className:Ln,value:n.timeout??``,placeholder:r.setupDefaultTimeout,onChange:e=>i({timeout:e.target.value?Number(e.target.value):void 0})})})]}):null,t[5]=m,t[6]=f,t[7]=i,t[8]=n,t[9]=d,t[10]=r,t[11]=g):g=t[11];let _;return t[12]!==h||t[13]!==g?(_=(0,$.jsxs)(`div`,{className:`space-y-4`,children:[h,g]}),t[12]=h,t[13]=g,t[14]=_):_=t[14],_}function Gn(e,t){let n=e;if(n?.status===429)return t.setupRateLimited;if(n?.status===401)return t.setupGatewayUnauthorized;if(n?.status===404||n?.status===409)return t.setupConflict;if(n?.status&&n.status>=500)return t.setupGatewayCheckFailed;let r={command_missing:t.setupCommandMissing,connection_refused:t.setupConnectionRefused,host_not_found:t.setupHostNotFound,timeout:t.setupTimedOut,access_denied:t.setupAccessDenied,network:t.setupServiceNetworkFailed,tls:t.setupTlsFailed,invalid_response:t.setupInvalidResponse,not_found:t.setupEndpointNotFound,rate_limited:t.setupServiceRateLimited,configuration:t.setupInvalidConfig};if(n?.errorCode&&Object.hasOwn(r,n.errorCode))return r[n.errorCode];let i=e instanceof Error?e.message:typeof e==`string`?e:n?.error??``;return/ENOENT|command not found|executable.{0,30}not found/i.test(i)?t.setupCommandMissing:/ECONNREFUSED|connection refused/i.test(i)?t.setupConnectionRefused:/ENOTFOUND|EAI_AGAIN|could not resolve/i.test(i)?t.setupHostNotFound:/timeout|timed out/i.test(i)?t.setupTimedOut:/fetch failed|failed to fetch|network error|NetworkError/i.test(i)?n?.error===void 0?t.setupGatewayNetworkFailed:t.setupServiceNetworkFailed:/\b(?:401|403)\b|unauthorized|forbidden|permission denied/i.test(i)?t.setupAccessDenied:t.setupCheckFailed}function Kn(e,t){return JSON.stringify({id:e.id,config:qt(Nn(e,t))})}function qn(e,t){try{return Kn(e,t)}catch{return JSON.stringify({row:e,auth:t})}}function Jn(e){let{t,cs:n}=e,r=(0,Q.useId)(),[i,a]=(0,Q.useState)(e.initialRow),[c,f]=(0,Q.useState)(()=>Mn(e.initialRow)),[m,g]=(0,Q.useState)(`idle`),[_,v]=(0,Q.useState)(``),[y,S]=(0,Q.useState)(!1),[D,O]=(0,Q.useState)(),[A,j]=(0,Q.useState)(),[M,N]=(0,Q.useState)(),[P,F]=(0,Q.useState)(!1),[I,L]=(0,Q.useState)(!1),[R,z]=(0,Q.useState)(``),[B,V]=(0,Q.useState)(``),[U,W]=(0,Q.useState)([]),[G,K]=(0,Q.useState)(`0`),[ee,q]=(0,Q.useState)(0),[te,J]=(0,Q.useState)(``),[ne,Y]=(0,Q.useState)(!1),[re,ie]=(0,Q.useState)(!1),ae=e.mode===`edit`,[oe,se]=(0,Q.useState)(``),X=(0,Q.useRef)(void 0),[ce]=(0,Q.useState)(()=>qn(e.initialRow,Mn(e.initialRow))),le=(0,Q.useRef)(e.mode===`edit`?e.initialRow.id:``),ue=(0,Q.useRef)(void 0),de=(0,Q.useRef)(void 0),fe=(0,Q.useRef)(void 0),Z=(0,Q.useRef)(null),pe=(0,Q.useRef)(``),me=(0,Q.useRef)(!0),he=(0,Q.useRef)(null),ge=(0,Q.useRef)(null),_e=(0,Q.useRef)(null),ve=(0,Q.useRef)(null),ye=(0,Q.useRef)(e.onSaved);ye.current=e.onSaved;let be=M?.state===`starting`||M?.state===`authorizing`,Se=m!==`idle`||be,Ce=ce!==qn(i,c),we=i.extra.enabled===!1,Te=!y&&(Ce||!!R.trim());(0,Q.useEffect)(()=>(me.current=!0,()=>{me.current=!1,ue.current?.abort(),Z.current?.close(),X.current&&Zt(X.current).catch(()=>{})}),[]),(0,Q.useEffect)(()=>{if(!Te)return;let e=e=>{e.preventDefault(),e.returnValue=``};return window.addEventListener(`beforeunload`,e),()=>window.removeEventListener(`beforeunload`,e)},[Te]),(0,Q.useEffect)(()=>{if(!D)return;let e=_e.current?.querySelector(`[data-field="${D.field}"]`),t=e?.closest(`details`);t&&(t.open=!0);let n=e?.querySelector(`input,button,textarea`)??e;return n?.setAttribute(`aria-invalid`,`true`),n?.setAttribute(`aria-describedby`,r),D.focus!==!1&&(n??ve.current)?.focus(),()=>{n?.removeAttribute(`aria-invalid`),n?.removeAttribute(`aria-describedby`)}},[D,r]),(0,Q.useEffect)(()=>{if(!M||!be)return;let e=new AbortController;de.current=e;let n;async function r(){try{let n=await en(X.current,e.signal);if(e.signal.aborted||(N(n),n.authorizationUrl&&pe.current!==n.authorizationUrl&&(pe.current=n.authorizationUrl,window.electronAPI?.shell?.openExternalUrl?!(await window.electronAPI.shell.openExternalUrl(n.authorizationUrl)).ok&&!e.signal.aborted&&v(t.oauthOpenFailed):Z.current&&!Z.current.closed&&Z.current.location.replace(n.authorizationUrl)),e.signal.aborted))return;if(n.state===`connected`){fe.current=void 0,Z.current?.close(),j({state:`connected`,toolCount:n.toolCount}),v(``);return}if(n.state===`error`||n.state===`cancelled`){fe.current=void 0,Z.current?.close(),v(n.state===`cancelled`?t.setupCancelled:t.setupAuthFailed),/client.{0,20}(id|registration)|register|registration/i.test(n.error??``)&&F(!0);return}}catch{if(e.signal.aborted)return;Ee(),Z.current?.close(),v(t.setupAuthFailed);return}n=setTimeout(()=>void r(),1200)}return r(),()=>{e.abort(),clearTimeout(n)}},[M?.id,be,t.oauthOpenFailed,t.setupCancelled,t.setupAuthFailed]);function Ee(){ue.current?.abort(),de.current?.abort(),X.current&&Zt(X.current).catch(()=>{}),X.current=void 0,se(``),Y(!1),j(void 0),N(void 0),v(``),O(void 0)}function De(e){a(t=>({...t,...e})),Ee()}function Oe(e){f(t=>({...t,...e})),Ee()}function ke(){m===`saving`||be||(m===`checking`&&(Ee(),g(`idle`)),Te?ie(!0):e.onClose())}function Ae(){try{W(Wt(R)),K(`0`),V(``)}catch{V(t.setupImportError),W([])}}function je(){let t=U[Number(G)];if(!t)return;let n={...t,id:le.current||t.id,clientKey:e.initialRow.clientKey,extra:{...t.extra,...le.current?{enabled:i.extra.enabled}:{}}};a(n),f(Mn(n)),Ee(),q(e=>e+1),L(!1),z(``),W([])}function Me(e){function n(e,t){return O({field:e,message:t}),!1}if(e.transport===`streamable-http`){try{e.url=Ut(e.url)}catch{return n(`url`,t.setupAddressInvalid)}if(c.mode===`bearer`&&!c.token.trim().replace(/^Bearer\s*/i,``)||c.mode===`apiKey`&&(!c.apiKey.trim()||!c.headerName.trim()))return n(`auth`,t.setupCredentialRequired);if(Pn(e.headers)>=0)return n(`auth`,t.setupHeaderInvalid);if(c.mode===`oauth`&&e.headers.some(e=>e.key.trim().toLowerCase()===`authorization`))return n(`auth`,t.setupOAuthHeaderConflict);if(c.mode===`headers`&&!e.headers.some(e=>e.key.trim()&&(e.value.trim()||e.reference)))return n(`auth`,t.setupCredentialRequired)}else if(!e.command.trim())return n(`command`,t.setupCommandRequired);if(e.timeout!==void 0&&(!Number.isFinite(e.timeout)||e.timeout<=0))return n(`advanced`,t.setupInvalidConfig);try{qt(e)}catch(r){return n(e.transport===`stdio`?`commandOptions`:`advanced`,r instanceof Error&&r.message.startsWith(`Environment`)?t.setupEnvInvalid:t.setupInvalidConfig)}return!0}async function Ne(){v(``),g(`checking`),pe.current=``,window.electronAPI?.shell?.openExternalUrl||(Z.current=window.open(`about:blank`,`_blank`),Z.current&&(Z.current.opener=null));try{let e=await $t(X.current);if(!me.current){Z.current?.close(),X.current&&Zt(X.current).catch(()=>{});return}fe.current=e.id,N(e)}catch{Z.current?.close(),me.current&&v(t.setupAuthFailed)}finally{me.current&&g(`idle`)}}async function Pe(){let r=Nn(i,c);if(!Me(r))return;let o=e.existingCustomServers.filter(t=>t.clientKey!==e.initialRow.clientKey&&t.id!==le.current),s=new Set([...e.managedServerIds,...o.map(e=>e.id)]);if(r.id=le.current||r.id.trim()||Ht(r,s),!/^[a-zA-Z0-9_-]+$/.test(r.id)||[...s].some(e=>e.replace(/-/g,`_`)===r.id.replace(/-/g,`_`))){O({field:`advanced`,message:n.duplicateServerId});return}Ee(),g(`checking`);let l=new AbortController;ue.current=l;try{let n=await Yt(r,le.current||void 0,e.initialRow.extra,l.signal);if(!me.current||l.signal.aborted){Zt(n.id).catch(()=>{});return}X.current=n.id,a(r),se(qn(r,c));let i=await Xt(n.id,l.signal);if(!me.current||l.signal.aborted)return;j(i),i.state===`error`&&v(Gn(i,t))}catch(e){me.current&&!l.signal.aborted&&v(e.status===409?t.setupConflict:Gn(e,t))}finally{me.current&&ue.current===l&&g(`idle`)}}async function Fe(n=!1){if(!(!X.current||A?.state!==`connected`||oe!==qn(i,c))){g(`saving`),v(``);try{let t=await Qt(X.current,n);X.current=void 0,await ye.current().catch(()=>{}),t?.reloadRequired?S(!0):e.onClose()}catch(e){let n=e.status;n===404||n===409?(Ee(),v(t.setupConflict)):v(t.setupSaveFailed)}finally{me.current&&g(`idle`)}}}async function Ie(){de.current?.abort();let e=X.current;fe.current=void 0,N(void 0),Z.current?.close(),v(t.setupCancelled),g(`checking`);try{e&&await tn(e)}catch{me.current&&(Ee(),v(t.setupCancelled))}finally{me.current&&g(`idle`)}}async function Le(){M?.authorizationUrl&&(window.electronAPI?.shell?.openExternalUrl?(await window.electronAPI.shell.openExternalUrl(M.authorizationUrl)).ok||v(t.oauthOpenFailed):window.open(M.authorizationUrl,`_blank`,`noopener,noreferrer`))}async function Re(){if(M)try{await nn(X.current,te),J(``),v(``)}catch{v(t.setupRedirectInvalid)}}let ze=!!X.current&&oe===qn(i,c)&&(c.mode===`oauth`||c.mode===`auto`&&A?.state===`oauth_required`)&&A?.state!==`connected`,Be=/^(?:https?:\/\/)?(?:localhost|127\.0\.0\.1|\[::1\])(?=[:/]|$)/i.test(i.url.trim()),Ve=U[Number(G)];return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(E,{open:e.open,onOpenChange:e=>{e||ke()},children:(0,$.jsxs)(C,{children:[(0,$.jsx)(b,{className:`fixed inset-0 z-[60] bg-scrim`}),(0,$.jsxs)(w,{ref:he,tabIndex:-1,className:`fixed left-1/2 top-1/2 z-[60] flex h-[min(44rem,calc(100dvh-2rem))] w-[min(42rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-2xl border border-edge bg-surface-overlay`,onOpenAutoFocus:e=>{e.preventDefault(),he.current?.focus()},children:[(0,$.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge p-5`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(T,{className:`font-semibold`,children:e.mode===`edit`?t.setupEditTitle:t.setupTitle}),(0,$.jsx)(x,{className:`mt-1 text-sm text-fg-muted`,children:t.setupHint})]}),(0,$.jsx)(`button`,{type:`button`,disabled:m===`saving`||be,onClick:ke,className:`rounded-lg p-2 text-fg-muted hover:bg-surface-hover disabled:opacity-50`,"aria-label":n.modalClose,children:(0,$.jsx)(p,{className:`size-5`,"aria-hidden":!0})})]}),(0,$.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto overscroll-contain p-5`,children:[I?(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsx)(k,{variant:`ghost`,onClick:()=>L(!1),children:t.setupImportBack}),(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.setupImportEmpty}),(0,$.jsxs)(`label`,{className:`block text-sm font-medium text-fg`,children:[t.setupImport,(0,$.jsx)(`textarea`,{className:h(Ln,`mt-1.5 min-h-40 font-mono text-xs`),value:R,placeholder:`{"mcpServers": {"docs": {"url": "https://example.com/mcp"}}}`,onChange:e=>{z(e.target.value),W([]),V(``)}})]}),(0,$.jsx)(k,{variant:`secondary`,disabled:!R.trim(),onClick:Ae,children:t.setupImportPreview}),B?(0,$.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:B}):null,Ve?(0,$.jsxs)(`div`,{className:`space-y-3 rounded-lg border border-edge p-4`,children:[(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.setupImportScope}),(0,$.jsxs)(`label`,{className:`block text-sm font-medium`,children:[t.setupImportChoose,(0,$.jsx)(o,{"aria-label":t.setupImportChoose,className:h(Ln,`mt-1.5`),value:G,onChange:e=>K(e.target.value),children:U.map((e,t)=>(0,$.jsx)(s,{value:String(t),children:e.displayName||e.id||un(e)},t))})]}),(0,$.jsxs)(`p`,{className:`break-all text-sm text-fg-muted`,children:[Ve.transport===`stdio`?t.setupUseCommand:t.setupUseUrl,` · `,un(Ve)]})]}):null]}):(0,$.jsxs)(`form`,{ref:_e,noValidate:!0,onBlurCapture:e=>{if(e.target instanceof HTMLInputElement&&e.target.dataset.field===`url`&&i.url.trim())try{Ut(i.url)}catch{O({field:`url`,message:t.setupAddressInvalid,focus:!1})}},onSubmit:e=>{e.preventDefault(),Pe()},children:[(0,$.jsxs)(`fieldset`,{disabled:Se||y,className:`min-w-0 space-y-4`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,$.jsx)(H,{className:`flex gap-1`,role:`group`,"aria-label":t.transportLabel,children:[`streamable-http`,`stdio`].map(e=>(0,$.jsx)(k,{type:`button`,variant:i.transport===e?`secondary`:`ghost`,"aria-pressed":i.transport===e,onClick:()=>De({transport:e}),children:e===`stdio`?t.setupUseCommand:t.setupUseUrl},e))}),(0,$.jsx)(k,{type:`button`,variant:`ghost`,onClick:()=>L(!0),children:t.setupImport})]}),(0,$.jsx)(`div`,{children:(0,$.jsx)(Wn,{row:i,t,variant:`basic`,onUpdate:De},`${i.transport}-${ee}`)}),i.transport===`streamable-http`?(0,$.jsx)(`div`,{"data-field":`auth`,children:(0,$.jsx)(Vn,{allowExisting:!!i.extra.auth||i.headers.some(e=>!!e.reference),draft:c,onChange:Oe,t})}):null,D?(0,$.jsx)(`p`,{id:r,ref:ve,tabIndex:-1,role:`alert`,className:`text-sm text-danger`,children:D.message}):null,(0,$.jsxs)(`details`,{"data-field":`advanced`,className:`rounded-lg border border-edge p-3`,open:P,onToggle:e=>F(e.currentTarget.open),children:[(0,$.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg-muted`,children:t.setupAdvanced}),(0,$.jsxs)(`div`,{className:`mt-4 space-y-4`,children:[(0,$.jsx)(Wn,{row:i,t,variant:`advanced`,idReadOnly:ae,showOAuth:c.mode===`oauth`,onUpdate:De}),i.transport===`streamable-http`&&c.mode!==`headers`&&c.mode!==`existing`?(0,$.jsx)(Bn,{additional:!0,headers:c.additionalHeaders,onChange:e=>Oe({additionalHeaders:e}),t}):null]})]}),(0,$.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-muted`,children:i.transport===`stdio`?t.setupCommandHostHint:Be?t.setupLocalhostHint:t.setupGatewayHint}),(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.setupTestNotice})]}),(0,$.jsx)(`button`,{type:`submit`,hidden:!0})]}),y?(0,$.jsx)(`p`,{role:`alert`,className:`mt-4 text-sm text-fg`,children:t.setupReloadRequired}):null,!I&&!y?(0,$.jsxs)(`div`,{className:`mt-4 space-y-3`,"aria-live":`polite`,children:[m===`idle`?null:(0,$.jsxs)(`p`,{role:`status`,className:`flex items-center gap-2 text-sm text-fg-muted`,children:[(0,$.jsx)(d,{className:`size-4 animate-spin motion-reduce:animate-none`,"aria-hidden":!0}),m===`saving`?t.setupSaving:t.setupChecking]}),m===`idle`&&ae&&!Ce&&!A&&!_&&!be?(0,$.jsx)(`p`,{role:`status`,className:`text-sm text-fg-muted`,children:we?t.setupDisabled:e.lastCheck?t.setupLastCheck.replace(`{{count}}`,String(e.lastCheck.toolCount)):t.setupSavedUnchecked}):null,A?.state===`connected`?(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsxs)(`p`,{role:`status`,className:`flex items-center gap-2 text-sm text-success`,children:[(0,$.jsx)(l,{className:`size-4 shrink-0`,"aria-hidden":!0}),A.toolCount?t.setupConnected.replace(`{{count}}`,String(A.toolCount)):t.setupZeroTools]}),(0,$.jsx)(k,{ref:ge,variant:`secondary`,onClick:()=>Y(!0),children:t.viewTools})]}):null,A?.state===`token_required`?(0,$.jsx)(`p`,{role:`status`,className:`text-sm text-fg-muted`,children:t.setupNeedsAuth}):null,A?.state===`oauth_required`&&!be?(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.setupOAuthRequired}):null,be?(0,$.jsxs)(`div`,{className:`space-y-3 rounded-lg border border-edge p-4`,children:[(0,$.jsxs)(`p`,{role:`status`,className:`flex items-center gap-2 text-sm text-fg-muted`,children:[(0,$.jsx)(d,{className:`size-4 animate-spin motion-reduce:animate-none`,"aria-hidden":!0}),t.setupAuthorizing]}),(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[M?.authorizationUrl?(0,$.jsxs)(k,{variant:`secondary`,onClick:()=>void Le(),children:[(0,$.jsx)(u,{className:`size-4`,"aria-hidden":!0}),t.oauthOpenAuthorization]}):null,(0,$.jsx)(k,{variant:`ghost`,onClick:()=>void Ie(),children:t.setupCancelAuth})]}),M?.acceptsRedirect?(0,$.jsxs)(`details`,{children:[(0,$.jsx)(`summary`,{className:`cursor-pointer text-sm text-accent-fg`,children:t.setupRemoteFallback}),(0,$.jsx)(`p`,{className:`mt-2 text-xs text-fg-muted`,children:t.setupRedirectHint}),(0,$.jsxs)(`label`,{className:`mt-2 block text-sm`,children:[t.setupRedirectLabel,(0,$.jsx)(`input`,{className:Ln,value:te,onChange:e=>J(e.target.value)})]}),(0,$.jsx)(k,{className:`mt-2`,disabled:!te.trim(),onClick:()=>void Re(),children:t.setupContinue})]}):null]}):null,_?(0,$.jsxs)(`div`,{role:`alert`,className:`space-y-1 text-sm`,children:[(0,$.jsx)(`p`,{className:`text-danger`,children:_}),_!==t.setupSaveFailed&&m!==`saving`?(0,$.jsx)(`p`,{className:`text-fg-muted`,children:t.setupTestFailure}):null]}):null]}):null]}),(0,$.jsxs)(`div`,{className:`flex shrink-0 flex-wrap justify-end gap-2 border-t border-edge p-4`,children:[(0,$.jsx)(k,{variant:`secondary`,disabled:m===`saving`||be,onClick:ke,children:ae||y?t.setupClose:n.modalCancel}),y?null:I?(0,$.jsx)(k,{variant:`primary`,disabled:!Ve,onClick:je,children:t.setupImportApply}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(k,{variant:A?.state===`connected`?`secondary`:`primary`,disabled:Se,onClick:()=>ze?void Ne():void Pe(),children:ze?t.setupSignIn:t.setupTestConnection}),A?.state===`connected`&&oe===qn(i,c)?(0,$.jsxs)($.Fragment,{children:[we?(0,$.jsx)(k,{variant:`secondary`,disabled:Se,onClick:()=>void Fe(!0),children:t.setupEnableSave}):null,(0,$.jsx)(k,{variant:`primary`,disabled:Se,"aria-busy":Se,onClick:()=>void Fe(),children:ae?t.setupSaveOnly:t.setupAddConnection})]}):null]})]})]})]})}),(0,$.jsx)(xe,{open:re,title:t.setupUnsavedTitle,description:t.setupUnsavedHint,confirmLabel:t.setupDiscard,cancelLabel:t.setupKeepEditing,onCancel:()=>ie(!1),onConfirm:e.onClose,overlayClassName:`z-[70]`,contentClassName:`z-[70]`}),ne?(0,$.jsx)(sn,{draftId:X.current,serverId:i.id,displayName:i.displayName,returnFocusTo:ge.current,t,onClose:()=>Y(!1)}):null]})}var Yn=`recommended`,Xn=`builtin`,Zn=`composio`,Qn=`xopc-store`;function $n(e,t=`en`){return e==="default"&&t.startsWith(`zh`)?Yn:Xn}function er(e,t){let n=e.connectorManifest;if(!n||typeof n!=`object`||Array.isArray(n))return null;let r=n;if(r.contractVersion!==1||r.id!==e.name)return null;let i=r.runtime,a=r.auth;if(!i||typeof i!=`object`||Array.isArray(i)||!a||typeof a!=`object`||Array.isArray(a))return null;let o=i,s=a;if(o.type!==`mcp`||typeof o.serverId!=`string`)return null;let c=[`code`,`docs`,`browser`,`data`,`automation`,`custom`].includes(String(r.category??``))?r.category:`custom`,l=s.mode===`oauth`?{mode:`oauth`,...typeof s.clientId==`string`?{clientId:s.clientId}:{}}:s.mode===`apiKey`?{mode:`apiKey`}:{mode:`none`},u=e.localizations?.[t===`zh`?`zh-CN`:`en`];return{id:e.name,version:e.latestVersion??`store`,displayName:u?.displayName??(typeof r.displayName==`string`?r.displayName:e.name),description:u?.description??(typeof r.description==`string`?r.description:e.description),category:c,kind:`mcp`,source:`store`,...e.branding?.iconUrl?{branding:{logoUrl:e.branding.iconUrl,source:`registry`}}:{},capabilities:Array.isArray(r.capabilities)?r.capabilities.filter(e=>typeof e==`string`):[],tags:Array.isArray(r.tags)?r.tags.filter(e=>typeof e==`string`):[`store`],auth:l,setup:r.setup&&typeof r.setup==`object`&&!Array.isArray(r.setup)?r.setup:{},runtime:{type:`mcp`,serverId:o.serverId}}}function tr(e){return Re(e.map(e=>({connector:e,service:{id:e.id,source:e.source===`builtin`?`builtin-connector`:e.source===`store`?`store-connector`:`registry-connector`}})),`en`).map(e=>e.connector)}function nr(e){return e?.startsWith(`/`)&&!e.startsWith(`//`)?e:`/user-model`}function rr({embedded:e=!1,onHeaderActionChange:t}){let n=ye().filter(pn),r=v(e=>e.language),o=m(r),s=o.connectorsSettings,l=o.mcpSettings,u=_(e=>e.conversationId),f=!!u,p=i(),[g,y]=a(),b=g.get(`understanding`)===`1`,x=nr(g.get(`returnTo`)),S=!!g.get(`returnTo`)&&!b,C=g.get(`tab`),[w,T]=(0,Q.useState)(!b&&C===`connected`?`connected`:`discover`),{data:E}=O(f&&w===`discover`&&!b?[`service-recommendations`,r]:null,()=>X(r),{revalidateOnFocus:!1}),D=(0,Q.useMemo)(()=>new Set(E?.items.filter(e=>e.service?.source===`store-plugin`).map(e=>Ze(e.id))??[]),[E]),A=(0,Q.useRef)(!1),[j,N]=(0,Q.useState)({catalog:[],registryCatalog:[],instances:[],loading:!0,error:null}),[P,F]=(0,Q.useState)(!1),[I,L]=(0,Q.useState)(!1),[R,z]=(0,Q.useState)(1),[B,V]=(0,Q.useState)(void 0),[U,G]=(0,Q.useState)(``),[K,ee]=(0,Q.useState)(b||S?g.get(`connector`)??``:``),[q,te]=(0,Q.useState)($n(b?`understanding`:`default`,r)),[J,ne]=(0,Q.useState)(`name`),[Y,re]=(0,Q.useState)(b?`understand`:`all`),[ie,ae]=(0,Q.useState)(null),[oe,se]=(0,Q.useState)(null),[ce,le]=(0,Q.useState)(null),[ue,de]=(0,Q.useState)(null),[fe,pe]=(0,Q.useState)(null),[me,ge]=(0,Q.useState)(null),{data:ve,mutate:be}=M(f),xe=ve?.payload?.config,Ce=(0,Q.useMemo)(()=>xe===void 0?null:Kt(xe),[xe]),we=Ce?.servers??[],Te=j.instances.length+we.length+n.length,[Oe,ke]=(0,Q.useState)({});(0,Q.useEffect)(()=>{if(ke({}),!f||!xe)return;let e=new AbortController;return an(e.signal).then(t=>{e.signal.aborted||ke(t)}).catch(()=>{}),()=>e.abort()},[f,xe]);let Ae=(0,Q.useCallback)(async()=>{if(!u){N({catalog:[],registryCatalog:[],instances:[],loading:!1,error:null});return}N(e=>({...e,loading:!0,error:null}));try{let[e,t]=await Promise.all([Xe(),Le()]);N(n=>({catalog:e,registryCatalog:n.registryCatalog,instances:t,loading:!1,error:null}))}catch(e){N({catalog:[],registryCatalog:[],instances:[],loading:!1,error:e instanceof Error?e.message:String(e)})}},[u]);(0,Q.useEffect)(()=>{Ae()},[Ae]),(0,Q.useEffect)(()=>{A.current||j.loading||f&&!Ce||(T(b?`discover`:Te>0?`connected`:`discover`),A.current=!0)},[f,Te,Ce,b,j.loading]),(0,Q.useEffect)(()=>{te(e=>e===`builtin`||e===`recommended`?$n(b?`understanding`:`default`,r):e)},[r,b]);let je=(0,Q.useCallback)(e=>{A.current=!0,T(e)},[]),Me=(0,Q.useMemo)(()=>[{id:Zn,displayName:s.composioSourceName},{id:Qn,displayName:s.storeSourceName}],[s.composioSourceName,s.storeSourceName]),Fe=(0,Q.useCallback)(async e=>{if(!f||q===`builtin`||q===`recommended`){N(e=>({...e,registryCatalog:[]})),z(1),V(void 0);return}let t=K.trim(),n=Math.max(e?.page??1,1),i=e?.append??!1,a=q===`all`?Me:Me.filter(e=>e.id===q);if(a.length!==0){F(!0),i?N(e=>({...e,error:null})):(z(1),V(void 0),N(e=>({...e,registryCatalog:[],error:null})));try{let e=await Promise.all(a.map(async e=>{if(e.id===`composio`){let e=await _e({q:t||void 0,page:n,pageSize:24,verification:`experimental`});return{connectors:e.connectors,totalPages:e.meta.totalPages}}let i=await Ke({q:t||void 0,page:n,pageSize:24,sort:J===`source`?`newest`:`downloads`});return{connectors:i.items.flatMap(e=>{let t=er(e,r);return t?[t]:[]}),totalPages:i.meta.totalPages}})),o=tr(e.flatMap(e=>e.connectors)),s=Math.max(1,...e.map(e=>e.totalPages??1));z(n),V(s),N(e=>({...e,registryCatalog:i?tr([...e.registryCatalog,...o]):o}))}catch(e){N(t=>({...t,error:e instanceof Error?e.message:String(e)}))}finally{F(!1)}}},[J,K,q,f,Me,r]);(0,Q.useEffect)(()=>{if(w!==`discover`||j.loading)return;if(q===`builtin`||q===`recommended`){N(e=>({...e,registryCatalog:[]})),z(1),V(void 0);return}let e=window.setTimeout(()=>{Fe()},K.trim()?350:0);return()=>window.clearTimeout(e)},[K,q,Fe,j.loading,w]);let Ie=(0,Q.useMemo)(()=>new Set(j.instances.map(e=>e.connectorId)),[j.instances]),Re=(0,Q.useMemo)(()=>new Map([...j.catalog,...j.registryCatalog].map(e=>[e.id,e])),[j.catalog,j.registryCatalog]);(0,Q.useEffect)(()=>{if(j.loading)return;let e=g.get(`connector`),t=g.get(`instance`);if(!e&&!t)return;let n=j.instances.find(n=>t?n.instanceId===t:n.connectorId===e);if(n)A.current=!0,G(``),le(n.instanceId),de(n),T(`connected`);else if(e){let t=Re.get(e);if(!t)return;A.current=!0,te($n(b?`understanding`:`default`,r)),ee(``),se(t),T(`discover`)}let i=new URLSearchParams(g);i.delete(`connector`),i.delete(`instance`),i.set(`tab`,n?`connected`:`discover`),y(i,{replace:!0})},[Re,b,r,g,y,j.instances,j.loading]);let ze=(0,Q.useCallback)(async e=>{L(!0),N(e=>({...e,error:null}));try{let t=await De(e);ae(Ee(t.definition,{packageName:t.packageName,version:t.version,reviewHash:t.reviewHash,permissions:t.permissions}))}catch(e){N(t=>({...t,error:e instanceof Error?e.message:String(e)}))}finally{L(!1)}},[]);(0,Q.useEffect)(()=>{let e=g.get(`storeConnector`);if(!f||!e)return;let t=new URLSearchParams(g);t.delete(`storeConnector`),y(t,{replace:!0}),ze(e)},[f,g,y,ze]);let Be=(0,Q.useMemo)(()=>new Set(j.instances.flatMap(e=>e.materialized.type===`mcp`?[e.materialized.serverId]:[])),[j.instances]),He=(0,Q.useCallback)(async e=>{let t=await on(e);await be(),await Ae(),t.reloadRequired&&N(e=>({...e,error:l.setupReloadRequired}))},[Ae,be,l.setupReloadRequired]),Ue=(0,Q.useCallback)(()=>{ge({mode:`add`,row:jn(we,Be)})},[we,Be]),We=Ve(e=>e.setPageHeader),Ge=Ve(e=>e.clearPageHeader),qe=(0,Q.useMemo)(()=>({searchLabel:w===`connected`?s.connectedSearchPlaceholder:s.discoverSearchPlaceholder,search:(0,$.jsx)(ct,{value:w===`connected`?U:K,onChange:w===`connected`?G:ee,placeholder:w===`connected`?s.connectedSearchPlaceholder:s.discoverSearchPlaceholder}),secondary:(0,$.jsx)(jt,{onRefresh:w===`connected`&&f?Ae:void 0,refreshing:j.loading,refreshLabel:s.refreshConnections,onBrowseCatalog:()=>je(`discover`),onAddCustomServer:Ue,addLabel:s.addConnection,browseLabel:s.addFromCatalog,customLabel:s.addCustomServerAdvanced,serviceLabel:r.startsWith(`zh`)?`应用连接服务`:`Connection service`,moreActionsLabel:o.capabilitiesHub.moreActions})}),[U,s,K,f,r,Ae,o.capabilitiesHub.moreActions,Ue,je,j.loading,w]);(0,Q.useLayoutEffect)(()=>e?(t?.(qe),()=>t?.(null)):(We({startExtra:null,main:(0,$.jsx)(`div`,{className:`min-w-0`,children:(0,$.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:s.title})}),end:(0,$.jsx)(lt,{contribution:qe})}),()=>Ge()),[Ge,s.title,e,qe,t,We]);let Je=(0,Q.useMemo)(()=>j.instances.map(e=>({instance:e,value:Ct(e,Re.get(e.connectorId))})),[Re,j.instances]),Qe=(0,Q.useMemo)(()=>new Map(Je.map(({instance:e,value:t})=>[e.instanceId,t])),[Je]),et=(0,Q.useMemo)(()=>j.instances.filter(e=>he(e,U)).sort((e,t)=>{let n={needs_setup:0,checking:1,ready:2},r=Qe.get(e.instanceId)?.state??`checking`,i=Qe.get(t.instanceId)?.state??`checking`;return n[r]-n[i]||e.displayName.localeCompare(t.displayName)}),[U,Qe,j.instances]),tt=(0,Q.useMemo)(()=>et.filter(e=>Qe.get(e.instanceId)?.state===`needs_setup`),[Qe,et]),nt=(0,Q.useMemo)(()=>et.filter(e=>Qe.get(e.instanceId)?.state!==`needs_setup`),[Qe,et]),rt=(0,Q.useMemo)(()=>we.filter(e=>Ne(e,U)),[U,we]),it=(0,Q.useMemo)(()=>{let e=U.trim().toLowerCase();return n.filter(t=>[t.name,t.description,...(t.setup?.authorizations??[]).map(e=>e.title),...(t.components?.mcp??[]).map(e=>e.name)].filter(Boolean).join(` `).toLowerCase().includes(e))},[U,n]),at=et.length+rt.length+it.length,ot=(0,Q.useMemo)(()=>j.catalog.filter(e=>e.source===`builtin`&&e.integrationStrategy?.preferred!==!1&&Se(e)),[j.catalog]),st=(0,Q.useMemo)(()=>q===`recommended`?[]:q===`builtin`?ot:q===`all`?tr([...ot,...j.registryCatalog]):j.registryCatalog,[ot,q,j.registryCatalog]),ut=(0,Q.useMemo)(()=>{let e=b?st.filter(e=>e.understanding?.mode===`activity`):tr(st).filter(e=>!D.has(Ze(e.id)));return $e(Y===`all`?e:e.filter(e=>xt(e).includes(Y)),K,J)},[J,K,st,b,Y,D]),dt=(0,Q.useMemo)(()=>bt.filter(e=>st.some(t=>xt(t).includes(e))),[st]);(0,Q.useEffect)(()=>{Y!==`all`&&!dt.includes(Y)&&re(`all`)},[dt,Y]);let ft=w===`discover`&&q!==`builtin`&&!!(B&&R<B),mt=(0,Q.useMemo)(()=>j.instances.find(e=>e.instanceId===ce)??ue,[ce,ue,j.instances]),_t=(0,Q.useMemo)(()=>[{value:Yn,label:r===`zh`?`推荐服务`:`Recommended services`},{value:`all`,label:s.discoverSourceAll},{value:Xn,label:s.discoverSourceBuiltin},...Me.map(e=>({value:e.id,label:e.displayName}))],[s.discoverSourceAll,s.discoverSourceBuiltin,Me,r]),St=[{id:`connected`,label:s.tabConnected,count:Te},{id:`discover`,label:s.tabDiscover}];return(0,$.jsx)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col bg-surface-panel`,children:(0,$.jsxs)(`div`,{className:h(`mx-auto flex w-full max-w-7xl flex-col gap-6 px-4 sm:px-6 lg:px-8`,e?`pb-7 pt-3 lg:pb-9 lg:pt-4`:`py-7 lg:py-9`),children:[f?null:(0,$.jsx)(`p`,{className:`rounded-xl border border-edge bg-surface-panel px-4 py-3 text-sm text-fg-muted`,children:s.tokenHint}),b?(0,$.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-xl border border-accent/25 bg-accent-soft px-4 py-3 sm:flex-row sm:items-center sm:justify-between`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`p`,{className:`text-sm font-semibold text-fg`,children:s.understandingSetupTitle}),(0,$.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:s.understandingSetupHint})]}),(0,$.jsx)(k,{type:`button`,variant:`secondary`,className:`shrink-0`,onClick:()=>p(x),children:s.understandingSetupDone})]}):null,S?(0,$.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-xl border border-accent/25 bg-accent-soft px-4 py-3 sm:flex-row sm:items-center sm:justify-between`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`p`,{className:`text-sm font-semibold text-fg`,children:s.recoverySetupTitle}),(0,$.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:s.recoverySetupHint})]}),(0,$.jsx)(k,{type:`button`,variant:`secondary`,className:`min-h-11 shrink-0`,onClick:()=>p(x),children:s.recoverySetupDone})]}):null,(0,$.jsxs)(`section`,{className:`flex flex-col gap-4`,children:[(0,$.jsx)(`div`,{className:`border-b border-edge-subtle pb-3 dark:border-edge-subtle`,children:(0,$.jsx)(Z,{items:St,activeTab:w,onChange:je,ariaLabel:s.navAria,tabIdPrefix:`connectors-tab`,panelIdPrefix:`connectors-panel`,className:`flex-wrap`})}),j.error?(0,$.jsx)(`p`,{className:`rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:j.error}):null,w===`connected`&&f?(0,$.jsx)(`div`,{className:`flex flex-col gap-6`,children:j.loading?(0,$.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 xl:grid-cols-3`,"aria-busy":`true`,"aria-label":s.loading,children:ht.slice(0,3).map(e=>(0,$.jsx)(yt,{},e))}):Te===0?(0,$.jsxs)(`div`,{className:`py-14 text-center`,children:[(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:s.connectionsEmpty}),(0,$.jsx)(k,{type:`button`,variant:`primary`,className:`mt-4`,onClick:()=>je(`discover`),children:s.addFromCatalog})]}):at===0?(0,$.jsx)(`div`,{className:`py-14 text-center text-sm text-fg-muted`,children:s.connectionsSearchEmpty}):(0,$.jsxs)(`div`,{className:`space-y-6`,children:[tt.length?(0,$.jsxs)(`section`,{children:[(0,$.jsxs)(`div`,{className:`mb-2 flex items-center gap-2`,children:[(0,$.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:s.needsAttentionTitle}),(0,$.jsx)(`span`,{className:`text-xs tabular-nums text-amber-700 dark:text-amber-300`,children:tt.length})]}),(0,$.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 xl:grid-cols-3`,children:tt.map(e=>(0,$.jsx)(An,{instance:e,definition:Re.get(e.connectorId),highlighted:e.instanceId===fe,onOpenDetails:e=>{pe(null),le(e.instanceId),de(e)},t:s},e.instanceId))})]}):null,nt.length||it.length?(0,$.jsx)(`section`,{children:(0,$.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2 xl:grid-cols-3`,children:[nt.map(e=>(0,$.jsx)(An,{instance:e,definition:Re.get(e.connectorId),highlighted:e.instanceId===fe,onOpenDetails:e=>{pe(null),le(e.instanceId),de(e)},t:s},e.instanceId)),it.map(e=>(0,$.jsx)(mn,{extension:e,language:r,onOpen:()=>p(Ye(e.pluginId,`connections`,e.authorizationStatus===`required`))},e.id))]})}):null,rt.length||!U.trim()?(0,$.jsx)(fn,{servers:rt,lastChecks:Oe,t:l,cs:s,onAdd:Ue,onEdit:e=>ge({mode:`edit`,row:structuredClone(e)}),onRemove:He}):null]})}):null,w===`discover`&&f?(0,$.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[b?null:(0,$.jsx)(H,{className:`flex min-w-0 flex-1 basis-80 flex-wrap gap-2`,role:`group`,"aria-label":s.taskFilterAria,indicatorClassName:`rounded-lg bg-surface-active`,children:[`all`,...dt].map(e=>(0,$.jsx)(`button`,{type:`button`,className:h(`rounded-full border px-3 py-1.5 text-xs font-medium transition-colors`,Y===e?`border-accent/40 bg-accent-soft text-accent-fg`:`border-edge bg-surface-panel text-fg-muted hover:bg-surface-hover hover:text-fg`),"aria-pressed":Y===e,onClick:()=>re(e),children:e===`all`?s.taskAll:s.connectorBenefitHeadings[e]},e))}),(0,$.jsxs)(`div`,{className:h(`ml-auto grid w-full gap-2 sm:flex sm:w-auto sm:justify-end`,b?`grid-cols-1`:`grid-cols-2`),children:[b?null:(0,$.jsx)(`div`,{className:`min-w-0 sm:w-40`,children:(0,$.jsx)(c,{value:q,options:_t,placeholder:s.discoverSourceAll,allowEmpty:!1,ariaLabel:s.registrySourceAria,triggerClassName:`h-9 bg-surface-panel text-xs`,onChange:te})}),q===`recommended`?null:(0,$.jsx)(`div`,{className:`min-w-0 sm:w-40`,children:(0,$.jsx)(c,{value:J,options:[{value:`name`,label:s.sortName},{value:`source`,label:s.sortSource}],placeholder:s.sortName,allowEmpty:!1,ariaLabel:s.sortAria,triggerClassName:`h-9 bg-surface-panel text-xs`,onChange:e=>ne(e)})})]})]}),q===`recommended`?(0,$.jsx)(W,{layout:`cards`,initialCount:6,query:K,onChanged:async()=>{await Ae(),await be()}}):(j.loading||P)&&ut.length===0?(0,$.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 xl:grid-cols-3`,"aria-busy":`true`,"aria-label":s.loading,children:ht.map(e=>(0,$.jsx)(vt,{},e))}):ut.length===0?(0,$.jsx)(`div`,{className:`py-14 text-center text-sm text-fg-muted`,children:s.discoverEmpty}):(0,$.jsxs)(`div`,{className:`relative`,children:[P?(0,$.jsx)(`div`,{className:`pointer-events-none absolute inset-0 z-[1] flex justify-center bg-surface-panel/40 pt-[min(28vh,7.5rem)] backdrop-blur-[1px] motion-reduce:backdrop-blur-none dark:bg-surface-base/35`,"aria-busy":`true`,"aria-label":s.loading,children:(0,$.jsx)(d,{className:`size-8 shrink-0 animate-spin text-accent motion-reduce:animate-none`,strokeWidth:2,"aria-hidden":!0})}):null,(0,$.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 xl:grid-cols-3`,children:ut.map(e=>(0,$.jsx)(pt,{connector:e,installed:Ie.has(e.id)||gt(e,j.instances),onInstall:e=>{if(e.source===`store`){ze(e.id);return}ae(Ee(e))},onOpenDetails:e.source===`store`?void 0:se,t:s},e.id))}),ft?(0,$.jsx)(`div`,{className:`mt-4 flex justify-center`,children:(0,$.jsxs)(k,{type:`button`,variant:`secondary`,disabled:P||I,onClick:()=>void Fe({page:R+1,append:!0}),children:[P?(0,$.jsx)(d,{className:`size-4 animate-spin`}):null,s.loadMore]})}):null]})]}):null]}),ie?(0,$.jsx)(Pe,{draft:ie,onChange:ae,onClose:()=>ae(null),t:s,onInstalled:async e=>{await Ae(),await be(),pe(e.instanceId),je(`connected`)}}):null,oe?(0,$.jsx)(Dt,{connector:oe,installed:Ie.has(oe.id)||gt(oe,j.instances),onClose:()=>se(null),onInstall:e=>ae(Ee(e)),t:s}):null,mt?(0,$.jsx)(kn,{instance:mt,definition:Re.get(mt.connectorId),onClose:()=>{le(null),de(null)},onChanged:Ae,t:s,mcp:l}):null,me?(0,$.jsx)(Jn,{open:!0,mode:me.mode,initialRow:me.row,lastCheck:me.mode===`edit`?Oe[me.row.id]:void 0,existingCustomServers:we,config:xe,managedServerIds:Be,t:l,cs:s,onClose:()=>ge(null),onSaved:async()=>{await be(),await Ae(),je(`connected`)}},`${me.mode}-${me.row.clientKey}`):null]})})}export{rr as ConnectorsPage};
@@ -1 +0,0 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./chunk-KS7C4IRE-B2HK1psj.js";import{t as a}from"./check-DUBLcKHA.js";import{t as o}from"./x-B_N4OPjy.js";import{t as s}from"./cn-0WouolD0.js";import{t as c}from"./button-aIC072nz.js";import{Ja as l,Xa as u,Xu as d,Ya as f,Za as p,eu as m,qa as h,sf as g}from"./index-uAJlrGvo.js";var _=n(),v=e(t(),1),y=r(),b=`!z-[10000] max-w-[min(28rem,90vw)] rounded-md border border-edge bg-surface-overlay px-2.5 py-2 text-left text-xs leading-relaxed text-fg shadow-lg`;function x(e){let t=(0,_.c)(31),{candidates:n,selectedIds:r,labels:x,disabled:C,borderless:w,getTaskHref:T,onChange:E}=e,D=w===void 0?!1:w,[O,k]=(0,v.useState)(!1),[A,j]=(0,v.useState)(``),M;t[0]===A?M=t[1]:(M=A.trim().toLocaleLowerCase(),t[0]=A,t[1]=M);let N=M,P;if(t[2]!==n||t[3]!==N){let e;t[5]===N?e=t[6]:(e=e=>!N||e.title.toLocaleLowerCase().includes(N),t[5]=N,t[6]=e),P=n.filter(e).slice(0,20),t[2]=n,t[3]=N,t[4]=P}else P=t[4];let F=P,I;t[7]!==n||t[8]!==C||t[9]!==T||t[10]!==x.remove||t[11]!==E||t[12]!==r?(I=r.length>0?(0,y.jsx)(`div`,{className:`flex min-w-0 flex-wrap gap-2`,children:r.map(e=>{let t=n.find(t=>t.id===e);return t?(0,y.jsxs)(`span`,{className:`inline-flex min-w-0 max-w-full items-center gap-1.5 rounded-lg bg-surface-hover px-2.5 py-1.5 text-xs text-fg-muted`,children:[(0,y.jsxs)(u,{children:[(0,y.jsx)(p,{asChild:!0,children:T?(0,y.jsx)(i,{to:T(t.id),className:`min-w-0 whitespace-normal break-words [overflow-wrap:anywhere] rounded-sm outline-none transition-colors hover:text-fg hover:underline focus-visible:ring-2 focus-visible:ring-accent/50`,children:t.title}):(0,y.jsx)(`span`,{className:`min-w-0 whitespace-normal break-words [overflow-wrap:anywhere]`,children:t.title})}),(0,y.jsx)(l,{children:(0,y.jsx)(h,{side:`top`,sideOffset:6,collisionPadding:12,className:b,children:(0,y.jsx)(`span`,{className:`break-words`,children:t.title})})})]}),(0,y.jsx)(`button`,{type:`button`,className:`shrink-0 rounded text-fg-subtle transition-colors hover:text-fg`,"aria-label":x.remove.replace(`{{task}}`,t.title),disabled:C,onClick:()=>E(r.filter(e=>e!==t.id)),children:(0,y.jsx)(o,{className:`size-3.5`,"aria-hidden":!0})})]},t.id):null})}):null,t[7]=n,t[8]=C,t[9]=T,t[10]=x.remove,t[11]=E,t[12]=r,t[13]=I):I=t[13];let L;t[14]!==D||t[15]!==n.length||t[16]!==C||t[17]!==x.link||t[18]!==x.linked||t[19]!==x.noCandidates||t[20]!==x.noMatches||t[21]!==x.searchPlaceholder||t[22]!==F||t[23]!==E||t[24]!==O||t[25]!==A||t[26]!==r?(L=n.length>0?(0,y.jsxs)(y.Fragment,{children:[(0,y.jsxs)(c,{type:`button`,variant:`secondary`,className:s(`w-fit rounded-lg`,D&&`border-0 bg-surface-hover shadow-none`),disabled:C,"aria-expanded":O,onClick:()=>k(S),children:[(0,y.jsx)(d,{className:`size-4`,"aria-hidden":!0}),r.length>0?x.linked.replace(`{{count}}`,String(r.length)):x.link,(0,y.jsx)(g,{className:s(`size-3.5 transition-transform`,O&&`rotate-180`),"aria-hidden":!0})]}),O?(0,y.jsxs)(`div`,{className:s(`grid gap-2 rounded-lg p-2`,D?`bg-surface-hover`:`border border-edge bg-surface-base`),children:[(0,y.jsxs)(`label`,{className:`relative block`,children:[(0,y.jsx)(m,{className:`pointer-events-none absolute left-2.5 top-1/2 size-4 -translate-y-1/2 text-fg-subtle`,"aria-hidden":!0}),(0,y.jsx)(`input`,{value:A,onChange:e=>j(e.target.value),placeholder:x.searchPlaceholder,className:s(`h-9 w-full rounded-md bg-surface-panel pl-8 pr-3 text-sm text-fg outline-none placeholder:text-fg-subtle`,D?`focus:ring-2 focus:ring-accent/30`:`border border-edge focus:border-accent`),autoFocus:!0})]}),F.length>0?(0,y.jsx)(`div`,{className:`grid max-h-52 gap-1 overflow-y-auto`,children:F.map(e=>{let t=r.includes(e.id);return(0,y.jsxs)(`button`,{type:`button`,"aria-pressed":t,disabled:C,onClick:()=>E(t?r.filter(t=>t!==e.id):[...r,e.id]),className:s(`flex items-center gap-2 rounded-md px-2.5 py-2 text-left text-sm transition-colors`,t?`bg-accent-soft text-accent-fg`:`text-fg hover:bg-surface-hover`),children:[(0,y.jsx)(`span`,{className:s(`flex size-4 shrink-0 items-center justify-center rounded`,D?t?`bg-accent text-on-accent`:`bg-surface-active`:t?`border border-accent bg-accent text-on-accent`:`border border-edge`),children:t?(0,y.jsx)(a,{className:`size-3`,"aria-hidden":!0}):null}),(0,y.jsx)(`span`,{className:`min-w-0 flex-1 whitespace-normal break-words [overflow-wrap:anywhere]`,children:e.title})]},e.id)})}):(0,y.jsx)(`p`,{className:`px-2 py-3 text-center text-sm text-fg-subtle`,children:x.noMatches})]}):null]}):(0,y.jsx)(`p`,{className:`text-sm text-fg-subtle`,children:x.noCandidates}),t[14]=D,t[15]=n.length,t[16]=C,t[17]=x.link,t[18]=x.linked,t[19]=x.noCandidates,t[20]=x.noMatches,t[21]=x.searchPlaceholder,t[22]=F,t[23]=E,t[24]=O,t[25]=A,t[26]=r,t[27]=L):L=t[27];let R;return t[28]!==I||t[29]!==L?(R=(0,y.jsx)(f,{delayDuration:300,children:(0,y.jsxs)(`div`,{className:`min-w-0 grid gap-2`,children:[I,L]})}),t[28]=I,t[29]=L,t[30]=R):R=t[30],R}function S(e){return!e}export{x as t};
@@ -1 +0,0 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./x-B_N4OPjy.js";import{t as a}from"./messages-D__oW2yE.js";import{n as o}from"./locale-store-D_migb9R.js";import{sf as s,t as c}from"./index-uAJlrGvo.js";import{t as l}from"./desktop-pet-sprite-Bd-aOI7N.js";var u=e(t(),1),d=n(),f=9e4,p=3e4,m=20*6e4,h=45e3,g=45*6e4,_=58;function v(e,t){return e.state===`running`&&t-(e.startedAt??e.timestamp)>=f}function y(e,t){return e.state===`running`&&t-e.timestamp>=p}function b(e,t,n){if(e.progress){let t=`${e.progress.completed}/${e.progress.total}`;return e.action.includes(t)?``:` · ${t}`}return e.detail&&!e.action.includes(e.detail)?n.replace(/\{\{detail\}\}/g,e.detail):e.state===`running`?` · ${Math.max(1,Math.floor((t-e.timestamp)/1e3))}s`:``}function ee(e,t){if(e.state!==`success`||!e.publicSummary)return;let n=e.publicSummary.replace(/\s+/g,` `).trim(),r=n.length>_?`${n.slice(0,_-1)}…`:n;return t.replace(/\{\{summary\}\}/g,r)}function x(e,t,n){if(y(e,t))return n.stale;if(v(e,t))return n.longRunning}function S(e,t){let n=e.feedback?.reassurance;return n?t[n]:void 0}function C(e){let t=e.now-e.lastActivityAt,n=t>=m?(t-m)%g:1/0;return e.bubbleEnabled&&e.behaviorMode!==`focus`&&e.proactiveTipsEnabled&&(!e.remindersPausedUntil||e.now>=e.remindersPausedUntil)&&!e.collapsed&&e.queuedCount===0&&e.activeCount===0&&n<=h&&e.now>=e.dismissedUntil}function w(e,t,n){return e.state===`waiting`||e.state===`error`?`action_required`:e.state===`success`?t===`focus`?`ambient`:`notice`:y(e,n)||t===`playful`||t===`companion`&&v(e,n)?`notice`:`ambient`}function T(e,t,n,r){let i=w(e,t,n);return i===`action_required`?!0:r&&n<r?!1:i===`notice`}var E=8e3;function D(e,t){let n=e?.runId===t.runId,r=t.feedback?.sensitivity===`private`;return{...n?e:void 0,...t,startedAt:n?e.startedAt??e.timestamp:t.timestamp,publicSummary:r?void 0:t.publicSummary??(n?e.publicSummary:void 0),feedback:t.feedback??(n?e.feedback:void 0),expiresAt:t.state===`success`?t.timestamp+E:void 0}}function O(e,t){let n={...e};for(let e of t){let t=n[e.conversationId];t?.runId===e.runId&&e.sequence<=t.sequence||(n[e.conversationId]=D(t,e))}return n}function k(e,t){return t?.runId===e.runId&&t.state===e.state}function te(e,t){let n={error:0,waiting:1,running:2,success:3};return e.filter(e=>!e.expiresAt||e.expiresAt>t).sort((e,t)=>n[e.state]-n[t.state]||t.timestamp-e.timestamp).slice(0,3)}function ne(e){return e?`/chat/${e.conversationId}`:void 0}var A=r();function j(e){return e?e.state===`error`?`concern`:e.state===`success`?`success`:e.animation??c(e.phase):`idle`}function M(e,t){if(!e?.length)return;let n=t.sequence;for(let e of`${t.conversationId}:${t.runId}`)n=n*31+e.charCodeAt(0)>>>0;return e[n%e.length]}function N(e,t,n){let r=e.persona?.phrases??n;if(t.state===`success`)return M(r?.success,t);if(t.state===`waiting`)return M(r?.waiting,t);if(t.state===`error`)return M(r?.error,t)}function P(e,t,n){return e?n?`${e} · ${t}`:e:t}function F(e,t){let n=e.feedback?.nextAction?.type;if(n===`confirm`)return t.needsInput;if(n===`review_error`)return t.reviewIssue;if(n===`open_session`)return t.open;if(e.state===`waiting`)return t.needsInput;if(e.state===`error`)return t.reviewIssue;if(e.state===`success`)return t.open}function I(){let e=Date.now();return{prefs:{enabled:!0,showOnStartup:!1,selectedPetId:`loopi`,alwaysOnTop:!0,bubbleEnabled:!0,clickThroughWhenIdle:!1,muted:!1,behaviorMode:`companion`,proactiveTipsEnabled:!0,interactionEnabled:!0,reducedMotion:!1,sizePercent:100,collapsed:!1},relationship:{firstMetAt:e,lastSeenAt:e,completedTaskCount:0,unlockedReactions:[],recentCompletedRunIds:[]},pets:[],visible:!0,customPetsDir:``,petIssues:[],activities:[]}}function L(){let e=a(o(e=>e.language)).desktopPet,[t,n]=(0,u.useState)(I),[r,c]=(0,u.useState)({}),[d,f]=(0,u.useState)({}),[p,m]=(0,u.useState)(Date.now()),[h,_]=(0,u.useState)(()=>Date.now()),[v,y]=(0,u.useState)(0),[w,E]=(0,u.useState)(null),D=(0,u.useRef)(null),L=(0,u.useRef)(!1),R=(0,u.useRef)(null),z=(0,u.useRef)(null),B=(0,u.useRef)(null),V=(0,u.useMemo)(()=>t.pets.find(e=>e.id===t.prefs.selectedPetId)??t.pets[0],[t]),H=Math.min(1.4,Math.max(.7,t.prefs.sizePercent/100)),U=(0,u.useMemo)(()=>te(Object.values(r),p),[r,p]),W=(0,u.useMemo)(()=>t.prefs.bubbleEnabled?U.filter(e=>!k(e,d[e.conversationId])&&T(e,t.prefs.behaviorMode,p,t.prefs.remindersPausedUntil)):[],[U,d,p,t.prefs.behaviorMode,t.prefs.bubbleEnabled,t.prefs.remindersPausedUntil]),G=(0,u.useMemo)(()=>t.prefs.bubbleEnabled?U.filter(e=>k(e,d[e.conversationId])&&T(e,t.prefs.behaviorMode,p,t.prefs.remindersPausedUntil)).length:0,[U,d,p,t.prefs.behaviorMode,t.prefs.bubbleEnabled,t.prefs.remindersPausedUntil]),K=W[0]??U[0],q=p-h>20*6e4&&(new Date(p).getHours()>=23||new Date(p).getHours()<7)?`sleep`:`idle`,J=w??(K?j(K):q),Y=e.personaPhrases[V?.persona?.tone??`calm`],X=C({bubbleEnabled:t.prefs.bubbleEnabled,behaviorMode:t.prefs.behaviorMode,proactiveTipsEnabled:t.prefs.proactiveTipsEnabled,remindersPausedUntil:t.prefs.remindersPausedUntil,collapsed:t.prefs.collapsed,queuedCount:W.length,activeCount:U.length,now:p,lastActivityAt:h,dismissedUntil:v});(0,u.useEffect)(()=>{document.documentElement.dataset.desktopPet=`true`;let e=window.electronAPI?.pet;if(!e)return;let t=e=>{n(e),c(t=>O(t,e.activities))};e.getState().then(t).catch(()=>{});let r=e.onStateChanged(t),i=e.onEvent(e=>c(t=>(_(Date.now()),O(t,[e])))),a=window.setInterval(()=>m(Date.now()),1e3);return()=>{delete document.documentElement.dataset.desktopPet,r(),i(),window.clearInterval(a)}},[]),(0,u.useEffect)(()=>{if(!t.relationshipMoment)return;E(t.relationshipMoment===`first_meeting`?`wake`:`greet`);let e=window.setTimeout(()=>E(null),1400);return()=>window.clearTimeout(e)},[t.relationshipMoment]),(0,u.useLayoutEffect)(()=>{let e=R.current,t=window.electronAPI?.pet;if(!e||!t)return;let n=()=>{let e=[z.current,B.current].filter(e=>e!==null).map(e=>({left:e.offsetLeft,top:e.offsetTop,right:e.offsetLeft+e.offsetWidth,bottom:e.offsetTop+e.offsetHeight}));if(!e.length)return;let n=Math.min(...e.map(e=>e.left)),r=Math.min(...e.map(e=>e.top)),i=Math.max(...e.map(e=>e.right)),a=Math.max(...e.map(e=>e.bottom)),o=Math.round(132*H),s=o+(z.current?8+z.current.offsetHeight:0);t.setContentSize({width:Math.ceil(Math.max(i-n,o)),height:Math.ceil(Math.max(a-r,s))})},r=new ResizeObserver(n);return r.observe(e),z.current&&r.observe(z.current),B.current&&r.observe(B.current),n(),()=>r.disconnect()},[X,W.length,t.prefs.collapsed,H]);let Z=(e=K)=>{e&&e.state!==`running`&&(window.electronAPI?.pet?.acknowledgeEvent(e.conversationId,e.runId),c(t=>{let{[e.conversationId]:n,...r}=t;return r})),window.electronAPI?.pet?.openMainWindow(ne(e))},re=async()=>{if(Object.keys(d).length>0&&(f({}),!t.prefs.collapsed))return;let e=await window.electronAPI?.pet?.setPrefs({collapsed:!t.prefs.collapsed});e&&n(e)},ie=(0,u.useCallback)(e=>{e.button===0&&(D.current={pointerId:e.pointerId,x:e.screenX,y:e.screenY,moved:!1},e.currentTarget.setPointerCapture(e.pointerId),window.electronAPI?.pet?.startDrag({screenX:e.screenX,screenY:e.screenY}))},[]),ae=(0,u.useCallback)(e=>{let t=D.current;!t||t.pointerId!==e.pointerId||(t.moved||Math.abs(e.screenX-t.x)+Math.abs(e.screenY-t.y)>4)&&(t.moved=!0,E(`pickedUp`),window.electronAPI?.pet?.drag({screenX:e.screenX,screenY:e.screenY}))},[]),Q=(0,u.useCallback)(e=>{let t=D.current;if(!t||e&&t.pointerId!==e.pointerId)return;D.current=null;let n=e?.type===`pointerup`&&Number.isFinite(e.screenX)&&Number.isFinite(e.screenY),r=t.moved||n&&Math.abs(e.screenX-t.x)+Math.abs(e.screenY-t.y)>4;r&&n&&window.electronAPI?.pet?.drag({screenX:e.screenX,screenY:e.screenY}),window.electronAPI?.pet?.endDrag(),r&&(E(`released`),window.setTimeout(()=>E(null),700),L.current=!0,window.setTimeout(()=>{L.current=!1},0))},[]);(0,u.useEffect)(()=>{let e=e=>Q(e),t=()=>Q();return window.addEventListener(`pointerup`,e),window.addEventListener(`pointercancel`,e),window.addEventListener(`blur`,t),()=>{window.removeEventListener(`pointerup`,e),window.removeEventListener(`pointercancel`,e),window.removeEventListener(`blur`,t)}},[Q]);let oe=()=>{L.current||Z()};if(!V)return null;let se={"--desktop-pet-stage-size":`${Math.round(132*H)}px`,"--desktop-pet-menu-size":`${Math.round(28*H)}px`,"--desktop-pet-menu-left":`0px`,"--desktop-pet-menu-bottom":`${Math.round(12*H)}px`},$=t.prefs.collapsed?W.length:G;return(0,A.jsxs)(`div`,{ref:R,className:`desktop-pet-window`,"data-reduced-motion":t.prefs.reducedMotion,style:se,children:[!t.prefs.collapsed&&W.length>0?(0,A.jsx)(`div`,{ref:z,className:`desktop-pet-bubble desktop-pet-queue`,children:W.map(t=>{let n=x(t,p,{longRunning:e.tipLongRunning,stale:e.tipStaleSignal}),r=ee(t,e.tipCompleteSummary),a=S(t,{making_progress:e.petReassuranceMakingProgress,waiting_safely:e.petReassuranceWaitingSafely,completed:e.petReassuranceCompleted,work_preserved:e.petReassuranceWorkPreserved,details_available:e.petReassuranceDetailsAvailable}),o=r??n??a??t.action,s=P(N(V,t,Y),o,!!(r||n||a)),c=F(t,{open:e.viewSession,needsInput:e.petCtaNeedsInput,reviewIssue:e.petCtaReviewIssue});return(0,A.jsxs)(`div`,{className:`desktop-pet-session desktop-pet-session--${t.state}${n?` desktop-pet-session--health`:``}`,children:[(0,A.jsxs)(`button`,{type:`button`,className:`desktop-pet-session-open`,onClick:()=>Z(t),children:[(0,A.jsx)(`span`,{className:`desktop-pet-session-dot`}),(0,A.jsxs)(`span`,{className:`desktop-pet-session-main`,children:[(0,A.jsx)(`strong`,{children:t.sessionLabel}),(0,A.jsxs)(`span`,{children:[s,r||n?``:b(t,p,e.tipTargetSuffix)]})]}),c?(0,A.jsx)(`span`,{className:`desktop-pet-session-cta`,children:c}):null]}),(0,A.jsx)(`button`,{type:`button`,className:`desktop-pet-session-close`,"aria-label":e.dismissSession,onClick:()=>{window.electronAPI?.pet?.acknowledgeEvent(t.conversationId,t.runId),f(e=>({...e,[t.conversationId]:{runId:t.runId,state:t.state}}))},children:(0,A.jsx)(i,{size:12})})]},t.conversationId)})}):null,X?(0,A.jsx)(`div`,{ref:z,className:`desktop-pet-bubble desktop-pet-queue desktop-pet-idle-tip`,children:(0,A.jsxs)(`div`,{className:`desktop-pet-session desktop-pet-session--idle`,children:[(0,A.jsxs)(`button`,{type:`button`,className:`desktop-pet-session-open`,onClick:()=>Z(),children:[(0,A.jsx)(`span`,{className:`desktop-pet-session-dot`}),(0,A.jsxs)(`span`,{className:`desktop-pet-session-main`,children:[(0,A.jsx)(`strong`,{children:e.idleTipTitle}),(0,A.jsx)(`span`,{children:M(V.persona?.phrases?.greeting??Y.greeting,{conversationId:`idle`,runId:`idle`,sessionLabel:``,sequence:0,timestamp:h,state:`running`,phase:`waiting`,action:e.idleTipBody})??e.idleTipBody})]})]}),(0,A.jsx)(`button`,{type:`button`,className:`desktop-pet-session-close`,"aria-label":e.dismissSession,onClick:()=>y(p+g),children:(0,A.jsx)(i,{size:12})})]})}):null,(0,A.jsxs)(`div`,{ref:B,className:`desktop-pet-stage`,children:[(0,A.jsx)(`button`,{type:`button`,className:`desktop-pet-menu-button`,onClick:()=>void re(),"aria-label":e.menu,children:$>0?(0,A.jsx)(`span`,{className:`desktop-pet-tip-count`,children:Math.min(99,$)}):(0,A.jsx)(s,{className:`desktop-pet-menu-chevron size-4`})}),(0,A.jsx)(`button`,{type:`button`,className:`desktop-pet-hit-area`,onClick:oe,onPointerEnter:()=>{!K&&t.prefs.interactionEnabled&&t.prefs.behaviorMode===`playful`&&E(`greet`)},onPointerLeave:()=>{D.current||E(null)},onPointerDown:ie,onPointerMove:ae,onPointerUp:Q,onPointerCancel:Q,onLostPointerCapture:Q,title:e.openApp,children:(0,A.jsx)(l,{animationKey:K?.runId,pet:V,action:J,reducedMotion:t.prefs.reducedMotion,displayHeight:Math.round(112*H)},V.id)})]})]})}function R(){let e=(0,d.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,A.jsx)(L,{}),e[0]=t):t=e[0],t}export{R as DesktopPetPage};
@@ -1 +0,0 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{f as i}from"./chunk-KS7C4IRE-B2HK1psj.js";import{n as a,r as o}from"./popover-select-DGKUpVsz.js";import{t as s}from"./external-link-DjqjBmc3.js";import{t as c}from"./messages-D__oW2yE.js";import{t as l}from"./cn-0WouolD0.js";import{n as u}from"./locale-store-D_migb9R.js";import{t as d}from"./skeleton-BI5TyibZ.js";import{Iu as f,Nc as p,Ss as m,au as h,bu as g,do as _,if as v,sf as y,vl as b}from"./index-uAJlrGvo.js";import{t as x}from"./desktop-pet-sprite-Bd-aOI7N.js";import{n as S,r as C}from"./settings-page-layout-Dx5S-Msc.js";var w=n(),T=e(t(),1),E=r();function D(e){let t=(0,w.c)(16),{title:n,desc:r,checked:i,disabled:a,onChange:o}=e,s;t[0]===n?s=t[1]:(s=(0,E.jsx)(`span`,{className:`block text-sm font-medium text-fg`,children:n}),t[0]=n,t[1]=s);let c;t[2]===r?c=t[3]:(c=r?(0,E.jsx)(`span`,{className:`block text-xs text-fg-muted`,children:r}):null,t[2]=r,t[3]=c);let l;t[4]!==s||t[5]!==c?(l=(0,E.jsxs)(`span`,{className:`min-w-0`,children:[s,c]}),t[4]=s,t[5]=c,t[6]=l):l=t[6];let u;t[7]===o?u=t[8]:(u=e=>o(e.target.checked),t[7]=o,t[8]=u);let d;t[9]!==i||t[10]!==a||t[11]!==u?(d=(0,E.jsx)(`input`,{type:`checkbox`,role:`switch`,"aria-checked":i,className:`ui-checkbox`,disabled:a,checked:i,onChange:u}),t[9]=i,t[10]=a,t[11]=u,t[12]=d):d=t[12];let f;return t[13]!==l||t[14]!==d?(f=(0,E.jsxs)(`label`,{className:`flex min-h-12 cursor-pointer items-center justify-between gap-3 py-3`,children:[l,d]}),t[13]=l,t[14]=d,t[15]=f):f=t[15],f}function O(){let e=c(u(e=>e.language)).desktopPetSettings,t=i(),[n,r]=(0,T.useState)(null),[w,O]=(0,T.useState)(!1),[k,A]=(0,T.useState)(null),j=typeof window<`u`?window.electronAPI?.pet:void 0,M=(0,T.useMemo)(()=>n?.pets.find(e=>e.id===n.prefs.selectedPetId)??n?.pets[0],[n]),N=(0,T.useCallback)(async()=>{if(j){O(!0);try{r(await j.getState())}finally{O(!1)}}},[j]);if((0,T.useEffect)(()=>{if(j)return N(),j.onStateChanged(r)},[j,N]),!m()||!j)return null;if(!n)return(0,E.jsxs)(C,{gap:`gap-4`,children:[(0,E.jsx)(S,{title:e.title,subtitle:e.subtitle}),(0,E.jsx)(`section`,{className:`rounded-xl bg-surface-hover/20 p-4`,"aria-busy":!0,"aria-label":e.loading,children:(0,E.jsxs)(`div`,{className:`space-y-3`,children:[(0,E.jsx)(d,{className:`h-14 rounded-xl`}),(0,E.jsx)(d,{className:`h-14 rounded-xl`}),(0,E.jsx)(d,{className:`h-24 rounded-xl`}),(0,E.jsx)(`div`,{className:`space-y-2 pt-2`,children:Array.from({length:3}).map((e,t)=>(0,E.jsx)(d,{className:`h-16 rounded-xl`},t))})]})})]});let P=async e=>{O(!0);try{r(await j.setPrefs(e))}finally{O(!1)}},F=async e=>{e?(await j.show(),r(await j.getState())):r(await j.setPrefs({enabled:!1}))},I=e=>{P({selectedPetId:e})},L=t=>{if(t.builtin&&t.i18nKey){let n=e.builtinPets[t.i18nKey];if(n)return n}return{name:t.name,description:t.description}},R=e=>{t({pathname:`/chat/new`,search:`?draft=${encodeURIComponent(e)}`})},z=e=>{if(e.sourcePrompt?.trim())return e.sourcePrompt.trim();let{description:t}=L(e);return t.replace(/^Custom pet generated from:\s*/i,``).trim()||t},B=(e,t)=>Object.entries(t).reduce((e,[t,n])=>e.split(`{${t}}`).join(n),e),V=()=>{R(e.createChatDraft)},H=t=>{R(B(e.optimizeChatDraft,{id:t.id,name:L(t).name,description:L(t).description,sourcePrompt:z(t)}))},U=t=>{R(B(e.fixChatDraft,{dir:t.dir,reason:t.reason,details:t.details?.join(`; `)||e.noIssueDetails}))},W=k??n.prefs.sizePercent,G=Math.max(1,Math.floor((Date.now()-n.relationship.firstMetAt)/864e5)+1),K=async(e=W)=>{let t=Math.min(140,Math.max(70,Math.round(e/5)*5));A(null),t!==n.prefs.sizePercent&&await P({sizePercent:t})};return(0,E.jsxs)(C,{gap:`gap-5`,children:[(0,E.jsx)(S,{title:e.title,subtitle:e.subtitle,actions:(0,E.jsx)(_,{className:`size-9 shrink-0 p-0`,disabled:w,label:e.refresh,onClick:N})}),(0,E.jsxs)(`section`,{className:`overflow-hidden rounded-xl border border-edge bg-surface-panel`,children:[(0,E.jsxs)(`div`,{className:`flex flex-col gap-4 p-5 sm:flex-row sm:items-center sm:gap-6`,children:[(0,E.jsx)(`div`,{className:`grid h-40 w-40 shrink-0 place-items-center self-center rounded-xl bg-surface-hover/35`,children:M?(0,E.jsx)(x,{pet:M,action:`idle`,displayHeight:Math.round(104*W/100),reducedMotion:n.prefs.reducedMotion}):null}),(0,E.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,E.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-x-6 gap-y-2`,children:[(0,E.jsx)(`h2`,{className:`break-words text-xl font-semibold text-fg`,children:M?L(M).name:e.title}),(0,E.jsx)(D,{title:e.enable,checked:n.prefs.enabled,disabled:w,onChange:e=>void F(e)})]}),(0,E.jsx)(`p`,{className:`text-xs text-fg-muted`,children:e.bondSummary.replace(`{days}`,String(G)).replace(`{tasks}`,String(n.relationship.completedTaskCount))}),n.pets.length>1?(0,E.jsx)(`div`,{className:`mt-4 max-w-56`,children:(0,E.jsx)(a,{"aria-label":e.petList,value:M?.id??``,onChange:e=>I(e.target.value),disabled:w,children:n.pets.map(e=>(0,E.jsx)(o,{value:e.id,children:L(e).name},e.id))})}):null,M&&!M.builtin?(0,E.jsxs)(`button`,{type:`button`,onClick:()=>H(M),className:`mt-3 inline-flex min-h-9 items-center gap-1.5 text-xs font-medium text-fg-muted hover:text-fg`,children:[(0,E.jsx)(g,{className:`size-3.5`}),e.optimizeInChat]}):null]})]}),(0,E.jsx)(`div`,{className:`border-t border-edge px-5 py-2`,children:(0,E.jsxs)(`button`,{type:`button`,onClick:V,className:l(`inline-flex min-h-10 items-center gap-2 text-xs font-medium text-fg-muted hover:text-accent-fg`,p.press),children:[(0,E.jsx)(b,{className:`size-4`}),e.createTitle]})})]}),n.petIssues.length>0?(0,E.jsxs)(`section`,{className:`rounded-xl border border-danger/20 bg-danger/5 p-4`,children:[(0,E.jsxs)(`h3`,{className:`flex items-center gap-2 text-sm font-medium text-danger`,children:[(0,E.jsx)(v,{className:`size-4`}),e.invalidPets]}),(0,E.jsx)(`div`,{className:`mt-3 space-y-3`,children:n.petIssues.map(t=>(0,E.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-start sm:justify-between`,children:[(0,E.jsxs)(`div`,{className:`min-w-0 text-xs text-fg-muted`,children:[(0,E.jsx)(`p`,{className:`break-words`,children:t.reason}),(0,E.jsxs)(`details`,{className:`mt-1`,children:[(0,E.jsx)(`summary`,{className:`cursor-pointer`,children:e.issueDetails}),(0,E.jsx)(`p`,{className:`mt-2 break-all font-mono`,children:t.dir}),t.details?.length?(0,E.jsx)(`p`,{className:`mt-1 break-words`,children:t.details.join(`; `)}):null]})]}),(0,E.jsxs)(`button`,{type:`button`,onClick:()=>U(t),className:`inline-flex min-h-9 shrink-0 items-center gap-1.5 text-xs font-medium text-danger`,children:[(0,E.jsx)(f,{className:`size-3.5`}),e.fixInChat]})]},`${t.dir}-${t.reason}`))})]}):null,(0,E.jsxs)(`section`,{"aria-label":e.displayGroup,children:[(0,E.jsx)(`h3`,{className:`mb-2 text-xs font-medium text-fg-muted`,children:e.displayGroup}),(0,E.jsxs)(`div`,{className:`divide-y divide-edge rounded-xl border border-edge bg-surface-panel px-4`,children:[(0,E.jsx)(D,{title:e.showOnStartup,checked:n.prefs.showOnStartup,disabled:w,onChange:e=>void P({showOnStartup:e})}),(0,E.jsx)(D,{title:e.alwaysOnTop,checked:n.prefs.alwaysOnTop,disabled:w,onChange:e=>void P({alwaysOnTop:e})}),(0,E.jsx)(D,{title:e.bubbles,checked:n.prefs.bubbleEnabled,disabled:w,onChange:e=>void P({bubbleEnabled:e})}),(0,E.jsxs)(`div`,{className:`py-3`,children:[(0,E.jsxs)(`label`,{htmlFor:`desktop-pet-size`,className:`flex items-center justify-between gap-3 text-sm font-medium text-fg`,children:[e.size,(0,E.jsxs)(`span`,{className:`text-xs tabular-nums text-fg-muted`,children:[W,`%`]})]}),(0,E.jsx)(`input`,{id:`desktop-pet-size`,type:`range`,min:70,max:140,step:5,className:`mt-3 w-full accent-accent`,value:W,disabled:w,onChange:e=>A(Number(e.target.value)),onBlur:()=>void K(),onKeyUp:e=>{(e.key===`Enter`||e.key===` `||e.key.startsWith(`Arrow`))&&K()},onPointerUp:()=>void K()})]})]})]}),(0,E.jsxs)(`section`,{"aria-label":e.interactionGroup,children:[(0,E.jsx)(`h3`,{className:`mb-2 text-xs font-medium text-fg-muted`,children:e.interactionGroup}),(0,E.jsxs)(`div`,{className:`divide-y divide-edge rounded-xl border border-edge bg-surface-panel px-4`,children:[(0,E.jsx)(D,{title:e.proactiveTips,checked:n.prefs.proactiveTipsEnabled,disabled:w,onChange:e=>void P({proactiveTipsEnabled:e})}),(0,E.jsx)(D,{title:e.interactions,desc:e.interactionsDesc,checked:n.prefs.interactionEnabled,disabled:w,onChange:e=>void P({interactionEnabled:e})}),(0,E.jsx)(D,{title:e.reducedMotion,checked:n.prefs.reducedMotion,disabled:w,onChange:e=>void P({reducedMotion:e})}),(0,E.jsxs)(`div`,{className:`flex min-h-12 flex-wrap items-center justify-between gap-3 py-3`,children:[(0,E.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:e.behaviorMode}),(0,E.jsxs)(a,{"aria-label":e.behaviorMode,className:`w-36`,triggerClassName:`h-9 bg-surface-panel`,value:n.prefs.behaviorMode,disabled:w,onChange:e=>void P({behaviorMode:e.target.value}),children:[(0,E.jsx)(o,{value:`focus`,children:e.behaviorFocus}),(0,E.jsx)(o,{value:`companion`,children:e.behaviorCompanion}),(0,E.jsx)(o,{value:`playful`,children:e.behaviorPlayful})]})]})]})]}),(0,E.jsxs)(`details`,{className:`group rounded-xl border border-edge bg-surface-panel`,children:[(0,E.jsxs)(`summary`,{className:`flex min-h-12 cursor-pointer list-none items-center justify-between gap-3 px-4 text-sm font-medium text-fg [&::-webkit-details-marker]:hidden`,children:[e.advanced,(0,E.jsx)(y,{className:`size-4 text-fg-muted transition-transform group-open:rotate-180`})]}),(0,E.jsxs)(`div`,{className:`space-y-3 border-t border-edge px-4 pb-4`,children:[(0,E.jsx)(D,{title:e.clickThrough,desc:e.clickThroughDesc,checked:n.prefs.clickThroughWhenIdle,disabled:w,onChange:e=>void P({clickThroughWhenIdle:e})}),(0,E.jsxs)(`div`,{className:`flex flex-col gap-2 border-t border-edge pt-4 sm:flex-row sm:items-center sm:justify-between`,children:[(0,E.jsxs)(`div`,{className:`min-w-0`,children:[(0,E.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:e.customPets}),(0,E.jsx)(`p`,{className:`mt-1 break-all font-mono text-xs text-fg-muted`,children:n.customPetsDir})]}),(0,E.jsxs)(`button`,{type:`button`,onClick:()=>void j.openCustomPetsDir(),className:`inline-flex min-h-10 shrink-0 items-center gap-1.5 text-xs font-medium text-fg-muted hover:text-fg`,children:[(0,E.jsx)(s,{className:`size-3.5`}),e.openFolder]})]}),(0,E.jsxs)(`button`,{type:`button`,className:l(`inline-flex min-h-10 items-center gap-1.5 text-xs font-medium text-fg-muted hover:text-fg disabled:opacity-50`,p.press),disabled:w,onClick:()=>void j.resetPosition().then(r),children:[(0,E.jsx)(h,{className:`size-3.5`}),e.resetPosition]})]})]})]})}export{O as DesktopPetSettings};
@@ -1 +0,0 @@
1
- import{i as e,n as t}from"./rolldown-runtime-aKtaBQYM.js";import{a as n,n as r,t as i}from"./vendor-react-BOUWij0V.js";import{f as a}from"./chunk-KS7C4IRE-B2HK1psj.js";import{t as o}from"./circle-check-C23XjkUj.js";import{t as s}from"./download-Dk-ZjtO6.js";import{t as c}from"./external-link-DjqjBmc3.js";import{t as l}from"./x-B_N4OPjy.js";import{t as u}from"./messages-D__oW2yE.js";import{t as d}from"./cn-0WouolD0.js";import{n as f}from"./locale-store-D_migb9R.js";import{a as p,i as m,o as h,r as g,s as _,t as v}from"./dist-BGTk37IG.js";import{n as y}from"./app-link-BV_eGr7l.js";import{i as b}from"./vendor-swr-BIWyz7Rc.js";import{t as x}from"./button-aIC072nz.js";import{t as S}from"./skeleton-BI5TyibZ.js";import{i as C,o as w}from"./settings-shell-dialog-layer-BU3UuiJr.js";import{$t as T,Cu as E,F as D,I as O,Ka as k,Kd as A,L as j,Wl as M,af as N,as as P,en as F,nn as I,ot as L,rd as ee}from"./index-uAJlrGvo.js";import{_ as te,a as ne,d as re,f as ie,g as ae,h as oe,i as R,l as z,m as se,n as B,p as ce,r as V,s as H,t as le,u as U,v as ue}from"./tunnel-api-DcDUSAjv.js";var W=e(n(),1),G=r(),K=e(L(),1),q={width:240,margin:4,errorCorrectionLevel:`M`,color:{dark:`#000000ff`,light:`#ffffffff`}};async function de(e){let t=await K.toString(e,{...q,type:`svg`});return`data:image/svg+xml;charset=utf-8,${encodeURIComponent(t)}`}var J=i();function fe(){let e=u(f(e=>e.language)),t=e.endpointToolsSettings.deviceAccess.flow,n=e.tunnelSettings,{data:r,error:i,mutate:a}=b(`tunnel-status`,B,{refreshInterval:1500}),[o,s]=(0,W.useState)(!1),[l,d]=(0,W.useState)(!1),[p,m]=(0,W.useState)(!0),[h,g]=(0,W.useState)(`idle`),[_,v]=(0,W.useState)(null),[C,w]=(0,W.useState)(``),E=(0,W.useRef)(!0);(0,W.useEffect)(()=>(E.current=!0,()=>{E.current=!1}),[]);let k=async()=>{if(!r)return;if(r.consentRequired&&!o){d(!0);return}let e=r.registrationSecret?.configured?null:j(),t,n=!1;v(null);try{if(r.consentRequired&&await ne(),!r.registrationSecret?.configured){g(`provisioning`);let r=!1;try{await R()}catch(e){if(!U(e))throw e;r=!0}if(r){g(`authorizing`);let r=sessionStorage.getItem(`device-pairing-oauth`),i=r?JSON.parse(r):null;t=i&&i.expiresAt>Date.now()?i.sessionId:(await I(`xopc-tunnel`)).sessionId,sessionStorage.setItem(`device-pairing-oauth`,JSON.stringify({sessionId:t,expiresAt:i&&i.expiresAt>Date.now()?i.expiresAt:Date.now()+5*6e4}));let a=``,o=Date.now()+5*6e4,s=!1;for(;E.current&&Date.now()<o;){let r=await F(t);if(r.authUrl&&r.authUrl!==a&&(a=r.authUrl,await O(a,e)||w(a)),r.status===`completed`){s=!0,n=!0;break}if(r.status===`failed`||r.status===`cancelled`)throw Error(`Authorization cancelled`);await new Promise(e=>setTimeout(e,1e3))}if(!E.current)return;if(!s)throw Error(`Authorization expired`);await R()}await a()}if(!E.current)return;g(`starting`),await H(),p&&await V({autoStart:!0}),await a(),n=!0}catch(e){n=!0,E.current&&v(z(e)===`tunnel_key_limit_reached`?`key-limit`:`failed`)}finally{D(e),n&&(sessionStorage.removeItem(`device-pairing-oauth`),t&&T(t).catch(()=>{})),E.current&&(g(`idle`),w(``))}};if(!r&&!i)return(0,J.jsxs)(`div`,{className:`space-y-5`,children:[(0,J.jsx)(S,{className:`h-5 w-4/5`}),(0,J.jsx)(S,{className:`h-24 w-full`})]});let A=h===`provisioning`||h===`starting`||r?.state===`connecting`||r?.state===`reconnecting`;return(0,J.jsxs)(`div`,{className:`flex min-h-full flex-col`,children:[(0,J.jsx)(`p`,{className:`text-sm leading-relaxed text-fg-muted`,children:A?t.preparingHint:h===`authorizing`?t.authorizing:t.enableHint}),C&&h===`authorizing`?(0,J.jsx)(`a`,{href:C,target:`_blank`,rel:`noopener noreferrer`,className:`mt-4 inline-flex min-h-11 items-center text-sm text-accent`,children:t.openAuthorization}):null,A?(0,J.jsxs)(`div`,{className:`mt-8 space-y-3`,"aria-label":t.preparing,children:[(0,J.jsx)(S,{className:`h-2 w-full`}),(0,J.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.preparing})]}):null,(l||r?.consentRequired)&&h===`idle`?(0,J.jsxs)(`div`,{className:`mt-6 space-y-4`,children:[(0,J.jsxs)(`details`,{open:l,className:`text-sm text-fg-muted`,children:[(0,J.jsx)(`summary`,{className:`cursor-pointer py-2`,children:t.details}),(0,J.jsx)(`p`,{className:`mt-2`,children:n.consentIntro}),(0,J.jsx)(`ul`,{className:`mt-3 list-disc space-y-2 pl-5`,children:[n.consentBullet1,n.consentBullet2,n.consentBullet3].map(e=>(0,J.jsx)(`li`,{children:e},e))})]}),(0,J.jsxs)(`label`,{className:`flex items-start gap-3 text-sm text-fg`,children:[(0,J.jsx)(`input`,{type:`checkbox`,checked:o,onChange:e=>s(e.target.checked),className:`mt-1 size-4 accent-accent`}),n.consentCheckbox]})]}):null,_===`key-limit`?(0,J.jsxs)(`div`,{role:`alert`,className:`mt-4 rounded-lg border border-warning/30 bg-warning/5 p-4`,children:[(0,J.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:t.routeKeyLimitTitle}),(0,J.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:t.routeKeyLimitHint}),(0,J.jsxs)(x,{variant:`secondary`,className:`mt-3`,onClick:()=>void y(le),children:[t.manageTunnelKeys,(0,J.jsx)(c,{className:`size-3`})]})]}):_||i||r?.state===`error`?(0,J.jsx)(`p`,{role:`alert`,className:`mt-4 text-sm text-danger`,children:t.routeSetupFailed}):null,(0,J.jsx)(`div`,{className:`flex-1`}),(0,J.jsxs)(`label`,{className:`my-5 flex items-center gap-3 text-sm text-fg-muted`,children:[(0,J.jsx)(`input`,{type:`checkbox`,checked:p,disabled:h!==`idle`,onChange:e=>m(e.target.checked),className:`size-4 accent-accent`}),t.autoStart]}),(0,J.jsx)(x,{className:`w-full`,variant:`primary`,disabled:!r||h!==`idle`||A||l&&!o,onClick:()=>void k(),children:h===`authorizing`?t.authorizing:A?t.preparing:_?t.retry:t.enable}),i&&!r?(0,J.jsx)(x,{variant:`ghost`,onClick:()=>void a(),children:t.retry}):null]})}var Y=t({DevicePairingWizard:()=>X});function X(e){let t=(0,G.c)(16),{open:n,onOpenChange:r,onPaired:i,targetKind:o}=e,s=a(),[c,l]=(0,W.useState)(o),u,d;t[0]===o?(u=t[1],d=t[2]):(u=()=>{l(o)},d=[o],t[0]=o,t[1]=u,t[2]=d),(0,W.useEffect)(u,d);let f;t[3]!==r||t[4]!==o?(f=e=>{e||l(o),r(e)},t[3]=r,t[4]=o,t[5]=f):f=t[5];let p=f,m;t[6]!==p||t[7]!==s||t[8]!==i||t[9]!==n||t[10]!==c?(m=n?c?(0,J.jsx)(he,{targetKind:c,onClose:()=>p(!1),onPaired:i}):(0,J.jsx)(pe,{onChoose:l,onChooseLocalBrowser:()=>{p(!1),s(`/settings/agent-browser?driver=extension`)},onClose:()=>p(!1)}):null,t[6]=p,t[7]=s,t[8]=i,t[9]=n,t[10]=c,t[11]=m):m=t[11];let h;return t[12]!==p||t[13]!==n||t[14]!==m?(h=(0,J.jsx)(v,{open:n,onOpenChange:p,children:m}),t[12]=p,t[13]=n,t[14]=m,t[15]=h):h=t[15],h}function Z(e){let t=(0,G.c)(14),{icon:n,title:r,hint:i,onClick:a}=e,o;t[0]===n?o=t[1]:(o=(0,J.jsx)(`span`,{className:`flex size-10 shrink-0 items-center justify-center rounded-xl bg-accent-soft text-accent-fg`,children:(0,J.jsx)(n,{className:`size-5`,"aria-hidden":`true`})}),t[0]=n,t[1]=o);let s;t[2]===r?s=t[3]:(s=(0,J.jsx)(`span`,{className:`block text-sm font-semibold text-fg`,children:r}),t[2]=r,t[3]=s);let c;t[4]===i?c=t[5]:(c=(0,J.jsx)(`span`,{className:`mt-0.5 block text-xs leading-5 text-fg-muted`,children:i}),t[4]=i,t[5]=c);let l;t[6]!==s||t[7]!==c?(l=(0,J.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[s,c]}),t[6]=s,t[7]=c,t[8]=l):l=t[8];let u;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,J.jsx)(N,{className:`size-4 shrink-0 text-fg-disabled transition-transform group-hover:translate-x-0.5 group-hover:text-fg-muted`,"aria-hidden":`true`}),t[9]=u):u=t[9];let d;return t[10]!==a||t[11]!==o||t[12]!==l?(d=(0,J.jsxs)(`button`,{type:`button`,className:`group flex min-h-18 w-full cursor-pointer items-center gap-4 rounded-xl border border-edge bg-surface-panel px-4 py-3.5 text-left shadow-surface transition-[background-color,border-color,box-shadow,transform] hover:border-edge-strong hover:bg-surface-active hover:shadow-elevated active:translate-y-px active:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-panel motion-reduce:active:translate-y-0`,onClick:a,children:[o,l,u]}),t[10]=a,t[11]=o,t[12]=l,t[13]=d):d=t[13],d}function pe(e){let t=(0,G.c)(40),{onChoose:n,onChooseLocalBrowser:r,onClose:i}=e,a=f(me),o;t[0]===a?o=t[1]:(o=u(a),t[0]=a,t[1]=o);let s=o.endpointToolsSettings.deviceAccess,c;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,J.jsx)(p,{className:d(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,w)}),t[2]=c):c=t[2];let v;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(v=d(`xopc-dialog-content fixed left-1/2 top-1/2 flex h-[min(28rem,calc(100dvh-2rem))] w-[min(40rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-overlay`,C),t[3]=v):v=t[3];let y;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,J.jsx)(`span`,{className:`text-lg font-semibold tracking-tight text-fg`,children:`xopc`}),t[4]=y):y=t[4];let b;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,J.jsx)(l,{className:`size-4`}),t[5]=b):b=t[5];let x;t[6]!==s.cancel||t[7]!==i?(x=(0,J.jsxs)(`header`,{className:`flex shrink-0 items-center justify-between border-b border-edge-subtle px-6 py-3`,children:[y,(0,J.jsx)(`button`,{type:`button`,className:`flex size-10 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover`,"aria-label":s.cancel,onClick:i,children:b})]}),t[6]=s.cancel,t[7]=i,t[8]=x):x=t[8];let S;t[9]===s.chooseTitle?S=t[10]:(S=(0,J.jsx)(_,{className:`text-lg font-semibold tracking-tight text-fg sm:text-xl`,children:s.chooseTitle}),t[9]=s.chooseTitle,t[10]=S);let T;t[11]===s.chooseHint?T=t[12]:(T=(0,J.jsx)(m,{className:`mt-1.5 text-sm leading-6 text-fg-muted`,children:s.chooseHint}),t[11]=s.chooseHint,t[12]=T);let D;t[13]!==s.localBrowserHint||t[14]!==s.localBrowserTitle||t[15]!==r?(D=(0,J.jsx)(Z,{icon:ee,title:s.localBrowserTitle,hint:s.localBrowserHint,onClick:r}),t[13]=s.localBrowserHint,t[14]=s.localBrowserTitle,t[15]=r,t[16]=D):D=t[16];let O;t[17]===n?O=t[18]:(O=()=>n(`mobile`),t[17]=n,t[18]=O);let k;t[19]!==s.mobileHint||t[20]!==s.mobileTitle||t[21]!==O?(k=(0,J.jsx)(Z,{icon:M,title:s.mobileTitle,hint:s.mobileHint,onClick:O}),t[19]=s.mobileHint,t[20]=s.mobileTitle,t[21]=O,t[22]=k):k=t[22];let A;t[23]===n?A=t[24]:(A=()=>n(`browser`),t[23]=n,t[24]=A);let j;t[25]!==s.remoteBrowserHint||t[26]!==s.remoteBrowserTitle||t[27]!==A?(j=(0,J.jsx)(Z,{icon:E,title:s.remoteBrowserTitle,hint:s.remoteBrowserHint,onClick:A}),t[25]=s.remoteBrowserHint,t[26]=s.remoteBrowserTitle,t[27]=A,t[28]=j):j=t[28];let N;t[29]!==k||t[30]!==j||t[31]!==D?(N=(0,J.jsxs)(`div`,{className:`mt-5 flex flex-col gap-2.5`,children:[D,k,j]}),t[29]=k,t[30]=j,t[31]=D,t[32]=N):N=t[32];let P;t[33]!==N||t[34]!==S||t[35]!==T?(P=(0,J.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-5 py-6 sm:px-8`,children:[S,T,N]}),t[33]=N,t[34]=S,t[35]=T,t[36]=P):P=t[36];let F;return t[37]!==P||t[38]!==x?(F=(0,J.jsxs)(h,{children:[c,(0,J.jsxs)(g,{className:v,children:[x,P]})]}),t[37]=P,t[38]=x,t[39]=F):F=t[39],F}function me(e){return e.language}function he({targetKind:e,onClose:t,onPaired:n}){let r=f(e=>e.language),i=u(r),a=i.endpointToolsSettings.deviceAccess,v=a.flow,[T,E]=(0,W.useState)(!1),D=b(T?`device-pairing-readiness`:null,oe,{refreshInterval:1500}),[O,j]=(0,W.useState)(),[M,F]=(0,W.useState)(null),[I,L]=(0,W.useState)(!1),[ee,ne]=(0,W.useState)(Date.now()),[R,z]=(0,W.useState)(null),B=(0,W.useRef)(!0),V=(0,W.useRef)(null),H=(0,W.useRef)(!1),le=(0,W.useRef)(!1),U=b(O?[`device-pairing-setup`,O.id]:null,()=>ae(O.id),{refreshInterval:1500}),G=U.data?.request,K=G?.status===`completed`,q=K&&G.connectedAt!==void 0,Y=b(q&&window.electronAPI?.system?`system-behavior`:null,()=>window.electronAPI.system.getBehavior()),X=O?.targetKind===`mobile`?O.universalLink:``,Z=P(()=>de(X),[X],{enabled:!!X,initial:null,errorData:null}),pe=r===`zh`?`https://xopc.ai/zh#download`:`https://xopc.ai/en#download`,me=r===`zh`?`https://xopcai.github.io/xopc/zh/browser-extension`:`https://xopcai.github.io/xopc/browser-extension`,he=P(()=>de(pe),[pe],{enabled:!T&&e===`mobile`,initial:null,errorData:null});(0,W.useEffect)(()=>{B.current=!0;let e=setInterval(()=>ne(Date.now()),1e3);return()=>{B.current=!1,clearInterval(e),V.current&&re(V.current).catch(()=>{})}},[]);let ge=(0,W.useCallback)(async()=>{if(!H.current){H.current=!0,L(!0),F(null);try{V.current&&await re(V.current),V.current=null,j(void 0);let t=await ie(e);if(t.kind===`ready`){if(!B.current){await re(t.setup.id);return}V.current=t.setup.id,j(t.setup)}else await D.mutate()}catch{B.current&&F(`create`)}finally{H.current=!1,B.current&&L(!1)}}},[D,e]);(0,W.useEffect)(()=>{D.data?.ready&&!O&&M!==`create`&&!H.current&&ge()},[D.data,O,M,ge]),(0,W.useEffect)(()=>{q&&!le.current&&(le.current=!0,n?.())},[q,n]);let _e=async e=>{if(G){L(!0),F(null);try{await ce(G,e),await U.mutate()}catch{F(`decision`),await U.mutate()}finally{B.current&&L(!1)}}},ve=(0,W.useRef)(0);(0,W.useEffect)(()=>{U.data&&(ve.current=U.data.serverTime-Date.now())},[U.data]);let Q=ee+ve.current,ye=O&&Q>=O.expiresAt&&!G,be=G&&[`expired`,`rejected`,`cancelled`].includes(G.status),xe=O?O.expiresAt-Q<6e4:!1,Se=O?xe?`${Math.max(0,Math.ceil((O.expiresAt-Q)/1e3))}s`:v.valid:``,$=e===`mobile`?{connect:a.mobileScan,connectHint:a.mobileScanHint,allowTitle:a.mobileAllowTitle,success:a.mobileSuccess,successHint:a.mobileSuccessHint}:{connect:a.browserConnect,connectHint:a.browserConnectHint,allowTitle:a.browserAllowTitle,success:a.browserSuccess,successHint:a.browserSuccessHint},Ce=e===`mobile`?a.mobilePrepareTitle:a.browserPrepareTitle,we=e===`mobile`?a.mobilePrepareHint:a.browserPrepareHint,Te=T?q?$.success:G?.status===`pending`?$.allowTitle:K||G?.status===`approved`?v.waiting:O?$.connect:v.title:Ce,Ee=M===`create`?v.createFailed:M===`decision`?v.decisionFailed:M===`background`?v.backgroundFailed:M===`download`?a.browserDownloadFailed:null,De=async()=>{L(!0),F(null);try{await se()}catch{F(`download`)}finally{B.current&&L(!1)}};return(0,J.jsxs)(h,{children:[(0,J.jsx)(p,{className:d(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,w)}),(0,J.jsxs)(g,{className:d(`xopc-dialog-content fixed left-1/2 top-1/2 flex h-[min(600px,calc(100dvh-48px))] w-[min(560px,calc(100vw-32px))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-overlay`,C),children:[(0,J.jsxs)(`header`,{className:`flex shrink-0 items-center justify-between border-b border-edge-subtle px-6 py-3`,children:[(0,J.jsx)(`span`,{className:`text-lg font-semibold tracking-tight text-fg`,children:`xopc`}),(0,J.jsx)(`button`,{type:`button`,className:`flex size-10 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover`,"aria-label":v.cancel,onClick:t,children:(0,J.jsx)(l,{className:`size-4`})})]}),(0,J.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-y-auto px-8 py-7`,children:[q?(0,J.jsx)(o,{className:`mb-5 size-7 text-success`}):null,(0,J.jsx)(_,{className:`text-xl font-semibold tracking-tight text-fg`,children:Te}),(0,J.jsx)(m,{className:`mt-2 text-sm leading-relaxed text-fg-muted`,children:T?q?$.successHint:K?v.waitingForDevice:G?G.displayName:O?$.connectHint:v.intro:we}),Ee?(0,J.jsx)(`p`,{role:`alert`,className:`mt-4 text-sm text-danger`,children:Ee}):null,T&&D.error?(0,J.jsx)(`p`,{role:`alert`,className:`mt-4 text-sm text-danger`,children:v.readinessFailed}):null,T&&U.error?(0,J.jsx)(`p`,{role:`status`,className:`mt-4 text-sm text-warning`,children:v.statusUnavailable}):null,T?D.data?q?(0,J.jsxs)(J.Fragment,{children:[Y.data?(0,J.jsxs)(`label`,{className:`mt-8 flex items-center justify-between gap-4 border-y border-edge-subtle py-5 text-sm text-fg`,children:[a.background,(0,J.jsx)(`input`,{type:`checkbox`,role:`switch`,"aria-checked":Y.data.runInBackground??!1,disabled:!Y.data.backgroundSupported,checked:Y.data.runInBackground??!1,className:`size-5 accent-accent`,onChange:e=>{window.electronAPI.system.setBehavior({runInBackground:e.target.checked}).then(e=>Y.mutate(e.behavior)).catch(()=>F(`background`))}})]}):null,(0,J.jsx)(`p`,{className:`mt-4 text-xs text-fg-muted`,children:a.sleep})]}):be||ye?(0,J.jsxs)(`div`,{className:`mt-10 space-y-5`,children:[(0,J.jsx)(`p`,{className:`text-sm text-fg-muted`,children:ye||G?.status===`expired`?v.expired:v.declined}),(0,J.jsx)(x,{variant:`primary`,onClick:()=>void ge(),disabled:I,children:v.refresh})]}):G?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`p`,{className:`mt-2 text-xs text-fg-muted`,children:v.scope}),(0,J.jsxs)(`p`,{className:`mt-10 font-mono text-4xl tracking-[0.16em] text-fg`,"aria-live":`polite`,children:[G.confirmationCode.slice(0,3),` `,G.confirmationCode.slice(3)]}),(0,J.jsx)(`p`,{className:`mt-3 text-xs text-fg-muted`,children:v.compare}),(0,J.jsxs)(`details`,{className:`mt-6 text-xs text-fg-muted`,children:[(0,J.jsx)(`summary`,{className:`cursor-pointer py-2`,children:v.access}),(0,J.jsx)(`p`,{children:v.accessHint})]})]}):O?.targetKind===`mobile`?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`div`,{className:`my-6 flex flex-col items-center`,children:[(0,J.jsx)(`div`,{className:`rounded-[1.75rem] border border-edge bg-surface-hover/55 p-2.5 shadow-surface`,children:(0,J.jsx)(`div`,{className:`rounded-[1.25rem] bg-white p-2 shadow-sm ring-1 ring-black/5`,children:Z.data?(0,J.jsx)(`img`,{src:Z.data,alt:a.qrAlt,width:240,height:240,className:`size-[240px] max-w-full rounded-xl bg-white`}):Z.error?null:(0,J.jsx)(S,{className:`size-[240px] rounded-xl`})})}),Z.error?null:(0,J.jsxs)(`p`,{className:d(`mt-4 inline-flex min-h-8 items-center gap-1.5 rounded-full px-3 text-xs font-medium`,xe?`bg-warning-soft text-warning`:`bg-surface-hover text-fg-muted`),"aria-live":`polite`,children:[(0,J.jsx)(A,{className:`size-3.5`,"aria-hidden":`true`}),Se]})]}),Z.error?(0,J.jsx)(`p`,{role:`status`,className:`text-center text-sm text-warning`,children:v.qrFailed}):null,Z.error?(0,J.jsx)(`div`,{className:`mt-5`,children:(0,J.jsx)(k,{text:O.universalLink,labels:{copy:a.copy,copied:a.copied,copyFailed:i.clipboard.copyFailed}})}):(0,J.jsxs)(`details`,{className:`group mx-auto mt-1 w-full max-w-sm rounded-xl border border-edge bg-surface-panel text-xs text-fg-muted`,children:[(0,J.jsxs)(`summary`,{className:`flex min-h-11 cursor-pointer list-none items-center justify-between gap-3 rounded-xl px-3.5 transition-colors hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent [&::-webkit-details-marker]:hidden`,children:[(0,J.jsx)(`span`,{children:v.fallback}),(0,J.jsx)(N,{className:`size-3.5 shrink-0 transition-transform group-open:rotate-90`,"aria-hidden":`true`})]}),(0,J.jsx)(`div`,{className:`border-t border-edge-subtle p-3`,children:(0,J.jsx)(k,{text:O.universalLink,labels:{copy:a.copy,copied:a.copied,copyFailed:i.clipboard.copyFailed}})})]})]}):O?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`ol`,{className:`mt-7 space-y-2 text-sm leading-6 text-fg-muted`,children:[(0,J.jsxs)(`li`,{children:[(0,J.jsx)(`span`,{className:`mr-2 text-fg-subtle`,children:`1.`}),a.browserConnectStep1]}),(0,J.jsxs)(`li`,{children:[(0,J.jsx)(`span`,{className:`mr-2 text-fg-subtle`,children:`2.`}),a.browserConnectStep2]}),(0,J.jsxs)(`li`,{children:[(0,J.jsx)(`span`,{className:`mr-2 text-fg-subtle`,children:`3.`}),a.browserConnectStep3]})]}),(0,J.jsx)(`div`,{className:`mt-6`,children:(0,J.jsx)(k,{text:O.browserInvitation,labels:{copy:a.copy,copied:a.copied,copyFailed:i.clipboard.copyFailed}})}),(0,J.jsx)(`p`,{className:`mt-3 text-center text-xs text-fg-muted`,children:O.expiresAt-Q<6e4?`${Math.max(0,Math.ceil((O.expiresAt-Q)/1e3))}s`:v.valid})]}):D.data.ready?(0,J.jsx)(`div`,{className:`mt-8`,children:(0,J.jsx)(S,{className:`mx-auto size-[216px]`})}):(0,J.jsxs)(`div`,{className:`mt-6 flex flex-1 flex-col`,children:[R===`tailscale`?(0,J.jsx)(ue,{embedded:!0}):R===`https`?(0,J.jsx)(te,{}):R===`choices`?(0,J.jsxs)(`div`,{className:`space-y-3`,children:[(0,J.jsx)(x,{variant:`secondary`,className:`w-full`,onClick:()=>z(`tailscale`),children:a.useTailscale}),(0,J.jsx)(x,{variant:`secondary`,className:`w-full`,onClick:()=>z(`https`),children:a.useOwnHttps})]}):(0,J.jsx)(fe,{}),(0,J.jsx)(x,{variant:`ghost`,className:`mt-3 w-full`,onClick:()=>z(R?null:`choices`),children:R?v.back:v.existing})]}):(0,J.jsxs)(`div`,{className:`mt-8 space-y-4`,children:[(0,J.jsx)(S,{className:`h-5 w-3/4`}),(0,J.jsx)(S,{className:`h-40 w-full`})]}):e===`mobile`?(0,J.jsxs)(`div`,{className:`mt-7 flex flex-col items-center`,children:[he.data?(0,J.jsx)(`img`,{src:he.data,alt:a.mobileDownloadQrAlt,width:144,height:144,className:`size-36 rounded-lg bg-white`}):(0,J.jsx)(S,{className:`size-36`}),(0,J.jsxs)(x,{variant:`secondary`,className:`mt-5 w-full`,onClick:()=>void y(pe),children:[(0,J.jsx)(c,{className:`size-4`}),a.mobileDownload]}),(0,J.jsx)(`p`,{className:`mt-3 text-center text-xs leading-5 text-fg-muted`,children:a.mobileDownloadHint})]}):(0,J.jsxs)(`div`,{className:`mt-7`,children:[(0,J.jsxs)(x,{variant:`secondary`,className:`w-full`,disabled:I,onClick:()=>void De(),children:[(0,J.jsx)(s,{className:`size-4`}),a.browserDownload]}),(0,J.jsxs)(`ol`,{className:`mt-5 space-y-3 text-sm leading-6 text-fg-muted`,children:[(0,J.jsxs)(`li`,{children:[(0,J.jsx)(`span`,{className:`mr-2 text-fg-subtle`,children:`1.`}),a.browserInstallStep1]}),(0,J.jsxs)(`li`,{children:[(0,J.jsx)(`span`,{className:`mr-2 text-fg-subtle`,children:`2.`}),a.browserInstallStep2]}),(0,J.jsxs)(`li`,{children:[(0,J.jsx)(`span`,{className:`mr-2 text-fg-subtle`,children:`3.`}),a.browserInstallStep3]})]}),(0,J.jsxs)(`button`,{type:`button`,className:`mt-5 inline-flex items-center gap-1 text-xs text-accent hover:underline`,onClick:()=>void y(me),children:[a.browserInstallHelp,(0,J.jsx)(c,{className:`size-3`})]})]})]}),!T||D.error||q||G?.status===`pending`||M===`create`||M===`decision`?(0,J.jsx)(`footer`,{className:`shrink-0 px-8 pb-6`,children:T?q?(0,J.jsx)(x,{className:`w-full`,variant:`primary`,onClick:t,children:v.done}):G?.status===`pending`?(0,J.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,J.jsx)(x,{className:`w-full`,variant:`primary`,disabled:I,onClick:()=>void _e(`approve`),children:v.allow}),(0,J.jsx)(x,{className:`w-full`,variant:`ghost`,disabled:I,onClick:()=>void _e(`reject`),children:v.cancel})]}):D.error?(0,J.jsx)(x,{className:`w-full`,variant:`primary`,onClick:()=>void D.mutate(),children:v.retry}):(0,J.jsx)(x,{className:`w-full`,variant:`primary`,disabled:I,onClick:()=>void ge(),children:v.retry}):(0,J.jsx)(x,{className:`w-full`,variant:`primary`,onClick:()=>{F(null),E(!0)},children:e===`mobile`?a.mobileReady:a.browserReady})}):null]})]})}export{Y as n,X as t};
@@ -1 +0,0 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,t as n}from"./vendor-react-BOUWij0V.js";import{a as r,c as i,f as a,g as o,h as s,i as c,n as l,o as u,p as d,r as f,s as p,t as m,u as h}from"./es2015-DBLcMg5B.js";import{i as g,n as _}from"./dist-CxGUk8J-.js";var v=e(t(),1),y=n(),b=`Dialog`,[x,S]=s(b),[C,w]=x(b),T=e=>{let{__scopeDialog:t,children:n,open:r,defaultOpen:i,onOpenChange:o,modal:s=!0}=e,c=v.useRef(null),l=v.useRef(null),[u,f]=a({prop:r,defaultProp:i??!1,onChange:o,caller:b});return(0,y.jsx)(C,{scope:t,triggerRef:c,contentRef:l,contentId:d(),titleId:d(),descriptionId:d(),open:u,onOpenChange:f,onOpenToggle:v.useCallback(()=>f(e=>!e),[f]),modal:s,children:n})};T.displayName=b;var E=`DialogTrigger`,D=v.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,i=w(E,n),a=g(t,i.triggerRef);return(0,y.jsx)(h.button,{type:`button`,"aria-haspopup":`dialog`,"aria-expanded":i.open,"aria-controls":i.open?i.contentId:void 0,"data-state":q(i.open),...r,ref:a,onClick:o(e.onClick,i.onOpenToggle)})});D.displayName=E;var O=`DialogPortal`,[k,A]=x(O,{forceMount:void 0}),j=e=>{let{__scopeDialog:t,forceMount:n,children:i,container:a}=e,o=w(O,t);return(0,y.jsx)(k,{scope:t,forceMount:n,children:v.Children.map(i,e=>(0,y.jsx)(c,{present:n||o.open,children:(0,y.jsx)(r,{asChild:!0,container:a,children:e})}))})};j.displayName=O;var M=`DialogOverlay`,N=v.forwardRef((e,t)=>{let n=A(M,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,a=w(M,e.__scopeDialog);return a.modal?(0,y.jsx)(c,{present:r||a.open,children:(0,y.jsx)(F,{...i,ref:t})}):null});N.displayName=M;var P=_(`DialogOverlay.RemoveScroll`),F=v.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,a=w(M,n),o=g(t,i());return(0,y.jsx)(l,{as:P,allowPinchZoom:!0,shards:[a.contentRef],children:(0,y.jsx)(h.div,{"data-state":q(a.open),...r,ref:o,style:{pointerEvents:`auto`,...r.style}})})}),I=`DialogContent`,L=v.forwardRef((e,t)=>{let n=A(I,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,a=w(I,e.__scopeDialog);return(0,y.jsx)(c,{present:r||a.open,children:a.modal?(0,y.jsx)(R,{...i,ref:t}):(0,y.jsx)(z,{...i,ref:t})})});L.displayName=I;var R=v.forwardRef((e,t)=>{let n=w(I,e.__scopeDialog),r=v.useRef(null),i=g(t,n.contentRef,r);return v.useEffect(()=>{let e=r.current;if(e)return m(e)},[]),(0,y.jsx)(B,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,onCloseAutoFocus:o(e.onCloseAutoFocus,e=>{e.preventDefault(),n.triggerRef.current?.focus()}),onPointerDownOutside:o(e.onPointerDownOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0;(t.button===2||n)&&e.preventDefault()}),onFocusOutside:o(e.onFocusOutside,e=>e.preventDefault())})}),z=v.forwardRef((e,t)=>{let n=w(I,e.__scopeDialog),r=v.useRef(!1),i=v.useRef(!1);return(0,y.jsx)(B,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:t=>{e.onCloseAutoFocus?.(t),t.defaultPrevented||(r.current||n.triggerRef.current?.focus(),t.preventDefault()),r.current=!1,i.current=!1},onInteractOutside:t=>{e.onInteractOutside?.(t),t.defaultPrevented||(r.current=!0,t.detail.originalEvent.type===`pointerdown`&&(i.current=!0));let a=t.target;n.triggerRef.current?.contains(a)&&t.preventDefault(),t.detail.originalEvent.type===`focusin`&&i.current&&t.preventDefault()}})}),B=v.forwardRef((e,t)=>{let{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:a,...o}=e,s=w(I,n);return f(),(0,y.jsx)(y.Fragment,{children:(0,y.jsx)(u,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:a,children:(0,y.jsx)(p,{role:`dialog`,id:s.contentId,"aria-describedby":s.descriptionId,"aria-labelledby":s.titleId,"data-state":q(s.open),...o,ref:t,deferPointerDownOutside:!0,onDismiss:()=>s.onOpenChange(!1)})})})}),V=`DialogTitle`,H=v.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,i=w(V,n);return(0,y.jsx)(h.h2,{id:i.titleId,...r,ref:t})});H.displayName=V;var U=`DialogDescription`,W=v.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,i=w(U,n);return(0,y.jsx)(h.p,{id:i.descriptionId,...r,ref:t})});W.displayName=U;var G=`DialogClose`,K=v.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,i=w(G,n);return(0,y.jsx)(h.button,{type:`button`,...r,ref:t,onClick:o(e.onClick,()=>i.onOpenChange(!1))})});K.displayName=G;function q(e){return e?`open`:`closed`}export{N as a,D as c,W as i,K as n,j as o,L as r,H as s,T as t};
@@ -1 +0,0 @@
1
- import{t as e}from"./createLucideIcon-DPHK1VkS.js";var t=e(`file-archive`,[[`path`,{d:`M13.659 22H18a2 2 0 0 0 2-2V8a2.4 2.4 0 0 0-.706-1.706l-3.588-3.588A2.4 2.4 0 0 0 14 2H6a2 2 0 0 0-2 2v11.5`,key:`4pqfef`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M8 12v-1`,key:`1ej8lb`}],[`path`,{d:`M8 18v-2`,key:`qcmpov`}],[`path`,{d:`M8 7V6`,key:`1nbb54`}],[`circle`,{cx:`8`,cy:`20`,r:`2`,key:`ckkr5m`}]]);export{t};
@@ -1 +0,0 @@
1
- import{t as e}from"./createLucideIcon-DPHK1VkS.js";var t=e(`file-braces`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M10 12a1 1 0 0 0-1 1v1a1 1 0 0 1-1 1 1 1 0 0 1 1 1v1a1 1 0 0 0 1 1`,key:`1oajmo`}],[`path`,{d:`M14 18a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1 1 1 0 0 1-1-1v-1a1 1 0 0 0-1-1`,key:`mpwhp6`}]]);export{t};
@@ -1 +0,0 @@
1
- import{r as e}from"./locale-store-D_migb9R.js";import{a as t,d as n,f as r,g as i,i as a,l as o,p as s,r as c,s as l,t as u,u as d,v as f}from"./schemas-CObaziC7.js";import{t as p}from"./gateway-realtime-store-yXB4a40_.js";var ee={type:`array`,minItems:1,maxItems:20,items:{type:`object`,additionalProperties:!1,required:[`type`,`fileId`,`name`,`mimeType`,`size`,`sha256`],properties:{type:{const:`file`},fileId:{type:`string`,minLength:1,maxLength:160},name:{type:`string`,minLength:1,maxLength:255},mimeType:{type:`string`,minLength:1,maxLength:255},size:{type:`integer`,minimum:0},sha256:{type:`string`,pattern:`^[a-f0-9]{64}$`}}}},te={type:`object`,properties:{},additionalProperties:!1},m=d({purpose:u([`weather`,`nearby`]),precision:u([`approximate`,`precise`]),category:u([`restaurant`,`cafe`,`pharmacy`,`park`]).optional()}).strict().superRefine((e,t)=>{e.purpose===`nearby`!=(e.category!==void 0)&&t.addIssue({code:`custom`,message:`Category is required only for nearby queries`})}),h={type:`object`,additionalProperties:!1,required:[`purpose`,`precision`],properties:{purpose:{enum:[`weather`,`nearby`]},precision:{enum:[`approximate`,`precise`]},category:{enum:[`restaurant`,`cafe`,`pharmacy`,`park`]}},allOf:[{if:{properties:{purpose:{const:`nearby`}},required:[`purpose`]},then:{properties:{category:{}},required:[`category`]},else:{not:{properties:{category:{}},required:[`category`]}}}]};d({latitude:o().min(-90).max(90),longitude:o().min(-180).max(180),accuracyMeters:o().min(0).max(1e5),capturedAt:o().int().nonnegative(),precision:u([`approximate`,`precise`]),coordinateSystem:l(`WGS84`)}).strict();var g={type:`array`,minItems:1,maxItems:1,items:{type:`object`,additionalProperties:!1,required:[`type`,`value`],properties:{type:{const:`json`},value:{type:`object`,additionalProperties:!1,required:[`latitude`,`longitude`,`accuracyMeters`,`capturedAt`,`precision`,`coordinateSystem`],properties:{latitude:{type:`number`,minimum:-90,maximum:90},longitude:{type:`number`,minimum:-180,maximum:180},accuracyMeters:{type:`number`,minimum:0,maximum:1e5},capturedAt:{type:`integer`,minimum:0},precision:{enum:[`approximate`,`precise`]},coordinateSystem:{const:`WGS84`}}}}}};function ne(e){return{name:`${e}.device.get_location`,title:`Use location once`,description:`With on-device consent, use one fresh WGS84 location for current weather (Open-Meteo) or nearby places (OpenStreetMap). Raw coordinates are consumed transiently by Gateway, never returned to the Agent or saved in history. Select approximate or precise; nearby requires a category. Each call requires new consent.`,inputSchema:h,outputSchema:g,policyId:`personal.foreground-read`,sensitivity:`personal`,effect:`read`,confirmation:`always`,requiresForeground:!0,requiredPermissions:[`location-read-once`],timeoutMs:9e4,maxConcurrency:1,supportsCancellation:!0,idempotent:!0,resultKinds:[`json`]}}var re=25*1024*1024,_=u([`web`,`desktop`,`mobile`,`browser`]),v=u([`foreground`,`background`]),ie=u([`read`,`write`,`destructive`]),y=u([`never`,`always`]),ae=u([`text`,`json`,`file`]),oe=u([`public`,`personal`]),b=s().min(1).max(160),se=s().min(32).max(160).regex(/^[A-Za-z0-9_-]+$/);t(`type`,[r({type:l(`endpoint`),endpointId:b}),r({type:l(`channel`),channel:s().min(1).max(64)}),r({type:l(`system`),source:u([`cli`,`automation`,`heartbeat`,`workflow`,`internal`,`task_update`])})]).options[0].extend({token:se});var ce=f(),x=o().int().nonnegative(),S=n(s(),i()),C=r({name:s().regex(/^[a-z][a-z0-9_]*(?:\.[a-z][a-z0-9_]*)+$/).max(120),title:s().min(1).max(120),description:s().min(1).max(2e3),inputSchema:S,outputSchema:S,policyId:s().regex(/^[a-z][a-z0-9_.-]+$/).max(120),sensitivity:oe,effect:ie,confirmation:y,requiresForeground:a(),requiredPermissions:c(s().min(1).max(120)).max(20),timeoutMs:o().int().min(1e3).max(3e5),maxConcurrency:o().int().min(1).max(4),supportsCancellation:a(),idempotent:a(),resultKinds:c(ae).min(1).max(3)});r({principalId:b,displayName:s().min(1).max(120),kind:_,platform:s().min(1).max(80),publicKey:s().min(32).max(2048)}),r({endpointId:b});var w=s().regex(/^[a-z][a-z0-9_]*(?:\.[a-z][a-z0-9_]*)+$/).max(120);r({jobId:f(),endpointId:b,capability:w,input:S,idempotencyKey:b,consentGrantId:b,createdAt:x,expiresAt:x}),r({jobId:f(),status:u([`queued`,`running`,`succeeded`,`failed`,`cancelled`]),updatedAt:x,output:S.optional(),error:r({code:b,message:s().min(1).max(2e3)}).optional()}),r({eventId:f(),endpointId:b,subscriptionId:b,eventType:w,data:S,occurredAt:x});var le=r({principalId:b,endpointId:b,connectionInstanceId:f(),displayName:s().min(1).max(120),kind:_,platform:s().min(1).max(80),appVersion:s().min(1).max(80),availability:v,nonce:b,signedAt:x,signature:s().min(16).max(1024),tools:c(C).max(100)}),ue=r({invocationId:f(),toolCallId:b,toolName:C.shape.name,arguments:S,descriptorRevision:s().min(1).max(128),confirmationRequired:a(),deadlineAt:x,uploadGrant:r({path:s().startsWith(`/`).max(500),token:b,maxBytes:o().int().positive(),maxFiles:o().int().min(1).max(20),expiresAt:x}).optional()}),de=r({invocationId:f(),reason:s().min(1).max(500)}),T=r({invocationId:f()}),E=t(`type`,[r({type:l(`text`),text:s().max(256*1024)}),r({type:l(`json`),value:i()}),r({type:l(`file`),fileId:b,name:s().min(1).max(255),mimeType:s().min(1).max(255),size:o().int().nonnegative(),sha256:s().regex(/^[a-f0-9]{64}$/)})]),fe=u([`ENDPOINT_OFFLINE`,`ENDPOINT_NOT_FOREGROUND`,`ENDPOINT_DISCONNECTED`,`TOOL_NOT_FOUND`,`TOOL_REVISION_MISMATCH`,`INVALID_ARGUMENTS`,`PERMISSION_DENIED`,`USER_DENIED`,`TOOL_BUSY`,`TOOL_TIMEOUT`,`TOOL_CANCELLED`,`RESULT_TOO_LARGE`,`PROTOCOL_ERROR`]),D=(e,t)=>r({protocolVersion:l(2),messageId:ce,type:l(e),sentAt:x,payload:t}),O=t(`type`,[D(`endpoint.availability_changed`,r({availability:v})),D(`tool.received`,T),D(`tool.progress`,r({invocationId:f(),message:s().max(500).optional(),percent:o().min(0).max(100).optional()})),D(`tool.result`,r({invocationId:f(),content:c(E).min(1).max(20),details:S.optional()})),D(`tool.error`,r({invocationId:f(),code:fe,message:s().min(1).max(2e3)})),D(`tool.cancelled`,T)]),k=t(`type`,[D(`tool.invoke`,ue),D(`tool.cancel`,de)]),A={type:`array`,minItems:1,maxItems:20,items:{type:`object`,additionalProperties:!1,required:[`type`,`text`],properties:{type:{const:`text`},text:{type:`string`,maxLength:256*1024}}}};function j(e){if(e===null)return`null`;if(typeof e==`string`||typeof e==`boolean`)return JSON.stringify(e);if(typeof e==`number`){if(!Number.isFinite(e))throw Error(`Canonical JSON only supports finite numbers`);return JSON.stringify(e)}if(typeof e!=`object`)throw Error(`Canonical JSON does not support ${typeof e}`);if(Array.isArray(e))return`[${e.map(j).join(`,`)}]`;let t=Object.getPrototypeOf(e);if(t!==Object.prototype&&t!==null)throw Error(`Canonical JSON only supports plain objects`);let n=e;return`{${Object.keys(n).sort().map(e=>`${JSON.stringify(e)}:${j(n[e])}`).join(`,`)}}`}function M(e){let{signature:t,...n}=e;return j(n)}var N={type:`array`,minItems:1,maxItems:1,items:{type:`object`,additionalProperties:!1,required:[`type`,`value`],properties:{type:{const:`json`},value:{type:`object`,additionalProperties:!1,required:[`capturedAt`,`platform`,`systemVersion`,`locale`,`timezone`],properties:{capturedAt:{type:`integer`,minimum:0},platform:{type:`string`,minLength:1,maxLength:40},systemVersion:{type:`string`,maxLength:80},locale:{type:`string`,maxLength:80},timezone:{type:`string`,maxLength:80},online:{type:`boolean`}}}}}},P={type:`array`,minItems:1,maxItems:1,items:{type:`object`,additionalProperties:!1,required:[`type`,`value`],properties:{type:{const:`json`},value:{type:`object`,additionalProperties:!1,required:[`capturedAt`,`levelPercent`,`charging`],properties:{capturedAt:{type:`integer`,minimum:0},levelPercent:{type:[`number`,`null`],minimum:0,maximum:100},charging:{type:[`boolean`,`null`]}}}}}};function F(e,t){return{name:`${e}.device.get_${t}`,title:t===`power`?`Read this device’s battery`:`Read this device’s environment`,description:t===`power`?`Read a fresh battery sample from the device that sent this user message. Unknown readings are null.`:`Read bounded platform, system version, language and timezone from the device that sent this user message. No files, page content, network addresses or identifiers are collected.`,inputSchema:te,outputSchema:t===`power`?P:N,policyId:`public.background-read`,sensitivity:`public`,effect:`read`,confirmation:`never`,requiresForeground:!1,requiredPermissions:[],timeoutMs:1e4,maxConcurrency:1,supportsCancellation:!0,idempotent:!0,resultKinds:[`json`]}}var I=256*1024,L=15e3,R=45e3,z=[`realtime.capability-negotiation.v1`],B=u([`web`,`desktop`,`mobile`,`browser_extension`,`tui`,`mcp`]),V=s().min(1).max(512),pe=s().regex(/^[a-z][a-z0-9_.-]*$/).max(160),me=f(),he=o().int().nonnegative(),H=o().int().positive(),U=s().min(1).max(160),W=(e,t)=>d({protocolVersion:l(2),messageId:me,kind:l(e),sentAt:he,payload:t}),G=d({topic:V,afterSeq:o().int().nonnegative().optional(),view:l(`compact`).optional()});t(`kind`,[W(`realtime.hello`,d({ticket:s().min(32).max(512),clientId:s().min(1).max(160),clientKind:B,subscriptions:c(G).max(100).default([]),capabilities:c(U).max(64).optional(),endpoint:le.optional()})),W(`realtime.subscribe`,d({subscriptions:c(G).min(1).max(100)})),W(`realtime.unsubscribe`,d({topics:c(V).min(1).max(100)})),W(`realtime.ping`,d({})),W(`endpoint.message`,O)]);var ge=d({topic:V,seq:H,event:pe,data:i()}),_e=t(`kind`,[W(`realtime.ready`,d({connectionId:f(),heartbeatIntervalMs:l(L),heartbeatTimeoutMs:l(R),negotiatedCapabilities:c(U).max(64).optional(),endpoint:d({endpointId:s().min(1).max(160),turnToken:s().min(32).max(160)}).optional()})),W(`realtime.event`,ge),W(`realtime.subscribed`,d({topic:V,cursor:o().int().nonnegative()})),W(`realtime.gap`,d({topic:V,requestedSeq:o().int().nonnegative(),earliestSeq:H,recoverable:a()})),W(`realtime.pong`,d({})),W(`realtime.error`,d({code:s().min(1).max(80),message:s().min(1).max(500)})),W(`endpoint.message`,k)]);function ve(e){return _e.parse(e)}var K=class extends Error{retryable;constructor(e,t){super(e),this.retryable=t,this.name=`RealtimeConnectionError`}},ye=class extends Error{bytes;maxBytes;constructor(e,t){super(`Realtime client frame is ${e} bytes; maximum is ${t} bytes`),this.bytes=e,this.maxBytes=t,this.name=`RealtimeFrameTooLargeError`}};function be(e){if(typeof e==`string`)return e;if(e instanceof ArrayBuffer)return new TextDecoder().decode(e);if(ArrayBuffer.isView(e)){let t=Uint8Array.from(new Uint8Array(e.buffer,e.byteOffset,e.byteLength));return new TextDecoder().decode(t)}throw Error(`Realtime server sent a non-text frame`)}function xe(e){return e===1009||e===4400||e===4401||e===4409||e===4413}var Se=class{options;desiredSubscriptions=new Map;cursors=new Map;socket;reconnectTimer;heartbeatTimer;connectionTimer;ticketAbort;generation=0;reconnectAttempts=0;shouldReconnect=!1;ready=!1;lastServerMessageAt=0;endpointBinding;reconnectWhenSocketOpens=!1;offeredCapabilities=new Set;constructor(e){this.options=e}connect(){this.shouldReconnect||(this.shouldReconnect=!0,this.open(!1))}disconnect(){this.shouldReconnect=!1,this.reconnectWhenSocketOpens=!1,this.generation+=1,this.clearTimers(),this.ready=!1,this.offeredCapabilities.clear(),this.endpointBinding?.onDisconnected?.(),this.socket?.close(1e3,`Client disconnected`),this.socket=void 0,this.options.onStateChange?.(`disconnected`)}reconnect(){this.reconnectWhenSocketOpens=!1,this.generation+=1,this.clearTimers(),this.ready=!1,this.endpointBinding?.onDisconnected?.(),this.socket?.close(1e3,`Client reconnecting`),this.socket=void 0,this.reconnectAttempts=0,this.shouldReconnect=!0,this.open(!0)}subscribe(e,t){this.desiredSubscriptions.set(e,t),t!==void 0&&this.cursors.set(e,t),this.ready&&this.sendSubscriptions([{topic:e,afterSeq:this.cursors.get(e)??t}])}unsubscribe(e){this.desiredSubscriptions.delete(e),this.ready&&this.send(this.clientMessage(`realtime.unsubscribe`,{topics:[e]}))}sendEndpointMessage(e){if(!this.ready)throw Error(`Realtime connection is not ready`);this.send(this.clientMessage(`endpoint.message`,e))}setEndpoint(e){this.endpointBinding=e,this.refreshEndpointConnection()}clearEndpoint(e){if(e&&this.endpointBinding!==e)return;let t=this.endpointBinding;this.endpointBinding=void 0,t?.onDisconnected?.(),this.refreshEndpointConnection()}refreshEndpointConnection(){if(this.shouldReconnect){if(this.socket?.readyState===0){this.reconnectWhenSocketOpens=!0;return}this.reconnect()}}async open(e){let t=++this.generation,n=this.options.connectionTimeoutMs??15e3,r=new AbortController;this.ticketAbort?.abort(),this.ticketAbort=r;let i,a=!1,o,s=(e,n=!0)=>{a||t!==this.generation||(a=!0,this.clearConnectionTimer(),r.abort(),this.ticketAbort===r&&(this.ticketAbort=void 0),this.ready=!1,this.offeredCapabilities.clear(),this.endpointBinding?.onDisconnected?.(),this.clearHeartbeat(),this.socket===i&&(this.socket=void 0),i&&(i.onopen=null,i.onmessage=null,i.onerror=null,i.onclose=null,i.close(4e3,e.slice(0,120))),this.shouldReconnect&&n?this.scheduleReconnect(e):this.shouldReconnect?(this.shouldReconnect=!1,this.options.onStateChange?.(`error`,e)):this.options.onStateChange?.(`disconnected`))};this.connectionTimer=setTimeout(()=>s(`Realtime connection timed out`),n),this.options.onStateChange?.(e?`reconnecting`:`connecting`);try{let[e,n]=await Promise.all([this.options.issueTicket(r.signal),this.endpointBinding?.createHello()]),c=e.ticket;if(2<e.realtime.minVersion)throw new K(`CLIENT_UPDATE_REQUIRED`,!1);if(2>e.realtime.maxVersion)throw new K(`GATEWAY_UPDATE_REQUIRED`,!1);let l=z.filter(t=>e.realtime.capabilities.includes(t));if(a||!this.shouldReconnect||t!==this.generation)return;this.offeredCapabilities=new Set(l??[]),i=this.options.createWebSocket(this.options.getWebSocketUrl()),this.socket=i,i.onopen=()=>{if(t!==this.generation)return;if(this.reconnectWhenSocketOpens){this.reconnect();return}let e=[...this.desiredSubscriptions].map(([e,t])=>({topic:e,afterSeq:this.cursors.get(e)??t}));this.send(this.clientMessage(`realtime.hello`,{ticket:c,clientId:this.options.clientId,clientKind:this.options.clientKind,subscriptions:e,...l?.length?{capabilities:l}:{},...n?{endpoint:n}:{}}))},i.onmessage=e=>{if(t!==this.generation)return;let n=()=>{if(!(a||t!==this.generation))return this.handleServerMessage(be(e.data))};if(!o){try{let e=n();if(!e)return;let t=e.catch(e=>s(e instanceof Error?e.message:`Invalid realtime server message`)).then(()=>void 0);o=t,t.finally(()=>{o===t&&(o=void 0)})}catch(e){s(e instanceof Error?e.message:`Invalid realtime server message`)}return}let r=o.then(n).catch(e=>s(e instanceof Error?e.message:`Invalid realtime server message`)).then(()=>void 0);o=r,r.finally(()=>{o===r&&(o=void 0)})},i.onerror=()=>{},i.onclose=e=>{s(e.reason||`WebSocket closed (${e.code??0})`,!xe(e.code))}}catch(e){s(e instanceof Error?e.message:`Realtime connection failed`,!(e instanceof K)||e.retryable)}}handleServerMessage(e){let t=ve(JSON.parse(e));if(this.lastServerMessageAt=Date.now(),t.kind===`realtime.ready`){let e=t.payload.negotiatedCapabilities??[];if(e.some(e=>!this.offeredCapabilities.has(e)))throw Error(`Realtime server negotiated a capability the client did not offer`);this.ready=!0,this.reconnectAttempts=0,this.clearConnectionTimer(),this.ticketAbort=void 0,this.options.onStateChange?.(`connected`),this.options.onCapabilities?.(e),t.payload.endpoint&&this.endpointBinding?.onReady(t.payload.endpoint),this.clearHeartbeat(),this.heartbeatTimer=setInterval(()=>{if(this.ready){if(Date.now()-this.lastServerMessageAt>=t.payload.heartbeatTimeoutMs){this.reconnect();return}this.send(this.clientMessage(`realtime.ping`,{}))}},t.payload.heartbeatIntervalMs)}else if(t.kind===`realtime.event`){let e=this.cursors.get(t.payload.topic);if(e!==void 0&&t.payload.seq<=e)return;this.options.onEvent?.(t.payload),this.cursors.set(t.payload.topic,t.payload.seq)}else if(t.kind===`realtime.subscribed`)this.cursors.set(t.payload.topic,t.payload.cursor),this.options.onSubscribed?.(t.payload);else if(t.kind===`realtime.gap`)return this.cursors.set(t.payload.topic,t.payload.earliestSeq-1),this.options.onGap?.(t.payload);else t.kind===`realtime.error`?this.options.onStateChange?.(`error`,t.payload.message):t.kind===`endpoint.message`&&(this.endpointBinding?.onMessage(t.payload),this.options.onEndpointMessage?.(t.payload))}sendSubscriptions(e){this.send(this.clientMessage(`realtime.subscribe`,{subscriptions:e}))}clientMessage(e,t){let n=this.options.createMessageId?.()??globalThis.crypto?.randomUUID?.();if(!n)throw Error(`RealtimeClient requires createMessageId when crypto.randomUUID is unavailable`);return{protocolVersion:2,messageId:n,kind:e,sentAt:Date.now(),payload:t}}send(e){if(!this.socket||this.socket.readyState!==1)return;let t=JSON.stringify(e),n=new TextEncoder().encode(t).byteLength;if(n>262144)throw new ye(n,I);this.socket.send(t)}scheduleReconnect(e){if(!this.shouldReconnect)return;this.reconnectAttempts+=1;let t=this.options.maxReconnectAttempts;if(t!==void 0&&this.reconnectAttempts>t){this.shouldReconnect=!1,this.options.onStateChange?.(`error`,e);return}this.options.onStateChange?.(`reconnecting`,e);let n=Math.min(3e4,1e3*2**Math.min(this.reconnectAttempts-1,5)),r=Math.round(n*(.5+Math.random()*.5));this.reconnectTimer&&clearTimeout(this.reconnectTimer),this.reconnectTimer=setTimeout(()=>{this.reconnectTimer=void 0,this.open(!0)},r)}clearHeartbeat(){this.heartbeatTimer&&clearInterval(this.heartbeatTimer),this.heartbeatTimer=void 0}clearTimers(){this.reconnectTimer&&clearTimeout(this.reconnectTimer),this.reconnectTimer=void 0,this.clearConnectionTimer(),this.ticketAbort?.abort(),this.ticketAbort=void 0,this.clearHeartbeat()}clearConnectionTimer(){this.connectionTimer&&clearTimeout(this.connectionTimer),this.connectionTimer=void 0}},Ce=500,q=null,J;function Y(e){J=e,q!==null&&clearTimeout(q),q=setTimeout(()=>{q=null;let e=J;J=void 0,window.dispatchEvent(new CustomEvent(`config-reload`,{detail:e}))},Ce)}function we(e,t){if(e===`config.reload`){Y(t);return}window.dispatchEvent(new CustomEvent(e.replace(/[._]/g,`-`),{detail:t}))}var X=new Map,Z=new Map,Q,$;function Te(){let e=`xopc:realtime-client-id`,t=sessionStorage.getItem(e);if(t)return t;let n=crypto.randomUUID();return sessionStorage.setItem(e,n),n}function Ee(){let t=new URL(e(`/api/realtime/v1/ws`));return t.protocol=t.protocol===`https:`?`wss:`:`ws:`,t.toString()}function De(){let t=Te(),n=window.electronAPI?`desktop`:`web`,r=new Se({clientId:t,clientKind:n,getWebSocketUrl:Ee,issueTicket:async r=>{let i=await fetch(e(`/api/realtime/tickets`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({clientId:t,clientKind:n,protocolVersion:2}),signal:r}),a=await i.json().catch(()=>null);if(!i.ok||!a?.payload?.ticket||!a.payload.realtime)throw Error(a?.error?.message??`Realtime ticket failed (${i.status})`);return{ticket:a.payload.ticket,realtime:a.payload.realtime}},createWebSocket:e=>new WebSocket(e),onStateChange:(e,t)=>{p({connectionState:e,error:t??null}),e===`connected`&&window.dispatchEvent(new CustomEvent(`gateway-realtime-connected`))},onEvent:e=>{(e.topic===`gateway`||e.topic===`sessions`)&&we(e.event,e.data);let t=Z.get(e.topic);(t===void 0||e.seq>t)&&Z.set(e.topic,e.seq);for(let t of X.get(e.topic)??[])if(!(t.cursor!==void 0&&e.seq<=t.cursor))try{t.listener.onEvent(e)}catch(e){console.error(`[realtime] topic listener failed:`,e)}finally{t.cursor=Math.max(t.cursor??0,e.seq)}},onGap:async e=>{window.dispatchEvent(new CustomEvent(`realtime-gap`,{detail:e}));let t=[...X.get(e.topic)??[]].filter(t=>!e.recoverable||t.cursor===void 0||t.cursor<e.earliestSeq-1),n=await Promise.allSettled(t.map(t=>t.listener.onGap?.(e)));for(let e of n)e.status===`rejected`&&console.error(`[realtime] topic gap handler failed:`,e.reason)}});Q?.disconnect(),Q=r,$&&r.setEndpoint($),r.subscribe(`gateway`,Z.get(`gateway`)),r.subscribe(`sessions`,Z.get(`sessions`));for(let e of X.keys())r.subscribe(e,Z.get(e));return p({connectionState:`connecting`,error:null}),r.connect(),()=>{Q===r&&(r.disconnect(),Q=void 0)}}function Oe(e){return $=e,Q?.setEndpoint(e),()=>{$===e&&($=void 0,Q?.clearEndpoint(e))}}function ke(e){Q?.sendEndpointMessage(e)}function Ae(){Q?.reconnect()}function je(e,t,n){let r=X.get(e)??new Set,i=r.size===0,a=Z.get(e),o={listener:t,cursor:n??a};if(r.add(o),X.set(e,r),i){let t=n??a;Z.set(e,t),Q?.subscribe(e,t)}else n!==void 0&&(a===void 0||n<a)&&Q?.subscribe(e,n);return()=>{let t=X.get(e);t?.delete(o),(!t||t.size===0)&&(X.delete(e),Z.delete(e),Q?.unsubscribe(e))}}export{je as a,A as c,M as d,E as f,ee as h,De as i,j as l,m,Ae as n,Y as o,ne as p,ke as r,re as s,Oe as t,F as u};
@@ -1 +0,0 @@
1
- import{p as e}from"./locale-store-D_migb9R.js";var t=e(()=>({connectionState:`idle`,error:null}));function n(e){t.setState(e)}export{t as n,n as t};