@xopcai/xopc 0.0.371 → 0.0.373

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 (206) hide show
  1. package/dist/browser-ext/manifest.json +1 -1
  2. package/dist/extensions/telegram/xopc.extension.json +1 -1
  3. package/dist/gateway/static/root/assets/{activity-store-BQ3PMp2q.js → activity-store-BeYLqqr8.js} +1 -1
  4. package/dist/gateway/static/root/assets/{agent-avatar-dicebear-C8MqXy6W.js → agent-avatar-dicebear--kDkSTqC.js} +1 -1
  5. package/dist/gateway/static/root/assets/agent-defaults-settings-panel-z4_2-Kn2.js +1 -0
  6. package/dist/gateway/static/root/assets/{agent-plugin-dialog-BrysdA6F.js → agent-plugin-dialog-BYndK83K.js} +1 -1
  7. package/dist/gateway/static/root/assets/{agents-BJRyMNx2.js → agents-CVo96cx1.js} +3 -3
  8. package/dist/gateway/static/root/assets/{agents-admin-api-HBZvVyzF.js → agents-admin-api-B4tgTbWG.js} +1 -1
  9. package/dist/gateway/static/root/assets/{app-management-settings-panel-Bi02swpZ.js → app-management-settings-panel-D9oOJKiH.js} +1 -1
  10. package/dist/gateway/static/root/assets/{appearance-settings-rr0qirDm.js → appearance-settings-B0-8Cdyv.js} +1 -1
  11. package/dist/gateway/static/root/assets/{apps-page-Sz3wl3lV.js → apps-page-DasVc6i4.js} +1 -1
  12. package/dist/gateway/static/root/assets/{archive-plugin-BO3I9zRP.js → archive-plugin-bI9OLnXj.js} +1 -1
  13. package/dist/gateway/static/root/assets/{automations-page-DqdbP0hD.js → automations-page-BlCNqy2i.js} +1 -1
  14. package/dist/gateway/static/root/assets/{automations-workspace-CxgKlA5d.js → automations-workspace-C8ipDP05.js} +1 -1
  15. package/dist/gateway/static/root/assets/{binary-plugins-gFD7vH9R.js → binary-plugins-dOwLzjeH.js} +1 -1
  16. package/dist/gateway/static/root/assets/{block-editor-CfVR1zGa.js → block-editor-Cktlez6g.js} +1 -1
  17. package/dist/gateway/static/root/assets/{browser-automation-inputs-DxRoKFun.js → browser-automation-inputs-i7h1Svpf.js} +1 -1
  18. package/dist/gateway/static/root/assets/{browser-automations-page-DeYnh3mY.js → browser-automations-page-KRfDl8ej.js} +1 -1
  19. package/dist/gateway/static/root/assets/{browser-settings-page-DDZvlGCD.js → browser-settings-page-BraQ4wnh.js} +1 -1
  20. package/dist/gateway/static/root/assets/{capabilities-CY4SiHcP.js → capabilities-CquUV0DP.js} +1 -1
  21. package/dist/gateway/static/root/assets/{capabilities-gjQtMhKu.js → capabilities-D4KFLtqM.js} +1 -1
  22. package/dist/gateway/static/root/assets/{capabilities-page-Bl6PZqx3.js → capabilities-page-B3m8xGzd.js} +2 -2
  23. package/dist/gateway/static/root/assets/{capabilities-settings-panel-B-MM4LJA.js → capabilities-settings-panel-VQ4fHuBV.js} +6 -6
  24. package/dist/gateway/static/root/assets/{capability-header-actions-CAiY7HK1.js → capability-header-actions-f5Ido4Eg.js} +1 -1
  25. package/dist/gateway/static/root/assets/{channels-D1_fDkhu.js → channels-N4Vc2nEG.js} +1 -1
  26. package/dist/gateway/static/root/assets/{chat-terminal-dock-D6slpF2a.js → chat-terminal-dock-BwvTKwsn.js} +1 -1
  27. package/dist/gateway/static/root/assets/cloud-credits-BMYMiiNn.js +1 -0
  28. package/dist/gateway/static/root/assets/{computer-settings-page-D1n_uQHN.js → computer-settings-page-CAwUsKpw.js} +1 -1
  29. package/dist/gateway/static/root/assets/{connector-service-page-FvSCyJzn.js → connector-service-page-C0HuAMuH.js} +1 -1
  30. package/dist/gateway/static/root/assets/{connectors-page-DroD-gQn.js → connectors-page-BcBmW8JT.js} +1 -1
  31. package/dist/gateway/static/root/assets/{date-picker-Bl-HqvGU.js → date-picker-DiQxRpe-.js} +1 -1
  32. package/dist/gateway/static/root/assets/{dependency-picker-DY4nU-HL.js → dependency-picker-Ds0_BJbN.js} +1 -1
  33. package/dist/gateway/static/root/assets/{desktop-pet-_A89B2xw.js → desktop-pet-ZMEOYwrR.js} +1 -1
  34. package/dist/gateway/static/root/assets/{desktop-pet-settings-BJWkGynu.js → desktop-pet-settings-DkyTqD07.js} +1 -1
  35. package/dist/gateway/static/root/assets/{device-pairing-wizard-DJ_ITvkI.js → device-pairing-wizard-CvaI5ZJZ.js} +1 -1
  36. package/dist/gateway/static/root/assets/{directory-picker-path-field-Bj2Cpmxs.js → directory-picker-path-field-Bfv93eK1.js} +1 -1
  37. package/dist/gateway/static/root/assets/{extension-debug-page-BfAtjhoK.js → extension-debug-page-CbgEonkK.js} +1 -1
  38. package/dist/gateway/static/root/assets/{extension-page-BFjc1zDp.js → extension-page-JXKGtIdM.js} +1 -1
  39. package/dist/gateway/static/root/assets/{extension-provider-Br6LXyIj.js → extension-provider-DxlAZ2iy.js} +1 -1
  40. package/dist/gateway/static/root/assets/{extension-settings-page-oAwllsMb.js → extension-settings-page-lsQ2xvbr.js} +1 -1
  41. package/dist/gateway/static/root/assets/{fallback-models-KHd6tw_t.js → fallback-models-7bG0AND1.js} +1 -1
  42. package/dist/gateway/static/root/assets/{gateway-config-swr-7RKqgU_U.js → gateway-config-swr-BoRkBnsw.js} +1 -1
  43. package/dist/gateway/static/root/assets/gateway-realtime-C3WQQY10.js +1 -0
  44. package/dist/gateway/static/root/assets/gateway-realtime-store-cLCDEe4D.js +1 -0
  45. package/dist/gateway/static/root/assets/{gateway-settings-BIyhyiOq.js → gateway-settings-BpbcoPx9.js} +1 -1
  46. package/dist/gateway/static/root/assets/{gateway-startup-retry-jiV5sbEX.js → gateway-startup-retry-TYSQEQcG.js} +1 -1
  47. package/dist/gateway/static/root/assets/{home-page-CEjaIUTF.js → home-page-BxctC0aJ.js} +1 -1
  48. package/dist/gateway/static/root/assets/{image-generation-api-DO4mXb6I.js → image-generation-api-_pKiNfSq.js} +1 -1
  49. package/dist/gateway/static/root/assets/{imports-page-ClFqRiGQ.js → imports-page-Bq8CazCb.js} +1 -1
  50. package/dist/gateway/static/root/assets/{index-GBFmI8im.js → index-B40-KDN8.js} +7 -7
  51. package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-Ca9_GJSQ.js → keyboard-shortcuts-settings-kkAevkl2.js} +1 -1
  52. package/dist/gateway/static/root/assets/{local-app-workbench-page-BaK9zX1-.js → local-app-workbench-page-abLaf1hW.js} +1 -1
  53. package/dist/gateway/static/root/assets/{local-apps-page-1CjSftZ3.js → local-apps-page-nwsnwYjK.js} +1 -1
  54. package/dist/gateway/static/root/assets/{local-session-drafts-pox8evDV.js → local-session-drafts-Cg9RdsNN.js} +1 -1
  55. package/dist/gateway/static/root/assets/{locale-store-COVscAqC.js → locale-store-rWFLl-p4.js} +1 -1
  56. package/dist/gateway/static/root/assets/{logs-page-6joZBbcx.js → logs-page-BEgYS-Xg.js} +1 -1
  57. package/dist/gateway/static/root/assets/{management-settings-Cnubkklb.js → management-settings-D_JQ6_X0.js} +1 -1
  58. package/dist/gateway/static/root/assets/{markdown-view-B_qnAcW2.js → markdown-view-BHFFusQs.js} +1 -1
  59. package/dist/gateway/static/root/assets/{media-plugins-C0Pc-wSY.js → media-plugins-BVPTMWJI.js} +1 -1
  60. package/dist/gateway/static/root/assets/messages-C1SUo4gG.js +3 -0
  61. package/dist/gateway/static/root/assets/models-hub-cache-Jj8dvYcv.js +1 -0
  62. package/dist/gateway/static/root/assets/{note-detail-panel-B6DHbMzT.js → note-detail-panel-CCnfurBR.js} +3 -3
  63. package/dist/gateway/static/root/assets/{notes-api-sBgBcyLW.js → notes-api-CSLVCZBn.js} +1 -1
  64. package/dist/gateway/static/root/assets/{notes-page-CGZkIKdi.js → notes-page-D9u_znxM.js} +1 -1
  65. package/dist/gateway/static/root/assets/{page-context-capture-button-y3QmhTu2.js → page-context-capture-button-BO3FoRej.js} +1 -1
  66. package/dist/gateway/static/root/assets/{personal-page-C_roXCJB.js → personal-page-BJn6UHAF.js} +1 -1
  67. package/dist/gateway/static/root/assets/{product-open-page-CSRYWt0f.js → product-open-page-Dso2_hyl.js} +1 -1
  68. package/dist/gateway/static/root/assets/{product-preview-content-DuOML6gs.js → product-preview-content-CkvVb3EA.js} +1 -1
  69. package/dist/gateway/static/root/assets/{project-detail-page-v7xtnvha.js → project-detail-page-UjrrzE3H.js} +1 -1
  70. package/dist/gateway/static/root/assets/{projects-page-BuJCBT6n.js → projects-page-C1h63P2M.js} +1 -1
  71. package/dist/gateway/static/root/assets/{registry-api-Bh9UBb-f.js → registry-api-CoMBYjHD.js} +1 -1
  72. package/dist/gateway/static/root/assets/{remote-access-hub-DpHnyBnG.js → remote-access-hub-BJifH8AB.js} +1 -1
  73. package/dist/gateway/static/root/assets/{runtime-tools-settings-panel-DTMTL0hy.js → runtime-tools-settings-panel-vG1wqcEb.js} +1 -1
  74. package/dist/gateway/static/root/assets/{scenes-page-B0JqO_fM.js → scenes-page-CwoAoYMX.js} +1 -1
  75. package/dist/gateway/static/root/assets/{schema-form-g4z7GH4W.js → schema-form-BIsHdyz7.js} +1 -1
  76. package/dist/gateway/static/root/assets/{send-session-input-BW40VHiL.js → send-session-input-CLhR1uEp.js} +1 -1
  77. package/dist/gateway/static/root/assets/{session-api-yjpEz4pP.js → session-api-u_4_kFQt.js} +1 -1
  78. package/dist/gateway/static/root/assets/{session-manager-BqlvrjPE.js → session-manager-B06ZCie_.js} +1 -1
  79. package/dist/gateway/static/root/assets/{sessions-page-CftImbH7.js → sessions-page-BcCLp3yU.js} +1 -1
  80. package/dist/gateway/static/root/assets/settings-advanced-gate-D114UdRI.js +1 -0
  81. package/dist/gateway/static/root/assets/{settings-page-YD-U8BVw.js → settings-page-z9Jlk0BL.js} +1 -1
  82. package/dist/gateway/static/root/assets/{setup-status-panel-q_X3kxw2.js → setup-status-panel-CrpXECqe.js} +1 -1
  83. package/dist/gateway/static/root/assets/{share-link-dialog-HCHM8qnf.js → share-link-dialog-XhiuPKF4.js} +1 -1
  84. package/dist/gateway/static/root/assets/{share-preview-page-Ce6FNWt1.js → share-preview-page-Vc0TQuZ8.js} +1 -1
  85. package/dist/gateway/static/root/assets/{shares-api-c0dfWz6h.js → shares-api-BVSb1vh4.js} +1 -1
  86. package/dist/gateway/static/root/assets/{shares-settings-KHRg_-03.js → shares-settings-D9XpTJXP.js} +1 -1
  87. package/dist/gateway/static/root/assets/{skill-api-BpqDMkNB.js → skill-api-DtPOf1aW.js} +1 -1
  88. package/dist/gateway/static/root/assets/{skill-reload-api-Ge5XymHa.js → skill-reload-api-BsLx_FXd.js} +1 -1
  89. package/dist/gateway/static/root/assets/{skills-page-Bnfn51ks.js → skills-page-Bq9-2b9U.js} +1 -1
  90. package/dist/gateway/static/root/assets/{system-settings-panel-CncvC2CI.js → system-settings-panel-P7T729uD.js} +1 -1
  91. package/dist/gateway/static/root/assets/{task-detail-page-BVJKdnMC.js → task-detail-page-CsB9AFx6.js} +1 -1
  92. package/dist/gateway/static/root/assets/{task-expandable-content-hYcgCEE3.js → task-expandable-content-DxeBTJvh.js} +1 -1
  93. package/dist/gateway/static/root/assets/{theme-store-BOfCKgl6.js → theme-store-KcQhCg1-.js} +1 -1
  94. package/dist/gateway/static/root/assets/{tracing-settings-page-DDWFXcST.js → tracing-settings-page-DJRAP3nb.js} +1 -1
  95. package/dist/gateway/static/root/assets/{tunnel-api-g7etuoaT.js → tunnel-api-CuowqIZ7.js} +1 -1
  96. package/dist/gateway/static/root/assets/usage-page-avX3msoZ.js +1 -0
  97. package/dist/gateway/static/root/assets/{use-autosave-CSckcjFx.js → use-autosave-C-IWxbzm.js} +1 -1
  98. package/dist/gateway/static/root/assets/{use-composer-attachments-DJya1hIL.js → use-composer-attachments-Dxphaxk-.js} +1 -1
  99. package/dist/gateway/static/root/assets/{use-file-preview-expanded-C5ONO7sF.js → use-file-preview-expanded-Du37Gofn.js} +2 -2
  100. package/dist/gateway/static/root/assets/{user-model-page-jr986ucl.js → user-model-page-DGDBWw7P.js} +1 -1
  101. package/dist/gateway/static/root/assets/{voice-api-key-field-GEw5x2fU.js → voice-api-key-field-7BImy8Jc.js} +1 -1
  102. package/dist/gateway/static/root/assets/{voice-config-api-3yyVwXln.js → voice-config-api-6MINytQl.js} +1 -1
  103. package/dist/gateway/static/root/assets/{work-discovery-overlay-CC3mr7tX.js → work-discovery-overlay-BgJNz2tH.js} +1 -1
  104. package/dist/gateway/static/root/assets/{workflow-run-setup-panel-CqpXZJxs.js → workflow-run-setup-panel-1I2q2J_U.js} +1 -1
  105. package/dist/gateway/static/root/assets/{workflows-page-DOk6tBbK.js → workflows-page-DhJl9pnO.js} +1 -1
  106. package/dist/gateway/static/root/assets/{workspace-api-WhbMvdBE.js → workspace-api-CXiyhTwv.js} +2 -2
  107. package/dist/gateway/static/root/assets/xopc-cloud-account-card-CnPBP1V_.js +1 -0
  108. package/dist/gateway/static/root/index.html +26 -26
  109. package/dist/package.js +1 -1
  110. package/dist/packages/endpoint-tools-protocol/src/index.js +4 -110
  111. package/dist/packages/endpoint-tools-protocol/src/personal.js +2 -2
  112. package/dist/packages/endpoint-tools-protocol/src/shared-schemas.js +116 -0
  113. package/dist/packages/gateway-contract/src/cloud-credits.js +80 -0
  114. package/dist/packages/gateway-contract/src/index.js +2 -0
  115. package/dist/src/agent/agent-manager.js +4 -4
  116. package/dist/src/agent/background-review/run-background-review.js +1 -1
  117. package/dist/src/agent/client-error-format.d.ts +1 -1
  118. package/dist/src/agent/client-error-format.js +7 -0
  119. package/dist/src/agent/embedded/model-runtime.js +1 -1
  120. package/dist/src/agent/embedded/run-for-session.js +2 -2
  121. package/dist/src/agent/embedded/run-turn.js +40 -4
  122. package/dist/src/agent/embedded/xopc-stream-bridge.js +18 -0
  123. package/dist/src/agent/image/generation/openai-images-provider.d.ts +2 -1
  124. package/dist/src/agent/image/generation/openai-images-provider.js +13 -7
  125. package/dist/src/agent/image/generation/providers/xopc-cloud.js +14 -2
  126. package/dist/src/agent/image/tool-model-config.js +1 -1
  127. package/dist/src/agent/service.js +3 -3
  128. package/dist/src/agent/session/session-inspector.js +1 -1
  129. package/dist/src/agent/tasks/task-judge-service.js +3 -3
  130. package/dist/src/agent-config/schema.d.ts +4 -0
  131. package/dist/src/agent-config/schema.js +1 -0
  132. package/dist/src/ai-assist/text-assist.js +1 -1
  133. package/dist/src/auth/credentials.js +2 -2
  134. package/dist/src/auth/model-credential-store.js +1 -1
  135. package/dist/src/auth/sync-provider-auth.js +1 -1
  136. package/dist/src/chat-commands/builtins/config.js +1 -1
  137. package/dist/src/cli/commands/doctor/checks/database-schema.js +1 -1
  138. package/dist/src/cli/commands/doctor/checks/image-providers.js +1 -1
  139. package/dist/src/cli/commands/doctor/checks/provider-auth.js +1 -1
  140. package/dist/src/cli/commands/models.js +42 -1
  141. package/dist/src/cli/commands/onboard/model.js +3 -3
  142. package/dist/src/computer/runtime.js +4 -1
  143. package/dist/src/config/index.js +3 -3
  144. package/dist/src/config/loader.js +1 -1
  145. package/dist/src/config/models-json.js +2 -2
  146. package/dist/src/endpoint-tools/policy.js +2 -1
  147. package/dist/src/extensions/activation-context.js +1 -1
  148. package/dist/src/gateway/hono/lib/config-payload.d.ts +1 -0
  149. package/dist/src/gateway/hono/lib/config-payload.js +2 -2
  150. package/dist/src/gateway/hono/routes/config-patch/misc.js +1 -1
  151. package/dist/src/gateway/hono/routes/models.js +4 -4
  152. package/dist/src/gateway/hono/routes/observability.js +1 -1
  153. package/dist/src/gateway/hono/routes/usage.js +15 -5
  154. package/dist/src/gateway/hono/routes/voice.js +1 -1
  155. package/dist/src/gateway/service/config-coordinator.js +1 -1
  156. package/dist/src/gateway/service/session-command-service.js +1 -1
  157. package/dist/src/gateway/service.js +4 -4
  158. package/dist/src/home-intelligence/generator.js +1 -1
  159. package/dist/src/notes/service.js +1 -1
  160. package/dist/src/observability/runtime.js +1 -1
  161. package/dist/src/personal-agent/proactivity/service.js +2 -2
  162. package/dist/src/personal-agent/reply-composer.js +2 -2
  163. package/dist/src/platform/client.d.ts +1 -1
  164. package/dist/src/platform/contracts.d.ts +1 -1
  165. package/dist/src/platform/index.js +1 -1
  166. package/dist/src/providers/index.js +4 -4
  167. package/dist/src/providers/model-call.js +15 -1
  168. package/dist/src/providers/model-registry.js +2 -2
  169. package/dist/src/providers/provider-auth-service.js +1 -1
  170. package/dist/src/providers/provider-disconnect-core.js +1 -1
  171. package/dist/src/providers/register-runtime-providers.js +1 -1
  172. package/dist/src/providers/xopc-cloud-account-service.d.ts +7 -23
  173. package/dist/src/providers/xopc-cloud-account-service.js +49 -29
  174. package/dist/src/providers/xopc-cloud-catalog-coordinator.js +1 -1
  175. package/dist/src/providers/xopc-cloud-credit-budget.d.ts +14 -0
  176. package/dist/src/providers/xopc-cloud-credit-budget.js +61 -0
  177. package/dist/src/storage/sqlite/ai-usage-repository.d.ts +9 -0
  178. package/dist/src/storage/sqlite/ai-usage-repository.js +94 -5
  179. package/dist/src/storage/sqlite/migrations/242_cloud_usage_receipts.sql +5 -0
  180. package/dist/src/storage/sqlite/migrations/runner.d.ts +1 -1
  181. package/dist/src/storage/sqlite/migrations/runner.js +3 -3
  182. package/dist/src/storage/sqlite/schema.js +1 -1
  183. package/dist/src/tasks/task-main-update-decision-service.js +2 -2
  184. package/dist/src/tui/backends/embedded-backend.js +1 -1
  185. package/dist/src/tui/tui.js +1 -1
  186. package/dist/src/usage/cloud-capability.d.ts +2 -0
  187. package/dist/src/usage/cloud-capability.js +34 -0
  188. package/dist/src/usage/cloud-receipts.d.ts +10 -0
  189. package/dist/src/usage/cloud-receipts.js +55 -0
  190. package/dist/src/usage/cost.js +1 -0
  191. package/dist/src/usage/recorder.js +3 -1
  192. package/dist/src/usage/scenario-registry.js +15 -0
  193. package/dist/src/voice/realtime/runtime.js +27 -22
  194. package/dist/src/voice/stt/providers/xopc-cloud-transcription.js +28 -14
  195. package/dist/src/voice/tts/providers/xopc-cloud-speech.js +39 -29
  196. package/dist/src/voice/tts/speech-provider-types.d.ts +1 -0
  197. package/dist/src/work-discovery/service.js +2 -2
  198. package/dist/src/workflows/service/workflow-run-service.js +1 -1
  199. package/package.json +4 -4
  200. package/dist/gateway/static/root/assets/agent-defaults-settings-panel-BLaL4law.js +0 -1
  201. package/dist/gateway/static/root/assets/gateway-realtime-F6D4A7N5.js +0 -1
  202. package/dist/gateway/static/root/assets/gateway-realtime-store-BheKaO6d.js +0 -1
  203. package/dist/gateway/static/root/assets/messages-Bb2GK-Nj.js +0 -3
  204. package/dist/gateway/static/root/assets/models-hub-cache-DyPPksMP.js +0 -1
  205. package/dist/gateway/static/root/assets/settings-advanced-gate-BkvbSieZ.js +0 -1
  206. package/dist/gateway/static/root/assets/usage-page-Dao1I-5F.js +0 -1
