@xopcai/xopc 0.0.285 → 0.0.291

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 (1223) hide show
  1. package/README.md +16 -0
  2. package/README.zh-CN.md +16 -0
  3. package/dist/browser-ext/dist/assets/{auth-DB30ywek.js → auth-B2CDTr_F.js} +3 -2
  4. package/dist/browser-ext/dist/background.js +2 -2
  5. package/dist/browser-ext/dist/sidepanel.html +1 -1
  6. package/dist/browser-ext/dist/sidepanel.js +171 -145
  7. package/dist/browser-ext/manifest.json +1 -1
  8. package/dist/extensions/feishu/src/adapters/gateway-setup.js +14 -14
  9. package/dist/extensions/feishu/src/state/message-bindings.d.ts +1 -1
  10. package/dist/extensions/feishu/src/state/thread-bindings.d.ts +4 -4
  11. package/dist/extensions/feishu/src/state/thread-bindings.js +6 -6
  12. package/dist/extensions/feishu/src/subagent-hooks.d.ts +1 -1
  13. package/dist/extensions/feishu/src/subagent-hooks.js +5 -5
  14. package/dist/extensions/feishu/src/transport/socket-mode/monitor.js +9 -9
  15. package/dist/extensions/feishu/src/transport/webhook/monitor.js +4 -4
  16. package/dist/extensions/feishu/src/workflow-progress.d.ts +1 -1
  17. package/dist/extensions/feishu/src/workflow-progress.js +8 -7
  18. package/dist/extensions/telegram/src/approval-store.d.ts +2 -2
  19. package/dist/extensions/telegram/src/approval-store.js +1 -1
  20. package/dist/extensions/telegram/src/command-handler.d.ts +2 -2
  21. package/dist/extensions/telegram/src/command-handler.js +8 -8
  22. package/dist/extensions/telegram/src/delivery-chat-id.d.ts +1 -1
  23. package/dist/extensions/telegram/src/delivery-chat-id.js +7 -3
  24. package/dist/extensions/telegram/src/exec-approval-handler.js +1 -1
  25. package/dist/extensions/telegram/src/focus-handler.d.ts +2 -2
  26. package/dist/extensions/telegram/src/focus-handler.js +10 -10
  27. package/dist/extensions/telegram/src/inbound-processor.d.ts +3 -3
  28. package/dist/extensions/telegram/src/inbound-processor.js +11 -11
  29. package/dist/extensions/telegram/src/plugin.js +5 -5
  30. package/dist/extensions/telegram/src/routing-integration.d.ts +1 -1
  31. package/dist/extensions/telegram/src/routing-integration.js +19 -21
  32. package/dist/extensions/telegram/src/thread-bindings.d.ts +1 -1
  33. package/dist/extensions/telegram/src/workflow-progress.js +8 -7
  34. package/dist/extensions/telegram/xopc.extension.json +1 -1
  35. package/dist/extensions/weixin/src/auth/login-qr.d.ts +4 -4
  36. package/dist/extensions/weixin/src/auth/login-qr.js +21 -21
  37. package/dist/extensions/weixin/src/auth/weixin-account-id.d.ts +1 -1
  38. package/dist/extensions/weixin/src/auth/weixin-account-id.js +1 -1
  39. package/dist/extensions/weixin/src/cli/gateway-qr-login.d.ts +2 -2
  40. package/dist/extensions/weixin/src/cli/gateway-qr-login.js +13 -13
  41. package/dist/extensions/weixin/src/cli/qr-login.js +1 -1
  42. package/dist/extensions/weixin/src/delivery-to.js +6 -2
  43. package/dist/extensions/weixin/src/messaging/inbound.d.ts +1 -1
  44. package/dist/extensions/weixin/src/messaging/inbound.js +1 -1
  45. package/dist/extensions/weixin/src/messaging/process-message.js +3 -3
  46. package/dist/extensions/weixin/src/plugin.js +5 -5
  47. package/dist/extensions/weixin/src/routing-integration.d.ts +1 -1
  48. package/dist/extensions/weixin/src/routing-integration.js +3 -3
  49. package/dist/extensions/weixin/src/workflow-progress.d.ts +1 -1
  50. package/dist/extensions/weixin/src/workflow-progress.js +7 -6
  51. package/dist/gateway/static/root/assets/{activity-store-B0BTIk9j.js → activity-store-6lmzUBEr.js} +1 -1
  52. package/dist/gateway/static/root/assets/{agent-avatar-dicebear-Dc-0QZTQ.js → agent-avatar-dicebear-BCtrkF15.js} +1 -1
  53. package/dist/gateway/static/root/assets/agent-defaults-settings-panel-D2eYNelh.js +1 -0
  54. package/dist/gateway/static/root/assets/agents-BedA5XwI.js +1 -0
  55. package/dist/gateway/static/root/assets/{api-Coly9ab6.js → api-D6yepxBp.js} +1 -1
  56. package/dist/gateway/static/root/assets/api-Dnfnl1Gd.js +1 -0
  57. package/dist/gateway/static/root/assets/{app-management-settings-panel-TWBO-msg.js → app-management-settings-panel-Md562Fo-.js} +1 -1
  58. package/dist/gateway/static/root/assets/{appearance-settings-CpTZ2KuT.js → appearance-settings-BiBFI4BM.js} +1 -1
  59. package/dist/gateway/static/root/assets/apps-page-Corla83b.js +1 -0
  60. package/dist/gateway/static/root/assets/{archive-plugin-z_u6alob.js → archive-plugin-A_Unp751.js} +1 -1
  61. package/dist/gateway/static/root/assets/{attachment-load-C2nS04TC.js → attachment-load-D6idSUyP.js} +1 -1
  62. package/dist/gateway/static/root/assets/{automations-page-aIBsw9zR.js → automations-page-C6j71Lgs.js} +1 -1
  63. package/dist/gateway/static/root/assets/automations-workspace-DjZdhLQ5.js +6 -0
  64. package/dist/gateway/static/root/assets/{binary-plugins-CGmXoZnl.js → binary-plugins-BkKYh-8v.js} +1 -1
  65. package/dist/gateway/static/root/assets/{block-editor-CtvzCZhC.js → block-editor-CDcMvaku.js} +3 -3
  66. package/dist/gateway/static/root/assets/{browser-automation-inputs-BOTU1isH.js → browser-automation-inputs-Cq4sIJt2.js} +1 -1
  67. package/dist/gateway/static/root/assets/{browser-automations-page-BwU5V8J0.js → browser-automations-page-C64k4TBH.js} +2 -2
  68. package/dist/gateway/static/root/assets/browser-settings-page-1k5rj_qR.js +8 -0
  69. package/dist/gateway/static/root/assets/button-CGlRPNzi.js +1 -0
  70. package/dist/gateway/static/root/assets/capabilities-settings-panel-B2NvoTYb.js +8 -0
  71. package/dist/gateway/static/root/assets/channels-settings-DExixzp4.js +1 -0
  72. package/dist/gateway/static/root/assets/{channels-status-swr-Dfi0Desh.js → channels-status-swr-CVzEYBpX.js} +1 -1
  73. package/dist/gateway/static/root/assets/{chat-terminal-dock-B0MvcO6j.js → chat-terminal-dock-B9eKFkbg.js} +2 -2
  74. package/dist/gateway/static/root/assets/computer-model-settings-DW6j2lsn.js +1 -0
  75. package/dist/gateway/static/root/assets/computer-settings-page-C2Qyw63Q.js +1 -0
  76. package/dist/gateway/static/root/assets/connectors-page-C3ubZz7K.js +2 -0
  77. package/dist/gateway/static/root/assets/{cron-expression-CjrWuy2m.js → cron-expression-GDPX4NxC.js} +1 -1
  78. package/dist/gateway/static/root/assets/{date-picker-DXOvbHCr.js → date-picker-BdxjXVKL.js} +1 -1
  79. package/dist/gateway/static/root/assets/{dependency-picker-BEnC-eS0.js → dependency-picker-CXOa4uh4.js} +1 -1
  80. package/dist/gateway/static/root/assets/desktop-pet-CBWiAaSv.js +1 -0
  81. package/dist/gateway/static/root/assets/{desktop-pet-settings-CYyjcSn6.js → desktop-pet-settings-BX1aILDK.js} +1 -1
  82. package/dist/gateway/static/root/assets/{device-pairing-wizard-BPMGvAKE.js → device-pairing-wizard-bqm_Yf4i.js} +1 -1
  83. package/dist/gateway/static/root/assets/{extension-debug-page-H_aPMGXW.js → extension-debug-page-B4MMerja.js} +1 -1
  84. package/dist/gateway/static/root/assets/{extension-page-C1JnpeMt.js → extension-page-B3ZtINak.js} +1 -1
  85. package/dist/gateway/static/root/assets/extension-settings-page-8BkQVh0z.js +1 -0
  86. package/dist/gateway/static/root/assets/{gateway-config-swr-G2lQt7Ak.js → gateway-config-swr-BBovMBQ1.js} +1 -1
  87. package/dist/gateway/static/root/assets/gateway-settings-ZyhacQX5.js +1 -0
  88. package/dist/gateway/static/root/assets/{gateway-startup-retry-GP31PUrG.js → gateway-startup-retry-NXDtzZED.js} +1 -1
  89. package/dist/gateway/static/root/assets/heartbeat-settings-Bllcxm2A.js +1 -0
  90. package/dist/gateway/static/root/assets/home-page-Cv2e8XBR.js +1 -0
  91. package/dist/gateway/static/root/assets/{image-generation-api-CKFhfHSw.js → image-generation-api-D01ieqGC.js} +1 -1
  92. package/dist/gateway/static/root/assets/{imports-page-GROumhj8.js → imports-page-DJG1BJzd.js} +1 -1
  93. package/dist/gateway/static/root/assets/index-B7EieIE4.js +75 -0
  94. package/dist/gateway/static/root/assets/index-BD5uNzie.css +2 -0
  95. package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-zcI822m_.js → keyboard-shortcuts-settings-6A6JOHTI.js} +1 -1
  96. package/dist/gateway/static/root/assets/local-app-workbench-page-Cipj52Zq.js +2 -0
  97. package/dist/gateway/static/root/assets/{local-apps-page-BtgDJ92Q.js → local-apps-page-bD-m7YHJ.js} +1 -1
  98. package/dist/gateway/static/root/assets/locale-store-eliqUnBr.js +1 -0
  99. package/dist/gateway/static/root/assets/logs-page-D5feO2yw.js +2 -0
  100. package/dist/gateway/static/root/assets/{management-settings-DasZxCyD.js → management-settings-B7mz0_44.js} +1 -1
  101. package/dist/gateway/static/root/assets/{markdown-view-6oYdBahT.js → markdown-view-BIg7cei7.js} +1 -1
  102. package/dist/gateway/static/root/assets/{media-plugins-CxthbBvk.js → media-plugins-DQ2HfMeG.js} +1 -1
  103. package/dist/gateway/static/root/assets/messages-NYDOR8-j.js +3 -0
  104. package/dist/gateway/static/root/assets/note-detail-panel-DhYJigb3.js +5 -0
  105. package/dist/gateway/static/root/assets/notes-page-Bg5NPUdf.js +8 -0
  106. package/dist/gateway/static/root/assets/page-tabs-DmG_Qjl8.js +1 -0
  107. package/dist/gateway/static/root/assets/popover-select-DldSX8GX.js +1 -0
  108. package/dist/gateway/static/root/assets/{preview-open-alternatives-Bevpbq9f.js → preview-open-alternatives-Y9J1kjKC.js} +1 -1
  109. package/dist/gateway/static/root/assets/proactive-page-Duc_NQ8l.js +1 -0
  110. package/dist/gateway/static/root/assets/{product-open-page-Bi1seZpM.js → product-open-page-DtgWUAwT.js} +1 -1
  111. package/dist/gateway/static/root/assets/project-detail-page-DVOiucVA.js +1 -0
  112. package/dist/gateway/static/root/assets/projects-page-Dr_kDoCJ.js +1 -0
  113. package/dist/gateway/static/root/assets/{registry-api-D0ddwBFj.js → registry-api-Dpm3N2h0.js} +1 -1
  114. package/dist/gateway/static/root/assets/remote-access-hub-hyJ2KKKK.js +1 -0
  115. package/dist/gateway/static/root/assets/{runtime-tools-settings-panel-Wkru8_My.js → runtime-tools-settings-panel-DB7J9opJ.js} +2 -2
  116. package/dist/gateway/static/root/assets/{schema-form-CSMRzj9Y.js → schema-form-CMYuPOlE.js} +1 -1
  117. package/dist/gateway/static/root/assets/sessions-page-DGsnYcoh.js +1 -0
  118. package/dist/gateway/static/root/assets/settings-advanced-gate-DuzZqQMn.js +1 -0
  119. package/dist/gateway/static/root/assets/settings-form-section-BayJP08a.js +1 -0
  120. package/dist/gateway/static/root/assets/{settings-page-BcQGAnCs.js → settings-page-CWBqZtt6.js} +1 -1
  121. package/dist/gateway/static/root/assets/settings-page-layout-CsUQKRq0.js +1 -0
  122. package/dist/gateway/static/root/assets/setup-status-panel-C97S5g5c.js +1 -0
  123. package/dist/gateway/static/root/assets/{share-preview-page-DQocUl-1.js → share-preview-page-Wn5bQA-5.js} +1 -1
  124. package/dist/gateway/static/root/assets/shares-settings-pfVzP8F7.js +1 -0
  125. package/dist/gateway/static/root/assets/skill-reload-api-DDJ0ZKx3.js +1 -0
  126. package/dist/gateway/static/root/assets/skills-page-DbDpLjDW.js +2 -0
  127. package/dist/gateway/static/root/assets/{skills-page.utils-DtlfCgJp.js → skills-page.utils-DCHY_kou.js} +1 -1
  128. package/dist/gateway/static/root/assets/{system-settings-panel-Ct698Nf-.js → system-settings-panel-DhgITgId.js} +1 -1
  129. package/dist/gateway/static/root/assets/task-detail-page-UqwtiHYu.js +1 -0
  130. package/dist/gateway/static/root/assets/{theme-store-ng8KJsAT.js → theme-store-DUHPzKzv.js} +1 -1
  131. package/dist/gateway/static/root/assets/tunnel-api-DJ3gz2tM.js +1 -0
  132. package/dist/gateway/static/root/assets/{use-autosave-BSyxRHt2.js → use-autosave-htvgT192.js} +1 -1
  133. package/dist/gateway/static/root/assets/user-model-page-xOsXY_2W.js +2 -0
  134. package/dist/gateway/static/root/assets/{voice-api-key-field-SE3OQI1s.js → voice-api-key-field-BviJF3Oa.js} +1 -1
  135. package/dist/gateway/static/root/assets/{voice-config-api-VNuCmdFe.js → voice-config-api-Bjy8EFqi.js} +1 -1
  136. package/dist/gateway/static/root/assets/{work-discovery-overlay-Dn1vy2oq.js → work-discovery-overlay-BOBVNEYZ.js} +1 -1
  137. package/dist/gateway/static/root/assets/{workflow-run-setup-panel-BJEfGY-k.js → workflow-run-setup-panel-D1N9uUyM.js} +2 -2
  138. package/dist/gateway/static/root/assets/workflows-page-2ylzlgkG.js +6 -0
  139. package/dist/gateway/static/root/index.html +12 -12
  140. package/dist/package.js +1 -1
  141. package/dist/packages/computer-control-contract/src/index.js +178 -0
  142. package/dist/packages/endpoint-tools-protocol/src/index.js +312 -305
  143. package/dist/packages/gateway-contract/src/agent-stream.js +6 -0
  144. package/dist/packages/gateway-contract/src/automations.js +215 -0
  145. package/dist/packages/gateway-contract/src/browser-page-context.js +48 -39
  146. package/dist/packages/gateway-contract/src/browser-tab-binding.js +30 -25
  147. package/dist/packages/gateway-contract/src/clarifications.js +6 -0
  148. package/dist/packages/gateway-contract/src/connection-waits.js +6 -0
  149. package/dist/packages/gateway-contract/src/conversation-identity.js +17 -0
  150. package/dist/packages/gateway-contract/src/device-pairing.js +84 -78
  151. package/dist/packages/gateway-contract/src/discussions.js +19 -15
  152. package/dist/packages/gateway-contract/src/files.js +55 -0
  153. package/dist/packages/gateway-contract/src/home.js +188 -0
  154. package/dist/packages/gateway-contract/src/index.js +65 -0
  155. package/dist/packages/gateway-contract/src/mobile-privacy.js +26 -0
  156. package/dist/packages/gateway-contract/src/model-selection.js +4 -1
  157. package/dist/packages/gateway-contract/src/new-session.js +5 -1
  158. package/dist/packages/gateway-contract/src/notifications.js +64 -59
  159. package/dist/packages/gateway-contract/src/proactive.js +133 -128
  160. package/dist/packages/gateway-contract/src/product-delivery.js +56 -50
  161. package/dist/packages/gateway-contract/src/project-monitoring.js +33 -28
  162. package/dist/packages/gateway-contract/src/project-operating.js +100 -0
  163. package/dist/packages/gateway-contract/src/session-identity.js +38 -34
  164. package/dist/packages/gateway-contract/src/session-input-reliability.js +6 -0
  165. package/dist/packages/gateway-contract/src/sessions.js +145 -0
  166. package/dist/packages/gateway-contract/src/task-lifecycle.js +69 -64
  167. package/dist/packages/gateway-contract/src/task-runs.js +80 -75
  168. package/dist/packages/gateway-contract/src/tasks.js +445 -438
  169. package/dist/packages/gateway-contract/src/tool-activity.js +154 -149
  170. package/dist/packages/gateway-contract/src/turn-outcome.js +118 -112
  171. package/dist/packages/gateway-contract/src/user-message-display.js +13 -8
  172. package/dist/packages/gateway-contract/src/welcome-suggestions.js +6 -0
  173. package/dist/packages/realtime-client/src/index.js +1 -1
  174. package/dist/packages/realtime-protocol/src/index.js +4 -2
  175. package/dist/packages/realtime-protocol/src/voice-audio.js +15 -10
  176. package/dist/packages/realtime-protocol/src/voice-catalog.js +61 -0
  177. package/dist/packages/realtime-protocol/src/voice.js +257 -248
  178. package/dist/src/activity/types.d.ts +1 -1
  179. package/dist/src/agent/agent-instance-gateway.d.ts +18 -18
  180. package/dist/src/agent/agent-manager.d.ts +28 -27
  181. package/dist/src/agent/agent-manager.js +184 -182
  182. package/dist/src/agent/background-review/coordinator.d.ts +3 -3
  183. package/dist/src/agent/background-review/coordinator.js +10 -10
  184. package/dist/src/agent/background-review/run-background-review.d.ts +1 -1
  185. package/dist/src/agent/background-review/run-background-review.js +15 -15
  186. package/dist/src/agent/bootstrap/bootstrap-cache.d.ts +4 -4
  187. package/dist/src/agent/bootstrap/bootstrap-cache.js +9 -9
  188. package/dist/src/agent/bootstrap/bootstrap-files.d.ts +4 -4
  189. package/dist/src/agent/bootstrap/bootstrap-files.js +9 -9
  190. package/dist/src/agent/bootstrap/filter-bootstrap-files.d.ts +1 -1
  191. package/dist/src/agent/bootstrap/filter-bootstrap-files.js +3 -3
  192. package/dist/src/agent/child-agent-factory.d.ts +3 -3
  193. package/dist/src/agent/child-agent-factory.js +5 -5
  194. package/dist/src/agent/coding/workspace-revision.js +1 -1
  195. package/dist/src/agent/commands/command-registry.js +2 -1
  196. package/dist/src/agent/context/audit.d.ts +2 -2
  197. package/dist/src/agent/context/audit.js +5 -4
  198. package/dist/src/agent/context/coordinator.d.ts +6 -6
  199. package/dist/src/agent/context/coordinator.js +13 -13
  200. package/dist/src/agent/context/execution-context.js +4 -3
  201. package/dist/src/agent/context/execution-scope.d.ts +3 -3
  202. package/dist/src/agent/context/execution-scope.js +13 -13
  203. package/dist/src/agent/context/project-context.d.ts +1 -1
  204. package/dist/src/agent/context/project-context.js +4 -4
  205. package/dist/src/agent/embedded/execution-context.d.ts +1 -1
  206. package/dist/src/agent/embedded/execution-context.js +3 -3
  207. package/dist/src/agent/embedded/index.d.ts +1 -1
  208. package/dist/src/agent/embedded/index.js +2 -2
  209. package/dist/src/agent/embedded/model-runtime.js +1 -1
  210. package/dist/src/agent/embedded/run-for-session.d.ts +1 -1
  211. package/dist/src/agent/embedded/run-for-session.js +79 -105
  212. package/dist/src/agent/embedded/run-turn.js +86 -34
  213. package/dist/src/agent/embedded/runs.d.ts +11 -11
  214. package/dist/src/agent/embedded/runs.js +22 -22
  215. package/dist/src/agent/embedded/session-runner.d.ts +2 -2
  216. package/dist/src/agent/embedded/session-runner.js +5 -5
  217. package/dist/src/agent/embedded/session-tool-result-guard.d.ts +2 -2
  218. package/dist/src/agent/embedded/session-tool-result-guard.js +8 -8
  219. package/dist/src/agent/embedded/sqlite-hydrating-session-manager.d.ts +2 -2
  220. package/dist/src/agent/embedded/sqlite-hydrating-session-manager.js +4 -4
  221. package/dist/src/agent/embedded/transcript-runtime.d.ts +4 -3
  222. package/dist/src/agent/embedded/transcript-runtime.js +33 -20
  223. package/dist/src/agent/embedded/types.d.ts +2 -1
  224. package/dist/src/agent/external-tools/composio-provider.d.ts +1 -1
  225. package/dist/src/agent/external-tools/composio-provider.js +12 -11
  226. package/dist/src/agent/external-tools/endpoint-provider.js +5 -3
  227. package/dist/src/agent/external-tools/extension-provider.d.ts +1 -1
  228. package/dist/src/agent/external-tools/extension-provider.js +1 -1
  229. package/dist/src/agent/external-tools/gateway-tools.js +9 -8
  230. package/dist/src/agent/external-tools/index.js +3 -3
  231. package/dist/src/agent/external-tools/mcp-provider.d.ts +2 -2
  232. package/dist/src/agent/external-tools/mcp-provider.js +8 -8
  233. package/dist/src/agent/external-tools/memory-provider.d.ts +1 -1
  234. package/dist/src/agent/external-tools/memory-provider.js +1 -1
  235. package/dist/src/agent/external-tools/types.d.ts +1 -1
  236. package/dist/src/agent/image/tool-model-config.js +1 -1
  237. package/dist/src/agent/inbound/attachment-pipeline.d.ts +7 -7
  238. package/dist/src/agent/inbound/attachment-pipeline.js +22 -21
  239. package/dist/src/agent/inbound/inbound-loop.d.ts +6 -6
  240. package/dist/src/agent/inbound/inbound-loop.js +23 -23
  241. package/dist/src/agent/inbound/turn-dispatcher.d.ts +14 -14
  242. package/dist/src/agent/inbound/turn-dispatcher.js +16 -16
  243. package/dist/src/agent/ipc/bus.d.ts +1 -1
  244. package/dist/src/agent/ipc/types.d.ts +3 -3
  245. package/dist/src/agent/ipc/types.js +1 -1
  246. package/dist/src/agent/lifecycle/hook-handler.d.ts +2 -2
  247. package/dist/src/agent/lifecycle/hook-handler.js +6 -6
  248. package/dist/src/agent/lifecycle/manager.d.ts +1 -1
  249. package/dist/src/agent/lifecycle/manager.js +4 -4
  250. package/dist/src/agent/lifecycle/types.d.ts +1 -1
  251. package/dist/src/agent/mcp/bundle-mcp-runtime.d.ts +4 -4
  252. package/dist/src/agent/mcp/bundle-mcp-runtime.js +21 -20
  253. package/dist/src/agent/mcp/bundle-mcp-tools.d.ts +1 -1
  254. package/dist/src/agent/mcp/bundle-mcp-tools.js +2 -2
  255. package/dist/src/agent/mcp/bundle-mcp-types.d.ts +4 -4
  256. package/dist/src/agent/mcp/index.js +2 -2
  257. package/dist/src/agent/mcp/oauth/mcp-oauth-manager.js +9 -8
  258. package/dist/src/agent/mcp/oauth/mcp-oauth-store.js +1 -1
  259. package/dist/src/agent/memory/compaction-ledger.js +9 -2
  260. package/dist/src/agent/memory/compaction-promotion.d.ts +2 -2
  261. package/dist/src/agent/memory/compaction-promotion.js +6 -6
  262. package/dist/src/agent/memory/compaction-source-planner.d.ts +2 -0
  263. package/dist/src/agent/memory/compaction-source-planner.js +9 -1
  264. package/dist/src/agent/memory/compaction.d.ts +6 -1
  265. package/dist/src/agent/memory/compaction.js +22 -11
  266. package/dist/src/agent/memory/context-recovery.d.ts +44 -0
  267. package/dist/src/agent/memory/context-recovery.js +96 -0
  268. package/dist/src/agent/memory/manager.js +11 -11
  269. package/dist/src/agent/memory/turn-provenance.d.ts +5 -5
  270. package/dist/src/agent/memory/turn-provenance.js +21 -17
  271. package/dist/src/agent/memory/types.d.ts +2 -2
  272. package/dist/src/agent/messaging/command-handler.d.ts +11 -11
  273. package/dist/src/agent/messaging/command-handler.js +7 -7
  274. package/dist/src/agent/messaging/message-router.d.ts +1 -1
  275. package/dist/src/agent/messaging/message-router.js +4 -4
  276. package/dist/src/agent/messaging/outbound-coordinator.d.ts +2 -2
  277. package/dist/src/agent/messaging/outbound-coordinator.js +4 -4
  278. package/dist/src/agent/middleware/context.d.ts +1 -2
  279. package/dist/src/agent/middleware/context.js +2 -5
  280. package/dist/src/agent/models/manager.d.ts +10 -10
  281. package/dist/src/agent/models/manager.js +34 -34
  282. package/dist/src/agent/orchestration/agent-event-handler.js +14 -14
  283. package/dist/src/agent/orchestration/agent-orchestrator.d.ts +7 -7
  284. package/dist/src/agent/orchestration/agent-orchestrator.js +29 -29
  285. package/dist/src/agent/orchestration/context-overflow.js +2 -0
  286. package/dist/src/agent/orchestration/llm-turn-retry.d.ts +1 -1
  287. package/dist/src/agent/orchestration/llm-turn-retry.js +2 -2
  288. package/dist/src/agent/orchestration/run-agent-turn-with-timeout.d.ts +1 -1
  289. package/dist/src/agent/orchestration/run-agent-turn-with-timeout.js +2 -2
  290. package/dist/src/agent/prompt/response-language.d.ts +1 -1
  291. package/dist/src/agent/prompt/response-language.js +2 -2
  292. package/dist/src/agent/prompt/service-prompt-builder.d.ts +2 -2
  293. package/dist/src/agent/prompt/service-prompt-builder.js +4 -4
  294. package/dist/src/agent/prompt/subagent-context.d.ts +4 -4
  295. package/dist/src/agent/prompt/subagent-context.js +1 -1
  296. package/dist/src/agent/prompt/system-prompt-params.d.ts +4 -4
  297. package/dist/src/agent/prompt/system-prompt-params.js +13 -12
  298. package/dist/src/agent/reply/apply-turn-user-enrichment.d.ts +1 -1
  299. package/dist/src/agent/reply/apply-turn-user-enrichment.js +3 -3
  300. package/dist/src/agent/reply/post-compaction-context.d.ts +1 -1
  301. package/dist/src/agent/reply/post-compaction-context.js +2 -2
  302. package/dist/src/agent/service/btw-query.d.ts +1 -1
  303. package/dist/src/agent/service/btw-query.js +4 -4
  304. package/dist/src/agent/service/build-direct-message-content.d.ts +1 -1
  305. package/dist/src/agent/service/build-direct-message-content.js +2 -2
  306. package/dist/src/agent/service/direct-turn-helpers.d.ts +6 -6
  307. package/dist/src/agent/service/direct-turn-helpers.js +17 -16
  308. package/dist/src/agent/service/parse-outbound-session-key.d.ts +1 -1
  309. package/dist/src/agent/service/parse-outbound-session-key.js +8 -9
  310. package/dist/src/agent/service/process-direct-one-shot.d.ts +11 -11
  311. package/dist/src/agent/service/process-direct-one-shot.js +16 -16
  312. package/dist/src/agent/service/process-direct-streaming.d.ts +18 -18
  313. package/dist/src/agent/service/process-direct-streaming.js +45 -40
  314. package/dist/src/agent/service/session-context-report.d.ts +1 -1
  315. package/dist/src/agent/service/session-context-report.js +3 -3
  316. package/dist/src/agent/service/webchat-tts.d.ts +3 -3
  317. package/dist/src/agent/service/webchat-tts.js +7 -7
  318. package/dist/src/agent/service.d.ts +23 -23
  319. package/dist/src/agent/service.js +113 -110
  320. package/dist/src/agent/service.types.d.ts +3 -3
  321. package/dist/src/agent/session/session-config-service.d.ts +5 -5
  322. package/dist/src/agent/session/session-config-service.js +53 -66
  323. package/dist/src/agent/session/session-context.d.ts +2 -2
  324. package/dist/src/agent/session/session-context.js +2 -2
  325. package/dist/src/agent/session/session-hydrator.d.ts +3 -3
  326. package/dist/src/agent/session/session-hydrator.js +19 -19
  327. package/dist/src/agent/session/session-inspector.d.ts +7 -7
  328. package/dist/src/agent/session/session-inspector.js +46 -46
  329. package/dist/src/agent/session/session-lifecycle.d.ts +2 -2
  330. package/dist/src/agent/session/session-lifecycle.js +17 -17
  331. package/dist/src/agent/session/session-state-bag.d.ts +18 -18
  332. package/dist/src/agent/session/session-state-bag.js +46 -46
  333. package/dist/src/agent/session/tracker.d.ts +7 -7
  334. package/dist/src/agent/session/tracker.js +27 -27
  335. package/dist/src/agent/skills/hub-lock.js +1 -1
  336. package/dist/src/agent/skills/index.js +25 -15
  337. package/dist/src/agent/skills/parse-skill-metadata.d.ts +5 -1
  338. package/dist/src/agent/skills/parse-skill-metadata.js +21 -1
  339. package/dist/src/agent/skills/types.d.ts +7 -0
  340. package/dist/src/agent/source-context/types.d.ts +1 -1
  341. package/dist/src/agent/tasks/task-judge-service.d.ts +1 -1
  342. package/dist/src/agent/tasks/task-judge-service.js +14 -13
  343. package/dist/src/agent/tool-manuals/computer.d.ts +1 -0
  344. package/dist/src/agent/tool-manuals/computer.js +19 -0
  345. package/dist/src/agent/tool-manuals/index.js +7 -0
  346. package/dist/src/agent/tools/automation-tool.js +2 -0
  347. package/dist/src/agent/tools/chain-tracker.d.ts +10 -10
  348. package/dist/src/agent/tools/chain-tracker.js +31 -31
  349. package/dist/src/agent/tools/clarify-tool.d.ts +1 -1
  350. package/dist/src/agent/tools/computer-use-tool.d.ts +11 -0
  351. package/dist/src/agent/tools/computer-use-tool.js +86 -0
  352. package/dist/src/agent/tools/create-share-tool.js +2 -0
  353. package/dist/src/agent/tools/delegate-tool.d.ts +1 -1
  354. package/dist/src/agent/tools/delegate-tool.js +4 -4
  355. package/dist/src/agent/tools/exec-command.d.ts +1 -1
  356. package/dist/src/agent/tools/exec-command.js +1 -1
  357. package/dist/src/agent/tools/factory.d.ts +5 -3
  358. package/dist/src/agent/tools/factory.js +66 -36
  359. package/dist/src/agent/tools/knowledge-memory-tool.js +2 -2
  360. package/dist/src/agent/tools/managed-job-tool.d.ts +1 -1
  361. package/dist/src/agent/tools/managed-job-tool.js +2 -2
  362. package/dist/src/agent/tools/publish-artifacts.js +2 -0
  363. package/dist/src/agent/tools/send-media.js +2 -0
  364. package/dist/src/agent/tools/session-recall-tool.d.ts +1 -1
  365. package/dist/src/agent/tools/session-recall-tool.js +3 -3
  366. package/dist/src/agent/tools/session-search-tool.d.ts +1 -1
  367. package/dist/src/agent/tools/session-search-tool.js +6 -6
  368. package/dist/src/agent/tools/skill-install-tool.d.ts +3 -3
  369. package/dist/src/agent/tools/skill-install-tool.js +3 -3
  370. package/dist/src/agent/tools/todo-tool.d.ts +3 -3
  371. package/dist/src/agent/tools/todo-tool.js +4 -4
  372. package/dist/src/agent/tools/workflow-tool.d.ts +1 -1
  373. package/dist/src/agent/tools/workflow-tool.js +15 -13
  374. package/dist/src/agent/tools/write.js +2 -0
  375. package/dist/src/agent/tools/xopc-use-tool.d.ts +1 -1
  376. package/dist/src/agent/tools/xopc-use-tool.js +16 -13
  377. package/dist/src/agent/types.d.ts +1 -1
  378. package/dist/src/agent/workflow/catalog.js +4 -2
  379. package/dist/src/agent/workflow/channel-capability.d.ts +2 -2
  380. package/dist/src/agent/workflow/progress-broker.d.ts +4 -4
  381. package/dist/src/agent/workflow/progress-broker.js +17 -17
  382. package/dist/src/agent/workflow/subagent-runner.js +10 -10
  383. package/dist/src/agent/workflow/types.d.ts +2 -2
  384. package/dist/src/agent/workflow/workflow-child-tools.js +1 -1
  385. package/dist/src/agent/workspace-runtime/registry.js +1 -1
  386. package/dist/src/agent-config/index.js +2 -2
  387. package/dist/src/agent-config/resolver.js +5 -0
  388. package/dist/src/agent-config/schema.d.ts +32 -0
  389. package/dist/src/agent-config/schema.js +5 -2
  390. package/dist/src/ai-assist/text-assist.js +1 -1
  391. package/dist/src/auth/credentials.js +2 -2
  392. package/dist/src/auth/oauth/xopc-cloud.js +1 -1
  393. package/dist/src/auth/profiles/store.js +1 -1
  394. package/dist/src/auth/sync-provider-auth.js +2 -2
  395. package/dist/src/automations/domain/types.d.ts +7 -7
  396. package/dist/src/automations/domain/validation.js +2 -0
  397. package/dist/src/automations/service/action-executor.js +15 -15
  398. package/dist/src/automations/service/automation-service.js +4 -3
  399. package/dist/src/automations/storage/automation-repository.js +2 -1
  400. package/dist/src/automations/storage/automation-run-repository.js +9 -8
  401. package/dist/src/browser/native-messaging-host.js +4 -1
  402. package/dist/src/browser/policy/approval-store.d.ts +4 -4
  403. package/dist/src/browser/policy/approval-store.js +8 -8
  404. package/dist/src/browser/providers/browser-ext-install.js +1 -1
  405. package/dist/src/browser/providers/extension.js +6 -6
  406. package/dist/src/browser/providers/realtime-extension.js +2 -2
  407. package/dist/src/browser/runtime/browser-runtime.js +3 -3
  408. package/dist/src/capabilities/readiness/from-config.js +14 -2
  409. package/dist/src/capabilities/readiness/planner.js +3 -2
  410. package/dist/src/capabilities/readiness/types.d.ts +1 -1
  411. package/dist/src/channels/exec-approval-runtime.d.ts +1 -1
  412. package/dist/src/channels/manager.js +1 -1
  413. package/dist/src/channels/pipeline.js +2 -2
  414. package/dist/src/channels/plugin-types.d.ts +2 -2
  415. package/dist/src/channels/plugins/types.adapters.d.ts +1 -1
  416. package/dist/src/channels/telegram/index.d.ts +1 -1
  417. package/dist/src/channels/telegram/index.js +2 -2
  418. package/dist/src/chat-commands/agent-edit.js +2 -2
  419. package/dist/src/chat-commands/builtins/review.js +4 -4
  420. package/dist/src/chat-commands/builtins/session.js +1 -1
  421. package/dist/src/chat-commands/builtins/system.js +2 -2
  422. package/dist/src/chat-commands/builtins/thinking.js +7 -7
  423. package/dist/src/chat-commands/builtins/understanding.js +4 -4
  424. package/dist/src/chat-commands/builtins/workflow.js +8 -8
  425. package/dist/src/chat-commands/context.d.ts +9 -9
  426. package/dist/src/chat-commands/context.js +35 -35
  427. package/dist/src/chat-commands/index.d.ts +1 -1
  428. package/dist/src/chat-commands/index.js +2 -2
  429. package/dist/src/chat-commands/processor.js +2 -2
  430. package/dist/src/chat-commands/registry.js +1 -1
  431. package/dist/src/chat-commands/session-key.d.ts +3 -3
  432. package/dist/src/chat-commands/session-key.js +20 -24
  433. package/dist/src/chat-commands/types.d.ts +3 -3
  434. package/dist/src/cli/command-manifest.js +1 -1
  435. package/dist/src/cli/commands/agent/interactive.d.ts +1 -1
  436. package/dist/src/cli/commands/agent/interactive.js +8 -8
  437. package/dist/src/cli/commands/agent/stream-renderer.d.ts +1 -1
  438. package/dist/src/cli/commands/agent/stream-renderer.js +2 -2
  439. package/dist/src/cli/commands/agent.js +10 -6
  440. package/dist/src/cli/commands/doctor/checks/database-schema.js +3 -2
  441. package/dist/src/cli/commands/doctor/checks/provider-auth.js +3 -3
  442. package/dist/src/cli/commands/doctor/checks/session-integrity.js +9 -9
  443. package/dist/src/cli/commands/gateway/lifecycle.js +1 -1
  444. package/dist/src/cli/commands/gateway/run-foreground.js +2 -1
  445. package/dist/src/cli/commands/import.js +2 -1
  446. package/dist/src/cli/commands/logs.js +3 -3
  447. package/dist/src/cli/commands/models.js +1 -1
  448. package/dist/src/cli/commands/project.js +5 -5
  449. package/dist/src/cli/commands/resume.js +4 -4
  450. package/dist/src/cli/commands/tunnel.js +2 -1
  451. package/dist/src/computer/broker.d.ts +97 -0
  452. package/dist/src/computer/broker.js +337 -0
  453. package/dist/src/computer/config.d.ts +9 -0
  454. package/dist/src/computer/config.js +16 -0
  455. package/dist/src/computer/control-guard.d.ts +4 -0
  456. package/dist/src/computer/control-guard.js +17 -0
  457. package/dist/src/computer/errors.d.ts +7 -0
  458. package/dist/src/computer/errors.js +30 -0
  459. package/dist/src/computer/model-adapter.d.ts +44 -0
  460. package/dist/src/computer/model-adapter.js +273 -0
  461. package/dist/src/computer/model-config.d.ts +3 -0
  462. package/dist/src/computer/model-config.js +27 -0
  463. package/dist/src/computer/model-policy.d.ts +3 -0
  464. package/dist/src/computer/model-policy.js +20 -0
  465. package/dist/src/computer/runtime.d.ts +128 -0
  466. package/dist/src/computer/runtime.js +388 -0
  467. package/dist/src/config/agent-profile.d.ts +3 -3
  468. package/dist/src/config/agent-profile.js +12 -12
  469. package/dist/src/config/index.js +4 -4
  470. package/dist/src/config/loader.js +2 -2
  471. package/dist/src/config/models-json.d.ts +42 -6
  472. package/dist/src/config/models-json.js +15 -1
  473. package/dist/src/config/schema.d.ts +38 -1
  474. package/dist/src/config/schema.js +11 -2
  475. package/dist/src/config/voice.js +2 -2
  476. package/dist/src/connectors/catalog.js +2 -1
  477. package/dist/src/connectors/composio-sessions.d.ts +1 -1
  478. package/dist/src/connectors/composio-sessions.js +3 -3
  479. package/dist/src/connectors/connection-recovery-service.d.ts +4 -4
  480. package/dist/src/connectors/connection-recovery-service.js +41 -37
  481. package/dist/src/connectors/principal.d.ts +1 -1
  482. package/dist/src/connectors/principal.js +4 -3
  483. package/dist/src/connectors/types.d.ts +2 -2
  484. package/dist/src/discussions/action-tasks.js +5 -2
  485. package/dist/src/discussions/analyzer.js +2 -1
  486. package/dist/src/discussions/edits.js +4 -2
  487. package/dist/src/discussions/index.js +1 -1
  488. package/dist/src/discussions/organizer.js +3 -2
  489. package/dist/src/discussions/recording.js +5 -2
  490. package/dist/src/discussions/recordingJobs.js +2 -1
  491. package/dist/src/discussions/repository.js +2 -1
  492. package/dist/src/discussions/revisions.js +2 -1
  493. package/dist/src/discussions/sealer.js +1 -1
  494. package/dist/src/discussions/service.js +6 -3
  495. package/dist/src/discussions/types.js +4 -0
  496. package/dist/src/endpoint-tools/auth.js +2 -1
  497. package/dist/src/endpoint-tools/binding-service.d.ts +8 -8
  498. package/dist/src/endpoint-tools/binding-service.js +14 -14
  499. package/dist/src/endpoint-tools/invocation-service.d.ts +1 -0
  500. package/dist/src/endpoint-tools/invocation-service.js +7 -3
  501. package/dist/src/endpoint-tools/policy.js +9 -1
  502. package/dist/src/endpoint-tools/registry.js +2 -1
  503. package/dist/src/endpoint-tools/runtime.js +1 -0
  504. package/dist/src/endpoint-tools/upload-service.d.ts +13 -1
  505. package/dist/src/endpoint-tools/upload-service.js +75 -9
  506. package/dist/src/execution-environments/local-worktree-manager.d.ts +1 -1
  507. package/dist/src/execution-environments/local-worktree-manager.js +2 -2
  508. package/dist/src/execution-environments/session-environment-service.d.ts +3 -3
  509. package/dist/src/execution-environments/session-environment-service.js +10 -10
  510. package/dist/src/execution-environments/store.d.ts +2 -2
  511. package/dist/src/execution-environments/store.js +15 -14
  512. package/dist/src/execution-environments/subject.d.ts +1 -1
  513. package/dist/src/execution-environments/subject.js +2 -2
  514. package/dist/src/execution-environments/types.d.ts +2 -2
  515. package/dist/src/extensions/api.js +1 -1
  516. package/dist/src/extensions/install.js +1 -1
  517. package/dist/src/extensions/loader.d.ts +1 -1
  518. package/dist/src/extensions/lockfile.js +1 -1
  519. package/dist/src/extensions/types/core.d.ts +2 -2
  520. package/dist/src/extensions/types/hooks.d.ts +12 -12
  521. package/dist/src/extensions/types/tools.d.ts +3 -3
  522. package/dist/src/extensions/types/tui.d.ts +3 -3
  523. package/dist/src/files/file-service.d.ts +3 -3
  524. package/dist/src/files/file-service.js +3 -3
  525. package/dist/src/gateway/agent-builtin-tools.d.ts +7 -1
  526. package/dist/src/gateway/agent-builtin-tools.js +7 -0
  527. package/dist/src/gateway/agents-admin.js +1 -1
  528. package/dist/src/gateway/automation-agent-session.js +5 -5
  529. package/dist/src/gateway/chat-stream/mapper.d.ts +1 -1
  530. package/dist/src/gateway/chat-stream/mapper.js +4 -2
  531. package/dist/src/gateway/chat-stream/protocol.d.ts +1 -1
  532. package/dist/src/gateway/chat-stream/thinking-delta-coalescer.js +1 -1
  533. package/dist/src/gateway/clarify-runtime.d.ts +2 -2
  534. package/dist/src/gateway/clarify-runtime.js +2 -2
  535. package/dist/src/gateway/file-path-classifier.d.ts +2 -2
  536. package/dist/src/gateway/file-path-classifier.js +5 -5
  537. package/dist/src/gateway/file-reference-registry.d.ts +2 -2
  538. package/dist/src/gateway/file-reference-registry.js +1 -1
  539. package/dist/src/gateway/file-space-service.js +3 -3
  540. package/dist/src/gateway/gateway-workflow-host.types.d.ts +1 -1
  541. package/dist/src/gateway/global-defaults-admin.js +16 -0
  542. package/dist/src/gateway/heartbeat/check-store.js +2 -1
  543. package/dist/src/gateway/heartbeat/service.js +23 -9
  544. package/dist/src/gateway/hono/lib/config-payload.d.ts +15 -0
  545. package/dist/src/gateway/hono/lib/config-payload.js +2 -1
  546. package/dist/src/gateway/hono/middleware/log-context.d.ts +1 -1
  547. package/dist/src/gateway/hono/middleware/log-context.js +3 -3
  548. package/dist/src/gateway/hono/routes/agent-stream.js +20 -20
  549. package/dist/src/gateway/hono/routes/browser-session.js +2 -2
  550. package/dist/src/gateway/hono/routes/browser.js +22 -20
  551. package/dist/src/gateway/hono/routes/chat-model-config.d.ts +1 -1
  552. package/dist/src/gateway/hono/routes/chat-model-config.js +6 -6
  553. package/dist/src/gateway/hono/routes/commands-skills.js +13 -13
  554. package/dist/src/gateway/hono/routes/config-patch/misc.js +13 -2
  555. package/dist/src/gateway/hono/routes/connection-waits.js +5 -5
  556. package/dist/src/gateway/hono/routes/connectors.js +5 -5
  557. package/dist/src/gateway/hono/routes/context-sources.js +2 -1
  558. package/dist/src/gateway/hono/routes/device-pairing-approval.js +2 -0
  559. package/dist/src/gateway/hono/routes/devices.js +2 -0
  560. package/dist/src/gateway/hono/routes/discussions.js +2 -2
  561. package/dist/src/gateway/hono/routes/endpoint-tools.js +11 -9
  562. package/dist/src/gateway/hono/routes/execution-environments.js +11 -11
  563. package/dist/src/gateway/hono/routes/file-references.js +5 -5
  564. package/dist/src/gateway/hono/routes/home.js +1 -1
  565. package/dist/src/gateway/hono/routes/interaction-state.js +6 -6
  566. package/dist/src/gateway/hono/routes/logs.js +2 -2
  567. package/dist/src/gateway/hono/routes/media.js +3 -3
  568. package/dist/src/gateway/hono/routes/models.js +6 -3
  569. package/dist/src/gateway/hono/routes/notes.js +11 -11
  570. package/dist/src/gateway/hono/routes/projects.js +26 -26
  571. package/dist/src/gateway/hono/routes/public-gateway.js +3 -3
  572. package/dist/src/gateway/hono/routes/session-input-handler.d.ts +10 -10
  573. package/dist/src/gateway/hono/routes/session-input-handler.js +20 -17
  574. package/dist/src/gateway/hono/routes/sessions.js +79 -50
  575. package/dist/src/gateway/hono/routes/shares.js +38 -38
  576. package/dist/src/gateway/hono/routes/side-chats.js +4 -2
  577. package/dist/src/gateway/hono/routes/site-shares.js +6 -6
  578. package/dist/src/gateway/hono/routes/tasks.js +18 -13
  579. package/dist/src/gateway/hono/routes/tui.js +2 -2
  580. package/dist/src/gateway/hono/routes/user-model.js +1 -1
  581. package/dist/src/gateway/hono/routes/voice.js +56 -2
  582. package/dist/src/gateway/hono/routes/workflows.js +7 -7
  583. package/dist/src/gateway/media-access.d.ts +1 -1
  584. package/dist/src/gateway/media-access.js +3 -3
  585. package/dist/src/gateway/resolve-webchat-session-key.d.ts +5 -5
  586. package/dist/src/gateway/resolve-webchat-session-key.js +5 -5
  587. package/dist/src/gateway/security/gateway-scopes.d.ts +1 -1
  588. package/dist/src/gateway/security/gateway-scopes.js +3 -0
  589. package/dist/src/gateway/service/agent-runner.d.ts +15 -15
  590. package/dist/src/gateway/service/agent-runner.js +63 -62
  591. package/dist/src/gateway/service/config-coordinator.js +4 -1
  592. package/dist/src/gateway/service/marketplace-service.d.ts +3 -3
  593. package/dist/src/gateway/service/marketplace-service.js +6 -6
  594. package/dist/src/gateway/service/run-gateway-agent.js +51 -49
  595. package/dist/src/gateway/service/session-input-coordinator.d.ts +11 -11
  596. package/dist/src/gateway/service/session-input-coordinator.js +76 -74
  597. package/dist/src/gateway/service/sessions-api.d.ts +19 -20
  598. package/dist/src/gateway/service/sessions-api.js +30 -38
  599. package/dist/src/gateway/service/task-conversation-query-service.d.ts +3 -2
  600. package/dist/src/gateway/service/task-conversation-query-service.js +3 -3
  601. package/dist/src/gateway/service.d.ts +4 -4
  602. package/dist/src/gateway/service.js +76 -70
  603. package/dist/src/gateway/session-context-summary.d.ts +1 -1
  604. package/dist/src/gateway/session-context-summary.js +13 -11
  605. package/dist/src/gateway/session-reset-service.d.ts +4 -4
  606. package/dist/src/gateway/session-reset-service.js +12 -12
  607. package/dist/src/gateway/side-chat/context-snapshot.d.ts +2 -2
  608. package/dist/src/gateway/side-chat/context-snapshot.js +2 -2
  609. package/dist/src/gateway/side-chat/manager.d.ts +4 -4
  610. package/dist/src/gateway/side-chat/manager.js +13 -13
  611. package/dist/src/gateway/side-chat/run-service.js +8 -8
  612. package/dist/src/gateway/side-chat/types.d.ts +4 -4
  613. package/dist/src/heartbeat/index.js +1 -1
  614. package/dist/src/heartbeat/wake.d.ts +1 -1
  615. package/dist/src/history/ctx/exporter.js +11 -11
  616. package/dist/src/history/ctx/format.d.ts +1 -1
  617. package/dist/src/history/ctx/format.js +7 -7
  618. package/dist/src/imports/contextImport.js +2 -1
  619. package/dist/src/imports/productImport.js +2 -1
  620. package/dist/src/infra/node-sqlite.js +9 -3
  621. package/dist/src/infra/process-diagnostics.js +9 -5
  622. package/dist/src/infra/sqlite-errors.js +25 -20
  623. package/dist/src/infra/unhandled-rejections.js +15 -7
  624. package/dist/src/infra/update-restart.js +1 -1
  625. package/dist/src/infra/warning-filter.js +9 -3
  626. package/dist/src/knowledge-memory/domain.d.ts +2 -2
  627. package/dist/src/knowledge-memory/repository.d.ts +1 -1
  628. package/dist/src/knowledge-memory/repository.js +10 -8
  629. package/dist/src/mcp/channel-bridge.d.ts +3 -3
  630. package/dist/src/mcp/channel-bridge.js +7 -7
  631. package/dist/src/mcp/channel-shared.d.ts +4 -4
  632. package/dist/src/mcp/channel-shared.js +3 -3
  633. package/dist/src/mcp/channel-tools.js +19 -19
  634. package/dist/src/media/session-references.js +2 -2
  635. package/dist/src/memory-maintenance/service.js +2 -1
  636. package/dist/src/migrations/conversation-routing-config.d.ts +2 -0
  637. package/dist/src/migrations/conversation-routing-config.js +42 -0
  638. package/dist/src/migrations/runner.js +6 -5
  639. package/dist/src/notes/service.d.ts +2 -2
  640. package/dist/src/notes/service.js +6 -6
  641. package/dist/src/notes/store.js +2 -1
  642. package/dist/src/notes/types.d.ts +3 -3
  643. package/dist/src/notifications/device-store.js +2 -1
  644. package/dist/src/notifications/planner.js +5 -3
  645. package/dist/src/notifications/proactive-channel.js +4 -1
  646. package/dist/src/notifications/proactive-policy.js +2 -1
  647. package/dist/src/notifications/service.d.ts +4 -4
  648. package/dist/src/notifications/service.js +4 -1
  649. package/dist/src/notifications/store.js +4 -1
  650. package/dist/src/notifications/web-push.js +4 -1
  651. package/dist/src/platform/contracts.d.ts +3 -3
  652. package/dist/src/proactive/actions/service.js +2 -1
  653. package/dist/src/proactive/events/product-event-bridge.js +1 -1
  654. package/dist/src/proactive/events/repository.js +2 -1
  655. package/dist/src/proactive/execution/authorization.js +2 -1
  656. package/dist/src/proactive/execution/context.js +2 -1
  657. package/dist/src/proactive/execution/insight.js +2 -0
  658. package/dist/src/proactive/execution/repository.js +2 -1
  659. package/dist/src/proactive/execution/worker.js +3 -2
  660. package/dist/src/proactive/experience.d.ts +1 -1
  661. package/dist/src/proactive/experience.js +4 -3
  662. package/dist/src/proactive/follow-ups.d.ts +7 -7
  663. package/dist/src/proactive/follow-ups.js +5 -4
  664. package/dist/src/proactive/inbox/cards.js +5 -2
  665. package/dist/src/proactive/inbox/delivery.js +2 -1
  666. package/dist/src/proactive/inbox/digest.js +2 -1
  667. package/dist/src/proactive/inbox/lifecycle.js +2 -1
  668. package/dist/src/proactive/inbox/repository.js +2 -1
  669. package/dist/src/proactive/inbox/service.js +2 -1
  670. package/dist/src/proactive/mail-thread.js +2 -1
  671. package/dist/src/proactive/maintenance.js +2 -1
  672. package/dist/src/proactive/metrics.js +2 -1
  673. package/dist/src/proactive/policy/presence.js +2 -1
  674. package/dist/src/proactive/policy/service.js +4 -1
  675. package/dist/src/proactive/routing/batch-repository.js +2 -1
  676. package/dist/src/proactive/scenarios/control.js +4 -1
  677. package/dist/src/proactive/scenarios/repository.js +2 -1
  678. package/dist/src/proactive/service.js +2 -1
  679. package/dist/src/proactive/source-freshness.js +2 -1
  680. package/dist/src/proactive/status.js +2 -1
  681. package/dist/src/proactive/temporal/schedule.js +2 -1
  682. package/dist/src/projects/automation-bind.js +2 -1
  683. package/dist/src/projects/index.js +2 -2
  684. package/dist/src/projects/knowledge-bind.js +2 -1
  685. package/dist/src/projects/project-agent.js +4 -1
  686. package/dist/src/projects/project-service.d.ts +4 -4
  687. package/dist/src/projects/project-service.js +11 -10
  688. package/dist/src/projects/project-store.js +11 -9
  689. package/dist/src/projects/session-bind.d.ts +5 -5
  690. package/dist/src/projects/session-bind.js +18 -17
  691. package/dist/src/projects/types.d.ts +1 -1
  692. package/dist/src/projects/workflow-bind.js +2 -1
  693. package/dist/src/projects/workspace.d.ts +3 -3
  694. package/dist/src/projects/workspace.js +6 -6
  695. package/dist/src/providers/auth-runtime/resolve-auth.js +1 -1
  696. package/dist/src/providers/index.js +2 -2
  697. package/dist/src/providers/model-catalog-persistence.js +11 -2
  698. package/dist/src/providers/model-catalog-store.js +1 -0
  699. package/dist/src/providers/model-catalog-types.d.ts +7 -2
  700. package/dist/src/providers/model-reference-auditor.js +7 -4
  701. package/dist/src/providers/model-registry.js +4 -1
  702. package/dist/src/providers/model-supplements.js +18 -2
  703. package/dist/src/providers/presentation.js +4 -2
  704. package/dist/src/providers/prompt-cache-lifecycle.d.ts +2 -2
  705. package/dist/src/providers/prompt-cache-lifecycle.js +6 -6
  706. package/dist/src/providers/register-runtime-providers.js +1 -1
  707. package/dist/src/providers/xopc-cloud-model-source.js +10 -4
  708. package/dist/src/realtime/broker.js +3 -3
  709. package/dist/src/realtime/runtime.js +1 -1
  710. package/dist/src/retrieval/queryProfile.d.ts +1 -1
  711. package/dist/src/routing/agent-session-key.d.ts +12 -41
  712. package/dist/src/routing/agent-session-key.js +39 -120
  713. package/dist/src/routing/conversation-route.d.ts +28 -0
  714. package/dist/src/routing/conversation-route.js +50 -0
  715. package/dist/src/routing/index.d.ts +2 -2
  716. package/dist/src/routing/index.js +5 -5
  717. package/dist/src/routing/resolve-route.d.ts +4 -9
  718. package/dist/src/routing/resolve-route.js +20 -60
  719. package/dist/src/routing/resolve-tui-session-key.d.ts +5 -13
  720. package/dist/src/routing/resolve-tui-session-key.js +11 -36
  721. package/dist/src/routing/session-key.d.ts +6 -39
  722. package/dist/src/routing/session-key.js +13 -161
  723. package/dist/src/session/client-history.js +2 -0
  724. package/dist/src/session/compaction-types.js +18 -13
  725. package/dist/src/session/config-store.d.ts +8 -8
  726. package/dist/src/session/config-store.js +19 -19
  727. package/dist/src/session/index.d.ts +2 -2
  728. package/dist/src/session/index.js +9 -5
  729. package/dist/src/session/init-session-turn.d.ts +7 -7
  730. package/dist/src/session/init-session-turn.js +18 -18
  731. package/dist/src/session/manager.d.ts +7 -7
  732. package/dist/src/session/manager.js +6 -6
  733. package/dist/src/session/model-config-lock.d.ts +1 -1
  734. package/dist/src/session/model-config-lock.js +4 -4
  735. package/dist/src/session/resolve-session.d.ts +10 -10
  736. package/dist/src/session/resolve-session.js +20 -20
  737. package/dist/src/session/session-context-for-llm.js +17 -10
  738. package/dist/src/session/session-title.d.ts +5 -5
  739. package/dist/src/session/session-title.js +28 -28
  740. package/dist/src/session/session-workspace.d.ts +1 -1
  741. package/dist/src/session/session-workspace.js +3 -3
  742. package/dist/src/session/store.d.ts +14 -14
  743. package/dist/src/session/store.js +70 -50
  744. package/dist/src/session/stored-rows-to-file-entries.d.ts +1 -1
  745. package/dist/src/session/stored-rows-to-file-entries.js +5 -3
  746. package/dist/src/session/thinking-resolve.d.ts +2 -2
  747. package/dist/src/session/thinking-resolve.js +4 -4
  748. package/dist/src/session/transcript-events.d.ts +1 -1
  749. package/dist/src/session/transcript-events.js +3 -3
  750. package/dist/src/session/transcript-outline.js +2 -1
  751. package/dist/src/session/turn-outcome-projector.js +2 -0
  752. package/dist/src/session/types.d.ts +5 -4
  753. package/dist/src/session/types.js +13 -9
  754. package/dist/src/session/user-message-display.js +2 -0
  755. package/dist/src/session/user-round-delete.js +2 -1
  756. package/dist/src/session/voice-transcript.js +8 -3
  757. package/dist/src/share/hosted-session-share.d.ts +6 -6
  758. package/dist/src/share/hosted-session-share.js +13 -11
  759. package/dist/src/share/hosted-static-site-publish.d.ts +1 -1
  760. package/dist/src/share/hosted-static-site-publish.js +1 -1
  761. package/dist/src/share/session-share-service.d.ts +9 -9
  762. package/dist/src/share/session-share-service.js +19 -19
  763. package/dist/src/share/share-store.d.ts +2 -2
  764. package/dist/src/share/share-store.js +9 -7
  765. package/dist/src/share/share-types.d.ts +2 -2
  766. package/dist/src/share/site-share-router.d.ts +2 -2
  767. package/dist/src/share/site-share-store.js +4 -2
  768. package/dist/src/share/site-share-types.d.ts +1 -1
  769. package/dist/src/storage/sqlite/activity-repository.js +2 -1
  770. package/dist/src/storage/sqlite/browser-session-repository.js +2 -1
  771. package/dist/src/storage/sqlite/browser-tab-binding-repository.d.ts +2 -2
  772. package/dist/src/storage/sqlite/browser-tab-binding-repository.js +10 -9
  773. package/dist/src/storage/sqlite/clarification-wait-repository.d.ts +7 -7
  774. package/dist/src/storage/sqlite/clarification-wait-repository.js +58 -53
  775. package/dist/src/storage/sqlite/collaboration-rule-repository.js +2 -1
  776. package/dist/src/storage/sqlite/composer-input-history-repository.js +2 -1
  777. package/dist/src/storage/sqlite/config-repository.d.ts +6 -6
  778. package/dist/src/storage/sqlite/config-repository.js +29 -25
  779. package/dist/src/storage/sqlite/connection-wait-repository.d.ts +11 -11
  780. package/dist/src/storage/sqlite/connection-wait-repository.js +61 -51
  781. package/dist/src/storage/sqlite/connection.js +28 -18
  782. package/dist/src/storage/sqlite/connector-account-repository.js +2 -1
  783. package/dist/src/storage/sqlite/connector-learning-repository.js +2 -1
  784. package/dist/src/storage/sqlite/connector-repository.d.ts +1 -1
  785. package/dist/src/storage/sqlite/connector-repository.js +11 -10
  786. package/dist/src/storage/sqlite/connector-sync-policy-repository.js +2 -1
  787. package/dist/src/storage/sqlite/context-evidence-repository.d.ts +1 -1
  788. package/dist/src/storage/sqlite/context-evidence-repository.js +7 -6
  789. package/dist/src/storage/sqlite/context-extraction-repository.js +2 -1
  790. package/dist/src/storage/sqlite/context-relation-repository.js +2 -1
  791. package/dist/src/storage/sqlite/conversation-repository.d.ts +12 -0
  792. package/dist/src/storage/sqlite/conversation-repository.js +76 -0
  793. package/dist/src/storage/sqlite/device-access-repository.js +4 -1
  794. package/dist/src/storage/sqlite/device-pairing-approval.js +4 -1
  795. package/dist/src/storage/sqlite/device-pairing-repository.js +2 -1
  796. package/dist/src/storage/sqlite/durable-queue.js +4 -2
  797. package/dist/src/storage/sqlite/durable-state.js +4 -2
  798. package/dist/src/storage/sqlite/endpoint-principal-repository.js +2 -1
  799. package/dist/src/storage/sqlite/endpoint-session-binding-repository.d.ts +3 -3
  800. package/dist/src/storage/sqlite/endpoint-session-binding-repository.js +12 -11
  801. package/dist/src/storage/sqlite/endpoint-tool-invocation-repository.js +2 -1
  802. package/dist/src/storage/sqlite/fts.js +39 -34
  803. package/dist/src/storage/sqlite/gateway-identity-repository.js +2 -1
  804. package/dist/src/storage/sqlite/home-attention-repository.js +2 -1
  805. package/dist/src/storage/sqlite/import-repository.js +2 -1
  806. package/dist/src/storage/sqlite/import-selection-repository.js +2 -1
  807. package/dist/src/storage/sqlite/index.d.ts +2 -2
  808. package/dist/src/storage/sqlite/index.js +25 -11
  809. package/dist/src/storage/sqlite/interaction-state-repository.d.ts +4 -4
  810. package/dist/src/storage/sqlite/interaction-state-repository.js +12 -11
  811. package/dist/src/storage/sqlite/knowledge-repository.js +2 -1
  812. package/dist/src/storage/sqlite/migrations/178_conversation_uuid.sql +2 -0
  813. package/dist/src/storage/sqlite/migrations/conversation-backup.d.ts +11 -0
  814. package/dist/src/storage/sqlite/migrations/conversation-backup.js +98 -0
  815. package/dist/src/storage/sqlite/migrations/conversation-key-decoder.d.ts +8 -0
  816. package/dist/src/storage/sqlite/migrations/conversation-key-decoder.js +87 -0
  817. package/dist/src/storage/sqlite/migrations/conversation-uuid.d.ts +8 -0
  818. package/dist/src/storage/sqlite/migrations/conversation-uuid.js +366 -0
  819. package/dist/src/storage/sqlite/migrations/conversation-windows-owners.d.ts +1 -0
  820. package/dist/src/storage/sqlite/migrations/conversation-windows-owners.js +95 -0
  821. package/dist/src/storage/sqlite/migrations/discover.js +9 -5
  822. package/dist/src/storage/sqlite/migrations/errors.d.ts +5 -0
  823. package/dist/src/storage/sqlite/migrations/errors.js +38 -23
  824. package/dist/src/storage/sqlite/migrations/runner.d.ts +2 -2
  825. package/dist/src/storage/sqlite/migrations/runner.js +44 -14
  826. package/dist/src/storage/sqlite/migrations/types.d.ts +1 -1
  827. package/dist/src/storage/sqlite/note-agent-context-repository.js +2 -1
  828. package/dist/src/storage/sqlite/notes-repository.js +4 -2
  829. package/dist/src/storage/sqlite/paths.js +6 -2
  830. package/dist/src/storage/sqlite/relationship-settings-repository.js +2 -1
  831. package/dist/src/storage/sqlite/row-mappers.d.ts +10 -10
  832. package/dist/src/storage/sqlite/row-mappers.js +22 -15
  833. package/dist/src/storage/sqlite/schema-version.js +7 -2
  834. package/dist/src/storage/sqlite/schema.js +16 -8
  835. package/dist/src/storage/sqlite/schema.sql +2641 -526
  836. package/dist/src/storage/sqlite/session-identity-sql.js +12 -5
  837. package/dist/src/storage/sqlite/session-input-repository.d.ts +14 -14
  838. package/dist/src/storage/sqlite/session-input-repository.js +69 -61
  839. package/dist/src/storage/sqlite/session-instance-repository.d.ts +1 -1
  840. package/dist/src/storage/sqlite/session-instance-repository.js +6 -3
  841. package/dist/src/storage/sqlite/session-metadata.d.ts +2 -2
  842. package/dist/src/storage/sqlite/session-metadata.js +7 -3
  843. package/dist/src/storage/sqlite/session-repository.d.ts +15 -15
  844. package/dist/src/storage/sqlite/session-repository.js +126 -102
  845. package/dist/src/storage/sqlite/session-task-plan-repository.d.ts +3 -3
  846. package/dist/src/storage/sqlite/session-task-plan-repository.js +21 -19
  847. package/dist/src/storage/sqlite/session-turn-replace-repository.d.ts +2 -2
  848. package/dist/src/storage/sqlite/session-turn-replace-repository.js +26 -22
  849. package/dist/src/storage/sqlite/transaction.js +12 -6
  850. package/dist/src/storage/sqlite/transcript-repository.d.ts +14 -14
  851. package/dist/src/storage/sqlite/transcript-repository.js +107 -102
  852. package/dist/src/storage/sqlite/user-people-repository.js +2 -1
  853. package/dist/src/storage/sqlite/user-trust-repository.js +2 -1
  854. package/dist/src/support/collect-support-report.js +7 -7
  855. package/dist/src/support/types.d.ts +2 -2
  856. package/dist/src/support/types.js +1 -1
  857. package/dist/src/tasks/execution-context.d.ts +2 -2
  858. package/dist/src/tasks/execution-context.js +3 -3
  859. package/dist/src/tasks/home-query-service.d.ts +2 -2
  860. package/dist/src/tasks/home-query-service.js +6 -6
  861. package/dist/src/tasks/index.js +6 -2
  862. package/dist/src/tasks/project-monitoring-service.js +2 -1
  863. package/dist/src/tasks/project-operating-view-service.js +2 -1
  864. package/dist/src/tasks/task-application-service.js +9 -4
  865. package/dist/src/tasks/task-change-events.js +7 -2
  866. package/dist/src/tasks/task-context-assembler.d.ts +2 -2
  867. package/dist/src/tasks/task-context-assembler.js +12 -9
  868. package/dist/src/tasks/task-context-repository.d.ts +1 -1
  869. package/dist/src/tasks/task-context-repository.js +4 -3
  870. package/dist/src/tasks/task-conversation-repository.d.ts +7 -7
  871. package/dist/src/tasks/task-conversation-repository.js +27 -26
  872. package/dist/src/tasks/task-deletion-service.js +2 -1
  873. package/dist/src/tasks/task-dependency-service.js +2 -1
  874. package/dist/src/tasks/task-handoff-service.d.ts +2 -2
  875. package/dist/src/tasks/task-handoff-service.js +16 -15
  876. package/dist/src/tasks/task-outbox-dispatcher.js +2 -1
  877. package/dist/src/tasks/task-read-model-projector.js +4 -2
  878. package/dist/src/tasks/task-repository.js +2 -1
  879. package/dist/src/tasks/task-run-coordinator.js +6 -5
  880. package/dist/src/tasks/task-run-dispatcher.d.ts +1 -1
  881. package/dist/src/tasks/task-run-dispatcher.js +4 -3
  882. package/dist/src/tasks/task-run-repository.d.ts +2 -2
  883. package/dist/src/tasks/task-run-repository.js +219 -212
  884. package/dist/src/tasks/task-signal-service.js +6 -2
  885. package/dist/src/tasks/task-workflow-coordinator.js +2 -1
  886. package/dist/src/tui/backends/embedded-backend.d.ts +33 -32
  887. package/dist/src/tui/backends/embedded-backend.js +95 -83
  888. package/dist/src/tui/backends/gateway-realtime-backend.d.ts +34 -33
  889. package/dist/src/tui/backends/gateway-realtime-backend.js +95 -78
  890. package/dist/src/tui/components/branch-summary.js +3 -3
  891. package/dist/src/tui/components/session-selector.d.ts +5 -5
  892. package/dist/src/tui/components/session-selector.js +7 -7
  893. package/dist/src/tui/components/tui-bottom-bar.js +1 -1
  894. package/dist/src/tui/components/tui-header.d.ts +1 -1
  895. package/dist/src/tui/components/tui-header.js +2 -2
  896. package/dist/src/tui/extension-host/autocomplete.d.ts +2 -2
  897. package/dist/src/tui/extension-host/autocomplete.js +4 -4
  898. package/dist/src/tui/extension-host/host.d.ts +1 -1
  899. package/dist/src/tui/extension-host/runtime-context.d.ts +1 -1
  900. package/dist/src/tui/extension-host/runtime-context.js +2 -2
  901. package/dist/src/tui/extension-host/runtime.d.ts +1 -1
  902. package/dist/src/tui/extension-host/runtime.js +6 -6
  903. package/dist/src/tui/tui-backend.d.ts +43 -39
  904. package/dist/src/tui/tui-command-formatters.d.ts +2 -2
  905. package/dist/src/tui/tui-command-formatters.js +10 -18
  906. package/dist/src/tui/tui-commands.d.ts +3 -3
  907. package/dist/src/tui/tui-commands.js +31 -33
  908. package/dist/src/tui/tui-empty-session-cleanup.d.ts +2 -3
  909. package/dist/src/tui/tui-empty-session-cleanup.js +7 -15
  910. package/dist/src/tui/tui-file-autocomplete.d.ts +1 -1
  911. package/dist/src/tui/tui-file-autocomplete.js +2 -2
  912. package/dist/src/tui/tui-new-session-preferences.js +2 -0
  913. package/dist/src/tui/tui-picker-overlay.d.ts +1 -1
  914. package/dist/src/tui/tui-picker-overlay.js +41 -53
  915. package/dist/src/tui/tui-picker-services.d.ts +3 -3
  916. package/dist/src/tui/tui-session-actions.d.ts +1 -1
  917. package/dist/src/tui/tui-session-actions.js +8 -17
  918. package/dist/src/tui/tui-session-format.js +4 -1
  919. package/dist/src/tui/tui-session-snapshot.d.ts +2 -2
  920. package/dist/src/tui/tui-session-snapshot.js +4 -4
  921. package/dist/src/tui/tui-settings.js +2 -0
  922. package/dist/src/tui/tui-startup-resources.d.ts +1 -1
  923. package/dist/src/tui/tui-startup-resources.js +4 -4
  924. package/dist/src/tui/tui-startup-text.js +1 -1
  925. package/dist/src/tui/tui-transcript-tree-picker.d.ts +1 -1
  926. package/dist/src/tui/tui-transcript-tree-picker.js +2 -2
  927. package/dist/src/tui/tui-types.d.ts +4 -2
  928. package/dist/src/tui/tui-types.js +2 -2
  929. package/dist/src/tui/tui.js +116 -114
  930. package/dist/src/user-context/access-policy.d.ts +1 -1
  931. package/dist/src/user-context/access-policy.js +6 -5
  932. package/dist/src/user-context/changes.js +9 -4
  933. package/dist/src/user-context/domain.d.ts +1 -1
  934. package/dist/src/user-context/relationship-continuity.d.ts +1 -1
  935. package/dist/src/user-context/relationship-continuity.js +1 -1
  936. package/dist/src/user-context/sources/repository.js +4 -2
  937. package/dist/src/user-model/capture/executor.d.ts +1 -1
  938. package/dist/src/user-model/capture/executor.js +3 -3
  939. package/dist/src/user-model/goals.js +2 -1
  940. package/dist/src/user-model/repository.js +2 -1
  941. package/dist/src/utils/global-singleton.js +4 -1
  942. package/dist/src/utils/logger/context.d.ts +1 -1
  943. package/dist/src/utils/logger/context.js +2 -2
  944. package/dist/src/utils/logger/log-store.js +2 -2
  945. package/dist/src/utils/logger/pino-record.js +6 -6
  946. package/dist/src/utils/logger/types.d.ts +6 -6
  947. package/dist/src/voice/platform-catalog.d.ts +81 -0
  948. package/dist/src/voice/platform-catalog.js +16 -0
  949. package/dist/src/voice/platform-settings.d.ts +4 -0
  950. package/dist/src/voice/platform-settings.js +120 -0
  951. package/dist/src/voice/platform-streams.d.ts +12 -0
  952. package/dist/src/voice/platform-streams.js +250 -0
  953. package/dist/src/voice/realtime/agentBroker.d.ts +6 -6
  954. package/dist/src/voice/realtime/agentBroker.js +6 -6
  955. package/dist/src/voice/realtime/agentEngine.js +6 -6
  956. package/dist/src/voice/realtime/memory-context.d.ts +2 -2
  957. package/dist/src/voice/realtime/memory-context.js +15 -15
  958. package/dist/src/voice/realtime/omniEngine.js +8 -5
  959. package/dist/src/voice/realtime/omniRoute.d.ts +1 -0
  960. package/dist/src/voice/realtime/omniRoute.js +11 -1
  961. package/dist/src/voice/realtime/persona-context.d.ts +1 -1
  962. package/dist/src/voice/realtime/persona-context.js +6 -6
  963. package/dist/src/voice/realtime/runtime.d.ts +1 -1
  964. package/dist/src/voice/realtime/runtime.js +28 -19
  965. package/dist/src/voice/realtime/runtime.types.d.ts +6 -6
  966. package/dist/src/voice/stt/providers/xopc-cloud-transcription.js +15 -8
  967. package/dist/src/voice/tts/providers/xopc-cloud-speech.js +12 -19
  968. package/dist/src/work-discovery/investigation-repository.js +4 -2
  969. package/dist/src/work-discovery/probe.js +1 -1
  970. package/dist/src/work-discovery/repository.js +7 -5
  971. package/dist/src/work-discovery/service.js +35 -31
  972. package/dist/src/work-discovery/types.d.ts +1 -1
  973. package/dist/src/workflows/context/workflow-context-snapshot-repository.js +2 -1
  974. package/dist/src/workflows/domain/event.d.ts +1 -1
  975. package/dist/src/workflows/domain/run.d.ts +5 -5
  976. package/dist/src/workflows/engine/projector.js +1 -1
  977. package/dist/src/workflows/engine/workflow-engine.d.ts +2 -2
  978. package/dist/src/workflows/engine/workflow-engine.js +15 -18
  979. package/dist/src/workflows/index.js +3 -3
  980. package/dist/src/workflows/project-presets/project-workflow-preset-repository.js +2 -1
  981. package/dist/src/workflows/service/run-view-to-snapshot.js +1 -1
  982. package/dist/src/workflows/service/workflow-run-service.d.ts +2 -2
  983. package/dist/src/workflows/service/workflow-run-service.js +53 -42
  984. package/dist/src/workflows/service/workflow-run-service.types.d.ts +2 -2
  985. package/dist/src/workflows/service/workflow-session-bridge.d.ts +2 -2
  986. package/dist/src/workflows/service/workflow-session-bridge.js +31 -31
  987. package/dist/src/workflows/service/workflow-session-key.d.ts +1 -1
  988. package/dist/src/workflows/service/workflow-session-key.js +4 -4
  989. package/dist/src/workflows/service/workflow-writeback-service.js +2 -1
  990. package/dist/src/workflows/store/event-store.js +4 -2
  991. package/dist/src/workflows/store/run-index-store.js +9 -8
  992. package/package.json +6 -3
  993. package/skills/creative/algorithmic-art/SKILL.md +7 -0
  994. package/skills/creative/frontend-design/SKILL.md +8 -0
  995. package/skills/creative/hatch-pet/SKILL.md +7 -0
  996. package/skills/creative/theme-factory/SKILL.md +8 -0
  997. package/skills/documents/doc-coauthoring/SKILL.md +7 -0
  998. package/skills/documents/docx/SKILL.md +7 -0
  999. package/skills/documents/pdf/SKILL.md +7 -0
  1000. package/skills/documents/pptx/SKILL.md +7 -0
  1001. package/skills/documents/xlsx/SKILL.md +9 -1
  1002. package/skills/engineering/build-xopc-local-app/SKILL.md +7 -0
  1003. package/skills/engineering/define-task/SKILL.md +7 -0
  1004. package/skills/engineering/diagnose/SKILL.md +8 -0
  1005. package/skills/engineering/tdd/SKILL.md +8 -0
  1006. package/skills/tools/find-skills/SKILL.md +8 -0
  1007. package/skills/tools/github/SKILL.md +7 -0
  1008. package/skills/tools/summarize/SKILL.md +8 -0
  1009. package/skills/tools/webapp-testing/SKILL.md +8 -1
  1010. package/dist/gateway/static/root/assets/agent-defaults-settings-panel-CcmqK1Sc.js +0 -1
  1011. package/dist/gateway/static/root/assets/agents-B_7PVt7S.js +0 -1
  1012. package/dist/gateway/static/root/assets/api-COG_Tzpv.js +0 -1
  1013. package/dist/gateway/static/root/assets/apps-page-6qxxKFsK.js +0 -1
  1014. package/dist/gateway/static/root/assets/automations-workspace-BRQlU4qk.js +0 -6
  1015. package/dist/gateway/static/root/assets/browser-settings-page-DDjbDeHQ.js +0 -8
  1016. package/dist/gateway/static/root/assets/button-BA45yciM.js +0 -1
  1017. package/dist/gateway/static/root/assets/capabilities-settings-panel-DM1Bcf1x.js +0 -8
  1018. package/dist/gateway/static/root/assets/channels-settings-Bq36CUxL.js +0 -1
  1019. package/dist/gateway/static/root/assets/connectors-page-L8JehrxF.js +0 -2
  1020. package/dist/gateway/static/root/assets/desktop-pet-DtPNvznL.js +0 -1
  1021. package/dist/gateway/static/root/assets/extension-settings-page-C75kCOqe.js +0 -1
  1022. package/dist/gateway/static/root/assets/gateway-settings-BCF732TU.js +0 -1
  1023. package/dist/gateway/static/root/assets/heartbeat-settings-C7fjiowt.js +0 -1
  1024. package/dist/gateway/static/root/assets/home-page-DZXeXdUL.js +0 -1
  1025. package/dist/gateway/static/root/assets/index-ChIrvv3t.js +0 -74
  1026. package/dist/gateway/static/root/assets/index-R1VNlHjj.css +0 -2
  1027. package/dist/gateway/static/root/assets/local-app-workbench-page-CAEKGTAg.js +0 -2
  1028. package/dist/gateway/static/root/assets/locale-store-DlOv7896.js +0 -1
  1029. package/dist/gateway/static/root/assets/logs-page-DHZ4BEkG.js +0 -2
  1030. package/dist/gateway/static/root/assets/messages-Ls1Aaiqd.js +0 -3
  1031. package/dist/gateway/static/root/assets/note-detail-panel-BcWq3ddw.js +0 -5
  1032. package/dist/gateway/static/root/assets/notes-page-DfZ8QWyv.js +0 -8
  1033. package/dist/gateway/static/root/assets/page-tabs-BG39KidE.js +0 -1
  1034. package/dist/gateway/static/root/assets/popover-select-DGmMQt4t.js +0 -1
  1035. package/dist/gateway/static/root/assets/proactive-page-D2U_xQaS.js +0 -1
  1036. package/dist/gateway/static/root/assets/project-detail-page-CzlGTW4F.js +0 -1
  1037. package/dist/gateway/static/root/assets/projects-page-mQsM-TsP.js +0 -1
  1038. package/dist/gateway/static/root/assets/remote-access-hub-Cb56JcO1.js +0 -1
  1039. package/dist/gateway/static/root/assets/sessions-page-Hj9uFcIO.js +0 -1
  1040. package/dist/gateway/static/root/assets/settings-advanced-gate-CV4-_EVA.js +0 -1
  1041. package/dist/gateway/static/root/assets/settings-form-section-wcAdCkK8.js +0 -1
  1042. package/dist/gateway/static/root/assets/settings-page-layout-DYelDcMV.js +0 -1
  1043. package/dist/gateway/static/root/assets/setup-status-panel-DzxmsaQG.js +0 -1
  1044. package/dist/gateway/static/root/assets/shares-settings-xlJh1ccG.js +0 -1
  1045. package/dist/gateway/static/root/assets/skill-reload-api-wSXJRSxX.js +0 -1
  1046. package/dist/gateway/static/root/assets/skills-page-AmqtBJo7.js +0 -2
  1047. package/dist/gateway/static/root/assets/task-detail-page-sQpwq5-c.js +0 -1
  1048. package/dist/gateway/static/root/assets/tunnel-api-Boajol0M.js +0 -1
  1049. package/dist/gateway/static/root/assets/user-model-page-DIEHnAER.js +0 -2
  1050. package/dist/gateway/static/root/assets/workflows-page-DgRNIyr7.js +0 -6
  1051. package/dist/src/routing/session-key-utils.d.ts +0 -23
  1052. package/dist/src/routing/session-key-utils.js +0 -85
  1053. package/dist/src/session/session-id.d.ts +0 -3
  1054. package/dist/src/session/session-id.js +0 -10
  1055. package/dist/src/storage/sqlite/migrations/002_add_flush_columns.sql +0 -3
  1056. package/dist/src/storage/sqlite/migrations/003_add_note_markdown_meta.sql +0 -4
  1057. package/dist/src/storage/sqlite/migrations/004_add_session_type_metadata.sql +0 -15
  1058. package/dist/src/storage/sqlite/migrations/005_add_note_agent_contexts.sql +0 -10
  1059. package/dist/src/storage/sqlite/migrations/006_add_goals.sql +0 -108
  1060. package/dist/src/storage/sqlite/migrations/007_goal_run_judge_schema.sql +0 -4
  1061. package/dist/src/storage/sqlite/migrations/008_goal_queue_workflow_runs.sql +0 -53
  1062. package/dist/src/storage/sqlite/migrations/009_cron_jobs.sql +0 -24
  1063. package/dist/src/storage/sqlite/migrations/010_session_id_identity.sql +0 -30
  1064. package/dist/src/storage/sqlite/migrations/011_goal_context_messages.sql +0 -8
  1065. package/dist/src/storage/sqlite/migrations/012_memory_records.sql +0 -63
  1066. package/dist/src/storage/sqlite/migrations/013_memory_trace_events.sql +0 -21
  1067. package/dist/src/storage/sqlite/migrations/014_memory_record_governance.sql +0 -10
  1068. package/dist/src/storage/sqlite/migrations/015_memory_trace_feedback.sql +0 -4
  1069. package/dist/src/storage/sqlite/migrations/016_automations.sql +0 -47
  1070. package/dist/src/storage/sqlite/migrations/017_automation_run_events.sql +0 -14
  1071. package/dist/src/storage/sqlite/migrations/018_automation_safety.sql +0 -1
  1072. package/dist/src/storage/sqlite/migrations/019_projects.sql +0 -40
  1073. package/dist/src/storage/sqlite/migrations/020_project_default_agent.sql +0 -1
  1074. package/dist/src/storage/sqlite/migrations/021_projects_fts.sql +0 -21
  1075. package/dist/src/storage/sqlite/migrations/022_work_items.sql +0 -61
  1076. package/dist/src/storage/sqlite/migrations/023_work_item_attachments.sql +0 -15
  1077. package/dist/src/storage/sqlite/migrations/024_activity_events.sql +0 -62
  1078. package/dist/src/storage/sqlite/migrations/025_project_pinned_at.sql +0 -5
  1079. package/dist/src/storage/sqlite/migrations/026_goal_contracts.sql +0 -10
  1080. package/dist/src/storage/sqlite/migrations/027_mobile_notifications.sql +0 -43
  1081. package/dist/src/storage/sqlite/migrations/028_goal_evidence_requirements.sql +0 -47
  1082. package/dist/src/storage/sqlite/migrations/029_user_understanding.sql +0 -133
  1083. package/dist/src/storage/sqlite/migrations/030_connectors.sql +0 -94
  1084. package/dist/src/storage/sqlite/migrations/031_connector_approvals.sql +0 -24
  1085. package/dist/src/storage/sqlite/migrations/032_connector_webhook_deliveries.sql +0 -15
  1086. package/dist/src/storage/sqlite/migrations/033_user_trust_policies.sql +0 -6
  1087. package/dist/src/storage/sqlite/migrations/034_allow_global_auto_trust.sql +0 -14
  1088. package/dist/src/storage/sqlite/migrations/035_user_profile_prompt_state.sql +0 -7
  1089. package/dist/src/storage/sqlite/migrations/036_goal_outcome_metric.sql +0 -12
  1090. package/dist/src/storage/sqlite/migrations/037_connected_knowledge_pipeline.sql +0 -47
  1091. package/dist/src/storage/sqlite/migrations/038_user_owned_memory.sql +0 -68
  1092. package/dist/src/storage/sqlite/migrations/039_memory_reference_consents.sql +0 -19
  1093. package/dist/src/storage/sqlite/migrations/040_local_apps.sql +0 -32
  1094. package/dist/src/storage/sqlite/migrations/041_local_app_release_lifecycle.sql +0 -17
  1095. package/dist/src/storage/sqlite/migrations/042_work_discovery.sql +0 -41
  1096. package/dist/src/storage/sqlite/migrations/043_local_app_acceptance_runs.sql +0 -16
  1097. package/dist/src/storage/sqlite/migrations/044_repair_work_discovery_foreign_keys.sql +0 -75
  1098. package/dist/src/storage/sqlite/migrations/045_extension_ui_grants.sql +0 -13
  1099. package/dist/src/storage/sqlite/migrations/046_work_discovery_feedback.sql +0 -13
  1100. package/dist/src/storage/sqlite/migrations/047_work_discovery_sources.sql +0 -16
  1101. package/dist/src/storage/sqlite/migrations/048_work_understanding_investigations.sql +0 -40
  1102. package/dist/src/storage/sqlite/migrations/049_work_understanding_threads.sql +0 -52
  1103. package/dist/src/storage/sqlite/migrations/050_work_discovery_source_refreshes.sql +0 -15
  1104. package/dist/src/storage/sqlite/migrations/051_focus_watches.sql +0 -26
  1105. package/dist/src/storage/sqlite/migrations/052_proactive_insights.sql +0 -25
  1106. package/dist/src/storage/sqlite/migrations/053_browser_recipes.sql +0 -45
  1107. package/dist/src/storage/sqlite/migrations/054_task_outcomes.sql +0 -24
  1108. package/dist/src/storage/sqlite/migrations/055_relationship_settings.sql +0 -14
  1109. package/dist/src/storage/sqlite/migrations/056_task_verification.sql +0 -6
  1110. package/dist/src/storage/sqlite/migrations/057_interaction_states.sql +0 -11
  1111. package/dist/src/storage/sqlite/migrations/058_proactive_value.sql +0 -3
  1112. package/dist/src/storage/sqlite/migrations/059_composer_input_history.sql +0 -8
  1113. package/dist/src/storage/sqlite/migrations/060_remove_runtime_transcript_messages.sql +0 -45
  1114. package/dist/src/storage/sqlite/migrations/061_drop_compaction_checkpoints.sql +0 -2
  1115. package/dist/src/storage/sqlite/migrations/062_connector_learning_jobs.sql +0 -27
  1116. package/dist/src/storage/sqlite/migrations/063_knowledge_collection_scopes.sql +0 -14
  1117. package/dist/src/storage/sqlite/migrations/064_user_claims.sql +0 -60
  1118. package/dist/src/storage/sqlite/migrations/065_knowledge_item_scope_identity.sql +0 -116
  1119. package/dist/src/storage/sqlite/migrations/066_first_class_focuses.sql +0 -126
  1120. package/dist/src/storage/sqlite/migrations/067_home_attention_acknowledgements.sql +0 -9
  1121. package/dist/src/storage/sqlite/migrations/068_proactive_event_spine.sql +0 -71
  1122. package/dist/src/storage/sqlite/migrations/069_proactive_scenario_control.sql +0 -69
  1123. package/dist/src/storage/sqlite/migrations/070_proactive_execution.sql +0 -55
  1124. package/dist/src/storage/sqlite/migrations/071_proactive_inbox.sql +0 -45
  1125. package/dist/src/storage/sqlite/migrations/072_proactive_judgments.sql +0 -14
  1126. package/dist/src/storage/sqlite/migrations/073_enable_default_proactive_scenarios.sql +0 -13
  1127. package/dist/src/storage/sqlite/migrations/074_deduplicate_blocked_work_routing.sql +0 -5
  1128. package/dist/src/storage/sqlite/migrations/075_connector_sync_policies.sql +0 -13
  1129. package/dist/src/storage/sqlite/migrations/076_meeting_preparation_scenario.sql +0 -29
  1130. package/dist/src/storage/sqlite/migrations/077_proactive_insight_fingerprints.sql +0 -4
  1131. package/dist/src/storage/sqlite/migrations/078_discussion_captures.sql +0 -64
  1132. package/dist/src/storage/sqlite/migrations/079_discussion_follow_up_scenario.sql +0 -29
  1133. package/dist/src/storage/sqlite/migrations/080_task_outcome_context.sql +0 -15
  1134. package/dist/src/storage/sqlite/migrations/081_project_monitoring_policies.sql +0 -10
  1135. package/dist/src/storage/sqlite/migrations/082_one_click_live_discussions.sql +0 -100
  1136. package/dist/src/storage/sqlite/migrations/083_session_task_plans.sql +0 -9
  1137. package/dist/src/storage/sqlite/migrations/084_work_intake_lifecycle.sql +0 -26
  1138. package/dist/src/storage/sqlite/migrations/085_task_outcome_projection.sql +0 -19
  1139. package/dist/src/storage/sqlite/migrations/086_outcome_aggregates.sql +0 -168
  1140. package/dist/src/storage/sqlite/migrations/087_context_snapshots.sql +0 -21
  1141. package/dist/src/storage/sqlite/migrations/088_automation_execution_deadlines.sql +0 -5
  1142. package/dist/src/storage/sqlite/migrations/089_automation_run_leases.sql +0 -8
  1143. package/dist/src/storage/sqlite/migrations/090_outcome_contract_judgment.sql +0 -2
  1144. package/dist/src/storage/sqlite/migrations/091_context_allocation.sql +0 -1
  1145. package/dist/src/storage/sqlite/migrations/092_outcome_execution_runtime.sql +0 -88
  1146. package/dist/src/storage/sqlite/migrations/093_remove_legacy_goals.sql +0 -174
  1147. package/dist/src/storage/sqlite/migrations/094_outcome_judgment_and_authority.sql +0 -3
  1148. package/dist/src/storage/sqlite/migrations/095_session_input_queue.sql +0 -35
  1149. package/dist/src/storage/sqlite/migrations/096_drop_work_intakes.sql +0 -6
  1150. package/dist/src/storage/sqlite/migrations/097_work_item_lifecycle.sql +0 -194
  1151. package/dist/src/storage/sqlite/migrations/098_discussion_note_documents.sql +0 -99
  1152. package/dist/src/storage/sqlite/migrations/099_task_model.sql +0 -500
  1153. package/dist/src/storage/sqlite/migrations/100_project_task_taskrun.sql +0 -763
  1154. package/dist/src/storage/sqlite/migrations/101_session_response_language.sql +0 -1
  1155. package/dist/src/storage/sqlite/migrations/102_session_user_context_mode.sql +0 -2
  1156. package/dist/src/storage/sqlite/migrations/103_finalize_structured_memory.sql +0 -3
  1157. package/dist/src/storage/sqlite/migrations/104_turn_memory_feedback.sql +0 -77
  1158. package/dist/src/storage/sqlite/migrations/105_dreaming_ledger.sql +0 -34
  1159. package/dist/src/storage/sqlite/migrations/106_dreaming_run_reproducibility.sql +0 -2
  1160. package/dist/src/storage/sqlite/migrations/107_connector_accounts.sql +0 -146
  1161. package/dist/src/storage/sqlite/migrations/108_repair_user_memory_provider.sql +0 -18
  1162. package/dist/src/storage/sqlite/migrations/109_endpoint_principals.sql +0 -14
  1163. package/dist/src/storage/sqlite/migrations/110_session_input_origin.sql +0 -43
  1164. package/dist/src/storage/sqlite/migrations/111_endpoint_tool_invocations.sql +0 -18
  1165. package/dist/src/storage/sqlite/migrations/112_endpoint_instance_bindings.sql +0 -8
  1166. package/dist/src/storage/sqlite/migrations/113_memory_evidence_single_source.sql +0 -76
  1167. package/dist/src/storage/sqlite/migrations/114_user_context_domain.sql +0 -193
  1168. package/dist/src/storage/sqlite/migrations/115_remove_legacy_user_context.sql +0 -6
  1169. package/dist/src/storage/sqlite/migrations/116_structured_context_consolidation.sql +0 -38
  1170. package/dist/src/storage/sqlite/migrations/117_unified_understanding_sources.sql +0 -110
  1171. package/dist/src/storage/sqlite/migrations/118_task_board_rank.sql +0 -6
  1172. package/dist/src/storage/sqlite/migrations/119_proactive_disposition.sql +0 -13
  1173. package/dist/src/storage/sqlite/migrations/120_task_conversation.sql +0 -112
  1174. package/dist/src/storage/sqlite/migrations/121_automation_inbox.sql +0 -24
  1175. package/dist/src/storage/sqlite/migrations/122_automation_session_projects.sql +0 -18
  1176. package/dist/src/storage/sqlite/migrations/123_remove_v2_compaction_boundaries.sql +0 -25
  1177. package/dist/src/storage/sqlite/migrations/124_workflow_context_snapshots.sql +0 -15
  1178. package/dist/src/storage/sqlite/migrations/125_project_workflow_presets.sql +0 -12
  1179. package/dist/src/storage/sqlite/migrations/126_focus_context_governance.sql +0 -72
  1180. package/dist/src/storage/sqlite/migrations/127_context_object_origin.sql +0 -36
  1181. package/dist/src/storage/sqlite/migrations/128_context_extraction.sql +0 -73
  1182. package/dist/src/storage/sqlite/migrations/129_focus_versions.sql +0 -51
  1183. package/dist/src/storage/sqlite/migrations/130_context_evidence_provenance.sql +0 -18
  1184. package/dist/src/storage/sqlite/migrations/131_session_input_contexts.sql +0 -2
  1185. package/dist/src/storage/sqlite/migrations/132_transcript_source_context_metadata.sql +0 -34
  1186. package/dist/src/storage/sqlite/migrations/133_archive_legacy_work_discovery_profile_facts.sql +0 -11
  1187. package/dist/src/storage/sqlite/migrations/134_memory_provenance.sql +0 -18
  1188. package/dist/src/storage/sqlite/migrations/135_user_people.sql +0 -59
  1189. package/dist/src/storage/sqlite/migrations/136_product_notifications.sql +0 -79
  1190. package/dist/src/storage/sqlite/migrations/137_understanding_status_audit.sql +0 -71
  1191. package/dist/src/storage/sqlite/migrations/138_device_access.sql +0 -96
  1192. package/dist/src/storage/sqlite/migrations/139_turn_outcome_artifact_backfill.sql +0 -231
  1193. package/dist/src/storage/sqlite/migrations/140_endpoint_session_bindings.sql +0 -8
  1194. package/dist/src/storage/sqlite/migrations/141_device_pairing_approval.sql +0 -17
  1195. package/dist/src/storage/sqlite/migrations/142_session_input_instance.sql +0 -1
  1196. package/dist/src/storage/sqlite/migrations/143_fixed_session_model.sql +0 -1
  1197. package/dist/src/storage/sqlite/migrations/144_execution_environments.sql +0 -59
  1198. package/dist/src/storage/sqlite/migrations/145_project_execution_mode.sql +0 -5
  1199. package/dist/src/storage/sqlite/migrations/146_understanding_focus_exclusions.sql +0 -9
  1200. package/dist/src/storage/sqlite/migrations/147_durable_application_state.sql +0 -39
  1201. package/dist/src/storage/sqlite/migrations/148_user_model_foundation.sql +0 -554
  1202. package/dist/src/storage/sqlite/migrations/149_separate_source_index_from_memory.sql +0 -18
  1203. package/dist/src/storage/sqlite/migrations/150_session_connection_waits.sql +0 -47
  1204. package/dist/src/storage/sqlite/migrations/151_proactive_scope_cleanup.sql +0 -6
  1205. package/dist/src/storage/sqlite/migrations/152_proactive_scenario_contract.sql +0 -140
  1206. package/dist/src/storage/sqlite/migrations/153_browser_control_v2.sql +0 -45
  1207. package/dist/src/storage/sqlite/migrations/154_session_clarification_waits.sql +0 -60
  1208. package/dist/src/storage/sqlite/migrations/155_browser_extension.sql +0 -120
  1209. package/dist/src/storage/sqlite/migrations/156_browser_tab_bindings.sql +0 -14
  1210. package/dist/src/storage/sqlite/migrations/157_browser_endpoint_principals.sql +0 -50
  1211. package/dist/src/storage/sqlite/migrations/158_browser_native_enrollment.sql +0 -4
  1212. package/dist/src/storage/sqlite/migrations/159_proactive_controls.sql +0 -68
  1213. package/dist/src/storage/sqlite/migrations/160_proactive_web_push.sql +0 -27
  1214. package/dist/src/storage/sqlite/migrations/161_proactive_delivery_and_lifecycle.sql +0 -51
  1215. package/dist/src/storage/sqlite/migrations/162_proactive_product.sql +0 -7
  1216. package/dist/src/storage/sqlite/migrations/163_proactive_follow_ups.sql +0 -29
  1217. package/dist/src/storage/sqlite/migrations/164_browser_sessions.sql +0 -8
  1218. package/dist/src/storage/sqlite/migrations/165_device_pairing_target.sql +0 -40
  1219. package/dist/src/storage/sqlite/migrations/__tests__/mobile-discussion-source.test.ts +0 -20
  1220. package/dist/src/storage/sqlite/migrations/discover.ts +0 -52
  1221. package/dist/src/storage/sqlite/migrations/errors.ts +0 -32
  1222. package/dist/src/storage/sqlite/migrations/runner.ts +0 -194
  1223. package/dist/src/storage/sqlite/migrations/types.ts +0 -15
@@ -1 +1 @@
1
- import{n as e,t}from"./vendor-react-BOUWij0V.js";import{t as n}from"./popover-select-DGmMQt4t.js";import{a as r,r as i}from"./locale-store-DlOv7896.js";function a(e){return{id:e.id,name:e.definition.name,description:e.definition.description,enabled:e.status===`enabled`,risk:e.definition.risk,domains:e.definition.allowedDomains,inputs:e.definition.inputs,createdAtMs:e.createdAtMs,updatedAtMs:e.updatedAtMs}}var o={list:async()=>({automations:(await r(i(`/api/browser/automations`))).automations.map(a)}),setEnabled:async(e,t)=>({automation:a((await r(i(`/api/browser/automations/${encodeURIComponent(e)}`),{method:`PATCH`,body:JSON.stringify({status:t?`enabled`:`disabled`})})).automation)}),remove:e=>r(i(`/api/browser/automations/${encodeURIComponent(e)}`),{method:`DELETE`}),run:(e,t)=>r(i(`/api/browser/automations/${encodeURIComponent(e)}/run`),{method:`POST`,body:JSON.stringify({inputs:t})}),getRun:e=>r(i(`/api/browser/automation-runs/${encodeURIComponent(e)}`)),listRuns:e=>r(i(`/api/browser/automation-runs?automationId=${encodeURIComponent(e)}`)),cancel:e=>r(i(`/api/browser/automation-runs/${encodeURIComponent(e)}/cancel`),{method:`POST`})};function s(e){return Object.fromEntries(Object.entries(e.inputs).flatMap(([e,t])=>t.default===void 0?[]:[[e,t.default]]))}function c(e,t){return!Object.entries(e.inputs).some(([e,n])=>n.required&&(t[e]===void 0||t[e]===``))}var l=e(),u=t();function d(e){let t=(0,l.c)(53),{name:r,input:i,value:a,yes:o,no:s,onChange:c}=e,d;t[0]!==i.description||t[1]!==r?(d=i.description?.trim()||r,t[0]=i.description,t[1]=r,t[2]=d):d=t[2];let p=d;if(i.choices?.length){let e;t[3]===i.choices?e=t[4]:(e=i.choices.map(f),t[3]=i.choices,t[4]=e);let r=e,o=i.required?` *`:``,s;t[5]!==p||t[6]!==o?(s=(0,u.jsxs)(`span`,{className:`mb-1.5 block font-medium`,children:[p,o]}),t[5]=p,t[6]=o,t[7]=s):s=t[7];let l;t[8]===a?l=t[9]:(l=a===void 0?``:JSON.stringify(a),t[8]=a,t[9]=l);let d;t[10]===c?d=t[11]:(d=e=>c(JSON.parse(e)),t[10]=c,t[11]=d);let m;t[12]!==p||t[13]!==r||t[14]!==l||t[15]!==d?(m=(0,u.jsx)(n,{value:l,options:r,placeholder:p,onChange:d}),t[12]=p,t[13]=r,t[14]=l,t[15]=d,t[16]=m):m=t[16];let h;return t[17]!==s||t[18]!==m?(h=(0,u.jsxs)(`label`,{className:`block text-sm text-fg`,children:[s,m]}),t[17]=s,t[18]=m,t[19]=h):h=t[19],h}if(i.type===`boolean`){let e=i.required?` *`:``,r;t[20]!==p||t[21]!==e?(r=(0,u.jsxs)(`span`,{className:`mb-1.5 block font-medium`,children:[p,e]}),t[20]=p,t[21]=e,t[22]=r):r=t[22];let l=typeof a==`boolean`?String(a):``,d;t[23]===o?d=t[24]:(d={value:`true`,label:o},t[23]=o,t[24]=d);let f;t[25]===s?f=t[26]:(f={value:`false`,label:s},t[25]=s,t[26]=f);let m;t[27]!==d||t[28]!==f?(m=[d,f],t[27]=d,t[28]=f,t[29]=m):m=t[29];let h;t[30]===c?h=t[31]:(h=e=>c(e===`true`),t[30]=c,t[31]=h);let g;t[32]!==p||t[33]!==l||t[34]!==m||t[35]!==h?(g=(0,u.jsx)(n,{value:l,options:m,placeholder:p,onChange:h}),t[32]=p,t[33]=l,t[34]=m,t[35]=h,t[36]=g):g=t[36];let _;return t[37]!==r||t[38]!==g?(_=(0,u.jsxs)(`label`,{className:`block text-sm text-fg`,children:[r,g]}),t[37]=r,t[38]=g,t[39]=_):_=t[39],_}let m=i.type===`number`,h=i.required?` *`:``,g;t[40]!==p||t[41]!==h?(g=(0,u.jsxs)(`span`,{className:`mb-1.5 block font-medium`,children:[p,h]}),t[40]=p,t[41]=h,t[42]=g):g=t[42];let _=m?`number`:`text`,v=a===void 0?``:String(a),y;t[43]!==m||t[44]!==c?(y=e=>c(m?e.target.value===``?void 0:Number(e.target.value):e.target.value),t[43]=m,t[44]=c,t[45]=y):y=t[45];let b;t[46]!==_||t[47]!==v||t[48]!==y?(b=(0,u.jsx)(`input`,{type:_,value:v,onChange:y,className:`h-10 w-full rounded-lg border border-edge bg-surface-subtle px-3 text-sm text-fg outline-none focus:border-accent`}),t[46]=_,t[47]=v,t[48]=y,t[49]=b):b=t[49];let x;return t[50]!==g||t[51]!==b?(x=(0,u.jsxs)(`label`,{className:`block text-sm text-fg`,children:[g,b]}),t[50]=g,t[51]=b,t[52]=x):x=t[52],x}function f(e){return{value:JSON.stringify(e),label:String(e)}}function p(e){let t=(0,l.c)(7),{automation:n,values:r,language:i,onChange:a}=e,o;t[0]===n.inputs?o=t[1]:(o=Object.entries(n.inputs),t[0]=n.inputs,t[1]=o);let s;return t[2]!==i||t[3]!==a||t[4]!==o||t[5]!==r?(s=(0,u.jsx)(`div`,{className:`grid gap-4`,children:o.map(e=>{let[t,n]=e;return(0,u.jsx)(d,{name:t,input:n,value:r[t],yes:i===`zh`?`是`:`Yes`,no:i===`zh`?`否`:`No`,onChange:e=>a({...r,[t]:e})},t)})}),t[2]=i,t[3]=a,t[4]=o,t[5]=r,t[6]=s):s=t[6],s}export{o as i,c as n,s as r,p as t};
1
+ import{n as e,t}from"./vendor-react-BOUWij0V.js";import{t as n}from"./popover-select-DldSX8GX.js";import{a as r,r as i}from"./locale-store-eliqUnBr.js";function a(e){return{id:e.id,name:e.definition.name,description:e.definition.description,enabled:e.status===`enabled`,risk:e.definition.risk,domains:e.definition.allowedDomains,inputs:e.definition.inputs,createdAtMs:e.createdAtMs,updatedAtMs:e.updatedAtMs}}var o={list:async()=>({automations:(await r(i(`/api/browser/automations`))).automations.map(a)}),setEnabled:async(e,t)=>({automation:a((await r(i(`/api/browser/automations/${encodeURIComponent(e)}`),{method:`PATCH`,body:JSON.stringify({status:t?`enabled`:`disabled`})})).automation)}),remove:e=>r(i(`/api/browser/automations/${encodeURIComponent(e)}`),{method:`DELETE`}),run:(e,t)=>r(i(`/api/browser/automations/${encodeURIComponent(e)}/run`),{method:`POST`,body:JSON.stringify({inputs:t})}),getRun:e=>r(i(`/api/browser/automation-runs/${encodeURIComponent(e)}`)),listRuns:e=>r(i(`/api/browser/automation-runs?automationId=${encodeURIComponent(e)}`)),cancel:e=>r(i(`/api/browser/automation-runs/${encodeURIComponent(e)}/cancel`),{method:`POST`})};function s(e){return Object.fromEntries(Object.entries(e.inputs).flatMap(([e,t])=>t.default===void 0?[]:[[e,t.default]]))}function c(e,t){return!Object.entries(e.inputs).some(([e,n])=>n.required&&(t[e]===void 0||t[e]===``))}var l=e(),u=t();function d(e){let t=(0,l.c)(53),{name:r,input:i,value:a,yes:o,no:s,onChange:c}=e,d;t[0]!==i.description||t[1]!==r?(d=i.description?.trim()||r,t[0]=i.description,t[1]=r,t[2]=d):d=t[2];let p=d;if(i.choices?.length){let e;t[3]===i.choices?e=t[4]:(e=i.choices.map(f),t[3]=i.choices,t[4]=e);let r=e,o=i.required?` *`:``,s;t[5]!==p||t[6]!==o?(s=(0,u.jsxs)(`span`,{className:`mb-1.5 block font-medium`,children:[p,o]}),t[5]=p,t[6]=o,t[7]=s):s=t[7];let l;t[8]===a?l=t[9]:(l=a===void 0?``:JSON.stringify(a),t[8]=a,t[9]=l);let d;t[10]===c?d=t[11]:(d=e=>c(JSON.parse(e)),t[10]=c,t[11]=d);let m;t[12]!==p||t[13]!==r||t[14]!==l||t[15]!==d?(m=(0,u.jsx)(n,{value:l,options:r,placeholder:p,onChange:d}),t[12]=p,t[13]=r,t[14]=l,t[15]=d,t[16]=m):m=t[16];let h;return t[17]!==s||t[18]!==m?(h=(0,u.jsxs)(`label`,{className:`block text-sm text-fg`,children:[s,m]}),t[17]=s,t[18]=m,t[19]=h):h=t[19],h}if(i.type===`boolean`){let e=i.required?` *`:``,r;t[20]!==p||t[21]!==e?(r=(0,u.jsxs)(`span`,{className:`mb-1.5 block font-medium`,children:[p,e]}),t[20]=p,t[21]=e,t[22]=r):r=t[22];let l=typeof a==`boolean`?String(a):``,d;t[23]===o?d=t[24]:(d={value:`true`,label:o},t[23]=o,t[24]=d);let f;t[25]===s?f=t[26]:(f={value:`false`,label:s},t[25]=s,t[26]=f);let m;t[27]!==d||t[28]!==f?(m=[d,f],t[27]=d,t[28]=f,t[29]=m):m=t[29];let h;t[30]===c?h=t[31]:(h=e=>c(e===`true`),t[30]=c,t[31]=h);let g;t[32]!==p||t[33]!==l||t[34]!==m||t[35]!==h?(g=(0,u.jsx)(n,{value:l,options:m,placeholder:p,onChange:h}),t[32]=p,t[33]=l,t[34]=m,t[35]=h,t[36]=g):g=t[36];let _;return t[37]!==r||t[38]!==g?(_=(0,u.jsxs)(`label`,{className:`block text-sm text-fg`,children:[r,g]}),t[37]=r,t[38]=g,t[39]=_):_=t[39],_}let m=i.type===`number`,h=i.required?` *`:``,g;t[40]!==p||t[41]!==h?(g=(0,u.jsxs)(`span`,{className:`mb-1.5 block font-medium`,children:[p,h]}),t[40]=p,t[41]=h,t[42]=g):g=t[42];let _=m?`number`:`text`,v=a===void 0?``:String(a),y;t[43]!==m||t[44]!==c?(y=e=>c(m?e.target.value===``?void 0:Number(e.target.value):e.target.value),t[43]=m,t[44]=c,t[45]=y):y=t[45];let b;t[46]!==_||t[47]!==v||t[48]!==y?(b=(0,u.jsx)(`input`,{type:_,value:v,onChange:y,className:`h-10 w-full rounded-lg border border-edge bg-surface-subtle px-3 text-sm text-fg outline-none focus:border-accent`}),t[46]=_,t[47]=v,t[48]=y,t[49]=b):b=t[49];let x;return t[50]!==g||t[51]!==b?(x=(0,u.jsxs)(`label`,{className:`block text-sm text-fg`,children:[g,b]}),t[50]=g,t[51]=b,t[52]=x):x=t[52],x}function f(e){return{value:JSON.stringify(e),label:String(e)}}function p(e){let t=(0,l.c)(7),{automation:n,values:r,language:i,onChange:a}=e,o;t[0]===n.inputs?o=t[1]:(o=Object.entries(n.inputs),t[0]=n.inputs,t[1]=o);let s;return t[2]!==i||t[3]!==a||t[4]!==o||t[5]!==r?(s=(0,u.jsx)(`div`,{className:`grid gap-4`,children:o.map(e=>{let[t,n]=e;return(0,u.jsx)(d,{name:t,input:n,value:r[t],yes:i===`zh`?`是`:`Yes`,no:i===`zh`?`否`:`No`,onChange:e=>a({...r,[t]:e})},t)})}),t[2]=i,t[3]=a,t[4]=o,t[5]=r,t[6]=s):s=t[6],s}export{o as i,c as n,s as r,p as t};
@@ -1,3 +1,3 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,t as n}from"./vendor-react-BOUWij0V.js";import{d as r}from"./chunk-KS7C4IRE-Cq1tE_3b.js";import{t as i}from"./clock-3-DnrAnuyZ.js";import{n as a}from"./locale-store-DlOv7896.js";import{t as o}from"./button-BA45yciM.js";import{t as s}from"./skeleton-BwbyijEw.js";import{Du as c,Fc as l,Zl as u,Zs as d,mo as f,mu as p,pu as m,sc as h,zc as g}from"./index-ChIrvv3t.js";import{i as _,n as v,r as y,t as b}from"./browser-automation-inputs-BOTU1isH.js";var x=e(t(),1),S=n(),C={en:{title:`Browser automations`,subtitle:`Let your assistant repeat routine actions on the web.`,emptyTitle:`No browser automations yet`,emptyBody:`Tell your assistant what to do on the web. Once it works, save it and run it again whenever you need.`,create:`Create with assistant`,edit:`Edit with assistant`,run:`Run now`,stop:`Stop`,enable:`Enable`,pause:`Pause`,enabled:`Enabled`,paused:`Paused`,inputs:`Before running`,noInputs:`This automation is ready to run.`,history:`Recent activity`,delete:`Delete automation`,confirmDelete:`Delete this browser automation?`,required:`Please complete all required fields.`,queued:`Waiting to start`,running:`Running`,succeeded:`Completed`,failed:`Needs attention`,cancelled:`Stopped`,result:`Result`,read:`Reads information`,draft:`Edits the page locally`,external_effect:`Affects an external system`,destructive:`Destructive action`,sensitive:`Sensitive action`,createPrompt:`Help me create a reusable browser automation. Ask what I want the browser to do, perform it once with me, then save the successful steps. Keep all technical details hidden.`,editPrompt:`Help me update the browser automation "{name}" (id: {id}). Ask what should change, test the new browser steps, then save it.`},zh:{title:`浏览器自动化`,subtitle:`让助手自动重复完成网页上的固定操作。`,emptyTitle:`还没有浏览器自动化`,emptyBody:`告诉助手你希望在网页上自动完成什么。成功执行一次后,即可保存并重复运行。`,create:`让助手帮我创建`,edit:`让助手帮我修改`,run:`立即运行`,stop:`停止`,enable:`启用`,pause:`暂停`,enabled:`已启用`,paused:`已暂停`,inputs:`运行前需要填写`,noInputs:`这个自动化可以直接运行。`,history:`最近运行`,delete:`删除自动化`,confirmDelete:`确定删除这个浏览器自动化吗?`,required:`请填写所有必填内容。`,queued:`等待开始`,running:`正在运行`,succeeded:`已完成`,failed:`需要处理`,cancelled:`已停止`,result:`运行结果`,read:`仅读取信息`,draft:`仅在页面内编辑`,external_effect:`会影响外部系统`,destructive:`破坏性操作`,sensitive:`包含敏感操作`,createPrompt:`请帮我创建一个可重复运行的浏览器自动化。先询问我希望浏览器完成什么,陪我实际执行成功一次,然后保存成功步骤。不要让我处理技术细节。`,editPrompt:`请帮我修改浏览器自动化“{name}”(id:{id})。先询问我要修改什么,实际测试新的浏览器步骤,然后保存。`}};function w(e){return e!==`queued`&&e!==`running`}function T(e){return e==null?`-`:typeof e==`string`?e:typeof e==`number`||typeof e==`boolean`?String(e):Array.isArray(e)?e.map(e=>`• ${T(e)}`).join(`
1
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,t as n}from"./vendor-react-BOUWij0V.js";import{d as r}from"./chunk-KS7C4IRE-Cq1tE_3b.js";import{t as i}from"./clock-3-DnrAnuyZ.js";import{n as a}from"./locale-store-eliqUnBr.js";import{t as o}from"./button-CGlRPNzi.js";import{t as s}from"./skeleton-BwbyijEw.js";import{$s as c,Lc as l,Vc as u,_u as d,ho as f,ju as p,lc as m,tu as h,vu as g}from"./index-B7EieIE4.js";import{i as _,n as v,r as y,t as b}from"./browser-automation-inputs-Cq4sIJt2.js";var x=e(t(),1),S=n(),C={en:{title:`Browser automations`,subtitle:`Let your assistant repeat routine actions on the web.`,emptyTitle:`No browser automations yet`,emptyBody:`Tell your assistant what to do on the web. Once it works, save it and run it again whenever you need.`,create:`Create with assistant`,edit:`Edit with assistant`,run:`Run now`,stop:`Stop`,enable:`Enable`,pause:`Pause`,enabled:`Enabled`,paused:`Paused`,inputs:`Before running`,noInputs:`This automation is ready to run.`,history:`Recent activity`,delete:`Delete automation`,confirmDelete:`Delete this browser automation?`,required:`Please complete all required fields.`,queued:`Waiting to start`,running:`Running`,succeeded:`Completed`,failed:`Needs attention`,cancelled:`Stopped`,result:`Result`,read:`Reads information`,draft:`Edits the page locally`,external_effect:`Affects an external system`,destructive:`Destructive action`,sensitive:`Sensitive action`,createPrompt:`Help me create a reusable browser automation. Ask what I want the browser to do, perform it once with me, then save the successful steps. Keep all technical details hidden.`,editPrompt:`Help me update the browser automation "{name}" (id: {id}). Ask what should change, test the new browser steps, then save it.`},zh:{title:`浏览器自动化`,subtitle:`让助手自动重复完成网页上的固定操作。`,emptyTitle:`还没有浏览器自动化`,emptyBody:`告诉助手你希望在网页上自动完成什么。成功执行一次后,即可保存并重复运行。`,create:`让助手帮我创建`,edit:`让助手帮我修改`,run:`立即运行`,stop:`停止`,enable:`启用`,pause:`暂停`,enabled:`已启用`,paused:`已暂停`,inputs:`运行前需要填写`,noInputs:`这个自动化可以直接运行。`,history:`最近运行`,delete:`删除自动化`,confirmDelete:`确定删除这个浏览器自动化吗?`,required:`请填写所有必填内容。`,queued:`等待开始`,running:`正在运行`,succeeded:`已完成`,failed:`需要处理`,cancelled:`已停止`,result:`运行结果`,read:`仅读取信息`,draft:`仅在页面内编辑`,external_effect:`会影响外部系统`,destructive:`破坏性操作`,sensitive:`包含敏感操作`,createPrompt:`请帮我创建一个可重复运行的浏览器自动化。先询问我希望浏览器完成什么,陪我实际执行成功一次,然后保存成功步骤。不要让我处理技术细节。`,editPrompt:`请帮我修改浏览器自动化“{name}”(id:{id})。先询问我要修改什么,实际测试新的浏览器步骤,然后保存。`}};function w(e){return e!==`queued`&&e!==`running`}function T(e){return e==null?`-`:typeof e==`string`?e:typeof e==`number`||typeof e==`boolean`?String(e):Array.isArray(e)?e.map(e=>`• ${T(e)}`).join(`
2
2
  `):typeof e==`object`?Object.entries(e).map(([e,t])=>`${e}: ${T(t)}`).join(`
3
- `):String(e)}function E(){let e=a(e=>e.language),t=C[e],n=r(),E=f(e=>e.setPageHeader),D=f(e=>e.clearPageHeader),[O,k]=(0,x.useState)(null),[A,j]=(0,x.useState)(),[M,N]=(0,x.useState)({}),[P,F]=(0,x.useState)([]),[I,L]=(0,x.useState)(),[R,z]=(0,x.useState)(``),[B,V]=(0,x.useState)(!1),H=(0,x.useMemo)(()=>O?.find(e=>e.id===A),[A,O]),U=(0,x.useCallback)(async()=>{let e=await _.list();k(e.automations),j(t=>t&&e.automations.some(e=>e.id===t)?t:e.automations[0]?.id)},[]);(0,x.useEffect)(()=>{U().catch(e=>z(String(e)))},[U]),(0,x.useEffect)(()=>{H&&(N(y(H)),L(void 0),z(``),_.listRuns(H.id).then(e=>F(e.runs)).catch(e=>z(String(e))))},[H]),(0,x.useEffect)(()=>{if(!I||w(I.status))return;let e=window.setInterval(()=>{_.getRun(I.id).then(({run:e})=>{L(e),w(e.status)&&H&&_.listRuns(H.id).then(e=>F(e.runs))}).catch(e=>z(String(e)))},700);return()=>window.clearInterval(e)},[I,H]);let W=(0,x.useCallback)(e=>{n(`/chat/new?draft=${encodeURIComponent(e)}`)},[n]),G=(0,x.useMemo)(()=>(0,S.jsxs)(o,{onClick:()=>W(t.createPrompt),children:[(0,S.jsx)(c,{className:`size-4`}),t.create]}),[W,t.create,t.createPrompt]);(0,x.useLayoutEffect)(()=>(E({startExtra:null,main:(0,S.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:t.title}),end:G}),()=>D()),[D,G,E,t.title]);let K=async()=>{if(H){V(!0);try{await _.setEnabled(H.id,!H.enabled),await U()}catch(e){z(String(e))}finally{V(!1)}}},q=async()=>{if(H){if(!v(H,M)){z(t.required);return}V(!0);try{let{run:e}=await _.run(H.id,M);L(e),z(``)}catch(e){z(String(e))}finally{V(!1)}}},J=async()=>{if(!(!H||!window.confirm(t.confirmDelete))){V(!0);try{await _.remove(H.id),j(void 0),F([]),await U()}catch(e){z(String(e))}finally{V(!1)}}};return O===null?(0,S.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col bg-surface-panel p-4 sm:p-6`,children:(0,S.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-[280px_minmax(0,1fr)]`,children:[(0,S.jsx)(s,{className:`h-[420px] rounded-xl`}),(0,S.jsx)(s,{className:`h-[420px] rounded-xl`})]})}):O.length===0?(0,S.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col bg-surface-panel p-4 sm:p-6`,children:(0,S.jsxs)(`div`,{className:`m-auto max-w-md py-12 text-center`,children:[(0,S.jsx)(c,{className:`mx-auto size-10 text-accent`}),(0,S.jsx)(`h2`,{className:`mt-4 text-lg font-semibold text-fg`,children:t.emptyTitle}),(0,S.jsx)(`p`,{className:`mt-2 text-sm leading-6 text-fg-muted`,children:t.emptyBody}),(0,S.jsxs)(o,{className:`mt-5`,onClick:()=>W(t.createPrompt),children:[(0,S.jsx)(c,{className:`size-4`}),t.create]})]})}):(0,S.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col bg-surface-panel p-4 sm:p-6`,children:(0,S.jsxs)(`div`,{className:`grid min-h-0 flex-1 gap-4 lg:grid-cols-[280px_minmax(0,1fr)]`,children:[(0,S.jsx)(`aside`,{className:`min-h-0 overflow-y-auto rounded-xl border border-edge bg-surface-base p-2`,children:O.map(e=>(0,S.jsxs)(`button`,{onClick:()=>j(e.id),className:`mb-1 w-full rounded-lg p-3 text-left ${A===e.id?`bg-accent-soft text-accent-fg`:`hover:bg-surface-hover`}`,children:[(0,S.jsx)(`span`,{className:`block truncate text-sm font-medium`,children:e.name}),(0,S.jsxs)(`span`,{className:`mt-1 flex items-center gap-1.5 text-xs text-fg-muted`,children:[e.enabled?(0,S.jsx)(m,{className:`size-3.5 text-emerald-600`}):(0,S.jsx)(p,{className:`size-3.5`}),e.enabled?t.enabled:t.paused]})]},e.id))}),H&&(0,S.jsxs)(`main`,{className:`min-h-0 overflow-y-auto rounded-xl border border-edge bg-surface-base p-5 sm:p-6`,children:[(0,S.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-4`,children:[(0,S.jsxs)(`div`,{className:`min-w-0`,children:[(0,S.jsx)(`h2`,{className:`text-lg font-semibold text-fg`,children:H.name}),H.description&&(0,S.jsx)(`p`,{className:`mt-1 max-w-2xl text-sm leading-6 text-fg-muted`,children:H.description}),(0,S.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2 text-xs`,children:[(0,S.jsx)(`span`,{className:`rounded-full bg-surface-subtle px-2.5 py-1 text-fg-muted`,children:t[H.risk]}),H.domains.map(e=>(0,S.jsxs)(`span`,{className:`flex items-center gap-1 rounded-full bg-surface-subtle px-2.5 py-1 text-fg-muted`,children:[(0,S.jsx)(u,{className:`size-3`}),e]},e))]})]}),(0,S.jsxs)(`div`,{className:`flex gap-2`,children:[(0,S.jsxs)(o,{variant:`secondary`,disabled:B,onClick:()=>void K(),children:[H.enabled?(0,S.jsx)(p,{className:`size-4`}):(0,S.jsx)(m,{className:`size-4`}),H.enabled?t.pause:t.enable]}),(0,S.jsxs)(o,{variant:`secondary`,onClick:()=>W(t.editPrompt.replace(`{name}`,H.name).replace(`{id}`,H.id)),children:[(0,S.jsx)(g,{className:`size-4`}),t.edit]})]})]}),(0,S.jsxs)(`section`,{className:`mt-7 max-w-xl`,children:[(0,S.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:t.inputs}),Object.keys(H.inputs).length===0?(0,S.jsx)(`p`,{className:`mt-2 text-sm text-fg-muted`,children:t.noInputs}):(0,S.jsx)(`div`,{className:`mt-3`,children:(0,S.jsx)(b,{automation:H,values:M,language:e,onChange:N})}),(0,S.jsxs)(`div`,{className:`mt-5 flex gap-2`,children:[(0,S.jsxs)(o,{variant:`primary`,disabled:!H.enabled||B||!!(I&&!w(I.status)),onClick:()=>void q(),children:[(0,S.jsx)(l,{className:`size-4`}),t.run]}),I&&!w(I.status)&&(0,S.jsxs)(o,{variant:`secondary`,onClick:()=>void _.cancel(I.id),children:[(0,S.jsx)(h,{className:`size-4`}),t.stop]})]}),R&&(0,S.jsx)(`p`,{className:`mt-3 text-sm text-red-700 dark:text-red-300`,children:R})]}),I&&(0,S.jsxs)(`section`,{className:`mt-7 rounded-xl border border-edge bg-surface-subtle p-4`,children:[(0,S.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-medium text-fg`,children:[(0,S.jsx)(i,{className:`size-4`}),t[I.status]]}),I.error&&(0,S.jsx)(`p`,{className:`mt-2 text-sm text-red-700 dark:text-red-300`,children:I.error}),I.status===`succeeded`&&I.result!==void 0&&(0,S.jsxs)(`div`,{className:`mt-3`,children:[(0,S.jsx)(`h3`,{className:`text-xs font-semibold uppercase tracking-wide text-fg-muted`,children:t.result}),(0,S.jsx)(`pre`,{className:`mt-2 max-h-64 overflow-auto whitespace-pre-wrap text-sm text-fg`,children:T(I.result)})]})]}),(0,S.jsxs)(`section`,{className:`mt-8`,children:[(0,S.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:t.history}),(0,S.jsx)(`div`,{className:`mt-2 divide-y divide-edge`,children:P.slice(0,10).map(e=>(0,S.jsxs)(`button`,{className:`flex w-full items-center justify-between gap-3 py-3 text-left text-sm hover:text-accent`,onClick:()=>L(e),children:[(0,S.jsx)(`span`,{children:t[e.status]}),(0,S.jsxs)(`span`,{className:`text-xs text-fg-muted`,children:[new Date(e.createdAtMs).toLocaleString(),e.durationMs?` · ${Math.max(1,Math.round(e.durationMs/1e3))}s`:``]})]},e.id))})]}),(0,S.jsx)(`div`,{className:`mt-8 border-t border-edge pt-4`,children:(0,S.jsxs)(o,{variant:`ghost`,className:`text-red-700 dark:text-red-300`,disabled:B,onClick:()=>void J(),children:[(0,S.jsx)(d,{className:`size-4`}),t.delete]})})]})]})})}export{E as BrowserAutomationsPage};
3
+ `):String(e)}function E(){let e=a(e=>e.language),t=C[e],n=r(),E=f(e=>e.setPageHeader),D=f(e=>e.clearPageHeader),[O,k]=(0,x.useState)(null),[A,j]=(0,x.useState)(),[M,N]=(0,x.useState)({}),[P,F]=(0,x.useState)([]),[I,L]=(0,x.useState)(),[R,z]=(0,x.useState)(``),[B,V]=(0,x.useState)(!1),H=(0,x.useMemo)(()=>O?.find(e=>e.id===A),[A,O]),U=(0,x.useCallback)(async()=>{let e=await _.list();k(e.automations),j(t=>t&&e.automations.some(e=>e.id===t)?t:e.automations[0]?.id)},[]);(0,x.useEffect)(()=>{U().catch(e=>z(String(e)))},[U]),(0,x.useEffect)(()=>{H&&(N(y(H)),L(void 0),z(``),_.listRuns(H.id).then(e=>F(e.runs)).catch(e=>z(String(e))))},[H]),(0,x.useEffect)(()=>{if(!I||w(I.status))return;let e=window.setInterval(()=>{_.getRun(I.id).then(({run:e})=>{L(e),w(e.status)&&H&&_.listRuns(H.id).then(e=>F(e.runs))}).catch(e=>z(String(e)))},700);return()=>window.clearInterval(e)},[I,H]);let W=(0,x.useCallback)(e=>{n(`/chat/new?draft=${encodeURIComponent(e)}`)},[n]),G=(0,x.useMemo)(()=>(0,S.jsxs)(o,{onClick:()=>W(t.createPrompt),children:[(0,S.jsx)(p,{className:`size-4`}),t.create]}),[W,t.create,t.createPrompt]);(0,x.useLayoutEffect)(()=>(E({startExtra:null,main:(0,S.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:t.title}),end:G}),()=>D()),[D,G,E,t.title]);let K=async()=>{if(H){V(!0);try{await _.setEnabled(H.id,!H.enabled),await U()}catch(e){z(String(e))}finally{V(!1)}}},q=async()=>{if(H){if(!v(H,M)){z(t.required);return}V(!0);try{let{run:e}=await _.run(H.id,M);L(e),z(``)}catch(e){z(String(e))}finally{V(!1)}}},J=async()=>{if(!(!H||!window.confirm(t.confirmDelete))){V(!0);try{await _.remove(H.id),j(void 0),F([]),await U()}catch(e){z(String(e))}finally{V(!1)}}};return O===null?(0,S.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col bg-surface-panel p-4 sm:p-6`,children:(0,S.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-[280px_minmax(0,1fr)]`,children:[(0,S.jsx)(s,{className:`h-[420px] rounded-xl`}),(0,S.jsx)(s,{className:`h-[420px] rounded-xl`})]})}):O.length===0?(0,S.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col bg-surface-panel p-4 sm:p-6`,children:(0,S.jsxs)(`div`,{className:`m-auto max-w-md py-12 text-center`,children:[(0,S.jsx)(p,{className:`mx-auto size-10 text-accent`}),(0,S.jsx)(`h2`,{className:`mt-4 text-lg font-semibold text-fg`,children:t.emptyTitle}),(0,S.jsx)(`p`,{className:`mt-2 text-sm leading-6 text-fg-muted`,children:t.emptyBody}),(0,S.jsxs)(o,{className:`mt-5`,onClick:()=>W(t.createPrompt),children:[(0,S.jsx)(p,{className:`size-4`}),t.create]})]})}):(0,S.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col bg-surface-panel p-4 sm:p-6`,children:(0,S.jsxs)(`div`,{className:`grid min-h-0 flex-1 gap-4 lg:grid-cols-[280px_minmax(0,1fr)]`,children:[(0,S.jsx)(`aside`,{className:`min-h-0 overflow-y-auto rounded-xl border border-edge bg-surface-base p-2`,children:O.map(e=>(0,S.jsxs)(`button`,{onClick:()=>j(e.id),className:`mb-1 w-full rounded-lg p-3 text-left ${A===e.id?`bg-accent-soft text-accent-fg`:`hover:bg-surface-hover`}`,children:[(0,S.jsx)(`span`,{className:`block truncate text-sm font-medium`,children:e.name}),(0,S.jsxs)(`span`,{className:`mt-1 flex items-center gap-1.5 text-xs text-fg-muted`,children:[e.enabled?(0,S.jsx)(d,{className:`size-3.5 text-emerald-600`}):(0,S.jsx)(g,{className:`size-3.5`}),e.enabled?t.enabled:t.paused]})]},e.id))}),H&&(0,S.jsxs)(`main`,{className:`min-h-0 overflow-y-auto rounded-xl border border-edge bg-surface-base p-5 sm:p-6`,children:[(0,S.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-4`,children:[(0,S.jsxs)(`div`,{className:`min-w-0`,children:[(0,S.jsx)(`h2`,{className:`text-lg font-semibold text-fg`,children:H.name}),H.description&&(0,S.jsx)(`p`,{className:`mt-1 max-w-2xl text-sm leading-6 text-fg-muted`,children:H.description}),(0,S.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2 text-xs`,children:[(0,S.jsx)(`span`,{className:`rounded-full bg-surface-subtle px-2.5 py-1 text-fg-muted`,children:t[H.risk]}),H.domains.map(e=>(0,S.jsxs)(`span`,{className:`flex items-center gap-1 rounded-full bg-surface-subtle px-2.5 py-1 text-fg-muted`,children:[(0,S.jsx)(h,{className:`size-3`}),e]},e))]})]}),(0,S.jsxs)(`div`,{className:`flex gap-2`,children:[(0,S.jsxs)(o,{variant:`secondary`,disabled:B,onClick:()=>void K(),children:[H.enabled?(0,S.jsx)(g,{className:`size-4`}):(0,S.jsx)(d,{className:`size-4`}),H.enabled?t.pause:t.enable]}),(0,S.jsxs)(o,{variant:`secondary`,onClick:()=>W(t.editPrompt.replace(`{name}`,H.name).replace(`{id}`,H.id)),children:[(0,S.jsx)(u,{className:`size-4`}),t.edit]})]})]}),(0,S.jsxs)(`section`,{className:`mt-7 max-w-xl`,children:[(0,S.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:t.inputs}),Object.keys(H.inputs).length===0?(0,S.jsx)(`p`,{className:`mt-2 text-sm text-fg-muted`,children:t.noInputs}):(0,S.jsx)(`div`,{className:`mt-3`,children:(0,S.jsx)(b,{automation:H,values:M,language:e,onChange:N})}),(0,S.jsxs)(`div`,{className:`mt-5 flex gap-2`,children:[(0,S.jsxs)(o,{variant:`primary`,disabled:!H.enabled||B||!!(I&&!w(I.status)),onClick:()=>void q(),children:[(0,S.jsx)(l,{className:`size-4`}),t.run]}),I&&!w(I.status)&&(0,S.jsxs)(o,{variant:`secondary`,onClick:()=>void _.cancel(I.id),children:[(0,S.jsx)(m,{className:`size-4`}),t.stop]})]}),R&&(0,S.jsx)(`p`,{className:`mt-3 text-sm text-red-700 dark:text-red-300`,children:R})]}),I&&(0,S.jsxs)(`section`,{className:`mt-7 rounded-xl border border-edge bg-surface-subtle p-4`,children:[(0,S.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-medium text-fg`,children:[(0,S.jsx)(i,{className:`size-4`}),t[I.status]]}),I.error&&(0,S.jsx)(`p`,{className:`mt-2 text-sm text-red-700 dark:text-red-300`,children:I.error}),I.status===`succeeded`&&I.result!==void 0&&(0,S.jsxs)(`div`,{className:`mt-3`,children:[(0,S.jsx)(`h3`,{className:`text-xs font-semibold uppercase tracking-wide text-fg-muted`,children:t.result}),(0,S.jsx)(`pre`,{className:`mt-2 max-h-64 overflow-auto whitespace-pre-wrap text-sm text-fg`,children:T(I.result)})]})]}),(0,S.jsxs)(`section`,{className:`mt-8`,children:[(0,S.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:t.history}),(0,S.jsx)(`div`,{className:`mt-2 divide-y divide-edge`,children:P.slice(0,10).map(e=>(0,S.jsxs)(`button`,{className:`flex w-full items-center justify-between gap-3 py-3 text-left text-sm hover:text-accent`,onClick:()=>L(e),children:[(0,S.jsx)(`span`,{children:t[e.status]}),(0,S.jsxs)(`span`,{className:`text-xs text-fg-muted`,children:[new Date(e.createdAtMs).toLocaleString(),e.durationMs?` · ${Math.max(1,Math.round(e.durationMs/1e3))}s`:``]})]},e.id))})]}),(0,S.jsx)(`div`,{className:`mt-8 border-t border-edge pt-4`,children:(0,S.jsxs)(o,{variant:`ghost`,className:`text-red-700 dark:text-red-300`,disabled:B,onClick:()=>void J(),children:[(0,S.jsx)(c,{className:`size-4`}),t.delete]})})]})]})})}export{E as BrowserAutomationsPage};
@@ -0,0 +1,8 @@
1
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{d as i,h as a}from"./chunk-KS7C4IRE-Cq1tE_3b.js";import{t as o}from"./popover-select-DldSX8GX.js";import{t as s}from"./circle-check-C23XjkUj.js";import{t as c}from"./download-Dk-ZjtO6.js";import{t as l}from"./external-link-DjqjBmc3.js";import{t as u}from"./loader-circle-CifKLtgG.js";import{a as d,c as f,i as p,n as m,r as h}from"./locale-store-eliqUnBr.js";import{t as g}from"./messages-NYDOR8-j.js";import{i as _}from"./vendor-swr-BIWyz7Rc.js";import{t as v}from"./button-CGlRPNzi.js";import{n as y,r as b}from"./gateway-config-swr-BBovMBQ1.js";import{t as x}from"./skeleton-BwbyijEw.js";import{$i as S,Hl as C,Ql as w,Qs as T,Rc as ee,Zc as te,cl as ne,ea as E,kc as D,ru as re,zl as O}from"./index-B7EieIE4.js";import{n as ie,r as k}from"./settings-page-layout-CsUQKRq0.js";import{n as A}from"./settings-loading-skeleton-CAmWMaOT.js";import{n as j,t as ae}from"./use-autosave-htvgT192.js";import{t as M}from"./settings-advanced-gate-DuzZqQMn.js";var N=e(t(),1),P=n();function F(){return d(h(`/api/browser/status`))}function I(){return d(h(`/api/browser/test`),{method:`POST`})}function oe(e=!1){return d(h(`/api/browser/extension/install`),{method:`POST`,body:JSON.stringify({force:e})})}function L(e){return d(h(`/api/browser/extension/open`),{method:`POST`,body:JSON.stringify({action:e})})}async function R(e,t){let n=await p(h(`/api/browser/playwright/install/stream`),{method:`POST`,headers:{Accept:`text/event-stream`},signal:t});if(!n.ok||!n.body)throw Error(`Chromium install request failed (HTTP ${n.status}).`);let r=n.body.getReader(),i=new TextDecoder,a=``,o;try{for(;!o;){let t=await r.read();if(t.done)break;a+=i.decode(t.value,{stream:!0}),a=a.replace(/\r\n/g,`
2
+ `);let n=a.split(`
3
+
4
+ `);a=n.pop()??``;for(let t of n){let n=t.split(`
5
+ `).find(e=>e.startsWith(`event:`))?.slice(6).trim(),r=t.split(`
6
+ `).filter(e=>e.startsWith(`data:`)).map(e=>e.slice(5).trimStart()).join(``);r&&(n===`progress`&&e(JSON.parse(r)),n===`result`&&(o=JSON.parse(r)))}}}finally{r.releaseLock()}if(!o)throw Error(`Chromium installer ended without a result.`);return o}async function se(){await d(h(`/api/browser/playwright/install/cancel`),{method:`POST`})}function z(e){let[t,n]=(0,N.useState)(!1),[r,i]=(0,N.useState)(!1),[a,o]=(0,N.useState)(null),[s,c]=(0,N.useState)(null),l=(0,N.useRef)(null);return{running:t,cancelling:r,progress:a,error:s,install:(0,N.useCallback)(async()=>{if(l.current)return;let t=new AbortController;l.current=t,n(!0),o(null),c(null);try{let n=await R(o,t.signal);if(!n.ok){n.error!==`cancelled`&&c(n.message??n.error);return}e()}catch(e){t.signal.aborted||c(e instanceof Error?e.message:String(e))}finally{l.current===t&&(l.current=null),n(!1),i(!1)}},[e]),cancel:(0,N.useCallback)(async()=>{l.current&&(i(!0),await se().catch(()=>{}),l.current.abort())},[])}}var B=r(),V={extension:`Chrome extension`,playwright:`Playwright Chromium`,cdp:`CDP`,remote:`Remote browser`};function ce(e){let{enabled:t,driverKind:n,autosaveStatus:r,zh:a}=e,o=i(),c=_(t?[`browser-control-status`,n]:null,F,{revalidateOnFocus:!0,refreshInterval:n===`extension`?3e3:0}),[l,d]=(0,N.useState)(null),[f,p]=(0,N.useState)(null),[m,h]=(0,N.useState)(null),g=r===`dirty`||r===`saving`;(0,N.useEffect)(()=>{r===`saved`&&c.mutate()},[r,c.mutate]);let y=(0,N.useCallback)(async(e,t,n)=>{d(e),p(null),h(null);try{await t(),h(n),await c.mutate()}catch(e){p(e instanceof Error?e.message:String(e))}finally{d(null)}},[c.mutate]),b=z((0,N.useCallback)(()=>{h(a?`Chromium 已安装,可以开始连接测试。`:`Chromium is installed and ready to test.`),c.mutate()},[c.mutate,a])),S=c.data?.payload,C=S?.driverKind===n,w=t?g||!C?`syncing`:S?.state:`disabled`;return(0,B.jsxs)(`section`,{className:`rounded-xl border border-edge bg-surface-base p-5`,children:[(0,B.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,B.jsxs)(`div`,{className:`min-w-0`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,B.jsx)(w===`ready`?s:w===`syncing`?u:T,{className:`size-4 shrink-0 ${w===`ready`?`text-success`:w===`syncing`?`animate-spin text-fg-muted`:w===`disabled`?`text-fg-subtle`:`text-warning`}`}),(0,B.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:a?`浏览器就绪状态`:`Browser readiness`}),(0,B.jsx)(`span`,{className:`rounded-full px-2 py-0.5 text-xs ${w===`ready`?`bg-success-soft text-success`:w===`disabled`?`bg-surface-hover text-fg-muted`:`bg-warning-soft text-warning`}`,children:w===`ready`?a?`已就绪`:`Ready`:w===`disabled`?a?`未启用`:`Disabled`:w===`syncing`?a?`正在应用配置`:`Applying configuration`:a?`需要处理`:`Needs attention`})]}),(0,B.jsxs)(`p`,{className:`mt-2 text-sm text-fg-muted`,children:[V[n],S?.detail&&C?` · ${S.detail}`:``]})]}),(0,B.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,B.jsxs)(v,{variant:`ghost`,className:`h-9`,onClick:()=>void c.mutate(),disabled:c.isValidating,children:[(0,B.jsx)(D,{className:`size-3.5 ${c.isValidating?`animate-spin`:``}`}),a?`刷新`:`Refresh`]}),(0,B.jsxs)(v,{variant:`secondary`,className:`h-9`,disabled:!t||g||l!==null||b.running,onClick:()=>void y(`test`,I,a?`连接测试成功。`:`Connection test passed.`),children:[l===`test`?(0,B.jsx)(u,{className:`size-3.5 animate-spin`}):(0,B.jsx)(ee,{className:`size-3.5`}),a?`测试连接`:`Test connection`]})]})]}),t&&c.isLoading?(0,B.jsxs)(`div`,{className:`mt-4 grid gap-2 sm:grid-cols-3`,children:[(0,B.jsx)(x,{className:`h-12`}),(0,B.jsx)(x,{className:`h-12`}),(0,B.jsx)(x,{className:`h-12`})]}):null,t&&c.error?(0,B.jsx)(W,{tone:`error`,children:c.error instanceof Error?c.error.message:String(c.error)}):null,f||b.error?(0,B.jsx)(W,{tone:`error`,children:f??b.error}):null,m?(0,B.jsx)(W,{tone:`success`,children:m}):null,t&&n===`extension`&&C?(0,B.jsx)(H,{status:S?.driverStatus,zh:a,busy:l,run:y,onConnectRemote:()=>o(`/settings/devices?startDevicePairing=browser`)}):null,t&&n===`playwright`&&C?(0,B.jsx)(de,{status:S?.driverStatus,zh:a,installer:b}):null,t&&n===`cdp`?(0,B.jsx)(`p`,{className:`mt-4 rounded-lg bg-surface-subtle px-3 py-2 text-xs leading-5 text-fg-muted`,children:a?`连接测试会验证已保存的 CDP 地址,并复用浏览器中现有的标签页和登录状态。`:`The connection test verifies the saved CDP endpoint and reuses that browser’s existing tabs and signed-in state.`}):null,t&&n===`remote`?(0,B.jsx)(`p`,{className:`mt-4 rounded-lg bg-surface-subtle px-3 py-2 text-xs leading-5 text-fg-muted`,children:a?`连接测试会在服务商侧创建一个临时浏览器会话,并在测试结束后立即关闭。`:`The connection test creates a temporary provider session and closes it immediately after the test.`}):null]})}function H(e){let t=(0,P.c)(70),{status:n,zh:r,busy:i,run:a,onConnectRemote:o}=e,s=n?.artifacts,d=r?`扩展文件`:`Extension files`,f=s?.installed===!0,p=s?.installed?r?`已安装`:`Installed`:r?`未安装或需更新`:`Install or update required`,m;t[0]!==d||t[1]!==f||t[2]!==p?(m=(0,B.jsx)(U,{label:d,ok:f,value:p}),t[0]=d,t[1]=f,t[2]=p,t[3]=m):m=t[3];let h=r?`本机自动发现`:`Local auto-discovery`,g=s?.nativeHost?.installed===!0,_=s?.nativeHost?.installed?r?`已就绪`:`Ready`:s?.nativeHost?.reason??(r?`需要修复`:`Repair required`),y;t[4]!==h||t[5]!==g||t[6]!==_?(y=(0,B.jsx)(U,{label:h,ok:g,value:_}),t[4]=h,t[5]=g,t[6]=_,t[7]=y):y=t[7];let b=r?`安全通道`:`Secure channel`,x=n?.transport===`gateway-realtime`,S=n?.transport===`gateway-realtime`?`Gateway Realtime`:r?`不可用`:`Unavailable`,w;t[8]!==S||t[9]!==b||t[10]!==x?(w=(0,B.jsx)(U,{label:b,ok:x,value:S}),t[8]=S,t[9]=b,t[10]=x,t[11]=w):w=t[11];let T=r?`Chrome 连接`:`Chrome connection`,te=n?.connected===!0,ne=n?.connected?r?`已连接`:`Connected`:n?.socketConnected?r?`需要重新加载扩展`:`Reload extension`:r?`等待扩展连接`:`Waiting for extension`,E;t[12]!==T||t[13]!==te||t[14]!==ne?(E=(0,B.jsx)(U,{label:T,ok:te,value:ne}),t[12]=T,t[13]=te,t[14]=ne,t[15]=E):E=t[15];let D;t[16]!==w||t[17]!==E||t[18]!==m||t[19]!==y?(D=(0,B.jsxs)(`div`,{className:`grid gap-2 sm:grid-cols-2 lg:grid-cols-4`,children:[m,y,w,E]}),t[16]=w,t[17]=E,t[18]=m,t[19]=y,t[20]=D):D=t[20];let re=s?.extensionDir??`Gateway Realtime`,O;t[21]===re?O=t[22]:(O=(0,B.jsx)(`p`,{className:`mt-3 break-all text-xs text-fg-subtle`,children:re}),t[21]=re,t[22]=O);let ie=s?.installed?`secondary`:`primary`,k=i!==null,A;t[23]!==s?.installed||t[24]!==a||t[25]!==r?(A=()=>void a(`extension-install`,()=>oe(!!s?.installed),r?`扩展文件已准备好。`:`Extension files are ready.`),t[23]=s?.installed,t[24]=a,t[25]=r,t[26]=A):A=t[26];let j;t[27]===i?j=t[28]:(j=i===`extension-install`?(0,B.jsx)(u,{className:`size-3.5 animate-spin`}):(0,B.jsx)(c,{className:`size-3.5`}),t[27]=i,t[28]=j);let ae=s?.installed?r?`刷新扩展文件`:`Refresh files`:r?`安装扩展文件`:`Install extension`,M;t[29]!==ie||t[30]!==k||t[31]!==A||t[32]!==j||t[33]!==ae?(M=(0,B.jsxs)(v,{className:`h-9`,variant:ie,disabled:k,onClick:A,children:[j,ae]}),t[29]=ie,t[30]=k,t[31]=A,t[32]=j,t[33]=ae,t[34]=M):M=t[34];let N=!s?.installed||i!==null,F;t[35]!==a||t[36]!==r?(F=()=>void a(`extension-open`,ue,r?`已打开 Chrome 扩展页。`:`Chrome extensions opened.`),t[35]=a,t[36]=r,t[37]=F):F=t[37];let I;t[38]===Symbol.for(`react.memo_cache_sentinel`)?(I=(0,B.jsx)(l,{className:`size-3.5`}),t[38]=I):I=t[38];let L=r?`打开扩展页`:`Open extensions`,R;t[39]!==N||t[40]!==F||t[41]!==L?(R=(0,B.jsxs)(v,{className:`h-9`,variant:`secondary`,disabled:N,onClick:F,children:[I,L]}),t[39]=N,t[40]=F,t[41]=L,t[42]=R):R=t[42];let se=!s?.installed||i!==null,z;t[43]!==a||t[44]!==r?(z=()=>void a(`extension-folder`,le,r?`已打开扩展目录。`:`Extension folder opened.`),t[43]=a,t[44]=r,t[45]=z):z=t[45];let V;t[46]===Symbol.for(`react.memo_cache_sentinel`)?(V=(0,B.jsx)(C,{className:`size-3.5`}),t[46]=V):V=t[46];let ce=r?`打开扩展目录`:`Open folder`,H;t[47]!==se||t[48]!==z||t[49]!==ce?(H=(0,B.jsxs)(v,{className:`h-9`,variant:`ghost`,disabled:se,onClick:z,children:[V,ce]}),t[47]=se,t[48]=z,t[49]=ce,t[50]=H):H=t[50];let de=i!==null,W;t[51]===Symbol.for(`react.memo_cache_sentinel`)?(W=(0,B.jsx)(ee,{className:`size-3.5`}),t[51]=W):W=t[51];let fe=r?`连接远程 Chrome`:`Connect remote Chrome`,G;t[52]!==o||t[53]!==de||t[54]!==fe?(G=(0,B.jsxs)(v,{className:`h-9`,variant:`secondary`,disabled:de,onClick:o,children:[W,fe]}),t[52]=o,t[53]=de,t[54]=fe,t[55]=G):G=t[55];let K;t[56]!==M||t[57]!==R||t[58]!==H||t[59]!==G?(K=(0,B.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[M,R,H,G]}),t[56]=M,t[57]=R,t[58]=H,t[59]=G,t[60]=K):K=t[60];let q;t[61]!==n?.connected||t[62]!==n?.socketConnected||t[63]!==r?(q=n?.connected?null:(0,B.jsx)(`p`,{className:`mt-3 text-xs leading-5 text-fg-muted`,children:n?.socketConnected?r?`扩展仍在运行旧协议。请打开 Chrome 扩展页,找到 xopc 并点击“重新加载”,然后刷新状态。`:`The extension is still running an older protocol. Open Chrome Extensions, find xopc, click Reload, then refresh status.`:r?`打开 xopc Chrome 扩展后,它会自动发现并安全连接本机 Gateway;只有连接另一台电脑时才需要一次性邀请和手动确认。`:`Open the xopc Chrome extension to discover and securely connect to a local Gateway automatically. A one-time invitation and explicit approval are only required for Chrome on another computer.`}),t[61]=n?.connected,t[62]=n?.socketConnected,t[63]=r,t[64]=q):q=t[64];let J;return t[65]!==D||t[66]!==O||t[67]!==K||t[68]!==q?(J=(0,B.jsxs)(`div`,{className:`mt-4 border-t border-edge-subtle pt-4`,children:[D,O,K,q]}),t[65]=D,t[66]=O,t[67]=K,t[68]=q,t[69]=J):J=t[69],J}function le(){return L(`folder`)}function ue(){return L(`chrome`)}function de(e){let t=(0,P.c)(28),{status:n,zh:r,installer:i}=e,a=n?.installed===!0,o=n?.installed?r?`已安装`:`Installed`:n?.reason??(r?`未安装`:`Not installed`),s;t[0]!==a||t[1]!==o?(s=(0,B.jsx)(U,{label:`Chromium`,ok:a,value:o}),t[0]=a,t[1]=o,t[2]=s):s=t[2];let l;t[3]===n?l=t[4]:(l=n?.executablePath?(0,B.jsx)(`p`,{className:`mt-2 break-all text-xs text-fg-subtle`,children:n.executablePath}):null,t[3]=n,t[4]=l);let d;t[5]===i.progress?d=t[6]:(d=i.progress?(0,B.jsxs)(`div`,{className:`mt-3`,children:[(0,B.jsxs)(`div`,{className:`flex justify-between text-xs text-fg-muted`,children:[(0,B.jsx)(`span`,{children:i.progress.message??i.progress.phase}),(0,B.jsx)(`span`,{children:i.progress.percent==null?``:`${Math.round(i.progress.percent)}%`})]}),(0,B.jsx)(`div`,{className:`mt-1 h-1.5 overflow-hidden rounded-full bg-surface-hover`,children:(0,B.jsx)(`div`,{className:`h-full rounded-full bg-accent transition-[width]`,style:{width:`${i.progress.percent??8}%`}})})]}):null,t[5]=i.progress,t[6]=d);let f=n?.installed?`secondary`:`primary`,p;t[7]===i?p=t[8]:(p=()=>void i.install(),t[7]=i,t[8]=p);let m;t[9]===i.running?m=t[10]:(m=i.running?(0,B.jsx)(u,{className:`size-3.5 animate-spin`}):(0,B.jsx)(c,{className:`size-3.5`}),t[9]=i.running,t[10]=m);let h=n?.installed?r?`重新安装 Chromium`:`Reinstall Chromium`:r?`安装 Chromium`:`Install Chromium`,g;t[11]!==i.running||t[12]!==f||t[13]!==p||t[14]!==m||t[15]!==h?(g=(0,B.jsxs)(v,{variant:f,className:`h-9`,disabled:i.running,onClick:p,children:[m,h]}),t[11]=i.running,t[12]=f,t[13]=p,t[14]=m,t[15]=h,t[16]=g):g=t[16];let _;t[17]!==i||t[18]!==r?(_=i.running?(0,B.jsx)(v,{variant:`ghost`,className:`h-9`,disabled:i.cancelling,onClick:()=>void i.cancel(),children:i.cancelling?r?`正在取消…`:`Cancelling…`:r?`取消`:`Cancel`}):null,t[17]=i,t[18]=r,t[19]=_):_=t[19];let y;t[20]!==_||t[21]!==g?(y=(0,B.jsxs)(`div`,{className:`mt-3 flex gap-2`,children:[g,_]}),t[20]=_,t[21]=g,t[22]=y):y=t[22];let b;return t[23]!==y||t[24]!==s||t[25]!==l||t[26]!==d?(b=(0,B.jsxs)(`div`,{className:`mt-4 border-t border-edge-subtle pt-4`,children:[s,l,d,y]}),t[23]=y,t[24]=s,t[25]=l,t[26]=d,t[27]=b):b=t[27],b}function U(e){let t=(0,P.c)(11),{label:n,ok:r,value:i}=e,a;t[0]===n?a=t[1]:(a=(0,B.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n}),t[0]=n,t[1]=a);let o=`mt-1 flex items-center gap-1.5 text-sm ${r?`text-success`:`text-fg-muted`}`,s=`size-1.5 rounded-full ${r?`bg-success`:`bg-warning`}`,c;t[2]===s?c=t[3]:(c=(0,B.jsx)(`span`,{className:s}),t[2]=s,t[3]=c);let l;t[4]!==o||t[5]!==c||t[6]!==i?(l=(0,B.jsxs)(`p`,{className:o,children:[c,i]}),t[4]=o,t[5]=c,t[6]=i,t[7]=l):l=t[7];let u;return t[8]!==a||t[9]!==l?(u=(0,B.jsxs)(`div`,{className:`rounded-lg bg-surface-subtle px-3 py-2`,children:[a,l]}),t[8]=a,t[9]=l,t[10]=u):u=t[10],u}function W(e){let t=(0,P.c)(4),{tone:n,children:r}=e,i=`mt-3 rounded-lg px-3 py-2 text-xs ${n===`success`?`bg-success-soft text-success`:`bg-danger-soft text-danger`}`,a=n===`error`?`alert`:`status`,o;return t[0]!==r||t[1]!==i||t[2]!==a?(o=(0,B.jsx)(`p`,{className:i,role:a,children:r}),t[0]=r,t[1]=i,t[2]=a,t[3]=o):o=t[3],o}function fe(e){let t=(0,P.c)(36),{sectionId:n,vm:r,children:i}=e,a=m(G),o;t[0]===a?o=t[1]:(o=g(a),t[0]=a,t[1]=o);let s=o,c=s.agentSettings,l=s.settingsSections[n]??n;if(!r.hasToken){let e;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,B.jsx)(re,{className:`mt-0.5 size-5 shrink-0 text-fg-subtle`,strokeWidth:1.75}),t[2]=e):e=t[2];let n;t[3]===l?n=t[4]:(n=(0,B.jsx)(`h1`,{className:`text-base font-semibold text-fg`,children:l}),t[3]=l,t[4]=n);let r;t[5]===c.needToken?r=t[6]:(r=(0,B.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:c.needToken}),t[5]=c.needToken,t[6]=r);let i;return t[7]!==n||t[8]!==r?(i=(0,B.jsx)(k,{gap:`gap-3`,padding:`px-3 py-10 sm:px-5 xl:px-6`,children:(0,B.jsxs)(`div`,{className:`flex items-start gap-3 rounded-2xl bg-surface-base p-6`,children:[e,(0,B.jsxs)(`div`,{children:[n,r]})]})}),t[7]=n,t[8]=r,t[9]=i):i=t[9],i}if(r.loading){let e;return t[10]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,B.jsx)(k,{gap:`gap-6`,padding:`px-3 py-8 sm:px-5 xl:px-6`,children:(0,B.jsx)(A,{sections:1})}),t[10]=e):e=t[10],e}if(!r.form){let e=r.error??r.fetchError??c.loadError,n;t[11]===e?n=t[12]:(n=(0,B.jsx)(`p`,{className:`text-sm text-fg-muted`,children:e}),t[11]=e,t[12]=n);let i;t[13]===r?i=t[14]:(i=()=>void r.mutate(),t[13]=r,t[14]=i);let a;t[15]!==s.logs.refresh||t[16]!==i?(a=(0,B.jsx)(v,{type:`button`,variant:`secondary`,onClick:i,children:s.logs.refresh}),t[15]=s.logs.refresh,t[16]=i,t[17]=a):a=t[17];let o;return t[18]!==n||t[19]!==a?(o=(0,B.jsxs)(k,{gap:`gap-3`,padding:`px-3 py-10 sm:px-5 xl:px-6`,children:[n,a]}),t[18]=n,t[19]=a,t[20]=o):o=t[20],o}let u;t[21]!==r.autosaveStatus||t[22]!==r.error?(u=(0,B.jsx)(j,{status:r.autosaveStatus,error:r.error}),t[21]=r.autosaveStatus,t[22]=r.error,t[23]=u):u=t[23];let d;t[24]!==l||t[25]!==u?(d=(0,B.jsx)(ie,{title:l,actions:u}),t[24]=l,t[25]=u,t[26]=d):d=t[26];let f;t[27]===r.error?f=t[28]:(f=r.error?(0,B.jsx)(`div`,{className:`rounded-md border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-700 dark:border-red-900/50 dark:bg-red-950/50 dark:text-red-400`,role:`alert`,children:r.error}):null,t[27]=r.error,t[28]=f);let p;t[29]===i?p=t[30]:(p=(0,B.jsx)(`div`,{className:`flex min-w-0 flex-col gap-5 pb-8`,children:i}),t[29]=i,t[30]=p);let h;return t[31]!==d||t[32]!==f||t[33]!==p||t[34]!==r.onBlurCapture?(h=(0,B.jsxs)(k,{gap:`gap-6`,onBlurCapture:r.onBlurCapture,children:[d,f,p]}),t[31]=d,t[32]=f,t[33]=p,t[34]=r.onBlurCapture,t[35]=h):h=t[35],h}function G(e){return e.language}var K={enabled:!0,driverKind:`extension`,headless:!1,executablePath:``,cdpEndpoint:`http://127.0.0.1:9222`,remoteProvider:`browserbase`,remoteApiKey:``,remoteProjectId:``,remoteRegion:``,maxNodes:180,maxCharacters:12e3,visualFallback:!0,actionTimeoutMs:3e4,sessionTimeoutMs:9e5,maxSequenceLength:5,allowedPrivateHosts:``,crossDomainNavigation:`ask`,uploads:`ask`,consequentialActions:`ask`};function q(e){let t=Y(Y(e).browser),n=Y(t.driver),r=Y(t.observation),i=Y(t.limits),a=Y(t.security),o=n.kind;return{...K,enabled:t.enabled!==!1,driverKind:o===`playwright`||o===`cdp`||o===`remote`?o:`extension`,headless:n.headless===!0,executablePath:X(n.executablePath,``),cdpEndpoint:X(n.endpoint,K.cdpEndpoint),remoteProvider:n.provider===`browser-use`?`browser-use`:`browserbase`,remoteApiKey:X(n.apiKey,``),remoteProjectId:X(n.projectId,``),remoteRegion:X(n.region,``),maxNodes:Z(r.maxNodes,K.maxNodes),maxCharacters:Z(r.maxCharacters,K.maxCharacters),visualFallback:r.visualFallback!==!1,actionTimeoutMs:Z(i.actionTimeoutMs,K.actionTimeoutMs),sessionTimeoutMs:Z(i.sessionTimeoutMs,K.sessionTimeoutMs),maxSequenceLength:Z(i.maxSequenceLength,K.maxSequenceLength),allowedPrivateHosts:Array.isArray(a.allowedPrivateHosts)?a.allowedPrivateHosts.filter(e=>typeof e==`string`).join(`
7
+ `):``,crossDomainNavigation:he(a.crossDomainNavigation),uploads:he(a.uploads),consequentialActions:he(a.consequentialActions)}}function J(e){let t=e.driverKind===`extension`?{kind:`extension`}:e.driverKind===`playwright`?{kind:`playwright`,headless:e.headless,...e.executablePath.trim()?{executablePath:e.executablePath.trim()}:{}}:e.driverKind===`cdp`?{kind:`cdp`,endpoint:e.cdpEndpoint.trim()}:{kind:`remote`,provider:e.remoteProvider,...e.remoteApiKey.trim()?{apiKey:e.remoteApiKey.trim()}:{},...e.remoteProjectId.trim()?{projectId:e.remoteProjectId.trim()}:{},...e.remoteRegion.trim()?{region:e.remoteRegion.trim()}:{}};return{enabled:e.enabled,driver:t,observation:{maxNodes:e.maxNodes,maxCharacters:e.maxCharacters,visualFallback:e.visualFallback},limits:{actionTimeoutMs:e.actionTimeoutMs,sessionTimeoutMs:e.sessionTimeoutMs,maxSequenceLength:e.maxSequenceLength},security:{privateNetworks:`deny`,allowedPrivateHosts:e.allowedPrivateHosts.split(`
8
+ `).map(e=>e.trim()).filter(Boolean),crossDomainNavigation:e.crossDomainNavigation,uploads:e.uploads,consequentialActions:e.consequentialActions}}}function pe(e){if(e.driverKind===`cdp`)try{let t=new URL(e.cdpEndpoint);if(t.protocol!==`http:`&&t.protocol!==`https:`&&t.protocol!==`ws:`&&t.protocol!==`wss:`)return`CDP endpoint must use http, https, ws, or wss.`}catch{return`Enter a valid CDP endpoint URL.`}return!Number.isInteger(e.maxNodes)||e.maxNodes<20||e.maxNodes>500?`Max nodes must be between 20 and 500.`:!Number.isInteger(e.maxCharacters)||e.maxCharacters<1e3||e.maxCharacters>5e4?`Max characters must be between 1,000 and 50,000.`:!Number.isInteger(e.actionTimeoutMs)||e.actionTimeoutMs<1e3||e.actionTimeoutMs>12e4?`Action timeout must be between 1,000 and 120,000 ms.`:!Number.isInteger(e.sessionTimeoutMs)||e.sessionTimeoutMs<6e4||e.sessionTimeoutMs>36e5?`Session timeout must be between 60,000 and 3,600,000 ms.`:!Number.isInteger(e.maxSequenceLength)||e.maxSequenceLength<1||e.maxSequenceLength>10?`Sequence length must be between 1 and 10.`:null}async function me(e){await d(h(`/api/config`),{method:`PATCH`,body:JSON.stringify({browser:J(e)})}),y()}function Y(e){return e&&typeof e==`object`&&!Array.isArray(e)?e:{}}function X(e,t){return typeof e==`string`?e:t}function Z(e,t){return typeof e==`number`&&Number.isFinite(e)?e:t}function he(e){return e===`allow`||e===`deny`?e:`ask`}var ge=S();function _e(e){let t=!!f(e=>e.conversationId),[n,r]=(0,N.useReducer)(ge,{form:null,baseline:null}),i=n.form,a=n.baseline,o=(0,N.useRef)(!1),s=(0,N.useRef)(i);s.current=i;let c=(0,N.useRef)(null),{data:l,error:u,isLoading:d,mutate:p}=b(t);E({enabled:t,parsed:(0,N.useMemo)(()=>l?.payload?.config===void 0?null:q(l.payload.config),[l]),dirty:o.current,trackedParsedRef:c,dispatch:r,onResetDirty:()=>{o.current=!1}});let m=!!(t&&d&&l===void 0&&!u),h=u instanceof Error?u.message:u?String(u):null,g=(0,N.useMemo)(()=>!i||!a?!1:JSON.stringify(i)!==JSON.stringify(a),[i,a]),_=(0,N.useCallback)(e=>{o.current=!0,r({type:`patch`,patch:e})},[]),v=ae({value:i,dirty:g,onSave:(0,N.useCallback)(async t=>{try{await me(t),r({type:`saved`,value:t}),o.current=!!(s.current&&JSON.stringify(s.current)!==JSON.stringify(t))}catch(t){throw Error(t instanceof Error?t.message:e.saveError)}},[e.saveError]),validate:pe});return{hasToken:t,loading:m,fetchError:h,form:i,update:_,autosaveStatus:v.status,error:v.error,onBlurCapture:v.onBlurCapture,mutate:p}}var ve=[`extension`,`playwright`,`cdp`,`remote`];function ye(){let e=(0,P.c)(29),t=m(be),n;e[0]===t?n=e[1]:(n=g(t),e[0]=t,e[1]=n);let r=_e(n.agentSettings),i=r.form,s=t===`zh`,[c]=a(),l=(0,N.useRef)(!1),u;e[2]!==i||e[3]!==c||e[4]!==r?(u=()=>{if(!i||l.current)return;l.current=!0;let e=c.get(`driver`);ve.includes(e)&&e!==i.driverKind&&r.update({driverKind:e})},e[2]=i,e[3]=c,e[4]=r,e[5]=u):u=e[5];let d;e[6]!==i||e[7]!==c||e[8]!==r.update?(d=[i,c,r.update],e[6]=i,e[7]=c,e[8]=r.update,e[9]=d):d=e[9],(0,N.useEffect)(u,d);let f=s?`Chrome 扩展(推荐)`:`Chrome extension (recommended)`,p;e[10]===f?p=e[11]:(p={value:`extension`,label:f},e[10]=f,e[11]=p);let h;e[12]===Symbol.for(`react.memo_cache_sentinel`)?(h={value:`playwright`,label:`Playwright Chromium`},e[12]=h):h=e[12];let _=s?`CDP 已有浏览器`:`Existing browser over CDP`,v;e[13]===_?v=e[14]:(v={value:`cdp`,label:_},e[13]=_,e[14]=v);let y=s?`远程浏览器`:`Remote browser`,b;e[15]===y?b=e[16]:(b={value:`remote`,label:y},e[15]=y,e[16]=b);let x;e[17]!==p||e[18]!==v||e[19]!==b?(x=[p,h,v,b],e[17]=p,e[18]=v,e[19]=b,e[20]=x):x=e[20];let S=x,C;e[21]!==S||e[22]!==i||e[23]!==r||e[24]!==s?(C=i?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(ce,{enabled:i.enabled,driverKind:i.driverKind,autosaveStatus:r.autosaveStatus,zh:s}),(0,B.jsxs)(Se,{title:s?`运行方式`:`Connection`,icon:(0,B.jsx)(te,{className:`size-4`}),children:[(0,B.jsx)(we,{label:s?`启用浏览器控制`:`Enable browser control`,checked:i.enabled,onChange:e=>r.update({enabled:e})}),(0,B.jsx)(Q,{label:s?`浏览器连接`:`Browser connection`,children:(0,B.jsx)(o,{value:i.driverKind,options:S,placeholder:s?`选择连接方式`:`Choose a connection`,allowEmpty:!1,onChange:e=>r.update({driverKind:e})})}),(0,B.jsx)(xe,{kind:i.driverKind,zh:s}),i.driverKind===`playwright`?(0,B.jsxs)(`div`,{className:`space-y-4 rounded-lg bg-surface-subtle p-4`,children:[(0,B.jsx)(we,{label:s?`无头模式`:`Headless mode`,description:s?`后台运行,不显示浏览器窗口。关闭后可观察智能体的操作过程。`:`Run in the background without a visible window. Turn off to watch the agent work.`,checked:i.headless,onChange:e=>r.update({headless:e})}),(0,B.jsx)($,{label:s?`Chromium 可执行文件(可选)`:`Chromium executable (optional)`,description:s?`留空时使用由 xopc 安装的 Chromium。`:`Leave empty to use Chromium installed by xopc.`,value:i.executablePath,onChange:e=>r.update({executablePath:e})})]}):null,i.driverKind===`cdp`?(0,B.jsx)(`div`,{className:`rounded-lg bg-surface-subtle p-4`,children:(0,B.jsx)($,{label:`CDP endpoint`,description:s?`例如 http://127.0.0.1:9222。Chrome 需要开启 remote debugging。`:`For example http://127.0.0.1:9222. Chrome must be started with remote debugging enabled.`,value:i.cdpEndpoint,onChange:e=>r.update({cdpEndpoint:e})})}):null,i.driverKind===`remote`?(0,B.jsxs)(`div`,{className:`space-y-4 rounded-lg bg-surface-subtle p-4`,children:[(0,B.jsx)(Q,{label:s?`服务商`:`Provider`,children:(0,B.jsx)(o,{value:i.remoteProvider,options:[{value:`browserbase`,label:`Browserbase`},{value:`browser-use`,label:`Browser Use`}],placeholder:s?`选择服务商`:`Choose a provider`,allowEmpty:!1,onChange:e=>r.update({remoteProvider:e})})}),(0,B.jsx)($,{label:`API key`,type:`password`,autoComplete:`off`,value:i.remoteApiKey,onChange:e=>r.update({remoteApiKey:e})}),(0,B.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,B.jsx)($,{label:`Project ID`,value:i.remoteProjectId,onChange:e=>r.update({remoteProjectId:e})}),(0,B.jsx)($,{label:`Region`,value:i.remoteRegion,onChange:e=>r.update({remoteRegion:e})})]})]}):null]}),(0,B.jsx)(M,{children:(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(Se,{title:s?`页面理解`:`Page understanding`,icon:(0,B.jsx)(w,{className:`size-4`}),children:[(0,B.jsx)(we,{label:s?`需要时附加截图`:`Attach screenshots when needed`,checked:i.visualFallback,onChange:e=>r.update({visualFallback:e})}),(0,B.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,B.jsx)(Ce,{label:s?`语义节点上限`:`Semantic node limit`,description:`20–500`,min:20,max:500,value:i.maxNodes,onChange:e=>r.update({maxNodes:e})}),(0,B.jsx)(Ce,{label:s?`文本字符上限`:`Text character limit`,description:`1,000–50,000`,min:1e3,max:5e4,step:1e3,value:i.maxCharacters,onChange:e=>r.update({maxCharacters:e})})]})]}),(0,B.jsx)(Se,{title:s?`执行限制`:`Execution limits`,icon:(0,B.jsx)(O,{className:`size-4`}),children:(0,B.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-3`,children:[(0,B.jsx)(Ce,{label:s?`操作超时(毫秒)`:`Action timeout (ms)`,min:1e3,max:12e4,step:1e3,value:i.actionTimeoutMs,onChange:e=>r.update({actionTimeoutMs:e})}),(0,B.jsx)(Ce,{label:s?`会话超时(毫秒)`:`Session timeout (ms)`,min:6e4,max:36e5,step:6e4,value:i.sessionTimeoutMs,onChange:e=>r.update({sessionTimeoutMs:e})}),(0,B.jsx)(Ce,{label:s?`批量步骤上限`:`Sequence step limit`,min:1,max:10,value:i.maxSequenceLength,onChange:e=>r.update({maxSequenceLength:e})})]})}),(0,B.jsxs)(Se,{title:s?`安全与审批`:`Safety and approvals`,icon:(0,B.jsx)(ne,{className:`size-4`}),children:[(0,B.jsx)($,{label:s?`允许访问的私网主机`:`Allowed private hosts`,description:s?`每行一个主机名或 IP,不支持通配符。`:`One hostname or IP per line. Wildcards are not supported.`,multiline:!0,value:i.allowedPrivateHosts,onChange:e=>r.update({allowedPrivateHosts:e})}),(0,B.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-3`,children:[(0,B.jsx)(Te,{zh:s,label:s?`跨域导航`:`Cross-domain navigation`,value:i.crossDomainNavigation,onChange:e=>r.update({crossDomainNavigation:e})}),(0,B.jsx)(Te,{zh:s,label:s?`高影响动作`:`Consequential actions`,value:i.consequentialActions,onChange:e=>r.update({consequentialActions:e})}),(0,B.jsx)(Te,{zh:s,label:s?`文件上传`:`File uploads`,value:i.uploads,onChange:e=>r.update({uploads:e})})]})]})]})})]}):null,e[21]=S,e[22]=i,e[23]=r,e[24]=s,e[25]=C):C=e[25];let T;return e[26]!==C||e[27]!==r?(T=(0,B.jsx)(fe,{sectionId:`agent-browser`,vm:r,children:C}),e[26]=C,e[27]=r,e[28]=T):T=e[28],T}function be(e){return e.language}function xe(e){let t=(0,P.c)(7),{kind:n,zh:r}=e,i=r?`直接操作你正在使用的 Chrome,保留登录状态和现有标签页;最适合日常协作。`:`Operate your current Chrome with its signed-in state and existing tabs; best for daily collaboration.`,a=r?`由 xopc 启动独立 Chromium,环境隔离、自动化稳定,适合无人值守任务。`:`Let xopc launch an isolated Chromium; stable for unattended automation.`,o=r?`连接已开启远程调试的 Chrome 或 Chromium,适合自定义浏览器启动方式。`:`Connect to Chrome or Chromium already running with remote debugging.`,s=r?`使用 Browserbase 或 Browser Use 的云端浏览器,适合服务器环境和长任务。`:`Use a Browserbase or Browser Use cloud browser for servers and long-running tasks.`,c;t[0]!==i||t[1]!==a||t[2]!==o||t[3]!==s?(c={extension:i,playwright:a,cdp:o,remote:s},t[0]=i,t[1]=a,t[2]=o,t[3]=s,t[4]=c):c=t[4];let l=c[n],u;return t[5]===l?u=t[6]:(u=(0,B.jsx)(`p`,{className:`rounded-lg bg-surface-subtle px-3 py-2 text-xs leading-5 text-fg-muted`,children:l}),t[5]=l,t[6]=u),u}function Se(e){let t=(0,P.c)(17),{title:n,description:r,icon:i,children:a}=e,o;t[0]===i?o=t[1]:(o=(0,B.jsx)(`span`,{className:`mt-0.5 text-fg-subtle`,children:i}),t[0]=i,t[1]=o);let s;t[2]===n?s=t[3]:(s=(0,B.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:n}),t[2]=n,t[3]=s);let c;t[4]===r?c=t[5]:(c=r?(0,B.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:r}):null,t[4]=r,t[5]=c);let l;t[6]!==s||t[7]!==c?(l=(0,B.jsxs)(`div`,{children:[s,c]}),t[6]=s,t[7]=c,t[8]=l):l=t[8];let u;t[9]!==o||t[10]!==l?(u=(0,B.jsxs)(`div`,{className:`mb-4 flex items-start gap-2`,children:[o,l]}),t[9]=o,t[10]=l,t[11]=u):u=t[11];let d;t[12]===a?d=t[13]:(d=(0,B.jsx)(`div`,{className:`space-y-4`,children:a}),t[12]=a,t[13]=d);let f;return t[14]!==u||t[15]!==d?(f=(0,B.jsxs)(`section`,{className:`rounded-xl border border-edge bg-surface-base p-5`,children:[u,d]}),t[14]=u,t[15]=d,t[16]=f):f=t[16],f}function Q(e){let t=(0,P.c)(8),{label:n,description:r,children:i}=e,a;t[0]===n?a=t[1]:(a=(0,B.jsx)(`span`,{className:`mb-1.5 block font-medium`,children:n}),t[0]=n,t[1]=a);let o;t[2]===r?o=t[3]:(o=r?(0,B.jsx)(`span`,{className:`mt-1.5 block text-xs leading-5 text-fg-subtle`,children:r}):null,t[2]=r,t[3]=o);let s;return t[4]!==i||t[5]!==a||t[6]!==o?(s=(0,B.jsxs)(`label`,{className:`block text-sm text-fg`,children:[a,i,o]}),t[4]=i,t[5]=a,t[6]=o,t[7]=s):s=t[7],s}function $(e){let t=(0,P.c)(10),{label:n,description:r,value:i,onChange:a,type:o,multiline:s,autoComplete:c}=e,l=o===void 0?`text`:o,u=s===void 0?!1:s,d;t[0]!==c||t[1]!==u||t[2]!==a||t[3]!==l||t[4]!==i?(d=u?(0,B.jsx)(`textarea`,{rows:3,value:i,onChange:e=>a(e.target.value),className:`w-full rounded-lg border border-edge bg-surface-subtle px-3 py-2 text-sm text-fg outline-none focus:border-accent`}):(0,B.jsx)(`input`,{type:l,autoComplete:c,value:i,onChange:e=>a(e.target.value),className:`w-full rounded-lg border border-edge bg-surface-subtle px-3 py-2 text-sm text-fg outline-none focus:border-accent`}),t[0]=c,t[1]=u,t[2]=a,t[3]=l,t[4]=i,t[5]=d):d=t[5];let f;return t[6]!==r||t[7]!==n||t[8]!==d?(f=(0,B.jsx)(Q,{label:n,description:r,children:d}),t[6]=r,t[7]=n,t[8]=d,t[9]=f):f=t[9],f}function Ce(e){let t=(0,P.c)(12),{label:n,description:r,value:i,onChange:a,min:o,max:s,step:c}=e,l=c===void 0?1:c,u;t[0]===a?u=t[1]:(u=e=>{let t=Number(e.target.value);Number.isFinite(t)&&a(t)},t[0]=a,t[1]=u);let d;t[2]!==s||t[3]!==o||t[4]!==l||t[5]!==u||t[6]!==i?(d=(0,B.jsx)(`input`,{type:`number`,min:o,max:s,step:l,value:i,onChange:u,className:`h-10 w-full rounded-lg border border-edge bg-surface-subtle px-3 text-sm text-fg outline-none focus:border-accent`}),t[2]=s,t[3]=o,t[4]=l,t[5]=u,t[6]=i,t[7]=d):d=t[7];let f;return t[8]!==r||t[9]!==n||t[10]!==d?(f=(0,B.jsx)(Q,{label:n,description:r,children:d}),t[8]=r,t[9]=n,t[10]=d,t[11]=f):f=t[11],f}function we(e){let t=(0,P.c)(15),{label:n,description:r,checked:i,onChange:a}=e,o;t[0]===a?o=t[1]:(o=e=>a(e.target.checked),t[0]=a,t[1]=o);let s;t[2]!==i||t[3]!==o?(s=(0,B.jsx)(`input`,{type:`checkbox`,checked:i,onChange:o,className:`mt-0.5 size-4 accent-accent`}),t[2]=i,t[3]=o,t[4]=s):s=t[4];let c;t[5]===n?c=t[6]:(c=(0,B.jsx)(`span`,{className:`block font-medium`,children:n}),t[5]=n,t[6]=c);let l;t[7]===r?l=t[8]:(l=r?(0,B.jsx)(`span`,{className:`mt-1 block text-xs leading-5 text-fg-subtle`,children:r}):null,t[7]=r,t[8]=l);let u;t[9]!==c||t[10]!==l?(u=(0,B.jsxs)(`span`,{children:[c,l]}),t[9]=c,t[10]=l,t[11]=u):u=t[11];let d;return t[12]!==s||t[13]!==u?(d=(0,B.jsxs)(`label`,{className:`flex items-start gap-3 text-sm text-fg`,children:[s,u]}),t[12]=s,t[13]=u,t[14]=d):d=t[14],d}function Te(e){let t=(0,P.c)(20),{zh:n,label:r,value:i,onChange:a}=e,s=n?`每次询问`:`Ask each time`,c;t[0]===s?c=t[1]:(c={value:`ask`,label:s},t[0]=s,t[1]=c);let l=n?`允许`:`Allow`,u;t[2]===l?u=t[3]:(u={value:`allow`,label:l},t[2]=l,t[3]=u);let d=n?`拒绝`:`Deny`,f;t[4]===d?f=t[5]:(f={value:`deny`,label:d},t[4]=d,t[5]=f);let p;t[6]!==c||t[7]!==u||t[8]!==f?(p=[c,u,f],t[6]=c,t[7]=u,t[8]=f,t[9]=p):p=t[9];let m=p,h=n?`选择策略`:`Choose a policy`,g;t[10]===a?g=t[11]:(g=e=>a(e),t[10]=a,t[11]=g);let _;t[12]!==m||t[13]!==h||t[14]!==g||t[15]!==i?(_=(0,B.jsx)(o,{value:i,options:m,placeholder:h,allowEmpty:!1,onChange:g}),t[12]=m,t[13]=h,t[14]=g,t[15]=i,t[16]=_):_=t[16];let v;return t[17]!==r||t[18]!==_?(v=(0,B.jsx)(Q,{label:r,children:_}),t[17]=r,t[18]=_,t[19]=v):v=t[19],v}export{ye as AgentBrowserSettingsPage};
@@ -0,0 +1 @@
1
+ import"./rolldown-runtime-aKtaBQYM.js";import{a as e,n as t,t as n}from"./vendor-react-BOUWij0V.js";import{t as r}from"./cn-JdwAhgNB.js";import{t as i}from"./dist-CxGUk8J-.js";var a=t();e();var o=n(),s={primary:`bg-accent text-white shadow-none sm:shadow-surface hover:bg-accent-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-base`,secondary:`bg-surface-panel text-fg border border-edge shadow-none sm:shadow-surface hover: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 dark:border-edge`,ghost:`text-fg-muted hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-panel`,segmented:``};function c(e){let t=(0,a.c)(16),n,c,l,u,d,f;t[0]===e?(n=t[1],c=t[2],l=t[3],u=t[4],d=t[5],f=t[6]):({className:n,variant:u,asChild:d,type:f,ref:l,...c}=e,t[0]=e,t[1]=n,t[2]=c,t[3]=l,t[4]=u,t[5]=d,t[6]=f);let p=u===void 0?`secondary`:u,m=d===void 0?!1:d,h=f===void 0?`button`:f,g=m?i:`button`,_=m?void 0:h,v=s[p],y;t[7]!==n||t[8]!==v?(y=r(`touch-target inline-flex items-center justify-center gap-2 rounded-xl px-3 py-2 text-sm font-medium`,`transition-colors duration-150 ease-out transition-transform`,`active:scale-[0.98] motion-reduce:transition-none motion-reduce:active:scale-100`,`disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50`,v,n),t[7]=n,t[8]=v,t[9]=y):y=t[9];let b;return t[10]!==g||t[11]!==c||t[12]!==l||t[13]!==_||t[14]!==y?(b=(0,o.jsx)(g,{ref:l,type:_,className:y,...c}),t[10]=g,t[11]=c,t[12]=l,t[13]=_,t[14]=y,t[15]=b):b=t[15],b}export{c as t};
@@ -0,0 +1,8 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/vendor-swr-BIWyz7Rc.js","assets/rolldown-runtime-aKtaBQYM.js","assets/vendor-react-BOUWij0V.js"])))=>i.map(i=>d[i]);
2
+ 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"./preload-helper-zJ_50EbN.js";import{d as a,h as o,p as s,r as c,t as l}from"./chunk-KS7C4IRE-Cq1tE_3b.js";import{n as u,r as d,t as f}from"./popover-select-DldSX8GX.js";import{t as p}from"./circle-check-C23XjkUj.js";import{t as m}from"./external-link-DjqjBmc3.js";import{t as h}from"./globe-DSSGFWFn.js";import{t as g}from"./loader-circle-CifKLtgG.js";import{t as _}from"./plus-Q2yW6OE7.js";import{t as v}from"./x-B_N4OPjy.js";import{t as y}from"./cn-JdwAhgNB.js";import{a as b,c as x,i as S,n as C,r as w}from"./locale-store-eliqUnBr.js";import{t as T}from"./messages-NYDOR8-j.js";import{a as E,i as D,n as O,o as k,r as A,s as j,t as M}from"./dist-BGTk37IG.js";import{i as N}from"./vendor-swr-BIWyz7Rc.js";import{t as P}from"./button-CGlRPNzi.js";import{n as F,r as I}from"./gateway-config-swr-BBovMBQ1.js";import{t as L}from"./skeleton-BwbyijEw.js";import{i as R,o as z}from"./settings-shell-dialog-layer-BU3UuiJr.js";import{n as B,t as V}from"./registry-api-Dpm3N2h0.js";import{$i as H,$s as U,Ao as W,At as G,B as K,Bu as q,Ct as ee,Dt as te,Et as ne,Fo as re,Ft as J,Gs as ie,Ho as Y,Ic as ae,Io as oe,It as X,Lc as se,Lo as ce,Lt as le,Lu as ue,Mt as de,No as fe,Nt as pe,Oo as me,Pt as he,Ql as ge,Qs as _e,Ro as ve,So as ye,St as be,Su as xe,Tl as Se,To as Ce,Tt as we,V as Te,Vc as Ee,Vo as De,Vu as Oe,X as ke,Y as Ae,Z as je,Zi as Me,_o as Ne,_s as Pe,_t as Fe,at as Ie,ct as Le,di as Re,dt as ze,ea as Be,ft as Ve,go as He,gt as Ue,hc as We,ht as Ge,jt as Ke,kc as qe,kl as Je,ko as Ye,kt as Xe,lc as Ze,lt as Qe,lu as $e,mt as et,ot as tt,pt as nt,sl as rt,st as it,tl as at,ut as ot,vo as st,vs as ct,vt as lt,wc as ut,wo as dt,wt as ft,xc as pt,xn as mt,xo as ht,xt as gt,yt as _t,z as vt,zo as yt}from"./index-B7EieIE4.js";import{n as bt,r as xt}from"./settings-page-layout-CsUQKRq0.js";import{n as St,t as Ct}from"./settings-form-section-BayJP08a.js";import{t as wt}from"./settings-loading-skeleton-CAmWMaOT.js";import{n as Tt,t as Et}from"./use-autosave-htvgT192.js";import{a as Dt,c as Ot,d as kt,f as At,h as jt,i as Mt,l as Nt,n as Pt,o as Ft,p as It,r as Lt,t as Rt,u as zt}from"./voice-config-api-Bjy8EFqi.js";import{t as Bt}from"./voice-api-key-field-BviJF3Oa.js";import{t as Vt}from"./page-tabs-DmG_Qjl8.js";import{t as Ht}from"./settings-advanced-gate-DuzZqQMn.js";import{a as Ut,i as Wt,n as Gt,o as Kt,r as qt,t as Jt}from"./image-generation-api-D01ieqGC.js";import{t as Yt}from"./computer-model-settings-DW6j2lsn.js";var Z=n(),Q=e(t(),1),$=r(),Xt={en:{addTitle:`Add image service`,editTitle:`Manage image service`,intro:`Connect an endpoint that implements the OpenAI Images protocol.`,connection:`Connection`,providerId:`Provider ID`,providerIdHint:`Lowercase letters, numbers, hyphens, or underscores.`,name:`Display name`,baseUrl:`Base URL`,auth:`Authentication`,bearer:`Bearer token`,header:`Custom API key header`,none:`No authentication`,headerName:`Header name`,apiKey:`API key`,apiKeyHint:`Stored in the local credential store, separate from models.json.`,apiKeyUrl:`API key page (optional)`,docsUrl:`Documentation page (optional)`,openKeyPage:`Create API key`,paths:`Protocol and network`,generationsPath:`Generations path`,editsPath:`Edits path`,allowedHosts:`Allowed private hosts (optional)`,allowedHostsHint:`One exact hostname or IP per line. Private endpoints stay blocked unless listed here.`,staticHeaders:`Static headers (optional)`,staticHeadersHint:`One per line: X-Tenant: value. Credential headers are rejected.`,models:`Image models`,addModel:`Add model`,modelId:`Model ID`,modelName:`Name (optional)`,defaultModel:`Default model`,maxCount:`Max images`,defaultCount:`Default count`,defaultSize:`Default size`,format:`Output format`,supportsSize:`Supports size`,edit:`Supports edits`,remove:`Remove`,cancel:`Cancel`,save:`Save service`,saving:`Saving…`,test:`Test generation`,testing:`Generating…`,delete:`Delete service`,confirmDelete:`Delete permanently`,saved:`Image service saved.`,deleted:`Image service deleted.`,testReady:`Test image generated.`,show:`Show key`,hide:`Hide key`,copy:`Copy key`,copied:`Copied`,revealFailed:`Unable to reveal the saved key.`,notRevealable:`No revealable key is stored locally.`,required:`Complete the required connection and model fields.`,duplicateModels:`Model IDs must be unique.`,invalidHeaders:`Static headers must use “Name: value”, one per line.`},zh:{addTitle:`添加图片服务`,editTitle:`管理图片服务`,intro:`连接一个严格实现 OpenAI Images 协议的服务端点。`,connection:`连接信息`,providerId:`Provider ID`,providerIdHint:`仅支持小写字母、数字、连字符和下划线。`,name:`显示名称`,baseUrl:`Base URL`,auth:`认证方式`,bearer:`Bearer Token`,header:`自定义 API Key Header`,none:`无需认证`,headerName:`Header 名称`,apiKey:`API Key`,apiKeyHint:`密钥单独保存在本机凭据存储,不写入 models.json。`,apiKeyUrl:`API Key 创建页面(可选)`,docsUrl:`协议文档页面(可选)`,openKeyPage:`去创建 API Key`,paths:`协议与网络`,generationsPath:`生成路径`,editsPath:`编辑路径`,allowedHosts:`允许访问的私有主机(可选)`,allowedHostsHint:`每行一个精确主机名或 IP;未列出的私网端点保持阻止。`,staticHeaders:`静态 Headers(可选)`,staticHeadersHint:`每行一个:X-Tenant: value。认证 Header 会被拒绝。`,models:`图片模型`,addModel:`添加模型`,modelId:`模型 ID`,modelName:`名称(可选)`,defaultModel:`默认模型`,maxCount:`单次最大张数`,defaultCount:`默认张数`,defaultSize:`默认尺寸`,format:`输出格式`,supportsSize:`支持尺寸参数`,edit:`支持图片编辑`,remove:`移除`,cancel:`取消`,save:`保存服务`,saving:`保存中…`,test:`测试生成`,testing:`生成中…`,delete:`删除服务`,confirmDelete:`确认永久删除`,saved:`图片服务已保存。`,deleted:`图片服务已删除。`,testReady:`测试图片生成成功。`,show:`显示密钥`,hide:`隐藏密钥`,copy:`复制密钥`,copied:`已复制`,revealFailed:`无法查看已保存的密钥。`,notRevealable:`本机没有可查看的密钥。`,required:`请补全必填的连接和模型信息。`,duplicateModels:`模型 ID 不能重复。`,invalidHeaders:`静态 Header 必须使用“名称: 值”格式,每行一个。`}},Zt=`mt-1.5 h-10 w-full rounded-lg border border-edge bg-surface-panel px-3 text-sm text-fg outline-none focus:border-accent focus:ring-2 focus:ring-accent/20`;function Qt(e){let t=e??{id:``,capabilities:{generate:{maxCount:1,supportsSize:!0},edit:{enabled:!1}}};return{original:t,id:t.id,name:t.name??``,maxCount:String(t.capabilities.generate?.maxCount??1),defaultCount:t.defaults?.count?String(t.defaults.count):``,defaultSize:t.defaults?.size??``,outputFormat:t.defaults?.outputFormat??``,supportsSize:t.capabilities.generate?.supportsSize??!1,editEnabled:t.capabilities.edit?.enabled??!1}}function $t(e){let t=e.split(`
3
+ `).map(e=>e.trim()).filter(Boolean);if(t.length===0)return;let n=t.map(e=>{let t=e.indexOf(`:`);if(t<=0||!e.slice(t+1).trim())throw Error(`invalid_headers`);return[e.slice(0,t).trim(),e.slice(t+1).trim()]});return Object.fromEntries(n)}function en({open:e,onOpenChange:t,provider:n,configured:r,language:i,onSaved:a}){let o=Xt[i],[s,c]=(0,Q.useState)(``),[l,u]=(0,Q.useState)(``),[d,p]=(0,Q.useState)(``),[m,h]=(0,Q.useState)(`bearer`),[b,x]=(0,Q.useState)(`x-api-key`),[S,C]=(0,Q.useState)(``),[w,T]=(0,Q.useState)(``),[N,F]=(0,Q.useState)(``),[I,L]=(0,Q.useState)(`/images/generations`),[B,V]=(0,Q.useState)(`/images/edits`),[H,W]=(0,Q.useState)(``),[G,K]=(0,Q.useState)(``),[ee,te]=(0,Q.useState)([Qt()]),[ne,re]=(0,Q.useState)(``),[J,ie]=(0,Q.useState)(),[Y,ae]=(0,Q.useState)(!1),[oe,X]=(0,Q.useState)(),[se,ce]=(0,Q.useState)(),[le,ue]=(0,Q.useState)();(0,Q.useEffect)(()=>{if(!e)return;let t=n?.imageGeneration;c(n?.providerId??``),u(t?.name??``),p(n?.baseUrl??``),h(t?.auth.type??`bearer`),x(t?.auth.type===`header`?t.auth.headerName:`x-api-key`),C(r?`••••••••••••`:``),T(t?.apiKeyUrl??``),F(t?.documentationUrl??``),L(t?.paths?.generations??`/images/generations`),V(t?.paths?.edits??`/images/edits`),W(t?.network?.allowedHosts.join(`
4
+ `)??``),K(Object.entries(n?.headers??{}).map(([e,t])=>`${e}: ${t}`).join(`
5
+ `)),te(t?.models.map(Qt)??[Qt()]),re(t?.defaultModel??``),ce(void 0),ie(void 0),ae(!1),X(void 0),ue(void 0)},[r,e,n]);let de=(0,Q.useMemo)(()=>ee.filter(e=>e.id.trim()).map(e=>({value:e.id.trim(),label:e.name.trim()||e.id.trim()})),[ee]),fe=(e,t)=>{te(n=>n.map((n,r)=>r===e?{...n,...t}:n))},me=()=>{let e=s.trim(),t=ee.map(e=>({...e,id:e.id.trim(),name:e.name.trim()}));if(!e||!l.trim()||!d.trim()||t.some(e=>!e.id))throw Error(o.required);if(new Set(t.map(e=>e.id)).size!==t.length)throw Error(o.duplicateModels);let n=ne||t[0]?.id;if(!n||!t.some(e=>e.id===n))throw Error(o.required);let r;try{r=$t(G)}catch{throw Error(o.invalidHeaders)}return{providerId:e,input:{baseUrl:d.trim(),...r?{headers:r}:{},imageGeneration:{api:`openai-images`,name:l.trim(),...N.trim()?{documentationUrl:N.trim()}:{},...w.trim()?{apiKeyUrl:w.trim()}:{},defaultModel:n,auth:m===`header`?{type:`header`,headerName:b.trim()}:{type:m},paths:{...I.trim()?{generations:I.trim()}:{},...B.trim()?{edits:B.trim()}:{}},...H.trim()?{network:{allowedHosts:H.split(`
6
+ `).map(e=>e.trim()).filter(Boolean)}}:{},models:t.map(e=>({...e.original,id:e.id,...e.name?{name:e.name}:{name:void 0},capabilities:{...e.original.capabilities,generate:{...e.original.capabilities.generate,maxCount:Math.max(1,Number.parseInt(e.maxCount,10)||1),supportsSize:e.supportsSize},edit:{...e.original.capabilities.edit,enabled:e.editEnabled}},defaults:{...e.original.defaults,...e.defaultCount?{count:Math.max(1,Number.parseInt(e.defaultCount,10)||1)}:{count:void 0},...e.defaultSize.trim()?{size:e.defaultSize.trim()}:{size:void 0},...e.outputFormat?{outputFormat:e.outputFormat}:{outputFormat:void 0}}}))}}}},he=async()=>{let e=me();return await Wt(e.providerId,e.input),m!==`none`&&S.trim()&&!Ce(S)&&await Ut(e.providerId,S.trim()),await a(e.providerId),e},_e=async()=>{ie(`save`),X(void 0),ce(void 0);try{await he(),C(m===`none`?``:`••••••••••••`),ce(o.saved)}catch(e){X(e instanceof Error?e.message:String(e))}finally{ie(void 0)}},ve=async()=>{ie(`test`),X(void 0),ce(void 0),ue(void 0);try{let e=await he();ue((await Kt(e.providerId,e.input.imageGeneration.defaultModel)).images[0]?.dataUrl),ce(o.testReady)}catch(e){X(e instanceof Error?e.message:String(e))}finally{ie(void 0)}},ye=async()=>{if(n){if(!Y){ae(!0);return}ie(`delete`),X(void 0);try{await Jt(n.providerId),await a(),t(!1)}catch(e){X(e instanceof Error?e.message:String(e))}finally{ie(void 0)}}};return(0,$.jsx)(M,{open:e,onOpenChange:t,children:(0,$.jsxs)(k,{children:[(0,$.jsx)(E,{className:y(`xopc-dialog-overlay fixed inset-0 bg-scrim`,z)}),(0,$.jsxs)(A,{className:y(`xopc-dialog-content fixed left-1/2 top-1/2 flex h-[min(88vh,760px)] w-[min(calc(100%-2rem),52rem)] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-panel shadow-popover`,R),onOpenAutoFocus:e=>e.preventDefault(),children:[(0,$.jsxs)(`header`,{className:`flex shrink-0 items-start justify-between gap-4 border-b border-edge px-5 py-4`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(j,{className:`font-semibold text-fg`,children:n?o.editTitle:o.addTitle}),(0,$.jsx)(D,{className:`mt-1 text-sm text-fg-muted`,children:o.intro})]}),(0,$.jsx)(O,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:`rounded-md p-1 text-fg-muted hover:bg-surface-subtle hover:text-fg`,"aria-label":o.cancel,children:(0,$.jsx)(v,{className:`size-5`})})})]}),(0,$.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-6 overflow-y-auto px-5 py-4`,children:[(0,$.jsxs)(`section`,{className:`space-y-4`,children:[(0,$.jsx)(`h3`,{className:`text-xs font-semibold uppercase tracking-wide text-fg-subtle`,children:o.connection}),(0,$.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[o.providerId,(0,$.jsx)(`input`,{value:s,disabled:!!n,onChange:e=>c(e.target.value),placeholder:`my-image-service`,className:Zt}),(0,$.jsx)(`span`,{className:`mt-1 block font-normal text-fg-subtle`,children:o.providerIdHint})]}),(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[o.name,(0,$.jsx)(`input`,{value:l,onChange:e=>u(e.target.value),placeholder:`My Image Service`,className:Zt})]})]}),(0,$.jsxs)(`label`,{className:`block text-xs font-medium text-fg-muted`,children:[o.baseUrl,(0,$.jsx)(`input`,{value:d,onChange:e=>p(e.target.value),placeholder:`https://api.example.com/v1`,className:Zt})]}),(0,$.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[o.auth,(0,$.jsx)(f,{value:m,options:[{value:`bearer`,label:o.bearer},{value:`header`,label:o.header},{value:`none`,label:o.none}],placeholder:o.auth,allowEmpty:!1,onChange:e=>h(e),triggerClassName:`mt-1.5`})]}),m===`header`?(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[o.headerName,(0,$.jsx)(`input`,{value:b,onChange:e=>x(e.target.value),className:Zt})]}):null]}),m===`none`?null:(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`div`,{className:`mb-1.5 flex items-center justify-between`,children:[(0,$.jsx)(`label`,{htmlFor:`custom-image-api-key`,className:`text-xs font-medium text-fg-muted`,children:o.apiKey}),w.trim()?(0,$.jsxs)(`a`,{href:w.trim(),target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 text-xs text-accent hover:underline`,children:[o.openKeyPage,(0,$.jsx)(q,{className:`size-3.5`})]}):null]}),(0,$.jsx)(dt,{id:`custom-image-api-key`,value:S,onChange:e=>C(Ce(S)?e.replace(/^•+/,``):e),labels:{show:o.show,hide:o.hide,copy:o.copy,copied:o.copied},reveal:()=>pe(s).then(e=>e.apiKey),loadFailedLabel:o.revealFailed,notInConfigFile:o.notRevealable}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:o.apiKeyHint})]}),(0,$.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[o.apiKeyUrl,(0,$.jsx)(`input`,{value:w,onChange:e=>T(e.target.value),placeholder:`https://…`,className:Zt})]}),(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[o.docsUrl,(0,$.jsx)(`input`,{value:N,onChange:e=>F(e.target.value),placeholder:`https://…`,className:Zt})]})]}),(0,$.jsxs)(`details`,{className:`rounded-lg border border-edge bg-surface-subtle px-3 py-2.5`,children:[(0,$.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg-muted`,children:o.paths}),(0,$.jsxs)(`div`,{className:`mt-3 grid gap-4 md:grid-cols-2`,children:[(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[o.generationsPath,(0,$.jsx)(`input`,{value:I,onChange:e=>L(e.target.value),className:Zt})]}),(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[o.editsPath,(0,$.jsx)(`input`,{value:B,onChange:e=>V(e.target.value),className:Zt})]})]}),(0,$.jsxs)(`label`,{className:`mt-4 block text-xs font-medium text-fg-muted`,children:[o.allowedHosts,(0,$.jsx)(`textarea`,{value:H,onChange:e=>W(e.target.value),rows:2,placeholder:`127.0.0.1
7
+ image-server.lan`,className:`mt-1.5 w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 font-mono text-xs text-fg outline-none focus:border-accent focus:ring-2 focus:ring-accent/20`}),(0,$.jsx)(`span`,{className:`mt-1 block font-normal text-fg-subtle`,children:o.allowedHostsHint})]}),(0,$.jsxs)(`label`,{className:`mt-4 block text-xs font-medium text-fg-muted`,children:[o.staticHeaders,(0,$.jsx)(`textarea`,{value:G,onChange:e=>K(e.target.value),rows:3,className:`mt-1.5 w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 font-mono text-xs text-fg outline-none focus:border-accent focus:ring-2 focus:ring-accent/20`}),(0,$.jsx)(`span`,{className:`mt-1 block font-normal text-fg-subtle`,children:o.staticHeadersHint})]})]})]}),(0,$.jsxs)(`section`,{className:`space-y-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsx)(`h3`,{className:`text-xs font-semibold uppercase tracking-wide text-fg-subtle`,children:o.models}),(0,$.jsxs)(P,{variant:`secondary`,className:`px-2.5 py-1.5 text-xs`,onClick:()=>te(e=>[...e,Qt()]),children:[(0,$.jsx)(_,{className:`size-4`}),o.addModel]})]}),(0,$.jsxs)(`label`,{className:`block text-xs font-medium text-fg-muted`,children:[o.defaultModel,(0,$.jsx)(f,{value:ne||de[0]?.value||``,options:de,placeholder:o.defaultModel,allowEmpty:!1,onChange:re,triggerClassName:`mt-1.5 max-w-sm`})]}),ee.map((e,t)=>(0,$.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-base p-3`,children:[(0,$.jsxs)(`div`,{className:`grid gap-3 md:grid-cols-2`,children:[(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[o.modelId,(0,$.jsx)(`input`,{value:e.id,onChange:e=>fe(t,{id:e.target.value}),placeholder:`image-1`,className:Zt})]}),(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[o.modelName,(0,$.jsx)(`input`,{value:e.name,onChange:e=>fe(t,{name:e.target.value}),className:Zt})]})]}),(0,$.jsxs)(`div`,{className:`mt-3 grid gap-3 sm:grid-cols-2 lg:grid-cols-4`,children:[(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[o.maxCount,(0,$.jsx)(`input`,{type:`number`,min:1,value:e.maxCount,onChange:e=>fe(t,{maxCount:e.target.value}),className:Zt})]}),(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[o.defaultCount,(0,$.jsx)(`input`,{type:`number`,min:1,value:e.defaultCount,onChange:e=>fe(t,{defaultCount:e.target.value}),className:Zt})]}),(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[o.defaultSize,(0,$.jsx)(`input`,{value:e.defaultSize,onChange:e=>fe(t,{defaultSize:e.target.value}),placeholder:`1024x1024`,className:Zt})]}),(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[o.format,(0,$.jsx)(f,{value:e.outputFormat,options:[{value:`png`,label:`PNG`},{value:`jpeg`,label:`JPEG`},{value:`webp`,label:`WebP`}],placeholder:o.format,allowEmpty:!0,onChange:e=>fe(t,{outputFormat:e}),triggerClassName:`mt-1.5`})]})]}),(0,$.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-4`,children:[(0,$.jsxs)(`label`,{className:`flex items-center gap-2 text-sm text-fg-muted`,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:e.supportsSize,onChange:e=>fe(t,{supportsSize:e.target.checked})}),o.supportsSize]}),(0,$.jsxs)(`label`,{className:`flex items-center gap-2 text-sm text-fg-muted`,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:e.editEnabled,onChange:e=>fe(t,{editEnabled:e.target.checked})}),o.edit]}),(0,$.jsxs)(`button`,{type:`button`,disabled:ee.length===1,onClick:()=>te(e=>e.filter((e,n)=>n!==t)),className:`ml-auto inline-flex items-center gap-1 text-xs text-red-600 disabled:opacity-40 dark:text-red-400`,children:[(0,$.jsx)(U,{className:`size-3.5`}),o.remove]})]})]},t))]}),le?(0,$.jsxs)(`section`,{className:`rounded-lg border border-edge bg-surface-base p-3`,children:[(0,$.jsxs)(`div`,{className:`mb-2 flex items-center gap-2 text-sm font-medium text-fg`,children:[(0,$.jsx)(ge,{className:`size-4`}),o.testReady]}),(0,$.jsx)(`img`,{src:le,alt:`Generated provider test`,className:`max-h-72 rounded-lg object-contain`})]}):null,se?(0,$.jsx)(`p`,{className:`rounded-lg bg-emerald-500/10 px-3 py-2 text-sm text-emerald-700 dark:text-emerald-300`,role:`status`,children:se}):null,oe?(0,$.jsx)(`p`,{className:`rounded-lg bg-red-500/10 px-3 py-2 text-sm text-red-600 dark:text-red-400`,children:oe}):null]}),(0,$.jsxs)(`footer`,{className:`flex shrink-0 flex-wrap items-center gap-2 border-t border-edge px-5 py-3`,children:[n?(0,$.jsxs)(P,{variant:`secondary`,className:`border-red-500/30 text-red-600 hover:bg-red-500/10 dark:text-red-400`,disabled:!!J,onClick:()=>void ye(),children:[J===`delete`?(0,$.jsx)(g,{className:`size-4 animate-spin`}):(0,$.jsx)(U,{className:`size-4`}),Y?o.confirmDelete:o.delete]}):null,(0,$.jsxs)(`div`,{className:`ml-auto flex gap-2`,children:[(0,$.jsx)(O,{asChild:!0,children:(0,$.jsx)(P,{variant:`secondary`,children:o.cancel})}),(0,$.jsxs)(P,{variant:`secondary`,disabled:!!J,onClick:()=>void ve(),children:[J===`test`?(0,$.jsx)(g,{className:`size-4 animate-spin`}):null,J===`test`?o.testing:o.test]}),(0,$.jsxs)(P,{variant:`primary`,disabled:!!J,onClick:()=>void _e(),children:[J===`save`?(0,$.jsx)(g,{className:`size-4 animate-spin`}):null,J===`save`?o.saving:o.save]})]})]})]})]})})}var tn=`••••••••••••`,nn={en:{title:`Image generation`,intro:`Configure the default image model and service. Agents inherit this setting unless overridden in Agent settings.`,provider:`Provider`,model:`Model`,apiKey:`API key`,getApiKey:`Get API key`,apiKeyHint:`Stored in the local credential store, never in xopc.json.`,existingKey:`A credential or environment variable is already available. Leave this blank to reuse it.`,savedKey:`A credential is saved. Use the eye button to view it, or type a new key to replace it.`,revealFailed:`Unable to load the saved API key.`,keyNotRevealable:`This credential comes from an environment variable or another non-revealable source.`,advanced:`Provider settings`,enable:`Enable image generation`,enabling:`Verifying and enabling…`,enabled:`Image generation is ready.`,addService:`Add image service`,manageService:`Manage service`,custom:`Custom`,current:`Current`,configured:`Credential ready`,needsKey:`API key required`,connect:`Connect to a gateway to continue.`,loadError:`Unable to load image generation settings.`,selectModel:`Select a model`,show:`Show key`,hide:`Hide key`,copy:`Copy key`,copied:`Copied`},zh:{title:`图片生成`,intro:`配置全局图片生成模型和服务。各智能体默认继承此设置,也可在智能体详情中单独覆盖。`,provider:`Provider`,model:`模型`,apiKey:`API Key`,getApiKey:`获取 API Key`,apiKeyHint:`密钥只保存在本机凭据存储中,不会写入 xopc.json。`,existingKey:`已有凭据或环境变量;留空即可继续使用。`,savedKey:`凭据已保存。点击眼睛可查看,直接输入新密钥可替换。`,revealFailed:`无法读取已保存的 API Key。`,keyNotRevealable:`当前凭据来自环境变量或其他不可查看的来源。`,advanced:`服务商设置`,enable:`启用图片生成`,enabling:`正在验证并启用…`,enabled:`图片生成已可用。`,addService:`添加图片服务`,manageService:`管理服务`,custom:`自定义`,current:`当前使用`,configured:`凭据已就绪`,needsKey:`需要 API Key`,connect:`请先连接网关。`,loadError:`无法加载图片生成设置。`,selectModel:`选择模型`,show:`显示密钥`,hide:`隐藏密钥`,copy:`复制密钥`,copied:`已复制`}};async function rn(){let e=await b(w(`/api/image-generation/default`));if(!e.payload)throw Error(`Invalid default image generation response`);return e.payload}function an(e){let t=e?.indexOf(`/`)??-1;return t>0?e.slice(0,t):void 0}function on(e){let t=e?.indexOf(`/`)??-1;return t>0?e.slice(t+1):void 0}function sn(e){return Object.fromEntries(e.configFields.map(t=>[t.key,e.config[t.key]??(t.required?t.options?.[0]?.value??``:``)]))}function cn(e){let t=(0,Z.c)(11),{field:n,value:r,onChange:i}=e,a;t[0]!==n.label||t[1]!==n.options||t[2]!==n.placeholder||t[3]!==n.required||t[4]!==n.type||t[5]!==i||t[6]!==r?(a=n.type===`select`?(0,$.jsx)(f,{value:r,options:(n.options??[]).map(ln),placeholder:n.placeholder??n.label,allowEmpty:!n.required,onChange:i,triggerClassName:`mt-1.5`}):(0,$.jsx)(`input`,{type:`url`,value:r,required:n.required,onChange:e=>i(e.target.value),placeholder:n.placeholder,className:`mt-1.5 h-10 w-full rounded-lg border border-edge bg-surface-panel px-3 text-sm text-fg outline-none focus:border-accent focus:ring-2 focus:ring-accent/20`}),t[0]=n.label,t[1]=n.options,t[2]=n.placeholder,t[3]=n.required,t[4]=n.type,t[5]=i,t[6]=r,t[7]=a):a=t[7];let o;return t[8]!==n.label||t[9]!==a?(o=(0,$.jsxs)(`label`,{className:`block text-xs font-medium text-fg-muted`,children:[n.label,a]}),t[8]=n.label,t[9]=a,t[10]=o):o=t[10],o}function ln(e){return{value:e.value,label:e.label}}function un(){let e=(0,Z.c)(2),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(L,{className:`h-24 rounded-xl`}),e[0]=t):t=e[0];let n;return e[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,$.jsxs)(`div`,{className:`grid gap-4`,"aria-hidden":`true`,children:[t,(0,$.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2 xl:grid-cols-3`,children:Array.from({length:5}).map(dn)}),(0,$.jsx)(L,{className:`h-64 rounded-xl`})]}),e[1]=n):n=e[1],n}function dn(e,t){return(0,$.jsx)(L,{className:`h-24 rounded-xl`},t)}function fn(){let e=C(e=>e.language),t=nn[e],n=!!x(e=>e.conversationId),[r,a]=(0,Q.useState)(``),[o,s]=(0,Q.useState)(``),[c,l]=(0,Q.useState)(``),[u,d]=(0,Q.useState)({}),[m,h]=(0,Q.useState)(!1),[v,y]=(0,Q.useState)(),[S,T]=(0,Q.useState)(!1),[E,D]=(0,Q.useState)(!1),[O,k]=(0,Q.useState)(),{data:A,isLoading:j,error:M,mutate:I}=N(n?w(`/api/image-generation/catalog`):null,qt,{revalidateOnFocus:!1}),{data:L,isLoading:R,error:z,mutate:B}=N(n?w(`/api/image-generation/custom-providers`):null,Gt,{revalidateOnFocus:!1}),{data:V,isLoading:H,error:U,mutate:W}=N(n?`default-image-generation`:null,rn,{revalidateOnFocus:!1});(0,Q.useEffect)(()=>{if(!A||!V)return;let e=an(V.model?.primary),t=A.find(t=>t.id===e)??A.find(e=>e.configured)??A[0];t&&(a(t.id),s(t.id===e&&on(V.model?.primary)||t.defaultModel),l(t.configured?tn:``),d(sn(t)))},[V,A]);let G=A?.find(e=>e.id===r),K=G?G.apiKeyUrl??ke(G.id,e)[0]?.href:void 0,ee=(0,Q.useMemo)(()=>(G?.models??[]).map(e=>({value:e,label:e})),[G?.models]),te=V?.model?.primary,ne=!!(G&&o&&(G.credentialMode!==`api-key`||G.configured||c.trim())&&G.configFields.every(e=>!e.required||u[e.key]?.trim()));if(!n)return(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.connect});if(j||R||H)return(0,$.jsx)(un,{});if(M||z||U||!A||!L)return(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:t.loadError});let re=e=>{a(e.id),s(e.defaultModel),l(e.configured?tn:``),d(sn(e)),y(void 0)},J=()=>{k(void 0),D(!0)},ie=()=>{let e=L.find(e=>e.providerId===G?.id);e&&(k(e),D(!0))},Y=async e=>{let[t,n]=await Promise.all([B(),I()]);if(e&&n?.some(t=>t.id===e)){let r=n.find(t=>t.id===e);a(r.id),s(r.defaultModel),l(r.configured?tn:``),d(sn(r)),k(t?.find(t=>t.providerId===e))}},ae=async()=>{if(!(!G||!ne)){h(!0),y(void 0),T(!1);try{let e=await b(w(`/api/image-generation/default/setup`),{method:`POST`,body:JSON.stringify({providerId:G.id,modelId:o,...c.trim()&&!Ce(c)?{apiKey:c.trim()}:{},providerConfig:Object.fromEntries(Object.entries(u).filter(([,e])=>e.trim()))})});if(!e.payload)throw Error(`Invalid setup response`);await Promise.all([W(e.payload.default,{revalidate:!1}),I(e.payload.providers,{revalidate:!1}),i(async()=>{let{mutate:e}=await import(`./vendor-swr-BIWyz7Rc.js`).then(e=>e.r);return{mutate:e}},__vite__mapDeps([0,1,2])).then(({mutate:e})=>Promise.all([e(`settings-agent-defaults`),e(`settings-gateway-agents`)])),F()]),l(tn),T(!0)}catch(e){y(e instanceof Error?e.message:String(e))}finally{h(!1)}}};return(0,$.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,$.jsx)(`section`,{className:`rounded-xl border border-edge bg-surface-base p-4`,children:(0,$.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,$.jsx)(`div`,{className:`rounded-lg bg-accent/10 p-2 text-accent`,children:(0,$.jsx)(Je,{className:`size-5`})}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:t.title}),(0,$.jsx)(`p`,{className:`mt-1 text-sm leading-relaxed text-fg-muted`,children:t.intro})]})]})}),(0,$.jsxs)(`section`,{children:[(0,$.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-3`,children:[(0,$.jsx)(`h3`,{className:`text-xs font-semibold uppercase tracking-wide text-fg-subtle`,children:t.provider}),(0,$.jsxs)(P,{variant:`secondary`,className:`px-2.5 py-1.5 text-xs`,onClick:J,children:[(0,$.jsx)(_,{className:`size-4`}),t.addService]})]}),(0,$.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2 xl:grid-cols-3`,children:A.map(e=>{let n=e.id===r,i=e.id===an(te);return(0,$.jsxs)(`button`,{type:`button`,onClick:()=>re(e),className:`min-h-24 rounded-xl border p-4 text-left transition-colors ${n?`border-accent bg-accent/5 ring-1 ring-accent/20`:`border-edge bg-surface-base hover:border-edge-strong`}`,children:[(0,$.jsxs)(`span`,{className:`flex items-center justify-between gap-2`,children:[(0,$.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`truncate font-medium text-fg`,children:e.label}),e.source===`custom`?(0,$.jsx)(`span`,{className:`rounded-full bg-surface-subtle px-2 py-0.5 text-[10px] text-fg-subtle`,children:t.custom}):null]}),(0,$.jsx)(`span`,{"aria-hidden":!i,className:`shrink-0 rounded-full bg-accent/10 px-2 py-0.5 text-[11px] font-medium text-accent ${i?``:`invisible`}`,children:t.current})]}),(0,$.jsxs)(`span`,{className:`mt-2 flex items-center gap-1.5 text-xs ${e.configured?`text-emerald-600 dark:text-emerald-400`:`text-fg-muted`}`,children:[e.configured||e.credentialMode!==`api-key`?(0,$.jsx)(p,{className:`size-3.5`}):(0,$.jsx)(Se,{className:`size-3.5`}),e.configured||e.credentialMode!==`api-key`?t.configured:t.needsKey]})]},e.id)})})]}),G?(0,$.jsxs)(`section`,{className:`rounded-xl border border-edge bg-surface-base p-4`,children:[(0,$.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,$.jsxs)(`label`,{className:`block text-xs font-medium text-fg-muted`,children:[t.model,(0,$.jsx)(f,{value:o,options:ee,placeholder:t.selectModel,allowEmpty:!1,onChange:s,triggerClassName:`mt-1.5`})]}),G.configFields.filter(e=>e.required).map(e=>(0,$.jsx)(cn,{field:e,value:u[e.key]??``,onChange:t=>d(n=>({...n,[e.key]:t}))},e.key))]}),G.source===`custom`?(0,$.jsx)(`div`,{className:`mt-4 flex justify-end`,children:(0,$.jsxs)(P,{variant:`secondary`,onClick:ie,children:[(0,$.jsx)(pt,{className:`size-4`}),t.manageService]})}):null,G.credentialMode===`api-key`?(0,$.jsxs)(`div`,{className:`mt-4`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,$.jsx)(`label`,{htmlFor:`image-generation-api-key`,className:`text-xs font-medium text-fg-muted`,children:t.apiKey}),K?(0,$.jsxs)(`a`,{href:K,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 text-xs font-medium text-accent hover:underline`,children:[t.getApiKey,(0,$.jsx)(q,{className:`size-3.5`,"aria-hidden":`true`})]}):null]}),(0,$.jsx)(dt,{id:`image-generation-api-key`,value:c,onChange:e=>l(Ce(c)?e.replace(/^•+/,``):e),placeholder:G.configured?t.existingKey:t.needsKey,labels:{show:t.show,hide:t.hide,copy:t.copy,copied:t.copied},reveal:()=>pe(G.id).then(e=>e.apiKey),loadFailedLabel:t.revealFailed,notInConfigFile:t.keyNotRevealable,className:`mt-1.5`,autoComplete:`new-password`},G.id),(0,$.jsx)(`span`,{className:`mt-1.5 block font-normal leading-relaxed text-fg-subtle`,children:G.configured?t.savedKey:t.apiKeyHint})]}):null,G.configFields.some(e=>!e.required)?(0,$.jsxs)(`details`,{className:`mt-4 rounded-lg border border-edge bg-surface-subtle px-3 py-2.5`,children:[(0,$.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center gap-2 text-sm font-medium text-fg-muted`,children:[(0,$.jsx)(We,{className:`size-4`}),t.advanced]}),(0,$.jsx)(`div`,{className:`mt-3 grid gap-3 md:grid-cols-2`,children:G.configFields.filter(e=>!e.required).map(e=>(0,$.jsx)(cn,{field:e,value:u[e.key]??``,onChange:t=>d(n=>({...n,[e.key]:t}))},e.key))})]}):null,S?(0,$.jsx)(`p`,{className:`mt-4 rounded-lg bg-emerald-500/10 px-3 py-2 text-sm text-emerald-700 dark:text-emerald-300`,role:`status`,children:t.enabled}):null,v?(0,$.jsx)(`p`,{className:`mt-4 rounded-lg bg-red-500/10 px-3 py-2 text-sm text-red-600 dark:text-red-400`,children:v}):null,(0,$.jsx)(`div`,{className:`mt-4 flex justify-end`,children:(0,$.jsxs)(P,{variant:`primary`,disabled:!ne||m,onClick:()=>void ae(),children:[m?(0,$.jsx)(g,{className:`size-4 animate-spin`}):(0,$.jsx)(p,{className:`size-4`}),(0,$.jsxs)(`span`,{className:`grid`,children:[(0,$.jsx)(`span`,{"aria-hidden":!0,className:`invisible col-start-1 row-start-1`,children:t.enable}),(0,$.jsx)(`span`,{"aria-hidden":!0,className:`invisible col-start-1 row-start-1`,children:t.enabling}),(0,$.jsx)(`span`,{className:`col-start-1 row-start-1`,children:m?t.enabling:t.enable})]})]})})]}):null,(0,$.jsx)(en,{open:E,onOpenChange:D,provider:O,configured:!!(O&&A.find(e=>e.id===O.providerId)?.configured),language:e,onSaved:Y})]})}function pn({disabled:e=!1}){let t=C(e=>e.language)===`zh`,[n,r]=(0,Q.useState)(!1),[i,a]=(0,Q.useState)(``),{data:o,mutate:s,error:c}=N(w(`/api/voice/catalog`),async e=>{let t=await b(e);return yt.parse(t.payload)}),l=t?{transcription:`录音转文字`,"transcription.stream":`实时听写 / 语音助手输入`,speech:`消息朗读`,"speech.stream":`语音助手输出`,conversation:`自然语音对话`}:{transcription:`Recorded transcription`,"transcription.stream":`Live dictation / assistant input`,speech:`Message readout`,"speech.stream":`Assistant speech`,conversation:`Natural conversation`},f=async e=>{if(o){r(!0),a(``);try{let t=await b(w(e?`/api/voice/selection`:`/api/voice/catalog/refresh`),{method:e?`PUT`:`POST`,...e?{body:JSON.stringify({revision:o.revision,selection:e})}:{}});await s(yt.parse(t.payload),!1),await F()}catch(e){a(e instanceof Error?e.message:String(e)),await s()}finally{r(!1)}}};return(0,$.jsxs)(`section`,{className:`space-y-4 rounded-xl border border-edge p-4`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,$.jsx)(`h3`,{className:`font-medium`,children:t?`XOPC 托管语音模型`:`XOPC managed voice models`}),(0,$.jsx)(P,{variant:`secondary`,disabled:n||e||!o,onClick:()=>void f(),children:t?`刷新目录`:`Refresh catalog`})]}),(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t?`各设备共用此 Gateway 的模型设置,修改在下次调用生效。仅显示支持对应场景的已发布模型。`:`Devices share this gateway’s selections. Changes apply to the next call. Only published models supporting each mode are shown.`}),i||c?(0,$.jsx)(`p`,{role:`alert`,className:`text-sm text-red-600`,children:i||String(c)}):null,o?Object.keys(l).map(r=>{let i=o.selections.find(e=>e.mode===r),a=o.models.filter(e=>e.voice.modes.includes(r)),s=a.find(e=>e.id===i?.model);return(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,$.jsxs)(`label`,{className:`space-y-1 text-sm`,children:[(0,$.jsx)(`span`,{children:l[r]}),(0,$.jsxs)(u,{className:`w-full`,value:i?.model??``,disabled:n||e||!a.length,onChange:e=>void f({mode:r,model:e.target.value}),children:[(0,$.jsx)(d,{value:``,disabled:!0,children:t?`选择模型`:`Choose model`}),i&&!s?(0,$.jsxs)(d,{value:i.model,disabled:!0,children:[i.model,` · `,t?`不可用`:`Unavailable`]}):null,a.map(e=>(0,$.jsx)(d,{value:e.id,children:e.name},e.id))]}),a.length?null:(0,$.jsx)(`span`,{className:`text-xs text-fg-muted`,children:t?`暂无可用模型`:`No available model`})]}),s&&s.voice.voices.length>0?(0,$.jsxs)(`label`,{className:`space-y-1 text-sm`,children:[(0,$.jsx)(`span`,{children:t?`音色`:`Voice`}),(0,$.jsx)(u,{className:`w-full`,value:i?.voice??``,disabled:n||e,onChange:e=>void f({mode:r,model:s.id,voice:e.target.value}),children:s.voice.voices.map(e=>(0,$.jsx)(d,{value:e.id,children:e.name},e.id))})]}):null]},r)}):(0,$.jsx)(L,{className:`h-48 w-full`})]})}function mn({v:e}){let t=De(e=>e.microphoneId),n=De(e=>e.setMicrophoneId),[r,i]=(0,Q.useState)([]),[a,o]=(0,Q.useState)(``),[s,c]=(0,Q.useState)(!1),l=(0,Q.useRef)(!1);(0,Q.useEffect)(()=>{l.current=!0;let e=()=>{navigator.mediaDevices?.enumerateDevices().then(e=>{l.current&&i(e.filter(e=>e.kind===`audioinput`))}).catch(()=>{})};return e(),navigator.mediaDevices?.addEventListener(`devicechange`,e),()=>{l.current=!1,navigator.mediaDevices?.removeEventListener(`devicechange`,e)}},[]);let f=async()=>{c(!0),o(``);try{(await navigator.mediaDevices.getUserMedia({audio:!0})).getTracks().forEach(e=>e.stop());let e=await navigator.mediaDevices.enumerateDevices();l.current&&i(e.filter(e=>e.kind===`audioinput`))}catch(e){l.current&&o(e instanceof Error?e.message:String(e))}finally{l.current&&c(!1)}};return(0,$.jsxs)(`section`,{className:`space-y-4 rounded-xl border border-edge p-4`,children:[(0,$.jsxs)(`label`,{className:`block space-y-2 text-sm`,children:[(0,$.jsx)(`span`,{children:e.experience.microphone}),(0,$.jsxs)(u,{value:t,onChange:e=>n(e.target.value),children:[(0,$.jsx)(d,{value:``,children:e.experience.systemDevice}),t&&!r.some(e=>e.deviceId===t)?(0,$.jsx)(d,{value:t,children:e.experience.unavailable}):null,r.filter(e=>e.deviceId&&e.deviceId!=="default").map((t,n)=>(0,$.jsx)(d,{value:t.deviceId,children:t.label||`${e.experience.microphone} ${n+1}`},t.deviceId))]})]}),(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:e.experience.deviceHint}),(0,$.jsx)(P,{variant:`secondary`,disabled:s,onClick:()=>void f(),children:e.experience.refreshDevices}),a?(0,$.jsx)(`p`,{role:`alert`,className:`text-sm text-red-600`,children:a}):null]})}function hn({v:e,canListen:t,canSpeak:n,disabled:r,onVerified:i}){let a=e.setup,o=(0,Q.useContext)(fe)?.active??!1,[s,c]=(0,Q.useState)(`idle`),[l,u]=(0,Q.useState)(``),[d,f]=(0,Q.useState)(``),p=(0,Q.useRef)(`idle`),m=(0,Q.useRef)(null),h=(0,Q.useRef)(!1),_=e=>{p.current=e,c(e)},v=()=>{m.current?.(),m.current=null};(0,Q.useEffect)(()=>()=>m.current?.(),[]);async function y(e){v(),i?.({input:!1,output:!1}),h.current=!1,u(``),f(``),_(e?`connecting`:`playing`);let t=new AbortController,r,o,s,c,l=()=>{o?.cancel(),r?.getTracks().forEach(e=>e.stop()),s?.stop(`surface_closed`)},d=window.setTimeout(()=>g(a.timeout),6e4);m.current=()=>{t.abort(),window.clearTimeout(d),l(),c?.close()};function g(e){t.signal.aborted||(_(`error`),f(e),v())}async function y(){_(`playing`),l();try{let e=await At(t.signal);if(t.signal.aborted)return;c?.enqueue(e,()=>{t.signal.aborted||(window.clearTimeout(d),_(`confirm`))})}catch(e){g(e instanceof Error?e.message:a.testFailed)}}try{if(n&&(c=new ce,await c.start(),t.signal.throwIfAborted()),!e){await y();return}let d=window.electronAPI?.system;if(d){let e=await d.requestMicrophone();if(t.signal.throwIfAborted(),e.status===`denied`)throw Error(a.microphoneDenied)}if(r=await navigator.mediaDevices.getUserMedia({audio:Y()}),t.signal.aborted){l();return}if(s=await ve.connect({purpose:`dictation`,signal:t.signal,onEvent:e=>{t.signal.aborted||(e.type===`session.error`&&g(a.testFailed),p.current===`listening`&&(e.type===`input.transcript.delta`&&u(e.payload.text),e.type===`input.transcript.final`&&e.payload.text.trim()&&(u(e.payload.text.trim()),h.current=!0,n?y():(_(`passed`),i?.({input:!0,output:!1}),v()))))},onClose:()=>{(p.current===`listening`||p.current===`connecting`)&&g(a.testFailed)}}),t.signal.aborted){l();return}let f;if(o=await re.start(r,{onSamples:e=>{f&&!t.signal.aborted&&s?.sendAudio(f.push(e))}}),t.signal.aborted){l();return}f=new oe(o.sampleRate,s.session.inputFormat.sampleRate),_(`listening`)}catch(e){if(t.signal.aborted){l();return}g(e instanceof Error?e.message:a.testFailed)}}let b=s===`connecting`||s===`listening`||s===`playing`;return(0,$.jsxs)(`div`,{className:`space-y-3 border-t border-edge pt-4`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,$.jsxs)(P,{type:`button`,variant:`primary`,disabled:o||r||!t||b,onClick:()=>void y(!0),children:[b?(0,$.jsx)(g,{className:`size-4 animate-spin`}):(0,$.jsx)(at,{className:`size-4`}),n?a.test:a.testInput]}),(0,$.jsxs)(P,{type:`button`,variant:`secondary`,disabled:o||r||!n||b,onClick:()=>void y(!1),children:[(0,$.jsx)(se,{className:`size-4`}),e.tts.test.play]}),b?(0,$.jsxs)(P,{type:`button`,variant:`ghost`,onClick:()=>{v(),_(`idle`)},children:[(0,$.jsx)(Ze,{className:`size-4`}),e.tts.test.stop]}):null]}),(0,$.jsxs)(`div`,{role:`status`,"aria-live":`polite`,className:`space-y-2 text-xs text-fg-muted`,children:[s===`idle`?(0,$.jsx)(`p`,{children:o?e.experience.endCallBeforeTest:r?a.saveBeforeTest:a.microphoneHint}):null,s===`connecting`?(0,$.jsx)(`p`,{children:a.connecting}):null,s===`listening`?(0,$.jsx)(`p`,{children:a.speakNow}):null,l?(0,$.jsx)(`p`,{className:`rounded-lg bg-surface-base p-3 text-sm text-fg`,children:l}):null,s===`playing`?(0,$.jsx)(`p`,{children:a.playing}):null,s===`confirm`?(0,$.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,$.jsx)(`span`,{children:a.heardQuestion}),(0,$.jsx)(P,{type:`button`,variant:`secondary`,onClick:()=>{v(),i?.({input:h.current,output:!0}),_(`passed`)},children:a.heard}),(0,$.jsx)(P,{type:`button`,variant:`ghost`,onClick:()=>{v(),_(`error`),f(a.notHeard)},children:a.notHeardButton})]}):null,s===`passed`?(0,$.jsx)(`p`,{children:h.current?n?a.passed:a.inputPassed:a.outputPassed}):null,s===`error`?(0,$.jsx)(`p`,{role:`alert`,className:`text-red-600 dark:text-red-400`,children:d}):null]})]})}function gn(e,t){return{...e,stt:{...e.stt,enabled:!0,provider:t},voice:{...e.voice,realtime:{...e.voice.realtime,enabled:!0,tts:e.voice.realtime.tts?.provider===t?e.voice.realtime.tts:{provider:t,...t===`alibaba`?{voice:`Cherry`}:{}},omni:e.voice.realtime.omni?.provider===t?e.voice.realtime.omni:t===`xopc-cloud`?void 0:{provider:t,model:`qwen3-omni-flash-realtime`,voice:e.voice.realtime.omni?.voice??`Cherry`,instructions:e.voice.realtime.omni?.instructions??`Keep replies conversational and concise.`}}}}}function _n(e){let t=(0,Z.c)(117),{section:n,v:r,form:i,pending:a,apiKeyLabels:o,sttProviders:s,onChange:c}=e,f=r.setup,[p,m]=(0,Q.useState)(!1),h;t[0]===i?h=t[1]:(h=JSON.stringify(i),t[0]=i,t[1]=h);let g=h,_;t[2]===g?_=t[3]:(_={signature:g,input:!1,output:!1},t[2]=g,t[3]=_);let[v,y]=(0,Q.useState)(_);v.signature!==g&&y({signature:g,input:!1,output:!1});let b;t[4]!==a||t[5]!==g?(b=a?null:[`voice-realtime-status`,g],t[4]=a,t[5]=g,t[6]=b):b=t[6];let x;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(x={revalidateOnFocus:!0},t[7]=x):x=t[7];let{data:S,error:C,isLoading:T}=N(b,Lt,x),E;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(E=w(`/api/voice/catalog`),t[8]=E):E=t[8];let{data:D}=N(E,Sn),O=i.voice.realtime,k=i.stt.provider,A=O.tts,j=A?.provider??S?.tts?.provider,M=S?.tts?.model,F;t[9]!==M||t[10]!==j?(F=j&&M?[`realtime-voices`,j,M]:null,t[9]=M,t[10]=j,t[11]=F):F=t[11];let I;t[12]!==M||t[13]!==j?(I=()=>Mt(j,M,`realtime`),t[12]=M,t[13]=j,t[14]=I):I=t[14];let R;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(R={revalidateOnFocus:!1},t[15]=R):R=t[15];let{data:z}=N(F,I,R),B;t[16]===z?B=t[17]:(B=z===void 0?[]:z,t[16]=z,t[17]=B);let V=B,H;t[18]!==j||t[19]!==V?(H=j===`alibaba`?V.filter(xn):V,t[18]=j,t[19]=V,t[20]=H):H=t[20];let U=H,W=typeof i.stt.providers?.alibaba?.apiKey==`string`?i.stt.providers.alibaba.apiKey:``,G;t[21]!==W||t[22]!==s?(G=!!W||s.some(bn),t[21]=W,t[22]=s,t[23]=G):G=t[23];let K=G,q=O.defaultEngine===`omni`,ee=q?O.omni?.voice??``:A?.voice??S?.tts?.voice??``,te;t[24]!==D?.models||t[25]!==q||t[26]!==O.omni?.model||t[27]!==O.omni?.provider||t[28]!==U?(te=q?O.omni?.provider===`xopc-cloud`?D?.models.find(e=>e.id===O.omni?.model)?.voice.voices??[]:[`Cherry`,`Ethan`,`Serena`,`Chelsie`].map(yn):U,t[24]=D?.models,t[25]=q,t[26]=O.omni?.model,t[27]=O.omni?.provider,t[28]=U,t[29]=te):te=t[29];let ne=te,re=!!(S?.enabled&&S.stt),J=!!(S?.enabled&&S.tts),ie;t[30]!==i||t[31]!==c||t[32]!==O?(ie=e=>c({...i,voice:{...i.voice,realtime:{...O,...e}}}),t[30]=i,t[31]=c,t[32]=O,t[33]=ie):ie=t[33];let Y=ie,ae;t[34]!==i||t[35]!==c?(ae=e=>c(gn(i,e)),t[34]=i,t[35]=c,t[36]=ae):ae=t[36];let oe=ae,X;t[37]!==a||t[38]!==O.enabled||t[39]!==f.disabled||t[40]!==f.needsSetup||t[41]!==f.pending||t[42]!==f.unverified||t[43]!==f.verified||t[44]!==g||t[45]!==v.signature?(X=(e,t)=>O.enabled?a?f.pending:e?t&&v.signature===g?f.verified:f.unverified:f.needsSetup:f.disabled,t[37]=a,t[38]=O.enabled,t[39]=f.disabled,t[40]=f.needsSetup,t[41]=f.pending,t[42]=f.unverified,t[43]=f.verified,t[44]=g,t[45]=v.signature,t[46]=X):X=t[46];let se=X,ce;t[47]!==o||t[48]!==oe||t[49]!==p||t[50]!==C||t[51]!==i||t[52]!==W||t[53]!==K||t[54]!==c||t[55]!==a||t[56]!==k||t[57]!==O.defaultEngine||t[58]!==O.enabled||t[59]!==f.changeKey||t[60]!==f.configureConversation||t[61]!==f.customProvider||t[62]!==f.edgeHint||t[63]!==f.enable||t[64]!==f.finishSetup||t[65]!==f.hosted||t[66]!==f.hostedAccountHint||t[67]!==f.hostedHint||t[68]!==f.keyConfigured||t[69]!==f.keyHint||t[70]!==f.manageAccount||t[71]!==f.outputHint||t[72]!==f.ownKey||t[73]!==f.ownKeyHint||t[74]!==f.service||t[75]!==f.statusError||t[76]!==n||t[77]!==A||t[78]!==S?.tts||t[79]!==Y||t[80]!==r.experience||t[81]!==r.stt?(ce=n===`service`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{className:`flex flex-wrap items-center justify-between gap-3 border-b border-edge pb-4`,children:(0,$.jsxs)(`label`,{className:`flex items-center gap-2 text-xs text-fg-muted`,children:[(0,$.jsx)(`input`,{type:`checkbox`,role:`switch`,"aria-checked":O.enabled,className:`size-4 accent-accent`,checked:O.enabled,onChange:e=>{e.target.checked?oe(k===`alibaba`?`alibaba`:`xopc-cloud`):Y({enabled:!1})}}),f.enable]})}),C?(0,$.jsx)(`p`,{role:`alert`,className:`text-xs text-red-600 dark:text-red-400`,children:f.statusError}):null,(0,$.jsxs)(`fieldset`,{className:`space-y-3`,children:[(0,$.jsx)(`legend`,{className:`text-sm font-medium text-fg`,children:f.service}),(0,$.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[`xopc-cloud`,`alibaba`].map(e=>(0,$.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-3 rounded-lg border border-edge px-3 py-3 text-sm text-fg has-checked:border-accent/60`,children:[(0,$.jsx)(`input`,{type:`radio`,name:`realtime-service`,value:e,checked:k===e,onChange:()=>oe(e),className:`mt-1 accent-accent`}),(0,$.jsxs)(`span`,{children:[(0,$.jsx)(`span`,{className:`block font-medium`,children:e===`xopc-cloud`?f.hosted:f.ownKey}),(0,$.jsx)(`span`,{className:`mt-1 block text-xs text-fg-muted`,children:e===`xopc-cloud`?f.hostedHint:f.ownKeyHint})]})]},e))})]}),k!==`alibaba`&&k!==`xopc-cloud`?(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:f.customProvider.replace(`{provider}`,k)}):null,k===`alibaba`?(0,$.jsx)(`div`,{className:`space-y-2 text-xs`,children:K&&!p?(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,$.jsx)(`span`,{className:`text-fg-muted`,children:f.keyConfigured}),(0,$.jsx)(P,{type:`button`,variant:`ghost`,onClick:()=>m(!0),children:f.changeKey})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`label`,{htmlFor:`realtime-api-key`,className:`font-medium text-fg`,children:r.stt.apiKey}),(0,$.jsx)(Bt,{kind:`stt`,providerId:`alibaba`,fieldId:`realtime-api-key`,value:W,labels:{...o,maskedHelp:``},onChange:e=>c({...i,stt:{...i.stt,providers:{...i.stt.providers,alibaba:{...i.stt.providers?.alibaba,apiKey:e}}}})}),(0,$.jsx)(`p`,{className:`text-fg-muted`,children:f.keyHint})]})}):null,k===`xopc-cloud`?(0,$.jsxs)(`p`,{className:`text-xs text-fg-muted`,children:[f.hostedAccountHint,` `,(0,$.jsx)(l,{className:`text-accent hover:underline`,to:`/settings/capabilities/models`,children:f.manageAccount})]}):null,!A&&!a&&!S?.tts&&(k===`alibaba`||k===`xopc-cloud`)?(0,$.jsxs)(`div`,{className:`rounded-lg bg-surface-base p-3 text-xs`,children:[(0,$.jsx)(`p`,{className:`font-medium text-fg`,children:f.finishSetup}),(0,$.jsx)(`p`,{className:`mt-1 text-fg-muted`,children:i.tts.provider===`edge`?f.edgeHint:f.outputHint}),(0,$.jsx)(P,{className:`mt-2`,type:`button`,variant:`secondary`,onClick:()=>oe(k),children:f.configureConversation})]}):null,(0,$.jsxs)(`label`,{className:`block space-y-2 text-sm`,children:[(0,$.jsx)(`span`,{children:r.experience.defaultMode}),(0,$.jsxs)(u,{value:O.defaultEngine,className:Ye,onChange:e=>Y({defaultEngine:e.target.value}),children:[(0,$.jsx)(d,{value:`agent`,children:r.experience.assistant}),(0,$.jsx)(d,{value:`omni`,children:r.experience.natural})]})]}),(0,$.jsxs)(`p`,{className:`text-xs text-fg-muted`,children:[O.defaultEngine===`agent`?r.experience.assistantHint:r.experience.naturalHint,` `,r.experience.nextCall]})]}):null,t[47]=o,t[48]=oe,t[49]=p,t[50]=C,t[51]=i,t[52]=W,t[53]=K,t[54]=c,t[55]=a,t[56]=k,t[57]=O.defaultEngine,t[58]=O.enabled,t[59]=f.changeKey,t[60]=f.configureConversation,t[61]=f.customProvider,t[62]=f.edgeHint,t[63]=f.enable,t[64]=f.finishSetup,t[65]=f.hosted,t[66]=f.hostedAccountHint,t[67]=f.hostedHint,t[68]=f.keyConfigured,t[69]=f.keyHint,t[70]=f.manageAccount,t[71]=f.outputHint,t[72]=f.ownKey,t[73]=f.ownKeyHint,t[74]=f.service,t[75]=f.statusError,t[76]=n,t[77]=A,t[78]=S?.tts,t[79]=Y,t[80]=r.experience,t[81]=r.stt,t[82]=ce):ce=t[82];let le;t[83]!==ee||t[84]!==q||t[85]!==j||t[86]!==O.bargeIn||t[87]!==O.omni||t[88]!==O.tts||t[89]!==f.bargeIn||t[90]!==f.defaultVoice||t[91]!==f.voice||t[92]!==n||t[93]!==A||t[94]!==S?.tts||t[95]!==Y||t[96]!==r.realtime||t[97]!==ne?(le=n===`listening`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,$.jsx)(`label`,{htmlFor:`realtime-voice`,className:`text-sm font-medium text-fg`,children:f.voice}),(0,$.jsxs)(u,{id:`realtime-voice`,className:`${Ye} w-full sm:w-56`,value:ee,disabled:q?!O.omni:!A&&!S?.tts,onChange:e=>{if(q&&O.omni){Y({omni:{...O.omni,voice:e.target.value}});return}(j===`alibaba`||j===`xopc-cloud`)&&Y({tts:{...O.tts,provider:j,...e.target.value?{voice:e.target.value}:{}},...O.omni&&[`Cherry`,`Ethan`,`Serena`,`Chelsie`].includes(e.target.value)?{omni:{...O.omni,voice:e.target.value}}:{}})},children:[q?null:(0,$.jsx)(d,{value:``,children:f.defaultVoice}),ee&&!ne.some(e=>e.id===ee)?(0,$.jsx)(d,{value:ee,children:ee}):null,ne.map(vn)]})]}),(0,$.jsxs)(`label`,{className:`flex items-center justify-between gap-4 text-sm text-fg`,children:[(0,$.jsxs)(`span`,{children:[f.bargeIn,(0,$.jsx)(`span`,{className:`mt-1 block text-xs text-fg-muted`,children:r.realtime.bargeInDescription})]}),(0,$.jsx)(`input`,{type:`checkbox`,role:`switch`,"aria-checked":O.bargeIn,checked:O.bargeIn,className:`size-4 accent-accent`,onChange:e=>Y({bargeIn:e.target.checked})})]})]}):null,t[83]=ee,t[84]=q,t[85]=j,t[86]=O.bargeIn,t[87]=O.omni,t[88]=O.tts,t[89]=f.bargeIn,t[90]=f.defaultVoice,t[91]=f.voice,t[92]=n,t[93]=A,t[94]=S?.tts,t[95]=Y,t[96]=r.realtime,t[97]=ne,t[98]=le):le=t[98];let ue;t[99]!==re||t[100]!==J||t[101]!==C||t[102]!==T||t[103]!==a||t[104]!==n||t[105]!==g||t[106]!==S||t[107]!==se||t[108]!==r||t[109]!==v.input||t[110]!==v.output?(ue=n===`diagnostics`?(0,$.jsxs)($.Fragment,{children:[T?(0,$.jsx)(L,{className:`h-16 w-full`}):(0,$.jsxs)(`div`,{className:`space-y-2 text-sm`,role:`status`,children:[(0,$.jsxs)(`p`,{children:[r.experience.dictationReady,` · `,se(re,v.input)]}),(0,$.jsxs)(`p`,{children:[r.experience.agentReady,` · `,se(re&&J,v.input&&v.output)]}),(0,$.jsxs)(`p`,{children:[r.experience.omniReady,` · `,se(!!(S?.enabled&&S.omni),!1)]})]}),(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:r.experience.configurationOnly}),(0,$.jsx)(hn,{v:r,canListen:re,canSpeak:J,disabled:a||T||!!C,onVerified:e=>y({signature:g,...e})},`${g}:${JSON.stringify(S)}`)]}):null,t[99]=re,t[100]=J,t[101]=C,t[102]=T,t[103]=a,t[104]=n,t[105]=g,t[106]=S,t[107]=se,t[108]=r,t[109]=v.input,t[110]=v.output,t[111]=ue):ue=t[111];let de;return t[112]!==f.service||t[113]!==ce||t[114]!==le||t[115]!==ue?(de=(0,$.jsxs)(`section`,{className:`space-y-5 rounded-xl border border-edge bg-surface-panel p-4 sm:p-5`,"aria-label":f.service,children:[ce,le,ue]}),t[112]=f.service,t[113]=ce,t[114]=le,t[115]=ue,t[116]=de):de=t[116],de}function vn(e){return(0,$.jsx)(d,{value:e.id,children:e.name},e.id)}function yn(e){return{id:e,name:e}}function bn(e){return e.id===`alibaba`&&e.configured}function xn(e){return[`Cherry`,`Ethan`,`Serena`,`Chelsie`].includes(e.id)}async function Sn(e){return yt.parse((await b(e)).payload)}function Cn(e){let t=(0,Z.c)(22),{value:n,onChange:r}=e,i=C(Tn)===`zh`,a;t[0]===i?a=t[1]:(a=(e,t)=>i?t:e,t[0]=i,t[1]=a);let o=a,s;t[2]!==r||t[3]!==n?(s=e=>{n&&r({...n,...e})},t[2]=r,t[3]=n,t[4]=s):s=t[4];let c=s,l;t[5]===o?l=t[6]:(l=o(`Natural conversation · advanced`,`自然对话 · 高级设置`),t[5]=o,t[6]=l);let f;t[7]===l?f=t[8]:(f=(0,$.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg`,children:l}),t[7]=l,t[8]=f);let p;t[9]===o?p=t[10]:(p=o(`Calls continue the same session using recent history. Service and credentials are shared with voice setup; override them here only when needed.`,`通话会接续同一会话的近期历史。默认共用语音服务与凭据,仅在需要独立配置时修改。`),t[9]=o,t[10]=p);let m;t[11]===p?m=t[12]:(m=(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:p}),t[11]=p,t[12]=m);let h;t[13]!==o||t[14]!==r||t[15]!==c||t[16]!==n?(h=n?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`label`,{className:`block space-y-1 text-sm`,children:[(0,$.jsx)(`span`,{children:o(`Connection`,`连接方式`)}),(0,$.jsx)(u,{value:n.provider,onChange:e=>r({model:n.model,voice:n.voice,instructions:n.instructions,provider:e.target.value}),children:(0,$.jsxs)(d,{value:`alibaba`,children:[`DashScope · `,o(`Your API key`,`自有 API Key`)]})})]}),(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n.provider===`xopc-cloud`?o(`Uses your XOPC sign-in and the platform’s published Omni route and credits.`,`使用 XOPC 登录授权、平台发布的 Omni 路由和额度。`):o(`Leave empty to use the shared voice service credential.`,`留空使用语音服务中已配置的凭据。`)}),(0,$.jsx)(`p`,{className:`font-mono text-xs text-fg-muted`,children:n.model}),n.provider===`alibaba`?(0,$.jsxs)(`label`,{className:`block space-y-1 text-sm`,children:[(0,$.jsx)(`span`,{children:`API Key`}),(0,$.jsx)(`input`,{className:`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,type:`password`,autoComplete:`new-password`,value:n.apiKey??``,onChange:e=>c({apiKey:e.target.value})})]}):null,(0,$.jsxs)(`label`,{className:`block space-y-1 text-sm`,children:[(0,$.jsx)(`span`,{children:o(`Endpoint override (optional)`,`自定义服务地址(可选)`)}),(0,$.jsx)(`input`,{className:`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,value:n.baseUrl??``,placeholder:n.provider===`alibaba`?`wss://dashscope.aliyuncs.com/api-ws/v1/realtime`:`https://router.xopc.ai/v1`,onChange:e=>c({baseUrl:e.target.value.trim()||void 0})})]}),(0,$.jsxs)(`label`,{className:`block space-y-1 text-sm`,children:[(0,$.jsx)(`span`,{children:o(`Voice`,`音色`)}),(0,$.jsx)(u,{value:n.voice,onChange:e=>c({voice:e.target.value}),children:[`Cherry`,`Ethan`,`Serena`,`Chelsie`].map(wn)})]}),(0,$.jsxs)(`label`,{className:`block space-y-1 text-sm`,children:[(0,$.jsx)(`span`,{children:o(`Conversation instructions`,`聊天指令`)}),(0,$.jsx)(`textarea`,{className:`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,rows:3,maxLength:8e3,value:n.instructions,onChange:e=>c({instructions:e.target.value})})]})]}):(0,$.jsx)(P,{variant:`secondary`,onClick:()=>r({provider:`alibaba`,model:`qwen3-omni-flash-realtime`,voice:`Cherry`,instructions:`You are a friendly voice companion. You cannot execute tools.`}),children:o(`Configure natural conversation`,`配置自然聊天`)}),t[13]=o,t[14]=r,t[15]=c,t[16]=n,t[17]=h):h=t[17];let g;return t[18]!==f||t[19]!==m||t[20]!==h?(g=(0,$.jsxs)(`details`,{className:`space-y-3 rounded-xl border border-edge p-4`,children:[f,m,h]}),t[18]=f,t[19]=m,t[20]=h,t[21]=g):g=t[21],g}function wn(e){return(0,$.jsx)(d,{value:e,children:e},e)}function Tn(e){return e.language}var En=me;function Dn(){return y(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,W,`dark:border-edge`)}function On(){return y(Ye,me)}function kn(e){return!e||e<=0?``:e<1024*1024?`${Math.round(e/1024)} KB`:`${(e/1024/1024).toFixed(1)} MB`}function An(e,t){let n=window.atob(e),r=new Uint8Array(n.length);for(let e=0;e<n.length;e++)r[e]=n.charCodeAt(e);return URL.createObjectURL(new Blob([r],{type:t}))}function jn(e,t){switch(e){case`xopc-local`:return t.stt.localProvider;case`openai`:return t.stt.openai;case`alibaba`:return t.stt.alibaba;case`groq`:return`Groq`;default:return e}}function Mn(e,t){switch(e){case`openai`:return t.tts.providerOpenai;case`alibaba`:return t.stt.alibaba;case`edge`:return t.tts.providerEdge;case`tts-local-cli`:return t.tts.providerLocalCli;case`minimax`:return`MiniMax`;default:return e}}function Nn(e,t){switch(e){case`off`:return t.tts.triggerOff;case`always`:return t.tts.triggerAlways;case`inbound`:return t.tts.triggerInbound;case`tagged`:return t.tts.triggerTagged}}function Pn(e,t){switch(e){case`edge`:return t.tts.providerHints.edge;case`openai`:return t.tts.providerHints.openai;case`alibaba`:return t.tts.providerHints.alibaba;case`minimax`:return t.tts.providerHints.minimax;case`tts-local-cli`:return t.tts.providerHints.localCli;default:return t.tts.providerHints.generic}}function Fn(e){return{maskedHelp:e.apiKeyMaskedHelp,copy:e.apiKeyCopy,copied:e.apiKeyCopied,show:e.apiKeyShow,hide:e.apiKeyHide,notInConfigFile:e.apiKeyNotInConfigFile,loadFailed:e.apiKeyRevealFailed}}function In(e,t){let n=e[t.key];return typeof n==`string`||typeof n==`number`||typeof n==`boolean`?n:t.defaultValue===void 0?t.type===`boolean`?!1:``:t.defaultValue}function Ln(e,t){if(e.type===`boolean`)return!!t;if(e.type!==`number`)return t;let n=String(t).trim();if(!n)return;let r=Number(n);return Number.isFinite(r)?r:void 0}function Rn(e,t){switch(t.type){case`reset`:return{form:null,baseline:null};case`sync`:{let e=structuredClone(t.value);return{form:e,baseline:structuredClone(e)}}case`update`:return{...e,form:t.updater(e.form)};case`saved`:{let n=structuredClone(t.value);return{form:e.form!==null&&JSON.stringify(e.form)!==JSON.stringify(t.value)?e.form:n,baseline:structuredClone(n)}}}}function zn(){let e=C(e=>e.language),t=T(e).voiceSettings,[n,r]=(0,Q.useState)(`listening`),i=mt(),a=De(e=>e.captions),o=De(e=>e.setCaptions),s=!!x(e=>e.conversationId);(0,Q.useEffect)(()=>{!i&&n===`diagnostics`&&r(`listening`)},[n,i]);let[c,l]=(0,Q.useReducer)(Rn,{form:null,baseline:null}),f=c.form,p=c.baseline,[m,h]=(0,Q.useState)(null),g=(0,Q.useRef)(!1),_=(0,Q.useRef)(f);_.current=f;let v=(0,Q.useRef)({parsed:null,models:void 0}),{data:y,error:b,isLoading:S,mutate:E}=I(s),{data:D,error:O,isLoading:k,mutate:A}=N(s?w(`/api/voice/models`):null,Dt,{revalidateOnFocus:!1}),{data:j,error:M,isLoading:F}=N(s?w(`/api/voice/providers`):null,Ft,{revalidateOnFocus:!1}),{data:L,error:R,isLoading:z}=N(s?w(`/api/voice/stt-providers`):null,Ot,{revalidateOnFocus:!1}),B=(0,Q.useMemo)(()=>j?.providers??[],[j]),V=(0,Q.useMemo)(()=>L?.providers??[],[L]),H=(0,Q.useMemo)(()=>y?.payload?.config===void 0?null:zt(y.payload.config),[y]),U=(0,Q.useMemo)(()=>!f||!p?!1:JSON.stringify(f)!==JSON.stringify(p),[f,p]);s?H!==null&&D!==void 0&&!g.current&&(v.current.parsed!==H||v.current.models!==D)&&(v.current={parsed:H,models:D},l({type:`sync`,value:H}),h(D)):(v.current.parsed!==null||v.current.models!==void 0)&&(v.current={parsed:null,models:void 0},l({type:`reset`}),h(null),g.current=!1);let W=!!(s&&(H===null||D===void 0||j===void 0||L===void 0)&&(S||k||F||z)),G=b instanceof Error?b.message:b?String(b):O instanceof Error?O.message:O?String(O):M instanceof Error?M.message:M?String(M):R instanceof Error?R.message:R?String(R):null,K=(0,Q.useCallback)(e=>{g.current=!0,l({type:`update`,updater:t=>t?{...t,stt:{...t.stt,...e}}:null})},[]),q=(0,Q.useCallback)(e=>{g.current=!0,l({type:`update`,updater:t=>{if(!t)return null;let n=t.stt.fallback??{enabled:!1,order:[`xopc-local`]};return{...t,stt:{...t.stt,fallback:{...n,...e}}}}})},[]),ee=(0,Q.useCallback)(e=>{g.current=!0,l({type:`update`,updater:t=>t?{...t,voice:{...t.voice,input:{...t.voice.input,refinement:{...t.voice.input.refinement,...e}}}}:null})},[]),te=(0,Q.useCallback)(t=>{g.current=!0,l({type:`update`,updater:n=>n?{...n,voice:{...n.voice,languageMode:t,...t===`auto`?{language:e}:{}}}:null})},[e]),ne=(0,Q.useCallback)(e=>{g.current=!0,l({type:`update`,updater:t=>t?{...t,voice:{...t.voice,realtime:{...t.voice.realtime,...e}}}:null})},[]),re=(0,Q.useCallback)(e=>{g.current=!0,l({type:`update`,updater:t=>t?{...t,tts:{...t.tts,...e}}:null})},[]),J=Et({value:f,dirty:U,onSave:(0,Q.useCallback)(async e=>{let n=p?.stt.provider!==`xopc-local`&&e.stt.provider===`xopc-local`;try{await kt(e),n&&window.dispatchEvent(new Event(Rt)),l({type:`saved`,value:e}),g.current=!!(_.current&&JSON.stringify(_.current)!==JSON.stringify(e))}catch(e){throw Error(e instanceof Error?e.message:t.saveError)}},[p?.stt.provider,t.saveError])}),ie=(0,Q.useCallback)(e=>{g.current=!0,l({type:`update`,updater:()=>e})},[]);if(!s)return(0,$.jsx)(`div`,{className:`flex flex-col gap-3`,children:(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.needToken})});if(W)return(0,$.jsx)(wt,{rows:4});if(!f||m===null)return(0,$.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:G??t.loadError}),(0,$.jsx)(P,{type:`button`,variant:`secondary`,onClick:()=>{E(),A()},children:t.retry})]});let Y=f.stt,ae=f.tts,oe=f.voice.input.refinement,X=Fn(t);return(0,$.jsxs)(`div`,{className:`flex w-full flex-col gap-4`,onBlurCapture:J.onBlurCapture,children:[(0,$.jsx)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:(0,$.jsx)(Tt,{status:J.status,error:J.error})}),J.error?(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:J.error}):null,(0,$.jsx)(`nav`,{"aria-label":t.setup.advanced,className:`flex flex-wrap gap-2`,children:[`listening`,`input`,`devices`,`service`,...i?[`diagnostics`]:[]].map(e=>(0,$.jsx)(P,{variant:n===e?`secondary`:`ghost`,"aria-pressed":n===e,onClick:()=>r(e),children:t.experience[e]},e))}),n===`listening`||n===`service`||n===`diagnostics`?(0,$.jsx)(_n,{section:n,v:t,form:f,pending:U||J.status===`saving`||!!J.error,apiKeyLabels:X,sttProviders:V,onChange:ie}):null,n===`listening`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Bn,{v:t,voice:f.voice,updateLanguageMode:te}),(0,$.jsxs)(`label`,{className:`flex items-center justify-between gap-3 text-sm text-fg`,children:[t.experience.pace,(0,$.jsxs)(u,{className:On(),value:String(f.voice.realtime.silenceDurationMs),onChange:e=>ne({silenceDurationMs:Number(e.target.value)}),children:[(0,$.jsx)(d,{value:`800`,children:t.experience.fast}),(0,$.jsx)(d,{value:`1200`,children:t.experience.standard}),(0,$.jsx)(d,{value:`2000`,children:t.experience.relaxed}),[800,1200,2e3].includes(f.voice.realtime.silenceDurationMs)?null:(0,$.jsxs)(d,{value:String(f.voice.realtime.silenceDurationMs),children:[f.voice.realtime.silenceDurationMs,` ms`]})]})]})]}):null,n===`input`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`label`,{className:`flex items-center justify-between text-sm`,children:[t.experience.captions,(0,$.jsx)(`input`,{type:`checkbox`,role:`switch`,"aria-checked":a,className:`ui-checkbox`,checked:a,onChange:e=>o(e.target.checked)})]}),(0,$.jsxs)(`label`,{className:`space-y-2 text-sm`,children:[(0,$.jsx)(`span`,{children:t.stt.refinement}),(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.stt.refinementDesc}),(0,$.jsxs)(u,{className:On(),value:oe.mode,onChange:e=>ee({mode:e.target.value}),children:[(0,$.jsx)(d,{value:`off`,children:t.stt.refinementOff}),(0,$.jsx)(d,{value:`punctuation`,children:t.stt.refinementPunctuation}),(0,$.jsx)(d,{value:`light`,children:t.stt.refinementLight}),oe.mode===`custom`?(0,$.jsx)(d,{value:`custom`,children:t.setup.advanced}):null]})]}),(0,$.jsxs)(`details`,{className:`rounded-xl border border-edge bg-surface-panel px-4 py-3`,children:[(0,$.jsxs)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg`,children:[t.setup.readout,` · `,ae.enabled?Nn(ae.trigger,t):t.overview.off]}),(0,$.jsx)(`p`,{className:`mt-3 text-xs text-fg-muted`,children:t.setup.readoutHint}),(0,$.jsx)(Gn,{v:t,apiKeyLabels:X,tts:ae,models:m,ttsProviders:B,updateTts:re})]})]}):null,n===`devices`?(0,$.jsx)(mn,{v:t}):null,n===`service`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(pn,{disabled:U||J.status===`saving`}),f.voice.realtime.enabled&&f.voice.realtime.omni?.provider===`alibaba`?(0,$.jsx)(Cn,{value:f.voice.realtime.omni,onChange:e=>ne({omni:e})}):null,(0,$.jsxs)(`details`,{className:`rounded-xl border border-edge bg-surface-panel px-4 py-3`,children:[(0,$.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg`,children:t.experience.technical}),(0,$.jsx)(Vn,{v:t,apiKeyLabels:X,stt:Y,models:m,sttProviders:V,updateStt:K,updateSttFallback:q}),(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.notes.envVars})]})]}):null]})}function Bn(e){let t=(0,Z.c)(22),{v:n,voice:r,updateLanguageMode:i}=e,a;t[0]===n.language.title?a=t[1]:(a=(0,$.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:n.language.title}),t[0]=n.language.title,t[1]=a);let o=r.languageMode===`auto`?n.language.autoDescription:n.language.manualDescription,s;t[2]===o?s=t[3]:(s=(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:o}),t[2]=o,t[3]=s);let c;t[4]!==a||t[5]!==s?(c=(0,$.jsxs)(`div`,{children:[a,s]}),t[4]=a,t[5]=s,t[6]=c):c=t[6];let l;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(l=On(),t[7]=l):l=t[7];let f;t[8]===i?f=t[9]:(f=e=>i(e.target.value),t[8]=i,t[9]=f);let p;t[10]===n.language.auto?p=t[11]:(p=(0,$.jsx)(d,{value:`auto`,children:n.language.auto}),t[10]=n.language.auto,t[11]=p);let m;t[12]===n.language.manual?m=t[13]:(m=(0,$.jsx)(d,{value:`manual`,children:n.language.manual}),t[12]=n.language.manual,t[13]=m);let h;t[14]!==f||t[15]!==p||t[16]!==m||t[17]!==r.languageMode?(h=(0,$.jsxs)(u,{className:l,value:r.languageMode,onChange:f,children:[p,m]}),t[14]=f,t[15]=p,t[16]=m,t[17]=r.languageMode,t[18]=h):h=t[18];let g;return t[19]!==c||t[20]!==h?(g=(0,$.jsx)(`section`,{className:`rounded-2xl bg-surface-base px-4 py-5 sm:px-5`,children:(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-[minmax(0,1fr)_minmax(12rem,18rem)] sm:items-center`,children:[c,h]})}),t[19]=c,t[20]=h,t[21]=g):g=t[21],g}function Vn(e){let t=(0,Z.c)(58),{v:n,apiKeyLabels:r,stt:i,models:a,sttProviders:o,updateStt:s,updateSttFallback:c}=e,l;if(t[0]!==o){let e=new Set;l=[];for(let t of o)e.has(t.id)||(e.add(t.id),l.push(t));t[0]=o,t[1]=l}else l=t[1];let f=l,p,m,h,g;if(t[2]!==a||t[3]!==f||t[4]!==i.provider||t[5]!==i.providers){p=f.find(e=>e.id===i.provider);let e;t[10]!==i.provider||t[11]!==i.providers?(e=i.providers?.[i.provider]??{},t[10]=i.provider,t[11]=i.providers,t[12]=e):e=t[12],h=e,m=a?.stt?.[i.provider]?.length?a.stt[i.provider]:p?.models??[],g=p?.fields.find(Hn),t[2]=a,t[3]=f,t[4]=i.provider,t[5]=i.providers,t[6]=p,t[7]=m,t[8]=h,t[9]=g}else p=t[6],m=t[7],h=t[8],g=t[9];let _=g,v=typeof h.model==`string`?h.model:void 0,b=v??(typeof _?.defaultValue==`string`?_.defaultValue:m[0]?.id),x;t[13]!==i.provider||t[14]!==i.providers||t[15]!==s?(x=e=>{s({providers:{...i.providers??{},[i.provider]:{...i.providers?.[i.provider]??{},...e}}})},t[13]=i.provider,t[14]=i.providers,t[15]=s,t[16]=x):x=t[16];let S=x,C,w;t[17]!==v||t[18]!==b||t[19]!==_||t[20]!==S?(C=()=>{_&&b&&v!==b&&S({model:b})},w=[v,b,_,S],t[17]=v,t[18]=b,t[19]=_,t[20]=S,t[21]=C,t[22]=w):(C=t[21],w=t[22]),(0,Q.useEffect)(C,w);let T;t[23]===Symbol.for(`react.memo_cache_sentinel`)?(T=(0,$.jsx)(at,{className:`size-4 text-accent`,strokeWidth:1.75}),t[23]=T):T=t[23];let E;t[24]===n.stt.title?E=t[25]:(E=(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[T,n.stt.title]}),t[24]=n.stt.title,t[25]=E);let D;t[26]===n.stt.description?D=t[27]:(D=(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:n.stt.description}),t[26]=n.stt.description,t[27]=D);let O;t[28]!==E||t[29]!==D?(O=(0,$.jsxs)(`div`,{className:`mb-4`,children:[E,D]}),t[28]=E,t[29]=D,t[30]=O):O=t[30];let k;t[31]===s?k=t[32]:(k=e=>s({enabled:e}),t[31]=s,t[32]=k);let A;t[33]!==i.enabled||t[34]!==k||t[35]!==n.stt.enable||t[36]!==n.stt.enableDesc?(A=(0,$.jsx)(qn,{checked:i.enabled,title:n.stt.enable,description:n.stt.enableDesc,onChange:k}),t[33]=i.enabled,t[34]=k,t[35]=n.stt.enable,t[36]=n.stt.enableDesc,t[37]=A):A=t[37];let j;t[38]!==p?.fields||t[39]!==r||t[40]!==b||t[41]!==m||t[42]!==f||t[43]!==h||t[44]!==i.enabled||t[45]!==i.fallback?.enabled||t[46]!==i.provider||t[47]!==S||t[48]!==s||t[49]!==c||t[50]!==n?(j=i.enabled?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,$.jsxs)(`div`,{className:y(`flex flex-col gap-1.5`,En),children:[(0,$.jsx)(Xn,{children:n.stt.provider}),(0,$.jsx)(u,{className:On(),value:i.provider,onChange:e=>s({provider:e.target.value}),children:f.map(e=>(0,$.jsxs)(d,{value:e.id,children:[jn(e.id,n),e.configured?``:` *`]},e.id))})]}),(0,$.jsx)(Kn,{kind:`stt`,providerId:i.provider,fields:p?.fields??[],providerSlice:h,models:m,currentModel:b,apiKeyLabels:r,onPatch:S})]}),i.provider===`xopc-local`?(0,$.jsx)(Wn,{v:n}):null,(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2 rounded-xl bg-surface-hover/50 px-3 py-2.5 dark:bg-surface-hover/35`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n.stt.fallback}),(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n.stt.fallbackDesc})]}),(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:i.fallback?.enabled??!1,onChange:e=>c({enabled:e.target.checked})})]})]}):null,t[38]=p?.fields,t[39]=r,t[40]=b,t[41]=m,t[42]=f,t[43]=h,t[44]=i.enabled,t[45]=i.fallback?.enabled,t[46]=i.provider,t[47]=S,t[48]=s,t[49]=c,t[50]=n,t[51]=j):j=t[51];let M;t[52]!==A||t[53]!==j?(M=(0,$.jsxs)(`div`,{className:`space-y-4`,children:[A,j]}),t[52]=A,t[53]=j,t[54]=M):M=t[54];let N;return t[55]!==M||t[56]!==O?(N=(0,$.jsxs)(`section`,{className:`rounded-2xl bg-surface-base px-4 py-5 sm:px-5`,children:[O,M]}),t[55]=M,t[56]=O,t[57]=N):N=t[57],N}function Hn(e){return e.key===`model`}function Un(e){return`${Math.round(e/1024/1024)} MB`}function Wn({v:e}){let{data:t,error:n,mutate:r}=N(w(`/api/voice/local/status`),Pt,{revalidateOnFocus:!1,refreshInterval:e=>e?.models.some(e=>e.state===`downloading`)?1e3:0}),[i,a]=(0,Q.useState)(null),[o,s]=(0,Q.useState)(null);(0,Q.useEffect)(()=>{let e=()=>void r();return window.addEventListener(Rt,e),()=>window.removeEventListener(Rt,e)},[r]);let c=(0,Q.useCallback)(async(e,t)=>{a(e.id),s(null);try{t===`install`?await Nt(e.id):await It(e.id),await r()}catch(e){s(e instanceof Error?e.message:String(e))}finally{a(null)}},[r]);return(0,$.jsxs)(`div`,{className:`rounded-xl border border-edge bg-surface-panel/60 p-3`,children:[(0,$.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:e.stt.localModels}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:e.stt.localModelsDesc}),n?(0,$.jsx)(`p`,{className:`mt-3 text-xs text-red-600 dark:text-red-400`,children:String(n)}):null,t?.runtime.ready===!1?(0,$.jsx)(`p`,{className:`mt-3 text-xs text-red-600 dark:text-red-400`,children:t.runtime.error??`Local voice runtime is unavailable`}):null,t?.decoder?.available===!1?(0,$.jsx)(`p`,{className:`mt-3 text-xs text-amber-700 dark:text-amber-300`,children:t.decoder.error??`Compressed audio decoding is unavailable`}):null,o?(0,$.jsx)(`p`,{className:`mt-3 text-xs text-red-600 dark:text-red-400`,children:o}):null,(0,$.jsx)(`div`,{className:`mt-3 grid gap-2`,children:(t?.models??[]).map(t=>{let n=i===t.id||t.state===`downloading`;return(0,$.jsxs)(`div`,{className:y(`flex items-center justify-between gap-3 rounded-lg bg-surface-base px-3 py-2.5`,t.recommended?`ring-1 ring-accent/40`:``),children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-sm font-medium text-fg`,children:[t.name,t.recommended?(0,$.jsx)(`span`,{className:`rounded-full bg-accent/10 px-2 py-0.5 text-[10px] font-medium text-accent`,children:e.stt.localRecommended}):null]}),(0,$.jsxs)(`div`,{className:`text-xs text-fg-muted`,children:[Un(t.approximateBytes),` · `,t.description]}),(0,$.jsxs)(`div`,{className:`mt-0.5 text-[11px] text-fg-subtle`,children:[t.engine,` · `,t.languages.join(` / `)]}),t.state===`downloading`?(0,$.jsxs)(`div`,{className:`mt-1 text-xs text-accent`,children:[e.stt.localDownloading,` `,Math.round((t.progress??0)*100),`%`]}):t.state===`error`?(0,$.jsx)(`div`,{className:`mt-1 text-xs text-red-600 dark:text-red-400`,children:t.error}):null]}),(0,$.jsx)(P,{type:`button`,variant:`secondary`,disabled:n,onClick:()=>void c(t,t.state===`ready`?`remove`:`install`),children:n?(0,$.jsx)(g,{className:`size-4 animate-spin`}):t.state===`ready`?e.stt.localRemove:e.stt.localInstall})]},t.id)})})]})}function Gn({v:e,apiKeyLabels:t,tts:n,models:r,ttsProviders:i,updateTts:a}){let[o,s]=(0,Q.useState)(e.tts.test.sampleText),[c,l]=(0,Q.useState)({status:`idle`}),f=(0,Q.useRef)(null),p=(0,Q.useRef)(null),m=(0,Q.useRef)(null),h=(0,Q.useCallback)(()=>{m.current?.abort(),m.current=null,f.current?.pause(),f.current=null,p.current&&=(URL.revokeObjectURL(p.current),null)},[]),_=(0,Q.useMemo)(()=>{let e=new Set,t=[];for(let n of i)e.has(n.id)||(e.add(n.id),t.push(n));return t},[i]),v=_.find(e=>e.id===n.provider),b=n.providers?.[n.provider]??{},x=r?.tts?.[n.provider]?.length?r.tts[n.provider]:v?.models??[],S=v?.fields.find(e=>e.key===`model`),C=v?.fields.find(e=>e.key===`voice`),w=typeof b.model==`string`?b.model:void 0,T=w??(typeof S?.defaultValue==`string`?S.defaultValue:x[0]?.id),E=x.find(e=>e.id===T),D=r?.ttsVoices?.[n.provider]?.length?r.ttsVoices[n.provider]:v?.voices??[],{data:O=[]}=N(T?`voice:tts:${n.provider}:${T}`:null,()=>Mt(n.provider,T??``),{revalidateOnFocus:!1}),k=O.length>0?O:D,A=typeof b.voice==`string`?b.voice:void 0,j=A??k.find(e=>e.id===E?.tts?.defaultVoice)?.id??(typeof C?.defaultValue==`string`?C.defaultValue:k[0]?.id),M=(v?.fields??[]).filter(e=>(e.key!==`speed`||E?.tts?.speed!==!1)&&(e.key!==`instructions`||E?.tts?.instructions!==!1)),F=!!v?.diagnostics.requiresApiKey,I=!!v?.configured||!F,L=(0,Q.useCallback)(e=>{a({providers:{...n.providers??{},[n.provider]:{...n.providers?.[n.provider]??{},...e}}})},[n.provider,n.providers,a]);(0,Q.useEffect)(()=>{let e={};S&&T&&w!==T&&(e.model=T),C&&j&&A!==j&&(e.voice=j),Object.keys(e).length>0&&L(e)},[w,A,T,j,S,L,C]),(0,Q.useEffect)(()=>()=>h(),[h]);let R=(0,Q.useCallback)(e=>{a({provider:e}),l({status:`idle`})},[a]),z=(0,Q.useCallback)(async()=>{let t=o.trim();if(!t){l({status:`error`,message:e.tts.test.emptyText});return}h();let r=new AbortController;m.current=r,l({status:`loading`});try{let i=await jt({text:t,provider:n.provider,providerConfig:b,...T?{model:T}:{},...j?{voice:j}:{}},r.signal);if(r.signal.aborted)return;let a=An(i.audio,i.mimeType);p.current=a;let o=new Audio(a);f.current=o;let s=[i.provider,i.format,i.latencyMs===void 0?void 0:`${i.latencyMs}ms`,kn(i.audioSize)].filter(Boolean).join(` · `);o.addEventListener(`ended`,()=>l({status:`done`,summary:s}),{once:!0}),o.addEventListener(`error`,()=>l({status:`error`,message:e.tts.test.playFailed}),{once:!0}),await o.play(),l({status:`playing`,summary:s})}catch(e){if(r.signal.aborted)return;h(),l({status:`error`,message:e instanceof Error?e.message:String(e)})}},[T,j,b,h,o,n.provider,e.tts.test.emptyText,e.tts.test.playFailed]);return(0,$.jsxs)(`section`,{className:`rounded-2xl bg-surface-base px-4 py-5 sm:px-5`,children:[(0,$.jsxs)(`div`,{className:`mb-4`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,$.jsx)(ie,{className:`size-4 text-accent`,strokeWidth:1.75}),e.tts.title]}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:e.tts.description})]}),(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsx)(qn,{checked:n.enabled,title:e.tts.enable,description:e.tts.enableDesc,onChange:e=>a({enabled:e})}),n.enabled?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,$.jsxs)(`div`,{className:y(`flex flex-col gap-1.5`,En),children:[(0,$.jsx)(Xn,{children:e.tts.trigger}),(0,$.jsxs)(u,{className:On(),value:n.trigger,onChange:e=>a({trigger:e.target.value}),children:[(0,$.jsx)(d,{value:`off`,children:e.tts.triggerOff}),(0,$.jsx)(d,{value:`inbound`,children:e.tts.triggerInbound}),(0,$.jsx)(d,{value:`tagged`,children:e.tts.triggerTagged}),(0,$.jsx)(d,{value:`always`,children:e.tts.triggerAlways})]}),(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:e.tts.triggerHelp})]}),(0,$.jsxs)(`div`,{className:y(`flex flex-col gap-1.5`,En),children:[(0,$.jsx)(Xn,{children:e.tts.provider}),(0,$.jsx)(u,{className:On(),value:n.provider,onChange:e=>R(e.target.value),children:_.map(t=>(0,$.jsx)(d,{value:t.id,children:Mn(t.id,e)},t.id))}),(0,$.jsxs)(`p`,{className:`text-xs text-fg-subtle`,children:[v?.configured?e.tts.configured:v?.diagnostics.requiresApiKey?`${e.tts.needsKey} · ${v.diagnostics.envKeys?.join(`, `)??e.stt.apiKey}`:e.tts.noKeyNeeded,` · `,v?.description??Pn(n.provider,e)]})]})]}),(0,$.jsxs)(`details`,{className:`rounded-xl bg-surface-panel/80 p-3 shadow-surface`,open:!I||n.provider===`tts-local-cli`,children:[(0,$.jsxs)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg marker:text-fg-muted`,children:[e.tts.advanced.title,(0,$.jsx)(`span`,{className:`ml-2 text-xs font-normal text-fg-muted`,children:e.tts.advanced.description})]}),(0,$.jsx)(`div`,{className:`mt-3`,children:(0,$.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:(0,$.jsx)(Kn,{kind:`tts`,providerId:n.provider,fields:M,providerSlice:b,models:x,voices:k,currentModel:T,currentVoice:j,apiKeyLabels:t,onPatch:L,resetVoiceOnModelChange:!0})})})]}),(0,$.jsxs)(`div`,{className:`rounded-xl bg-surface-panel/80 p-3 shadow-surface`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-start sm:justify-between`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:e.tts.test.title}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:e.tts.test.description})]}),(0,$.jsxs)(`div`,{className:`flex shrink-0 gap-2`,children:[(0,$.jsxs)(P,{type:`button`,variant:`primary`,onClick:()=>void z(),disabled:c.status===`loading`,className:`h-9`,children:[c.status===`loading`?(0,$.jsx)(g,{className:`size-4 animate-spin`}):(0,$.jsx)(se,{className:`size-4`}),c.status===`loading`?e.tts.test.generating:e.tts.test.play]}),(0,$.jsxs)(P,{type:`button`,variant:`secondary`,onClick:()=>{h(),l(e=>e.status===`playing`?{status:`done`,summary:e.summary}:{status:`idle`})},disabled:c.status!==`playing`,className:`h-9`,children:[(0,$.jsx)(Ze,{className:`size-4`}),e.tts.test.stop]})]})]}),(0,$.jsxs)(`details`,{className:`mt-3`,children:[(0,$.jsx)(`summary`,{className:`cursor-pointer text-xs text-fg-muted`,children:e.setup.sampleText}),(0,$.jsx)(`textarea`,{className:y(Dn(),`mt-3 min-h-20 resize-y`),value:o,onChange:e=>s(e.target.value),maxLength:1e3})]}),(0,$.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center justify-between gap-2 text-xs`,children:[(0,$.jsxs)(`span`,{className:`text-fg-subtle`,children:[o.length,`/1000`]}),c.status===`playing`||c.status===`done`?(0,$.jsxs)(`span`,{className:`text-emerald-700 dark:text-emerald-200`,children:[c.status===`playing`?e.tts.test.playing:e.tts.test.ready,` · `,c.summary]}):null,c.status===`error`?(0,$.jsx)(`span`,{className:`text-red-600 dark:text-red-400`,children:c.message}):null]})]})]}):null]})]})}function Kn({kind:e,providerId:t,fields:n,providerSlice:r,models:i,voices:a=[],currentModel:o,currentVoice:s,apiKeyLabels:c,onPatch:l,resetVoiceOnModelChange:f=!1}){return n.map(n=>n.key===`apiKey`?(0,$.jsxs)(`div`,{className:y(`flex flex-col gap-1.5`,En),children:[(0,$.jsx)(Xn,{children:n.label}),(0,$.jsx)(Bt,{kind:e,providerId:t,fieldId:`voice-${e}-${t}-api-key`,value:typeof r.apiKey==`string`?r.apiKey:``,onChange:e=>l({apiKey:e}),labels:c,placeholder:n.placeholder}),n.description?(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.description}):null]},n.key):n.key===`model`&&i.length>0?(0,$.jsxs)(`div`,{className:y(`flex flex-col gap-1.5`,En),children:[(0,$.jsx)(Xn,{children:n.label}),(0,$.jsx)(u,{className:On(),value:o??``,onChange:e=>l({model:e.target.value,...f?{voice:void 0}:{}}),children:i.map(e=>(0,$.jsx)(d,{value:e.id,children:e.name},e.id))})]},n.key):n.key===`voice`&&a.length>0?(0,$.jsxs)(`div`,{className:y(`flex flex-col gap-1.5`,En),children:[(0,$.jsx)(Xn,{children:n.label}),(0,$.jsx)(u,{className:On(),value:s??``,onChange:e=>l({voice:e.target.value}),children:a.map(e=>(0,$.jsx)(d,{value:e.id,children:e.name},e.id))})]},n.key):(0,$.jsx)(Jn,{field:n,value:In(r,n),onChange:e=>l({[n.key]:e}),className:n.type===`textarea`?`sm:col-span-2`:En},n.key))}function qn(e){let t=(0,Z.c)(27),{checked:n,title:r,description:i,onChange:a}=e,o;t[0]!==n||t[1]!==a?(o=()=>a(!n),t[0]=n,t[1]=a,t[2]=o):o=t[2];let s=n?`bg-surface-panel text-fg`:`bg-surface-panel/80 text-fg hover:bg-surface-hover`,c;t[3]===s?c=t[4]:(c=y(`group flex w-full items-center justify-between gap-4 rounded-lg border border-edge px-3 py-3 text-left transition-colors`,W,s),t[3]=s,t[4]=c);let l;t[5]===r?l=t[6]:(l=(0,$.jsx)(`span`,{className:`flex flex-wrap items-center gap-2 text-sm font-semibold text-fg`,children:r}),t[5]=r,t[6]=l);let u;t[7]===i?u=t[8]:(u=(0,$.jsx)(`span`,{className:`mt-1 block text-xs leading-relaxed text-fg-muted`,children:i}),t[7]=i,t[8]=u);let d;t[9]!==l||t[10]!==u?(d=(0,$.jsxs)(`span`,{className:`min-w-0`,children:[l,u]}),t[9]=l,t[10]=u,t[11]=d):d=t[11];let f=n?`border-accent bg-accent`:`border-edge bg-surface-hover group-hover:border-accent/40`,p;t[12]===f?p=t[13]:(p=y(`relative inline-flex h-6 w-11 shrink-0 items-center rounded-full border transition-colors`,f),t[12]=f,t[13]=p);let m=n?`translate-x-5`:`translate-x-0.5`,h;t[14]===m?h=t[15]:(h=y(`size-5 rounded-full bg-white shadow-surface transition-transform`,m),t[14]=m,t[15]=h);let g;t[16]===h?g=t[17]:(g=(0,$.jsx)(`span`,{className:h}),t[16]=h,t[17]=g);let _;t[18]!==g||t[19]!==p?(_=(0,$.jsx)(`span`,{className:p,"aria-hidden":!0,children:g}),t[18]=g,t[19]=p,t[20]=_):_=t[20];let v;return t[21]!==n||t[22]!==o||t[23]!==_||t[24]!==c||t[25]!==d?(v=(0,$.jsxs)(`button`,{type:`button`,role:`switch`,"aria-checked":n,onClick:o,className:c,children:[d,_]}),t[21]=n,t[22]=o,t[23]=_,t[24]=c,t[25]=d,t[26]=v):v=t[26],v}function Jn(e){let t=(0,Z.c)(36),{field:n,value:r,onChange:i,className:a}=e,o=`voice-schema-field-${n.key}`,s=n.description;if(n.type===`boolean`){let e;t[0]===a?e=t[1]:(e=y(`flex items-center justify-between gap-3 rounded-xl bg-surface-hover/50 px-3 py-2.5 dark:bg-surface-hover/35`,a),t[0]=a,t[1]=e);let o;t[2]===n.label?o=t[3]:(o=(0,$.jsx)(`span`,{className:`block text-sm font-medium text-fg`,children:n.label}),t[2]=n.label,t[3]=o);let c;t[4]===s?c=t[5]:(c=s?(0,$.jsx)(`span`,{className:`mt-1 block text-xs text-fg-subtle`,children:s}):null,t[4]=s,t[5]=c);let l;t[6]!==o||t[7]!==c?(l=(0,$.jsxs)(`span`,{children:[o,c]}),t[6]=o,t[7]=c,t[8]=l):l=t[8];let u=!!r,d;t[9]!==n||t[10]!==i?(d=e=>i(Ln(n,e.target.checked)),t[9]=n,t[10]=i,t[11]=d):d=t[11];let f;t[12]!==u||t[13]!==d?(f=(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:u,onChange:d}),t[12]=u,t[13]=d,t[14]=f):f=t[14];let p;return t[15]!==e||t[16]!==l||t[17]!==f?(p=(0,$.jsxs)(`label`,{className:e,children:[l,f]}),t[15]=e,t[16]=l,t[17]=f,t[18]=p):p=t[18],p}let c=typeof r==`boolean`?``:String(r),l;t[19]===a?l=t[20]:(l=y(`flex flex-col gap-1.5`,a),t[19]=a,t[20]=l);let d;t[21]===n.label?d=t[22]:(d=(0,$.jsx)(Xn,{children:n.label}),t[21]=n.label,t[22]=d);let f;t[23]!==a||t[24]!==n||t[25]!==c||t[26]!==o||t[27]!==i?(f=n.type===`select`?(0,$.jsx)(u,{id:o,className:On(),value:c,required:n.required,onChange:e=>i(Ln(n,e.target.value)),children:(n.options??[]).map(Yn)}):n.type===`textarea`?(0,$.jsx)(`textarea`,{id:o,className:y(Dn(),`min-h-24 resize-y`),value:c,required:n.required,placeholder:n.placeholder,onChange:e=>i(Ln(n,e.target.value))}):n.type===`password`?(0,$.jsx)(dt,{id:o,className:a,value:c,onChange:e=>i(Ln(n,e)),placeholder:n.placeholder,labels:ht}):(0,$.jsx)(`input`,{id:o,className:Dn(),type:n.type===`number`?`number`:`text`,autoComplete:n.secret?`new-password`:`off`,spellCheck:!1,value:c,required:n.required,placeholder:n.placeholder,min:n.min,max:n.max,step:n.step,onChange:e=>i(Ln(n,e.target.value))}),t[23]=a,t[24]=n,t[25]=c,t[26]=o,t[27]=i,t[28]=f):f=t[28];let p;t[29]===s?p=t[30]:(p=s?(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:s}):null,t[29]=s,t[30]=p);let m;return t[31]!==l||t[32]!==d||t[33]!==f||t[34]!==p?(m=(0,$.jsxs)(`div`,{className:l,children:[d,f,p]}),t[31]=l,t[32]=d,t[33]=f,t[34]=p,t[35]=m):m=t[35],m}function Yn(e){return(0,$.jsx)(d,{value:e.id,children:e.name},e.id)}function Xn(e){let t=(0,Z.c)(2),{children:n}=e,r;return t[0]===n?r=t[1]:(r=(0,$.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n}),t[0]=n,t[1]=r),r}function Zn(e){let t=e&&typeof e==`object`&&`tools`in e?e.tools:void 0,n=t&&typeof t==`object`&&`web`in t?t.web:void 0,r=n&&typeof n==`object`&&`region`in n?n.region:void 0,i=r===`cn`||r===`global`?r:`auto`,a=n&&typeof n==`object`&&`search`in n?n.search:void 0,o=a&&typeof a==`object`?a:{},s=typeof o.maxResults==`number`&&Number.isFinite(o.maxResults)?Math.floor(o.maxResults):5,c=n&&typeof n==`object`&&`blocklist`in n?n.blocklist:void 0,l=c&&typeof c==`object`?c:{},u=Array.isArray(l.domains)?l.domains.filter(e=>typeof e==`string`&&e.trim().length>0):[],d=o.providers;return{regionMode:i,maxResults:s,providers:Array.isArray(d)?d.map(e=>{let t=e&&typeof e==`object`?e:{},n=t.type;return{type:n===`brave`||n===`tavily`||n===`bing`||n===`searxng`?n:`brave`,apiKey:typeof t.apiKey==`string`?t.apiKey:``,url:typeof t.url==`string`?t.url:``,disabled:t.disabled===!0}}):[],blocklistEnabled:l.enabled===!0,blocklistDomains:u}}async function Qn(e){let t=e.regionMode===`auto`?`auto`:e.regionMode===`cn`?`cn`:`global`,n={maxResults:e.maxResults,providers:e.providers.map(e=>{let t={type:e.type,apiKey:e.apiKey};return e.type===`searxng`&&e.url.trim()&&(t.url=e.url.trim().replace(/\/+$/,``)),e.disabled&&(t.disabled=!0),t})};await b(w(`/api/config`),{method:`PATCH`,body:JSON.stringify({tools:{web:{region:t,search:n,blocklist:{enabled:e.blocklistEnabled,domains:e.blocklistDomains}}}})}),F()}async function $n(e){let t=await b(w(`/api/tools/web/reveal-search-api-key`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({index:e})});if(!t.ok||!t.payload)throw Error(t.error?.message??`Reveal failed`);return t.payload}function er(e){let t=(0,Z.c)(8),{label:n,description:r,children:i}=e,a;t[0]===n?a=t[1]:(a=(0,$.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n}),t[0]=n,t[1]=a);let o;t[2]===r?o=t[3]:(o=(0,$.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-subtle`,children:r}),t[2]=r,t[3]=o);let s;return t[4]!==i||t[5]!==a||t[6]!==o?(s=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[a,i,o]}),t[4]=i,t[5]=a,t[6]=o,t[7]=s):s=t[7],s}function tr(){return y(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,W,`dark:border-edge`)}function nr(){return y(Ye,me)}var rr=[`brave`,`tavily`,`bing`,`searxng`];function ir(){return{type:`brave`,apiKey:``,url:``,disabled:!1}}var ar=H();function or(){let e=T(C(e=>e.language)),t=e.webSearchSettings,n=e.logs,r=!!x(e=>e.conversationId),[i,a]=(0,Q.useReducer)(ar,{form:null,baseline:null}),o=i.form,s=i.baseline,c=(0,Q.useRef)(!1),l=(0,Q.useRef)(o);l.current=o;let f=(0,Q.useRef)(null),{data:p,error:m,isLoading:h,mutate:g}=I(r);Be({enabled:r,parsed:(0,Q.useMemo)(()=>p?.payload?.config===void 0?null:Zn(p.payload.config),[p]),dirty:c.current,trackedParsedRef:f,dispatch:a,onResetDirty:()=>{c.current=!1}});let v=!!(r&&h&&p===void 0&&!m),b=m instanceof Error?m.message:m?String(m):null,S=(0,Q.useMemo)(()=>!o||!s?!1:JSON.stringify(o)!==JSON.stringify(s),[o,s]),w=(0,Q.useCallback)(e=>{c.current=!0,a({type:`patch`,patch:e})},[]),E=Et({value:o,dirty:S,onSave:(0,Q.useCallback)(async e=>{try{await Qn(e),a({type:`saved`,value:e}),c.current=!!(l.current&&JSON.stringify(l.current)!==JSON.stringify(e))}catch(e){throw Error(e instanceof Error?e.message:t.saveError)}},[t.saveError])});return r?v?(0,$.jsx)(wt,{rows:3}):o?(0,$.jsxs)(`div`,{className:`flex flex-col gap-4`,onBlurCapture:E.onBlurCapture,children:[E.error?(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:E.error}):null,(0,$.jsxs)(Ct,{children:[(0,$.jsx)(St,{icon:ut,title:t.sectionRegion,trailing:(0,$.jsx)(Tt,{status:E.status,error:E.error})}),(0,$.jsx)(`div`,{className:`flex max-w-md flex-col gap-4`,children:(0,$.jsx)(er,{label:t.regionLabel,children:(0,$.jsxs)(u,{className:nr(),value:o.regionMode,onChange:e=>w({regionMode:e.target.value}),children:[(0,$.jsx)(d,{value:`auto`,children:t.regionAuto}),(0,$.jsx)(d,{value:`cn`,children:t.regionCn}),(0,$.jsx)(d,{value:`global`,children:t.regionGlobal})]})})})]}),(0,$.jsx)(Ht,{children:(0,$.jsxs)(Ct,{children:[(0,$.jsx)(St,{icon:ue,title:t.sectionBlocklist}),(0,$.jsxs)(`div`,{className:`flex max-w-xl flex-col gap-4`,children:[(0,$.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 text-sm text-fg`,children:[(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox mt-0.5`,checked:o.blocklistEnabled,onChange:e=>w({blocklistEnabled:e.target.checked})}),(0,$.jsxs)(`span`,{children:[(0,$.jsx)(`span`,{className:`font-medium`,children:t.blocklistEnabled}),(0,$.jsx)(`span`,{className:`mt-0.5 block text-xs text-fg-subtle`,children:t.blocklistEnabledDesc})]})]}),(0,$.jsx)(er,{label:t.blocklistDomains,description:t.blocklistDomainsDesc,children:(0,$.jsx)(`textarea`,{className:y(tr(),`min-h-[6rem] font-mono text-xs`),value:o.blocklistDomains.join(`
8
+ `),placeholder:t.blocklistDomainsPlaceholder,disabled:!o.blocklistEnabled,onChange:e=>{w({blocklistDomains:e.target.value.split(/\r?\n/).flatMap(e=>{let t=e.trim().toLowerCase();return t?[t]:[]})})}})})]})]})}),(0,$.jsxs)(Ct,{children:[(0,$.jsx)(St,{icon:ut,title:t.sectionSearch}),(0,$.jsxs)(`div`,{className:`flex max-w-xl flex-col gap-6`,children:[(0,$.jsx)(er,{label:t.maxResultsLabel,children:(0,$.jsx)(`input`,{type:`number`,min:1,max:50,className:tr(),value:o.maxResults,onChange:e=>w({maxResults:Math.max(1,Math.min(50,Number(e.target.value)||5))})})}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,$.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:t.providersTitle}),o.providers.map((n,r)=>(0,$.jsx)(sr,{row:n,providerIndex:r,labels:t,secretLabels:ye(e.providersSettings),onChange:e=>{let t=[...o.providers];t[r]=e,w({providers:t})},onRemove:()=>{w({providers:o.providers.filter((e,t)=>t!==r)})}},`${n.type}:${n.url}:${n.apiKey}:${n.disabled}`)),(0,$.jsxs)(P,{type:`button`,variant:`secondary`,className:`w-fit gap-1.5 text-sm`,onClick:()=>w({providers:[...o.providers,ir()]}),children:[(0,$.jsx)(_,{className:`size-4`}),t.addProvider]})]})]})]})]}):(0,$.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:b??t.loadError}),(0,$.jsx)(P,{type:`button`,variant:`secondary`,onClick:()=>void g(),children:n.refresh})]}):(0,$.jsx)(`div`,{className:`flex flex-col gap-3`,children:(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.needToken})})}function sr(e){let t=(0,Z.c)(54),{row:n,providerIndex:r,labels:i,secretLabels:a,onChange:o,onRemove:s}=e,c;t[0]===r?c=t[1]:(c=()=>$n(r).then(cr),t[0]=r,t[1]=c);let l=c,f;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(f=y(nr(),`min-w-[8rem]`),t[2]=f):f=t[2];let p=n.type,m;t[3]!==o||t[4]!==n?(m=e=>o({...n,type:e.target.value,url:e.target.value===`searxng`?n.url:``}),t[3]=o,t[4]=n,t[5]=m):m=t[5];let h;t[6]===i.providerTypes?h=t[7]:(h=rr.map(e=>(0,$.jsx)(d,{value:e,children:i.providerTypes[e]},e)),t[6]=i.providerTypes,t[7]=h);let g;t[8]!==n.type||t[9]!==m||t[10]!==h?(g=(0,$.jsx)(u,{className:f,value:p,onChange:m,children:h}),t[8]=n.type,t[9]=m,t[10]=h,t[11]=g):g=t[11];let _;t[12]!==o||t[13]!==n?(_=e=>o({...n,disabled:e.target.checked}),t[12]=o,t[13]=n,t[14]=_):_=t[14];let v;t[15]!==n.disabled||t[16]!==_?(v=(0,$.jsx)(`input`,{type:`checkbox`,className:`size-3.5 rounded border-edge`,checked:n.disabled,onChange:_}),t[15]=n.disabled,t[16]=_,t[17]=v):v=t[17];let b;t[18]!==i.disabled||t[19]!==v?(b=(0,$.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-1.5 text-xs text-fg-muted`,children:[v,i.disabled]}),t[18]=i.disabled,t[19]=v,t[20]=b):b=t[20];let x;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(x=(0,$.jsx)(U,{className:`size-4`}),t[21]=x):x=t[21];let S;t[22]===s?S=t[23]:(S=(0,$.jsx)(P,{type:`button`,variant:`ghost`,className:`h-8 px-2 text-fg-muted`,onClick:s,children:x}),t[22]=s,t[23]=S);let C;t[24]!==S||t[25]!==b?(C=(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[b,S]}),t[24]=S,t[25]=b,t[26]=C):C=t[26];let w;t[27]!==C||t[28]!==g?(w=(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[g,C]}),t[27]=C,t[28]=g,t[29]=w):w=t[29];let T;t[30]!==i.urlDesc||t[31]!==i.urlLabel||t[32]!==o||t[33]!==n?(T=n.type===`searxng`?(0,$.jsx)(er,{label:i.urlLabel,description:i.urlDesc,children:(0,$.jsx)(`input`,{type:`url`,className:tr(),value:n.url,placeholder:`http://localhost:8080`,onChange:e=>o({...n,url:e.target.value})})}):null,t[30]=i.urlDesc,t[31]=i.urlLabel,t[32]=o,t[33]=n,t[34]=T):T=t[34];let E;t[35]!==o||t[36]!==n?(E=e=>o({...n,apiKey:e}),t[35]=o,t[36]=n,t[37]=E):E=t[37];let D;t[38]!==i.keyPlaceholder||t[39]!==i.keyPlaceholderMasked||t[40]!==i.saveError||t[41]!==l||t[42]!==n.apiKey||t[43]!==a||t[44]!==E?(D=(0,$.jsx)(dt,{value:n.apiKey,onChange:E,placeholder:i.keyPlaceholder,labels:a,reveal:l,loadFailedLabel:i.saveError,notInConfigFile:i.keyPlaceholderMasked}),t[38]=i.keyPlaceholder,t[39]=i.keyPlaceholderMasked,t[40]=i.saveError,t[41]=l,t[42]=n.apiKey,t[43]=a,t[44]=E,t[45]=D):D=t[45];let O;t[46]!==i.apiKeyDesc||t[47]!==i.apiKeyLabel||t[48]!==D?(O=(0,$.jsx)(er,{label:i.apiKeyLabel,description:i.apiKeyDesc,children:D}),t[46]=i.apiKeyDesc,t[47]=i.apiKeyLabel,t[48]=D,t[49]=O):O=t[49];let k;return t[50]!==w||t[51]!==T||t[52]!==O?(k=(0,$.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-xl bg-surface-panel/70 p-4 shadow-surface`,children:[w,T,O]}),t[50]=w,t[51]=T,t[52]=O,t[53]=k):k=t[53],k}function cr(e){return e.apiKey??null}var lr=[`common`,`domestic`,`specialty`,`enterprise`,`oauth`,`extension`];function ur(e){let t=new Map;for(let e of lr)t.set(e,[]);for(let n of e){let e=n.category||`specialty`,r=t.get(e)??[];r.push(n),t.set(e,r)}return t}var dr=`xopc-cloud`;function fr(e){let t=(0,Z.c)(22),{open:n,onOpenChange:r,builtinRows:i,customConfig:a,labels:o,language:s,onSaved:c}=e,l;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(l={type:`pick`},t[0]=l):l=t[0];let[u,d]=(0,Q.useState)(l),[f,p]=(0,Q.useState)(``),m;t[1]===r?m=t[2]:(m=e=>{e||window.setTimeout(()=>{d({type:`pick`}),p(``)},200),r(e)},t[1]=r,t[2]=m);let h=m,g;t[3]!==h||t[4]!==c?(g=()=>{c(),h(!1)},t[3]=h,t[4]=c,t[5]=g):g=t[5];let _=g,v;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,$.jsx)(E,{className:y(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,z)}),t[6]=v):v=t[6];let b;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(b=y(`fixed left-1/2 top-1/2 flex max-h-[85vh] w-full max-w-lg -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-2xl border border-edge-subtle bg-surface-base shadow-xl`,R),t[7]=b):b=t[7];let x;t[8]!==i||t[9]!==a||t[10]!==_||t[11]!==o||t[12]!==s||t[13]!==f||t[14]!==u.presetKey||t[15]!==u.providerId||t[16]!==u.type?(x=(0,$.jsxs)(k,{children:[v,(0,$.jsx)(A,{className:b,children:u.type===`pick`?(0,$.jsx)(mr,{builtinRows:i,searchQuery:f,onSearchChange:p,labels:o,onPickBuiltin:e=>{let t=Ue(e);d(t?{type:`custom`,presetKey:t}:{type:`builtin`,providerId:e})},onPickCustom:()=>d({type:`custom`})}):u.type===`builtin`?(0,$.jsx)(vr,{providerId:u.providerId,builtinRows:i,labels:o,language:s,onBack:()=>d({type:`pick`}),onSaved:_}):(0,$.jsx)(xr,{initialPresetKey:u.presetKey,customConfig:a,labels:o,language:s,onBack:()=>d({type:`pick`}),onSaved:_})})]}),t[8]=i,t[9]=a,t[10]=_,t[11]=o,t[12]=s,t[13]=f,t[14]=u.presetKey,t[15]=u.providerId,t[16]=u.type,t[17]=x):x=t[17];let S;return t[18]!==h||t[19]!==n||t[20]!==x?(S=(0,$.jsx)(M,{open:n,onOpenChange:h,children:x}),t[18]=h,t[19]=n,t[20]=x,t[21]=S):S=t[21],S}function pr(e){let t=(0,Z.c)(4),{label:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=y(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,ct.press),t[0]=r):r=t[0];let i;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,$.jsx)(v,{className:`size-4`,"aria-hidden":!0}),t[1]=i):i=t[1];let a;return t[2]===n?a=t[3]:(a=(0,$.jsx)(O,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:r,"aria-label":n,children:i})}),t[2]=n,t[3]=a),a}function mr(e){let t=(0,Z.c)(49),{builtinRows:n,searchQuery:r,onSearchChange:i,labels:a,onPickBuiltin:o,onPickCustom:s}=e,c;t[0]===r?c=t[1]:(c=r.trim().toLowerCase(),t[0]=r,t[1]=c);let l=c,u;bb0:{if(!l){u=n;break bb0}let e;if(t[2]!==n||t[3]!==l){let r;t[5]===l?r=t[6]:(r=e=>{let t=Ae[e.id]?.aliases??[];return e.id.toLowerCase().includes(l)||e.name.toLowerCase().includes(l)||t.some(e=>e.toLowerCase().includes(l))},t[5]=l,t[6]=r),e=n.filter(r),t[2]=n,t[3]=l,t[4]=e}else e=t[4];u=e}let d=u,f;t[7]===d?f=t[8]:(f=d.find(gr),t[7]=d,t[8]=f);let p=f,m;t[9]===d?m=t[10]:(m=ur(d.filter(hr)),t[9]=d,t[10]=m);let g=m,_;t[11]===a.step1Title?_=t[12]:(_=(0,$.jsx)(j,{className:`min-w-0 flex-1 text-base font-semibold text-fg`,children:a.step1Title}),t[11]=a.step1Title,t[12]=_);let v;t[13]===a.close?v=t[14]:(v=(0,$.jsx)(pr,{label:a.close}),t[13]=a.close,t[14]=v);let b;t[15]!==_||t[16]!==v?(b=(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2 border-b border-edge-subtle px-5 py-4`,children:[_,v]}),t[15]=_,t[16]=v,t[17]=b):b=t[17];let x;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(x=(0,$.jsx)(ut,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-fg-subtle`,strokeWidth:1.75,"aria-hidden":!0}),t[18]=x):x=t[18];let S;t[19]===i?S=t[20]:(S=e=>i(e.target.value),t[19]=i,t[20]=S);let C=a.searchPlaceholder,w;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(w=y(`w-full rounded-lg border border-edge bg-surface-panel py-2 pl-10 pr-3 text-sm text-fg placeholder:text-fg-subtle`,W),t[21]=w):w=t[21];let T;t[22]!==a.searchPlaceholder||t[23]!==r||t[24]!==S?(T=(0,$.jsx)(`div`,{className:`px-5 pt-3`,children:(0,$.jsxs)(`div`,{className:`relative`,children:[x,(0,$.jsx)(`input`,{type:`search`,value:r,onChange:S,placeholder:C,autoComplete:`off`,className:w})]})}),t[22]=a.searchPlaceholder,t[23]=r,t[24]=S,t[25]=T):T=t[25];let E;t[26]!==a.recommended||t[27]!==o||t[28]!==p?(E=p?(0,$.jsxs)(`div`,{className:`mb-2`,children:[(0,$.jsx)(`p`,{className:`mb-1 px-1 text-[11px] font-semibold uppercase tracking-wide text-fg-subtle`,children:a.recommended}),(0,$.jsx)(_r,{row:p,onPick:o})]}):null,t[26]=a.recommended,t[27]=o,t[28]=p,t[29]=E):E=t[29];let D;t[30]!==a.addCustom||t[31]!==a.customDescription||t[32]!==s||t[33]!==l?(D=l?null:(0,$.jsxs)(`button`,{type:`button`,onClick:s,className:y(`mb-3 flex w-full items-center gap-3 rounded-xl border border-dashed border-edge-subtle bg-surface-panel/40 px-4 py-3 text-left transition-colors`,`hover:bg-surface-hover/60 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,ct.press),children:[(0,$.jsx)(h,{className:`size-5 shrink-0 text-fg-subtle`,strokeWidth:1.75,"aria-hidden":!0}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:a.addCustom}),(0,$.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:a.customDescription})]}),(0,$.jsx)(xe,{className:`size-4 shrink-0 text-fg-subtle`,"aria-hidden":!0})]}),t[30]=a.addCustom,t[31]=a.customDescription,t[32]=s,t[33]=l,t[34]=D):D=t[34];let O;t[35]!==d.length||t[36]!==g||t[37]!==a.categories||t[38]!==a.noResults||t[39]!==o?(O=d.length===0?(0,$.jsx)(`p`,{className:`py-6 text-center text-sm text-fg-muted`,children:a.noResults}):(0,$.jsx)(`div`,{className:`flex flex-col gap-2`,children:lr.map(e=>{let t=g.get(e)??[];return t.length===0?null:(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`p`,{className:`mb-1 px-1 text-[11px] font-semibold uppercase tracking-wide text-fg-subtle`,children:a.categories[e]??e}),(0,$.jsx)(`div`,{className:`flex flex-col gap-0.5`,children:t.map(e=>(0,$.jsx)(_r,{row:e,onPick:o},e.id))})]},e)})}),t[35]=d.length,t[36]=g,t[37]=a.categories,t[38]=a.noResults,t[39]=o,t[40]=O):O=t[40];let k;t[41]!==E||t[42]!==D||t[43]!==O?(k=(0,$.jsxs)(`div`,{className:`flex-1 overflow-y-auto px-5 py-3`,children:[E,D,O]}),t[41]=E,t[42]=D,t[43]=O,t[44]=k):k=t[44];let A;return t[45]!==T||t[46]!==k||t[47]!==b?(A=(0,$.jsxs)($.Fragment,{children:[b,T,k]}),t[45]=T,t[46]=k,t[47]=b,t[48]=A):A=t[48],A}function hr(e){return e.id!==dr}function gr(e){return e.id===dr}function _r(e){let t=(0,Z.c)(12),{row:n,onPick:r}=e,i;t[0]!==r||t[1]!==n.id?(i=()=>r(n.id),t[0]=r,t[1]=n.id,t[2]=i):i=t[2];let a;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(a=y(`flex w-full items-center justify-between gap-2 rounded-lg px-3 py-2.5 text-left transition-colors`,`hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,ct.press),t[3]=a):a=t[3];let o;t[4]===n.name?o=t[5]:(o=(0,$.jsx)(`span`,{className:`truncate text-sm text-fg`,children:n.name}),t[4]=n.name,t[5]=o);let s;t[6]===n.configured?s=t[7]:(s=n.configured?(0,$.jsx)(p,{className:`size-3.5 shrink-0 text-emerald-600 dark:text-emerald-400`,"aria-hidden":!0}):null,t[6]=n.configured,t[7]=s);let c;return t[8]!==i||t[9]!==o||t[10]!==s?(c=(0,$.jsxs)(`button`,{type:`button`,onClick:i,className:a,children:[o,s]}),t[8]=i,t[9]=o,t[10]=s,t[11]=c):c=t[11],c}function vr({providerId:e,builtinRows:t,labels:n,language:r,onBack:i,onSaved:a}){let o=t.find(t=>t.id===e),s=Ae[e],[c,l]=(0,Q.useState)(``),[u,d]=(0,Q.useState)(!1),[f,m]=(0,Q.useState)(null),[h,_]=(0,Q.useState)(!1),v=(0,Q.useRef)(null),b=T(r).providersSettings,x=ye(b),S=(0,Q.useMemo)(()=>ke(e,r),[e,r]),C=o?.supportsApiKey!==!1,w=o?.supportsOAuth===!0,[E,D]=(0,Q.useState)(null),[O,k]=(0,Q.useState)(null),[A,M]=(0,Q.useState)(`idle`),[N,F]=(0,Q.useState)(null),[I,L]=(0,Q.useState)(null),[R,z]=(0,Q.useState)(null),[B,V]=(0,Q.useState)(``),H=(0,Q.useRef)(null),U=(0,Q.useRef)(null),G=A===`waiting`||A===`waiting_code`;(0,Q.useEffect)(()=>{if(!E||!G)return;let t=window.setInterval(()=>{(async()=>{try{let n=await ee(E);n.status===`waiting_auth`||n.status===`waiting_code`?(M(n.status===`waiting_code`?`waiting_code`:`waiting`),k(n.message??null),F(n.authUrl??null),L(n.instructions??null),z(n.deviceCode??null),n.authUrl&&n.authUrl!==U.current&&(U.current=n.authUrl,K(n.authUrl,H.current).catch(()=>{}))):n.status===`completed`?(window.clearInterval(t),vt(H.current),H.current=null,e===`xopc-cloud`&&await le(),M(`success`),k(n.message??b.saved),window.setTimeout(a,600)):(n.status===`failed`||n.status===`cancelled`)&&(window.clearInterval(t),vt(H.current),H.current=null,M(`error`),k(n.error??n.message??b.revokeFailed))}catch{}})()},1e3);return()=>window.clearInterval(t)},[E,G,a,e,b.revokeFailed,b.saved]),(0,Q.useEffect)(()=>()=>{E&&be(E).catch(()=>{})},[E]),(0,Q.useEffect)(()=>()=>{vt(H.current),H.current=null},[]);let q=async()=>{vt(H.current),H.current=Te(),U.current=null,M(`waiting`),k(b.oauthStarting),F(null),L(null),z(null),m(null);try{D((await we(e)).sessionId)}catch(e){vt(H.current),H.current=null,M(`error`),k(e instanceof Error?e.message:b.revokeFailed)}},te=async()=>{if(E){try{await gt(E)}catch{}vt(H.current),H.current=null,U.current=null,M(`idle`),k(null),D(null),F(null),L(null),z(null)}},re=async()=>{if(!(!E||!B.trim()))try{await ne(E,B.trim()),V(``),k(b.oauthProcessingCode)}catch(e){M(`error`),k(e instanceof Error?e.message:b.revokeFailed)}},J=async()=>{let t=c.trim();if(!(!t||!C)){d(!0),m(null);try{await Ke({[e]:t}),_(!0),window.setTimeout(a,600)}catch(e){m(e instanceof Error?e.message:n.saveError)}finally{d(!1)}}};return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-edge-subtle px-5 py-4`,children:[(0,$.jsx)(`button`,{type:`button`,onClick:i,className:y(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,ct.press),"aria-label":n.back,children:(0,$.jsx)(xe,{className:`size-4 rotate-180`,"aria-hidden":!0})}),(0,$.jsx)(j,{className:`min-w-0 flex-1 text-base font-semibold text-fg`,children:o?.name??e}),(0,$.jsx)(pr,{label:n.close})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-4 px-5 py-4`,children:[s?.description?(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:s.description}):null,C?(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(`label`,{htmlFor:`builtin-api-key`,className:`text-sm font-medium text-fg`,children:n.apiKeyLabel}),(0,$.jsx)(dt,{id:`builtin-api-key`,value:c,onChange:l,placeholder:n.apiKeyPlaceholder,labels:x,inputRef:v,onKeyDown:e=>{e.key===`Enter`&&J()}})]}):null,w?(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-lg border border-edge-subtle bg-surface-panel/60 p-3`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:b.oauth}),(0,$.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:b.oauthHint})]}),(0,$.jsxs)(P,{type:`button`,variant:`primary`,className:`gap-1.5`,disabled:G,onClick:()=>void q(),children:[G?(0,$.jsx)(g,{className:`size-3.5 animate-spin`,"aria-hidden":!0}):null,b.oauth]})]}),O?(0,$.jsx)(`p`,{className:y(`text-xs`,A===`error`?`text-red-600 dark:text-red-400`:`text-fg-muted`),children:O}):null,A===`waiting`||A===`waiting_code`?(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[N?(0,$.jsxs)(`a`,{href:N,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1.5 rounded-md bg-accent px-3 py-2 text-sm font-medium text-white hover:bg-accent-hover`,children:[b.openAuthPage,(0,$.jsx)(`span`,{className:`size-3`,"aria-hidden":!0,children:`↗`})]}):null,(0,$.jsx)(P,{type:`button`,variant:`secondary`,onClick:()=>void te(),children:b.cancelOAuth})]}):null,I?(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:I}):null,R?(0,$.jsxs)(`div`,{className:`rounded-lg border border-edge-subtle bg-surface-panel px-3 py-2`,children:[(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:b.deviceCodeLabel}),(0,$.jsx)(`code`,{className:`mt-1 block select-all font-mono text-lg font-semibold tracking-widest text-fg`,children:R}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:b.deviceCodeHint})]}):null,A===`waiting_code`?(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row`,children:[(0,$.jsx)(`input`,{type:`text`,value:B,onChange:e=>V(e.target.value),onKeyDown:e=>e.key===`Enter`&&void re(),placeholder:b.pasteRedirectUrl,className:y(`min-w-0 flex-1 rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg placeholder:text-fg-subtle`,W)}),(0,$.jsx)(P,{type:`button`,variant:`primary`,onClick:()=>void re(),children:b.submitCode})]}):null]}):null,S.length>0&&C?(0,$.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:S.map(({kind:e,href:t})=>(0,$.jsxs)(`a`,{href:t,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 text-xs text-accent hover:underline`,children:[je(e,n),(0,$.jsx)(`span`,{className:`size-3`,"aria-hidden":!0,children:`↗`})]},e))}):null,f?(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:f}):null,(0,$.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[(0,$.jsx)(P,{type:`button`,variant:`secondary`,onClick:i,children:n.cancel}),C?(0,$.jsx)(P,{type:`button`,variant:`primary`,disabled:!c.trim()||u||h,onClick:()=>void J(),children:h?(0,$.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(p,{className:`size-3.5`,"aria-hidden":!0}),n.saved]}):u?(0,$.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(g,{className:`size-3.5 animate-spin`,"aria-hidden":!0}),n.saving]}):n.save}):null]})]})]})}function yr(e=`custom`){if(e!==`custom`&&Ve[e]){let t=Ve[e].config;return{preset:e,providerId:lt(e),baseUrl:t.baseUrl??``,api:t.api??`openai-completions`,apiKey:t.apiKey??``,modelIds:t.models?.map(e=>e.id)??[``],error:null}}return{preset:`custom`,providerId:``,baseUrl:``,api:`openai-completions`,apiKey:``,modelIds:[``],error:null}}function br(e,t){switch(t.type){case`applyPreset`:return t.key===`custom`?{...e,preset:`custom`,error:null}:Ve[t.key]?yr(t.key):e;case`setProviderId`:return{...e,providerId:t.value};case`setBaseUrl`:return{...e,baseUrl:t.value};case`setApi`:return{...e,api:t.value};case`setApiKey`:return{...e,apiKey:t.value};case`addModelSlot`:return{...e,modelIds:[...e.modelIds,``]};case`updateModelId`:return{...e,modelIds:e.modelIds.map((e,n)=>n===t.index?t.value:e)};case`setModelIds`:return{...e,modelIds:t.values.length>0?t.values:[``]};case`removeModelSlot`:return{...e,modelIds:e.modelIds.filter((e,n)=>n!==t.index)};case`setError`:return{...e,error:t.value}}}function xr({initialPresetKey:e,customConfig:t,labels:n,language:r,onBack:i,onSaved:a}){let[o,s]=(0,Q.useReducer)(br,void 0,()=>yr(e)),[c,l]=(0,Q.useState)(!1),[f,p]=(0,Q.useState)(!1),m=ye(T(r).providersSettings),{preset:h,providerId:b,baseUrl:x,api:S,apiKey:C,modelIds:w,error:E}=o,D=async()=>{let e=b.trim(),r=x.trim();if(!e){s({type:`setError`,value:n.providerIdRequired});return}if(!r){s({type:`setError`,value:n.baseUrlRequired});return}let i=w.map(e=>e.trim()).filter(Boolean);l(!0),s({type:`setError`,value:null});try{let n=t?.providers??{},o=h===`custom`?void 0:Ve[h]?.config,s={...o??{},baseUrl:r,api:S,apiKey:C.trim()||void 0,models:i.map(e=>o?.models?.find(t=>t.id===e)??{id:e})};await ot({providers:{...n,[e]:s}}),a()}catch(e){s({type:`setError`,value:e instanceof Error?e.message:n.saveError})}finally{l(!1)}},O=async()=>{let e=b.trim()||lt(h)||`custom`,t=x.trim();if(!t){s({type:`setError`,value:n.baseUrlRequired});return}p(!0),s({type:`setError`,value:null});try{let r=h===`custom`?void 0:Ve[h]?.config,i=(await it({providerId:e,baseUrl:t,apiKey:C.trim()||void 0,api:S,headers:r?.headers})).map(e=>e.id).filter(e=>e&&!e.includes(`/`));s({type:`setModelIds`,values:i}),i.length===0&&s({type:`setError`,value:n.discoverModelsHint})}catch(e){s({type:`setError`,value:e instanceof Error?e.message:n.discoverModelsHint})}finally{p(!1)}},k=b.trim()&&x.trim(),A=(S===`openai-completions`||S===`openai-responses`)&&x.trim();return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-edge-subtle px-5 py-4`,children:[(0,$.jsx)(`button`,{type:`button`,onClick:i,className:y(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,ct.press),"aria-label":n.back,children:(0,$.jsx)(xe,{className:`size-4 rotate-180`,"aria-hidden":!0})}),(0,$.jsx)(j,{className:`min-w-0 flex-1 text-base font-semibold text-fg`,children:n.step2CustomTitle}),(0,$.jsx)(pr,{label:n.close})]}),(0,$.jsxs)(`div`,{className:`flex max-h-[60vh] flex-col gap-4 overflow-y-auto px-5 py-4`,children:[(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.customDescription}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(`label`,{htmlFor:`custom-preset`,className:`text-sm font-medium text-fg`,children:n.presetLabel}),(0,$.jsxs)(u,{id:`custom-preset`,value:h,onChange:e=>s({type:`applyPreset`,key:e.target.value}),className:_t(),children:[(0,$.jsx)(d,{value:`custom`,children:n.presetCustom}),nt.map(e=>(0,$.jsx)(d,{value:e.key,children:e.label},e.key))]})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(`label`,{htmlFor:`custom-provider-id`,className:`text-sm font-medium text-fg`,children:n.providerIdLabel}),(0,$.jsx)(`input`,{id:`custom-provider-id`,type:`text`,autoComplete:`off`,value:b,onChange:e=>s({type:`setProviderId`,value:e.target.value}),placeholder:n.providerIdPlaceholder,className:y(`rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg placeholder:text-fg-subtle`,W)})]}),(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(`label`,{htmlFor:`custom-base-url`,className:`text-sm font-medium text-fg`,children:n.baseUrlLabel}),(0,$.jsx)(`input`,{id:`custom-base-url`,type:`url`,autoComplete:`off`,value:x,onChange:e=>s({type:`setBaseUrl`,value:e.target.value}),placeholder:n.baseUrlPlaceholder,className:y(`rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg placeholder:text-fg-subtle`,W)})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(`label`,{htmlFor:`custom-api-type`,className:`text-sm font-medium text-fg`,children:n.apiTypeLabel}),(0,$.jsx)(u,{id:`custom-api-type`,value:S,onChange:e=>s({type:`setApi`,value:e.target.value}),className:_t(),children:Ie.map(e=>(0,$.jsx)(d,{value:e.value,children:e.label},e.value))})]})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(`label`,{htmlFor:`custom-api-key`,className:`text-sm font-medium text-fg`,children:n.apiKeyLabel}),(0,$.jsx)(dt,{id:`custom-api-key`,value:C,onChange:e=>s({type:`setApiKey`,value:e}),placeholder:n.apiKeyPlaceholder,labels:m})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-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:n.modelIdLabel}),(0,$.jsxs)(P,{type:`button`,variant:`secondary`,className:`gap-1.5`,disabled:!A||f,onClick:()=>void O(),children:[f?(0,$.jsx)(g,{className:`size-3.5 animate-spin`,"aria-hidden":!0}):(0,$.jsx)(ut,{className:`size-3.5`,"aria-hidden":!0}),f?n.discoveringModels:n.discoverModels]})]}),w.map((e,t)=>(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`input`,{type:`text`,autoComplete:`off`,value:e,onChange:e=>s({type:`updateModelId`,index:t,value:e.target.value}),placeholder:n.modelIdPlaceholder,className:y(`flex-1 rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg placeholder:text-fg-subtle`,W)}),w.length>1?(0,$.jsx)(`button`,{type:`button`,onClick:()=>s({type:`removeModelSlot`,index:t}),className:y(`rounded-lg p-1.5 text-fg-subtle hover:bg-surface-hover hover:text-fg`,ct.press),children:(0,$.jsx)(v,{className:`size-3.5`,"aria-hidden":!0})}):null]},e||`model-slot-${t}`)),(0,$.jsxs)(P,{type:`button`,variant:`ghost`,className:`w-fit gap-1.5 text-fg-muted`,onClick:()=>s({type:`addModelSlot`}),children:[(0,$.jsx)(_,{className:`size-3.5`,"aria-hidden":!0}),n.addModel]})]}),E?(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:E}):null]}),(0,$.jsxs)(`div`,{className:`flex items-center justify-end gap-2 border-t border-edge-subtle px-5 py-3`,children:[(0,$.jsx)(P,{type:`button`,variant:`secondary`,onClick:i,children:n.cancel}),(0,$.jsx)(P,{type:`button`,variant:`primary`,disabled:!k||c,onClick:()=>void D(),children:c?(0,$.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(g,{className:`size-3.5 animate-spin`,"aria-hidden":!0}),n.saving]}):n.save})]})]})}function Sr(){let e=(0,Z.c)(29),t=!!x(Or),{data:n,isLoading:r}=I(t),i;e[0]===t?i=e[1]:(i=t?w(`/api/providers/meta`):null,e[0]=t,e[1]=i);let a;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(a={revalidateOnFocus:!1},e[2]=a):a=e[2];let{data:o,isLoading:s}=N(i,Dr,a),c;e[3]===Symbol.for(`react.memo_cache_sentinel`)?(c={revalidateOnFocus:!1},e[3]=c):c=e[3];let{data:l,isLoading:u}=N(t?V:null,Er,c),d;e[4]===l?d=e[5]:(d=l===void 0?[]:l,e[4]=l,e[5]=d);let f=d,p;e[6]===Symbol.for(`react.memo_cache_sentinel`)?(p={revalidateOnFocus:!1},e[6]=p):p=e[6];let{data:m}=N(t?J:null,Tr,p),h;bb0:{if(!o||n===void 0){let t;e[7]===Symbol.for(`react.memo_cache_sentinel`)?(t=[],e[7]=t):t=e[7],h=t;break bb0}let t;e[8]!==n?.payload?.config||e[9]!==o||e[10]!==f?(t=G(o,de(n?.payload?.config),f),e[8]=n?.payload?.config,e[9]=o,e[10]=f,e[11]=t):t=e[11],h=t}let g=h,_;bb1:{if(!m){_=null;break bb1}let t;e[12]===m.config?t=e[13]:(t=Qe(m.config),e[12]=m.config,e[13]=t),_=t}let v=_,y;if(e[14]!==g||e[15]!==v||e[16]!==o||e[17]!==f){y=[];let t=new Set((o??[]).filter(wr).map(Cr)),n;e[19]===v?n=e[20]:(n=new Set(v?Object.keys(v.providers):[]),e[19]=v,e[20]=n);let r=n;for(let e of g){if(!t.has(e.id))continue;let n=r.has(e.id),i=n?v.providers[e.id]?.models?.length??0:f.filter(t=>t.provider===e.id).length;y.push({id:e.id,name:e.name,configured:!0,isCustom:n,modelCount:i})}if(v){let t;e[21]===v.providers?t=e[22]:(t=Object.entries(v.providers),e[21]=v.providers,e[22]=t);for(let[e,n]of t)y.some(t=>t.id===e)||y.push({id:e,name:e,configured:!0,isCustom:!0,modelCount:n.models?.length??0})}e[14]=g,e[15]=v,e[16]=o,e[17]=f,e[18]=y}else y=e[18];let b=y,S=r||s||u,C;return e[23]!==g||e[24]!==b||e[25]!==v||e[26]!==S||e[27]!==f?(C={cards:b,loading:S,builtinRows:g,customConfig:v,allModels:f},e[23]=g,e[24]=b,e[25]=v,e[26]=S,e[27]=f,e[28]=C):C=e[28],C}function Cr(e){return e.id}function wr(e){return e.configured}function Tr(){return Le()}function Er(){return B()}async function Dr(e){let{payload:t}=await(await fetch(e,{credentials:`same-origin`,redirect:`error`})).json();return t?.providers??[]}function Or(e){return e.conversationId}function kr(e){let t=(0,Z.c)(16),{labels:n,data:r,onAdd:i,onManage:a}=e,{cards:o,loading:s}=r;if(s){let e;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(L,{className:`h-6 w-48 max-w-full`}),t[0]=e):e=t[0];let n;return t[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,$.jsxs)(`div`,{className:`flex flex-col gap-3`,"aria-busy":`true`,children:[e,(0,$.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2 lg:grid-cols-3`,children:[1,2,3].map(jr)})]}),t[1]=n):n=t[1],n}let c;if(t[2]!==o||t[3]!==n||t[4]!==i||t[5]!==a){let e=o.filter(Ar),r=e.length>0?n.titleCount.replace(`{{count}}`,String(e.length)):n.title,s;t[7]===r?s=t[8]:(s=(0,$.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:r}),t[7]=r,t[8]=s);let l;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,$.jsx)(_,{className:`size-3.5`,strokeWidth:2,"aria-hidden":!0}),t[9]=l):l=t[9];let u;t[10]!==n.addProvider||t[11]!==i?(u=(0,$.jsxs)(P,{type:`button`,variant:`primary`,className:`gap-1.5`,onClick:i,children:[l,n.addProvider]}),t[10]=n.addProvider,t[11]=i,t[12]=u):u=t[12];let d;t[13]!==s||t[14]!==u?(d=(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[s,u]}),t[13]=s,t[14]=u,t[15]=d):d=t[15],c=(0,$.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[d,e.length===0?(0,$.jsxs)(`div`,{className:`rounded-2xl bg-surface-panel/60 px-6 py-10 text-center shadow-surface`,children:[(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:n.empty}),(0,$.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:n.emptyHint}),(0,$.jsxs)(P,{type:`button`,variant:`primary`,className:`mt-4 gap-1.5`,onClick:i,children:[(0,$.jsx)(_,{className:`size-3.5`,strokeWidth:2,"aria-hidden":!0}),n.addProvider]})]}):(0,$.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2 lg:grid-cols-3`,children:e.map(e=>(0,$.jsx)(Mr,{card:e,labels:n,onManage:()=>a(e.id,e.isCustom)},e.id))})]}),t[2]=o,t[3]=n,t[4]=i,t[5]=a,t[6]=c}else c=t[6];return c}function Ar(e){return e.configured}function jr(e){return(0,$.jsx)(L,{className:`h-32 rounded-2xl`},e)}function Mr(e){let t=(0,Z.c)(28),{card:n,labels:r,onManage:i}=e,a;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(a=y(`group relative flex flex-col justify-between rounded-2xl bg-surface-base p-4 text-left shadow-surface transition-colors`,`hover:bg-surface-hover/60 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,ct.pressCard),t[0]=a):a=t[0];let o;t[1]===n.name?o=t[2]:(o=(0,$.jsx)(`span`,{className:`truncate text-sm font-semibold text-fg`,children:n.name}),t[1]=n.name,t[2]=o);let s;t[3]!==n.isCustom||t[4]!==r.custom?(s=n.isCustom?(0,$.jsx)(`span`,{className:`shrink-0 rounded bg-surface-hover px-1.5 py-0.5 text-[10px] font-medium text-fg-subtle`,children:r.custom}):null,t[3]=n.isCustom,t[4]=r.custom,t[5]=s):s=t[5];let c;t[6]!==o||t[7]!==s?(c=(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[o,s]}),t[6]=o,t[7]=s,t[8]=c):c=t[8];let l;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,$.jsx)(p,{className:`size-4 shrink-0 text-emerald-600 dark:text-emerald-400`,"aria-hidden":!0}),t[9]=l):l=t[9];let u;t[10]===c?u=t[11]:(u=(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[c,l]}),t[10]=c,t[11]=u);let d;t[12]!==n.modelCount||t[13]!==r.modelsCount||t[14]!==r.noModels?(d=n.modelCount>0?r.modelsCount.replace(`{{count}}`,String(n.modelCount)):r.noModels,t[12]=n.modelCount,t[13]=r.modelsCount,t[14]=r.noModels,t[15]=d):d=t[15];let f;t[16]===d?f=t[17]:(f=(0,$.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:d}),t[16]=d,t[17]=f);let m;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,$.jsx)(pt,{className:`size-3`,"aria-hidden":!0}),t[18]=m):m=t[18];let h;t[19]===r.manage?h=t[20]:(h=(0,$.jsxs)(`span`,{className:`flex items-center gap-1 text-xs font-medium text-accent-fg opacity-0 transition-opacity group-hover:opacity-100`,children:[m,r.manage]}),t[19]=r.manage,t[20]=h);let g;t[21]!==h||t[22]!==f?(g=(0,$.jsxs)(`div`,{className:`mt-2.5 flex items-center justify-between`,children:[f,h]}),t[21]=h,t[22]=f,t[23]=g):g=t[23];let _;return t[24]!==i||t[25]!==g||t[26]!==u?(_=(0,$.jsxs)(`button`,{type:`button`,onClick:i,className:a,children:[u,g]}),t[24]=i,t[25]=g,t[26]=u,t[27]=_):_=t[27],_}function Nr(e){let t=(0,Z.c)(184),{model:n,isNew:r,providerId:i,onSave:a,onClose:o,m:s}=e,c=C(Fr)===`zh`,l;t[0]===n?l=t[1]:(l=()=>n?{...n}:tt(``),t[0]=n,t[1]=l);let[f,p]=(0,Q.useState)(l),[m,h]=(0,Q.useState)(Pr),g;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(g=(e,t)=>{p(n=>({...n,[e]:t})),h(t=>{let n=new Map(t);return n.delete(e),n})},t[2]=g):g=t[2];let _=g,b;t[3]!==f.computerUse||t[4]!==f.contextWindow||t[5]!==f.id||t[6]!==f.input||t[7]!==f.maxTokens||t[8]!==s.modelIdRequired||t[9]!==s.mustBePositive||t[10]!==c?(b=()=>{let e=new Map;return(f.id||``).trim()||e.set(`id`,s.modelIdRequired),f.contextWindow!==void 0&&f.contextWindow<=0&&e.set(`contextWindow`,s.mustBePositive),f.maxTokens!==void 0&&f.maxTokens<=0&&e.set(`maxTokens`,s.mustBePositive),f.computerUse&&!f.input?.includes(`image`)&&e.set(`computerUse`,c?`电脑操作模型必须支持图片输入`:`Computer Use requires image input`),h(e),e.size===0},t[3]=f.computerUse,t[4]=f.contextWindow,t[5]=f.id,t[6]=f.input,t[7]=f.maxTokens,t[8]=s.modelIdRequired,t[9]=s.mustBePositive,t[10]=c,t[11]=b):b=t[11];let x=b,S;t[12]!==f||t[13]!==o||t[14]!==a||t[15]!==x?(S=()=>{if(!x())return;let e=(f.id||``).trim();a({...f,id:e,name:f.name?.trim()||e,reasoning:f.reasoning||!1,input:f.input||[`text`],contextWindow:f.contextWindow??128e3,maxTokens:f.maxTokens??16384,cost:{input:f.cost?.input??0,output:f.cost?.output??0,cacheRead:f.cost?.cacheRead??0,cacheWrite:f.cost?.cacheWrite??0}}),o()},t[12]=f,t[13]=o,t[14]=a,t[15]=x,t[16]=S):S=t[16];let w=S,T=f,E;t[17]===T?E=t[18]:(E=Fe(T),t[17]=T,t[18]=E);let D=E,k=r?s.addModelTitle:s.editModelTitle,A;t[19]===k?A=t[20]:(A=(0,$.jsx)(j,{className:`text-base font-semibold text-fg`,children:k}),t[19]=k,t[20]=A);let M;t[21]!==s.modelProviderLabel||t[22]!==i?(M=i?(0,$.jsxs)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:[s.modelProviderLabel,`: `,i]}):null,t[21]=s.modelProviderLabel,t[22]=i,t[23]=M):M=t[23];let N;t[24]!==A||t[25]!==M?(N=(0,$.jsxs)(`div`,{children:[A,M]}),t[24]=A,t[25]=M,t[26]=N):N=t[26];let F;t[27]===Symbol.for(`react.memo_cache_sentinel`)?(F=y(Pe,`p-1.5 hover:bg-surface-base`),t[27]=F):F=t[27];let I;t[28]===Symbol.for(`react.memo_cache_sentinel`)?(I=(0,$.jsx)(v,{className:`size-4`}),t[28]=I):I=t[28];let L;t[29]===s.close?L=t[30]:(L=(0,$.jsx)(O,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:F,"aria-label":s.close,children:I})}),t[29]=s.close,t[30]=L);let R;t[31]!==N||t[32]!==L?(R=(0,$.jsxs)(`div`,{className:`mb-3 flex shrink-0 items-start justify-between gap-2`,children:[N,L]}),t[31]=N,t[32]=L,t[33]=R):R=t[33];let z;t[34]===Symbol.for(`react.memo_cache_sentinel`)?(z=(0,$.jsx)(`span`,{className:`text-red-600 dark:text-red-400`,children:` *`}),t[34]=z):z=t[34];let B;t[35]===s.modelId?B=t[36]:(B=(0,$.jsxs)(`label`,{className:`mb-1 block text-xs font-medium text-fg`,children:[s.modelId,z]}),t[35]=s.modelId,t[36]=B);let V;t[37]===m?V=t[38]:(V=y(et(),m.has(`id`)&&`border-red-500`),t[37]=m,t[38]=V);let H=f.id||``,U;t[39]===Symbol.for(`react.memo_cache_sentinel`)?(U=e=>_(`id`,e.target.value),t[39]=U):U=t[39];let W=!r,G;t[40]!==V||t[41]!==H||t[42]!==W?(G=(0,$.jsx)(`input`,{className:V,value:H,onChange:U,placeholder:`e.g. llama3.1:8b`,disabled:W}),t[40]=V,t[41]=H,t[42]=W,t[43]=G):G=t[43];let K;t[44]===m?K=t[45]:(K=m.has(`id`)?(0,$.jsx)(`p`,{className:`mt-1 text-xs text-red-600 dark:text-red-400`,children:m.get(`id`)}):null,t[44]=m,t[45]=K);let q;t[46]!==B||t[47]!==G||t[48]!==K?(q=(0,$.jsxs)(`div`,{children:[B,G,K]}),t[46]=B,t[47]=G,t[48]=K,t[49]=q):q=t[49];let ee;t[50]===s.displayName?ee=t[51]:(ee=(0,$.jsx)(`label`,{className:`mb-1 block text-xs font-medium text-fg-muted`,children:s.displayName}),t[50]=s.displayName,t[51]=ee);let te;t[52]===Symbol.for(`react.memo_cache_sentinel`)?(te=et(),t[52]=te):te=t[52];let ne=f.name||``,re;t[53]===Symbol.for(`react.memo_cache_sentinel`)?(re=e=>_(`name`,e.target.value),t[53]=re):re=t[53];let J;t[54]===ne?J=t[55]:(J=(0,$.jsx)(`input`,{className:te,value:ne,onChange:re}),t[54]=ne,t[55]=J);let ie;t[56]!==ee||t[57]!==J?(ie=(0,$.jsxs)(`div`,{children:[ee,J]}),t[56]=ee,t[57]=J,t[58]=ie):ie=t[58];let Y;t[59]===s.inputTypes?Y=t[60]:(Y=(0,$.jsx)(`label`,{className:`mb-1 block text-xs font-medium text-fg-muted`,children:s.inputTypes}),t[59]=s.inputTypes,t[60]=Y);let ae;t[61]===Symbol.for(`react.memo_cache_sentinel`)?(ae=_t(),t[61]=ae):ae=t[61];let oe;t[62]===Symbol.for(`react.memo_cache_sentinel`)?(oe=e=>_(`input`,Ge(e.target.value)),t[62]=oe):oe=t[62];let X;t[63]===s?X=t[64]:(X=ze.map(e=>(0,$.jsx)(d,{value:e.value,children:s[e.labelKey]},e.value)),t[63]=s,t[64]=X);let se;t[65]!==D||t[66]!==X?(se=(0,$.jsx)(u,{className:ae,value:D,onChange:oe,children:X}),t[65]=D,t[66]=X,t[67]=se):se=t[67];let ce;t[68]!==Y||t[69]!==se?(ce=(0,$.jsxs)(`div`,{children:[Y,se]}),t[68]=Y,t[69]=se,t[70]=ce):ce=t[70];let le=f.reasoning||!1,ue;t[71]===Symbol.for(`react.memo_cache_sentinel`)?(ue=e=>_(`reasoning`,e.target.checked),t[71]=ue):ue=t[71];let de;t[72]===le?de=t[73]:(de=(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:le,onChange:ue}),t[72]=le,t[73]=de);let fe;t[74]!==s.reasoning||t[75]!==de?(fe=(0,$.jsxs)(`label`,{className:`mt-6 flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[de,s.reasoning]}),t[74]=s.reasoning,t[75]=de,t[76]=fe):fe=t[76];let pe;t[77]!==ce||t[78]!==fe?(pe=(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[ce,fe]}),t[77]=ce,t[78]=fe,t[79]=pe):pe=t[79];let me;t[80]===s.contextWindow?me=t[81]:(me=(0,$.jsx)(`label`,{className:`mb-1 block text-xs font-medium text-fg-muted`,children:s.contextWindow}),t[80]=s.contextWindow,t[81]=me);let he;t[82]===m?he=t[83]:(he=y(et(),m.has(`contextWindow`)&&`border-red-500`),t[82]=m,t[83]=he);let ge=f.contextWindow??128e3,_e;t[84]===Symbol.for(`react.memo_cache_sentinel`)?(_e=e=>_(`contextWindow`,parseInt(e.target.value,10)||0),t[84]=_e):_e=t[84];let ve;t[85]!==he||t[86]!==ge?(ve=(0,$.jsx)(`input`,{type:`number`,min:1,className:he,value:ge,onChange:_e}),t[85]=he,t[86]=ge,t[87]=ve):ve=t[87];let ye;t[88]===m?ye=t[89]:(ye=m.has(`contextWindow`)?(0,$.jsx)(`p`,{className:`mt-1 text-xs text-red-600 dark:text-red-400`,children:m.get(`contextWindow`)}):null,t[88]=m,t[89]=ye);let be;t[90]!==me||t[91]!==ve||t[92]!==ye?(be=(0,$.jsxs)(`div`,{children:[me,ve,ye]}),t[90]=me,t[91]=ve,t[92]=ye,t[93]=be):be=t[93];let xe;t[94]===s.maxOutputTokens?xe=t[95]:(xe=(0,$.jsx)(`label`,{className:`mb-1 block text-xs font-medium text-fg-muted`,children:s.maxOutputTokens}),t[94]=s.maxOutputTokens,t[95]=xe);let Se;t[96]===m?Se=t[97]:(Se=y(et(),m.has(`maxTokens`)&&`border-red-500`),t[96]=m,t[97]=Se);let Ce=f.maxTokens??16384,we;t[98]===Symbol.for(`react.memo_cache_sentinel`)?(we=e=>_(`maxTokens`,parseInt(e.target.value,10)||0),t[98]=we):we=t[98];let Te;t[99]!==Se||t[100]!==Ce?(Te=(0,$.jsx)(`input`,{type:`number`,min:1,className:Se,value:Ce,onChange:we}),t[99]=Se,t[100]=Ce,t[101]=Te):Te=t[101];let Ee;t[102]===m?Ee=t[103]:(Ee=m.has(`maxTokens`)?(0,$.jsx)(`p`,{className:`mt-1 text-xs text-red-600 dark:text-red-400`,children:m.get(`maxTokens`)}):null,t[102]=m,t[103]=Ee);let De;t[104]!==xe||t[105]!==Te||t[106]!==Ee?(De=(0,$.jsxs)(`div`,{children:[xe,Te,Ee]}),t[104]=xe,t[105]=Te,t[106]=Ee,t[107]=De):De=t[107];let Oe;t[108]!==be||t[109]!==De?(Oe=(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[be,De]}),t[108]=be,t[109]=De,t[110]=Oe):Oe=t[110];let ke;t[111]===s.costSection?ke=t[112]:(ke=(0,$.jsx)(`p`,{className:`mb-2 text-xs font-semibold text-fg`,children:s.costSection}),t[111]=s.costSection,t[112]=ke);let Ae;t[113]===s.costInput?Ae=t[114]:(Ae=(0,$.jsx)(`label`,{className:`mb-1 block text-xs text-fg-muted`,children:s.costInput}),t[113]=s.costInput,t[114]=Ae);let je;t[115]===Symbol.for(`react.memo_cache_sentinel`)?(je=et(),t[115]=je):je=t[115];let Me=f.cost?.input??0,Ne;t[116]===f.cost?Ne=t[117]:(Ne=e=>_(`cost`,{...f.cost,input:parseFloat(e.target.value)||0,output:f.cost?.output??0,cacheRead:f.cost?.cacheRead??0,cacheWrite:f.cost?.cacheWrite??0}),t[116]=f.cost,t[117]=Ne);let Ie;t[118]!==Me||t[119]!==Ne?(Ie=(0,$.jsx)(`input`,{type:`number`,step:`any`,min:0,className:je,value:Me,onChange:Ne}),t[118]=Me,t[119]=Ne,t[120]=Ie):Ie=t[120];let Le;t[121]!==Ae||t[122]!==Ie?(Le=(0,$.jsxs)(`div`,{children:[Ae,Ie]}),t[121]=Ae,t[122]=Ie,t[123]=Le):Le=t[123];let Re;t[124]===s.costOutput?Re=t[125]:(Re=(0,$.jsx)(`label`,{className:`mb-1 block text-xs text-fg-muted`,children:s.costOutput}),t[124]=s.costOutput,t[125]=Re);let Be;t[126]===Symbol.for(`react.memo_cache_sentinel`)?(Be=et(),t[126]=Be):Be=t[126];let Ve=f.cost?.output??0,He;t[127]===f.cost?He=t[128]:(He=e=>_(`cost`,{...f.cost,input:f.cost?.input??0,output:parseFloat(e.target.value)||0,cacheRead:f.cost?.cacheRead??0,cacheWrite:f.cost?.cacheWrite??0}),t[127]=f.cost,t[128]=He);let Ue;t[129]!==Ve||t[130]!==He?(Ue=(0,$.jsx)(`input`,{type:`number`,step:`any`,min:0,className:Be,value:Ve,onChange:He}),t[129]=Ve,t[130]=He,t[131]=Ue):Ue=t[131];let We;t[132]!==Re||t[133]!==Ue?(We=(0,$.jsxs)(`div`,{children:[Re,Ue]}),t[132]=Re,t[133]=Ue,t[134]=We):We=t[134];let Ke;t[135]!==Le||t[136]!==We?(Ke=(0,$.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[Le,We]}),t[135]=Le,t[136]=We,t[137]=Ke):Ke=t[137];let qe;t[138]!==ke||t[139]!==Ke?(qe=(0,$.jsxs)(`div`,{className:`border-t border-edge-subtle pt-2 dark:border-edge`,children:[ke,Ke]}),t[138]=ke,t[139]=Ke,t[140]=qe):qe=t[140];let Je;t[141]!==q||t[142]!==ie||t[143]!==pe||t[144]!==Oe||t[145]!==qe?(Je=(0,$.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[q,ie,pe,Oe,qe]}),t[141]=q,t[142]=ie,t[143]=pe,t[144]=Oe,t[145]=qe,t[146]=Je):Je=t[146];let Ye=c?`高级:电脑操作协议`:`Advanced: Computer Use protocol`,Xe;t[147]===Ye?Xe=t[148]:(Xe=(0,$.jsx)(`summary`,{className:`cursor-pointer`,children:Ye}),t[147]=Ye,t[148]=Xe);let Ze=c?`电脑操作协议`:`Computer Use protocol`,Qe=f.computerUse?.profile??``,$e;t[149]===Symbol.for(`react.memo_cache_sentinel`)?($e=e=>_(`computerUse`,e.target.value?{profile:e.target.value}:void 0),t[149]=$e):$e=t[149];let nt=c?`未声明`:`Not declared`,rt;t[150]===nt?rt=t[151]:(rt=(0,$.jsx)(d,{value:``,children:nt}),t[150]=nt,t[151]=rt);let it,at;t[152]===Symbol.for(`react.memo_cache_sentinel`)?(it=(0,$.jsx)(d,{value:`gui-plus-2026-02-26`,children:`GUI-Plus (2026-02-26)`}),at=(0,$.jsx)(d,{value:`structured-tools-v1`,children:`structured-tools-v1`}),t[152]=it,t[153]=at):(it=t[152],at=t[153]);let ot;t[154]!==Ze||t[155]!==Qe||t[156]!==rt?(ot=(0,$.jsxs)(u,{"aria-label":Ze,value:Qe,onChange:$e,children:[rt,it,at]}),t[154]=Ze,t[155]=Qe,t[156]=rt,t[157]=ot):ot=t[157];let st=c?`仅适用于已适配的 OpenAI Chat Completions 视觉模型。声明协议不代表模型已通过效果验证。`:`For adapted OpenAI Chat Completions vision models only. Declaring a protocol does not certify model quality.`,ct;t[158]===st?ct=t[159]:(ct=(0,$.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-muted`,children:st}),t[158]=st,t[159]=ct);let lt;t[160]===m?lt=t[161]:(lt=m.has(`computerUse`)&&(0,$.jsx)(`p`,{role:`alert`,className:`text-xs text-danger`,children:m.get(`computerUse`)}),t[160]=m,t[161]=lt);let ut;t[162]!==ot||t[163]!==ct||t[164]!==lt?(ut=(0,$.jsxs)(`div`,{className:`mt-3 space-y-2`,children:[ot,ct,lt]}),t[162]=ot,t[163]=ct,t[164]=lt,t[165]=ut):ut=t[165];let dt;t[166]!==Xe||t[167]!==ut?(dt=(0,$.jsxs)(`details`,{className:`mt-4 rounded-lg border border-edge p-3 text-sm text-fg`,children:[Xe,ut]}),t[166]=Xe,t[167]=ut,t[168]=dt):dt=t[168];let ft;t[169]!==Je||t[170]!==dt?(ft=(0,$.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto pr-1`,children:[Je,dt]}),t[169]=Je,t[170]=dt,t[171]=ft):ft=t[171];let pt;t[172]===s.cancel?pt=t[173]:(pt=(0,$.jsx)(O,{asChild:!0,children:(0,$.jsx)(P,{type:`button`,variant:`secondary`,children:s.cancel})}),t[172]=s.cancel,t[173]=pt);let mt=r?s.addModelConfirm:s.saveModelConfirm,ht;t[174]!==w||t[175]!==mt?(ht=(0,$.jsx)(P,{type:`button`,className:`bg-accent text-white hover:bg-accent/90`,onClick:w,children:mt}),t[174]=w,t[175]=mt,t[176]=ht):ht=t[176];let gt;t[177]!==pt||t[178]!==ht?(gt=(0,$.jsxs)(`div`,{className:`mt-4 flex shrink-0 justify-end gap-2 border-t border-edge-subtle pt-3 dark:border-edge`,children:[pt,ht]}),t[177]=pt,t[178]=ht,t[179]=gt):gt=t[179];let vt;return t[180]!==R||t[181]!==ft||t[182]!==gt?(vt=(0,$.jsxs)($.Fragment,{children:[R,ft,gt]}),t[180]=R,t[181]=ft,t[182]=gt,t[183]=vt):vt=t[183],vt}function Pr(){return new Map}function Fr(e){return e.language}function Ir(e){let t=(0,Z.c)(16),{open:n,onOpenChange:r,providerId:i,model:a,isNew:o,onSave:s,m:c}=e,l;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,$.jsx)(E,{className:y(`xopc-dialog-overlay fixed inset-0 bg-scrim`,z)}),t[0]=l):l=t[0];let u;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(u=y(`xopc-dialog-content fixed left-1/2 top-1/2 flex h-[min(90vh,720px)] w-[min(100%-2rem,28rem)] -translate-x-1/2 -translate-y-1/2 flex-col`,R,`overflow-hidden rounded-xl border border-edge bg-surface-panel p-4 shadow-popover dark:border-edge`),t[1]=u):u=t[1];let d;t[2]!==o||t[3]!==c||t[4]!==a||t[5]!==r||t[6]!==s||t[7]!==n||t[8]!==i?(d=n?(0,$.jsx)(Nr,{model:a,isNew:o,providerId:i,onSave:s,onClose:()=>r(!1),m:c},`${i??`none`}-${a?.id??`new`}`):null,t[2]=o,t[3]=c,t[4]=a,t[5]=r,t[6]=s,t[7]=n,t[8]=i,t[9]=d):d=t[9];let f;t[10]===d?f=t[11]:(f=(0,$.jsxs)(k,{children:[l,(0,$.jsx)(A,{className:u,onOpenAutoFocus:Lr,children:d})]}),t[10]=d,t[11]=f);let p;return t[12]!==r||t[13]!==n||t[14]!==f?(p=(0,$.jsx)(M,{open:n,onOpenChange:r,children:f}),t[12]=r,t[13]=n,t[14]=f,t[15]=p):p=t[15],p}function Lr(e){return e.preventDefault()}function Rr(e){let t=(0,Z.c)(14),{providerId:n,inputId:r,value:i,onChange:a,labels:o}=e,s;t[0]===n?s=t[1]:(s=()=>pe(n).then(zr),t[0]=n,t[1]=s);let c=s,l;t[2]!==r||t[3]!==o.apiKeyLabel?(l=(0,$.jsx)(`label`,{htmlFor:r,className:`text-sm font-medium text-fg`,children:o.apiKeyLabel}),t[2]=r,t[3]=o.apiKeyLabel,t[4]=l):l=t[4];let u;t[5]!==r||t[6]!==o||t[7]!==a||t[8]!==c||t[9]!==i?(u=(0,$.jsx)(dt,{id:r,value:i,onChange:a,placeholder:o.apiKeyPlaceholder,labels:o,reveal:c,loadFailedLabel:o.loadFailed,maskedHelp:o.maskedHelp,notInConfigFile:o.notInConfigFile}),t[5]=r,t[6]=o,t[7]=a,t[8]=c,t[9]=i,t[10]=u):u=t[10];let d;return t[11]!==l||t[12]!==u?(d=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[l,u]}),t[11]=l,t[12]=u,t[13]=d):d=t[13],d}function zr(e){return e.apiKey??null}function Br(e){let t=(0,Z.c)(16),{open:n,onOpenChange:r,providerId:i,isCustom:a,builtinRows:o,customConfig:s,allModels:c,labels:l,language:u,onSaved:d}=e,f;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,$.jsx)(E,{className:y(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,z)}),t[0]=f):f=t[0];let p;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(p=y(`fixed left-1/2 top-1/2 flex h-[min(85vh,720px)] w-[calc(100%-2rem)] max-w-lg -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-2xl border border-edge-subtle bg-surface-base shadow-xl`,R),t[1]=p):p=t[1];let m;t[2]!==c||t[3]!==o||t[4]!==s||t[5]!==a||t[6]!==l||t[7]!==u||t[8]!==r||t[9]!==d||t[10]!==i?(m=(0,$.jsxs)(k,{children:[f,(0,$.jsx)(A,{className:p,children:a?(0,$.jsx)(Hr,{providerId:i,customConfig:s,labels:l,language:u,onClose:()=>r(!1),onSaved:d}):(0,$.jsx)(Vr,{providerId:i,builtinRows:o,allModels:c,labels:l,language:u,onClose:()=>r(!1),onSaved:d})})]}),t[2]=c,t[3]=o,t[4]=s,t[5]=a,t[6]=l,t[7]=u,t[8]=r,t[9]=d,t[10]=i,t[11]=m):m=t[11];let h;return t[12]!==r||t[13]!==n||t[14]!==m?(h=(0,$.jsx)(M,{open:n,onOpenChange:r,children:m}),t[12]=r,t[13]=n,t[14]=m,t[15]=h):h=t[15],h}function Vr({providerId:e,builtinRows:t,allModels:n,labels:r,language:i,onClose:a,onSaved:o}){let s=t.find(t=>t.id===e),c=Ae[e],u=n.filter(t=>t.provider===e),[d,f]=(0,Q.useState)(!1),[h,_]=(0,Q.useState)(s?.apiKey??``),[b,x]=(0,Q.useState)(!1),[S,C]=(0,Q.useState)(!1),[w,E]=(0,Q.useState)(null),[D,k]=(0,Q.useState)(!1),A=T(i).providersSettings,M=s?.supportsApiKey!==!1,N=s?.supportsOAuth===!0,F=s?.authMode===`oauth`&&s.authStatus===`connected`,I=s?.configured===!0&&s.activeKeySource!==`env`&&s.activeKeySource!==`extension`&&s.activeKeySource!==`models_json`,[L,R]=(0,Q.useState)(null),[z,B]=(0,Q.useState)(null),[V,H]=(0,Q.useState)(`idle`),[G,q]=(0,Q.useState)(null),[re,J]=(0,Q.useState)(null),[ie,Y]=(0,Q.useState)(null),[ae,oe]=(0,Q.useState)(``),X=(0,Q.useRef)(null),se=(0,Q.useRef)(null),ce=V===`waiting`||V===`waiting_code`,le=(0,Q.useMemo)(()=>ke(e,i),[e,i]),ue=h!==(s?.apiKey??``),de=async()=>{let t=h.trim();if(!(!t||!M||Xe(t))){x(!0),E(null);try{await Ke({[e]:t}),C(!0),window.setTimeout(()=>{o(),a()},600)}catch(e){E(e instanceof Error?e.message:r.saveError)}finally{x(!1)}}};(0,Q.useEffect)(()=>{if(!L||!ce)return;let e=window.setInterval(()=>{(async()=>{try{let t=await ee(L);t.status===`waiting_auth`||t.status===`waiting_code`?(H(t.status===`waiting_code`?`waiting_code`:`waiting`),B(t.message??null),q(t.authUrl??null),J(t.instructions??null),Y(t.deviceCode??null),t.authUrl&&t.authUrl!==se.current&&(se.current=t.authUrl,K(t.authUrl,X.current).catch(()=>{}))):t.status===`completed`?(window.clearInterval(e),vt(X.current),X.current=null,H(`success`),B(t.message??A.saved),window.setTimeout(()=>{o(),a()},600)):(t.status===`failed`||t.status===`cancelled`)&&(window.clearInterval(e),vt(X.current),X.current=null,H(`error`),B(t.error??t.message??A.revokeFailed))}catch{}})()},1e3);return()=>window.clearInterval(e)},[L,ce,a,o,A.revokeFailed,A.saved]),(0,Q.useEffect)(()=>()=>{L&&be(L).catch(()=>{})},[L]),(0,Q.useEffect)(()=>()=>{vt(X.current),X.current=null},[]);let fe=async()=>{try{await te(e),o(),a()}catch{}},pe=async()=>{vt(X.current),X.current=Te(),se.current=null,H(`waiting`),B(A.oauthStarting),q(null),J(null),Y(null),E(null);try{R((await we(e)).sessionId)}catch(e){vt(X.current),X.current=null,H(`error`),B(e instanceof Error?e.message:A.revokeFailed)}},me=async()=>{if(L){try{await gt(L)}catch{}vt(X.current),X.current=null,se.current=null,H(`idle`),B(null),R(null),q(null),J(null),Y(null)}},he=async()=>{if(!(!L||!ae.trim()))try{await ne(L,ae.trim()),oe(``),B(A.oauthProcessingCode)}catch(e){H(`error`),B(e instanceof Error?e.message:A.revokeFailed)}},ge=async()=>{try{await ft(e),o(),a()}catch(e){E(e instanceof Error?e.message:A.revokeFailed)}};return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between border-b border-edge-subtle px-5 py-4`,children:[(0,$.jsx)(j,{className:`text-base font-semibold text-fg`,children:s?.name??e}),(0,$.jsx)(O,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:y(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,ct.press),children:(0,$.jsx)(v,{className:`size-4`,"aria-hidden":!0})})})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-4 overflow-y-auto px-5 py-4`,children:[c?.description?(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:c.description}):null,s?.baseUrl?(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:r.apiUrlLabel}),(0,$.jsx)(`code`,{className:`break-all rounded-lg border border-edge-subtle bg-surface-panel/60 px-3 py-2 font-mono text-xs text-fg-muted`,children:s.baseUrl})]}):s?.category===`extension`?(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:r.apiUrlExtensionHint}):null,M?(0,$.jsx)(Rr,{providerId:e,inputId:`manage-api-key`,value:h,onChange:e=>{_(e),C(!1)},labels:{apiKeyLabel:r.apiKeyLabel,apiKeyPlaceholder:r.apiKeyPlaceholder,maskedHelp:r.maskedHelp,copy:r.copy,copied:r.copied,show:r.showKey,hide:r.hideKey,notInConfigFile:r.notInConfigFile,loadFailed:r.loadFailed}}):s?.category===`extension`?(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-lg border border-edge-subtle bg-surface-panel/60 px-3 py-2 text-sm text-fg-muted`,children:[(0,$.jsx)(`p`,{children:r.extensionKeyHint}),s?.extensionId?(0,$.jsxs)(l,{to:`/settings/ext/${encodeURIComponent(s.extensionId)}`,className:`inline-flex w-fit items-center gap-1 font-medium text-accent hover:underline`,title:r.extensionSettingsLinkTitle,onClick:a,children:[r.openExtensionSettings,(0,$.jsx)(m,{className:`size-3`,"aria-hidden":!0})]}):null]}):null,N?(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-lg border border-edge-subtle bg-surface-panel/60 p-3`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:A.oauth}),(0,$.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:F?A.sourceOauth:A.oauthHint})]}),F?(0,$.jsx)(P,{type:`button`,variant:`secondary`,className:`gap-1.5 text-red-600 dark:text-red-400`,onClick:()=>void ge(),children:A.revoke}):(0,$.jsxs)(P,{type:`button`,variant:`primary`,className:`gap-1.5`,disabled:ce,onClick:()=>void pe(),children:[ce?(0,$.jsx)(g,{className:`size-3.5 animate-spin`,"aria-hidden":!0}):(0,$.jsx)(rt,{className:`size-3.5`,"aria-hidden":!0}),A.oauth]})]}),z?(0,$.jsx)(`p`,{className:y(`text-xs`,V===`error`?`text-red-600 dark:text-red-400`:`text-fg-muted`),children:z}):null,V===`waiting`||V===`waiting_code`?(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[G?(0,$.jsxs)(`a`,{href:G,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1.5 rounded-md bg-accent px-3 py-2 text-sm font-medium text-white hover:bg-accent-hover`,children:[(0,$.jsx)(m,{className:`size-4`,"aria-hidden":!0}),A.openAuthPage]}):null,(0,$.jsx)(P,{type:`button`,variant:`secondary`,onClick:()=>void me(),children:A.cancelOAuth})]}):null,re?(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:re}):null,ie?(0,$.jsxs)(`div`,{className:`rounded-lg border border-edge-subtle bg-surface-panel px-3 py-2`,children:[(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:A.deviceCodeLabel}),(0,$.jsx)(`code`,{className:`mt-1 block select-all font-mono text-lg font-semibold tracking-widest text-fg`,children:ie}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:A.deviceCodeHint})]}):null,V===`waiting_code`?(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row`,children:[(0,$.jsx)(`input`,{type:`text`,value:ae,onChange:e=>oe(e.target.value),onKeyDown:e=>e.key===`Enter`&&void he(),placeholder:A.pasteRedirectUrl,className:y(`min-w-0 flex-1 rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg placeholder:text-fg-subtle`,W)}),(0,$.jsx)(P,{type:`button`,variant:`primary`,onClick:()=>void he(),children:A.submitCode})]}):null]}):null,le.length>0&&M?(0,$.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:le.map(({kind:e,href:t})=>(0,$.jsxs)(`a`,{href:t,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 text-xs text-accent hover:underline`,children:[je(e,r),(0,$.jsx)(m,{className:`size-3`,"aria-hidden":!0})]},e))}):null,u.length>0?(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsxs)(`span`,{className:`text-sm font-medium text-fg`,children:[r.modelsLabel,` (`,u.length,`)`]}),(0,$.jsxs)(`label`,{className:`mb-2 flex items-center gap-2 text-xs text-fg-muted`,children:[(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:d,onChange:e=>f(e.target.checked)}),i===`zh`?`仅电脑操作模型`:`Computer Use only`]}),(0,$.jsx)(`div`,{className:`max-h-40 overflow-y-auto rounded-lg border border-edge-subtle bg-surface-panel/40 p-2`,children:(0,$.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:u.filter(e=>!d||e.computerUse).map(e=>(0,$.jsxs)(`span`,{className:`inline-block rounded-md bg-surface-hover px-2 py-1 text-xs text-fg-muted`,children:[Re(e,i),e.computerUse?` · Computer Use`:``]},e.id))})})]}):(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:r.noModels}),w?(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:w}):null]}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between border-t border-edge-subtle px-5 py-3`,children:[I?(0,$.jsxs)(P,{type:`button`,variant:`ghost`,className:`gap-1.5 text-red-600 hover:text-red-700 dark:text-red-400 dark:hover:text-red-300`,onClick:()=>k(!0),children:[(0,$.jsx)(U,{className:`size-3.5`,"aria-hidden":!0}),r.remove]}):(0,$.jsx)(`span`,{}),(0,$.jsx)(`div`,{className:`flex items-center gap-2`,children:M&&ue&&!Xe(h.trim())?(0,$.jsx)(P,{type:`button`,variant:`primary`,disabled:!h.trim()||b||S,onClick:()=>void de(),children:S?(0,$.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(p,{className:`size-3.5`,"aria-hidden":!0}),r.saved]}):b?(0,$.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(g,{className:`size-3.5 animate-spin`,"aria-hidden":!0}),r.saving]}):r.save}):null})]}),(0,$.jsx)(Me,{open:D,title:r.removeConfirmTitle,description:r.removeConfirmDescription.replace(`{{provider}}`,s?.name??e),confirmLabel:r.removeConfirmAction,cancelLabel:r.cancel,destructive:!0,onConfirm:()=>void fe(),onCancel:()=>k(!1)})]})}function Hr({providerId:e,customConfig:t,labels:n,language:r,onClose:i,onSaved:a}){let o=T(r).modelsSettings,s=t?.providers[e],[c,l]=(0,Q.useState)(s?.baseUrl??``),[u,d]=(0,Q.useState)(s?.apiKey??``),[f,p]=(0,Q.useState)(s?.models??[]),[m,h]=(0,Q.useState)(!1),[b,x]=(0,Q.useState)(s?.modelDiscovery?.enabled===!0),[S,C]=(0,Q.useState)(!1),[w,E]=(0,Q.useState)(null),[D,k]=(0,Q.useState)(!1),[A,M]=(0,Q.useState)(null),[N,F]=(0,Q.useState)(!1),[I,L]=(0,Q.useState)(null),R=n=>{if(!t)return null;let r=u.trim(),i={...s,baseUrl:c.trim()||void 0,apiKey:Xe(r)?s?.apiKey:r||void 0,...n};return{providers:{...t.providers,[e]:i}}},z=async()=>{let e=R({models:f,modelDiscovery:{enabled:b}});if(e){C(!0),E(null);try{await ot(e),a(),i()}catch(e){E(e instanceof Error?e.message:n.saveError)}finally{C(!1)}}},B=async()=>{if(t)try{let{[e]:n,...r}=t.providers;await ot({providers:r}),a(),i()}catch{}},V=(e,t)=>{L({model:e,isNew:t}),F(!0)},H=async e=>{if(!I)return;let t=I.isNew?[...f,e]:f.map(t=>t.id===e.id?e:t);p(t);let r=R({models:t});if(r)try{await ot(r),a()}catch(e){E(e instanceof Error?e.message:n.saveError)}},G=async e=>{let t=f.filter(t=>t.id!==e);p(t),M(null);let r=R({models:t});if(r)try{await ot(r),a()}catch(e){E(e instanceof Error?e.message:n.saveError)}};return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between border-b border-edge-subtle px-5 py-4`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(j,{className:`text-base font-semibold text-fg`,children:e}),(0,$.jsx)(`span`,{className:`rounded bg-surface-hover px-1.5 py-0.5 text-[10px] font-medium text-fg-subtle`,children:n.custom})]}),(0,$.jsx)(O,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:y(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,ct.press),children:(0,$.jsx)(v,{className:`size-4`,"aria-hidden":!0})})})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-4 overflow-y-auto px-5 py-4`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(`label`,{htmlFor:`manage-base-url`,className:`text-sm font-medium text-fg`,children:n.baseUrlLabel}),(0,$.jsx)(`input`,{id:`manage-base-url`,type:`url`,autoComplete:`off`,value:c,onChange:e=>l(e.target.value),className:y(`rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg placeholder:text-fg-subtle`,W)})]}),(0,$.jsx)(Rr,{providerId:e,inputId:`manage-custom-api-key`,value:u,onChange:d,labels:{apiKeyLabel:n.apiKeyLabel,apiKeyPlaceholder:n.apiKeyPlaceholder,maskedHelp:n.maskedHelp,copy:n.copy,copied:n.copied,show:n.showKey,hide:n.hideKey,notInConfigFile:n.notInConfigFile,loadFailed:n.loadFailed}}),(0,$.jsxs)(`label`,{className:`flex items-start gap-3 rounded-xl border border-edge-subtle bg-surface-panel/40 p-3`,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:b,onChange:e=>x(e.target.checked),className:`mt-0.5 size-4 rounded border-edge accent-accent`}),(0,$.jsxs)(`span`,{className:`min-w-0`,children:[(0,$.jsx)(`span`,{className:`block text-sm font-medium text-fg`,children:r===`zh`?`自动同步模型目录`:`Automatically sync model catalog`}),(0,$.jsx)(`span`,{className:`mt-0.5 block text-xs text-fg-muted`,children:r===`zh`?`启动时及定时从此服务的 /models 接口更新模型。`:`Update models from this service’s /models endpoint at startup and on schedule.`})]})]}),(0,$.jsxs)(`div`,{className:`border-t border-edge-subtle pt-3`,children:[(0,$.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-2`,children:[(0,$.jsxs)(`span`,{className:`text-sm font-semibold text-fg`,children:[o.modelsSection,f.length>0?` (${f.length})`:``]}),(0,$.jsxs)(P,{type:`button`,variant:`primary`,className:`gap-1.5 px-2 py-1 text-xs`,onClick:()=>V(null,!0),children:[(0,$.jsx)(_,{className:`size-3.5`,"aria-hidden":!0}),o.addModel]})]}),(0,$.jsxs)(`label`,{className:`mb-2 flex items-center gap-2 text-xs text-fg-muted`,children:[(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:m,onChange:e=>h(e.target.checked)}),r===`zh`?`仅电脑操作模型`:`Computer Use only`]}),f.filter(e=>!m||e.computerUse).length===0?(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:o.modelsEmpty}):(0,$.jsx)(`ul`,{className:`space-y-2`,children:f.filter(e=>!m||e.computerUse).map(e=>(0,$.jsxs)(`li`,{className:`flex items-center justify-between gap-2 rounded-lg border border-edge-subtle bg-surface-panel/40 px-3 py-2`,children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`div`,{className:`truncate text-sm font-medium text-fg`,children:e.id}),e.computerUse&&(0,$.jsx)(`span`,{className:`text-xs text-fg-muted`,children:`Computer Use`}),e.name&&e.name!==e.id?(0,$.jsx)(`div`,{className:`truncate text-xs text-fg-muted`,children:e.name}):null]}),(0,$.jsxs)(`div`,{className:`flex shrink-0 gap-1`,children:[(0,$.jsx)(`button`,{type:`button`,className:y(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,ct.press),onClick:()=>V(e,!1),"aria-label":o.editModel,children:(0,$.jsx)(Ee,{className:`size-3.5`,"aria-hidden":!0})}),(0,$.jsx)(`button`,{type:`button`,className:y(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-red-600 dark:hover:text-red-400`,ct.press),onClick:()=>M(e.id),"aria-label":o.removeModel,children:(0,$.jsx)(U,{className:`size-3.5`,"aria-hidden":!0})})]})]},e.id))})]}),w?(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:w}):null]}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between border-t border-edge-subtle px-5 py-3`,children:[(0,$.jsxs)(P,{type:`button`,variant:`ghost`,className:`gap-1.5 text-red-600 hover:text-red-700 dark:text-red-400 dark:hover:text-red-300`,onClick:()=>k(!0),children:[(0,$.jsx)(U,{className:`size-3.5`,"aria-hidden":!0}),n.remove]}),(0,$.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,$.jsx)(P,{type:`button`,variant:`primary`,disabled:S,onClick:()=>void z(),children:S?(0,$.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(g,{className:`size-3.5 animate-spin`,"aria-hidden":!0}),n.saving]}):n.save})})]}),(0,$.jsx)(Me,{open:D,title:n.removeConfirmTitle,description:n.removeConfirmDescription.replace(`{{provider}}`,e),confirmLabel:n.removeConfirmAction,cancelLabel:n.cancel,destructive:!0,onConfirm:()=>void B(),onCancel:()=>k(!1)}),(0,$.jsx)(Me,{open:A!==null,title:o.removeModel,description:o.removeModelConfirm.replace(`{{id}}`,A??``),confirmLabel:n.removeConfirmAction,cancelLabel:n.cancel,destructive:!0,onConfirm:()=>{A&&G(A)},onCancel:()=>M(null)}),(0,$.jsx)(Ir,{open:N,onOpenChange:e=>{F(e),e||L(null)},providerId:e,model:I?.model??null,isNew:I?.isNew??!1,onSave:e=>void H(e),m:o})]})}function Ur(e,t){switch(e){case`computer-use`:return{href:`/settings/computer-use`,guidance:t?`选择兼容的电脑操作模型;本机权限需单独授权`:`Select a compatible computer model; local access requires separate approval`,action:t?`配置电脑操作`:`Configure computer use`};case`vision`:return{href:`${Ne(`models`)}?add=1`,guidance:t?`接入支持图片理解的模型服务`:`Connect a model service that supports vision`,action:t?`去接入模型`:`Connect model`};case`image-generation`:return{href:Ne(`image`),guidance:t?`选择图片模型并配置所需凭据`:`Choose an image model and configure its credentials`,action:t?`去配置图片生成`:`Configure image generation`};case`stt`:return{href:Ne(`voice`),guidance:t?`选择语音识别服务,或安装本地语音模型`:`Choose a speech-to-text service or install a local voice model`,action:t?`去配置语音识别`:`Configure speech-to-text`};case`tts`:return{href:Ne(`voice`),guidance:t?`选择语音合成服务并完成凭据配置`:`Choose a text-to-speech service and configure its credentials`,action:t?`去配置语音合成`:`Configure text-to-speech`}}}async function Wr(){let e=await S(w(`/api/models/catalog`)),t=await e.json().catch(()=>null);if(!e.ok||!t?.ok||!t.payload)throw Error(t?.error?.message??`HTTP ${e.status}`);return t.payload}async function Gr(){let e=await S(w(`/api/capabilities/readiness`)),t=await e.json().catch(()=>null);if(!e.ok||!t?.ok||!t.payload)throw Error(t?.error?.message??`HTTP ${e.status}`);return t.payload}function Kr(){let e=C(e=>e.language)===`zh`,{data:t,error:n,isLoading:r}=N(X,Wr,{revalidateOnFocus:!1}),{data:i}=N(he,Gr,{revalidateOnFocus:!1}),[a,o]=(0,Q.useState)(!1),[s,c]=(0,Q.useState)(null);if(r)return(0,$.jsx)(L,{className:`h-24 w-full rounded-2xl`});let u=Object.values(t?.sources??{}),d=u.reduce((e,t)=>e+t.models.filter(e=>e.availability===`available`).length,0),f=(t?.references??[]).filter(e=>e.availability===`unavailable`),m=t?.sync.lastSuccessAt??Math.max(0,...u.map(e=>e.lastSuccessAt)),h=s??(n instanceof Error?n.message:t?.sync.lastError??Object.values(t?.sync.sourceErrors??{})[0]),_=Object.entries(i?.capabilities??{}).some(([e,t])=>(t.status===`degraded`||t.status===`unavailable`)&&(e!==`computer-use`||!!t.rejected?.length)),v=async()=>{o(!0),c(null);try{let e=await S(w(`/api/models/catalog/refresh`),{method:`POST`});if(!e.ok)throw Error(`HTTP ${e.status}`);await le()}catch(t){c(t instanceof Error?t.message:e?`模型目录刷新失败`:`Model catalog refresh failed`)}finally{o(!1)}};return(0,$.jsxs)(`div`,{className:`rounded-2xl border border-edge-subtle bg-surface-panel/40 p-4`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between`,children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[h||f.length>0||_?(0,$.jsx)(_e,{className:`size-4 text-amber-500`,"aria-hidden":!0}):(0,$.jsx)(p,{className:`size-4 text-emerald-500`,"aria-hidden":!0}),(0,$.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:e?`模型目录同步`:`Model catalog sync`})]}),(0,$.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:e?`${u.length} 个来源,${d} 个可用模型${m?` · 最近同步 ${new Date(m).toLocaleString()}`:``}`:`${u.length} sources, ${d} available models${m?` · Last synced ${new Date(m).toLocaleString()}`:``}`})]}),(0,$.jsxs)(P,{className:`shrink-0`,type:`button`,variant:`secondary`,disabled:a,onClick:()=>void v(),children:[a?(0,$.jsx)(g,{className:`size-4 animate-spin`,"aria-hidden":!0}):(0,$.jsx)(qe,{className:`size-4`,"aria-hidden":!0}),a?e?`刷新中…`:`Refreshing…`:e?`立即刷新`:`Refresh now`]})]}),i?(0,$.jsx)(`div`,{className:`mt-3 grid gap-2 sm:grid-cols-2 xl:grid-cols-3`,children:Object.entries(i.capabilities).map(([t,n])=>{let r=t===`vision`?e?`图片理解`:`Vision`:t===`image-generation`?e?`图片生成`:`Image generation`:t===`computer-use`?e?`电脑操作模型`:`Computer use model`:t.toUpperCase(),i=n.selectionSource!==`explicit-config`,a=t===`computer-use`&&!n.primary&&!n.rejected?.length,o=!a&&(n.status===`degraded`||n.status===`unavailable`),s=Ur(t,e),c=(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,$.jsx)(`span`,{className:`min-w-0 text-xs font-medium text-fg`,children:r}),(0,$.jsx)(`span`,{className:n.status===`ready`?`shrink-0 text-xs text-emerald-600 dark:text-emerald-400`:n.status===`disabled`||a?`shrink-0 text-xs text-fg-muted`:`shrink-0 text-xs text-amber-600 dark:text-amber-400`,children:a?e?`未选择`:`Not selected`:n.status===`ready`?t===`computer-use`?e?`已配置`:`Configured`:e?`可用`:`Ready`:n.status===`disabled`?e?`已关闭`:`Off`:e?`需处理`:`Needs attention`})]}),(0,$.jsx)(`p`,{className:`mt-1 truncate text-xs text-fg-muted`,title:n.primary?`${n.primary.provider}/${n.primary.model}`:void 0,children:n.primary?`${i?e?`自动`:`Auto`:e?`显式`:`Explicit`} · ${n.primary.provider}/${n.primary.model}`:a?e?`不继承聊天模型`:`Does not inherit chat model`:e?`无可用实现`:`No available implementation`}),o?(0,$.jsxs)(`div`,{className:`mt-2 border-t border-edge-subtle pt-2`,children:[(0,$.jsx)(`p`,{className:`text-xs leading-5 text-amber-700 dark:text-amber-300`,children:n.status===`degraded`?e?`当前配置不可用,正在使用备用方案。${s.guidance}`:`The current configuration is unavailable, so a fallback is in use. ${s.guidance}.`:s.guidance}),(0,$.jsxs)(`span`,{className:`mt-1 inline-flex items-center gap-1 text-xs font-medium text-accent`,children:[s.action,(0,$.jsx)(Oe,{className:`size-3.5`,"aria-hidden":!0})]})]}):null]});return o||t===`computer-use`?(0,$.jsx)(l,{to:s.href,"aria-label":`${r}:${s.action}`,className:y(`rounded-xl border px-3 py-2 transition-colors`,o?`border-amber-400/40 bg-amber-500/5 hover:border-amber-400/70`:`border-edge-subtle bg-surface-panel hover:bg-surface-hover`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`),children:c},t):(0,$.jsx)(`div`,{className:`rounded-xl border border-edge-subtle bg-surface-panel px-3 py-2`,children:c},t)})}):null,f.length>0?(0,$.jsx)(`div`,{className:`mt-2 space-y-1 text-sm text-amber-700 dark:text-amber-300`,children:f.slice(0,3).map(t=>(0,$.jsxs)(`p`,{children:[t.ref,` `,e?`不可用`:`is unavailable`,t.suggestedRef?` · ${e?`建议`:`Suggested`} ${t.suggestedRef}`:``,` · ${t.locations.length} ${e?`处引用`:`references`}`]},t.ref))}):null,h?(0,$.jsx)(`p`,{className:`mt-2 text-sm text-danger`,children:h}):null]})}async function qr(){return(await b(w(`/api/models/xopc-cloud/account-summary`))).payload}function Jr(e){let t=(0,Z.c)(93),{labels:n}=e,r=C(Yr)===`zh`?`zh-CN`:`en-US`,i;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(i={refreshInterval:6e4,revalidateOnFocus:!0},t[0]=i):i=t[0];let{data:a,error:o,isLoading:s,isValidating:c,mutate:l}=N(`/api/models/xopc-cloud/account-summary`,qr,i);if(s){let e;return t[1]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(L,{className:`h-48 w-full rounded-2xl`}),t[1]=e):e=t[1],e}if(o||!a){let e;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(_e,{className:`mt-0.5 size-4 shrink-0 text-amber-500`,"aria-hidden":!0}),t[2]=e):e=t[2];let r;t[3]===n.title?r=t[4]:(r=(0,$.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:n.title}),t[3]=n.title,t[4]=r);let i;t[5]===n.unavailable?i=t[6]:(i=(0,$.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:n.unavailable}),t[5]=n.unavailable,t[6]=i);let a;t[7]!==r||t[8]!==i?(a=(0,$.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[e,(0,$.jsxs)(`div`,{children:[r,i]})]}),t[7]=r,t[8]=i,t[9]=a):a=t[9];let o;t[10]===l?o=t[11]:(o=()=>void l(),t[10]=l,t[11]=o);let s=c?`size-4 animate-spin`:`size-4`,u;t[12]===s?u=t[13]:(u=(0,$.jsx)(qe,{className:s,"aria-hidden":!0}),t[12]=s,t[13]=u);let d;t[14]!==c||t[15]!==n.retry||t[16]!==o||t[17]!==u?(d=(0,$.jsxs)(P,{type:`button`,variant:`secondary`,disabled:c,onClick:o,children:[u,n.retry]}),t[14]=c,t[15]=n.retry,t[16]=o,t[17]=u,t[18]=d):d=t[18];let f;return t[19]!==a||t[20]!==d?(f=(0,$.jsx)(`section`,{className:`rounded-2xl border border-edge-subtle bg-surface-panel/40 p-4`,children:(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[a,d]})}),t[19]=a,t[20]=d,t[21]=f):f=t[21],f}let u,d,f,p,h,g,_,v;if(t[22]!==a.balance.credits||t[23]!==a.usage.chargedCredits||t[24]!==a.usage.requests||t[25]!==a.usage.totalTokens||t[26]!==n.availableCredits||t[27]!==n.connected||t[28]!==n.title||t[29]!==n.usageSummary||t[30]!==r){let e=new Intl.NumberFormat(r);v=n.usageSummary.replace(`{{tokens}}`,e.format(a.usage.totalTokens)).replace(`{{credits}}`,e.format(a.usage.chargedCredits)).replace(`{{requests}}`,e.format(a.usage.requests)),_=`rounded-2xl border border-edge-subtle bg-surface-panel/40 p-5`,g=`flex flex-col gap-5 sm:flex-row sm:items-start sm:justify-between`,f=`min-w-0 flex-1`;let i;t[39]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,$.jsx)($e,{className:`size-4 text-accent-fg`,"aria-hidden":!0}),t[39]=i):i=t[39];let o;t[40]===n.title?o=t[41]:(o=(0,$.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:n.title}),t[40]=n.title,t[41]=o);let s;t[42]===n.connected?s=t[43]:(s=(0,$.jsx)(`span`,{className:`rounded-full bg-emerald-500/10 px-2 py-0.5 text-xs font-medium text-emerald-700 dark:text-emerald-300`,children:n.connected}),t[42]=n.connected,t[43]=s),t[44]!==o||t[45]!==s?(p=(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[i,o,s]}),t[44]=o,t[45]=s,t[46]=p):p=t[46],t[47]===n.availableCredits?h=t[48]:(h=(0,$.jsx)(`p`,{className:`mt-5 text-xs font-medium text-fg-subtle`,children:n.availableCredits}),t[47]=n.availableCredits,t[48]=h),u=`mt-1 text-3xl font-semibold tracking-tight text-fg`,d=e.format(a.balance.credits),t[22]=a.balance.credits,t[23]=a.usage.chargedCredits,t[24]=a.usage.requests,t[25]=a.usage.totalTokens,t[26]=n.availableCredits,t[27]=n.connected,t[28]=n.title,t[29]=n.usageSummary,t[30]=r,t[31]=u,t[32]=d,t[33]=f,t[34]=p,t[35]=h,t[36]=g,t[37]=_,t[38]=v}else u=t[31],d=t[32],f=t[33],p=t[34],h=t[35],g=t[36],_=t[37],v=t[38];let y;t[49]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,$.jsx)(`span`,{className:`ml-2 text-sm font-medium text-fg-muted`,children:`credits`}),t[49]=y):y=t[49];let b;t[50]!==u||t[51]!==d?(b=(0,$.jsxs)(`p`,{className:u,children:[d,y]}),t[50]=u,t[51]=d,t[52]=b):b=t[52];let x;t[53]!==a.balance.credits||t[54]!==n.zeroBalance?(x=a.balance.credits===0?(0,$.jsx)(`p`,{className:`mt-2 text-sm font-medium text-danger`,children:n.zeroBalance}):null,t[53]=a.balance.credits,t[54]=n.zeroBalance,t[55]=x):x=t[55];let S;t[56]===n.recentUsage?S=t[57]:(S=(0,$.jsx)(`p`,{className:`mt-5 text-xs font-medium text-fg-subtle`,children:n.recentUsage}),t[56]=n.recentUsage,t[57]=S);let w;t[58]===v?w=t[59]:(w=(0,$.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:v}),t[58]=v,t[59]=w);let T;t[60]!==a.balance.updatedAt||t[61]!==n.updatedAt||t[62]!==r?(T=n.updatedAt.replace(`{{time}}`,new Date(a.balance.updatedAt).toLocaleString(r)),t[60]=a.balance.updatedAt,t[61]=n.updatedAt,t[62]=r,t[63]=T):T=t[63];let E;t[64]===T?E=t[65]:(E=(0,$.jsx)(`p`,{className:`mt-2 text-xs text-fg-subtle`,children:T}),t[64]=T,t[65]=E);let D;t[66]!==b||t[67]!==x||t[68]!==S||t[69]!==w||t[70]!==E||t[71]!==f||t[72]!==p||t[73]!==h?(D=(0,$.jsxs)(`div`,{className:f,children:[p,h,b,x,S,w,E]}),t[66]=b,t[67]=x,t[68]=S,t[69]=w,t[70]=E,t[71]=f,t[72]=p,t[73]=h,t[74]=D):D=t[74];let O;t[75]===Symbol.for(`react.memo_cache_sentinel`)?(O=(0,$.jsx)(m,{className:`size-3.5`,"aria-hidden":!0}),t[75]=O):O=t[75];let k;t[76]!==a.links.purchase||t[77]!==n.purchase?(k=(0,$.jsx)(P,{asChild:!0,variant:`primary`,children:(0,$.jsxs)(`a`,{href:a.links.purchase,target:`_blank`,rel:`noreferrer`,children:[n.purchase,O]})}),t[76]=a.links.purchase,t[77]=n.purchase,t[78]=k):k=t[78];let A;t[79]===Symbol.for(`react.memo_cache_sentinel`)?(A=(0,$.jsx)(m,{className:`size-3.5`,"aria-hidden":!0}),t[79]=A):A=t[79];let j;t[80]!==a.links.details||t[81]!==n.details?(j=(0,$.jsx)(P,{asChild:!0,variant:`secondary`,children:(0,$.jsxs)(`a`,{href:a.links.details,target:`_blank`,rel:`noreferrer`,children:[n.details,A]})}),t[80]=a.links.details,t[81]=n.details,t[82]=j):j=t[82];let M;t[83]!==k||t[84]!==j?(M=(0,$.jsxs)(`div`,{className:`flex shrink-0 flex-wrap gap-2`,children:[k,j]}),t[83]=k,t[84]=j,t[85]=M):M=t[85];let F;t[86]!==D||t[87]!==M||t[88]!==g?(F=(0,$.jsxs)(`div`,{className:g,children:[D,M]}),t[86]=D,t[87]=M,t[88]=g,t[89]=F):F=t[89];let I;return t[90]!==F||t[91]!==_?(I=(0,$.jsx)(`section`,{className:_,children:F}),t[90]=F,t[91]=_,t[92]=I):I=t[92],I}function Yr(e){return e.language}function Xr(e){return He.includes(e)}function Zr(){let e=(0,Z.c)(69),t=C(ei),n;e[0]===t?n=e[1]:(n=T(t),e[0]=t,e[1]=n);let r=n,i=r.capabilitiesSettings,u=a(),[d,f]=o(),p;if(e[2]!==d){let t=d.get(`returnTo`);p=t?.startsWith(`/chat/`)?t:null,e[2]=d,e[3]=p}else p=e[3];let m=p,{capability:h}=s(),[g,_]=(0,Q.useState)(!1),[v,y]=(0,Q.useState)(null),b=Sr(),x;e[4]===b.cards?x=e[5]:(x=b.cards.some($r),e[4]=b.cards,e[5]=x);let S=x,w,E;e[6]!==h||e[7]!==d||e[8]!==f?(w=()=>{if(h!==`models`||d.get(`add`)!==`1`)return;_(!0);let e=new URLSearchParams(d);e.delete(`add`),f(e,{replace:!0})},E=[h,d,f],e[6]=h,e[7]=d,e[8]=f,e[9]=w,e[10]=E):(w=e[9],E=e[10]),(0,Q.useEffect)(w,E);let D;e[11]===i.tabs.models?D=e[12]:(D={id:`models`,icon:ae,label:i.tabs.models},e[11]=i.tabs.models,e[12]=D);let O;e[13]===i.tabs.image?O=e[14]:(O={id:`image`,icon:Je,label:i.tabs.image},e[13]=i.tabs.image,e[14]=O);let k;e[15]!==D||e[16]!==O?(k=[D,O],e[15]=D,e[16]=O,e[17]=k):k=e[17];let A=k,j;e[18]===u?j=e[19]:(j=e=>u(Ne(e)),e[18]=u,e[19]=j);let M=j,N=Qr;if(!Xr(h)){let t;return e[20]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(c,{to:Ne(`models`),replace:!0}),e[20]=t):t=e[20],t}let P=h===`models`||h===`image`,F=h===`voice`?r.nav.settingsVoice:h===`search`?r.nav.settingsSearch:r.nav.settingsModels,I;e[21]===t?I=e[22]:(I=st(t,`configuration`),e[21]=t,e[22]=I);let L;e[23]!==i.docsLink||e[24]!==F||e[25]!==I?(L=(0,$.jsx)(bt,{title:F,docsLink:I,docsLabel:i.docsLink}),e[23]=i.docsLink,e[24]=F,e[25]=I,e[26]=L):L=e[26];let R;e[27]!==h||e[28]!==m||e[29]!==t?(R=h===`voice`&&m?(0,$.jsx)(l,{to:m,className:`text-sm text-accent-fg hover:underline`,children:t===`zh`?`返回对话`:`Return to conversation`}):null,e[27]=h,e[28]=m,e[29]=t,e[30]=R):R=e[30];let z;e[31]!==i.tabsAria||e[32]!==h||e[33]!==P||e[34]!==A||e[35]!==M?(z=P?(0,$.jsx)(Vt,{items:A,activeTab:h,onChange:M,ariaLabel:i.tabsAria,tabIdPrefix:`capability-tab`,panelIdPrefix:`capability-panel`}):null,e[31]=i.tabsAria,e[32]=h,e[33]=P,e[34]=A,e[35]=M,e[36]=z):z=e[36];let B=P?`tabpanel`:void 0,V=`capability-panel-${h}`,H=P?`capability-tab-${h}`:void 0,U;e[37]!==i.connectedProviders||e[38]!==i.xopcCloudAccount||e[39]!==h||e[40]!==t||e[41]!==b||e[42]!==S?(U=h===`models`?(0,$.jsxs)($.Fragment,{children:[S?(0,$.jsx)(Jr,{labels:i.xopcCloudAccount}):null,(0,$.jsx)(Kr,{}),(0,$.jsx)(Yt,{zh:t===`zh`}),(0,$.jsx)(kr,{labels:i.connectedProviders,data:b,onAdd:()=>_(!0),onManage:(e,t)=>y({providerId:e,isCustom:t})})]}):(0,$.jsx)(ti,{section:h}),e[37]=i.connectedProviders,e[38]=i.xopcCloudAccount,e[39]=h,e[40]=t,e[41]=b,e[42]=S,e[43]=U):U=e[43];let W;e[44]!==B||e[45]!==V||e[46]!==H||e[47]!==U?(W=(0,$.jsx)(`div`,{role:B,id:V,"aria-labelledby":H,className:`flex min-w-0 flex-col gap-3 rounded-2xl bg-surface-base px-4 py-5 sm:px-5`,children:U}),e[44]=B,e[45]=V,e[46]=H,e[47]=U,e[48]=W):W=e[48];let G;e[49]!==g||e[50]!==i.addProviderDialog||e[51]!==t||e[52]!==b.builtinRows||e[53]!==b.customConfig?(G=(0,$.jsx)(fr,{open:g,onOpenChange:_,builtinRows:b.builtinRows,customConfig:b.customConfig,labels:i.addProviderDialog,language:t,onSaved:N}),e[49]=g,e[50]=i.addProviderDialog,e[51]=t,e[52]=b.builtinRows,e[53]=b.customConfig,e[54]=G):G=e[54];let K;e[55]!==i.manageProviderDialog||e[56]!==t||e[57]!==v||e[58]!==b.allModels||e[59]!==b.builtinRows||e[60]!==b.customConfig?(K=v?(0,$.jsx)(Br,{open:!0,onOpenChange:e=>{e||y(null)},providerId:v.providerId,isCustom:v.isCustom,builtinRows:b.builtinRows,customConfig:b.customConfig,allModels:b.allModels,labels:i.manageProviderDialog,language:t,onSaved:N}):null,e[55]=i.manageProviderDialog,e[56]=t,e[57]=v,e[58]=b.allModels,e[59]=b.builtinRows,e[60]=b.customConfig,e[61]=K):K=e[61];let q;return e[62]!==L||e[63]!==R||e[64]!==z||e[65]!==W||e[66]!==G||e[67]!==K?(q=(0,$.jsxs)(xt,{children:[L,R,z,W,G,K]}),e[62]=L,e[63]=R,e[64]=z,e[65]=W,e[66]=G,e[67]=K,e[68]=q):q=e[68],q}function Qr(){le()}function $r(e){return e.id===`xopc-cloud`&&!e.isCustom}function ei(e){return e.language}function ti(e){let t=(0,Z.c)(3),{section:n}=e;switch(n){case`models`:return null;case`image`:{let e;return t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(fn,{}),t[0]=e):e=t[0],e}case`voice`:{let e;return t[1]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(zn,{}),t[1]=e):e=t[1],e}case`search`:{let e;return t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(or,{}),t[2]=e):e=t[2],e}}}export{Zr as CapabilitiesSettingsPanel};