@@ -8,15 +8,15 @@ import { ActivityService } from "../activity/service.js";
8
8
  import { getAgentDefaultModelRef, init_schema } from "../config/schema.js";
9
9
  import { init_session_key, resolveConversationId } from "../routing/session-key.js";
10
10
  import { getDefaultAgentId, init_resolve_route } from "../routing/resolve-route.js";
11
- import { resolveEffectiveAgentProfile } from "../config/agent-profile.js";
12
11
  import { init_providers, resolveModel } from "../providers/index.js";
12
+ import { isLocalModelBaseUrl } from "../providers/model-call.js";
13
+ import { resolveEffectiveAgentProfile } from "../config/agent-profile.js";
13
14
  import { writeKnowledgeItem } from "../knowledge-memory/repository.js";
14
15
  import "../knowledge-memory/index.js";
15
16
  import { linkAssertionEvidence, reconcileAssertion } from "../user-model/repository.js";
16
17
  import { createPriorityWindow, createUserGoal } from "../user-model/goals.js";
17
18
  import "../user-model/index.js";
18
19
  import { createWorkDiscoveryRun, getProjectUnderstandingRun, getWorkDiscoveryOnboardingState, getWorkDiscoveryRun, getWorkDiscoveryRunByIdempotencyKey, listPendingProjectUnderstandingRuns, setWorkDiscoveryFeedback, setWorkDiscoveryOnboardingState, updateWorkDiscoveryRun } from "./repository.js";
19
- import { isLocalModelBaseUrl } from "../providers/model-call.js";
20
20
  import { createUnderstandingSourceRun, getUnderstandingSourceGrant, getUnderstandingSourceRun, updateUnderstandingSourceGrantCheckpoint, updateUnderstandingSourceGrantPolicies, updateUnderstandingSourceRun, upsertUnderstandingSourceGrant } from "../user-context/sources/repository.js";
21
21
  import { allowsRemoteSourceProcessing } from "../user-context/sources/processing-policy.js";
22
22
  import { analyzeUnderstandingSources, analyzeWorkContext, workDiscoveryResultMarkdown } from "./analyzer.js";
@@ -2,8 +2,8 @@ import { TaskRepository, init_task_repository } from "../../tasks/task-repositor
2
2
  import { TaskRunRepository, init_task_run_repository } from "../../tasks/task-run-repository.js";
3
3
  import { init_conversation_repository, resolveRoutedConversation } from "../../storage/sqlite/conversation-repository.js";
4
4
  import { getDefaultAgentId, init_resolve_route } from "../../routing/resolve-route.js";
5
- import { extractProfileAgentId, resolveEffectiveAgentProfile, resolveEffectiveAgentProfileForSession } from "../../config/agent-profile.js";
6
5
  import { init_providers, resolveModel } from "../../providers/index.js";
6
+ import { extractProfileAgentId, resolveEffectiveAgentProfile, resolveEffectiveAgentProfileForSession } from "../../config/agent-profile.js";
7
7
  import { getProjectWorkspacePathForSession } from "../../projects/workspace.js";
8
8
  import { TaskConversationRepository } from "../../tasks/task-conversation-repository.js";
9
9
  import { automationEventPublisher, getAutomationEventForRun } from "../../automations/events/event-repository.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xopcai/xopc",
3
- "version": "0.0.371",
3
+ "version": "0.0.373",
4
4
  "description": "Local-first personal AI with Ada, task delegation, files, projects, workflows, and automations. Use cloud or local models.",
5
5
  "type": "module",
6
6
  "main": "dist/src/index.js",
@@ -167,12 +167,12 @@
167
167
  "vue": "^3.5.35",
168
168
  "@xopcai/browser-control-contract": "0.1.0",
169
169
  "@xopcai/computer-control-contract": "0.1.0",
170
+ "@xopcai/endpoint-tools-client": "0.0.0",
170
171
  "@xopcai/endpoint-tools-protocol": "0.0.0",
171
172
  "@xopcai/gateway-contract": "0.0.0",
172
- "@xopcai/endpoint-tools-client": "0.0.0",
173
173
  "@xopcai/image-providers": "0.1.0",
174
- "@xopcai/realtime-protocol": "0.0.0",
175
- "@xopcai/realtime-client": "0.0.0"
174
+ "@xopcai/realtime-client": "0.0.0",
175
+ "@xopcai/realtime-protocol": "0.0.0"
176
176
  },
177
177
  "scripts": {
178
178
  "generate:device-tools": "tsx scripts/devices/generate-mobile-tools.mts",
@@ -1 +0,0 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./chunk-KS7C4IRE-BMYIfy9x.js";import{t as a}from"./popover-select-BgSdSbCL.js";import{t as o}from"./circle-check-C23XjkUj.js";import{t as s}from"./mic-CuUb7zc-.js";import{t as c}from"./search-DA7gz22f.js";import{t as l}from"./sparkles-DHlfQFAF.js";import{t as u}from"./cn-JdwAhgNB.js";import{c as d,n as f}from"./locale-store-COVscAqC.js";import{i as ee}from"./vendor-swr-BIWyz7Rc.js";import{t as te}from"./button-CS04eWY9.js";import{r as p}from"./gateway-config-swr-7RKqgU_U.js";import{n as m,t as h}from"./registry-api-Bh9UBb-f.js";import{t as g}from"./skeleton-BwbyijEw.js";import{t as _}from"./electron-env-Dit0bHgy.js";import{Fc as v,Ko as y,Ks as b,Lc as x,Po as S,Qr as C,Yr as w,_n as T,gn as E,jo as D,v as O,ws as ne}from"./index-GBFmI8im.js";import{n as k,r as A}from"./settings-page-layout-X1x-2Cp9.js";import{n as j,t as M}from"./use-autosave-CSckcjFx.js";import{s as N}from"./voice-config-api-3yyVwXln.js";import{t as re}from"./fallback-models-KHd6tw_t.js";import{r as ie}from"./image-generation-api-DO4mXb6I.js";var ae=e(t(),1),oe=n(),P=r(),F={"xopc-cloud":`XOPC Cloud`,alibaba:`Alibaba Cloud`,edge:`Microsoft Edge`,groq:`Groq`,minimax:`MiniMax`,openai:`OpenAI`};function I(e,t,n){let r=e?.[t]?.[n];return typeof r==`string`&&r.trim()?r.trim():void 0}function L(e){return F[e]??e}function R(e){let t=(0,oe.c)(17),{icon:n,label:r,enabled:i,details:a,zh:o}=e,s;t[0]===n?s=t[1]:(s=(0,P.jsx)(`div`,{className:`rounded-lg bg-accent/10 p-2 text-accent`,children:(0,P.jsx)(n,{className:`size-4`,"aria-hidden":!0})}),t[0]=n,t[1]=s);let c;t[2]===r?c=t[3]:(c=(0,P.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:r}),t[2]=r,t[3]=c);let l=i?o?`已启用`:`On`:o?`已关闭`:`Off`,u;t[4]===l?u=t[5]:(u=(0,P.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5 text-[10px] font-medium text-fg-muted`,children:l}),t[4]=l,t[5]=u);let d;t[6]!==c||t[7]!==u?(d=(0,P.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[c,u]}),t[6]=c,t[7]=u,t[8]=d):d=t[8];let f=i?a:o?`不处理语音`:`Voice processing is disabled`,ee;t[9]===f?ee=t[10]:(ee=(0,P.jsx)(`p`,{className:`mt-1 truncate text-xs text-fg-muted`,children:f}),t[9]=f,t[10]=ee);let te;t[11]!==d||t[12]!==ee?(te=(0,P.jsxs)(`div`,{className:`min-w-0`,children:[d,ee]}),t[11]=d,t[12]=ee,t[13]=te):te=t[13];let p;return t[14]!==s||t[15]!==te?(p=(0,P.jsxs)(`div`,{className:`flex items-start gap-3 rounded-xl bg-surface-base/55 p-4`,children:[s,te]}),t[14]=s,t[15]=te,t[16]=p):p=t[16],p}function z(e){let t=(0,oe.c)(27),{zh:n}=e,{data:r,error:a,isLoading:o}=p(!0),c=r?.payload?.config,l,u,d;if(t[0]!==c){d=c===void 0?void 0:N(c);let e=d?I(d.stt.providers,d.stt.provider,`model`):void 0,n=d?I(d.tts.providers,d.tts.provider,`model`):void 0,r=d?I(d.tts.providers,d.tts.provider,`voice`):void 0;l=d?[L(d.stt.provider),e].filter(Boolean).join(` · `):void 0,u=d?[L(d.tts.provider),n,r].filter(Boolean).join(` · `):void 0,t[0]=c,t[1]=l,t[2]=u,t[3]=d}else l=t[1],u=t[2],d=t[3];let f=u,ee=n?`语音能力`:`Voice capabilities`,m;t[4]===ee?m=t[5]:(m=(0,P.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:ee}),t[4]=ee,t[5]=m);let h=n?`语音识别和朗读由所有智能体共用,在语音设置中统一管理。`:`STT and TTS are shared by every agent and managed in global voice settings.`,_;t[6]===h?_=t[7]:(_=(0,P.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:h}),t[6]=h,t[7]=_);let y;t[8]!==m||t[9]!==_?(y=(0,P.jsxs)(`div`,{children:[m,_]}),t[8]=m,t[9]=_,t[10]=y):y=t[10];let b=n?`管理语音设置`:`Manage voice settings`,S;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(S=(0,P.jsx)(x,{className:`size-4`,"aria-hidden":!0}),t[11]=S):S=t[11];let C;t[12]===b?C=t[13]:(C=(0,P.jsx)(te,{asChild:!0,variant:`secondary`,className:`shrink-0`,children:(0,P.jsxs)(i,{to:`/settings/capabilities/voice`,children:[b,S]})}),t[12]=b,t[13]=C);let w;t[14]!==y||t[15]!==C?(w=(0,P.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[y,C]}),t[14]=y,t[15]=C,t[16]=w):w=t[16];let T;t[17]!==a||t[18]!==o||t[19]!==l||t[20]!==f||t[21]!==d||t[22]!==n?(T=o||!d?a?(0,P.jsx)(`p`,{className:`mt-4 rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:n?`暂时无法读取语音配置。`:`Voice settings could not be loaded.`}):(0,P.jsxs)(`div`,{className:`mt-4 grid gap-3 sm:grid-cols-2`,children:[(0,P.jsx)(g,{className:`h-20 rounded-xl`}),(0,P.jsx)(g,{className:`h-20 rounded-xl`})]}):(0,P.jsxs)(`div`,{className:`mt-4 grid gap-3 sm:grid-cols-2`,children:[(0,P.jsx)(R,{icon:s,label:n?`语音转文字(STT)`:`Speech to text (STT)`,enabled:d.stt.enabled,details:l,zh:n}),(0,P.jsx)(R,{icon:v,label:n?`文字转语音(TTS)`:`Text to speech (TTS)`,enabled:d.tts.enabled,details:f,zh:n})]}),t[17]=a,t[18]=o,t[19]=l,t[20]=f,t[21]=d,t[22]=n,t[23]=T):T=t[23];let E;return t[24]!==w||t[25]!==T?(E=(0,P.jsxs)(`section`,{className:`rounded-xl bg-surface-hover/20 p-5`,children:[w,T]}),t[24]=w,t[25]=T,t[26]=E):E=t[26],E}var B=[`fast`,`reasoning`,`coding`,`review`,`vision`,`understanding`],V=`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg outline-none focus:border-accent focus:ring-2 focus:ring-accent/15`,H={en:{fast:[`Fast tasks`,`Short, low-latency work`],reasoning:[`Complex reasoning`,`Planning and multi-step analysis`],coding:[`Coding`,`Implementation and debugging`],review:[`Review`,`Critique and verification`],vision:[`Vision`,`Image and visual analysis`],understanding:[`Understanding`,`Long-form content comprehension`]},zh:{fast:[`快速任务`,`简短、低延迟的工作`],reasoning:[`复杂推理`,`规划和多步骤分析`],coding:[`编程`,`实现、调试和代码修改`],review:[`审查`,`检查、批评和验证`],vision:[`视觉任务`,`图片和视觉内容分析`],understanding:[`内容理解`,`长内容阅读和理解`]}};function U(e,t){return{primary:t,fallbacks:e?.fallbacks??[]}}function W(e){let t=(0,oe.c)(121),{draft:n,setDraft:r,zh:i}=e,a;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(a={revalidateOnFocus:!1},t[0]=a):a=t[0];let o=ee(h,m,a),s;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(s={revalidateOnFocus:!1},t[1]=s):s=t[1];let c=ee(`agent-defaults-image-models`,ie,s),l;t[2]===o.data?l=t[3]:(l=o.data??[],t[2]=o.data,t[3]=l);let u=l,d;t[4]===c.data?d=t[5]:(d=c.data??[],t[4]=c.data,t[5]=d);let f;t[6]===d?f=t[7]:(f=d.flatMap(G),t[6]=d,t[7]=f);let p=f,g=i?H.zh:H.en,_;t[8]!==n||t[9]!==r?(_=(e,t)=>{let i={...n.models.intents};t?i[e]=U(i[e],t):delete i[e],r({...n,models:{...n.models,intents:i}})},t[8]=n,t[9]=r,t[10]=_):_=t[10];let v=_,y=i?`默认对话模型`:`Default conversation model`,b;t[11]===y?b=t[12]:(b=(0,P.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:y}),t[11]=y,t[12]=b);let x=i?`大多数对话和没有专用路由的任务都会使用它。`:`Used for most conversations and every task without a dedicated route.`,S;t[13]===x?S=t[14]:(S=(0,P.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:x}),t[13]=x,t[14]=S);let C;t[15]!==S||t[16]!==b?(C=(0,P.jsxs)(`div`,{children:[b,S]}),t[15]=S,t[16]=b,t[17]=C):C=t[17];let T=i?`主模型`:`Primary model`,E;t[18]===T?E=t[19]:(E=(0,P.jsx)(`label`,{className:`block text-xs font-medium text-fg-muted`,children:T}),t[18]=T,t[19]=E);let D=i?`选择模型`:`Select a model`,O=i?`搜索模型或服务商`:`Search models or providers`,ne=i?`没有匹配的模型`:`No matching models`,k=i?`默认对话模型`:`Default conversation model`,A;t[20]!==n||t[21]!==r?(A=e=>r({...n,models:{...n.models,chat:{...n.models.chat,primary:e}}}),t[20]=n,t[21]=r,t[22]=A):A=t[22];let j;t[23]!==n.models.chat.primary||t[24]!==D||t[25]!==O||t[26]!==ne||t[27]!==k||t[28]!==A?(j=(0,P.jsx)(w,{value:n.models.chat.primary,placeholder:D,searchPlaceholder:O,noMatches:ne,showProviderSettingsFooter:!0,contentAlign:`start`,className:`mt-2 w-full`,ariaLabel:k,onChange:A}),t[23]=n.models.chat.primary,t[24]=D,t[25]=O,t[26]=ne,t[27]=k,t[28]=A,t[29]=j):j=t[29];let M;t[30]!==E||t[31]!==j?(M=(0,P.jsxs)(`div`,{className:`mt-5 max-w-xl`,children:[E,j]}),t[30]=E,t[31]=j,t[32]=M):M=t[32];let N;t[33]!==n||t[34]!==r?(N=e=>r({...n,models:{...n.models,chat:{...n.models.chat,fallbacks:e}}}),t[33]=n,t[34]=r,t[35]=N):N=t[35];let ae;t[36]!==n.models.chat.fallbacks||t[37]!==n.models.chat.primary||t[38]!==u||t[39]!==o.error||t[40]!==o.isLoading||t[41]!==N||t[42]!==i?(ae=(0,P.jsx)(`div`,{className:`mt-6 rounded-xl bg-surface-base/45 p-4`,children:(0,P.jsx)(re,{primary:n.models.chat.primary,value:n.models.chat.fallbacks,models:u,loading:o.isLoading,error:o.error,zh:i,onChange:N})}),t[36]=n.models.chat.fallbacks,t[37]=n.models.chat.primary,t[38]=u,t[39]=o.error,t[40]=o.isLoading,t[41]=N,t[42]=i,t[43]=ae):ae=t[43];let F;t[44]!==C||t[45]!==M||t[46]!==ae?(F=(0,P.jsxs)(`section`,{className:`rounded-xl bg-surface-hover/20 p-5`,children:[C,M,ae]}),t[44]=C,t[45]=M,t[46]=ae,t[47]=F):F=t[47];let I=i?`图片能力`:`Image capabilities`,L;t[48]===I?L=t[49]:(L=(0,P.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:I}),t[48]=I,t[49]=L);let R=i?`没有图片任务时可以保持关闭。`:`Leave these off when the agents do not work with images.`,W;t[50]===R?W=t[51]:(W=(0,P.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:R}),t[50]=R,t[51]=W);let K=i?`图片理解模型`:`Image understanding model`,q;t[52]===K?q=t[53]:(q=(0,P.jsx)(`label`,{className:`block text-xs font-medium text-fg-muted`,children:K}),t[52]=K,t[53]=q);let J=n.models.imageUnderstanding?.primary??``,Y=i?`关闭图片理解`:`Image understanding off`,X=i?`搜索视觉模型`:`Search vision models`,se=i?`没有可用的视觉模型`:`No vision models available`,Z=i?`关闭图片理解`:`Image understanding off`,ce=i?`图片理解模型`:`Image understanding model`,le;t[54]!==n||t[55]!==r?(le=e=>{let t={...n.models};e?t.imageUnderstanding=U(t.imageUnderstanding,e):delete t.imageUnderstanding,r({...n,models:t})},t[54]=n,t[55]=r,t[56]=le):le=t[56];let ue;t[57]!==J||t[58]!==Y||t[59]!==X||t[60]!==se||t[61]!==Z||t[62]!==ce||t[63]!==le?(ue=(0,P.jsx)(w,{value:J,placeholder:Y,searchPlaceholder:X,noMatches:se,capabilitiesFilter:`vision`,allowEmpty:!0,emptyLabel:Z,contentAlign:`start`,className:`mt-2 w-full`,ariaLabel:ce,onChange:le}),t[57]=J,t[58]=Y,t[59]=X,t[60]=se,t[61]=Z,t[62]=ce,t[63]=le,t[64]=ue):ue=t[64];let de;t[65]!==q||t[66]!==ue?(de=(0,P.jsxs)(`div`,{children:[q,ue]}),t[65]=q,t[66]=ue,t[67]=de):de=t[67];let fe=i?`图片生成模型`:`Image generation model`,Q;t[68]===fe?Q=t[69]:(Q=(0,P.jsx)(`label`,{className:`block text-xs font-medium text-fg-muted`,children:fe}),t[68]=fe,t[69]=Q);let pe=n.models.imageGeneration?.primary??``,me=i?`关闭图片生成`:`Image generation off`,he=i?`搜索图片模型或服务商`:`Search image models or providers`,ge=i?`没有可用的图片生成模型`:`No image generation models available`,_e=i?`关闭图片生成`:`Image generation off`,ve=i?`图片生成模型`:`Image generation model`,ye;t[70]!==n||t[71]!==r?(ye=e=>{let t={...n.models};e?t.imageGeneration={primary:e,fallbacks:t.imageGeneration?.fallbacks??[],timeoutMs:t.imageGeneration?.timeoutMs,autoProviderFallback:t.imageGeneration?.autoProviderFallback??!0}:delete t.imageGeneration,r({...n,models:t})},t[70]=n,t[71]=r,t[72]=ye):ye=t[72];let $;t[73]!==p||t[74]!==c.error||t[75]!==c.isLoading||t[76]!==pe||t[77]!==me||t[78]!==he||t[79]!==ge||t[80]!==_e||t[81]!==ve||t[82]!==ye?($=(0,P.jsx)(w,{value:pe,models:p,modelsLoading:c.isLoading,modelsError:c.error,placeholder:me,searchPlaceholder:he,noMatches:ge,allowEmpty:!0,emptyLabel:_e,contentAlign:`start`,className:`mt-2 w-full`,ariaLabel:ve,onChange:ye}),t[73]=p,t[74]=c.error,t[75]=c.isLoading,t[76]=pe,t[77]=me,t[78]=he,t[79]=ge,t[80]=_e,t[81]=ve,t[82]=ye,t[83]=$):$=t[83];let be;t[84]!==Q||t[85]!==$?(be=(0,P.jsxs)(`div`,{children:[Q,$]}),t[84]=Q,t[85]=$,t[86]=be):be=t[86];let xe;t[87]!==de||t[88]!==be?(xe=(0,P.jsxs)(`div`,{className:`mt-5 grid gap-5 lg:grid-cols-2`,children:[de,be]}),t[87]=de,t[88]=be,t[89]=xe):xe=t[89];let Se;t[90]!==n||t[91]!==r||t[92]!==i?(Se=n.models.imageGeneration?(0,P.jsxs)(`div`,{className:`mt-5 grid gap-4 rounded-xl bg-surface-base/45 p-4 sm:grid-cols-2`,children:[(0,P.jsxs)(`label`,{className:`block text-xs font-medium text-fg-muted`,children:[i?`生成超时(毫秒)`:`Generation timeout (ms)`,(0,P.jsx)(`input`,{type:`number`,min:1,className:`${V} mt-2`,value:n.models.imageGeneration.timeoutMs??``,onChange:e=>r({...n,models:{...n.models,imageGeneration:{...n.models.imageGeneration,timeoutMs:e.target.value?Number(e.target.value):void 0}}})})]}),(0,P.jsxs)(`div`,{className:`text-xs font-medium text-fg-muted`,children:[(0,P.jsx)(`span`,{children:i?`服务商自动回退`:`Automatic provider fallback`}),(0,P.jsx)(`div`,{className:`mt-1.5 flex rounded-lg bg-surface-panel p-1`,children:[!0,!1].map(e=>(0,P.jsx)(te,{variant:n.models.imageGeneration?.autoProviderFallback===e?`secondary`:`ghost`,className:`flex-1 py-1.5 text-xs`,onClick:()=>r({...n,models:{...n.models,imageGeneration:{...n.models.imageGeneration,autoProviderFallback:e}}}),children:e?i?`开启`:`On`:i?`关闭`:`Off`},String(e)))})]})]}):null,t[90]=n,t[91]=r,t[92]=i,t[93]=Se):Se=t[93];let Ce;t[94]!==L||t[95]!==W||t[96]!==xe||t[97]!==Se?(Ce=(0,P.jsxs)(`section`,{className:`rounded-xl bg-surface-hover/20 p-5`,children:[L,W,xe,Se]}),t[94]=L,t[95]=W,t[96]=xe,t[97]=Se,t[98]=Ce):Ce=t[98];let we;t[99]===i?we=t[100]:(we=(0,P.jsx)(z,{zh:i}),t[99]=i,t[100]=we);let Te=i?`按任务选择模型`:`Route by task`,Ee;t[101]===Te?Ee=t[102]:(Ee=(0,P.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:Te}),t[101]=Te,t[102]=Ee);let De=i?`仅在确实需要不同模型时设置;否则保持“使用默认对话模型”。`:`Set a route only when a task genuinely needs another model; otherwise keep the default.`,Oe;t[103]===De?Oe=t[104]:(Oe=(0,P.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:De}),t[103]=De,t[104]=Oe);let ke;t[105]!==g||t[106]!==n.models.intents||t[107]!==v||t[108]!==i?(ke=B.map(e=>(0,P.jsxs)(`div`,{className:`rounded-xl bg-surface-base/55 p-4`,children:[(0,P.jsxs)(`div`,{className:`mb-3`,children:[(0,P.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:g[e][0]}),(0,P.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:g[e][1]})]}),(0,P.jsx)(w,{value:n.models.intents[e]?.primary??``,placeholder:i?`使用默认对话模型`:`Use default conversation model`,searchPlaceholder:i?`搜索模型或服务商`:`Search models or providers`,noMatches:i?`没有匹配的模型`:`No matching models`,allowEmpty:!0,emptyLabel:i?`使用默认对话模型`:`Use default conversation model`,showProviderInTrigger:!1,contentAlign:`start`,className:`w-full`,ariaLabel:i?`${g[e][0]}模型`:`${g[e][0]} model`,onChange:t=>v(e,t)})]},e)),t[105]=g,t[106]=n.models.intents,t[107]=v,t[108]=i,t[109]=ke):ke=t[109];let Ae;t[110]===ke?Ae=t[111]:(Ae=(0,P.jsx)(`div`,{className:`mt-5 grid gap-3 lg:grid-cols-2`,children:ke}),t[110]=ke,t[111]=Ae);let je;t[112]!==Ee||t[113]!==Oe||t[114]!==Ae?(je=(0,P.jsxs)(`section`,{className:`rounded-xl bg-surface-hover/20 p-5`,children:[Ee,Oe,Ae]}),t[112]=Ee,t[113]=Oe,t[114]=Ae,t[115]=je):je=t[115];let Me;return t[116]!==F||t[117]!==Ce||t[118]!==we||t[119]!==je?(Me=(0,P.jsxs)(`div`,{className:`space-y-5`,children:[F,Ce,we,je]}),t[116]=F,t[117]=Ce,t[118]=we,t[119]=je,t[120]=Me):Me=t[120],Me}function G(e){return e.models.map(t=>({id:`${e.id}/${t}`,name:t,provider:e.label}))}var K=`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg outline-none focus:border-accent focus:ring-2 focus:ring-accent/15`;function q(e){let t=Number.parseInt(e,10);return Number.isFinite(t)&&t>0?t:void 0}function J(e){let t=(0,oe.c)(168),{draft:n,setDraft:r,zh:i}=e,o;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(o={revalidateOnFocus:!1},t[0]=o):o=t[0];let s=ee(`agent-defaults-workflows`,O,o),c;t[1]===s.data?c=t[2]:(c=s.data??[],t[1]=s.data,t[2]=c);let l;t[3]===c?l=t[4]:(l=c.map(Y),t[3]=c,t[4]=l);let d=l,f=n.workflows.allowed===void 0,p;t[5]!==n||t[6]!==r?(p=(e,t)=>{let i=n.workflows.allowed??[],a=t?[...new Set([...i,e])]:i.filter(t=>t!==e);r({...n,workflows:{...n.workflows,allowed:a}})},t[5]=n,t[6]=r,t[7]=p):p=t[7];let m=p,h=n.runtime.codemode?.enabled??!1,g;t[8]!==n||t[9]!==r?(g=e=>r({...n,runtime:{...n.runtime,codemode:{...n.runtime.codemode,enabled:e.target.checked}}}),t[8]=n,t[9]=r,t[10]=g):g=t[10];let _;t[11]!==h||t[12]!==g?(_=(0,P.jsx)(`input`,{type:`checkbox`,checked:h,onChange:g,className:`mt-1 size-4 accent-[var(--color-accent)]`}),t[11]=h,t[12]=g,t[13]=_):_=t[13];let v=i?`Codemode 读取试点`:`Codemode read pilot`,y;t[14]===v?y=t[15]:(y=(0,P.jsx)(`span`,{className:`block text-base font-semibold text-fg`,children:v}),t[14]=v,t[15]=y);let b=i?`允许智能体用脚本组合已授权的读取工具。默认关闭,保留普通工具调用。`:`Let agents combine authorized reads in scripts. Off by default; ordinary tool calls stay available.`,x;t[16]===b?x=t[17]:(x=(0,P.jsx)(`span`,{className:`mt-1 block text-sm text-fg-muted`,children:b}),t[16]=b,t[17]=x);let S;t[18]!==x||t[19]!==y?(S=(0,P.jsxs)(`span`,{children:[y,x]}),t[18]=x,t[19]=y,t[20]=S):S=t[20];let C;t[21]!==S||t[22]!==_?(C=(0,P.jsx)(`section`,{className:`rounded-xl bg-surface-hover/20 p-5`,children:(0,P.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-3`,children:[_,S]})}),t[21]=S,t[22]=_,t[23]=C):C=t[23];let w=i?`执行限制`:`Execution limits`,T;t[24]===w?T=t[25]:(T=(0,P.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:w}),t[24]=w,t[25]=T);let E=i?`为所有智能体设置安全上限;留空时使用系统默认值。`:`Set safe upper bounds for every agent. Empty fields use system defaults.`,D;t[26]===E?D=t[27]:(D=(0,P.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:E}),t[26]=E,t[27]=D);let ne=i?`每次运行最多轮数`:`Maximum turns per run`,k=n.runtime.maxTurns??``,A=i?`系统默认`:`System default`,j;t[28]!==n||t[29]!==r?(j=e=>r({...n,runtime:{...n.runtime,maxTurns:q(e.target.value)}}),t[28]=n,t[29]=r,t[30]=j):j=t[30];let M;t[31]!==k||t[32]!==A||t[33]!==j?(M=(0,P.jsx)(`input`,{type:`number`,min:1,value:k,placeholder:A,onChange:j,className:`${K} mt-2`}),t[31]=k,t[32]=A,t[33]=j,t[34]=M):M=t[34];let N;t[35]!==ne||t[36]!==M?(N=(0,P.jsxs)(`label`,{className:`block text-xs font-medium text-fg-muted`,children:[ne,M]}),t[35]=ne,t[36]=M,t[37]=N):N=t[37];let re=i?`单轮超时(毫秒)`:`Turn timeout (ms)`,ie=n.runtime.timeoutMs??``,ae=i?`系统默认`:`System default`,F;t[38]!==n||t[39]!==r?(F=e=>r({...n,runtime:{...n.runtime,timeoutMs:q(e.target.value)}}),t[38]=n,t[39]=r,t[40]=F):F=t[40];let I;t[41]!==ie||t[42]!==ae||t[43]!==F?(I=(0,P.jsx)(`input`,{type:`number`,min:1,value:ie,placeholder:ae,onChange:F,className:`${K} mt-2`}),t[41]=ie,t[42]=ae,t[43]=F,t[44]=I):I=t[44];let L;t[45]!==re||t[46]!==I?(L=(0,P.jsxs)(`label`,{className:`block text-xs font-medium text-fg-muted`,children:[re,I]}),t[45]=re,t[46]=I,t[47]=L):L=t[47];let R=i?`每轮最多工具失败次数`:`Maximum tool failures per turn`,z=n.runtime.maxToolFailuresPerTurn??``,B=i?`系统默认`:`System default`,V;t[48]!==n||t[49]!==r?(V=e=>r({...n,runtime:{...n.runtime,maxToolFailuresPerTurn:q(e.target.value)}}),t[48]=n,t[49]=r,t[50]=V):V=t[50];let H;t[51]!==z||t[52]!==B||t[53]!==V?(H=(0,P.jsx)(`input`,{type:`number`,min:1,value:z,placeholder:B,onChange:V,className:`${K} mt-2`}),t[51]=z,t[52]=B,t[53]=V,t[54]=H):H=t[54];let U;t[55]!==R||t[56]!==H?(U=(0,P.jsxs)(`label`,{className:`block text-xs font-medium text-fg-muted`,children:[R,H]}),t[55]=R,t[56]=H,t[57]=U):U=t[57];let W;t[58]!==N||t[59]!==L||t[60]!==U?(W=(0,P.jsxs)(`div`,{className:`mt-5 grid gap-4 md:grid-cols-3`,children:[N,L,U]}),t[58]=N,t[59]=L,t[60]=U,t[61]=W):W=t[61];let G;t[62]!==T||t[63]!==D||t[64]!==W?(G=(0,P.jsxs)(`section`,{className:`rounded-xl bg-surface-hover/20 p-5`,children:[T,D,W]}),t[62]=T,t[63]=D,t[64]=W,t[65]=G):G=t[65];let J=i?`提示词缓存`:`Prompt cache`,X;t[66]===J?X=t[67]:(X=(0,P.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:J}),t[66]=J,t[67]=X);let se=i?`复用稳定的上下文以降低响应延迟和模型费用。`:`Reuse stable context to reduce latency and model cost.`,Z;t[68]===se?Z=t[69]:(Z=(0,P.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:se}),t[68]=se,t[69]=Z);let ce=i?`缓存模式`:`Cache mode`,le;t[70]===ce?le=t[71]:(le=(0,P.jsx)(`span`,{children:ce}),t[70]=ce,t[71]=le);let ue;t[72]===Symbol.for(`react.memo_cache_sentinel`)?(ue=[`auto`,`off`],t[72]=ue):ue=t[72];let de;t[73]!==n||t[74]!==r||t[75]!==i?(de=(0,P.jsx)(`div`,{className:`mt-1.5 flex rounded-lg bg-surface-panel p-1`,children:ue.map(e=>(0,P.jsx)(te,{variant:n.runtime.promptCache?.mode===e?`secondary`:`ghost`,className:`flex-1 py-1.5 text-xs`,onClick:()=>r({...n,runtime:{...n.runtime,promptCache:{mode:e,lifetime:n.runtime.promptCache?.lifetime??`short`}}}),children:e===`auto`?i?`自动`:`Automatic`:i?`关闭`:`Off`},e))}),t[73]=n,t[74]=r,t[75]=i,t[76]=de):de=t[76];let fe;t[77]!==le||t[78]!==de?(fe=(0,P.jsxs)(`div`,{className:`text-xs font-medium text-fg-muted`,children:[le,de]}),t[77]=le,t[78]=de,t[79]=fe):fe=t[79];let Q;t[80]!==n||t[81]!==r||t[82]!==i?(Q=n.runtime.promptCache?.mode===`auto`?(0,P.jsxs)(`div`,{className:`text-xs font-medium text-fg-muted`,children:[(0,P.jsx)(`span`,{children:i?`缓存周期`:`Cache lifetime`}),(0,P.jsx)(`div`,{className:`mt-1.5 flex rounded-lg bg-surface-panel p-1`,children:[`short`,`long`].map(e=>(0,P.jsx)(te,{variant:n.runtime.promptCache?.lifetime===e?`secondary`:`ghost`,className:`flex-1 py-1.5 text-xs`,onClick:()=>r({...n,runtime:{...n.runtime,promptCache:{mode:`auto`,lifetime:e}}}),children:e===`short`?i?`短期`:`Short`:i?`长期`:`Long`},e))})]}):null,t[80]=n,t[81]=r,t[82]=i,t[83]=Q):Q=t[83];let pe;t[84]!==fe||t[85]!==Q?(pe=(0,P.jsxs)(`div`,{className:`mt-5 grid gap-4 sm:grid-cols-2`,children:[fe,Q]}),t[84]=fe,t[85]=Q,t[86]=pe):pe=t[86];let me;t[87]!==X||t[88]!==Z||t[89]!==pe?(me=(0,P.jsxs)(`section`,{className:`rounded-xl bg-surface-hover/20 p-5`,children:[X,Z,pe]}),t[87]=X,t[88]=Z,t[89]=pe,t[90]=me):me=t[90];let he=i?`工作流`:`Workflows`,ge;t[91]===he?ge=t[92]:(ge=(0,P.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:he}),t[91]=he,t[92]=ge);let _e=i?`设置默认工作流,并决定智能体可以调用哪些工作流。`:`Set a default workflow and control which workflows agents may invoke.`,ve;t[93]===_e?ve=t[94]:(ve=(0,P.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:_e}),t[93]=_e,t[94]=ve);let ye=i?`默认工作流`:`Default workflow`,$;t[95]===ye?$=t[96]:($=(0,P.jsx)(`label`,{className:`block text-xs font-medium text-fg-muted`,children:ye}),t[95]=ye,t[96]=$);let be=n.workflows.default??``,xe=s.isLoading?i?`正在加载…`:`Loading…`:i?`不设置默认工作流`:`No default workflow`,Se=i?`不设置默认工作流`:`No default workflow`,Ce=i?`默认工作流`:`Default workflow`,we;t[97]!==n||t[98]!==r?(we=e=>r({...n,workflows:{...n.workflows,default:e||void 0}}),t[97]=n,t[98]=r,t[99]=we):we=t[99];let Te;t[100]!==be||t[101]!==xe||t[102]!==Se||t[103]!==Ce||t[104]!==we||t[105]!==d||t[106]!==s.isLoading?(Te=(0,P.jsx)(a,{value:be,options:d,placeholder:xe,emptyLabel:Se,disabled:s.isLoading,ariaLabel:Ce,onChange:we,triggerClassName:`mt-2`}),t[100]=be,t[101]=xe,t[102]=Se,t[103]=Ce,t[104]=we,t[105]=d,t[106]=s.isLoading,t[107]=Te):Te=t[107];let Ee;t[108]!==$||t[109]!==Te?(Ee=(0,P.jsxs)(`div`,{className:`mt-5 max-w-xl`,children:[$,Te]}),t[108]=$,t[109]=Te,t[110]=Ee):Ee=t[110];let De;t[111]===s.error?De=t[112]:(De=s.error?(0,P.jsx)(`p`,{className:`mt-3 text-sm text-red-600`,children:s.error instanceof Error?s.error.message:String(s.error)}):null,t[111]=s.error,t[112]=De);let Oe=i?`允许调用的工作流`:`Allowed workflows`,ke;t[113]===Oe?ke=t[114]:(ke=(0,P.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:Oe}),t[113]=Oe,t[114]=ke);let Ae;t[115]!==n||t[116]!==r?(Ae=()=>r({...n,workflows:{...n.workflows,allowed:void 0}}),t[115]=n,t[116]=r,t[117]=Ae):Ae=t[117];let je=f?`bg-accent-soft shadow-surface`:`hover:bg-surface-hover`,Me;t[118]===je?Me=t[119]:(Me=u(`rounded-xl bg-surface-base/55 p-4 text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,je),t[118]=je,t[119]=Me);let Ne=i?`允许全部工作流`:`Allow every workflow`,Pe;t[120]===Ne?Pe=t[121]:(Pe=(0,P.jsx)(`span`,{className:`block text-sm font-medium text-fg`,children:Ne}),t[120]=Ne,t[121]=Pe);let Fe=i?`新增工作流也会自动可用。`:`New workflows become available automatically.`,Ie;t[122]===Fe?Ie=t[123]:(Ie=(0,P.jsx)(`span`,{className:`mt-1 block text-xs text-fg-muted`,children:Fe}),t[122]=Fe,t[123]=Ie);let Le;t[124]!==Ae||t[125]!==Me||t[126]!==Pe||t[127]!==Ie?(Le=(0,P.jsxs)(`button`,{type:`button`,onClick:Ae,className:Me,children:[Pe,Ie]}),t[124]=Ae,t[125]=Me,t[126]=Pe,t[127]=Ie,t[128]=Le):Le=t[128];let Re;t[129]!==n||t[130]!==r?(Re=()=>r({...n,workflows:{...n.workflows,allowed:[]}}),t[129]=n,t[130]=r,t[131]=Re):Re=t[131];let ze=f?`hover:bg-surface-hover`:`bg-accent-soft shadow-surface`,Be;t[132]===ze?Be=t[133]:(Be=u(`rounded-xl bg-surface-base/55 p-4 text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,ze),t[132]=ze,t[133]=Be);let Ve=i?`只允许选中的工作流`:`Allow selected workflows only`,He;t[134]===Ve?He=t[135]:(He=(0,P.jsx)(`span`,{className:`block text-sm font-medium text-fg`,children:Ve}),t[134]=Ve,t[135]=He);let Ue=i?`未选中的工作流不能被调用。`:`Unselected workflows cannot be invoked.`,We;t[136]===Ue?We=t[137]:(We=(0,P.jsx)(`span`,{className:`mt-1 block text-xs text-fg-muted`,children:Ue}),t[136]=Ue,t[137]=We);let Ge;t[138]!==Re||t[139]!==Be||t[140]!==He||t[141]!==We?(Ge=(0,P.jsxs)(`button`,{type:`button`,onClick:Re,className:Be,children:[He,We]}),t[138]=Re,t[139]=Be,t[140]=He,t[141]=We,t[142]=Ge):Ge=t[142];let Ke;t[143]!==Le||t[144]!==Ge?(Ke=(0,P.jsxs)(`div`,{className:`mt-3 grid gap-3 sm:grid-cols-2`,children:[Le,Ge]}),t[143]=Le,t[144]=Ge,t[145]=Ke):Ke=t[145];let qe;t[146]!==f||t[147]!==n.workflows.allowed||t[148]!==m||t[149]!==s.data||t[150]!==s.isLoading||t[151]!==i?(qe=f?null:(0,P.jsxs)(`div`,{className:`mt-3 flex flex-col gap-1 rounded-xl bg-surface-base/45 p-1 [&>label]:rounded-lg [&>label]:bg-surface-panel/55`,children:[(s.data??[]).map(e=>(0,P.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-3 px-4 py-3 hover:bg-surface-hover/60`,children:[(0,P.jsx)(`input`,{type:`checkbox`,checked:n.workflows.allowed?.includes(e.id)??!1,onChange:t=>m(e.id,t.target.checked),className:`mt-0.5 size-4 accent-[var(--color-accent)]`}),(0,P.jsxs)(`span`,{children:[(0,P.jsx)(`span`,{className:`block text-sm font-medium text-fg`,children:e.title||e.name}),e.description?(0,P.jsx)(`span`,{className:`mt-1 block text-xs text-fg-muted`,children:e.description}):null]})]},e.id)),(s.data??[]).length===0&&!s.isLoading?(0,P.jsx)(`p`,{className:`px-4 py-8 text-center text-sm text-fg-muted`,children:i?`还没有工作流。`:`No workflows yet.`}):null]}),t[146]=f,t[147]=n.workflows.allowed,t[148]=m,t[149]=s.data,t[150]=s.isLoading,t[151]=i,t[152]=qe):qe=t[152];let Je;t[153]!==ke||t[154]!==Ke||t[155]!==qe?(Je=(0,P.jsxs)(`div`,{className:`mt-6 rounded-xl bg-surface-base/45 p-4`,children:[ke,Ke,qe]}),t[153]=ke,t[154]=Ke,t[155]=qe,t[156]=Je):Je=t[156];let Ye;t[157]!==ge||t[158]!==ve||t[159]!==Ee||t[160]!==De||t[161]!==Je?(Ye=(0,P.jsxs)(`section`,{className:`rounded-xl bg-surface-hover/20 p-5`,children:[ge,ve,Ee,De,Je]}),t[157]=ge,t[158]=ve,t[159]=Ee,t[160]=De,t[161]=Je,t[162]=Ye):Ye=t[162];let Xe;return t[163]!==C||t[164]!==G||t[165]!==me||t[166]!==Ye?(Xe=(0,P.jsxs)(`div`,{className:`space-y-5`,children:[C,G,me,Ye]}),t[163]=C,t[164]=G,t[165]=me,t[166]=Ye,t[167]=Xe):Xe=t[167],Xe}function Y(e){return{value:e.id,label:e.title||e.name}}function X(e){return[...new Set(e)].sort()}var se=[{id:`core`,names:[`doc-coauthoring`,`define-task`,`find-skills`,`summarize`],en:`Core`,zh:`核心`},{id:`office`,names:[`doc-coauthoring`,`define-task`,`find-skills`,`summarize`,`docx`,`pdf`,`pptx`,`xlsx`],en:`Office`,zh:`办公成果`},{id:`local-app`,names:[`doc-coauthoring`,`define-task`,`find-skills`,`summarize`,`build-xopc-local-app`,`frontend-design`,`theme-factory`],en:`Local App`,zh:`本地应用`},{id:`developer`,names:[`doc-coauthoring`,`define-task`,`find-skills`,`summarize`,`diagnose`,`github`,`tdd`,`webapp-testing`],en:`Developer`,zh:`开发者`},{id:`desktop-pet`,names:[`doc-coauthoring`,`define-task`,`find-skills`,`summarize`,`hatch-pet`],en:`Desktop Pet`,zh:`桌面宠物`}];function Z(e){let t=(0,oe.c)(115),{draft:n,setDraft:r,zh:i}=e,a;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(a={revalidateOnFocus:!1},t[0]=a):a=t[0];let{data:s,error:l,isLoading:d}=ee(`agent-defaults-skills-catalog`,C,a),[f,te]=(0,ae.useState)(``),p=n.skills.mode===`selected`?n.skills.include:n.skills.exclude;s?.catalog;let m;if(t[1]!==p||t[2]!==s?.catalog||t[3]!==f){let e=[...s?.catalog??[]],n=new Set(e.map(fe));for(let t of p)n.has(t)||e.push({name:t,description:``,enabled:!0});let r=f.trim().toLowerCase();m=e.filter(e=>!r||`${e.name} ${e.description}`.toLowerCase().includes(r)).sort(de),t[1]=p,t[2]=s?.catalog,t[3]=f,t[4]=m}else m=t[4];let h=m,g;t[5]!==n.skills.exclude||t[6]!==n.skills.include||t[7]!==n.skills.mode?(g=e=>n.skills.mode===`selected`?n.skills.include.includes(e):!n.skills.exclude.includes(e),t[5]=n.skills.exclude,t[6]=n.skills.include,t[7]=n.skills.mode,t[8]=g):g=t[8];let _=g,v;t[9]!==n||t[10]!==r?(v=e=>{if(n.skills.mode===`selected`){let t=n.skills.include.includes(e)?n.skills.include.filter(t=>t!==e):X([...n.skills.include,e]);r({...n,skills:{mode:`selected`,include:t}});return}let t=n.skills.exclude.includes(e)?n.skills.exclude.filter(t=>t!==e):X([...n.skills.exclude,e]);r({...n,skills:{mode:`all-enabled`,exclude:t}})},t[9]=n,t[10]=r,t[11]=v):v=t[11];let y=v,b;t[12]===s?.catalog?b=t[13]:(b=s?.catalog??[],t[12]=s?.catalog,t[13]=b);let x;if(t[14]!==_||t[15]!==b){let e;t[17]===_?e=t[18]:(e=e=>e.enabled&&_(e.name),t[17]=_,t[18]=e),x=b.filter(e),t[14]=_,t[15]=b,t[16]=x}else x=t[16];let S=x.length,w;t[19]!==s?.catalog||t[20]!==n||t[21]!==r?(w=e=>{let t=new Set((s?.catalog??[]).filter(ue).map(le));r({...n,skills:{mode:`selected`,include:X(e.filter(e=>t.has(e)))}})},t[19]=s?.catalog,t[20]=n,t[21]=r,t[22]=w):w=t[22];let T=w,E=i?`技能策略`:`Skill policy`,D;t[23]===E?D=t[24]:(D=(0,P.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:E}),t[23]=E,t[24]=D);let O=i?`决定所有智能体默认可以使用哪些技能。`:`Choose which skills every agent can discover and use by default.`,k;t[25]===O?k=t[26]:(k=(0,P.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:O}),t[25]=O,t[26]=k);let A;t[27]!==n||t[28]!==r?(A=()=>r({...n,skills:{mode:`all-enabled`,exclude:[]}}),t[27]=n,t[28]=r,t[29]=A):A=t[29];let j=n.skills.mode===`all-enabled`?`bg-accent-soft shadow-surface`:`hover:bg-surface-hover`,M;t[30]===j?M=t[31]:(M=u(`flex items-start gap-3 rounded-xl bg-surface-base/55 p-4 text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,j),t[30]=j,t[31]=M);let N;t[32]===Symbol.for(`react.memo_cache_sentinel`)?(N=(0,P.jsx)(o,{className:`mt-0.5 size-5 shrink-0 text-accent`}),t[32]=N):N=t[32];let re=i?`使用所有已启用技能`:`Use every enabled skill`,ie;t[33]===re?ie=t[34]:(ie=(0,P.jsx)(`span`,{className:`block text-sm font-medium text-fg`,children:re}),t[33]=re,t[34]=ie);let F=i?`适合需要完整目录的高级智能体;新增技能会自动加入。`:`For advanced agents that need the full catalog; newly enabled skills are added automatically.`,I;t[35]===F?I=t[36]:(I=(0,P.jsx)(`span`,{className:`mt-1 block text-xs leading-5 text-fg-muted`,children:F}),t[35]=F,t[36]=I);let L;t[37]!==ie||t[38]!==I?(L=(0,P.jsxs)(`span`,{children:[ie,I]}),t[37]=ie,t[38]=I,t[39]=L):L=t[39];let R;t[40]!==A||t[41]!==M||t[42]!==L?(R=(0,P.jsxs)(`button`,{type:`button`,onClick:A,className:M,children:[N,L]}),t[40]=A,t[41]=M,t[42]=L,t[43]=R):R=t[43];let z;t[44]!==n||t[45]!==r?(z=()=>r({...n,skills:{mode:`selected`,include:[]}}),t[44]=n,t[45]=r,t[46]=z):z=t[46];let B=n.skills.mode===`selected`?`bg-accent-soft shadow-surface`:`hover:bg-surface-hover`,V;t[47]===B?V=t[48]:(V=u(`flex items-start gap-3 rounded-xl bg-surface-base/55 p-4 text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,B),t[47]=B,t[48]=V);let H;t[49]===Symbol.for(`react.memo_cache_sentinel`)?(H=(0,P.jsx)(ne,{className:`mt-0.5 size-5 shrink-0 text-accent`}),t[49]=H):H=t[49];let U=i?`只使用选中的技能`:`Use selected skills only`,W;t[50]===U?W=t[51]:(W=(0,P.jsx)(`span`,{className:`block text-sm font-medium text-fg`,children:U}),t[50]=U,t[51]=W);let G=i?`适合严格受控的环境;新增技能不会自动加入。`:`For tightly controlled environments; new skills are not added automatically.`,K;t[52]===G?K=t[53]:(K=(0,P.jsx)(`span`,{className:`mt-1 block text-xs leading-5 text-fg-muted`,children:G}),t[52]=G,t[53]=K);let q;t[54]!==W||t[55]!==K?(q=(0,P.jsxs)(`span`,{children:[W,K]}),t[54]=W,t[55]=K,t[56]=q):q=t[56];let J;t[57]!==z||t[58]!==V||t[59]!==q?(J=(0,P.jsxs)(`button`,{type:`button`,onClick:z,className:V,children:[H,q]}),t[57]=z,t[58]=V,t[59]=q,t[60]=J):J=t[60];let Y;t[61]!==R||t[62]!==J?(Y=(0,P.jsxs)(`div`,{className:`mt-5 grid gap-3 sm:grid-cols-2`,children:[R,J]}),t[61]=R,t[62]=J,t[63]=Y):Y=t[63];let Z=i?`能力组合(会替换当前选择)`:`Capability packs (replaces the current selection)`,Q;t[64]===Z?Q=t[65]:(Q=(0,P.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:Z}),t[64]=Z,t[65]=Q);let pe;t[66]!==T||t[67]!==s||t[68]!==i?(pe=se.map(e=>(0,P.jsx)(`button`,{type:`button`,onClick:()=>T(e.names),disabled:!s,className:`rounded-lg border border-edge bg-surface-panel px-3 py-1.5 text-xs font-medium text-fg transition-colors hover:bg-surface-hover disabled:cursor-not-allowed disabled:opacity-50`,children:i?e.zh:e.en},e.id)),t[66]=T,t[67]=s,t[68]=i,t[69]=pe):pe=t[69];let me;t[70]===pe?me=t[71]:(me=(0,P.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-2`,children:pe}),t[70]=pe,t[71]=me);let he;t[72]!==Q||t[73]!==me?(he=(0,P.jsxs)(`div`,{className:`mt-4`,children:[Q,me]}),t[72]=Q,t[73]=me,t[74]=he):he=t[74];let ge;t[75]!==k||t[76]!==Y||t[77]!==he||t[78]!==D?(ge=(0,P.jsxs)(`section`,{className:`rounded-xl bg-surface-hover/20 p-5`,children:[D,k,Y,he]}),t[75]=k,t[76]=Y,t[77]=he,t[78]=D,t[79]=ge):ge=t[79];let _e=n.skills.mode===`selected`?i?`选择可用技能`:`Select available skills`:i?`管理例外`:`Manage exceptions`,ve;t[80]===_e?ve=t[81]:(ve=(0,P.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:_e}),t[80]=_e,t[81]=ve);let ye=i?`当前默认可用 ${S} 个技能。`:`${S} skills are available by default.`,$;t[82]===ye?$=t[83]:($=(0,P.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:ye}),t[82]=ye,t[83]=$);let be;t[84]!==ve||t[85]!==$?(be=(0,P.jsxs)(`div`,{children:[ve,$]}),t[84]=ve,t[85]=$,t[86]=be):be=t[86];let xe=i?`搜索技能`:`Search skills`,Se;t[87]===xe?Se=t[88]:(Se=(0,P.jsx)(`span`,{className:`sr-only`,children:xe}),t[87]=xe,t[88]=Se);let Ce;t[89]===Symbol.for(`react.memo_cache_sentinel`)?(Ce=(0,P.jsx)(c,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-fg-subtle`}),t[89]=Ce):Ce=t[89];let we;t[90]===Symbol.for(`react.memo_cache_sentinel`)?(we=e=>te(e.target.value),t[90]=we):we=t[90];let Te=i?`搜索技能`:`Search skills`,Ee;t[91]!==f||t[92]!==Te?(Ee=(0,P.jsx)(`input`,{type:`search`,value:f,onChange:we,placeholder:Te,className:`w-full rounded-lg border border-edge bg-surface-panel py-2 pl-9 pr-3 text-sm text-fg outline-none focus:border-accent`}),t[91]=f,t[92]=Te,t[93]=Ee):Ee=t[93];let De;t[94]!==Se||t[95]!==Ee?(De=(0,P.jsxs)(`label`,{className:`relative block w-full sm:w-72`,children:[Se,Ce,Ee]}),t[94]=Se,t[95]=Ee,t[96]=De):De=t[96];let Oe;t[97]!==be||t[98]!==De?(Oe=(0,P.jsxs)(`div`,{className:`flex flex-wrap items-end justify-between gap-3`,children:[be,De]}),t[97]=be,t[98]=De,t[99]=Oe):Oe=t[99];let ke;t[100]===l?ke=t[101]:(ke=l?(0,P.jsx)(`p`,{className:`mt-4 rounded-lg bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:l instanceof Error?l.message:String(l)}):null,t[100]=l,t[101]=ke);let Ae;t[102]!==_||t[103]!==d||t[104]!==h||t[105]!==y||t[106]!==i?(Ae=d?(0,P.jsx)(`div`,{className:`mt-4 space-y-2`,children:[0,1,2,3].map(ce)}):(0,P.jsxs)(`div`,{className:`mt-4 flex max-h-[32rem] flex-col gap-1 overflow-y-auto rounded-xl bg-surface-base/45 p-1 [&>label]:rounded-lg [&>label]:bg-surface-panel/55`,children:[h.map(e=>{let t=_(e.name);return(0,P.jsxs)(`label`,{className:u(`flex cursor-pointer items-start gap-3 px-4 py-3 hover:bg-surface-hover/60`,!e.enabled&&`cursor-not-allowed opacity-55`),children:[(0,P.jsx)(`input`,{type:`checkbox`,checked:t,disabled:!e.enabled,onChange:()=>y(e.name),className:`mt-0.5 size-4 rounded border-edge accent-[var(--color-accent)]`}),(0,P.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,P.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2`,children:[(0,P.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:e.name}),e.enabled?null:(0,P.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5 text-[10px] text-fg-muted`,children:i?`全局未启用`:`Disabled globally`})]}),e.description?(0,P.jsx)(`span`,{className:`mt-1 block line-clamp-2 text-xs leading-5 text-fg-muted`,children:e.description}):null]})]},e.name)}),h.length===0?(0,P.jsx)(`p`,{className:`px-4 py-8 text-center text-sm text-fg-muted`,children:i?`没有匹配的技能。`:`No matching skills.`}):null]}),t[102]=_,t[103]=d,t[104]=h,t[105]=y,t[106]=i,t[107]=Ae):Ae=t[107];let je;t[108]!==Oe||t[109]!==ke||t[110]!==Ae?(je=(0,P.jsxs)(`section`,{className:`rounded-xl bg-surface-hover/20 p-5`,children:[Oe,ke,Ae]}),t[108]=Oe,t[109]=ke,t[110]=Ae,t[111]=je):je=t[111];let Me;return t[112]!==ge||t[113]!==je?(Me=(0,P.jsxs)(`div`,{className:`space-y-5`,children:[ge,je]}),t[112]=ge,t[113]=je,t[114]=Me):Me=t[114],Me}function ce(e){return(0,P.jsx)(g,{className:`h-14 rounded-xl`},e)}function le(e){return e.name}function ue(e){return e.enabled}function de(e,t){return e.name.localeCompare(t.name)}function fe(e){return e.name}function Q(e){let t=Number.parseInt(e,10);return Number.isFinite(t)&&t>0?t:void 0}function pe(e){let t=(0,oe.c)(92),{draft:n,setDraft:r,builtinTools:i,zh:a}=e,[o,s]=(0,ae.useState)(``),[l,d]=(0,ae.useState)(`all`),[f,ee]=(0,ae.useState)(),p;t[0]===i?p=t[1]:(p=new Map(i.map(ge)),t[0]=i,t[1]=p);let m=p,h;t[2]!==i||t[3]!==n.tools?(h=[...new Set([...i.map(he),...Object.keys(n.tools)])].filter(me).sort(),t[2]=i,t[3]=n.tools,t[4]=h):h=t[4];let g=h,_;if(t[5]!==g||t[6]!==n.tools){let e;t[8]===n.tools?e=t[9]:(e=e=>(n.tools[e]?.mode??`allow`)===`allow`,t[8]=n.tools,t[9]=e),_=g.filter(e),t[5]=g,t[6]=n.tools,t[7]=_}else _=t[7];let v=_.length,y;if(t[10]!==g||t[11]!==n.tools){let e;t[13]===n.tools?e=t[14]:(e=e=>n.tools[e]?.mode===`ask`,t[13]=n.tools,t[14]=e),y=g.filter(e),t[10]=g,t[11]=n.tools,t[12]=y}else y=t[12];let b=y.length,x;if(t[15]!==g||t[16]!==n.tools){let e;t[18]===n.tools?e=t[19]:(e=e=>n.tools[e]?.mode===`deny`,t[18]=n.tools,t[19]=e),x=g.filter(e),t[15]=g,t[16]=n.tools,t[17]=x}else x=t[17];let S;t[20]!==_.length||t[21]!==y.length||t[22]!==x.length?(S={allow:v,ask:b,deny:x.length},t[20]=_.length,t[21]=y.length,t[22]=x.length,t[23]=S):S=t[23];let C=S,w;if(t[24]!==g||t[25]!==m||t[26]!==n.tools||t[27]!==l||t[28]!==o){let e=o.trim().toLowerCase();w=g.filter(t=>{let r=n.tools[t]?.mode??`allow`,i=m.get(t),a=`${t} ${i?.en??``} ${i?.zh??``}`.toLowerCase();return(!e||a.includes(e))&&(l===`all`||r===l)}),t[24]=g,t[25]=m,t[26]=n.tools,t[27]=l,t[28]=o,t[29]=w}else w=t[29];let T=w,E;t[30]!==n||t[31]!==r?(E=(e,t)=>{let i=n.tools[e]??{mode:`allow`};r({...n,tools:{...n.tools,[e]:{...i,...t}}})},t[30]=n,t[31]=r,t[32]=E):E=t[32];let O=E,ne=a?`全部 ${g.length}`:`All ${g.length}`,k;t[33]===ne?k=t[34]:(k={id:`all`,label:ne},t[33]=ne,t[34]=k);let A=a?`允许 ${C.allow}`:`Allow ${C.allow}`,j;t[35]===A?j=t[36]:(j={id:`allow`,label:A},t[35]=A,t[36]=j);let M=a?`询问 ${C.ask}`:`Ask ${C.ask}`,N;t[37]===M?N=t[38]:(N={id:`ask`,label:M},t[37]=M,t[38]=N);let re=a?`禁用 ${C.deny}`:`Deny ${C.deny}`,ie;t[39]===re?ie=t[40]:(ie={id:`deny`,label:re},t[39]=re,t[40]=ie);let F;t[41]!==k||t[42]!==j||t[43]!==N||t[44]!==ie?(F=[k,j,N,ie],t[41]=k,t[42]=j,t[43]=N,t[44]=ie,t[45]=F):F=t[45];let I=F,L=a?`默认工具权限`:`Default tool permissions`,R;t[46]===L?R=t[47]:(R=(0,P.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:L}),t[46]=L,t[47]=R);let z=a?`允许:直接执行;询问:执行前确认;禁用:智能体无法使用。`:`Allow runs directly, Ask requires confirmation, and Deny makes the tool unavailable.`,B;t[48]===z?B=t[49]:(B=(0,P.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:z}),t[48]=z,t[49]=B);let V;t[50]!==R||t[51]!==B?(V=(0,P.jsxs)(`div`,{children:[R,B]}),t[50]=R,t[51]=B,t[52]=V):V=t[52];let H;t[53]!==l||t[54]!==I?(H=(0,P.jsx)(`div`,{className:`flex flex-wrap gap-1 rounded-xl bg-surface-panel p-1`,children:I.map(e=>(0,P.jsx)(`button`,{type:`button`,onClick:()=>d(e.id),className:u(`rounded-lg px-3 py-1.5 text-xs font-medium`,l===e.id?`bg-surface-base text-fg shadow-surface`:`text-fg-muted hover:text-fg`),children:e.label},e.id))}),t[53]=l,t[54]=I,t[55]=H):H=t[55];let U=a?`搜索工具`:`Search tools`,W;t[56]===U?W=t[57]:(W=(0,P.jsx)(`span`,{className:`sr-only`,children:U}),t[56]=U,t[57]=W);let G;t[58]===Symbol.for(`react.memo_cache_sentinel`)?(G=(0,P.jsx)(c,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-fg-subtle`}),t[58]=G):G=t[58];let K;t[59]===Symbol.for(`react.memo_cache_sentinel`)?(K=e=>s(e.target.value),t[59]=K):K=t[59];let q=a?`搜索工具`:`Search tools`,J;t[60]!==o||t[61]!==q?(J=(0,P.jsx)(`input`,{type:`search`,value:o,onChange:K,placeholder:q,className:`w-full rounded-lg border border-edge bg-surface-panel py-2 pl-9 pr-3 text-sm text-fg outline-none focus:border-accent`}),t[60]=o,t[61]=q,t[62]=J):J=t[62];let Y;t[63]!==W||t[64]!==J?(Y=(0,P.jsxs)(`label`,{className:`relative block w-full sm:w-72`,children:[W,G,J]}),t[63]=W,t[64]=J,t[65]=Y):Y=t[65];let X;t[66]!==H||t[67]!==Y?(X=(0,P.jsxs)(`div`,{className:`mt-5 flex flex-wrap items-center justify-between gap-3`,children:[H,Y]}),t[66]=H,t[67]=Y,t[68]=X):X=t[68];let se;if(t[69]!==m||t[70]!==n.tools||t[71]!==f||t[72]!==O||t[73]!==T||t[74]!==a){let e;t[76]!==m||t[77]!==n.tools||t[78]!==f||t[79]!==O||t[80]!==a?(e=e=>{let t=n.tools[e]??{mode:`allow`},r=m.get(e),i=f===e;return(0,P.jsxs)(`div`,{className:`px-4 py-3`,children:[(0,P.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,P.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,P.jsx)(`code`,{className:`text-xs font-medium text-fg`,children:e}),r?(0,P.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:a?r.zh:r.en}):null]}),(0,P.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,P.jsx)(`div`,{className:`flex rounded-lg bg-surface-base p-1`,children:[`allow`,`ask`,`deny`].map(n=>(0,P.jsx)(`button`,{type:`button`,onClick:()=>O(e,{mode:n}),className:u(`rounded-md px-2.5 py-1 text-xs font-medium capitalize`,t.mode===n?`bg-accent text-on-accent`:`text-fg-muted hover:text-fg`),children:n===`allow`?a?`允许`:`Allow`:n===`ask`?a?`询问`:`Ask`:a?`禁用`:`Deny`},n))}),(0,P.jsx)(te,{variant:`ghost`,className:`px-2 py-1`,"aria-label":a?`${e} 调用限制`:`${e} call limits`,onClick:()=>ee(i?void 0:e),children:(0,P.jsx)(D,{className:`size-4`})})]})]}),i?(0,P.jsxs)(`div`,{className:`mt-3 grid gap-3 rounded-lg bg-surface-base p-3 sm:grid-cols-2`,children:[(0,P.jsxs)(`label`,{className:`block text-xs font-medium text-fg-muted`,children:[a?`每轮最多调用次数`:`Maximum calls per turn`,(0,P.jsx)(`input`,{type:`number`,min:1,value:t.maxCallsPerTurn??``,placeholder:a?`不限制`:`Unlimited`,onChange:t=>O(e,{maxCallsPerTurn:Q(t.target.value)}),className:`mt-2 w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg outline-none focus:border-accent`})]}),(0,P.jsxs)(`label`,{className:`block text-xs font-medium text-fg-muted`,children:[a?`单次超时(毫秒)`:`Call timeout (ms)`,(0,P.jsx)(`input`,{type:`number`,min:1,value:t.timeoutMs??``,placeholder:a?`使用系统默认值`:`Use system default`,onChange:t=>O(e,{timeoutMs:Q(t.target.value)}),className:`mt-2 w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg outline-none focus:border-accent`})]})]}):null]},e)},t[76]=m,t[77]=n.tools,t[78]=f,t[79]=O,t[80]=a,t[81]=e):e=t[81],se=T.map(e),t[69]=m,t[70]=n.tools,t[71]=f,t[72]=O,t[73]=T,t[74]=a,t[75]=se}else se=t[75];let Z;t[82]!==T.length||t[83]!==a?(Z=T.length===0?(0,P.jsx)(`p`,{className:`px-4 py-10 text-center text-sm text-fg-muted`,children:a?`没有匹配的工具。`:`No matching tools.`}):null,t[82]=T.length,t[83]=a,t[84]=Z):Z=t[84];let ce;t[85]!==se||t[86]!==Z?(ce=(0,P.jsxs)(`div`,{className:`mt-4 flex max-h-[38rem] flex-col gap-1 overflow-y-auto rounded-xl bg-surface-base/45 p-1 [&>*]:rounded-lg [&>*]:bg-surface-panel/55`,children:[se,Z]}),t[85]=se,t[86]=Z,t[87]=ce):ce=t[87];let le;return t[88]!==V||t[89]!==X||t[90]!==ce?(le=(0,P.jsxs)(`section`,{className:`rounded-xl bg-surface-hover/20 p-5`,children:[V,X,ce]}),t[88]=V,t[89]=X,t[90]=ce,t[91]=le):le=t[91],le}function me(e){return e!==`computer_use`||_()}function he(e){return e.id}function ge(e){return[e.id,e.description]}function _e(){let e=(0,oe.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,P.jsxs)(A,{gap:`gap-5`,children:[(0,P.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,P.jsxs)(`div`,{className:`space-y-2`,children:[(0,P.jsx)(g,{className:`h-7 w-56`}),(0,P.jsx)(g,{className:`h-4 w-96 max-w-full`})]}),(0,P.jsx)(g,{className:`h-9 w-28`})]}),(0,P.jsx)(g,{className:`h-20 rounded-2xl`}),(0,P.jsx)(g,{className:`h-12 rounded-xl`}),(0,P.jsx)(g,{className:`h-72 rounded-2xl`})]}),e[0]=t):t=e[0],t}function ve(e){let t=(0,oe.c)(67),{initial:n,builtinTools:r,zh:i}=e,[a,o]=(0,ae.useState)(`models`),s;t[0]===n?s=t[1]:(s=()=>structuredClone(n),t[0]=n,t[1]=s);let[c,d]=(0,ae.useState)(s),f;t[2]===n?f=t[3]:(f=()=>structuredClone(n),t[2]=n,t[3]=f);let[ee,p]=(0,ae.useState)(f),m;t[4]===c?m=t[5]:(m=JSON.stringify(c),t[4]=c,t[5]=m);let h;t[6]===ee?h=t[7]:(h=JSON.stringify(ee),t[6]=ee,t[7]=h);let g=m!==h,_=i?`模型`:`Models`,v;t[8]===_?v=t[9]:(v={id:`models`,label:_,icon:l},t[8]=_,t[9]=v);let x=i?`技能`:`Skills`,C;t[10]===x?C=t[11]:(C={id:`skills`,label:x,icon:y},t[10]=x,t[11]=C);let w=i?`工具`:`Tools`,E;t[12]===w?E=t[13]:(E={id:`tools`,label:w,icon:S},t[12]=w,t[13]=E);let D=i?`运行`:`Runtime`,O;t[14]===D?O=t[15]:(O={id:`runtime`,label:D,icon:b},t[14]=D,t[15]=O);let ne;t[16]!==E||t[17]!==O||t[18]!==v||t[19]!==C?(ne=[v,C,E,O],t[16]=E,t[17]=O,t[18]=v,t[19]=C,t[20]=ne):ne=t[20];let N=ne,re;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(re=async e=>{let t=structuredClone(e),n=await T(t),r=structuredClone(n.defaults);d(e=>JSON.stringify(e)===JSON.stringify(t)?r:e),p(structuredClone(r))},t[21]=re):re=t[21];let ie=re,F;t[22]!==g||t[23]!==c?(F={value:c,dirty:g,onSave:ie,delayMs:0},t[22]=g,t[23]=c,t[24]=F):F=t[24];let I=M(F),L=I.onBlurCapture,R=i?`智能体设置`:`Agent settings`,z;t[25]!==I.error||t[26]!==I.status?(z=(0,P.jsx)(j,{status:I.status,error:I.error}),t[25]=I.error,t[26]=I.status,t[27]=z):z=t[27];let B;t[28]!==R||t[29]!==z?(B=(0,P.jsx)(k,{title:R,actions:z}),t[28]=R,t[29]=z,t[30]=B):B=t[30];let V;t[31]!==I.error||t[32]!==I.retry||t[33]!==i?(V=I.error?(0,P.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2 rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:[(0,P.jsx)(`span`,{children:I.error}),(0,P.jsx)(te,{type:`button`,variant:`ghost`,className:`h-8 text-red-600`,onClick:I.retry,children:i?`重试`:`Retry`})]}):null,t[31]=I.error,t[32]=I.retry,t[33]=i,t[34]=V):V=t[34];let H=i?`默认配置分区`:`Default configuration sections`,U;t[35]!==a||t[36]!==N?(U=N.map(e=>{let{id:t,label:n,icon:r}=e;return(0,P.jsxs)(`button`,{type:`button`,"aria-pressed":a===t,onClick:()=>o(t),className:u(`flex min-w-0 items-center justify-center gap-2 rounded-lg px-3 py-2.5 text-left transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,a===t?`bg-surface-base text-fg shadow-surface`:`text-fg-muted hover:bg-surface-hover hover:text-fg`),children:[(0,P.jsx)(r,{className:u(`size-4 shrink-0`,a===t?`text-accent`:`text-fg-subtle`)}),(0,P.jsx)(`span`,{className:`text-sm font-medium`,children:n})]},t)}),t[35]=a,t[36]=N,t[37]=U):U=t[37];let G;t[38]!==H||t[39]!==U?(G=(0,P.jsx)(`nav`,{className:`grid grid-cols-2 gap-1 rounded-xl bg-surface-hover/20 p-1 lg:grid-cols-4`,"aria-label":H,children:U}),t[38]=H,t[39]=U,t[40]=G):G=t[40];let K;t[41]!==a||t[42]!==c||t[43]!==i?(K=a===`models`?(0,P.jsx)(W,{draft:c,setDraft:d,zh:i}):null,t[41]=a,t[42]=c,t[43]=i,t[44]=K):K=t[44];let q;t[45]!==a||t[46]!==c||t[47]!==i?(q=a===`skills`?(0,P.jsx)(Z,{draft:c,setDraft:d,zh:i}):null,t[45]=a,t[46]=c,t[47]=i,t[48]=q):q=t[48];let Y;t[49]!==a||t[50]!==r||t[51]!==c||t[52]!==i?(Y=a===`tools`?(0,P.jsx)(pe,{draft:c,setDraft:d,builtinTools:r,zh:i}):null,t[49]=a,t[50]=r,t[51]=c,t[52]=i,t[53]=Y):Y=t[53];let X;t[54]!==a||t[55]!==c||t[56]!==i?(X=a===`runtime`?(0,P.jsx)(J,{draft:c,setDraft:d,zh:i}):null,t[54]=a,t[55]=c,t[56]=i,t[57]=X):X=t[57];let se;return t[58]!==I.onBlurCapture||t[59]!==B||t[60]!==V||t[61]!==G||t[62]!==K||t[63]!==q||t[64]!==Y||t[65]!==X?(se=(0,P.jsxs)(A,{gap:`gap-5`,onBlurCapture:L,children:[B,V,G,K,q,Y,X]}),t[58]=I.onBlurCapture,t[59]=B,t[60]=V,t[61]=G,t[62]=K,t[63]=q,t[64]=Y,t[65]=X,t[66]=se):se=t[66],se}function ye(){let e=(0,oe.c)(17),t=d(be),n=f($)===`zh`,{data:r,error:i,isLoading:a,mutate:o}=ee(t?`settings-agent-defaults`:null,E);if(!t){let t=n?`需要本机服务令牌。`:`Local service token required.`,r;return e[0]===t?r=e[1]:(r=(0,P.jsx)(A,{children:(0,P.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t})}),e[0]=t,e[1]=r),r}if(i&&!r){let t=String(i),r;e[2]===t?r=e[3]:(r=(0,P.jsx)(`p`,{className:`rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:t}),e[2]=t,e[3]=r);let a;e[4]===o?a=e[5]:(a=()=>void o(),e[4]=o,e[5]=a);let s=n?`重试`:`Retry`,c;e[6]!==a||e[7]!==s?(c=(0,P.jsx)(te,{onClick:a,children:s}),e[6]=a,e[7]=s,e[8]=c):c=e[8];let l;return e[9]!==r||e[10]!==c?(l=(0,P.jsxs)(A,{children:[r,c]}),e[9]=r,e[10]=c,e[11]=l):l=e[11],l}if(a||!r){let t;return e[12]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,P.jsx)(_e,{}),e[12]=t):t=e[12],t}let s;return e[13]!==r.builtinTools||e[14]!==r.defaults||e[15]!==n?(s=(0,P.jsx)(ve,{initial:r.defaults,builtinTools:r.builtinTools,zh:n}),e[13]=r.builtinTools,e[14]=r.defaults,e[15]=n,e[16]=s):s=e[16],s}function $(e){return e.language}function be(e){return e.conversationId}export{ye as AgentDefaultsSettingsPanel};
@@ -1 +0,0 @@
1
- import{r as e}from"./locale-store-COVscAqC.js";import{a as t,d as n,f as r,g as i,i as a,l as o,p as s,r as c,s as l,t as u,u as d,v as f}from"./schemas-CObaziC7.js";import{t as p}from"./gateway-realtime-store-BheKaO6d.js";var ee=d({purpose:u([`weather`,`nearby`]),precision:u([`approximate`,`precise`]),category:u([`restaurant`,`cafe`,`pharmacy`,`park`]).optional()}).strict().superRefine((e,t)=>{e.purpose===`nearby`!=(e.category!==void 0)&&t.addIssue({code:`custom`,message:`Category is required only for nearby queries`})}),te={type:`object`,additionalProperties:!1,required:[`purpose`,`precision`],properties:{purpose:{enum:[`weather`,`nearby`]},precision:{enum:[`approximate`,`precise`]},category:{enum:[`restaurant`,`cafe`,`pharmacy`,`park`]}},allOf:[{if:{properties:{purpose:{const:`nearby`}},required:[`purpose`]},then:{properties:{category:{}},required:[`category`]},else:{not:{properties:{category:{}},required:[`category`]}}}]};d({latitude:o().min(-90).max(90),longitude:o().min(-180).max(180),accuracyMeters:o().min(0).max(1e5),capturedAt:o().int().nonnegative(),precision:u([`approximate`,`precise`]),coordinateSystem:l(`WGS84`)}).strict();var m={type:`array`,minItems:1,maxItems:1,items:{type:`object`,additionalProperties:!1,required:[`type`,`value`],properties:{type:{const:`json`},value:{type:`object`,additionalProperties:!1,required:[`latitude`,`longitude`,`accuracyMeters`,`capturedAt`,`precision`,`coordinateSystem`],properties:{latitude:{type:`number`,minimum:-90,maximum:90},longitude:{type:`number`,minimum:-180,maximum:180},accuracyMeters:{type:`number`,minimum:0,maximum:1e5},capturedAt:{type:`integer`,minimum:0},precision:{enum:[`approximate`,`precise`]},coordinateSystem:{const:`WGS84`}}}}}};function ne(e){return{name:`${e}.device.get_location`,title:`Use location once`,description:`With on-device consent, use one fresh WGS84 location for current weather (Open-Meteo) or nearby places (OpenStreetMap). Raw coordinates are consumed transiently by Gateway, never returned to the Agent or saved in history. Select approximate or precise; nearby requires a category. Each call requires new consent.`,inputSchema:te,outputSchema:m,policyId:`personal.foreground-read`,sensitivity:`personal`,effect:`read`,confirmation:`always`,requiresForeground:!0,requiredPermissions:[`location-read-once`],timeoutMs:9e4,maxConcurrency:1,supportsCancellation:!0,idempotent:!0,resultKinds:[`json`]}}var re=25*1024*1024,h=u([`web`,`desktop`,`mobile`,`browser`]),g=u([`foreground`,`background`]),ie=u([`read`,`write`,`destructive`]),ae=u([`never`,`always`]),oe=u([`text`,`json`,`file`]),_=u([`public`,`personal`]),v=s().min(1).max(160),se=s().min(32).max(160).regex(/^[A-Za-z0-9_-]+$/);t(`type`,[r({type:l(`endpoint`),endpointId:v}),r({type:l(`channel`),channel:s().min(1).max(64)}),r({type:l(`system`),source:u([`cli`,`automation`,`heartbeat`,`workflow`,`internal`,`task_update`])})]).options[0].extend({token:se});var ce=f(),y=o().int().nonnegative(),b=n(s(),i()),x=r({name:s().regex(/^[a-z][a-z0-9_]*(?:\.[a-z][a-z0-9_]*)+$/).max(120),title:s().min(1).max(120),description:s().min(1).max(2e3),inputSchema:b,outputSchema:b,policyId:s().regex(/^[a-z][a-z0-9_.-]+$/).max(120),sensitivity:_,effect:ie,confirmation:ae,requiresForeground:a(),requiredPermissions:c(s().min(1).max(120)).max(20),timeoutMs:o().int().min(1e3).max(3e5),maxConcurrency:o().int().min(1).max(4),supportsCancellation:a(),idempotent:a(),resultKinds:c(oe).min(1).max(3)});r({principalId:v,displayName:s().min(1).max(120),kind:h,platform:s().min(1).max(80),publicKey:s().min(32).max(2048)}),r({endpointId:v});var S=s().regex(/^[a-z][a-z0-9_]*(?:\.[a-z][a-z0-9_]*)+$/).max(120);r({jobId:f(),endpointId:v,capability:S,input:b,idempotencyKey:v,consentGrantId:v,createdAt:y,expiresAt:y}),r({jobId:f(),status:u([`queued`,`running`,`succeeded`,`failed`,`cancelled`]),updatedAt:y,output:b.optional(),error:r({code:v,message:s().min(1).max(2e3)}).optional()}),r({eventId:f(),endpointId:v,subscriptionId:v,eventType:S,data:b,occurredAt:y});var le=r({principalId:v,endpointId:v,connectionInstanceId:f(),displayName:s().min(1).max(120),kind:h,platform:s().min(1).max(80),appVersion:s().min(1).max(80),availability:g,nonce:v,signedAt:y,signature:s().min(16).max(1024),tools:c(x).max(100)}),ue=r({invocationId:f(),toolCallId:v,toolName:x.shape.name,arguments:b,descriptorRevision:s().min(1).max(128),confirmationRequired:a(),deadlineAt:y,uploadGrant:r({path:s().startsWith(`/`).max(500),token:v,maxBytes:o().int().positive(),maxFiles:o().int().min(1).max(20),expiresAt:y}).optional()}),de=r({invocationId:f(),reason:s().min(1).max(500)}),C=r({invocationId:f()}),w=t(`type`,[r({type:l(`text`),text:s().max(256*1024)}),r({type:l(`json`),value:i()}),r({type:l(`file`),fileId:v,name:s().min(1).max(255),mimeType:s().min(1).max(255),size:o().int().nonnegative(),sha256:s().regex(/^[a-f0-9]{64}$/)})]),fe=u([`ENDPOINT_OFFLINE`,`ENDPOINT_NOT_FOREGROUND`,`ENDPOINT_DISCONNECTED`,`TOOL_NOT_FOUND`,`TOOL_REVISION_MISMATCH`,`INVALID_ARGUMENTS`,`PERMISSION_DENIED`,`USER_DENIED`,`TOOL_BUSY`,`TOOL_TIMEOUT`,`TOOL_CANCELLED`,`RESULT_TOO_LARGE`,`PROTOCOL_ERROR`]),T=(e,t)=>r({protocolVersion:l(2),messageId:ce,type:l(e),sentAt:y,payload:t}),pe=t(`type`,[T(`endpoint.availability_changed`,r({availability:g})),T(`tool.received`,C),T(`tool.progress`,r({invocationId:f(),message:s().max(500).optional(),percent:o().min(0).max(100).optional()})),T(`tool.result`,r({invocationId:f(),content:c(w).min(1).max(20),details:b.optional()})),T(`tool.error`,r({invocationId:f(),code:fe,message:s().min(1).max(2e3)})),T(`tool.cancelled`,C)]),E=t(`type`,[T(`tool.invoke`,ue),T(`tool.cancel`,de)]),D={type:`array`,minItems:1,maxItems:20,items:{type:`object`,additionalProperties:!1,required:[`type`,`text`],properties:{type:{const:`text`},text:{type:`string`,maxLength:256*1024}}}},O={type:`array`,minItems:1,maxItems:20,items:{type:`object`,additionalProperties:!1,required:[`type`,`fileId`,`name`,`mimeType`,`size`,`sha256`],properties:{type:{const:`file`},fileId:{type:`string`,minLength:1,maxLength:160},name:{type:`string`,minLength:1,maxLength:255},mimeType:{type:`string`,minLength:1,maxLength:255},size:{type:`integer`,minimum:0},sha256:{type:`string`,pattern:`^[a-f0-9]{64}$`}}}};function k(e){if(e===null)return`null`;if(typeof e==`string`||typeof e==`boolean`)return JSON.stringify(e);if(typeof e==`number`){if(!Number.isFinite(e))throw Error(`Canonical JSON only supports finite numbers`);return JSON.stringify(e)}if(typeof e!=`object`)throw Error(`Canonical JSON does not support ${typeof e}`);if(Array.isArray(e))return`[${e.map(k).join(`,`)}]`;let t=Object.getPrototypeOf(e);if(t!==Object.prototype&&t!==null)throw Error(`Canonical JSON only supports plain objects`);let n=e;return`{${Object.keys(n).sort().map(e=>`${JSON.stringify(e)}:${k(n[e])}`).join(`,`)}}`}function A(e){let{signature:t,...n}=e;return k(n)}var j={type:`object`,properties:{},additionalProperties:!1},M={type:`array`,minItems:1,maxItems:1,items:{type:`object`,additionalProperties:!1,required:[`type`,`value`],properties:{type:{const:`json`},value:{type:`object`,additionalProperties:!1,required:[`capturedAt`,`platform`,`systemVersion`,`locale`,`timezone`],properties:{capturedAt:{type:`integer`,minimum:0},platform:{type:`string`,minLength:1,maxLength:40},systemVersion:{type:`string`,maxLength:80},locale:{type:`string`,maxLength:80},timezone:{type:`string`,maxLength:80},online:{type:`boolean`}}}}}},N={type:`array`,minItems:1,maxItems:1,items:{type:`object`,additionalProperties:!1,required:[`type`,`value`],properties:{type:{const:`json`},value:{type:`object`,additionalProperties:!1,required:[`capturedAt`,`levelPercent`,`charging`],properties:{capturedAt:{type:`integer`,minimum:0},levelPercent:{type:[`number`,`null`],minimum:0,maximum:100},charging:{type:[`boolean`,`null`]}}}}}};function P(e,t){return{name:`${e}.device.get_${t}`,title:t===`power`?`Read this device’s battery`:`Read this device’s environment`,description:t===`power`?`Read a fresh battery sample from the device that sent this user message. Unknown readings are null.`:`Read bounded platform, system version, language and timezone from the device that sent this user message. No files, page content, network addresses or identifiers are collected.`,inputSchema:j,outputSchema:t===`power`?N:M,policyId:`public.background-read`,sensitivity:`public`,effect:`read`,confirmation:`never`,requiresForeground:!1,requiredPermissions:[],timeoutMs:1e4,maxConcurrency:1,supportsCancellation:!0,idempotent:!0,resultKinds:[`json`]}}var F=256*1024,I=15e3,L=45e3,R=[`realtime.capability-negotiation.v1`],z=u([`web`,`desktop`,`mobile`,`browser_extension`,`tui`,`mcp`]),B=s().min(1).max(512),me=s().regex(/^[a-z][a-z0-9_.-]*$/).max(160),he=f(),ge=o().int().nonnegative(),V=o().int().positive(),H=s().min(1).max(160),U=(e,t)=>d({protocolVersion:l(2),messageId:he,kind:l(e),sentAt:ge,payload:t}),W=d({topic:B,afterSeq:o().int().nonnegative().optional(),view:l(`compact`).optional()});t(`kind`,[U(`realtime.hello`,d({ticket:s().min(32).max(512),clientId:s().min(1).max(160),clientKind:z,subscriptions:c(W).max(100).default([]),capabilities:c(H).max(64).optional(),endpoint:le.optional()})),U(`realtime.subscribe`,d({subscriptions:c(W).min(1).max(100)})),U(`realtime.unsubscribe`,d({topics:c(B).min(1).max(100)})),U(`realtime.ping`,d({})),U(`endpoint.message`,pe)]);var _e=d({topic:B,seq:V,event:me,data:i()}),ve=t(`kind`,[U(`realtime.ready`,d({connectionId:f(),heartbeatIntervalMs:l(I),heartbeatTimeoutMs:l(L),negotiatedCapabilities:c(H).max(64).optional(),endpoint:d({endpointId:s().min(1).max(160),turnToken:s().min(32).max(160)}).optional()})),U(`realtime.event`,_e),U(`realtime.subscribed`,d({topic:B,cursor:o().int().nonnegative()})),U(`realtime.gap`,d({topic:B,requestedSeq:o().int().nonnegative(),earliestSeq:V,recoverable:a()})),U(`realtime.pong`,d({})),U(`realtime.error`,d({code:s().min(1).max(80),message:s().min(1).max(500)})),U(`endpoint.message`,E)]);function ye(e){return ve.parse(e)}var G=class extends Error{retryable;constructor(e,t){super(e),this.retryable=t,this.name=`RealtimeConnectionError`}},be=class extends Error{bytes;maxBytes;constructor(e,t){super(`Realtime client frame is ${e} bytes; maximum is ${t} bytes`),this.bytes=e,this.maxBytes=t,this.name=`RealtimeFrameTooLargeError`}};function xe(e){if(typeof e==`string`)return e;if(e instanceof ArrayBuffer)return new TextDecoder().decode(e);if(ArrayBuffer.isView(e)){let t=Uint8Array.from(new Uint8Array(e.buffer,e.byteOffset,e.byteLength));return new TextDecoder().decode(t)}throw Error(`Realtime server sent a non-text frame`)}function Se(e){return e===1009||e===4400||e===4401||e===4409||e===4413}var Ce=class{options;desiredSubscriptions=new Map;cursors=new Map;socket;reconnectTimer;heartbeatTimer;connectionTimer;ticketAbort;generation=0;reconnectAttempts=0;shouldReconnect=!1;ready=!1;lastServerMessageAt=0;endpointBinding;reconnectWhenSocketOpens=!1;offeredCapabilities=new Set;constructor(e){this.options=e}connect(){this.shouldReconnect||(this.shouldReconnect=!0,this.open(!1))}disconnect(){this.shouldReconnect=!1,this.reconnectWhenSocketOpens=!1,this.generation+=1,this.clearTimers(),this.ready=!1,this.offeredCapabilities.clear(),this.endpointBinding?.onDisconnected?.(),this.socket?.close(1e3,`Client disconnected`),this.socket=void 0,this.options.onStateChange?.(`disconnected`)}reconnect(){this.reconnectWhenSocketOpens=!1,this.generation+=1,this.clearTimers(),this.ready=!1,this.endpointBinding?.onDisconnected?.(),this.socket?.close(1e3,`Client reconnecting`),this.socket=void 0,this.reconnectAttempts=0,this.shouldReconnect=!0,this.open(!0)}subscribe(e,t){this.desiredSubscriptions.set(e,t),t!==void 0&&this.cursors.set(e,t),this.ready&&this.sendSubscriptions([{topic:e,afterSeq:this.cursors.get(e)??t}])}unsubscribe(e){this.desiredSubscriptions.delete(e),this.ready&&this.send(this.clientMessage(`realtime.unsubscribe`,{topics:[e]}))}sendEndpointMessage(e){if(!this.ready)throw Error(`Realtime connection is not ready`);this.send(this.clientMessage(`endpoint.message`,e))}setEndpoint(e){this.endpointBinding=e,this.refreshEndpointConnection()}clearEndpoint(e){if(e&&this.endpointBinding!==e)return;let t=this.endpointBinding;this.endpointBinding=void 0,t?.onDisconnected?.(),this.refreshEndpointConnection()}refreshEndpointConnection(){if(this.shouldReconnect){if(this.socket?.readyState===0){this.reconnectWhenSocketOpens=!0;return}this.reconnect()}}async open(e){let t=++this.generation,n=this.options.connectionTimeoutMs??15e3,r=new AbortController;this.ticketAbort?.abort(),this.ticketAbort=r;let i,a=!1,o,s=(e,n=!0)=>{a||t!==this.generation||(a=!0,this.clearConnectionTimer(),r.abort(),this.ticketAbort===r&&(this.ticketAbort=void 0),this.ready=!1,this.offeredCapabilities.clear(),this.endpointBinding?.onDisconnected?.(),this.clearHeartbeat(),this.socket===i&&(this.socket=void 0),i&&(i.onopen=null,i.onmessage=null,i.onerror=null,i.onclose=null,i.close(4e3,e.slice(0,120))),this.shouldReconnect&&n?this.scheduleReconnect(e):this.shouldReconnect?(this.shouldReconnect=!1,this.options.onStateChange?.(`error`,e)):this.options.onStateChange?.(`disconnected`))};this.connectionTimer=setTimeout(()=>s(`Realtime connection timed out`),n),this.options.onStateChange?.(e?`reconnecting`:`connecting`);try{let[e,n]=await Promise.all([this.options.issueTicket(r.signal),this.endpointBinding?.createHello()]),c=e.ticket;if(2<e.realtime.minVersion)throw new G(`CLIENT_UPDATE_REQUIRED`,!1);if(2>e.realtime.maxVersion)throw new G(`GATEWAY_UPDATE_REQUIRED`,!1);let l=R.filter(t=>e.realtime.capabilities.includes(t));if(a||!this.shouldReconnect||t!==this.generation)return;this.offeredCapabilities=new Set(l??[]),i=this.options.createWebSocket(this.options.getWebSocketUrl()),this.socket=i,i.onopen=()=>{if(t!==this.generation)return;if(this.reconnectWhenSocketOpens){this.reconnect();return}let e=[...this.desiredSubscriptions].map(([e,t])=>({topic:e,afterSeq:this.cursors.get(e)??t}));this.send(this.clientMessage(`realtime.hello`,{ticket:c,clientId:this.options.clientId,clientKind:this.options.clientKind,subscriptions:e,...l?.length?{capabilities:l}:{},...n?{endpoint:n}:{}}))},i.onmessage=e=>{if(t!==this.generation)return;let n=()=>{if(!(a||t!==this.generation))return this.handleServerMessage(xe(e.data))};if(!o){try{let e=n();if(!e)return;let t=e.catch(e=>s(e instanceof Error?e.message:`Invalid realtime server message`)).then(()=>void 0);o=t,t.finally(()=>{o===t&&(o=void 0)})}catch(e){s(e instanceof Error?e.message:`Invalid realtime server message`)}return}let r=o.then(n).catch(e=>s(e instanceof Error?e.message:`Invalid realtime server message`)).then(()=>void 0);o=r,r.finally(()=>{o===r&&(o=void 0)})},i.onerror=()=>{},i.onclose=e=>{s(e.reason||`WebSocket closed (${e.code??0})`,!Se(e.code))}}catch(e){s(e instanceof Error?e.message:`Realtime connection failed`,!(e instanceof G)||e.retryable)}}handleServerMessage(e){let t=ye(JSON.parse(e));if(this.lastServerMessageAt=Date.now(),t.kind===`realtime.ready`){let e=t.payload.negotiatedCapabilities??[];if(e.some(e=>!this.offeredCapabilities.has(e)))throw Error(`Realtime server negotiated a capability the client did not offer`);this.ready=!0,this.reconnectAttempts=0,this.clearConnectionTimer(),this.ticketAbort=void 0,this.options.onStateChange?.(`connected`),this.options.onCapabilities?.(e),t.payload.endpoint&&this.endpointBinding?.onReady(t.payload.endpoint),this.clearHeartbeat(),this.heartbeatTimer=setInterval(()=>{if(this.ready){if(Date.now()-this.lastServerMessageAt>=t.payload.heartbeatTimeoutMs){this.reconnect();return}this.send(this.clientMessage(`realtime.ping`,{}))}},t.payload.heartbeatIntervalMs)}else if(t.kind===`realtime.event`){let e=this.cursors.get(t.payload.topic);if(e!==void 0&&t.payload.seq<=e)return;this.options.onEvent?.(t.payload),this.cursors.set(t.payload.topic,t.payload.seq)}else if(t.kind===`realtime.subscribed`)this.cursors.set(t.payload.topic,t.payload.cursor),this.options.onSubscribed?.(t.payload);else if(t.kind===`realtime.gap`)return this.cursors.set(t.payload.topic,t.payload.earliestSeq-1),this.options.onGap?.(t.payload);else t.kind===`realtime.error`?this.options.onStateChange?.(`error`,t.payload.message):t.kind===`endpoint.message`&&(this.endpointBinding?.onMessage(t.payload),this.options.onEndpointMessage?.(t.payload))}sendSubscriptions(e){this.send(this.clientMessage(`realtime.subscribe`,{subscriptions:e}))}clientMessage(e,t){let n=this.options.createMessageId?.()??globalThis.crypto?.randomUUID?.();if(!n)throw Error(`RealtimeClient requires createMessageId when crypto.randomUUID is unavailable`);return{protocolVersion:2,messageId:n,kind:e,sentAt:Date.now(),payload:t}}send(e){if(!this.socket||this.socket.readyState!==1)return;let t=JSON.stringify(e),n=new TextEncoder().encode(t).byteLength;if(n>262144)throw new be(n,F);this.socket.send(t)}scheduleReconnect(e){if(!this.shouldReconnect)return;this.reconnectAttempts+=1;let t=this.options.maxReconnectAttempts;if(t!==void 0&&this.reconnectAttempts>t){this.shouldReconnect=!1,this.options.onStateChange?.(`error`,e);return}this.options.onStateChange?.(`reconnecting`,e);let n=Math.min(3e4,1e3*2**Math.min(this.reconnectAttempts-1,5)),r=Math.round(n*(.5+Math.random()*.5));this.reconnectTimer&&clearTimeout(this.reconnectTimer),this.reconnectTimer=setTimeout(()=>{this.reconnectTimer=void 0,this.open(!0)},r)}clearHeartbeat(){this.heartbeatTimer&&clearInterval(this.heartbeatTimer),this.heartbeatTimer=void 0}clearTimers(){this.reconnectTimer&&clearTimeout(this.reconnectTimer),this.reconnectTimer=void 0,this.clearConnectionTimer(),this.ticketAbort?.abort(),this.ticketAbort=void 0,this.clearHeartbeat()}clearConnectionTimer(){this.connectionTimer&&clearTimeout(this.connectionTimer),this.connectionTimer=void 0}},we=500,K=null,q;function J(e){q=e,K!==null&&clearTimeout(K),K=setTimeout(()=>{K=null;let e=q;q=void 0,window.dispatchEvent(new CustomEvent(`config-reload`,{detail:e}))},we)}function Y(e,t){if(e===`config.reload`){J(t);return}window.dispatchEvent(new CustomEvent(e.replace(/[._]/g,`-`),{detail:t}))}var X=new Map,Z=new Map,Q,$;function Te(){let e=`xopc:realtime-client-id`,t=sessionStorage.getItem(e);if(t)return t;let n=crypto.randomUUID();return sessionStorage.setItem(e,n),n}function Ee(){let t=new URL(e(`/api/realtime/v1/ws`));return t.protocol=t.protocol===`https:`?`wss:`:`ws:`,t.toString()}function De(){let t=Te(),n=window.electronAPI?`desktop`:`web`,r=new Ce({clientId:t,clientKind:n,getWebSocketUrl:Ee,issueTicket:async r=>{let i=await fetch(e(`/api/realtime/tickets`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({clientId:t,clientKind:n,protocolVersion:2}),signal:r}),a=await i.json().catch(()=>null);if(!i.ok||!a?.payload?.ticket||!a.payload.realtime)throw Error(a?.error?.message??`Realtime ticket failed (${i.status})`);return{ticket:a.payload.ticket,realtime:a.payload.realtime}},createWebSocket:e=>new WebSocket(e),onStateChange:(e,t)=>{p({connectionState:e,error:t??null}),e===`connected`&&window.dispatchEvent(new CustomEvent(`gateway-realtime-connected`))},onEvent:e=>{(e.topic===`gateway`||e.topic===`sessions`)&&Y(e.event,e.data);let t=Z.get(e.topic);(t===void 0||e.seq>t)&&Z.set(e.topic,e.seq);for(let t of X.get(e.topic)??[])if(!(t.cursor!==void 0&&e.seq<=t.cursor))try{t.listener.onEvent(e)}catch(e){console.error(`[realtime] topic listener failed:`,e)}finally{t.cursor=Math.max(t.cursor??0,e.seq)}},onGap:async e=>{window.dispatchEvent(new CustomEvent(`realtime-gap`,{detail:e}));let t=[...X.get(e.topic)??[]].filter(t=>!e.recoverable||t.cursor===void 0||t.cursor<e.earliestSeq-1),n=await Promise.allSettled(t.map(t=>t.listener.onGap?.(e)));for(let e of n)e.status===`rejected`&&console.error(`[realtime] topic gap handler failed:`,e.reason)}});Q?.disconnect(),Q=r,$&&r.setEndpoint($),r.subscribe(`gateway`,Z.get(`gateway`)),r.subscribe(`sessions`,Z.get(`sessions`));for(let e of X.keys())r.subscribe(e,Z.get(e));return p({connectionState:`connecting`,error:null}),r.connect(),()=>{Q===r&&(r.disconnect(),Q=void 0)}}function Oe(e){return $=e,Q?.setEndpoint(e),()=>{$===e&&($=void 0,Q?.clearEndpoint(e))}}function ke(e){Q?.sendEndpointMessage(e)}function Ae(){Q?.reconnect()}function je(e,t,n){let r=X.get(e)??new Set,i=r.size===0,a=Z.get(e),o={listener:t,cursor:n??a};if(r.add(o),X.set(e,r),i){let t=n??a;Z.set(e,t),Q?.subscribe(e,t)}else n!==void 0&&(a===void 0||n<a)&&Q?.subscribe(e,n);return()=>{let t=X.get(e);t?.delete(o),(!t||t.size===0)&&(X.delete(e),Z.delete(e),Q?.unsubscribe(e))}}export{je as a,re as c,P as d,A as f,ee as h,De as i,D as l,ne as m,Ae as n,J as o,w as p,ke as r,O as s,Oe as t,k as u};
@@ -1 +0,0 @@
1
- import{p as e}from"./locale-store-COVscAqC.js";var t=e(()=>({connectionState:`idle`,error:null}));function n(e){t.setState(e)}export{t as n,n as t};