@xopcai/xopc 0.0.467 → 0.0.469

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 (465) hide show
  1. package/dist/browser-ext/dist/sidepanel.js +5 -0
  2. package/dist/browser-ext/manifest.json +1 -1
  3. package/dist/extensions/telegram/xopc.extension.json +1 -1
  4. package/dist/gateway/static/root/assets/{activity-store-CdEua6PR.js → activity-store-DKP2sWTJ.js} +1 -1
  5. package/dist/gateway/static/root/assets/{agent-avatar-dicebear-l8GQ4I9J.js → agent-avatar-dicebear-BR85bT1W.js} +1 -1
  6. package/dist/gateway/static/root/assets/{agent-avatar-display-BO1bqKlR.js → agent-avatar-display-CIsejg_E.js} +2 -2
  7. package/dist/gateway/static/root/assets/{agent-defaults-settings-panel-Dj_H2kDD.js → agent-defaults-settings-panel-CxLUEl0V.js} +1 -1
  8. package/dist/gateway/static/root/assets/{agent-plugin-dialog-BQA2brAU.js → agent-plugin-dialog-Cvj04Ckm.js} +1 -1
  9. package/dist/gateway/static/root/assets/{agents-C5C5l13A.js → agents-DZftplJc.js} +3 -3
  10. package/dist/gateway/static/root/assets/{agents-admin-api-DZ1lLnrj.js → agents-admin-api-BL8lN8gP.js} +1 -1
  11. package/dist/gateway/static/root/assets/{api-DDWYNF7I.js → api-BnS9d0p6.js} +1 -1
  12. package/dist/gateway/static/root/assets/{api-DVXcGKP-.js → api-V4P8zfkJ.js} +1 -1
  13. package/dist/gateway/static/root/assets/{app-link-BkEO3eBe.js → app-link-CauYDM-y.js} +1 -1
  14. package/dist/gateway/static/root/assets/{app-management-settings-panel-B5-7E03Z.js → app-management-settings-panel-CAEry5Vu.js} +1 -1
  15. package/dist/gateway/static/root/assets/{appearance-settings-E_BcjEDM.js → appearance-settings-CphsmJgM.js} +1 -1
  16. package/dist/gateway/static/root/assets/{apps-page-BjB_mjXu.js → apps-page-CXKTWj1s.js} +1 -1
  17. package/dist/gateway/static/root/assets/{archive-plugin-MvSiDvxK.js → archive-plugin-DS6JWBPZ.js} +1 -1
  18. package/dist/gateway/static/root/assets/arrow-down-to-line-C5D8Vt-L.js +1 -0
  19. package/dist/gateway/static/root/assets/{attachment-load-DrVGNxJm.js → attachment-load-C9iZLUHv.js} +1 -1
  20. package/dist/gateway/static/root/assets/attachment-preview-renderer-_6GhoCYk.js +12 -0
  21. package/dist/gateway/static/root/assets/attachment-utils-core-BPYdUI6y.js +1 -0
  22. package/dist/gateway/static/root/assets/{automation-api-24NjW7qG.js → automation-api-GcRQ9wM4.js} +1 -1
  23. package/dist/gateway/static/root/assets/{automation-result-state-C94Q3OEL.js → automation-result-state-Dcp0JX0w.js} +1 -1
  24. package/dist/gateway/static/root/assets/{automation-run-list-BShRirWV.js → automation-run-list-BLejrWpG.js} +1 -1
  25. package/dist/gateway/static/root/assets/{automation-task-card-Bgq5Plux.js → automation-task-card-BNT3n0qu.js} +1 -1
  26. package/dist/gateway/static/root/assets/{automations-page-3WGWLdiW.js → automations-page-DqrAOReO.js} +1 -1
  27. package/dist/gateway/static/root/assets/automations-workspace-BYmFhO8E.js +9 -0
  28. package/dist/gateway/static/root/assets/binary-plugins-CnFVuJtL.js +2 -0
  29. package/dist/gateway/static/root/assets/{block-editor-DAWXPErA.js → block-editor-jy5CCmhH.js} +9 -9
  30. package/dist/gateway/static/root/assets/{browser-settings-page-DI2PYAPC.js → browser-settings-page-Dd2eTtvL.js} +1 -1
  31. package/dist/gateway/static/root/assets/{capabilities-Dyw8xW90.js → capabilities-CaJjMTli.js} +1 -1
  32. package/dist/gateway/static/root/assets/capabilities-YmBD7oK8.js +1 -0
  33. package/dist/gateway/static/root/assets/capabilities-page-XgIRdqCb.js +2 -0
  34. package/dist/gateway/static/root/assets/capabilities-settings-panel-DfyND0IO.js +8 -0
  35. package/dist/gateway/static/root/assets/channels-DwUmMnA1.js +1 -0
  36. package/dist/gateway/static/root/assets/{chat-agents-api-BksS0CNy.js → chat-agents-api-Bim8--J9.js} +1 -1
  37. package/dist/gateway/static/root/assets/{chat-chart-block-aZIklMNN.js → chat-chart-block-B_c5sy7q.js} +1 -1
  38. package/dist/gateway/static/root/assets/chat-page-DfFXhDRv.js +72 -0
  39. package/dist/gateway/static/root/assets/{chat-terminal-dock-B4HoRIzf.js → chat-terminal-dock-Dn7Cm1O4.js} +1 -1
  40. package/dist/gateway/static/root/assets/{command-palette-api-VhBEUFmw.js → command-palette-api-DPtCt8Je.js} +1 -1
  41. package/dist/gateway/static/root/assets/{composer-model-config-control-BhRAbdPW.js → composer-model-config-control-BF9PPSiu.js} +1 -1
  42. package/dist/gateway/static/root/assets/{composer-notifications-nT-U6jcc.js → composer-notifications-B0IZsy8x.js} +1 -1
  43. package/dist/gateway/static/root/assets/{composer-payload-handoff-xEFHDnLo.js → composer-payload-handoff-CRCz17sd.js} +1 -1
  44. package/dist/gateway/static/root/assets/{computer-settings-page-DXlH96m6.js → computer-settings-page-CtfitoMZ.js} +1 -1
  45. package/dist/gateway/static/root/assets/{connected-providers-grid-D8vBFsbY.js → connected-providers-grid-DUHMZjyV.js} +1 -1
  46. package/dist/gateway/static/root/assets/{connection-usage-guide-C8jPm7QO.js → connection-usage-guide-CM5qgMcK.js} +1 -1
  47. package/dist/gateway/static/root/assets/{connector-service-page-B42yWHxS.js → connector-service-page-DLbBblN2.js} +1 -1
  48. package/dist/gateway/static/root/assets/{connectors-api-so2a7xrD.js → connectors-api-BUdH4tZQ.js} +1 -1
  49. package/dist/gateway/static/root/assets/{connectors-page-yhOZIiUZ.js → connectors-page-HHGB3r3Q.js} +1 -1
  50. package/dist/gateway/static/root/assets/constants-D5Z-mUto.js +1 -0
  51. package/dist/gateway/static/root/assets/{date-picker-UEh3JM7r.js → date-picker-DRSq2kDz.js} +1 -1
  52. package/dist/gateway/static/root/assets/{date-time-picker-Dci0LfAU.js → date-time-picker--LGC1D3b.js} +1 -1
  53. package/dist/gateway/static/root/assets/{desktop-pet-BAU_GuBe.js → desktop-pet-1oXlQvjH.js} +1 -1
  54. package/dist/gateway/static/root/assets/{desktop-pet-settings-CYE2eTTf.js → desktop-pet-settings-GdOjz7W9.js} +1 -1
  55. package/dist/gateway/static/root/assets/{dev-view-store-C7v4CIlF.js → dev-view-store-DnQ2nBtV.js} +1 -1
  56. package/dist/gateway/static/root/assets/{device-pairing-wizard-7NDkYmiZ.js → device-pairing-wizard-eWeHH6Ru.js} +1 -1
  57. package/dist/gateway/static/root/assets/{directory-picker-path-field-DmRZY8kg.js → directory-picker-path-field-DBe_paLy.js} +1 -1
  58. package/dist/gateway/static/root/assets/extension-authoritative-grants-BqtUnmq-.js +1 -0
  59. package/dist/gateway/static/root/assets/{extension-debug-page-D8TAJgZ_.js → extension-debug-page-DIAyDA-a.js} +1 -1
  60. package/dist/gateway/static/root/assets/{extension-iframe-host-CjfRKtQ4.js → extension-iframe-host-CCe4R7L7.js} +1 -1
  61. package/dist/gateway/static/root/assets/{extension-marketplace-api-V1oFBxVi.js → extension-marketplace-api-baFXdV56.js} +1 -1
  62. package/dist/gateway/static/root/assets/{extension-message-router-DZahH1Hd.js → extension-message-router-BD0ZamBV.js} +1 -1
  63. package/dist/gateway/static/root/assets/{extension-page-DMuHBIHa.js → extension-page-C09dlV3J.js} +1 -1
  64. package/dist/gateway/static/root/assets/{extension-provider-lqJ1zIkA.js → extension-provider-BhluafoX.js} +1 -1
  65. package/dist/gateway/static/root/assets/{extension-settings-page-D5IfKVff.js → extension-settings-page-CB8KLYoG.js} +1 -1
  66. package/dist/gateway/static/root/assets/file-CStvVK2S.js +1 -0
  67. package/dist/gateway/static/root/assets/{file-BqMS_3DT.js → file-code-corner-byQA1VfD.js} +1 -1
  68. package/dist/gateway/static/root/assets/file-icon-N6WjUhq_.js +1 -0
  69. package/dist/gateway/static/root/assets/{file-preview-surface-B7B9qXm9.js → file-preview-surface-CeFFZo3a.js} +1 -1
  70. package/dist/gateway/static/root/assets/file-tree-CYUkQR1t.js +1 -0
  71. package/dist/gateway/static/root/assets/{gateway-config-swr-Dk3FtNv1.js → gateway-config-swr-DVXDJNCI.js} +1 -1
  72. package/dist/gateway/static/root/assets/{gateway-realtime-DMvo4pAc.js → gateway-realtime-BnwNxbyc.js} +1 -1
  73. package/dist/gateway/static/root/assets/gateway-realtime-store-BpnGXAhi.js +1 -0
  74. package/dist/gateway/static/root/assets/{gateway-restart-C2h5R1eP.js → gateway-restart-Bws2Shaz.js} +1 -1
  75. package/dist/gateway/static/root/assets/{gateway-settings-DGPaikv5.js → gateway-settings-BU5Cp4Bw.js} +1 -1
  76. package/dist/gateway/static/root/assets/{gateway-startup-retry-yZn7ShiP.js → gateway-startup-retry-2jU7zCyx.js} +1 -1
  77. package/dist/gateway/static/root/assets/{global-defaults-api-gsAa0Kj9.js → global-defaults-api-CNyJ0dGb.js} +1 -1
  78. package/dist/gateway/static/root/assets/{home-page-BBTtXpDD.js → home-page-8KwhWlYt.js} +3 -3
  79. package/dist/gateway/static/root/assets/{image-generation-api-DPn1SBMH.js → image-generation-api-CiqQSx5j.js} +1 -1
  80. package/dist/gateway/static/root/assets/{imports-page-Cc48Uq20.js → imports-page-B9JMNXwt.js} +1 -1
  81. package/dist/gateway/static/root/assets/index-CZUfwwLp.css +1 -0
  82. package/dist/gateway/static/root/assets/index-D5hovYIw.js +11 -0
  83. package/dist/gateway/static/root/assets/{install-connector-dialog-QkJMw_uW.js → install-connector-dialog-BZjodnUC.js} +1 -1
  84. package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-BZXqXuI4.js → keyboard-shortcuts-settings-A37hYJtR.js} +1 -1
  85. package/dist/gateway/static/root/assets/local-app-workbench-page-DmzgjJNj.js +1 -0
  86. package/dist/gateway/static/root/assets/{local-apps-page-D-bRvlZY.js → local-apps-page-Ct8z2B7R.js} +1 -1
  87. package/dist/gateway/static/root/assets/{local-session-drafts-CZ19DRRK.js → local-session-drafts-CgAuYyKi.js} +1 -1
  88. package/dist/gateway/static/root/assets/{locale-store-DIBIYLnI.js → locale-store-Cit_aHqC.js} +1 -1
  89. package/dist/gateway/static/root/assets/logs-page-CH9amuGc.js +2 -0
  90. package/dist/gateway/static/root/assets/{management-api-EG5duPec.js → management-api-DG-yZnHK.js} +1 -1
  91. package/dist/gateway/static/root/assets/{management-settings-B7RWHrwo.js → management-settings-CUQd0FJ3.js} +1 -1
  92. package/dist/gateway/static/root/assets/{markdown-view-C30KvTaE.js → markdown-view-Dm01GIXv.js} +1 -1
  93. package/dist/gateway/static/root/assets/{mcp-conversation-setup-page-BZ1PDTYY.js → mcp-conversation-setup-page-YvPXchDz.js} +1 -1
  94. package/dist/gateway/static/root/assets/{media-plugins-CW5UoTx6.js → media-plugins-jsWNdARw.js} +1 -1
  95. package/dist/gateway/static/root/assets/messages-DQveK9sk.js +3 -0
  96. package/dist/gateway/static/root/assets/{model-selector-COGICRIG.js → model-selector-Cg2kTsE7.js} +1 -1
  97. package/dist/gateway/static/root/assets/models-hub-cache-B2QcrY4n.js +1 -0
  98. package/dist/gateway/static/root/assets/note-detail-panel-DeFb2HEC.js +7 -0
  99. package/dist/gateway/static/root/assets/note-image-lightbox-DUzoWZEe.js +1 -0
  100. package/dist/gateway/static/root/assets/notes-api-BMSPkAm8.js +1 -0
  101. package/dist/gateway/static/root/assets/notes-page-nvqpOeHp.js +8 -0
  102. package/dist/gateway/static/root/assets/{oauth-api-enDU_32p.js → oauth-api-Bz_PU9R_.js} +1 -1
  103. package/dist/gateway/static/root/assets/{oauth-provider-connect-C2pfvPOI.js → oauth-provider-connect-BexlZuZ4.js} +1 -1
  104. package/dist/gateway/static/root/assets/{page-context-capture-button-BaSooYGv.js → page-context-capture-button-Cn4zi3Mt.js} +1 -1
  105. package/dist/gateway/static/root/assets/{page-context-draft-4-3RtO0q.js → page-context-draft-BjbX5zd7.js} +1 -1
  106. package/dist/gateway/static/root/assets/page-header-store-1-lflHAx.js +1 -0
  107. package/dist/gateway/static/root/assets/personal-avatar-CM3vUGhL.js +1 -0
  108. package/dist/gateway/static/root/assets/personal-avatar-DsEp8QJ7.css +1 -0
  109. package/dist/gateway/static/root/assets/personal-page-HFjWZacf.js +1 -0
  110. package/dist/gateway/static/root/assets/{personal-profile-settings-DwMdjQ6H.js → personal-profile-settings-CNI5Eor6.js} +1 -1
  111. package/dist/gateway/static/root/assets/{personal-settings-panel-DiNpP_g3.js → personal-settings-panel-BcrpYRn9.js} +1 -1
  112. package/dist/gateway/static/root/assets/{phone-dependencies-card-DUT-qRLZ.js → phone-dependencies-card-CJ3ovsW1.js} +1 -1
  113. package/dist/gateway/static/root/assets/{phone-model-connection-pvOciDNo.js → phone-model-connection-DKvOEjWH.js} +1 -1
  114. package/dist/gateway/static/root/assets/{phone-model-picker-CD97E6C5.js → phone-model-picker-CNTcpY1A.js} +1 -1
  115. package/dist/gateway/static/root/assets/{phone-settings-page-BUZ1dh7s.js → phone-settings-page-DvX6okzz.js} +1 -1
  116. package/dist/gateway/static/root/assets/{phone-workspace-store-BwilERgv.js → phone-workspace-store-CKOW55gy.js} +1 -1
  117. package/dist/gateway/static/root/assets/playback-coordinator-CWHIf0wr.js +1 -0
  118. package/dist/gateway/static/root/assets/{plugin-details-dialog-C_uOVmJv.js → plugin-details-dialog-BDoSffLO.js} +1 -1
  119. package/dist/gateway/static/root/assets/{preference-select-fields-BSUgcO7-.js → preference-select-fields-BKmzpfHq.js} +1 -1
  120. package/dist/gateway/static/root/assets/presentation-D-Ui_vVA.js +1 -0
  121. package/dist/gateway/static/root/assets/preview-runtime-RnBDP-Lq.js +15 -0
  122. package/dist/gateway/static/root/assets/product-automation-feedback-xAcXeJM2.js +7 -0
  123. package/dist/gateway/static/root/assets/product-delivery-4gEqUIsK.js +1 -0
  124. package/dist/gateway/static/root/assets/{product-open-page-Dy6D5exJ.js → product-open-page-DXwOPgRP.js} +1 -1
  125. package/dist/gateway/static/root/assets/{product-preview-content-DEUPAilo.js → product-preview-content-DiQbeaCK.js} +1 -1
  126. package/dist/gateway/static/root/assets/{product-preview-modal-C4TV9RUd.js → product-preview-modal-BU7Qojpq.js} +2 -2
  127. package/dist/gateway/static/root/assets/project-detail-page-Dr5_WPRB.js +7 -0
  128. package/dist/gateway/static/root/assets/{project-understanding-lOJ5Tz2V.js → project-understanding-Dv26vu9S.js} +1 -1
  129. package/dist/gateway/static/root/assets/{projects-page-B3aGdPHy.js → projects-page-DGATZB23.js} +1 -1
  130. package/dist/gateway/static/root/assets/{providers-api-C26HgxZY.js → providers-api-BXa2Aheb.js} +1 -1
  131. package/dist/gateway/static/root/assets/recording-upload-CQdhrRq3.js +1 -0
  132. package/dist/gateway/static/root/assets/{registry-api-pQ0eInzG.js → registry-api-BEnvt9-6.js} +1 -1
  133. package/dist/gateway/static/root/assets/{remote-access-hub-CjWrYzjf.js → remote-access-hub-_7tmWand.js} +1 -1
  134. package/dist/gateway/static/root/assets/{resource-unavailable-Y9WRHOnz.js → resource-unavailable-fk26VrOL.js} +1 -1
  135. package/dist/gateway/static/root/assets/right-workspace-store-NXMrEuwH.js +1 -0
  136. package/dist/gateway/static/root/assets/route-preload-D-pdVwIK.js +2 -0
  137. package/dist/gateway/static/root/assets/routine-panel-rjq-8nZ8.js +2 -0
  138. package/dist/gateway/static/root/assets/{runtime-tools-api-BoJQ3u5o.js → runtime-tools-api-CL6CG-qq.js} +1 -1
  139. package/dist/gateway/static/root/assets/{runtime-tools-settings-panel-DB7cfLrX.js → runtime-tools-settings-panel-CdvQRxCR.js} +1 -1
  140. package/dist/gateway/static/root/assets/scan-search-CSIGkseh.js +1 -0
  141. package/dist/gateway/static/root/assets/{service-recommendation-list-_rFmwIwY.js → service-recommendation-list-2UOjV0Mx.js} +1 -1
  142. package/dist/gateway/static/root/assets/{session-api-a6wb0_Gf.js → session-api-CkOliupg.js} +1 -1
  143. package/dist/gateway/static/root/assets/session-manager-BVS3zxRZ.js +22 -0
  144. package/dist/gateway/static/root/assets/{sessions-page-dEupc-3A.js → sessions-page-CN9ESZdY.js} +1 -1
  145. package/dist/gateway/static/root/assets/settings-advanced-gate-BYrXsPjK.js +1 -0
  146. package/dist/gateway/static/root/assets/{settings-advanced-section-CnGJr2xp.js → settings-advanced-section-Zex2dJo7.js} +1 -1
  147. package/dist/gateway/static/root/assets/{settings-mode-store-DWRhupcY.js → settings-mode-store-Dk0bZQgo.js} +1 -1
  148. package/dist/gateway/static/root/assets/{settings-page-D9A2DdJ_.js → settings-page-bCW4rave.js} +1 -1
  149. package/dist/gateway/static/root/assets/{settings-page-header-wL2jvs-y.js → settings-page-header-B9Y_eGcH.js} +1 -1
  150. package/dist/gateway/static/root/assets/{settings-page-layout-BkUQVmyY.js → settings-page-layout-D1MgJ5zP.js} +1 -1
  151. package/dist/gateway/static/root/assets/{setup-interaction-page-D238tuw-.js → setup-interaction-page-BYXDX0F2.js} +1 -1
  152. package/dist/gateway/static/root/assets/{setup-status-panel-DXvYjIu3.js → setup-status-panel-Bhda3jS2.js} +1 -1
  153. package/dist/gateway/static/root/assets/{share-link-dialog-DFDJyl3N.js → share-link-dialog-BxFk4-4u.js} +1 -1
  154. package/dist/gateway/static/root/assets/share-preview-page-nzWjWhqF.js +2 -0
  155. package/dist/gateway/static/root/assets/{shares-api-CfFiW03g.js → shares-api-ChBHTPKN.js} +1 -1
  156. package/dist/gateway/static/root/assets/shares-settings-LB3SYKFS.js +1 -0
  157. package/dist/gateway/static/root/assets/sheet-C2H8iR8Y.js +1 -0
  158. package/dist/gateway/static/root/assets/{skill-api-CWRhFSkA.js → skill-api-TQAyWHGS.js} +1 -1
  159. package/dist/gateway/static/root/assets/{skill-list-api-CmPp2czp.js → skill-list-api-D4eokPXx.js} +1 -1
  160. package/dist/gateway/static/root/assets/{skill-reload-api-BGsSq3dj.js → skill-reload-api-Bm-8vhsQ.js} +1 -1
  161. package/dist/gateway/static/root/assets/{skills-page-DqD0FPeH.js → skills-page-CfhEcU8L.js} +1 -1
  162. package/dist/gateway/static/root/assets/space-api-DaKpHc_7.js +1 -0
  163. package/dist/gateway/static/root/assets/space-page-BXyQdUvp.js +2 -0
  164. package/dist/gateway/static/root/assets/star-BuMAkjC9.js +1 -0
  165. package/dist/gateway/static/root/assets/{system-settings-panel-aw9C86I8.js → system-settings-panel-CvL5G2w1.js} +1 -1
  166. package/dist/gateway/static/root/assets/task-detail-page-gffrDRvW.js +3 -0
  167. package/dist/gateway/static/root/assets/task-header-title-DwtjUOBg.js +1 -0
  168. package/dist/gateway/static/root/assets/{task-result-evidence-C-zIBpzi.js → task-result-evidence-Bmgta9z9.js} +1 -1
  169. package/dist/gateway/static/root/assets/tasks-BIehlq7k.js +1 -0
  170. package/dist/gateway/static/root/assets/{terminal-panel-store-CgPqgrm7.js → terminal-panel-store-B1bAD5Xf.js} +1 -1
  171. package/dist/gateway/static/root/assets/{theme-store-DxF7S6I2.js → theme-store-C1MxmBg7.js} +1 -1
  172. package/dist/gateway/static/root/assets/{tracing-settings-page-Dvlunx28.js → tracing-settings-page-CvXDgIJQ.js} +1 -1
  173. package/dist/gateway/static/root/assets/{tunnel-api-CIte6n0U.js → tunnel-api-BkhCBt38.js} +1 -1
  174. package/dist/gateway/static/root/assets/turn-outcome-BSbEJx8h.js +1 -0
  175. package/dist/gateway/static/root/assets/{understanding-activity-store-C2RHmRo8.js → understanding-activity-store-BYGCmCVb.js} +1 -1
  176. package/dist/gateway/static/root/assets/{understanding-refresh-store-CPeQIXS_.js → understanding-refresh-store-DaLVsdYS.js} +1 -1
  177. package/dist/gateway/static/root/assets/{usage-page-DPUjEj39.js → usage-page-C-NM6vtY.js} +1 -1
  178. package/dist/gateway/static/root/assets/{use-autosave-xX2KrbXw.js → use-autosave-CvjQMyY8.js} +1 -1
  179. package/dist/gateway/static/root/assets/use-composer-attachments-sszsCdh5.js +2 -0
  180. package/dist/gateway/static/root/assets/use-file-preview-expanded-D4b4fDeu.js +1 -0
  181. package/dist/gateway/static/root/assets/use-personal-profile-CNPszzzT.js +1 -0
  182. package/dist/gateway/static/root/assets/use-personal-work-C-rw8XVO.js +1 -0
  183. package/dist/gateway/static/root/assets/{use-realtime-voice-RQW5KnIN.js → use-realtime-voice-cugjs8cK.js} +1 -1
  184. package/dist/gateway/static/root/assets/{use-workspace-tree-B6QFV5gR.js → use-workspace-tree-Crfx5ctU.js} +1 -1
  185. package/dist/gateway/static/root/assets/{user-model-page-hKnsTcMk.js → user-model-page-BvnLbTYx.js} +1 -1
  186. package/dist/gateway/static/root/assets/video-generation-Cec49Jwg.js +1 -0
  187. package/dist/gateway/static/root/assets/{voice-api-key-field-BeEF7Thh.js → voice-api-key-field-M7KB_Gl1.js} +1 -1
  188. package/dist/gateway/static/root/assets/{voice-config-api-vbBoKnqd.js → voice-config-api-BLGbUq3v.js} +1 -1
  189. package/dist/gateway/static/root/assets/{voice-input-shortcut-events-CKn6X3qL.js → voice-input-shortcut-events-CxH3RDXi.js} +1 -1
  190. package/dist/gateway/static/root/assets/voice-player-store-DZGlzjva.js +1 -0
  191. package/dist/gateway/static/root/assets/voice-settings-BzfNK5Jm.js +1 -0
  192. package/dist/gateway/static/root/assets/{work-discovery-overlay-Ddvqu02U.js → work-discovery-overlay-DpEYgcG2.js} +1 -1
  193. package/dist/gateway/static/root/assets/{work-discovery-page-BdBpri6P.js → work-discovery-page-DappIHQq.js} +1 -1
  194. package/dist/gateway/static/root/assets/{working-directory-picker-modal-DStgfCzQ.js → working-directory-picker-modal-W2QiUVjN.js} +1 -1
  195. package/dist/gateway/static/root/assets/workspace-api-g-wCKoQU.js +2 -0
  196. package/dist/gateway/static/root/assets/workspace-editor-agent-store-DwpWKogz.js +1 -0
  197. package/dist/gateway/static/root/assets/workspace-file-preview-dialog-DxaxVC3q.js +1 -0
  198. package/dist/gateway/static/root/assets/{workspace-open-location-menu-CBHFZ2iQ.js → workspace-open-location-menu-Dh0TvTkH.js} +1 -1
  199. package/dist/gateway/static/root/assets/workspace-preview-store-DoIjn_2j.js +1 -0
  200. package/dist/gateway/static/root/assets/{xopc-cloud-account-card-Cm0Saa8B.js → xopc-cloud-account-card-DGAGXbGI.js} +1 -1
  201. package/dist/gateway/static/root/index.html +136 -123
  202. package/dist/package.js +1 -1
  203. package/dist/packages/gateway-contract/src/automations.js +7 -0
  204. package/dist/packages/gateway-contract/src/capabilities.js +1 -1
  205. package/dist/packages/gateway-contract/src/clarifications.js +20 -2
  206. package/dist/packages/gateway-contract/src/index.js +6 -4
  207. package/dist/packages/gateway-contract/src/music-generation.js +5 -2
  208. package/dist/packages/gateway-contract/src/space.js +23 -0
  209. package/dist/packages/gateway-contract/src/task-lifecycle.js +1 -0
  210. package/dist/packages/gateway-contract/src/task-result-delivery.js +1 -0
  211. package/dist/packages/gateway-contract/src/task-runs.js +1 -0
  212. package/dist/packages/gateway-contract/src/tasks.js +118 -6
  213. package/dist/packages/gateway-contract/src/turn-outcome.js +16 -2
  214. package/dist/packages/gateway-contract/src/video-generation.js +29 -4
  215. package/dist/src/agent/agent-manager.js +2 -2
  216. package/dist/src/agent/background-review/prompts.js +5 -1
  217. package/dist/src/agent/embedded/agent-profile-context.js +1 -1
  218. package/dist/src/agent/inbound/attachment-pipeline.js +1 -1
  219. package/dist/src/agent/orchestration/delegation-budget.d.ts +2 -2
  220. package/dist/src/agent/orchestration/turn-recovery.d.ts +12 -3
  221. package/dist/src/agent/orchestration/turn-recovery.js +25 -6
  222. package/dist/src/agent/service/process-direct-streaming.js +1 -1
  223. package/dist/src/agent/service/webchat-tts.js +1 -1
  224. package/dist/src/agent/service.js +1 -1
  225. package/dist/src/agent/tasks/task-judge-service.js +1 -1
  226. package/dist/src/agent/tools/apply-patch.js +1 -1
  227. package/dist/src/agent/tools/factory.js +1 -1
  228. package/dist/src/agent/tools/image-generate-tool.js +1 -0
  229. package/dist/src/agent/tools/language-diagnostics.js +1 -1
  230. package/dist/src/agent/tools/personal-memory-tool.js +12 -10
  231. package/dist/src/agent/tools/personal-task-tool.d.ts +1 -0
  232. package/dist/src/agent/tools/personal-task-tool.js +12 -7
  233. package/dist/src/agent/tools/publish-artifacts.js +2 -1
  234. package/dist/src/agent/tools/review-workspace.js +1 -1
  235. package/dist/src/agent/tools/send-media.js +1 -0
  236. package/dist/src/agent/tools/tool-media.d.ts +3 -1
  237. package/dist/src/agent/tools/tool-media.js +2 -0
  238. package/dist/src/agent/tools/video-draft-tool.d.ts +1 -0
  239. package/dist/src/agent/tools/video-draft-tool.js +5 -1
  240. package/dist/src/agent/tools/xopc-use-tool.js +21 -4
  241. package/dist/src/agent-catalog/test-support.js +1 -1
  242. package/dist/src/agent-matching/delegation-service.js +1 -1
  243. package/dist/src/automations/capabilities/drafts.js +1 -1
  244. package/dist/src/automations/capabilities/write.d.ts +30 -6
  245. package/dist/src/automations/capabilities/write.js +2 -2
  246. package/dist/src/automations/configuration-conversation.js +1 -1
  247. package/dist/src/automations/domain/types.d.ts +6 -0
  248. package/dist/src/automations/domain/validation.d.ts +60 -12
  249. package/dist/src/automations/domain/validation.js +7 -0
  250. package/dist/src/automations/draft/automation-draft-validator.d.ts +12 -3
  251. package/dist/src/automations/draft/automation-draft-validator.js +1 -0
  252. package/dist/src/automations/service/action-executor.js +14 -2
  253. package/dist/src/automations/service/automation-service.js +2 -2
  254. package/dist/src/browser/providers/browser-ext-install.js +1 -1
  255. package/dist/src/cli/commands/doctor/checks/database-schema.js +1 -1
  256. package/dist/src/computer/diagnostics.d.ts +9 -9
  257. package/dist/src/computer/errors.d.ts +2 -2
  258. package/dist/src/computer/evaluation.d.ts +7 -7
  259. package/dist/src/computer/runtime.d.ts +4 -4
  260. package/dist/src/config/schema.d.ts +2 -2
  261. package/dist/src/discussions/action-tasks.d.ts +2 -2
  262. package/dist/src/execution-environments/local-worktree-manager.js +1 -1
  263. package/dist/src/extensions/agent-plugins/inventory.d.ts +2 -2
  264. package/dist/src/extensions/agent-plugins/setup.d.ts +3 -3
  265. package/dist/src/gateway/hono/routes/commands-skills.js +1 -1
  266. package/dist/src/gateway/hono/routes/connectors.js +2 -2
  267. package/dist/src/gateway/hono/routes/context-sources.js +1 -1
  268. package/dist/src/gateway/hono/routes/lazy-bundles.js +8 -0
  269. package/dist/src/gateway/hono/routes/memory-learning.js +19 -3
  270. package/dist/src/gateway/hono/routes/models.js +7 -0
  271. package/dist/src/gateway/hono/routes/music-generation.js +26 -3
  272. package/dist/src/gateway/hono/routes/personal-agent.js +214 -5
  273. package/dist/src/gateway/hono/routes/phone-setup.js +1 -1
  274. package/dist/src/gateway/hono/routes/space.d.ts +3 -0
  275. package/dist/src/gateway/hono/routes/space.js +105 -0
  276. package/dist/src/gateway/hono/routes/tasks.js +27 -28
  277. package/dist/src/gateway/hono/routes/video-generation.js +9 -6
  278. package/dist/src/gateway/html-preview-shell.d.ts +1 -1
  279. package/dist/src/gateway/html-preview-shell.js +3 -0
  280. package/dist/src/gateway/media-access.js +2 -2
  281. package/dist/src/gateway/security/gateway-scopes.js +2 -0
  282. package/dist/src/gateway/service/config-coordinator.d.ts +1 -1
  283. package/dist/src/gateway/service.d.ts +1 -0
  284. package/dist/src/gateway/service.js +10 -3
  285. package/dist/src/gateway/session-context-summary.js +1 -1
  286. package/dist/src/gateway/xopc-cloud-capability-setup.d.ts +2 -0
  287. package/dist/src/gateway/xopc-cloud-capability-setup.js +18 -1
  288. package/dist/src/home-intelligence/follow-ups.js +2 -1
  289. package/dist/src/home-intelligence/routines.js +1 -1
  290. package/dist/src/local-apps/automation-proposals.d.ts +54 -12
  291. package/dist/src/local-apps/capabilities/projections.d.ts +7 -7
  292. package/dist/src/local-apps/preview-fixtures.d.ts +1 -1
  293. package/dist/src/media/session-references.d.ts +4 -1
  294. package/dist/src/media/session-references.js +40 -8
  295. package/dist/src/memory-learning/work-capture.js +2 -1
  296. package/dist/src/memory-learning/work-review.d.ts +2 -0
  297. package/dist/src/memory-learning/work-review.js +25 -2
  298. package/dist/src/music-generation/artifact.js +3 -1
  299. package/dist/src/music-generation/mureka.js +1 -1
  300. package/dist/src/music-generation/provider.d.ts +4 -1
  301. package/dist/src/music-generation/provider.js +6 -1
  302. package/dist/src/music-generation/providers.d.ts +3 -1
  303. package/dist/src/music-generation/providers.js +39 -16
  304. package/dist/src/music-generation/repository.d.ts +3 -1
  305. package/dist/src/music-generation/repository.js +12 -3
  306. package/dist/src/music-generation/tencent-mps.d.ts +11 -0
  307. package/dist/src/music-generation/tencent-mps.js +151 -0
  308. package/dist/src/music-generation/worker.js +16 -5
  309. package/dist/src/music-generation/xopc-cloud.d.ts +2 -0
  310. package/dist/src/music-generation/xopc-cloud.js +38 -0
  311. package/dist/src/personal-agent/capability-service.js +1 -1
  312. package/dist/src/personal-agent/proactivity/service.js +1 -1
  313. package/dist/src/personal-agent/prompt-context.js +1 -1
  314. package/dist/src/personal-agent/prompts.js +2 -2
  315. package/dist/src/personal-agent/reply-composer.js +16 -7
  316. package/dist/src/personal-agent/repository.js +1 -1
  317. package/dist/src/personal-agent/request-delivery.js +17 -7
  318. package/dist/src/personal-agent/request-service.js +6 -10
  319. package/dist/src/personal-agent/result-extraction.js +13 -13
  320. package/dist/src/personal-agent/schedules.d.ts +9 -0
  321. package/dist/src/personal-agent/schedules.js +44 -0
  322. package/dist/src/personal-agent/service.js +1 -1
  323. package/dist/src/providers/model-catalog-persistence.js +6 -1
  324. package/dist/src/providers/model-catalog-store.js +1 -0
  325. package/dist/src/providers/model-catalog-types.d.ts +2 -0
  326. package/dist/src/providers/xopc-cloud-media-manifest.d.ts +24 -0
  327. package/dist/src/providers/xopc-cloud-media-manifest.js +28 -0
  328. package/dist/src/providers/xopc-cloud-media.d.ts +28 -0
  329. package/dist/src/providers/xopc-cloud-media.js +67 -0
  330. package/dist/src/providers/xopc-cloud-model-source.js +4 -0
  331. package/dist/src/runtime-tools/archive.js +1 -1
  332. package/dist/src/runtime-tools/manager.js +1 -1
  333. package/dist/src/runtime-tools/phone-dependencies.js +1 -1
  334. package/dist/src/session/client-history.d.ts +4 -1
  335. package/dist/src/session/client-history.js +18 -0
  336. package/dist/src/session/compact-history.js +30 -1
  337. package/dist/src/session/store.js +2 -1
  338. package/dist/src/session/turn-outcome-projector.js +1 -1
  339. package/dist/src/space/ingest.d.ts +36 -0
  340. package/dist/src/space/ingest.js +149 -0
  341. package/dist/src/space/repository.d.ts +39 -0
  342. package/dist/src/space/repository.js +325 -0
  343. package/dist/src/space/worker.d.ts +14 -0
  344. package/dist/src/space/worker.js +199 -0
  345. package/dist/src/storage/sqlite/clarification-wait-repository.js +7 -4
  346. package/dist/src/storage/sqlite/row-mappers.d.ts +1 -0
  347. package/dist/src/storage/sqlite/row-mappers.js +9 -2
  348. package/dist/src/storage/sqlite/schema.d.ts +2 -2
  349. package/dist/src/storage/sqlite/schema.js +8 -7
  350. package/dist/src/storage/sqlite/schema.sql +104 -0
  351. package/dist/src/storage/sqlite/transcript-repository.js +8 -0
  352. package/dist/src/storage/sqlite/upgrades/278_music_job_error_code.sql +6 -0
  353. package/dist/src/storage/sqlite/upgrades/279_task_model_cutover.sql +288 -0
  354. package/dist/src/storage/sqlite/upgrades/280_space.sql +61 -0
  355. package/dist/src/tasks/capabilities/management.d.ts +15 -2
  356. package/dist/src/tasks/capabilities/management.js +8 -2
  357. package/dist/src/tasks/capabilities/read.js +14 -2
  358. package/dist/src/tasks/capabilities/relations.d.ts +13 -7
  359. package/dist/src/tasks/capabilities/write.d.ts +118 -2
  360. package/dist/src/tasks/capabilities/write.js +2 -0
  361. package/dist/src/tasks/home-query-service.js +7 -9
  362. package/dist/src/tasks/task-allocation-service.js +2 -2
  363. package/dist/src/tasks/task-application-service.d.ts +8 -2
  364. package/dist/src/tasks/task-application-service.js +94 -27
  365. package/dist/src/tasks/task-collaboration-repository.js +12 -1
  366. package/dist/src/tasks/task-context-assembler.js +9 -3
  367. package/dist/src/tasks/task-contract-planner.js +1 -3
  368. package/dist/src/tasks/task-conversation-summary.d.ts +33 -2
  369. package/dist/src/tasks/task-conversation-summary.js +3 -1
  370. package/dist/src/tasks/task-criterion-review-repository.d.ts +31 -2
  371. package/dist/src/tasks/task-criterion-review-repository.js +70 -23
  372. package/dist/src/tasks/task-deliverables.d.ts +7 -0
  373. package/dist/src/tasks/task-deliverables.js +112 -0
  374. package/dist/src/tasks/task-handoff-service.js +1 -1
  375. package/dist/src/tasks/task-instruction-sequence.js +10 -3
  376. package/dist/src/tasks/task-json-acceptance.js +3 -5
  377. package/dist/src/tasks/task-origin-repository.d.ts +99 -1
  378. package/dist/src/tasks/task-origin-repository.js +67 -5
  379. package/dist/src/tasks/task-read-model-projector.d.ts +4 -1
  380. package/dist/src/tasks/task-read-model-projector.js +123 -9
  381. package/dist/src/tasks/task-repository.d.ts +4 -1
  382. package/dist/src/tasks/task-repository.js +34 -11
  383. package/dist/src/tasks/task-research-repair.d.ts +2 -2
  384. package/dist/src/tasks/task-research-result.d.ts +1 -0
  385. package/dist/src/tasks/task-research-result.js +13 -3
  386. package/dist/src/tasks/task-result-delivery-repository.d.ts +4 -3
  387. package/dist/src/tasks/task-result-delivery-repository.js +35 -17
  388. package/dist/src/tasks/task-result-delivery-service.js +22 -7
  389. package/dist/src/tasks/task-result-versions.d.ts +11 -0
  390. package/dist/src/tasks/task-result-versions.js +34 -0
  391. package/dist/src/tasks/task-run-coordinator.js +28 -15
  392. package/dist/src/tasks/task-run-dispatcher.js +29 -4
  393. package/dist/src/tasks/task-run-repository.d.ts +2 -0
  394. package/dist/src/tasks/task-run-repository.js +62 -19
  395. package/dist/src/tasks/task-workspace-verification.d.ts +16 -0
  396. package/dist/src/tasks/task-workspace-verification.js +95 -0
  397. package/dist/src/tui/backends/embedded-backend.js +2 -2
  398. package/dist/src/user-model/action-rule-suggestions.js +4 -3
  399. package/dist/src/user-model/capture/evidence-policy.d.ts +7 -1
  400. package/dist/src/user-model/capture/evidence-policy.js +68 -2
  401. package/dist/src/user-model/capture/executor.js +62 -14
  402. package/dist/src/video-generation/artifact.js +3 -1
  403. package/dist/src/video-generation/drafts.d.ts +1 -0
  404. package/dist/src/video-generation/drafts.js +6 -0
  405. package/dist/src/video-generation/providers.d.ts +1 -0
  406. package/dist/src/video-generation/providers.js +37 -5
  407. package/dist/src/video-generation/repository.d.ts +5 -3
  408. package/dist/src/video-generation/repository.js +30 -8
  409. package/dist/src/video-generation/settings.d.ts +1 -0
  410. package/dist/src/video-generation/settings.js +10 -4
  411. package/dist/src/voice/realtime/runtime.js +1 -1
  412. package/package.json +1 -1
  413. package/dist/gateway/static/root/assets/attachment-preview-renderer-DdOEgexg.js +0 -12
  414. package/dist/gateway/static/root/assets/attachment-utils-core-BIOUBrpT.js +0 -1
  415. package/dist/gateway/static/root/assets/automations-workspace-CH9gYqIK.js +0 -9
  416. package/dist/gateway/static/root/assets/binary-plugins-MFVtTdvy.js +0 -2
  417. package/dist/gateway/static/root/assets/capabilities-CFWTer_v.js +0 -1
  418. package/dist/gateway/static/root/assets/capabilities-page-C2RB9fzC.js +0 -2
  419. package/dist/gateway/static/root/assets/capabilities-settings-panel-BjaLTd6i.js +0 -8
  420. package/dist/gateway/static/root/assets/channels-DiDfjON8.js +0 -1
  421. package/dist/gateway/static/root/assets/chat-page-BtMkdtxJ.js +0 -71
  422. package/dist/gateway/static/root/assets/constants-Bg1wM2nv.js +0 -1
  423. package/dist/gateway/static/root/assets/extension-authoritative-grants-DIeg1mg8.js +0 -1
  424. package/dist/gateway/static/root/assets/file-tree-CFlZnV3Y.js +0 -1
  425. package/dist/gateway/static/root/assets/gateway-realtime-store-CJf-qaHZ.js +0 -1
  426. package/dist/gateway/static/root/assets/index-BJj-uZNl.js +0 -11
  427. package/dist/gateway/static/root/assets/index-DiWUK4sJ.css +0 -1
  428. package/dist/gateway/static/root/assets/local-app-workbench-page-wekatwet.js +0 -1
  429. package/dist/gateway/static/root/assets/local-apps-DeqzkJiF.js +0 -1
  430. package/dist/gateway/static/root/assets/logs-page-CukseY3k.js +0 -2
  431. package/dist/gateway/static/root/assets/messages-BDBGlBKh.js +0 -3
  432. package/dist/gateway/static/root/assets/models-hub-cache-aRYHi2dh.js +0 -1
  433. package/dist/gateway/static/root/assets/note-detail-panel-D5BtgBxy.js +0 -7
  434. package/dist/gateway/static/root/assets/note-image-lightbox-CxXu_Tkh.js +0 -1
  435. package/dist/gateway/static/root/assets/notes-api-BXevQivV.js +0 -1
  436. package/dist/gateway/static/root/assets/notes-page-DyM-3O_9.js +0 -8
  437. package/dist/gateway/static/root/assets/page-header-store-C2ydtnXa.js +0 -1
  438. package/dist/gateway/static/root/assets/personal-avatar-BPQpvC34.js +0 -1
  439. package/dist/gateway/static/root/assets/personal-avatar-BUCb7OiW.css +0 -1
  440. package/dist/gateway/static/root/assets/personal-page-BB4Sv68K.js +0 -1
  441. package/dist/gateway/static/root/assets/phone-DdhTnt6X.js +0 -1
  442. package/dist/gateway/static/root/assets/product-automation-feedback-BlwtlUY7.js +0 -7
  443. package/dist/gateway/static/root/assets/product-delivery-CnvCn9L-.js +0 -1
  444. package/dist/gateway/static/root/assets/project-detail-page-BG2nDt98.js +0 -7
  445. package/dist/gateway/static/root/assets/recording-upload-BJkXktA-.js +0 -1
  446. package/dist/gateway/static/root/assets/right-workspace-store-DHHyicqQ.js +0 -1
  447. package/dist/gateway/static/root/assets/route-preload-BYqg1BYz.js +0 -2
  448. package/dist/gateway/static/root/assets/routine-panel-Coh2B0j7.js +0 -2
  449. package/dist/gateway/static/root/assets/session-manager-D5g6LOU-.js +0 -25
  450. package/dist/gateway/static/root/assets/settings-advanced-gate-DjyibJZ1.js +0 -1
  451. package/dist/gateway/static/root/assets/share-preview-page-CyCv69rh.js +0 -2
  452. package/dist/gateway/static/root/assets/shares-settings-B85XIDFv.js +0 -1
  453. package/dist/gateway/static/root/assets/star-CnYNmpLd.js +0 -1
  454. package/dist/gateway/static/root/assets/task-detail-page-DgsLOz6h.js +0 -3
  455. package/dist/gateway/static/root/assets/tasks-BTLabOMp.js +0 -1
  456. package/dist/gateway/static/root/assets/use-composer-attachments-C9GpCJQR.js +0 -2
  457. package/dist/gateway/static/root/assets/use-file-preview-expanded-Daf-LmiF.js +0 -15
  458. package/dist/gateway/static/root/assets/use-personal-profile-BJgaheR4.js +0 -1
  459. package/dist/gateway/static/root/assets/video-generation-D08uZbsu.js +0 -1
  460. package/dist/gateway/static/root/assets/voice-settings-BUrk4mwV.js +0 -1
  461. package/dist/gateway/static/root/assets/with-selector-xonYxPoM.js +0 -1
  462. package/dist/gateway/static/root/assets/workspace-api-CscTRODe.js +0 -2
  463. package/dist/gateway/static/root/assets/workspace-editor-agent-store-CyPjTDSx.js +0 -1
  464. package/dist/gateway/static/root/assets/workspace-file-preview-dialog-JSGIA79T.js +0 -1
  465. package/dist/gateway/static/root/assets/workspace-preview-store-DNLnuHlf.js +0 -1
@@ -1 +1 @@
1
- import{i as e,o as t,p as n}from"./locale-store-DIBIYLnI.js";import{t as r}from"./createLucideIcon-DPHK1VkS.js";var i=r(`file-clock`,[[`path`,{d:`M16 22h2a2 2 0 0 0 2-2V8a2.4 2.4 0 0 0-.706-1.706l-3.588-3.588A2.4 2.4 0 0 0 14 2H6a2 2 0 0 0-2 2v2.85`,key:`ryk6xj`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M8 14v2.2l1.6 1`,key:`6m4bie`}],[`circle`,{cx:`8`,cy:`16`,r:`6`,key:`10v15b`}]]),a=r(`mail`,[[`path`,{d:`m22 7-8.991 5.727a2 2 0 0 1-2.009 0L2 7`,key:`132q7q`}],[`rect`,{x:`2`,y:`4`,width:`20`,height:`16`,rx:`2`,key:`izxlao`}]]);async function o(){return t(e(`/api/onboarding/work-discovery`))}async function s(){await t(e(`/api/onboarding/work-discovery`),{method:`PATCH`,body:JSON.stringify({status:`dismissed`})})}async function c(n){return(await t(e(`/api/work-discovery/preview`),{method:`POST`,body:JSON.stringify({rootPath:n})})).preview}async function l(){let n=await t(e(`/api/work-discovery/candidates`),{method:`POST`});return{candidates:n.candidates,processingTarget:n.processingTarget}}async function u(n,r){return(await t(e(`/api/context-sources/work-folders`),{method:`POST`,body:JSON.stringify({rootPath:n,processingPolicy:r})})).source}async function d(n,r,i,a){return t(e(`/api/context-sources/bootstrap`),{method:`POST`,body:JSON.stringify({items:n,processingPolicy:i,...r?{workDiscoveryRunId:r}:{},sourceCheckpoints:a})})}async function f(n){return(await t(e(`/api/work-discovery/runs`),{method:`POST`,body:JSON.stringify({rootPath:n,source:`onboarding_selected_directory`,idempotencyKey:crypto.randomUUID()})})).run}async function p(n){return(await t(e(`/api/work-discovery/runs/${encodeURIComponent(n)}`))).run}async function m(n){return(await t(e(`/api/work-discovery/runs/${encodeURIComponent(n)}/cancel`),{method:`POST`})).run}async function h(n){return(await t(e(`/api/work-discovery/runs/${encodeURIComponent(n)}/retry`),{method:`POST`})).run}async function g(n,r,i){return(await t(e(`/api/work-discovery/runs/${encodeURIComponent(n)}/recognition-feedback`),{method:`POST`,body:JSON.stringify({decision:r,correctedIntent:i})})).run}async function _(n,r){await t(e(`/api/work-discovery/runs/${encodeURIComponent(n)}/suggestions/${encodeURIComponent(r)}/select`),{method:`POST`})}function v(e,t){return Object.fromEntries(e.map(e=>[e,t]))}function y(e,t){let n=v(t,`running`);for(let t of e)n[t.sourceId]=t.status;return n}async function b(e){if(!e)return;let t=Date.now()+75e3;for(;Date.now()<t;){try{let t=await p(e);if(S.getState().updateDirectoryRun(t),t.status===`completed`||t.status===`failed`||t.status===`canceled`)return}catch{}await new Promise(e=>window.setTimeout(e,800))}}var x={status:`idle`,drawerOpen:!1,directoryStatus:`idle`,directoryRun:null,sources:{},itemCounts:{},memories:[],threads:[],error:void 0},S=n((e,t)=>({...x,setDrawerOpen:n=>{!n&&t().status===`completed`?e({...x}):e({drawerOpen:n})},finish:()=>e({...x}),updateDirectoryRun:n=>{let r=n.status===`completed`?`completed`:n.status===`failed`||n.status===`canceled`?`failed`:`running`,i=Object.values(t().sources).every(e=>e!==`running`&&e!==`idle`),a=Object.values(t().sources).some(e=>e===`denied`||e===`failed`||e===`partial`);e({directoryStatus:r,directoryRun:n,status:r===`completed`&&i?a?`partial`:`completed`:r===`failed`&&i?`partial`:`running`})},collectSources:async(n,r,i)=>{let a=window.electronAPI?.understandingSources?.collect;if(!(!a||!r.length)){e({status:`running`,sources:v(r,`running`),itemCounts:Object.fromEntries(r.map(e=>[e,0])),memories:[],threads:[],error:void 0});try{let o=await a(r),s=y(o,r),c=Object.fromEntries(o.map(e=>[e.sourceId,e.items.length]));e({sources:s,itemCounts:c});let l=o.flatMap(e=>e.status===`completed`?e.items:[]),u=Object.fromEntries(o.flatMap(e=>e.checkpoint?[[e.sourceId,e.checkpoint]]:[]));l.length&&await b(n);let f=l.length?await d(l,n,i,u):{profileCandidates:[],workThreads:[],knowledgeCandidates:[],sourceStatuses:[]};for(let e of f.sourceStatuses)s[e.sourceId]=e.status;let p=f.profileCandidates,m=Object.values(s).some(e=>e===`denied`||e===`failed`||e===`partial`),h=f.sourceStatuses.flatMap(e=>e.error?[e.error]:[]),g=!n||t().directoryStatus===`completed`;e({sources:s,itemCounts:c,memories:p,threads:f.workThreads,...h.length?{error:h.join(`; `)}:{},status:g?m?`partial`:`completed`:`running`})}catch(t){e(e=>({status:`partial`,sources:Object.fromEntries(Object.entries(e.sources).map(([e,t])=>[e,t===`running`?`failed`:t])),error:t instanceof Error?t.message:String(t)}))}}}}));export{o as a,c,f as d,g as f,s as i,h as l,i as m,m as n,p as o,a as p,l as r,u as s,S as t,_ as u};
1
+ import{i as e,o as t,p as n}from"./locale-store-Cit_aHqC.js";import{t as r}from"./createLucideIcon-DPHK1VkS.js";var i=r(`file-clock`,[[`path`,{d:`M16 22h2a2 2 0 0 0 2-2V8a2.4 2.4 0 0 0-.706-1.706l-3.588-3.588A2.4 2.4 0 0 0 14 2H6a2 2 0 0 0-2 2v2.85`,key:`ryk6xj`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M8 14v2.2l1.6 1`,key:`6m4bie`}],[`circle`,{cx:`8`,cy:`16`,r:`6`,key:`10v15b`}]]),a=r(`mail`,[[`path`,{d:`m22 7-8.991 5.727a2 2 0 0 1-2.009 0L2 7`,key:`132q7q`}],[`rect`,{x:`2`,y:`4`,width:`20`,height:`16`,rx:`2`,key:`izxlao`}]]);async function o(){return t(e(`/api/onboarding/work-discovery`))}async function s(){await t(e(`/api/onboarding/work-discovery`),{method:`PATCH`,body:JSON.stringify({status:`dismissed`})})}async function c(n){return(await t(e(`/api/work-discovery/preview`),{method:`POST`,body:JSON.stringify({rootPath:n})})).preview}async function l(){let n=await t(e(`/api/work-discovery/candidates`),{method:`POST`});return{candidates:n.candidates,processingTarget:n.processingTarget}}async function u(n,r){return(await t(e(`/api/context-sources/work-folders`),{method:`POST`,body:JSON.stringify({rootPath:n,processingPolicy:r})})).source}async function d(n,r,i,a){return t(e(`/api/context-sources/bootstrap`),{method:`POST`,body:JSON.stringify({items:n,processingPolicy:i,...r?{workDiscoveryRunId:r}:{},sourceCheckpoints:a})})}async function f(n){return(await t(e(`/api/work-discovery/runs`),{method:`POST`,body:JSON.stringify({rootPath:n,source:`onboarding_selected_directory`,idempotencyKey:crypto.randomUUID()})})).run}async function p(n){return(await t(e(`/api/work-discovery/runs/${encodeURIComponent(n)}`))).run}async function m(n){return(await t(e(`/api/work-discovery/runs/${encodeURIComponent(n)}/cancel`),{method:`POST`})).run}async function h(n){return(await t(e(`/api/work-discovery/runs/${encodeURIComponent(n)}/retry`),{method:`POST`})).run}async function g(n,r,i){return(await t(e(`/api/work-discovery/runs/${encodeURIComponent(n)}/recognition-feedback`),{method:`POST`,body:JSON.stringify({decision:r,correctedIntent:i})})).run}async function _(n,r){await t(e(`/api/work-discovery/runs/${encodeURIComponent(n)}/suggestions/${encodeURIComponent(r)}/select`),{method:`POST`})}function v(e,t){return Object.fromEntries(e.map(e=>[e,t]))}function y(e,t){let n=v(t,`running`);for(let t of e)n[t.sourceId]=t.status;return n}async function b(e){if(!e)return;let t=Date.now()+75e3;for(;Date.now()<t;){try{let t=await p(e);if(S.getState().updateDirectoryRun(t),t.status===`completed`||t.status===`failed`||t.status===`canceled`)return}catch{}await new Promise(e=>window.setTimeout(e,800))}}var x={status:`idle`,drawerOpen:!1,directoryStatus:`idle`,directoryRun:null,sources:{},itemCounts:{},memories:[],threads:[],error:void 0},S=n((e,t)=>({...x,setDrawerOpen:n=>{!n&&t().status===`completed`?e({...x}):e({drawerOpen:n})},finish:()=>e({...x}),updateDirectoryRun:n=>{let r=n.status===`completed`?`completed`:n.status===`failed`||n.status===`canceled`?`failed`:`running`,i=Object.values(t().sources).every(e=>e!==`running`&&e!==`idle`),a=Object.values(t().sources).some(e=>e===`denied`||e===`failed`||e===`partial`);e({directoryStatus:r,directoryRun:n,status:r===`completed`&&i?a?`partial`:`completed`:r===`failed`&&i?`partial`:`running`})},collectSources:async(n,r,i)=>{let a=window.electronAPI?.understandingSources?.collect;if(!(!a||!r.length)){e({status:`running`,sources:v(r,`running`),itemCounts:Object.fromEntries(r.map(e=>[e,0])),memories:[],threads:[],error:void 0});try{let o=await a(r),s=y(o,r),c=Object.fromEntries(o.map(e=>[e.sourceId,e.items.length]));e({sources:s,itemCounts:c});let l=o.flatMap(e=>e.status===`completed`?e.items:[]),u=Object.fromEntries(o.flatMap(e=>e.checkpoint?[[e.sourceId,e.checkpoint]]:[]));l.length&&await b(n);let f=l.length?await d(l,n,i,u):{profileCandidates:[],workThreads:[],knowledgeCandidates:[],sourceStatuses:[]};for(let e of f.sourceStatuses)s[e.sourceId]=e.status;let p=f.profileCandidates,m=Object.values(s).some(e=>e===`denied`||e===`failed`||e===`partial`),h=f.sourceStatuses.flatMap(e=>e.error?[e.error]:[]),g=!n||t().directoryStatus===`completed`;e({sources:s,itemCounts:c,memories:p,threads:f.workThreads,...h.length?{error:h.join(`; `)}:{},status:g?m?`partial`:`completed`:`running`})}catch(t){e(e=>({status:`partial`,sources:Object.fromEntries(Object.entries(e.sources).map(([e,t])=>[e,t===`running`?`failed`:t])),error:t instanceof Error?t.message:String(t)}))}}}}));export{o as a,c,f as d,g as f,s as i,h as l,i as m,m as n,p as o,a as p,l as r,u as s,S as t,_ as u};
@@ -1 +1 @@
1
- import{a as e,i as t,o as n,p as r}from"./locale-store-DIBIYLnI.js";import{t as i}from"./createLucideIcon-DPHK1VkS.js";import{o as a}from"./vendor-swr-CdRzEUwF.js";var o=i(`brain`,[[`path`,{d:`M12 18V5`,key:`adv99a`}],[`path`,{d:`M15 13a4.17 4.17 0 0 1-3-4 4.17 4.17 0 0 1-3 4`,key:`1e3is1`}],[`path`,{d:`M17.598 6.5A3 3 0 1 0 12 5a3 3 0 1 0-5.598 1.5`,key:`1gqd8o`}],[`path`,{d:`M17.997 5.125a4 4 0 0 1 2.526 5.77`,key:`iwvgf7`}],[`path`,{d:`M18 18a4 4 0 0 0 2-7.464`,key:`efp6ie`}],[`path`,{d:`M19.967 17.483A4 4 0 1 1 12 18a4 4 0 1 1-7.967-.517`,key:`1gq6am`}],[`path`,{d:`M6 18a4 4 0 0 1-2-7.464`,key:`k1g0md`}],[`path`,{d:`M6.003 5.125a4 4 0 0 0-2.526 5.77`,key:`q97ue3`}]]),s=i(`compass`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m16.24 7.76-1.804 5.411a2 2 0 0 1-1.265 1.265L7.76 16.24l1.804-5.411a2 2 0 0 1 1.265-1.265z`,key:`9ktpf1`}]]),c=i(`handshake`,[[`path`,{d:`m11 17 2 2a1 1 0 1 0 3-3`,key:`efffak`}],[`path`,{d:`m14 14 2.5 2.5a1 1 0 1 0 3-3l-3.88-3.88a3 3 0 0 0-4.24 0l-.88.88a1 1 0 1 1-3-3l2.81-2.81a5.79 5.79 0 0 1 7.06-.87l.47.28a2 2 0 0 0 1.42.25L21 4`,key:`9pr0kb`}],[`path`,{d:`m21 3 1 11h-2`,key:`1tisrp`}],[`path`,{d:`M3 3 2 14l6.5 6.5a1 1 0 1 0 3-3`,key:`1uvwmv`}],[`path`,{d:`M3 4h8`,key:`1ep09j`}]]),l=i(`user-round-pen`,[[`path`,{d:`M2 21a8 8 0 0 1 10.821-7.487`,key:`1c8h7z`}],[`path`,{d:`M21.378 16.626a1 1 0 0 0-3.004-3.004l-4.01 4.012a2 2 0 0 0-.506.854l-.837 2.87a.5.5 0 0 0 .62.62l2.87-.837a2 2 0 0 0 .854-.506z`,key:`1817ys`}],[`circle`,{cx:`10`,cy:`8`,r:`5`,key:`o932ke`}]]);function u(){return n(t(`/api/user-model`))}var d=`/api/user-model?view=about`;function f(){return n(t(d))}function p(e){return n(t(e))}function m(e){return n(t(`/api/user-model/assertions`),{method:`POST`,body:JSON.stringify({scope:{type:`global`},predicate:`preference.collaboration`,cardinality:`multiple`,kind:`preference`,statement:e,value:e})})}async function h(){let e=await u();return{profile:{callName:typeof e.profile.callName==`string`?e.profile.callName:``,role:typeof e.profile.role==`string`?e.profile.role:``,pronouns:typeof e.profile.pronouns==`string`?e.profile.pronouns:``,timezone:typeof e.profile.timezone==`string`?e.profile.timezone:``,locale:typeof e.profile.locale==`string`?e.profile.locale:``},...typeof e.suggestedCallName==`string`?{suggestedCallName:e.suggestedCallName}:{}}}async function g(e){let r=await n(t(`/api/user-model/profile`),{method:`PATCH`,body:JSON.stringify(e)});return{callName:r.profile.callName??``,role:r.profile.role??``,pronouns:r.profile.pronouns??``,timezone:r.profile.timezone??``,locale:r.profile.locale??``}}function _(){return Intl.DateTimeFormat().resolvedOptions().timeZone||`UTC`}function v(e,r,i){return n(t(`/api/user-model/assertions/${encodeURIComponent(e)}/scope`),{method:`PATCH`,body:JSON.stringify({scope:r,version:i})})}function y(e,r){return n(t(`/api/user-model/assertions/${encodeURIComponent(e)}`),{method:`PATCH`,body:JSON.stringify({statement:r})})}function b(e,r){return n(t(`/api/user-model/priorities/${encodeURIComponent(e)}`),{method:`PATCH`,body:JSON.stringify(r)})}function x(e){let r=Date.now();return n(t(`/api/user-model/priorities`),{method:`POST`,body:JSON.stringify({targetType:`topic`,targetId:e.title.trim(),rank:`primary`,urgency:1,scope:{type:`global`},validFrom:r,validTo:e.validTo})})}function S(e,r){return n(t(`/api/user-model/rules/${encodeURIComponent(e)}/status`),{method:`PATCH`,body:JSON.stringify({status:r})})}function C(e){return n(t(`/api/user-model/rules`),{method:`POST`,body:JSON.stringify({category:e.category,statement:e.statement,priority:50,scope:e.scope,conditions:{...e.conditions,requiresConfirmation:!1}})})}function w(e,r,i){return n(t(`/api/knowledge-memory/${encodeURIComponent(e.id)}/review`),{method:`POST`,body:JSON.stringify({action:r,expectedStatus:e.status,...i===void 0?{}:{content:i}})})}function T(e){return n(t(`/api/user-model/assertions/${encodeURIComponent(e)}`),{method:`DELETE`})}function E(e){return n(t(`/api/knowledge-memory/${encodeURIComponent(e)}`),{method:`DELETE`})}function D(e){return n(t(`/api/user-model/settings`),{method:`PATCH`,body:JSON.stringify(e)})}async function O(){let n=await e(t(`/api/user-model/export`));if(!n.ok)throw Error(`Export failed (${n.status})`);let r=await n.blob(),i=(n.headers.get(`Content-Disposition`)??``).match(/filename="([^"]+)"/)?.[1]??`xopc-memory.json`,a=URL.createObjectURL(r),o=document.createElement(`a`);o.href=a,o.download=i,o.click(),URL.revokeObjectURL(a)}function k(e,r){return n(t(`/api/knowledge-memory/${encodeURIComponent(e.id)}/scope`),{method:`PATCH`,body:JSON.stringify({scope:r,version:e.version})})}var A=e=>e.status===`queued`||e.status===`running`,j=new Set,M,N=r((e,r)=>({sources:[],starting:!1,async start(i){if(!r().starting){e({starting:!0,error:void 0});try{await n(t(`/api/user-model/refresh`),{method:`POST`,body:JSON.stringify(i?{sourceIds:[i]}:{})}),await r().poll()}catch(t){e({error:t instanceof Error?t.message:String(t)})}finally{e({starting:!1})}}},poll(){return M||(M=(async()=>{try{let i=await n(t(`/api/user-model/refresh`)),o=new Map(r().sources.map(e=>[e.id,e.status]));e({sources:i.sources,error:void 0}),i.sources.some(e=>!A(e)&&o.get(e.id)!==e.status)&&a(d);for(let e of i.sources)A(e)&&e.metadata.phase===`waiting_desktop`&&P(e)}catch(t){e({error:t instanceof Error?t.message:String(t)})}})().finally(()=>{M=void 0}),M)}}));async function P(e){let r=window.electronAPI?.understandingSources?.collect;if(!(!r||j.size>0)){j.add(e.id);try{let i;try{let t=(await r([e.adapterId])).find(t=>t.sourceId===e.adapterId);i=t?.status===`completed`?{items:t.items}:{items:[],error:t?.error??`Source collection failed. Check its permissions and retry.`}}catch{i={items:[],error:`Source collection was interrupted. Please retry.`}}await n(t(`/api/user-model/refresh/sources/${encodeURIComponent(e.id)}/collection`),{method:`POST`,body:JSON.stringify(i)}),await N.getState().poll()}catch(e){N.setState({error:e instanceof Error?e.message:String(e)})}finally{j.delete(e.id)}}}export{s as C,c as S,S as _,x as a,g as b,E as c,f as d,h as f,k as g,v as h,y as i,_ as l,w as m,d as n,C as o,p,m as r,T as s,N as t,O as u,D as v,o as w,l as x,b as y};
1
+ import{a as e,i as t,o as n,p as r}from"./locale-store-Cit_aHqC.js";import{t as i}from"./createLucideIcon-DPHK1VkS.js";import{o as a}from"./vendor-swr-CdRzEUwF.js";var o=i(`brain`,[[`path`,{d:`M12 18V5`,key:`adv99a`}],[`path`,{d:`M15 13a4.17 4.17 0 0 1-3-4 4.17 4.17 0 0 1-3 4`,key:`1e3is1`}],[`path`,{d:`M17.598 6.5A3 3 0 1 0 12 5a3 3 0 1 0-5.598 1.5`,key:`1gqd8o`}],[`path`,{d:`M17.997 5.125a4 4 0 0 1 2.526 5.77`,key:`iwvgf7`}],[`path`,{d:`M18 18a4 4 0 0 0 2-7.464`,key:`efp6ie`}],[`path`,{d:`M19.967 17.483A4 4 0 1 1 12 18a4 4 0 1 1-7.967-.517`,key:`1gq6am`}],[`path`,{d:`M6 18a4 4 0 0 1-2-7.464`,key:`k1g0md`}],[`path`,{d:`M6.003 5.125a4 4 0 0 0-2.526 5.77`,key:`q97ue3`}]]),s=i(`compass`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m16.24 7.76-1.804 5.411a2 2 0 0 1-1.265 1.265L7.76 16.24l1.804-5.411a2 2 0 0 1 1.265-1.265z`,key:`9ktpf1`}]]),c=i(`handshake`,[[`path`,{d:`m11 17 2 2a1 1 0 1 0 3-3`,key:`efffak`}],[`path`,{d:`m14 14 2.5 2.5a1 1 0 1 0 3-3l-3.88-3.88a3 3 0 0 0-4.24 0l-.88.88a1 1 0 1 1-3-3l2.81-2.81a5.79 5.79 0 0 1 7.06-.87l.47.28a2 2 0 0 0 1.42.25L21 4`,key:`9pr0kb`}],[`path`,{d:`m21 3 1 11h-2`,key:`1tisrp`}],[`path`,{d:`M3 3 2 14l6.5 6.5a1 1 0 1 0 3-3`,key:`1uvwmv`}],[`path`,{d:`M3 4h8`,key:`1ep09j`}]]),l=i(`user-round-pen`,[[`path`,{d:`M2 21a8 8 0 0 1 10.821-7.487`,key:`1c8h7z`}],[`path`,{d:`M21.378 16.626a1 1 0 0 0-3.004-3.004l-4.01 4.012a2 2 0 0 0-.506.854l-.837 2.87a.5.5 0 0 0 .62.62l2.87-.837a2 2 0 0 0 .854-.506z`,key:`1817ys`}],[`circle`,{cx:`10`,cy:`8`,r:`5`,key:`o932ke`}]]);function u(){return n(t(`/api/user-model`))}var d=`/api/user-model?view=about`;function f(){return n(t(d))}function p(e){return n(t(e))}function m(e){return n(t(`/api/user-model/assertions`),{method:`POST`,body:JSON.stringify({scope:{type:`global`},predicate:`preference.collaboration`,cardinality:`multiple`,kind:`preference`,statement:e,value:e})})}async function h(){let e=await u();return{profile:{callName:typeof e.profile.callName==`string`?e.profile.callName:``,role:typeof e.profile.role==`string`?e.profile.role:``,pronouns:typeof e.profile.pronouns==`string`?e.profile.pronouns:``,timezone:typeof e.profile.timezone==`string`?e.profile.timezone:``,locale:typeof e.profile.locale==`string`?e.profile.locale:``},...typeof e.suggestedCallName==`string`?{suggestedCallName:e.suggestedCallName}:{}}}async function g(e){let r=await n(t(`/api/user-model/profile`),{method:`PATCH`,body:JSON.stringify(e)});return{callName:r.profile.callName??``,role:r.profile.role??``,pronouns:r.profile.pronouns??``,timezone:r.profile.timezone??``,locale:r.profile.locale??``}}function _(){return Intl.DateTimeFormat().resolvedOptions().timeZone||`UTC`}function v(e,r,i){return n(t(`/api/user-model/assertions/${encodeURIComponent(e)}/scope`),{method:`PATCH`,body:JSON.stringify({scope:r,version:i})})}function y(e,r){return n(t(`/api/user-model/assertions/${encodeURIComponent(e)}`),{method:`PATCH`,body:JSON.stringify({statement:r})})}function b(e,r){return n(t(`/api/user-model/priorities/${encodeURIComponent(e)}`),{method:`PATCH`,body:JSON.stringify(r)})}function x(e){let r=Date.now();return n(t(`/api/user-model/priorities`),{method:`POST`,body:JSON.stringify({targetType:`topic`,targetId:e.title.trim(),rank:`primary`,urgency:1,scope:{type:`global`},validFrom:r,validTo:e.validTo})})}function S(e,r){return n(t(`/api/user-model/rules/${encodeURIComponent(e)}/status`),{method:`PATCH`,body:JSON.stringify({status:r})})}function C(e){return n(t(`/api/user-model/rules`),{method:`POST`,body:JSON.stringify({category:e.category,statement:e.statement,priority:50,scope:e.scope,conditions:{...e.conditions,requiresConfirmation:!1}})})}function w(e,r,i){return n(t(`/api/knowledge-memory/${encodeURIComponent(e.id)}/review`),{method:`POST`,body:JSON.stringify({action:r,expectedStatus:e.status,...i===void 0?{}:{content:i}})})}function T(e){return n(t(`/api/user-model/assertions/${encodeURIComponent(e)}`),{method:`DELETE`})}function E(e){return n(t(`/api/knowledge-memory/${encodeURIComponent(e)}`),{method:`DELETE`})}function D(e){return n(t(`/api/user-model/settings`),{method:`PATCH`,body:JSON.stringify(e)})}async function O(){let n=await e(t(`/api/user-model/export`));if(!n.ok)throw Error(`Export failed (${n.status})`);let r=await n.blob(),i=(n.headers.get(`Content-Disposition`)??``).match(/filename="([^"]+)"/)?.[1]??`xopc-memory.json`,a=URL.createObjectURL(r),o=document.createElement(`a`);o.href=a,o.download=i,o.click(),URL.revokeObjectURL(a)}function k(e,r){return n(t(`/api/knowledge-memory/${encodeURIComponent(e.id)}/scope`),{method:`PATCH`,body:JSON.stringify({scope:r,version:e.version})})}var A=e=>e.status===`queued`||e.status===`running`,j=new Set,M,N=r((e,r)=>({sources:[],starting:!1,async start(i){if(!r().starting){e({starting:!0,error:void 0});try{await n(t(`/api/user-model/refresh`),{method:`POST`,body:JSON.stringify(i?{sourceIds:[i]}:{})}),await r().poll()}catch(t){e({error:t instanceof Error?t.message:String(t)})}finally{e({starting:!1})}}},poll(){return M||(M=(async()=>{try{let i=await n(t(`/api/user-model/refresh`)),o=new Map(r().sources.map(e=>[e.id,e.status]));e({sources:i.sources,error:void 0}),i.sources.some(e=>!A(e)&&o.get(e.id)!==e.status)&&a(d);for(let e of i.sources)A(e)&&e.metadata.phase===`waiting_desktop`&&P(e)}catch(t){e({error:t instanceof Error?t.message:String(t)})}})().finally(()=>{M=void 0}),M)}}));async function P(e){let r=window.electronAPI?.understandingSources?.collect;if(!(!r||j.size>0)){j.add(e.id);try{let i;try{let t=(await r([e.adapterId])).find(t=>t.sourceId===e.adapterId);i=t?.status===`completed`?{items:t.items}:{items:[],error:t?.error??`Source collection failed. Check its permissions and retry.`}}catch{i={items:[],error:`Source collection was interrupted. Please retry.`}}await n(t(`/api/user-model/refresh/sources/${encodeURIComponent(e.id)}/collection`),{method:`POST`,body:JSON.stringify(i)}),await N.getState().poll()}catch(e){N.setState({error:e instanceof Error?e.message:String(e)})}finally{j.delete(e.id)}}}export{s as C,c as S,S as _,x as a,g as b,E as c,f as d,h as f,k as g,v as h,y as i,_ as l,w as m,d as n,C as o,p,m as r,T as s,N as t,O as u,D as v,o as w,l as x,b as y};
@@ -1 +1 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{m as i}from"./chunk-KS7C4IRE-CiwuuyV8.js";import{i as a,n as o,o as s}from"./locale-store-DIBIYLnI.js";import{t as c}from"./messages-BDBGlBKh.js";import{t as l}from"./bot-DjLkhyZL.js";import{t as u}from"./popover-select-CLsphyzA.js";import{t as d}from"./circle-alert-BEjgurr2.js";import{t as f}from"./coins-DjP27vUx.js";import{t as p}from"./database-CjjeZfRG.js";import{t as m}from"./gauge-C78eD2BA.js";import{t as h}from"./refresh-cw-BRlGaq2w.js";import{t as g}from"./timer-rCwGHjuO.js";import{t as _}from"./skeleton-DzdOeGYz.js";import{i as v}from"./vendor-swr-CdRzEUwF.js";import{t as y}from"./button-Cc4hUNTt.js";import{t as b}from"./sliding-tab-list-CmcrqRzN.js";import{n as x,t as S}from"./settings-page-header-wL2jvs-y.js";import"./settings-page-layout-BkUQVmyY.js";import{t as ee}from"./xopc-cloud-account-card-Cm0Saa8B.js";var C=e(t(),1),w=n();function T(e,t=Date.now()+1){let n=t-e*24*60*60*1e3;return new URLSearchParams({from:String(n),to:String(t)}).toString()}function E(e){return s(a(`/api/usage/summary?${e}`))}function D(e,t,n=20){let r=new URLSearchParams(e);return r.set(`limit`,String(n)),t&&r.set(`cursor`,t),s(a(`/api/usage/events?${r}`))}var O=r();function k(e,t){return new Intl.NumberFormat(t===`zh`?`zh-CN`:`en-US`,{notation:`compact`,maximumFractionDigits:1}).format(e)}function A(e){return`$${Number(e).toLocaleString(void 0,{minimumFractionDigits:0,maximumFractionDigits:6})}`}function j(e){let t=BigInt(e),n=String(t%10000n).padStart(4,`0`).replace(/0+$/,``);return`${t/10000n}${n?`.${n}`:``}`}function te(e,t){return new Intl.DateTimeFormat(t===`zh`?`zh-CN`:`en-US`,{month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`}).format(e)}function M(){let e=(0,w.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,O.jsxs)(`div`,{className:`space-y-4`,"aria-busy":`true`,children:[(0,O.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2 lg:grid-cols-4`,children:[0,1,2,3].map(N)}),(0,O.jsx)(_,{className:`h-52 rounded-xl`}),(0,O.jsx)(_,{className:`h-72 rounded-xl`})]}),e[0]=t):t=e[0],t}function N(e){return(0,O.jsx)(_,{className:`h-24 rounded-xl`},e)}function P(){let e=o(e=>e.language),t=c(e).usage,[n,r]=i(),a=[`7`,`30`,`90`].includes(n.get(`days`)??``)?n.get(`days`):`7`,s=n.get(`size`)===`50`?50:20,w=n.getAll(`cursor`),N=w.at(-1),[P]=(0,C.useState)(()=>Date.now()+1),F=Number(n.get(`to`)),I=Number.isSafeInteger(F)&&F>Number(a)*864e5?F:P,L=(0,C.useMemo)(()=>T(Number(a),I),[a,I]),R=v([`usage-summary`,L],()=>E(L),{refreshInterval:15e3}),z=v([`usage-events`,L,N,s],()=>D(L,N,s),{refreshInterval:15e3}),B=!R.data&&!R.error,V=R.error,H=e=>{let t=new URLSearchParams(n);t.set(`to`,String(I)),e(t),r(t)},U=e=>H(t=>{t.set(`days`,e),t.set(`to`,String(Date.now()+1)),t.delete(`cursor`),t.delete(`groupPage`)}),W=n.get(`group`)===`model`?`model`:`scenario`,G=[...W===`model`?R.data?.byModel??[]:R.data?.byCategory??[]].sort((e,t)=>t.totals.calls-e.totals.calls||e.key.localeCompare(t.key)),K=Math.max(1,Math.ceil((G?.length??0)/6)),q=Number(n.get(`groupPage`)),J=Math.min(K,Number.isSafeInteger(q)&&q>0?q:1),Y=G?.slice((J-1)*6,J*6),X=w.length+1,Z=R.data?.totals,ne=(Z?.billing?.cloud.calls??0)>0,Q=e=>{let n=e.billing?.cloud;return n?.calls?n.chargedCreditMicro===null?t.cloudUnconfirmed:`${n.pendingCalls+n.unavailableCalls>0?`≥ `:``}${j(n.chargedCreditMicro)} Credits`:t.noCloudCalls},$=e=>{let n=e.billing?.external;return n?.calls?n.unknownCostCalls===n.calls?t.costUnknown:`${n.unknownCostCalls>0?`≥ `:`≈ `}${A(n.estimatedCostUsd)}`:t.noExternalCalls},re=e=>e.billing?.source===`local`||e.provider!==`xopc-cloud`&&e.costSource===`local`?t.localSource:e.billing?.source===`xopc_cloud`||e.provider===`xopc-cloud`?t.cloudSource:t.externalSource,ie=e=>{let n=e.billing;return n?.source===`local`?t.localNoCharge:n?.source===`xopc_cloud`?n.state===`settled`&&n.chargedCreditMicro!==null?`${j(n.chargedCreditMicro)} Credits`:n.state===`released`?t.cloudReleased:n.state===`pending`?n.reservedCreditMicro===null?t.cloudPending:t.cloudPendingReserved.replace(`{{credits}}`,j(n.reservedCreditMicro)):t.cloudUnconfirmed:e.provider===`xopc-cloud`?t.cloudUnconfirmed:e.costSource===`local`?t.localNoCharge:e.estimatedCostUsd===void 0?t.costUnknown:`≈ ${A(e.estimatedCostUsd)}`},ae=e=>(0,O.jsxs)(`span`,{className:`flex flex-col items-end gap-1 text-xs`,children:[e.billing?.cloud.calls?(0,O.jsxs)(`span`,{children:[t.cloudSource,`: `,Q(e)]}):null,e.billing?.external.calls?(0,O.jsxs)(`span`,{children:[t.externalSource,`: `,$(e)]}):null,e.billing?.localCalls?(0,O.jsx)(`span`,{children:t.localNoCharge}):null,(0,O.jsxs)(`span`,{children:[e.calls,` `,t.callUnit]})]}),oe={"usage.reason.imageGeneration":t.reasons.imageGeneration,"usage.reason.audioTranscription":t.reasons.audioTranscription,"usage.reason.audioSpeech":t.reasons.audioSpeech,"usage.reason.agentAnswer":t.reasons.agentAnswer,"usage.reason.continueAfterTool":t.reasons.continueAfterTool,"usage.reason.backgroundReview":t.reasons.backgroundReview,"usage.reason.sessionCompaction":t.reasons.sessionCompaction,"usage.reason.sessionTitle":t.reasons.sessionTitle,"usage.reason.imageUnderstanding":t.reasons.imageUnderstanding,"usage.reason.webExtract":t.reasons.webExtract,"usage.reason.sessionSearch":t.reasons.sessionSearch,"usage.reason.noteGeneration":t.reasons.noteGeneration,"usage.reason.automationDraft":t.reasons.automationDraft,"usage.reason.taskPlanning":t.reasons.taskPlanning,"usage.reason.taskJudging":t.reasons.taskJudging,"usage.reason.voiceSummary":t.reasons.voiceSummary,"usage.reason.voiceSelection":t.reasons.voiceSelection,"usage.reason.homeAdvice":t.reasons.homeAdvice,"usage.reason.workDiscovery":t.reasons.workDiscovery,"usage.reason.workInvestigation":t.reasons.workInvestigation,"usage.reason.discussionAnalysis":t.reasons.discussionAnalysis,"usage.reason.textAssist":t.reasons.textAssist,"usage.reason.userModelInterpretation":t.reasons.userModelInterpretation,"usage.reason.other":t.reasons.other};return(0,O.jsxs)(x,{children:[(0,O.jsx)(S,{title:t.title,subtitle:t.subtitle,actions:(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,O.jsx)(`div`,{className:`w-36`,children:(0,O.jsx)(u,{value:a,allowEmpty:!1,ariaLabel:t.periodLabel,placeholder:t.periodLabel,options:[{value:`7`,label:t.last7Days},{value:`30`,label:t.last30Days},{value:`90`,label:t.last90Days}],onChange:U})}),(0,O.jsx)(y,{variant:`ghost`,"aria-label":t.refresh,title:t.refresh,onClick:()=>U(a),children:(0,O.jsx)(h,{className:`size-4`,"aria-hidden":!0})})]})}),B?(0,O.jsx)(M,{}):V?(0,O.jsxs)(`div`,{role:`alert`,className:`flex items-start gap-3 rounded-xl border border-edge bg-surface-inset p-4 text-sm text-fg-muted`,children:[(0,O.jsx)(d,{className:`mt-0.5 size-4 shrink-0 text-danger`,"aria-hidden":!0}),(0,O.jsxs)(`div`,{className:`space-y-2`,children:[(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`p`,{className:`font-medium text-fg`,children:t.loadError}),(0,O.jsx)(`p`,{className:`mt-1`,children:String(V.message??V)})]}),(0,O.jsx)(y,{variant:`secondary`,onClick:()=>void Promise.all([R.mutate(),z.mutate()]),children:t.retry})]})]}):Z?(0,O.jsxs)(`div`,{className:`space-y-5`,children:[(0,O.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:t.summaryLabel}),(0,O.jsx)(`section`,{"aria-label":t.summaryLabel,className:`grid gap-3 sm:grid-cols-2 lg:grid-cols-4`,children:[{label:t.cloudCharged,value:Q(Z),icon:f},{label:t.knownCost,value:$(Z),icon:f},{label:t.calls,value:Z.calls.toLocaleString(),icon:m},{label:t.tokens,value:k(Z.totalTokens,e),icon:p}].map(e=>(0,O.jsxs)(`div`,{className:`rounded-xl border border-edge bg-surface-panel p-4`,children:[(0,O.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-fg-muted`,children:[(0,O.jsx)(e.icon,{className:`size-4`,"aria-hidden":!0}),e.label]}),(0,O.jsx)(`div`,{className:`mt-2 text-xl font-semibold tabular-nums text-fg`,children:e.value})]},e.label))}),(Z.billing?.external.unknownCostCalls??0)>0?(0,O.jsx)(`p`,{className:`rounded-lg border border-edge bg-surface-inset px-3 py-2 text-xs leading-5 text-fg-muted`,children:Z.billing?.external.unknownCostCalls===Z.billing?.external.calls?t.allCostsUnknown:t.someCostsUnknown}):null,Z.billing?.cloud.calls?(0,O.jsxs)(`p`,{className:`rounded-lg border border-edge bg-surface-inset px-3 py-2 text-xs leading-5 text-fg-muted`,children:[t.cloudCoverage.replace(`{{pending}}`,String(Z.billing.cloud.pendingCalls)).replace(`{{unknown}}`,String(Z.billing.cloud.unavailableCalls)),Z.billing.cloud.reservedCreditMicro===null?``:` ${t.cloudReserved.replace(`{{credits}}`,j(Z.billing.cloud.reservedCreditMicro))}`]}):null,(0,O.jsxs)(`section`,{className:`overflow-hidden rounded-xl border border-edge bg-surface-panel`,children:[(0,O.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3 border-b border-edge px-4 py-3`,children:[(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:t.distribution}),(0,O.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:t.distributionHint})]}),(0,O.jsx)(b,{className:`flex gap-1`,role:`group`,"aria-label":t.distribution,children:[`scenario`,`model`].map(e=>(0,O.jsx)(y,{variant:W===e?`secondary`:`ghost`,"aria-pressed":W===e,onClick:()=>H(t=>{t.set(`group`,e),t.delete(`groupPage`)}),children:e===`scenario`?t.byScenario:t.byModel},e))})]}),(0,O.jsx)(`div`,{className:`divide-y divide-edge-subtle px-4`,children:Y?.length?Y.map(e=>{let n=W===`scenario`?t.categories[e.key]??e.key:e.key;return(0,O.jsxs)(`div`,{className:`flex flex-col gap-3 py-3 text-sm sm:flex-row sm:items-center sm:justify-between`,children:[(0,O.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,O.jsx)(`p`,{className:`truncate font-medium text-fg`,title:n,children:n}),(0,O.jsx)(`div`,{className:`mt-2 h-1 max-w-64 overflow-hidden rounded-full bg-surface-inset`,"aria-hidden":!0,children:(0,O.jsx)(`div`,{className:`h-full rounded-full bg-accent`,style:{width:`${Z.calls?e.totals.calls/Z.calls*100:0}%`}})})]}),(0,O.jsx)(`div`,{className:`shrink-0 self-end tabular-nums text-fg-muted sm:self-auto`,children:ae(e.totals)})]},e.key)}):(0,O.jsx)(`p`,{className:`py-5 text-sm text-fg-subtle`,children:t.empty})}),K>1?(0,O.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3 border-t border-edge px-4 py-3`,children:[(0,O.jsx)(`p`,{className:`text-xs text-fg-muted`,"aria-live":`polite`,children:t.groupPage.replace(`{{page}}`,String(J)).replace(`{{pages}}`,String(K)).replace(`{{count}}`,String(G?.length??0))}),(0,O.jsxs)(`div`,{className:`flex gap-2`,children:[(0,O.jsx)(y,{disabled:J===1,"aria-label":t.previousDistribution,onClick:()=>H(e=>e.set(`groupPage`,String(J-1))),children:t.previousPage}),(0,O.jsx)(y,{disabled:J===K,"aria-label":t.nextDistribution,onClick:()=>H(e=>e.set(`groupPage`,String(J+1))),children:t.nextPage})]})]}):null]}),(0,O.jsxs)(`section`,{className:`overflow-hidden rounded-xl border border-edge bg-surface-panel`,children:[(0,O.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3 border-b border-edge px-4 py-3`,children:[(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:t.recentCalls}),(0,O.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:t.recentCallsHint})]}),(0,O.jsx)(`div`,{className:`w-36`,children:(0,O.jsx)(u,{value:String(s),allowEmpty:!1,ariaLabel:t.pageSize,placeholder:t.pageSize,options:[20,50].map(e=>({value:String(e),label:t.rowsPerPage.replace(`{{count}}`,String(e))})),onChange:e=>H(t=>{t.set(`size`,e),t.delete(`cursor`)})})})]}),(0,O.jsx)(`div`,{className:`divide-y divide-edge-subtle`,children:z.error?(0,O.jsxs)(`div`,{role:`alert`,className:`space-y-3 p-4 text-sm text-fg-muted`,children:[(0,O.jsx)(`p`,{children:t.loadError}),(0,O.jsx)(y,{onClick:()=>void z.mutate(),children:t.retry})]}):z.data?z.data.items.length?z.data.items.map(n=>(0,O.jsxs)(`article`,{className:`grid gap-2 px-4 py-3 text-sm sm:grid-cols-[minmax(0,1fr)_auto] sm:items-center`,children:[(0,O.jsxs)(`div`,{className:`min-w-0`,children:[(0,O.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,O.jsx)(l,{className:`size-4 shrink-0 text-fg-subtle`,"aria-hidden":!0}),(0,O.jsx)(`span`,{className:`truncate font-medium text-fg`,children:oe[n.reasonKey]??t.reasons.other})]}),(0,O.jsxs)(`div`,{className:`mt-1 flex flex-wrap items-center gap-x-3 gap-y-1 text-xs text-fg-subtle`,children:[(0,O.jsxs)(`span`,{className:`min-w-0 [overflow-wrap:anywhere]`,children:[n.provider,`/`,n.model]}),(0,O.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,O.jsx)(g,{className:`size-3`,"aria-hidden":!0}),te(n.startedAt,e)]}),(0,O.jsx)(`span`,{className:`rounded border border-edge px-1.5 py-0.5`,children:re(n)}),(0,O.jsx)(`span`,{children:n.totalTokens===void 0?t.tokensUnknown:`${k(n.totalTokens,e)} tokens`})]})]}),(0,O.jsxs)(`div`,{className:`text-left tabular-nums text-fg sm:text-right`,children:[ie(n),(0,O.jsx)(`div`,{className:`mt-0.5 text-xs text-fg-subtle`,children:t.status[n.status]??n.status})]})]},n.id)):(0,O.jsx)(`p`,{className:`px-4 py-8 text-center text-sm text-fg-subtle`,children:t.empty}):(0,O.jsx)(`div`,{"aria-busy":`true`,className:`space-y-3 p-4`,children:[0,1,2,3].map(e=>(0,O.jsx)(_,{className:`h-16`},e))})}),(0,O.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3 border-t border-edge px-4 py-3`,children:[(0,O.jsx)(`p`,{className:`text-xs text-fg-muted`,"aria-live":`polite`,children:t.eventPage.replace(`{{page}}`,String(X)).replace(`{{count}}`,String(z.data?.items.length??0))}),(0,O.jsxs)(`nav`,{className:`flex gap-2`,"aria-label":t.pagination,children:[X>1?(0,O.jsx)(y,{variant:`ghost`,onClick:()=>H(e=>e.delete(`cursor`)),children:t.firstPage}):null,(0,O.jsx)(y,{disabled:X===1,onClick:()=>H(e=>{e.delete(`cursor`),w.slice(0,-1).forEach(t=>e.append(`cursor`,t))}),children:t.previousPage}),(0,O.jsx)(y,{disabled:!z.data?.nextCursor||!!z.error,onClick:()=>H(e=>{z.data?.nextCursor&&e.append(`cursor`,z.data.nextCursor)}),children:t.nextPage})]})]})]}),(0,O.jsxs)(`details`,{className:`rounded-xl border border-edge bg-surface-panel p-4`,children:[(0,O.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg focus-visible:outline-accent`,children:t.billingDetails}),(0,O.jsx)(`p`,{className:`mt-3 text-xs leading-5 text-fg-muted`,children:t.cloudBillingHint}),(0,O.jsx)(`a`,{className:`mt-2 inline-block text-xs text-accent-fg hover:underline`,href:`https://console.xopc.ai/models/billing`,target:`_blank`,rel:`noreferrer`,children:t.cloudCreditsLabel}),ne?(0,O.jsx)(`div`,{className:`mt-4`,children:(0,O.jsx)(ee,{labels:c(e).capabilitiesSettings.xopcCloudAccount})}):null]})]}):null]})}export{P as UsageSettingsPage};
1
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{m as i}from"./chunk-KS7C4IRE-CiwuuyV8.js";import{i as a,n as o,o as s}from"./locale-store-Cit_aHqC.js";import{t as c}from"./messages-DQveK9sk.js";import{t as l}from"./bot-DjLkhyZL.js";import{t as u}from"./popover-select-CLsphyzA.js";import{t as d}from"./circle-alert-BEjgurr2.js";import{t as f}from"./coins-DjP27vUx.js";import{t as p}from"./database-CjjeZfRG.js";import{t as m}from"./gauge-C78eD2BA.js";import{t as h}from"./refresh-cw-BRlGaq2w.js";import{t as g}from"./timer-rCwGHjuO.js";import{t as _}from"./skeleton-DzdOeGYz.js";import{i as v}from"./vendor-swr-CdRzEUwF.js";import{t as y}from"./button-Cc4hUNTt.js";import{t as b}from"./sliding-tab-list-CmcrqRzN.js";import{n as x,t as S}from"./settings-page-header-B9Y_eGcH.js";import"./settings-page-layout-D1MgJ5zP.js";import{t as ee}from"./xopc-cloud-account-card-DGAGXbGI.js";var C=e(t(),1),w=n();function T(e,t=Date.now()+1){let n=t-e*24*60*60*1e3;return new URLSearchParams({from:String(n),to:String(t)}).toString()}function E(e){return s(a(`/api/usage/summary?${e}`))}function D(e,t,n=20){let r=new URLSearchParams(e);return r.set(`limit`,String(n)),t&&r.set(`cursor`,t),s(a(`/api/usage/events?${r}`))}var O=r();function k(e,t){return new Intl.NumberFormat(t===`zh`?`zh-CN`:`en-US`,{notation:`compact`,maximumFractionDigits:1}).format(e)}function A(e){return`$${Number(e).toLocaleString(void 0,{minimumFractionDigits:0,maximumFractionDigits:6})}`}function j(e){let t=BigInt(e),n=String(t%10000n).padStart(4,`0`).replace(/0+$/,``);return`${t/10000n}${n?`.${n}`:``}`}function te(e,t){return new Intl.DateTimeFormat(t===`zh`?`zh-CN`:`en-US`,{month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`}).format(e)}function M(){let e=(0,w.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,O.jsxs)(`div`,{className:`space-y-4`,"aria-busy":`true`,children:[(0,O.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2 lg:grid-cols-4`,children:[0,1,2,3].map(N)}),(0,O.jsx)(_,{className:`h-52 rounded-xl`}),(0,O.jsx)(_,{className:`h-72 rounded-xl`})]}),e[0]=t):t=e[0],t}function N(e){return(0,O.jsx)(_,{className:`h-24 rounded-xl`},e)}function P(){let e=o(e=>e.language),t=c(e).usage,[n,r]=i(),a=[`7`,`30`,`90`].includes(n.get(`days`)??``)?n.get(`days`):`7`,s=n.get(`size`)===`50`?50:20,w=n.getAll(`cursor`),N=w.at(-1),[P]=(0,C.useState)(()=>Date.now()+1),F=Number(n.get(`to`)),I=Number.isSafeInteger(F)&&F>Number(a)*864e5?F:P,L=(0,C.useMemo)(()=>T(Number(a),I),[a,I]),R=v([`usage-summary`,L],()=>E(L),{refreshInterval:15e3}),z=v([`usage-events`,L,N,s],()=>D(L,N,s),{refreshInterval:15e3}),B=!R.data&&!R.error,V=R.error,H=e=>{let t=new URLSearchParams(n);t.set(`to`,String(I)),e(t),r(t)},U=e=>H(t=>{t.set(`days`,e),t.set(`to`,String(Date.now()+1)),t.delete(`cursor`),t.delete(`groupPage`)}),W=n.get(`group`)===`model`?`model`:`scenario`,G=[...W===`model`?R.data?.byModel??[]:R.data?.byCategory??[]].sort((e,t)=>t.totals.calls-e.totals.calls||e.key.localeCompare(t.key)),K=Math.max(1,Math.ceil((G?.length??0)/6)),q=Number(n.get(`groupPage`)),J=Math.min(K,Number.isSafeInteger(q)&&q>0?q:1),Y=G?.slice((J-1)*6,J*6),X=w.length+1,Z=R.data?.totals,ne=(Z?.billing?.cloud.calls??0)>0,Q=e=>{let n=e.billing?.cloud;return n?.calls?n.chargedCreditMicro===null?t.cloudUnconfirmed:`${n.pendingCalls+n.unavailableCalls>0?`≥ `:``}${j(n.chargedCreditMicro)} Credits`:t.noCloudCalls},$=e=>{let n=e.billing?.external;return n?.calls?n.unknownCostCalls===n.calls?t.costUnknown:`${n.unknownCostCalls>0?`≥ `:`≈ `}${A(n.estimatedCostUsd)}`:t.noExternalCalls},re=e=>e.billing?.source===`local`||e.provider!==`xopc-cloud`&&e.costSource===`local`?t.localSource:e.billing?.source===`xopc_cloud`||e.provider===`xopc-cloud`?t.cloudSource:t.externalSource,ie=e=>{let n=e.billing;return n?.source===`local`?t.localNoCharge:n?.source===`xopc_cloud`?n.state===`settled`&&n.chargedCreditMicro!==null?`${j(n.chargedCreditMicro)} Credits`:n.state===`released`?t.cloudReleased:n.state===`pending`?n.reservedCreditMicro===null?t.cloudPending:t.cloudPendingReserved.replace(`{{credits}}`,j(n.reservedCreditMicro)):t.cloudUnconfirmed:e.provider===`xopc-cloud`?t.cloudUnconfirmed:e.costSource===`local`?t.localNoCharge:e.estimatedCostUsd===void 0?t.costUnknown:`≈ ${A(e.estimatedCostUsd)}`},ae=e=>(0,O.jsxs)(`span`,{className:`flex flex-col items-end gap-1 text-xs`,children:[e.billing?.cloud.calls?(0,O.jsxs)(`span`,{children:[t.cloudSource,`: `,Q(e)]}):null,e.billing?.external.calls?(0,O.jsxs)(`span`,{children:[t.externalSource,`: `,$(e)]}):null,e.billing?.localCalls?(0,O.jsx)(`span`,{children:t.localNoCharge}):null,(0,O.jsxs)(`span`,{children:[e.calls,` `,t.callUnit]})]}),oe={"usage.reason.imageGeneration":t.reasons.imageGeneration,"usage.reason.audioTranscription":t.reasons.audioTranscription,"usage.reason.audioSpeech":t.reasons.audioSpeech,"usage.reason.agentAnswer":t.reasons.agentAnswer,"usage.reason.continueAfterTool":t.reasons.continueAfterTool,"usage.reason.backgroundReview":t.reasons.backgroundReview,"usage.reason.sessionCompaction":t.reasons.sessionCompaction,"usage.reason.sessionTitle":t.reasons.sessionTitle,"usage.reason.imageUnderstanding":t.reasons.imageUnderstanding,"usage.reason.webExtract":t.reasons.webExtract,"usage.reason.sessionSearch":t.reasons.sessionSearch,"usage.reason.noteGeneration":t.reasons.noteGeneration,"usage.reason.automationDraft":t.reasons.automationDraft,"usage.reason.taskPlanning":t.reasons.taskPlanning,"usage.reason.taskJudging":t.reasons.taskJudging,"usage.reason.voiceSummary":t.reasons.voiceSummary,"usage.reason.voiceSelection":t.reasons.voiceSelection,"usage.reason.homeAdvice":t.reasons.homeAdvice,"usage.reason.workDiscovery":t.reasons.workDiscovery,"usage.reason.workInvestigation":t.reasons.workInvestigation,"usage.reason.discussionAnalysis":t.reasons.discussionAnalysis,"usage.reason.textAssist":t.reasons.textAssist,"usage.reason.userModelInterpretation":t.reasons.userModelInterpretation,"usage.reason.other":t.reasons.other};return(0,O.jsxs)(x,{children:[(0,O.jsx)(S,{title:t.title,subtitle:t.subtitle,actions:(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,O.jsx)(`div`,{className:`w-36`,children:(0,O.jsx)(u,{value:a,allowEmpty:!1,ariaLabel:t.periodLabel,placeholder:t.periodLabel,options:[{value:`7`,label:t.last7Days},{value:`30`,label:t.last30Days},{value:`90`,label:t.last90Days}],onChange:U})}),(0,O.jsx)(y,{variant:`ghost`,"aria-label":t.refresh,title:t.refresh,onClick:()=>U(a),children:(0,O.jsx)(h,{className:`size-4`,"aria-hidden":!0})})]})}),B?(0,O.jsx)(M,{}):V?(0,O.jsxs)(`div`,{role:`alert`,className:`flex items-start gap-3 rounded-xl border border-edge bg-surface-inset p-4 text-sm text-fg-muted`,children:[(0,O.jsx)(d,{className:`mt-0.5 size-4 shrink-0 text-danger`,"aria-hidden":!0}),(0,O.jsxs)(`div`,{className:`space-y-2`,children:[(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`p`,{className:`font-medium text-fg`,children:t.loadError}),(0,O.jsx)(`p`,{className:`mt-1`,children:String(V.message??V)})]}),(0,O.jsx)(y,{variant:`secondary`,onClick:()=>void Promise.all([R.mutate(),z.mutate()]),children:t.retry})]})]}):Z?(0,O.jsxs)(`div`,{className:`space-y-5`,children:[(0,O.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:t.summaryLabel}),(0,O.jsx)(`section`,{"aria-label":t.summaryLabel,className:`grid gap-3 sm:grid-cols-2 lg:grid-cols-4`,children:[{label:t.cloudCharged,value:Q(Z),icon:f},{label:t.knownCost,value:$(Z),icon:f},{label:t.calls,value:Z.calls.toLocaleString(),icon:m},{label:t.tokens,value:k(Z.totalTokens,e),icon:p}].map(e=>(0,O.jsxs)(`div`,{className:`rounded-xl border border-edge bg-surface-panel p-4`,children:[(0,O.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-fg-muted`,children:[(0,O.jsx)(e.icon,{className:`size-4`,"aria-hidden":!0}),e.label]}),(0,O.jsx)(`div`,{className:`mt-2 text-xl font-semibold tabular-nums text-fg`,children:e.value})]},e.label))}),(Z.billing?.external.unknownCostCalls??0)>0?(0,O.jsx)(`p`,{className:`rounded-lg border border-edge bg-surface-inset px-3 py-2 text-xs leading-5 text-fg-muted`,children:Z.billing?.external.unknownCostCalls===Z.billing?.external.calls?t.allCostsUnknown:t.someCostsUnknown}):null,Z.billing?.cloud.calls?(0,O.jsxs)(`p`,{className:`rounded-lg border border-edge bg-surface-inset px-3 py-2 text-xs leading-5 text-fg-muted`,children:[t.cloudCoverage.replace(`{{pending}}`,String(Z.billing.cloud.pendingCalls)).replace(`{{unknown}}`,String(Z.billing.cloud.unavailableCalls)),Z.billing.cloud.reservedCreditMicro===null?``:` ${t.cloudReserved.replace(`{{credits}}`,j(Z.billing.cloud.reservedCreditMicro))}`]}):null,(0,O.jsxs)(`section`,{className:`overflow-hidden rounded-xl border border-edge bg-surface-panel`,children:[(0,O.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3 border-b border-edge px-4 py-3`,children:[(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:t.distribution}),(0,O.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:t.distributionHint})]}),(0,O.jsx)(b,{className:`flex gap-1`,role:`group`,"aria-label":t.distribution,children:[`scenario`,`model`].map(e=>(0,O.jsx)(y,{variant:W===e?`secondary`:`ghost`,"aria-pressed":W===e,onClick:()=>H(t=>{t.set(`group`,e),t.delete(`groupPage`)}),children:e===`scenario`?t.byScenario:t.byModel},e))})]}),(0,O.jsx)(`div`,{className:`divide-y divide-edge-subtle px-4`,children:Y?.length?Y.map(e=>{let n=W===`scenario`?t.categories[e.key]??e.key:e.key;return(0,O.jsxs)(`div`,{className:`flex flex-col gap-3 py-3 text-sm sm:flex-row sm:items-center sm:justify-between`,children:[(0,O.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,O.jsx)(`p`,{className:`truncate font-medium text-fg`,title:n,children:n}),(0,O.jsx)(`div`,{className:`mt-2 h-1 max-w-64 overflow-hidden rounded-full bg-surface-inset`,"aria-hidden":!0,children:(0,O.jsx)(`div`,{className:`h-full rounded-full bg-accent`,style:{width:`${Z.calls?e.totals.calls/Z.calls*100:0}%`}})})]}),(0,O.jsx)(`div`,{className:`shrink-0 self-end tabular-nums text-fg-muted sm:self-auto`,children:ae(e.totals)})]},e.key)}):(0,O.jsx)(`p`,{className:`py-5 text-sm text-fg-subtle`,children:t.empty})}),K>1?(0,O.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3 border-t border-edge px-4 py-3`,children:[(0,O.jsx)(`p`,{className:`text-xs text-fg-muted`,"aria-live":`polite`,children:t.groupPage.replace(`{{page}}`,String(J)).replace(`{{pages}}`,String(K)).replace(`{{count}}`,String(G?.length??0))}),(0,O.jsxs)(`div`,{className:`flex gap-2`,children:[(0,O.jsx)(y,{disabled:J===1,"aria-label":t.previousDistribution,onClick:()=>H(e=>e.set(`groupPage`,String(J-1))),children:t.previousPage}),(0,O.jsx)(y,{disabled:J===K,"aria-label":t.nextDistribution,onClick:()=>H(e=>e.set(`groupPage`,String(J+1))),children:t.nextPage})]})]}):null]}),(0,O.jsxs)(`section`,{className:`overflow-hidden rounded-xl border border-edge bg-surface-panel`,children:[(0,O.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3 border-b border-edge px-4 py-3`,children:[(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:t.recentCalls}),(0,O.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:t.recentCallsHint})]}),(0,O.jsx)(`div`,{className:`w-36`,children:(0,O.jsx)(u,{value:String(s),allowEmpty:!1,ariaLabel:t.pageSize,placeholder:t.pageSize,options:[20,50].map(e=>({value:String(e),label:t.rowsPerPage.replace(`{{count}}`,String(e))})),onChange:e=>H(t=>{t.set(`size`,e),t.delete(`cursor`)})})})]}),(0,O.jsx)(`div`,{className:`divide-y divide-edge-subtle`,children:z.error?(0,O.jsxs)(`div`,{role:`alert`,className:`space-y-3 p-4 text-sm text-fg-muted`,children:[(0,O.jsx)(`p`,{children:t.loadError}),(0,O.jsx)(y,{onClick:()=>void z.mutate(),children:t.retry})]}):z.data?z.data.items.length?z.data.items.map(n=>(0,O.jsxs)(`article`,{className:`grid gap-2 px-4 py-3 text-sm sm:grid-cols-[minmax(0,1fr)_auto] sm:items-center`,children:[(0,O.jsxs)(`div`,{className:`min-w-0`,children:[(0,O.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,O.jsx)(l,{className:`size-4 shrink-0 text-fg-subtle`,"aria-hidden":!0}),(0,O.jsx)(`span`,{className:`truncate font-medium text-fg`,children:oe[n.reasonKey]??t.reasons.other})]}),(0,O.jsxs)(`div`,{className:`mt-1 flex flex-wrap items-center gap-x-3 gap-y-1 text-xs text-fg-subtle`,children:[(0,O.jsxs)(`span`,{className:`min-w-0 [overflow-wrap:anywhere]`,children:[n.provider,`/`,n.model]}),(0,O.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,O.jsx)(g,{className:`size-3`,"aria-hidden":!0}),te(n.startedAt,e)]}),(0,O.jsx)(`span`,{className:`rounded border border-edge px-1.5 py-0.5`,children:re(n)}),(0,O.jsx)(`span`,{children:n.totalTokens===void 0?t.tokensUnknown:`${k(n.totalTokens,e)} tokens`})]})]}),(0,O.jsxs)(`div`,{className:`text-left tabular-nums text-fg sm:text-right`,children:[ie(n),(0,O.jsx)(`div`,{className:`mt-0.5 text-xs text-fg-subtle`,children:t.status[n.status]??n.status})]})]},n.id)):(0,O.jsx)(`p`,{className:`px-4 py-8 text-center text-sm text-fg-subtle`,children:t.empty}):(0,O.jsx)(`div`,{"aria-busy":`true`,className:`space-y-3 p-4`,children:[0,1,2,3].map(e=>(0,O.jsx)(_,{className:`h-16`},e))})}),(0,O.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3 border-t border-edge px-4 py-3`,children:[(0,O.jsx)(`p`,{className:`text-xs text-fg-muted`,"aria-live":`polite`,children:t.eventPage.replace(`{{page}}`,String(X)).replace(`{{count}}`,String(z.data?.items.length??0))}),(0,O.jsxs)(`nav`,{className:`flex gap-2`,"aria-label":t.pagination,children:[X>1?(0,O.jsx)(y,{variant:`ghost`,onClick:()=>H(e=>e.delete(`cursor`)),children:t.firstPage}):null,(0,O.jsx)(y,{disabled:X===1,onClick:()=>H(e=>{e.delete(`cursor`),w.slice(0,-1).forEach(t=>e.append(`cursor`,t))}),children:t.previousPage}),(0,O.jsx)(y,{disabled:!z.data?.nextCursor||!!z.error,onClick:()=>H(e=>{z.data?.nextCursor&&e.append(`cursor`,z.data.nextCursor)}),children:t.nextPage})]})]})]}),(0,O.jsxs)(`details`,{className:`rounded-xl border border-edge bg-surface-panel p-4`,children:[(0,O.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg focus-visible:outline-accent`,children:t.billingDetails}),(0,O.jsx)(`p`,{className:`mt-3 text-xs leading-5 text-fg-muted`,children:t.cloudBillingHint}),(0,O.jsx)(`a`,{className:`mt-2 inline-block text-xs text-accent-fg hover:underline`,href:`https://console.xopc.ai/models/billing`,target:`_blank`,rel:`noreferrer`,children:t.cloudCreditsLabel}),ne?(0,O.jsx)(`div`,{className:`mt-4`,children:(0,O.jsx)(ee,{labels:c(e).capabilitiesSettings.xopcCloudAccount})}):null]})]}):null]})}export{P as UsageSettingsPage};
@@ -1 +1 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{n as i}from"./locale-store-DIBIYLnI.js";import{t as a}from"./check-DUBLcKHA.js";import{t as o}from"./circle-alert-BEjgurr2.js";import{t as s}from"./loader-circle-CifKLtgG.js";import{t as c}from"./cn-0WouolD0.js";var l=n(),u=r();function d(e){let t=(0,l.c)(21),{status:n,error:r,className:d}=e,p=i(f)===`zh`;if(n===`idle`)return null;let m=n===`saving`?p?`正在保存…`:`Saving…`:n===`saved`?p?`已自动保存`:`Saved automatically`:n===`error`?r||(p?`自动保存失败`:`Autosave failed`):n===`dirty`?p?`编辑中,将自动保存`:`Editing — autosave pending`:``,h=n===`error`?`text-danger`:n===`saved`?`text-success`:`text-fg-subtle`,g;t[0]!==d||t[1]!==h?(g=c(`inline-flex min-w-0 items-center gap-1.5 text-xs`,h,d),t[0]=d,t[1]=h,t[2]=g):g=t[2];let _;t[3]===n?_=t[4]:(_=n===`saving`?(0,u.jsx)(s,{className:`size-3.5 shrink-0 animate-spin`,"aria-hidden":!0}):null,t[3]=n,t[4]=_);let v;t[5]===n?v=t[6]:(v=n===`saved`?(0,u.jsx)(a,{className:`size-3.5 shrink-0`,"aria-hidden":!0}):null,t[5]=n,t[6]=v);let y;t[7]===n?y=t[8]:(y=n===`error`?(0,u.jsx)(o,{className:`size-3.5 shrink-0`,"aria-hidden":!0}):null,t[7]=n,t[8]=y);let b;t[9]===n?b=t[10]:(b=n===`dirty`?(0,u.jsx)(`span`,{className:`size-1.5 shrink-0 rounded-full bg-current`,"aria-hidden":!0}):null,t[9]=n,t[10]=b);let x;t[11]===m?x=t[12]:(x=(0,u.jsx)(`span`,{className:`truncate`,children:m}),t[11]=m,t[12]=x);let S;return t[13]!==m||t[14]!==g||t[15]!==_||t[16]!==v||t[17]!==y||t[18]!==b||t[19]!==x?(S=(0,u.jsxs)(`span`,{className:g,role:`status`,"aria-live":`polite`,title:m,children:[_,v,y,b,x]}),t[13]=m,t[14]=g,t[15]=_,t[16]=v,t[17]=y,t[18]=b,t[19]=x,t[20]=S):S=t[20],S}function f(e){return e.language}var p=e(t(),1);function m({value:e,dirty:t,onSave:n,enabled:r=!0,delayMs:i=700,validate:a,serialize:o=JSON.stringify}){let[s,c]=(0,p.useState)(`idle`),[l,u]=(0,p.useState)(null),d=(0,p.useRef)(e),f=(0,p.useRef)(n),m=(0,p.useRef)(a),h=(0,p.useRef)(o),g=(0,p.useRef)(null),_=(0,p.useRef)(!1),v=(0,p.useRef)(null),y=(0,p.useRef)(null),b=(0,p.useRef)(null),x=(0,p.useRef)(!0);d.current=e,f.current=n,m.current=a,h.current=o;let S=(0,p.useCallback)(()=>{g.current!==null&&(window.clearTimeout(g.current),g.current=null)},[]),C=(0,p.useCallback)(async e=>{S();let t=h.current(e);b.current=t;let n=m.current?.(e)??null;if(n){u(n),c(`error`);return}if(_.current){v.current=e;return}_.current=!0,u(null),c(`saving`);try{await f.current(e),y.current=t,x.current&&c(`saved`)}catch(e){x.current&&(u(e instanceof Error?e.message:String(e)),c(`error`))}finally{_.current=!1;let e=v.current;v.current=null,e&&h.current(e)!==y.current&&C(e)}},[S]),w=(0,p.useCallback)(()=>{let e=d.current;!r||!t||e===null||C(e)},[t,r,C]),T=(0,p.useCallback)(e=>{let t=e??d.current;!r||t===null||C(t)},[r,C]);return(0,p.useEffect)(()=>{if(!r||!t||e===null){S(),!t&&s===`dirty`&&c(`idle`);return}let n=o(e);if(n!==y.current&&!(s===`error`&&n===b.current))return c(e=>e===`saving`?e:`dirty`),S(),g.current=window.setTimeout(()=>void C(e),i),S},[S,i,t,r,C,o,s,e]),(0,p.useEffect)(()=>(x.current=!0,()=>{x.current=!1,S()}),[S]),(0,p.useEffect)(()=>{if(s!==`saved`)return;let e=window.setTimeout(()=>c(`idle`),1600);return()=>window.clearTimeout(e)},[s]),{status:s,error:l,flush:w,saveNow:T,retry:w,onBlurCapture:w}}export{d as n,m as t};
1
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{n as i}from"./locale-store-Cit_aHqC.js";import{t as a}from"./check-DUBLcKHA.js";import{t as o}from"./circle-alert-BEjgurr2.js";import{t as s}from"./loader-circle-CifKLtgG.js";import{t as c}from"./cn-0WouolD0.js";var l=n(),u=r();function d(e){let t=(0,l.c)(21),{status:n,error:r,className:d}=e,p=i(f)===`zh`;if(n===`idle`)return null;let m=n===`saving`?p?`正在保存…`:`Saving…`:n===`saved`?p?`已自动保存`:`Saved automatically`:n===`error`?r||(p?`自动保存失败`:`Autosave failed`):n===`dirty`?p?`编辑中,将自动保存`:`Editing — autosave pending`:``,h=n===`error`?`text-danger`:n===`saved`?`text-success`:`text-fg-subtle`,g;t[0]!==d||t[1]!==h?(g=c(`inline-flex min-w-0 items-center gap-1.5 text-xs`,h,d),t[0]=d,t[1]=h,t[2]=g):g=t[2];let _;t[3]===n?_=t[4]:(_=n===`saving`?(0,u.jsx)(s,{className:`size-3.5 shrink-0 animate-spin`,"aria-hidden":!0}):null,t[3]=n,t[4]=_);let v;t[5]===n?v=t[6]:(v=n===`saved`?(0,u.jsx)(a,{className:`size-3.5 shrink-0`,"aria-hidden":!0}):null,t[5]=n,t[6]=v);let y;t[7]===n?y=t[8]:(y=n===`error`?(0,u.jsx)(o,{className:`size-3.5 shrink-0`,"aria-hidden":!0}):null,t[7]=n,t[8]=y);let b;t[9]===n?b=t[10]:(b=n===`dirty`?(0,u.jsx)(`span`,{className:`size-1.5 shrink-0 rounded-full bg-current`,"aria-hidden":!0}):null,t[9]=n,t[10]=b);let x;t[11]===m?x=t[12]:(x=(0,u.jsx)(`span`,{className:`truncate`,children:m}),t[11]=m,t[12]=x);let S;return t[13]!==m||t[14]!==g||t[15]!==_||t[16]!==v||t[17]!==y||t[18]!==b||t[19]!==x?(S=(0,u.jsxs)(`span`,{className:g,role:`status`,"aria-live":`polite`,title:m,children:[_,v,y,b,x]}),t[13]=m,t[14]=g,t[15]=_,t[16]=v,t[17]=y,t[18]=b,t[19]=x,t[20]=S):S=t[20],S}function f(e){return e.language}var p=e(t(),1);function m({value:e,dirty:t,onSave:n,enabled:r=!0,delayMs:i=700,validate:a,serialize:o=JSON.stringify}){let[s,c]=(0,p.useState)(`idle`),[l,u]=(0,p.useState)(null),d=(0,p.useRef)(e),f=(0,p.useRef)(n),m=(0,p.useRef)(a),h=(0,p.useRef)(o),g=(0,p.useRef)(null),_=(0,p.useRef)(!1),v=(0,p.useRef)(null),y=(0,p.useRef)(null),b=(0,p.useRef)(null),x=(0,p.useRef)(!0);d.current=e,f.current=n,m.current=a,h.current=o;let S=(0,p.useCallback)(()=>{g.current!==null&&(window.clearTimeout(g.current),g.current=null)},[]),C=(0,p.useCallback)(async e=>{S();let t=h.current(e);b.current=t;let n=m.current?.(e)??null;if(n){u(n),c(`error`);return}if(_.current){v.current=e;return}_.current=!0,u(null),c(`saving`);try{await f.current(e),y.current=t,x.current&&c(`saved`)}catch(e){x.current&&(u(e instanceof Error?e.message:String(e)),c(`error`))}finally{_.current=!1;let e=v.current;v.current=null,e&&h.current(e)!==y.current&&C(e)}},[S]),w=(0,p.useCallback)(()=>{let e=d.current;!r||!t||e===null||C(e)},[t,r,C]),T=(0,p.useCallback)(e=>{let t=e??d.current;!r||t===null||C(t)},[r,C]);return(0,p.useEffect)(()=>{if(!r||!t||e===null){S(),!t&&s===`dirty`&&c(`idle`);return}let n=o(e);if(n!==y.current&&!(s===`error`&&n===b.current))return c(e=>e===`saving`?e:`dirty`),S(),g.current=window.setTimeout(()=>void C(e),i),S},[S,i,t,r,C,o,s,e]),(0,p.useEffect)(()=>(x.current=!0,()=>{x.current=!1,S()}),[S]),(0,p.useEffect)(()=>{if(s!==`saved`)return;let e=window.setTimeout(()=>c(`idle`),1600);return()=>window.clearTimeout(e)},[s]),{status:s,error:l,flush:w,saveNow:T,retry:w,onBlurCapture:w}}export{d as n,m as t};
@@ -0,0 +1,2 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/attachment-load-C9iZLUHv.js","assets/rolldown-runtime-aKtaBQYM.js","assets/attachment-utils-core-BPYdUI6y.js"])))=>i.map(i=>d[i]);
2
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./preload-helper-Czpn1I53.js";import{n as a}from"./locale-store-Cit_aHqC.js";import{t as o}from"./messages-DQveK9sk.js";import{o as s,r as c,s as l,t as u}from"./dist-CY7CS_D3.js";import{t as d}from"./chevron-left-DqFhpbvK.js";import{t as f}from"./chevron-right-BweFrslA.js";import{t as p}from"./file-code-corner-byQA1VfD.js";import{t as m}from"./file-CStvVK2S.js";import{n as h,r as g,s as _,t as v}from"./use-file-preview-expanded-D4b4fDeu.js";import{t as y}from"./mic-CuUb7zc-.js";import{u as b}from"./preview-runtime-RnBDP-Lq.js";import{n as x}from"./share-link-dialog-BxFk4-4u.js";import{t as S}from"./cn-0WouolD0.js";import{r as C}from"./turn-outcome-BSbEJx8h.js";import{i as w}from"./attachment-utils-core-BPYdUI6y.js";import{t as T}from"./constants-D5Z-mUto.js";import{r as E}from"./right-workspace-store-NXMrEuwH.js";import{n as D}from"./interaction-BdhHBbYa.js";import{t as O}from"./composer-notifications-B0IZsy8x.js";import{n as k}from"./electron-env-DHOGevH3.js";import{a as A,n as j,t as M}from"./file-preview-surface-CeFFZo3a.js";var N=n(),P=e(t(),1),F=r();function I(e){let t=(0,N.c)(6),n=_(),r,i;if(t[0]!==n||t[1]!==e?(r=()=>{!n||e.embedded||!e.open||!e.attachment||(E.getState().openFile({attachment:e.attachment,images:e.images,conversationId:e.conversationId||void 0,resultRevision:e.resultRevision},n),e.onClose())},i=[n,e],t[0]=n,t[1]=e,t[2]=r,t[3]=i):(r=t[2],i=t[3]),(0,P.useEffect)(r,i),n&&!e.embedded)return null;let a;return t[4]===e?a=t[5]:(a=(0,F.jsx)(L,{...e}),t[4]=e,t[5]=a),a}function L({open:e,embedded:t=!1,showEmbeddedClose:n=!1,tabId:r,attachment:i,images:p=[],resultRevision:m,onAttachmentChange:g,authToken:_,conversationId:y,layerClassName:w=`z-[115]`,onClose:T}){let E=a(e=>e.language),N=o(E).chat,I=b({open:e,attachment:i,authToken:_,conversationId:y,language:E}),L=A(),{expanded:R,setExpanded:z}=v(e,L.dialogOpen),[B,V]=(0,P.useState)(!1),{preview:H,fileType:U,hasExtractedText:W}=I,G=i?p.findIndex(e=>e===i||e.id&&e.id===i.id||e.uri&&e.uri===i.uri||!e.id&&!e.uri&&e.name===i.name&&!!e.data&&e.data===i.data):-1,K=U===`image`&&p.length>1&&G>=0&&!!g,q=e=>{if(!K||L.dialogOpen)return;let t=G+(e===`previous`?-1:1);t>=0&&t<p.length&&g?.(p[t])},J=U!==`image`&&U!==`text`&&U!==`pptx`&&W,Y=H?.uri?C(H.uri):null,X=!!(Y||H?.uri?.startsWith(`media://`)&&(y||H.taskId)),ee=()=>{!H?.uri||!X||L.createShareLink(Y?{fileId:Y,fileName:H.name}:{uri:H.uri,conversationId:y??void 0,taskId:H.taskId,fileName:H.name})},te=!!(H&&!I.loading&&!I.loadError),Z=()=>{z(!1),T()},ne=()=>{if(!H||!I.downloadBuffer)return;let e=new Blob([I.downloadBuffer],{type:I.descriptor.mimeType}),t=URL.createObjectURL(e),n=document.createElement(`a`);n.href=t,n.download=H.name??`download`,document.body.appendChild(n),n.click(),document.body.removeChild(n),URL.revokeObjectURL(t)},re=!!I.downloadBuffer,ie=k()&&U===`spreadsheet`&&/\.xlsx?$/i.test(I.fileName)&&!!I.downloadBuffer&&!!window.electronAPI?.shell?.openTemporaryFile,ae=async()=>{let e=I.downloadBuffer,t=window.electronAPI?.shell?.openTemporaryFile;if(!(!e||!t||B)){V(!0);try{(await t({fileName:I.fileName,data:new Uint8Array(e)})).ok||O(`warning`,N.attachmentPreviewOpenLocalFailed)}catch{O(`warning`,N.attachmentPreviewOpenLocalFailed)}finally{V(!1)}}},oe={onDownload:ne,canDownload:re},Q=S(`min-h-0 min-w-0 flex-1 cursor-pointer border-0 p-0`,`bg-surface-base transition-colors`,`hover:bg-surface-hover/90 dark:bg-black/60 dark:hover:bg-black/70`,D.focusRingBase),$=(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(h,{header:{expanded:R,onToggleExpanded:te?()=>z(e=>!e):void 0,hideClose:t&&!n,hideExpand:!!r,onClose:Z,share:X?{onClick:ee,loading:L.loading}:void 0,openWithSystemApp:ie?{onClick:()=>void ae(),loading:B}:void 0,textView:J?{active:I.showExtractedText,onChange:e=>{I.setShowExtractedText(e),I.clearLoadError()}}:void 0},chat:I.downloadBuffer?{conversationId:y,createFile:async()=>new File([I.downloadBuffer],I.fileName,{type:I.descriptor.mimeType})}:void 0,onImageSwipe:K?q:void 0,language:E,descriptor:r?{...I.descriptor,id:r}:I.descriptor,loading:I.loading,loadError:I.loadError,textContent:I.textContent,binaryBuffer:I.binaryBuffer,showExtractedText:I.showExtractedText,extractedText:I.extractedText,extractedTextTruncated:I.extractedTextTruncated,actions:oe}),m?(0,F.jsxs)(`p`,{className:`shrink-0 border-t border-edge px-4 py-2 text-xs text-fg-muted`,"data-result-revision":!0,children:[E===`zh`?`成果版本`:`Result version`,` `,m]}):null,K?(0,F.jsxs)(`div`,{className:`flex shrink-0 items-center justify-center gap-4 border-t border-edge bg-surface-panel px-3 py-2`,children:[(0,F.jsx)(`button`,{type:`button`,"aria-label":N.attachmentPreviewPreviousImage,disabled:G===0,onClick:()=>q(`previous`),className:S(`flex size-11 touch-manipulation items-center justify-center rounded-lg hover:bg-surface-hover disabled:opacity-30`,D.focusRingBase),children:(0,F.jsx)(d,{size:20,"aria-hidden":`true`})}),(0,F.jsxs)(`span`,{role:`status`,className:`min-w-16 text-center text-sm tabular-nums text-fg-muted`,children:[G+1,` / `,p.length]}),(0,F.jsx)(`button`,{type:`button`,"aria-label":N.attachmentPreviewNextImage,disabled:G===p.length-1,onClick:()=>q(`next`),className:S(`flex size-11 touch-manipulation items-center justify-center rounded-lg hover:bg-surface-hover disabled:opacity-30`,D.focusRingBase),children:(0,F.jsx)(f,{size:20,"aria-hidden":`true`})})]}):null]});return t?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(M,{expanded:R,children:$}),(0,F.jsx)(x,{open:L.dialogOpen,onOpenChange:L.handleOpenChange,loading:L.loading,error:L.error,result:L.result,pendingParams:L.pendingParams,onConfirm:e=>void L.confirmShareLink(e)})]}):(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(u,{open:e,onOpenChange:e=>!e&&Z(),children:(0,F.jsx)(s,{children:(0,F.jsxs)(c,{"aria-describedby":void 0,onKeyDown:e=>{!K||L.dialogOpen||e.altKey||e.ctrlKey||e.metaKey||e.target.closest(`input, textarea, select, [contenteditable="true"]`)||(e.key===`ArrowLeft`||e.key===`ArrowRight`)&&(e.preventDefault(),q(e.key===`ArrowLeft`?`previous`:`next`))},className:S(`xopc-dialog-content-fullscreen fixed inset-0 flex h-[100dvh] w-full flex-row overflow-hidden`,j(),w,`border-0 bg-transparent p-0 shadow-none outline-none`),children:[(0,F.jsx)(l,{className:`sr-only`,children:H?.name??``}),(0,F.jsx)(`button`,{type:`button`,className:Q,onClick:Z,"aria-label":N.attachmentPreviewClose}),(0,F.jsx)(`div`,{className:S(`flex h-full min-h-0 shrink-0 flex-col overflow-hidden`,R?`w-full`:`w-[min(100%,var(--max-width-app-main))]`,`bg-surface-panel sm:border-x sm:border-edge dark:sm:border-edge`,`shadow-float dark:shadow-elevated`),children:$}),(0,F.jsx)(`button`,{type:`button`,className:Q,onClick:Z,"aria-label":N.attachmentPreviewClose})]})})}),(0,F.jsx)(x,{open:L.dialogOpen,onOpenChange:L.handleOpenChange,loading:L.loading,error:L.error,result:L.result,pendingParams:L.pendingParams,onConfirm:e=>void L.confirmShareLink(e)})]})}function R(e){let t=(0,N.c)(23),{attachments:n,conversationId:r,topPadded:i,onRemove:s,className:c}=e,l=a(z),u;t[0]===l?u=t[1]:(u=o(l),t[0]=l,t[1]=u);let d=u.chat,[f,h]=(0,P.useState)(null);if(n.length===0)return null;let g=i?`pt-2`:`pt-3`,_;t[2]!==c||t[3]!==g?(_=S(`flex flex-wrap gap-2 border-b border-edge-subtle/90 bg-surface-hover/20 px-4 pb-2 dark:border-edge-subtle`,g,c),t[2]=c,t[3]=g,t[4]=_):_=t[4];let v;if(t[5]!==n||t[6]!==d||t[7]!==s){let e;t[9]!==d||t[10]!==s?(e=(e,t)=>{let n=e.type===`pasted_text`?d.pastedText:e.name;return(0,F.jsxs)(`div`,{className:`flex max-w-[200px] items-center rounded-lg bg-surface-hover text-xs dark:bg-surface-hover/80`,children:[(0,F.jsxs)(`button`,{type:`button`,className:S(`flex min-w-0 flex-1 items-center gap-1.5 rounded-l-lg py-1 pl-2 pr-1 text-left hover:bg-surface-active`,D.transition,D.press,D.focusRingPanel),onClick:()=>h(e),"aria-label":`${d.attachmentPreviewOpen}: ${n}`,title:`${d.attachmentPreviewOpen}: ${n}`,children:[e.mimeType?.startsWith(`image/`)&&e.content?(0,F.jsx)(`img`,{src:`data:${e.mimeType};base64,${e.content}`,alt:``,className:`size-6 shrink-0 rounded object-cover`}):e.type===`voice`||e.mimeType?.startsWith(`audio/`)?(0,F.jsx)(y,{className:`size-3.5 shrink-0 text-accent-fg`,"aria-hidden":!0}):e.type===`pasted_text`?(0,F.jsx)(p,{className:`size-3.5 shrink-0 text-accent-fg`,"aria-hidden":!0}):(0,F.jsx)(m,{className:`size-3.5 shrink-0 text-fg-muted`,"aria-hidden":!0}),(0,F.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:n}),(0,F.jsx)(`span`,{className:`shrink-0 text-fg-disabled`,children:w(e.size)})]}),(0,F.jsx)(`button`,{type:`button`,className:S(`flex min-h-8 min-w-8 items-center justify-center rounded-r-lg text-fg-muted hover:bg-surface-active hover:text-fg`,D.transition,D.press,D.focusRingPanel),onClick:()=>s(t),"aria-label":`${d.attachmentPreviewRemove}: ${n}`,title:`${d.attachmentPreviewRemove}: ${n}`,children:(0,F.jsx)(`span`,{"aria-hidden":!0,children:`×`})})]},e.id??`${e.name}-${e.size}-${e.mimeType}-${e.content?.slice(0,16)??``}`)},t[9]=d,t[10]=s,t[11]=e):e=t[11],v=n.map(e),t[5]=n,t[6]=d,t[7]=s,t[8]=v}else v=t[8];let b;t[12]!==_||t[13]!==v?(b=(0,F.jsx)(`div`,{className:_,children:v}),t[12]=_,t[13]=v,t[14]=b):b=t[14];let x=f!==null,C;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(C=()=>h(null),t[15]=C):C=t[15];let T;t[16]!==r||t[17]!==f||t[18]!==x?(T=(0,F.jsx)(I,{open:x,attachment:f,conversationId:r,onClose:C}),t[16]=r,t[17]=f,t[18]=x,t[19]=T):T=t[19];let E;return t[20]!==b||t[21]!==T?(E=(0,F.jsxs)(F.Fragment,{children:[b,T]}),t[20]=b,t[21]=T,t[22]=E):E=t[22],E}function z(e){return e.language}function B(e){let{chat:t,initialAttachments:n=[],onAttachmentsChange:r}=e,[a,o]=(0,P.useState)(n),[s,c]=(0,P.useState)(!1),l=(0,P.useRef)(null),u=(0,P.useRef)(a),d=(0,P.useRef)(r);u.current=a,d.current=r;let f=(0,P.useCallback)(e=>{let t=typeof e==`function`?e(u.current):e;u.current=t,o(t),d.current?.(t)},[]),p=(0,P.useCallback)(()=>{f([])},[]),m=(0,P.useCallback)(e=>{f(t=>t.filter((t,n)=>n!==e))},[]),h=(0,P.useCallback)(()=>u.current.map(e=>({type:e.type===`voice`?`voice`:e.type||`file`,mimeType:e.mimeType,data:e.content,name:e.name,size:e.size,...e.uri?{uri:e.uri}:{},...typeof e.durationSeconds==`number`&&Number.isFinite(e.durationSeconds)&&e.durationSeconds>0?{durationSeconds:e.durationSeconds}:{}})),[]),_=(0,P.useCallback)(async(e,n)=>{if(e.length===0)return;let r=10-u.current.length;if(r<=0){O(`warning`,t.maxAttachmentsReached,{max:10});return}let a=e.slice(0,r);e.length>a.length&&O(`warning`,t.maxAttachmentsTruncated,{max:10,dropped:e.length-a.length});let{loadAttachment:o}=await i(async()=>{let{loadAttachment:e}=await import(`./attachment-load-C9iZLUHv.js`).then(e=>e.t);return{loadAttachment:e}},__vite__mapDeps([0,1,2])),s=(await Promise.all(a.map(async e=>{if(e.size>33554432)return O(`warning`,t.attachmentFileTooLarge,{name:e.name,maxSize:w(T)}),null;try{return await o(e,e.name)}catch{return O(`error`,t.attachmentLoadFailed,{name:e.name}),null}}))).filter(e=>e!==null).map(e=>n?{...e,type:n}:e);f(e=>[...e,...s])},[t.attachmentFileTooLarge,t.attachmentLoadFailed,t.maxAttachmentsReached,t.maxAttachmentsTruncated]),v=(0,P.useCallback)(e=>_(e),[_]);return(0,P.useEffect)(()=>{if(e.conversationId)return g(e.conversationId,async e=>{let t=u.current.length;return await _([e]),u.current.length>t})},[_,e.conversationId]),{attachments:a,setAttachments:f,attachmentsRef:u,isDragging:s,setIsDragging:c,fileInputRef:l,processFiles:v,processPastedText:(0,P.useCallback)(e=>_([new File([e.text],e.name,{type:e.mimeType})],`pasted_text`),[_]),removeAttachment:m,clearAttachments:p,wireAttachmentsPayload:h}}export{R as n,I as r,B as t};
@@ -0,0 +1 @@
1
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{u as i}from"./chunk-KS7C4IRE-CiwuuyV8.js";import{n as a}from"./locale-store-Cit_aHqC.js";import{t as o}from"./messages-DQveK9sk.js";import{t as s}from"./createLucideIcon-DPHK1VkS.js";import{t as c}from"./app-window-DXFNqt_0.js";import{t as l}from"./check-DUBLcKHA.js";import{t as u}from"./chevron-down-ccbiQQz_.js";import{t as d}from"./copy-Dv6d4Dvw.js";import{t as f}from"./download-Dk-ZjtO6.js";import{t as p}from"./ellipsis-0k4rZLoy.js";import{t as ee}from"./external-link-DjqjBmc3.js";import{t as te}from"./eye-CABVeTq0.js";import{t as ne}from"./folder-open-CyzJ19I9.js";import{t as re}from"./link-2-D_ZKYUW7.js";import{t as ie}from"./loader-circle-CifKLtgG.js";import{q as ae}from"./markdown-view-Dm01GIXv.js";import{t as oe}from"./message-square-plus-XP0tGdlV.js";import{t as m}from"./minimize-2-DtOGrlpo.js";import{t as h}from"./paperclip-f1HujQY1.js";import{t as g}from"./pencil-DmIY3Oa-.js";import{t as se}from"./refresh-cw-BRlGaq2w.js";import{t as ce}from"./save-DRDABU--.js";import{c as _,i as le,n as ue,r as de,s as fe,t as pe}from"./preview-runtime-RnBDP-Lq.js";import{t as me}from"./x-B_N4OPjy.js";import{t as v}from"./cn-0WouolD0.js";import{a as y}from"./session-api-CkOliupg.js";import{i as b}from"./attachment-utils-core-BPYdUI6y.js";import{t as x}from"./constants-D5Z-mUto.js";import{n as he}from"./interaction-BdhHBbYa.js";import{t as S}from"./composer-notifications-B0IZsy8x.js";import{r as ge}from"./app-chrome-BeB4KgOf.js";import{n as _e}from"./electron-env-DHOGevH3.js";import{t as ve}from"./sliding-tab-list-CmcrqRzN.js";import{a as ye,l as be,m as C,n as w,o as xe,r as T,t as E,u as D}from"./dist-ZrL34Ps4.js";var Se=s(`folders`,[[`path`,{d:`M20 5a2 2 0 0 1 2 2v7a2 2 0 0 1-2 2H9a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h2.5a1.5 1.5 0 0 1 1.2.6l.6.8a1.5 1.5 0 0 0 1.2.6z`,key:`a4852j`}],[`path`,{d:`M3 8.268a2 2 0 0 0-1 1.738V19a2 2 0 0 0 2 2h11a2 2 0 0 0 1.732-1`,key:`yxbcw3`}]]),Ce=s(`text-wrap`,[[`path`,{d:`m16 16-3 3 3 3`,key:`117b85`}],[`path`,{d:`M3 12h14.5a1 1 0 0 1 0 7H13`,key:`18xa6z`}],[`path`,{d:`M3 19h6`,key:`1ygdsz`}],[`path`,{d:`M3 5h18`,key:`1u36vt`}]]),O=e(t(),1),k=(0,O.createContext)(null);function A(){return(0,O.useContext)(k)}var j=(0,O.createContext)([]),we=(0,O.createContext)(null),M=new Map;function Te(e,t){return M.set(e,t),()=>{M.get(e)===t&&M.delete(e)}}async function N(e,t){return await M.get(e)?.(t)??!1}var P=n(),F=r();function I(e){let t=(0,P.c)(3),{app:n}=e,[r,i]=(0,O.useState)(),a;return t[0]!==n||t[1]!==r?(a=n?.iconDataUrl&&n.iconDataUrl!==r?(0,F.jsx)(`img`,{src:n.iconDataUrl,alt:``,width:20,height:20,className:`size-5 shrink-0 object-contain`,onError:()=>i(n.iconDataUrl)}):(0,F.jsx)(c,{className:`size-5 shrink-0 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),t[0]=n,t[1]=r,t[2]=a):a=t[2],a}function Ee({variant:e=`split`,onAction:t,systemApp:n,chooseApp:r,recommendedApps:i,recentApps:s,onOpenWithApp:d}){let f=a(e=>e.language),p=o(f).workspace,[te,ne]=(0,O.useState)(),[re,ae]=(0,O.useState)(!1),oe=[...i,...s],m=d&&te!==null?oe.find(e=>e.path===te?.path)??te??oe[0]:void 0,h=!!(re||n?.loading||r?.loading),g=h||!!n?.disabled,se=m?f===`zh`?`用 ${m.name} 打开`:`Open with ${m.name}`:p.openSystemApp,ce=`flex min-h-9 cursor-default items-center gap-2.5 rounded-md px-2.5 py-2 text-sm text-fg outline-none data-[highlighted]:bg-surface-hover data-[disabled]:pointer-events-none data-[disabled]:opacity-40`,_=`my-1 h-px bg-edge-subtle`;if(!n&&!r&&(!d||!oe.length))return null;if(e===`menu`){let e=e=>t?t(e):e(),a=`flex min-h-9 w-full items-center gap-2.5 rounded-md px-2.5 py-2 text-left text-sm text-fg hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent disabled:cursor-not-allowed disabled:opacity-40`;return(0,F.jsxs)(F.Fragment,{children:[n?(0,F.jsxs)(`button`,{type:`button`,role:`menuitem`,className:a,disabled:g,onClick:()=>e(n.onClick),children:[(0,F.jsx)(ee,{className:`size-5 shrink-0 text-fg-muted`,"aria-hidden":!0}),(0,F.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:p.openSystemApp})]}):null,d?[{label:p.recommendedApps,apps:i},{label:p.recentApps,apps:s.filter(e=>!i.some(t=>t.path===e.path))}].map(t=>t.apps.length?(0,F.jsxs)(`div`,{role:`group`,"aria-label":t.label,children:[(0,F.jsx)(`div`,{className:`px-2.5 pb-1 pt-1.5 text-xs font-medium text-fg-muted`,children:t.label}),t.apps.map(t=>(0,F.jsxs)(`button`,{type:`button`,role:`menuitem`,className:a,disabled:g,onClick:()=>e(()=>d(t.path)),children:[(0,F.jsx)(I,{app:t}),(0,F.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:t.name})]},t.path))]},t.label):null):null,r?(0,F.jsxs)(`button`,{type:`button`,role:`menuitem`,className:a,disabled:g||r.disabled,onClick:()=>e(()=>{r.onClick()}),children:[(0,F.jsx)(c,{className:`size-5 shrink-0 text-fg-muted`,"aria-hidden":!0}),(0,F.jsx)(`span`,{className:`min-w-0 truncate`,children:p.chooseApp})]}):null,(0,F.jsx)(`div`,{className:`my-1 border-t border-edge-subtle dark:border-edge`})]})}return(0,F.jsxs)(`div`,{className:`inline-flex h-9 shrink-0 items-stretch rounded-full border border-edge-subtle bg-surface-panel`,children:[(0,F.jsxs)(`button`,{type:`button`,"aria-label":se,title:se,disabled:g||!m&&!n,onClick:()=>m?d?.(m.path):n?.onClick(),className:v(`inline-flex min-w-0 items-center gap-2 rounded-l-full pl-3 pr-2 text-sm font-medium text-fg transition-colors hover:bg-surface-hover disabled:cursor-not-allowed disabled:opacity-40`,he.focusRingPanel),children:[h?(0,F.jsx)(ie,{className:`size-5 animate-spin`,"aria-hidden":!0}):(0,F.jsx)(I,{app:m}),(0,F.jsx)(`span`,{children:f===`zh`?`打开`:`Open`})]}),(0,F.jsxs)(be,{modal:!1,children:[(0,F.jsx)(C,{asChild:!0,children:(0,F.jsx)(`button`,{type:`button`,"aria-label":p.chooseApp,title:p.chooseApp,disabled:g,className:v(`inline-flex w-8 shrink-0 items-center justify-center rounded-r-full text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg disabled:cursor-not-allowed disabled:opacity-40`,he.focusRingPanel),children:(0,F.jsx)(u,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0})})}),(0,F.jsx)(xe,{children:(0,F.jsxs)(E,{align:`end`,sideOffset:6,collisionPadding:8,"aria-label":p.chooseApp,onEscapeKeyDown:e=>e.stopPropagation(),className:`z-[150] max-h-[var(--radix-dropdown-menu-content-available-height)] w-64 max-w-[calc(100vw-1rem)] overflow-y-auto overscroll-contain rounded-xl border border-edge bg-surface-overlay p-1 shadow-popover outline-none`,children:[n?(0,F.jsxs)(T,{className:ce,disabled:n.disabled||h,onSelect:()=>{ne(null),n.onClick()},children:[(0,F.jsx)(ee,{className:`size-5 shrink-0 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),(0,F.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:p.openSystemApp}),m?null:(0,F.jsx)(l,{className:`size-4 shrink-0`,"aria-hidden":!0})]}):null,d?[{label:p.recommendedApps,apps:i},{label:p.recentApps,apps:s.filter(e=>!i.some(t=>t.path===e.path))}].map(e=>e.apps.length?(0,F.jsxs)(w,{children:[(0,F.jsx)(D,{className:_}),(0,F.jsx)(ye,{className:`px-2.5 pb-1 pt-1.5 text-xs font-medium text-fg-muted`,children:e.label}),e.apps.map(e=>(0,F.jsxs)(T,{className:ce,disabled:h,title:e.name,onSelect:()=>{ne(e),d(e.path)},children:[(0,F.jsx)(I,{app:e}),(0,F.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.name}),e.path===m?.path?(0,F.jsx)(l,{className:`size-4 shrink-0`,"aria-hidden":!0}):null]},e.path))]},e.label):null):null,r?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(D,{className:_}),(0,F.jsxs)(T,{className:ce,disabled:r.disabled||h,onSelect:async()=>{ae(!0);try{let e=await r.onClick();e&&ne(e)}finally{ae(!1)}},children:[(0,F.jsx)(c,{className:`size-5 shrink-0 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),(0,F.jsx)(`span`,{className:`min-w-0 truncate`,children:p.chooseApp})]})]}):null]})})]})]})}function De(e){let t=(0,P.c)(9),{label:n,active:r,disabled:i,onClick:a,children:o}=e,s=r&&`border-accent/20 bg-accent-soft text-accent-fg`,c;t[0]===s?c=t[1]:(c=v(`inline-flex size-9 shrink-0 items-center justify-center rounded-full border border-edge-subtle bg-surface-panel text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg disabled:cursor-not-allowed disabled:opacity-40`,s,he.focusRingPanel),t[0]=s,t[1]=c);let l;return t[2]!==r||t[3]!==o||t[4]!==i||t[5]!==n||t[6]!==a||t[7]!==c?(l=(0,F.jsx)(`button`,{type:`button`,className:c,title:n,"aria-label":n,"aria-pressed":r,disabled:i,onClick:a,children:o}),t[2]=r,t[3]=o,t[4]=i,t[5]=n,t[6]=a,t[7]=c,t[8]=l):l=t[8],l}function L(e){let t=(0,P.c)(14),{icon:n,label:r,active:i,disabled:a,onClick:o}=e,s=i===void 0?`menuitem`:`menuitemcheckbox`,c;t[0]===n?c=t[1]:(c=(0,F.jsx)(`span`,{className:`flex size-4 shrink-0 items-center justify-center text-fg-muted`,"aria-hidden":!0,children:n}),t[0]=n,t[1]=c);let u;t[2]===r?u=t[3]:(u=(0,F.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:r}),t[2]=r,t[3]=u);let d;t[4]===i?d=t[5]:(d=i?(0,F.jsx)(l,{className:`size-4 shrink-0`,"aria-hidden":!0}):null,t[4]=i,t[5]=d);let f;return t[6]!==i||t[7]!==a||t[8]!==o||t[9]!==s||t[10]!==c||t[11]!==u||t[12]!==d?(f=(0,F.jsxs)(`button`,{type:`button`,role:s,"aria-checked":i,className:`flex h-9 w-full min-w-0 items-center gap-2.5 rounded-md px-2.5 text-left text-sm text-fg hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent disabled:cursor-not-allowed disabled:opacity-40`,disabled:a,onClick:o,children:[c,u,d]}),t[6]=i,t[7]=a,t[8]=o,t[9]=s,t[10]=c,t[11]=u,t[12]=d,t[13]=f):f=t[13],f}function R(e){let t=(0,P.c)(90),{referenceActions:n,onRefresh:r,onRetrySave:i,subtitle:s,controller:c,actions:u,expanded:_,onToggleExpanded:le,onClose:ue,hideClose:de,hideExpand:fe,edit:y,wordWrap:b,editInNewChat:x,share:S,openWithSystemApp:ye,chooseApp:be,recommendedApps:C,recentApps:w,onOpenWithApp:xe,onRevealInFolder:T,copyPath:E,textView:D,openInBrowser:k}=e,A;t[0]===n?A=t[1]:(A=n===void 0?[]:n,t[0]=n,t[1]=A);let j=A,M;t[2]===C?M=t[3]:(M=C===void 0?[]:C,t[2]=C,t[3]=M);let Te=M,N;t[4]===w?N=t[5]:(N=w===void 0?[]:w,t[4]=w,t[5]=N);let I=N,R=a(Ae),je;t[6]===R?je=t[7]:(je=o(R),t[6]=R,t[7]=je);let z=je,B=z.workspace,Me=c.plugin.id===`pdf`?z.chat.attachmentPreviewPdf:c.plugin.id===`docx`?z.chat.attachmentPreviewDocument:c.plugin.id===`spreadsheet`?z.chat.attachmentPreviewSpreadsheet:B.preview,Ne;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(Ne=_e(),t[8]=Ne):Ne=t[8];let Pe=Ne,V=(0,O.useContext)(we),Fe=(0,O.useRef)(null),Ie=(0,O.useRef)(null),[H,Le]=(0,O.useState)(!1),Re;t[9]===c.plugin.capabilities?Re=t[10]:(Re=c.plugin.capabilities.some(ke),t[9]=c.plugin.capabilities,t[10]=Re);let ze=Re,Be,Ve;t[11]===H?(Be=t[12],Ve=t[13]):(Be=()=>{if(!H)return;Fe.current?.querySelector(`button:not(:disabled), a`)?.focus();let e=e=>{if([`ArrowDown`,`ArrowUp`,`Home`,`End`].includes(e.key)&&Fe.current?.contains(document.activeElement)){e.preventDefault(),e.stopImmediatePropagation();let t=[...Fe.current.querySelectorAll(`button:not(:disabled), a`)],n=t.indexOf(document.activeElement);t[e.key===`Home`?0:e.key===`End`?t.length-1:(n+(e.key===`ArrowDown`?1:-1)+t.length)%t.length]?.focus();return}e.key===`Escape`&&(e.preventDefault(),e.stopImmediatePropagation(),Le(!1),Ie.current?.focus())};return window.addEventListener(`keydown`,e,!0),()=>window.removeEventListener(`keydown`,e,!0)},Ve=[H],t[11]=H,t[12]=Be,t[13]=Ve),(0,O.useEffect)(Be,Ve);let He;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(He=e=>{Le(!1),Ie.current?.focus(),e()},t[14]=He):He=t[14];let U=He,Ue;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(Ue=v(`shrink-0 bg-surface-base px-3 py-2 sm:px-4`,ge),t[15]=Ue):Ue=t[15];let W;t[16]===V?W=t[17]:(W=V?(0,F.jsx)(De,{label:V.label,active:V.active,onClick:V.onToggle,children:(0,F.jsx)(Se,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0})}):null,t[16]=V,t[17]=W);let G;t[18]!==_||t[19]!==fe||t[20]!==B.collapsePreview||t[21]!==B.expandPreview||t[22]!==le?(G=fe?null:(0,F.jsx)(De,{label:_?B.collapsePreview:B.expandPreview,active:_,disabled:!le,onClick:le,children:_?(0,F.jsx)(m,{className:`size-4`,"aria-hidden":!0}):(0,F.jsx)(ae,{className:`size-4`,"aria-hidden":!0})}),t[18]=_,t[19]=fe,t[20]=B.collapsePreview,t[21]=B.expandPreview,t[22]=le,t[23]=G):G=t[23];let K;t[24]===H?K=t[25]:(K=H?(0,F.jsx)(`button`,{type:`button`,className:`fixed inset-0 z-40 cursor-default bg-transparent`,"aria-hidden":!0,tabIndex:-1,onPointerDown:e=>{e.preventDefault(),Le(!1)}}):null,t[24]=H,t[25]=K);let We;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(We=v(`inline-flex size-9 shrink-0 items-center justify-center rounded-full border border-edge-subtle bg-surface-panel text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg`,he.focusRingPanel),t[26]=We):We=t[26];let Ge,Ke;t[27]===Symbol.for(`react.memo_cache_sentinel`)?(Ge=()=>Le(Oe),Ke=(0,F.jsx)(p,{className:`size-4`}),t[27]=Ge,t[28]=Ke):(Ge=t[27],Ke=t[28]);let q;t[29]!==B.moreActions||t[30]!==H?(q=(0,F.jsx)(`button`,{ref:Ie,type:`button`,className:We,title:B.moreActions,"aria-label":B.moreActions,"aria-haspopup":`menu`,"aria-expanded":H,onClick:Ge,children:Ke}),t[29]=B.moreActions,t[30]=H,t[31]=q):q=t[31];let J;t[32]!==u||t[33]!==be||t[34]!==c.plugin.capabilities||t[35]!==E||t[36]!==y||t[37]!==x||t[38]!==R||t[39]!==B.copyFilePath||t[40]!==B.copyWorkspacePath||t[41]!==B.download||t[42]!==B.edit||t[43]!==B.editInNewChat||t[44]!==B.moreActions||t[45]!==B.openInBrowser||t[46]!==B.pathCopied||t[47]!==B.preview||t[48]!==B.revealInFolder||t[49]!==B.saveCopy||t[50]!==B.shareLink||t[51]!==B.wordWrap||t[52]!==H||t[53]!==xe||t[54]!==r||t[55]!==i||t[56]!==T||t[57]!==k||t[58]!==ye||t[59]!==I||t[60]!==Te||t[61]!==j||t[62]!==S||t[63]!==b?(J=H?(0,F.jsxs)(`div`,{ref:Fe,role:`menu`,"aria-label":B.moreActions,"data-file-preview-menu":!0,className:`absolute right-0 top-full z-50 mt-1 max-h-[min(32rem,calc(100dvh-8rem))] w-60 max-w-[calc(100vw-2rem)] overflow-y-auto overscroll-contain rounded-lg border border-edge bg-surface-overlay p-1 shadow-popover`,children:[(0,F.jsx)(Ee,{variant:`menu`,onAction:U,systemApp:ye,chooseApp:be,recommendedApps:Te,recentApps:I,onOpenWithApp:xe}),j.map(e=>(0,F.jsx)(L,{icon:(0,F.jsx)(h,{className:`size-4`}),label:e.label,disabled:e.disabled,onClick:()=>U(e.onClick)},e.label)),i?(0,F.jsx)(L,{icon:(0,F.jsx)(ce,{className:`size-4`}),label:R===`zh`?`重试保存`:`Retry save`,onClick:()=>U(i)}):null,r?(0,F.jsx)(L,{icon:(0,F.jsx)(se,{className:`size-4`}),label:R===`zh`?`刷新文件`:`Refresh file`,onClick:()=>U(r)}):null,c.plugin.capabilities.includes(`edit`)?(0,F.jsx)(L,{icon:y?.active?(0,F.jsx)(te,{className:`size-4`}):(0,F.jsx)(g,{className:`size-4`}),label:y?.active?B.preview:B.edit,disabled:!y,onClick:()=>U(()=>y?.onToggle())}):null,b?(0,F.jsx)(L,{icon:(0,F.jsx)(Ce,{className:`size-4`}),label:B.wordWrap,active:b.active,onClick:()=>U(b.onToggle)}):null,(0,F.jsx)(`div`,{className:`my-1 border-t border-edge-subtle dark:border-edge`}),(0,F.jsx)(L,{icon:x?.loading?(0,F.jsx)(ie,{className:`size-4 animate-spin`}):(0,F.jsx)(oe,{className:`size-4`}),label:B.editInNewChat,disabled:!x||x.disabled||x.loading,onClick:()=>U(()=>x?.onClick())}),(0,F.jsx)(L,{icon:S?.loading?(0,F.jsx)(ie,{className:`size-4 animate-spin`}):(0,F.jsx)(re,{className:`size-4`}),label:B.shareLink,disabled:!S||S.disabled||S.loading,onClick:()=>U(()=>S?.onClick())}),(0,F.jsx)(`div`,{className:`my-1 border-t border-edge-subtle dark:border-edge`}),k?(0,F.jsxs)(`a`,{href:k.href,target:`_blank`,rel:`noopener noreferrer`,role:`menuitem`,className:`flex h-9 w-full items-center gap-2.5 rounded-md px-2.5 text-sm text-fg hover:bg-surface-hover`,onClick:()=>Le(!1),children:[(0,F.jsx)(ee,{className:`size-4 text-fg-muted`,"aria-hidden":!0}),B.openInBrowser]}):null,T?(0,F.jsx)(L,{icon:(0,F.jsx)(ne,{className:`size-4`}),label:B.revealInFolder,onClick:()=>U(T)}):null,T?(0,F.jsx)(`div`,{className:`my-1 border-t border-edge-subtle dark:border-edge`}):null,(0,F.jsx)(L,{icon:(0,F.jsx)(f,{className:`size-4`}),label:Pe?B.saveCopy:B.download,disabled:!u.canDownload,onClick:()=>U(()=>void u.onDownload())}),E?(0,F.jsx)(L,{icon:E.copied?(0,F.jsx)(l,{className:`size-4 text-emerald-500`}):(0,F.jsx)(d,{className:`size-4`}),label:E.copied?B.pathCopied:Pe?B.copyFilePath:B.copyWorkspacePath,onClick:()=>U(E.onClick)}):null]}):null,t[32]=u,t[33]=be,t[34]=c.plugin.capabilities,t[35]=E,t[36]=y,t[37]=x,t[38]=R,t[39]=B.copyFilePath,t[40]=B.copyWorkspacePath,t[41]=B.download,t[42]=B.edit,t[43]=B.editInNewChat,t[44]=B.moreActions,t[45]=B.openInBrowser,t[46]=B.pathCopied,t[47]=B.preview,t[48]=B.revealInFolder,t[49]=B.saveCopy,t[50]=B.shareLink,t[51]=B.wordWrap,t[52]=H,t[53]=xe,t[54]=r,t[55]=i,t[56]=T,t[57]=k,t[58]=ye,t[59]=I,t[60]=Te,t[61]=j,t[62]=S,t[63]=b,t[64]=J):J=t[64];let Y;t[65]!==K||t[66]!==q||t[67]!==J?(Y=(0,F.jsxs)(`div`,{className:`relative shrink-0`,children:[K,q,J]}),t[65]=K,t[66]=q,t[67]=J,t[68]=Y):Y=t[68];let X;t[69]!==de||t[70]!==B.close||t[71]!==ue?(X=de?null:(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(`div`,{className:`mx-0.5 h-5 w-px bg-edge-subtle`,"aria-hidden":!0}),(0,F.jsx)(De,{label:B.close,onClick:ue,children:(0,F.jsx)(me,{className:`size-4`,strokeWidth:1.75})})]}),t[69]=de,t[70]=B.close,t[71]=ue,t[72]=X):X=t[72];let Z;t[73]!==W||t[74]!==G||t[75]!==Y||t[76]!==X?(Z=(0,F.jsx)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:(0,F.jsxs)(`div`,{className:`ml-auto flex shrink-0 items-center gap-1.5`,children:[W,G,Y,X]})}),t[73]=W,t[74]=G,t[75]=Y,t[76]=X,t[77]=Z):Z=t[77];let Q;t[78]===s?Q=t[79]:(Q=s?(0,F.jsx)(`div`,{className:`mt-1.5 flex min-h-4 min-w-0 items-center gap-2 px-3 text-xs leading-4 text-fg-muted`,children:s}):null,t[78]=s,t[79]=Q);let $;t[80]!==c||t[81]!==ze||t[82]!==z.chat||t[83]!==Me||t[84]!==D?($=ze||D?(0,F.jsxs)(`div`,{className:`mt-2 flex items-center gap-2 overflow-x-auto pb-0.5`,children:[D?(0,F.jsx)(ve,{className:`mr-2 flex shrink-0 rounded-lg bg-surface-hover p-0.5`,role:`group`,"aria-label":z.chat.attachmentPreviewText,children:[{active:!1,label:Me},{active:!0,label:z.chat.attachmentPreviewText}].map(e=>(0,F.jsx)(`button`,{type:`button`,"aria-pressed":D.active===e.active,className:v(`rounded-md px-2.5 py-1 text-xs font-medium`,D.active===e.active?`bg-surface-hover text-fg`:`text-fg-muted hover:text-fg`),onClick:()=>D.onChange(e.active),children:e.label},e.label))}):null,ze?(0,F.jsx)(pe,{controller:c}):null]}):null,t[80]=c,t[81]=ze,t[82]=z.chat,t[83]=Me,t[84]=D,t[85]=$):$=t[85];let qe;return t[86]!==Z||t[87]!==Q||t[88]!==$?(qe=(0,F.jsxs)(`div`,{"data-workspace-toolbar":!0,className:Ue,children:[Z,Q,$]}),t[86]=Z,t[87]=Q,t[88]=$,t[89]=qe):qe=t[89],qe}function Oe(e){return!e}function ke(e){return[`zoom`,`search`,`rotate`,`pageNavigation`].includes(e)}function Ae(e){return e.language}function je({header:e,chat:t,...n}){let r=(0,O.useRef)(null);(0,O.useEffect)(()=>{let e=r.current;if(!e)return;let t=()=>{let t=fe(n.descriptor.id).scroll;e.querySelectorAll(`[class*="overflow-auto"], [class*="overflow-y-auto"], .cm-scroller`).forEach((e,n)=>{t[n]!=null&&(e.scrollTop=t[n])})},i=requestAnimationFrame(t),a=typeof MutationObserver<`u`?new MutationObserver(t):null;a?.observe(e,{childList:!0,subtree:!0});let o=()=>_(n.descriptor.id,{scroll:[...e.querySelectorAll(`[class*="overflow-auto"], [class*="overflow-y-auto"], .cm-scroller`)].map(e=>e.scrollTop)});return e.addEventListener(`scroll`,o,!0),()=>{cancelAnimationFrame(i),a?.disconnect(),e.removeEventListener(`scroll`,o,!0)}},[n.descriptor.id]);let a=(0,O.useContext)(j),[s,c]=(0,O.useState)(!1),l=de(n.descriptor),u=i(),d=o(n.language),[f,p]=(0,O.useState)(!1),ee=async()=>{if(!(!t||f)){p(!0);try{let[n,r]=await Promise.all([t.createFile(),t.conversationId?y(t.conversationId).catch(()=>null):Promise.resolve(null)]);if(n.size>33554432){S(`warning`,d.chat.attachmentFileTooLarge,{name:n.name,maxSize:b(x)});return}let i=new URLSearchParams({attachmentHandoff:le(n)}),a=t.projectId?.trim()||r?.projectId?.trim(),o=t.agentId?.trim()||r?.routing?.agentId?.trim();a&&i.set(`projectId`,a),u({pathname:`/chat/new`,search:`?${i}`},{state:{forceNewChat:!0,agentId:o||void 0}}),e.onClose()}catch{S(`error`,d.workspace.editInNewChatFailed)}finally{p(!1)}}};return(0,F.jsxs)(`div`,{ref:r,className:`flex h-full min-h-0 min-w-0 flex-1 flex-col overflow-hidden bg-transparent`,children:[(0,F.jsx)(R,{...e,name:n.descriptor.fileName,filePath:n.descriptor.source.kind===`workspace`?n.descriptor.source.path:void 0,controller:l,actions:n.actions,referenceActions:t?a.map(e=>({label:e.label,disabled:s||n.loading||!!n.loadError||t.disabled,onClick:async()=>{if(!s){c(!0);try{let r=await t.createFile(),i=await N(e.id,r);S(i?`success`:`warning`,n.language===`zh`?i?`已添加到目标聊天草稿`:`未能添加附件,请确认目标聊天可用及附件限制`:i?`Added to the target chat draft`:`Could not add attachment. Check the target chat and attachment limits.`)}catch{S(`error`,n.language===`zh`?`文件引用失败,原草稿已保留`:`Could not reference file. Your draft is retained.`)}finally{c(!1)}}}})):void 0,editInNewChat:t?{onClick:()=>void ee(),loading:f,disabled:n.loading||!!n.loadError||t.disabled}:void 0},n.descriptor.id),(0,F.jsx)(ue,{...n,controller:l})]})}function z(e,t){let n=(0,P.c)(7),r=e===void 0||e,i=t!==void 0&&t,[a,o]=(0,O.useState)(!1);!r&&a&&o(!1);let s,c;n[0]!==r||n[1]!==i||n[2]!==a?(s=()=>{if(!r||!a)return;let e=document.body.style.overflow;document.body.style.overflow=`hidden`;let t=e=>{i||e.key!==`Escape`||e.defaultPrevented||document.querySelector(`[data-file-preview-menu]`)||(e.preventDefault(),e.stopImmediatePropagation(),o(!1))};return window.addEventListener(`keydown`,t,!0),()=>{document.body.style.overflow=e,window.removeEventListener(`keydown`,t,!0)}},c=[r,a,i],n[0]=r,n[1]=i,n[2]=a,n[3]=s,n[4]=c):(s=n[3],c=n[4]),(0,O.useEffect)(s,c);let l;return n[5]===a?l=n[6]:(l={expanded:a,setExpanded:o},n[5]=a,n[6]=l),l}export{k as a,Ce as c,j as i,Se as l,je as n,we as o,Te as r,A as s,z as t};
@@ -0,0 +1 @@
1
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n}from"./vendor-react-BOUWij0V.js";import{i as r,l as i,o as a}from"./locale-store-Cit_aHqC.js";import{i as o}from"./vendor-swr-CdRzEUwF.js";var s=n(),c=e(t(),1);function l(e){let t=(0,s.c)(13),n=e===void 0||e,r=i(d),a;t[0]!==r||t[1]!==n?(a=n&&r?[`personal-agent-nav`,r]:null,t[0]=r,t[1]=n,t[2]=a):a=t[2];let l;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(l={revalidateOnFocus:!1},t[3]=l):l=t[3];let{data:f,mutate:p}=o(a,u,l),m,h;t[4]!==n||t[5]!==p?(m=()=>{if(!n)return;let e=e=>{let t=e.detail;t===void 0?p():p({ok:!0,payload:t},{revalidate:!1})};return window.addEventListener(`personal-agent-updated`,e),()=>window.removeEventListener(`personal-agent-updated`,e)},h=[n,p],t[4]=n,t[5]=p,t[6]=m,t[7]=h):(m=t[6],h=t[7]),(0,c.useEffect)(m,h);let g=f?.payload,_;t[8]===f?.payload?.displayName?_=t[9]:(_=f?.payload?.displayName?.trim()||`Ada`,t[8]=f?.payload?.displayName,t[9]=_);let v;return t[10]!==g||t[11]!==_?(v={profile:g,displayName:_},t[10]=g,t[11]=_,t[12]=v):v=t[12],v}function u(){return a(r(`/api/personal-agent`))}function d(e){return e.conversationId}export{l as t};
@@ -0,0 +1 @@
1
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n}from"./vendor-react-BOUWij0V.js";import{i as r,l as i,o as a}from"./locale-store-Cit_aHqC.js";import{t as o}from"./createLucideIcon-DPHK1VkS.js";import{L as s}from"./chat-page-DfFXhDRv.js";import{i as c,t as l}from"./vendor-swr-CdRzEUwF.js";import{c as u}from"./composer-payload-handoff-CRCz17sd.js";var d=o(`phone`,[[`path`,{d:`M13.832 16.568a1 1 0 0 0 1.213-.303l.355-.465A2 2 0 0 1 17 15h3a2 2 0 0 1 2 2v3a2 2 0 0 1-2 2A18 18 0 0 1 2 4a2 2 0 0 1 2-2h3a2 2 0 0 1 2 2v3a2 2 0 0 1-.8 1.6l-.468.351a1 1 0 0 0-.292 1.233 14 14 0 0 0 6.392 6.384`,key:`9njp5v`}]]),f=n(),p=e(t(),1),m=10;function h(e){return r(`/api/personal-agent/activity?view=work&limit=${m}&offset=${e}`)}async function g([e]){return(await a(e)).payload}function _(e){let t=(0,f.c)(3),n=i(v),r;return t[0]!==e||t[1]!==n?(r=e?[h(0),e,n]:null,t[0]=e,t[1]=n,t[2]=r):r=t[2],c(r,g)}function v(e){return e.conversationId}function y(e,t,n){let r=(0,f.c)(36),a=i(S),[o,s]=(0,p.useState)(!1),c=t?.total??0,u;r[0]!==a||r[1]!==e||r[2]!==o||r[3]!==c?(u=(t,n)=>{let r=(t+1)*m;return!o||r>=c||n&&n.items.length<m?null:[h(r),e,a]},r[0]=a,r[1]=e,r[2]=o,r[3]=c,r[4]=u):u=r[4];let d;r[5]===Symbol.for(`react.memo_cache_sentinel`)?(d={revalidateFirstPage:!1,shouldRetryOnError:!1},r[5]=d):d=r[5];let{data:_,error:v,isValidating:y,size:C,setSize:w,mutate:T}=l(u,g,d),E;r[6]!==t?.items||r[7]!==c?(E=JSON.stringify([c,t?.items.map(x)]),r[6]=t?.items,r[7]=c,r[8]=E):E=r[8];let D=E,O=(0,p.useRef)(D),k,A;r[9]!==D||r[10]!==T||r[11]!==o?(k=()=>{let e=O.current!==D;O.current=D,e&&o&&T()},A=[D,T,o],r[9]=D,r[10]=T,r[11]=o,r[12]=k,r[13]=A):(k=r[12],A=r[13]),(0,p.useEffect)(k,A);let j=_?.length??0,M;r[14]!==_||r[15]!==j||r[16]!==c?(M=(j+1)*m<c&&(j===0||_?.at(-1)?.items.length===m),r[14]=_,r[15]=j,r[16]=c,r[17]=M):M=r[17];let N=M,P=o&&!v&&N&&(y||C>j),F;r[18]!==w||r[19]!==C||r[20]!==o?(F=()=>{o?w(C+1):s(!0)},r[18]=w,r[19]=C,r[20]=o,r[21]=F):F=r[21];let I=F,L;r[22]===t?.items?L=r[23]:(L=t?.items??[],r[22]=t?.items,r[23]=L);let R;r[24]!==_||r[25]!==L?(R=[...L,...(_??[]).flatMap(b)],r[24]=_,r[25]=L,r[26]=R):R=r[26];let z=n?v:void 0,B=n&&N,V=n&&P,H;r[27]===T?H=r[28]:(H=()=>void T(),r[27]=T,r[28]=H);let U;return r[29]!==I||r[30]!==B||r[31]!==V||r[32]!==H||r[33]!==R||r[34]!==z?(U={items:R,error:z,hasMore:B,loading:V,loadMore:I,retry:H},r[29]=I,r[30]=B,r[31]=V,r[32]=H,r[33]=R,r[34]=z,r[35]=U):U=r[35],U}function b(e){return e.items}function x(e){return e.id}function S(e){return e.conversationId}function C(e){let t=(0,f.c)(6),n=i(T),a=`/api/sessions/${encodeURIComponent(e??``)}/clarification`,o;t[0]===a?o=t[1]:(o=r(a),t[0]=a,t[1]=o);let s=o,l;return t[2]!==e||t[3]!==n||t[4]!==s?(l=e?[s,e,n]:null,t[2]=e,t[3]=n,t[4]=s,t[5]=l):l=t[5],c(l,w)}async function w(e){let[t]=e;return(await a(t)).payload?.clarification??null}function T(e){return e.conversationId}function E(e){return!!e.attention||e.presentation.status===`needsUser`||e.presentation.status===`review`}function D(e,t,n){let r=(0,f.c)(5),i,a;r[0]!==e||r[1]!==n||r[2]!==t?(i=()=>{if(!e)return;let r,i=()=>{window.clearTimeout(r),r=window.setTimeout(()=>{Promise.allSettled([t(),n?.()])},120)},a=[`task-changed-v2`,`task-updated`,`clarification-updated`,`gateway-realtime-connected`],o=t=>{t.detail?.key===e&&i()};a.forEach(e=>window.addEventListener(e,i)),window.addEventListener(`session-transcript-updated`,o);let s=window.setInterval(()=>{document.visibilityState===`visible`&&i()},15e3);return()=>{window.clearTimeout(r),window.clearInterval(s),a.forEach(e=>window.removeEventListener(e,i)),window.removeEventListener(`session-transcript-updated`,o)}},a=[e,t,n],r[0]=e,r[1]=n,r[2]=t,r[3]=i,r[4]=a):(i=r[3],a=r[4]),(0,p.useEffect)(i,a)}function O(e,t){let n=(0,f.c)(5),r=(0,p.useRef)(null),i=(0,p.useRef)(null),a,o;n[0]!==e||n[1]!==t?(a=()=>{let n=r.current,a=i.current;if(!e||!n||!a||typeof IntersectionObserver>`u`)return;let o=new IntersectionObserver(e=>{e.some(k)&&t()},{root:n,rootMargin:`0px 0px 120px`});return o.observe(a),()=>o.disconnect()},o=[e,t],n[0]=e,n[1]=t,n[2]=a,n[3]=o):(a=n[2],o=n[3]),(0,p.useEffect)(a,o);let s;return n[4]===Symbol.for(`react.memo_cache_sentinel`)?(s={listRef:r,loadMoreRef:i},n[4]=s):s=n[4],s}function k(e){return e.isIntersecting}function A(e){return e?.status===`open`&&(e.expiresAt===void 0||e.expiresAt>Date.now())}function j(e,t){let{status:n}=e.presentation,r=n===`failed`?`bg-danger`:[`needsUser`,`review`,`waiting`,`blocked`,`paused`].includes(n)?`bg-warning`:[`running`,`verifying`,`completed`].includes(n)?`bg-accent`:`bg-fg-subtle`;return[u(t?`zh`:`en`).detailStatuses[n],r]}function M(e,t){let n=(0,f.c)(26),r;n[0]===e?r=n[1]:(r=t=>e?t.runs[e]:void 0,n[0]=e,n[1]=r);let i=s(r),{data:a,mutate:o,error:c}=_(e),{data:l,mutate:u,error:d}=C(e),m,h,g,v;if(n[2]!==l||n[3]!==a?.current){m=a?.current??[];let e=m.filter(E);v=e.length,h=Number,g=A(l)&&!e.some(e=>e.prompt?.id===l.id),n[2]=l,n[3]=a?.current,n[4]=m,n[5]=h,n[6]=g,n[7]=v}else m=n[4],h=n[5],g=n[6],v=n[7];let y=v+h(g),b;n[8]===m?b=n[9]:(b=m.filter(F),n[8]=m,n[9]=b);let x=b,S;n[10]===m?S=n[11]:(S=m.filter(P),n[10]=m,n[11]=S);let w=S,T;n[12]===a?.items?T=n[13]:(T=a?.items.find(N)?.updatedAt,n[12]=a?.items,n[13]=T);let D=T,[O,k]=(0,p.useState)(),j,M;n[14]===D?(j=n[15],M=n[16]):(j=()=>{if(D===void 0)return;let e=D+4e3-Date.now();if(e<=0)return;k(D);let t=window.setTimeout(()=>k(void 0),e);return()=>window.clearTimeout(t)},M=[D],n[14]=D,n[15]=j,n[16]=M),(0,p.useEffect)(j,M);let I=O!==void 0&&O===D,L=y?`waiting`:x.length||w.length||i?.status===`running`?`working`:i?.status===`waiting`?`waiting`:I?`delivered`:`idle`,R=``;y?R=t?`有 ${y} 项待你处理`:`${y} to review`:x.length>1?R=t?`有 ${x.length} 项正在推进`:`${x.length} in progress`:x[0]?R=t?`正在推进 · ${x[0].title}`:`Working · ${x[0].title}`:i?.status===`running`?R=t?`正在回复`:`Responding`:w.length?R=t?`有 ${w.length} 项等待开始`:`${w.length} queued`:i?.status===`waiting`?R=t?`等待继续`:`Waiting to resume`:I?R=t?`刚刚完成交付`:`Just delivered`:(c||d)&&(R=t?`暂时无法更新状态`:`Status unavailable`);let z;return n[17]!==y||n[18]!==L||n[19]!==l||n[20]!==u||n[21]!==o||n[22]!==R||n[23]!==a||n[24]!==c?(z={work:a,workError:c,prompt:l,avatarState:L,summary:R,attentionCount:y,refreshWork:o,refreshPrompt:u},n[17]=y,n[18]=L,n[19]=l,n[20]=u,n[21]=o,n[22]=R,n[23]=a,n[24]=c,n[25]=z):z=n[25],z}function N(e){return e.resolution===`done`}function P(e){return e.operationalState===`queued`||e.operationalState===`allocating`}function F(e){return e.operationalState===`running`||e.operationalState===`verifying`}export{y as a,d as c,O as i,E as n,M as o,j as r,D as s,A as t};
@@ -1 +1 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t}from"./vendor-react-BOUWij0V.js";import{i as n,o as r,p as i,r as a}from"./locale-store-DIBIYLnI.js";import{a as o,r as s}from"./voice-CDlC6XMH.js";import{t as c}from"./session-manager-D5g6LOU-.js";import{t as l}from"./middleware-Pd0e8Igk.js";import{t as u}from"./composer-notifications-nT-U6jcc.js";var d=e(t(),1),ee=i()(l(e=>({captions:!0,microphoneId:``,setCaptions:t=>e({captions:t}),setMicrophoneId:t=>e({microphoneId:t})}),{name:`xopc-voice-preferences`}));function te(){let e=ee.getState().microphoneId;return{echoCancellation:!0,noiseSuppression:!0,autoGainControl:!0,...e?{deviceId:{exact:e}}:{}}}function ne(e,t,n,r){return new Promise((i,a)=>{let o=!1,s=(e,n)=>{o||(o=!0,clearTimeout(l),t.removeEventListener(`abort`,c),e===void 0?i(n):a(e))},c=()=>s(t.reason??new DOMException(`Cancelled`,`AbortError`)),l=setTimeout(()=>s(new DOMException(`Voice startup timed out`,`TimeoutError`)),n);e.then(e=>{o?r?.(e):s(void 0,e)},e=>s(e)),t.addEventListener(`abort`,c,{once:!0}),t.aborted&&c()})}function re(e,t,n,r){let i=e.get(t);if(i&&(n<i.revision||i.final&&!r||n===i.revision&&(i.final||!r)))return!1;if(!e.has(t)&&e.size>=256){let t=e.keys().next().value;t!==void 0&&e.delete(t)}return e.set(t,{revision:n,final:r}),!0}var f=32,p=1481592883,ie=3,ae=1,oe=2,m=1,h=64*1024,g=new TextEncoder,_=new TextDecoder(`utf-8`,{fatal:!0});function se(e){let t=g.encode(e.id);if(!t.length||t.length>160||!Number.isInteger(e.connectionEpoch)||e.connectionEpoch<1||e.connectionEpoch>4294967295||!Number.isInteger(e.seq)||e.seq<1||e.seq>4294967295||!Number.isFinite(e.timestampMs)||e.timestampMs<0||e.durationMs!==20||e.flags<0||e.flags>3||!e.audio.length||e.audio.length%2||f+t.length+e.audio.length>h)throw Error(`Invalid voice media frame`);let n=new Uint8Array(f+t.length+e.audio.length),r=new DataView(n.buffer);return r.setUint32(0,p),r.setUint8(4,ie),r.setUint8(5,e.kind),r.setUint8(6,m),r.setUint8(7,e.flags),r.setUint32(8,e.connectionEpoch),r.setUint32(12,e.seq),r.setFloat64(16,e.timestampMs),r.setUint16(24,e.durationMs),r.setUint16(26,t.length),r.setUint32(28,e.audio.length),n.set(t,f),n.set(e.audio,f+t.length),n}function ce(e,t){if(e.length<=f||e.length>h)throw Error(`Invalid voice media frame`);let n=new DataView(e.buffer,e.byteOffset,e.byteLength),r=n.getUint8(5),i=n.getUint32(8),a=n.getUint32(12),o=n.getFloat64(16),s=n.getUint16(24),c=n.getUint16(26),l=n.getUint32(28),u=f+c,d=n.getUint8(7);if(n.getUint32(0)!==p||n.getUint8(4)!==ie||r!==t||n.getUint8(6)!==m||d>3||!i||!a||!Number.isFinite(o)||o<0||s!==20||!c||c>160||!l||l%2||u+l!==e.length)throw Error(`Invalid voice media header`);return{kind:r,connectionEpoch:i,id:_.decode(e.subarray(f,u)),seq:a,timestampMs:o,durationMs:s,flags:d,audio:e.slice(u)}}function le(e){let t=ce(e,oe);return{connectionEpoch:t.connectionEpoch,responseId:t.id,seq:t.seq,mediaTimestampMs:t.timestampMs,durationMs:t.durationMs,audio:t.audio}}function ue(e){return se({kind:ae,connectionEpoch:e.connectionEpoch,id:e.utteranceId,seq:e.audioSeq,timestampMs:e.capturedAtMonotonicMs,durationMs:e.durationMs,flags:!!e.start|(e.end?2:0),audio:e.audio})}var de=class{session;eventSeq=0;audioSeq=0;ready=!1;closed=!1;cancelled=new Set;constructor(e){this.session=e}event(e){if(this.closed)throw Error(`Voice session closed`);if(e.sessionId!==this.session.sessionId||e.seq!==this.eventSeq+1)throw Error(`Invalid voice event sequence`);if(this.eventSeq=e.seq,e.type===`session.ready`){if(this.ready||e.payload.connectionEpoch!==this.session.connectionEpoch||e.payload.purpose!==this.session.purpose||e.payload.inputMode!==this.session.inputMode||e.payload.inputFormat.sampleRate!==this.session.inputFormat.sampleRate||e.payload.mode!==this.session.mode||e.payload.route.engine!==this.session.route.engine)throw Error(`Voice session mismatch`);this.ready=!0}e.type===`response.cancelled`&&this.cancel(e.payload.responseId),e.type===`session.closed`&&(this.ready=!1,this.closed=!0)}audio(e){if(!this.ready||e.connectionEpoch!==this.session.connectionEpoch||e.seq!==this.audioSeq+1)throw Error(`Invalid voice audio sequence`);return this.audioSeq=e.seq,!this.cancelled.has(e.responseId)}cancel(e){if(!this.cancelled.has(e)){if(this.cancelled.size>=1e4)throw Error(`Voice response limit exceeded`);this.cancelled.add(e)}}};function v(e,t){return{protocolVersion:3,messageId:crypto.randomUUID(),type:e,sentAt:Date.now(),payload:t}}function y(e){let t=new URL(n(e));return t.protocol=t.protocol===`https:`?`wss:`:`ws:`,t.toString()}var fe=class e{socket;session;timingMetrics;receive;heartbeatId;inputRemainder=new Uint8Array;utteranceId=crypto.randomUUID();inputSeq=0;constructor(e,t,n=[]){this.socket=e,this.session=t,this.timingMetrics=n,this.receive=new de(t)}static async preflight(e){return e.purpose===`conversation`&&e.conversationId&&await new c().materialize(e.conversationId,`voice`),(await r(n(`/api/voice/realtime/preflight`),{method:`POST`,signal:e.signal,body:JSON.stringify({purpose:e.purpose,mode:e.mode,naturalBackend:e.naturalBackend,testHiggsVoice:e.testHiggsVoice,conversationId:e.conversationId,supportedProtocolVersions:[3],mediaPreferences:[`websocket-pcm`]})})).timingMetrics??[]}static async connect(t){t.signal?.throwIfAborted();let i=await r(n(`/api/voice/realtime/sessions`),{method:`POST`,signal:t.signal,body:JSON.stringify({purpose:t.purpose,...t.language?{language:t.language}:{},...t.purpose===`conversation`&&t.mode!==`natural`&&t.logicalCallId?{openingGreeting:{logicalCallId:t.logicalCallId,initiation:t.recovery?`recovery`:`user`,supportsOutputReady:!0}}:{},...t.mode?{mode:t.mode}:{},...t.naturalBackend?{naturalBackend:t.naturalBackend}:{},...t.testHiggsVoice?{testHiggsVoice:t.testHiggsVoice}:{},...t.conversationId?{conversationId:t.conversationId}:{},supportedProtocolVersions:[3],mediaPreferences:[`websocket-pcm`]})}),a=s.parse(i.payload);t.signal?.throwIfAborted();let c=new WebSocket(y(a.websocketPath));c.binaryType=`arraybuffer`;let l=new e(c,a,t.timingMetrics);return await new Promise((e,n)=>{let r=!1,i,s=e=>{r||(r=!0,i!==void 0&&window.clearTimeout(i),c.close(),n(e))};i=window.setTimeout(()=>s(Error(`Realtime voice connection timed out`)),15e3);let u=()=>{r?c.close():s(Error(`Realtime voice connection cancelled`))};if(t.signal?.addEventListener(`abort`,u,{once:!0}),c.addEventListener(`close`,()=>t.signal?.removeEventListener(`abort`,u),{once:!0}),t.signal?.aborted){u();return}c.onerror=()=>s(Error(`Realtime voice connection failed`)),c.onclose=e=>{r?t.onClose?.(e.reason):s(Error(e.reason||`Realtime voice connection closed`))},c.onopen=()=>{c.send(JSON.stringify(v(`session.start`,{sessionId:a.sessionId,ticket:a.ticket})))},c.onmessage=n=>{if(typeof n.data!=`string`){try{let e=le(new Uint8Array(n.data));l.receive.audio(e)&&t.onAudio?.(e.audio.slice().buffer,e.responseId)}catch{c.close(4400,`Invalid voice audio frame`)}return}try{let c=o(JSON.parse(n.data));if(l.receive.event(c),t.onEvent(c),c.type===`session.ready`&&!r){if(c.payload.connectionEpoch!==a.connectionEpoch||c.payload.mode!==a.mode)throw Error(`Voice session mismatch`);r=!0,window.clearTimeout(i),l.startHeartbeat(c.payload.heartbeatIntervalMs),e()}else c.type===`session.error`&&!c.payload.recoverable&&s(Error(c.payload.message))}catch(e){r?c.close(4400,`Invalid voice protocol frame`):s(e instanceof Error?e:Error(String(e)))}}}),l}outputReady(){this.session.openingGreeting?.accepted&&this.sendControl(`session.output_ready`,{connectionEpoch:this.session.connectionEpoch})}sendAudio(e){if(!e.byteLength||this.socket.readyState!==WebSocket.OPEN)return;let t=new Uint8Array(e),n=new Uint8Array(this.inputRemainder.byteLength+t.byteLength);n.set(this.inputRemainder),n.set(t,this.inputRemainder.byteLength);let r=0;for(;r+640<=n.byteLength;){let e=ue({connectionEpoch:this.session.connectionEpoch,utteranceId:this.utteranceId,audioSeq:++this.inputSeq,capturedAtMonotonicMs:performance.now(),durationMs:20,...this.inputSeq===1?{start:!0}:{},audio:n.slice(r,r+640)});this.socket.send(e.buffer),r+=640}this.inputRemainder=n.slice(r)}reportMetric(e,t,n){t===`speech_end_to_audio_scheduled`&&!this.timingMetrics.includes(t)||this.sendControl(`session.metric`,{responseId:e,metric:t,durationMs:Math.min(6e5,Math.max(0,n))})}setInputMuted(e){this.sendControl(`input.mute`,{muted:e}),this.inputRemainder=new Uint8Array,e||(this.utteranceId=crypto.randomUUID(),this.inputSeq=0)}commit(){this.sendControl(`input.commit`,{})}cancelResponse(e){this.sendControl(`response.stop_playback`,{responseId:e})}cancelTask(e){this.sendControl(`task.cancel`,{taskId:e})}acknowledgeAudio(e,t){this.sendControl(`response.audio.played`,{responseId:e,playedDurationMs:Math.floor(t/48)})}stop(e=`user_finished`){this.stopHeartbeat(),this.socket.readyState===WebSocket.OPEN?this.sendControl(`session.stop`,{reason:e}):this.socket.close()}sendControl(e,t){this.socket.readyState===WebSocket.OPEN&&(e===`response.stop_playback`&&`responseId`in t&&this.receive.cancel(t.responseId),this.socket.send(JSON.stringify(v(e,t))))}startHeartbeat(e){this.stopHeartbeat(),this.heartbeatId=window.setInterval(()=>this.sendControl(`session.ping`,{}),e),this.socket.addEventListener(`close`,()=>this.stopHeartbeat(),{once:!0})}stopHeartbeat(){this.heartbeatId!==void 0&&(window.clearInterval(this.heartbeatId),this.heartbeatId=void 0)}},b=1.7,pe=class{context=new AudioContext({sampleRate:24e3,latencyHint:`interactive`});output=this.context.createGain();ringbackOutput=this.context.createGain();limiter=this.context.createDynamicsCompressor();sources=new Set;ringbackSources=new Map;ringbackDelay=null;ringbackInterval=null;ringbackActive=!1;nextStartTime=0;hasStartedAudio=!1;confirmedSpeech=!1;tentativeDuckTimer;constructor(){this.output.gain.value=b,this.limiter.threshold.value=-6,this.limiter.knee.value=6,this.limiter.ratio.value=12,this.limiter.attack.value=.003,this.limiter.release.value=.12,this.output.connect(this.limiter),this.limiter.connect(this.context.destination),this.ringbackOutput.gain.value=0,this.ringbackOutput.connect(this.context.destination)}async start(){await this.context.resume()}get hasPendingAudio(){return this.sources.size>0}startRingback(){this.stopRingback(),this.context.state!==`closed`&&(this.ringbackActive=!0,this.ringbackDelay=setTimeout(()=>{this.ringbackDelay=null,!(!this.ringbackActive||this.context.state!==`running`)&&(this.ringbackOutput.gain.cancelScheduledValues(this.context.currentTime),this.ringbackOutput.gain.setValueAtTime(.14,this.context.currentTime),this.playRingbackPulse(),this.ringbackInterval=setInterval(()=>this.playRingbackPulse(),3e3))},500))}playRingbackPulse(){if(!this.ringbackActive||this.context.state!==`running`)return;let e=this.context.currentTime;for(let[t,n]of[392,494].entries()){let r=e+t*.4,i=this.context.createOscillator(),a=this.context.createGain();i.type=`sine`,i.frequency.value=n,a.gain.setValueAtTime(0,r),a.gain.linearRampToValueAtTime(.5,r+.04),a.gain.setValueAtTime(.5,r+.18),a.gain.linearRampToValueAtTime(0,r+.28),i.connect(a),a.connect(this.ringbackOutput),this.ringbackSources.set(i,a),i.onended=()=>{this.ringbackSources.delete(i),i.disconnect(),a.disconnect()},i.start(r),i.stop(r+.29)}}stopRingback(){if(this.ringbackActive=!1,this.ringbackDelay!==null&&clearTimeout(this.ringbackDelay),this.ringbackInterval!==null&&clearInterval(this.ringbackInterval),this.ringbackDelay=null,this.ringbackInterval=null,this.context.state!==`closed`){this.ringbackOutput.gain.cancelScheduledValues(this.context.currentTime),this.ringbackOutput.gain.setTargetAtTime(0,this.context.currentTime,.025);for(let[e,t]of this.ringbackSources){t.gain.cancelScheduledValues(this.context.currentTime),t.gain.setTargetAtTime(0,this.context.currentTime,.02);try{e.stop(this.context.currentTime+.12)}catch{}}}}enqueue(e,t,n=24e3){if(e.byteLength<2||this.context.state===`closed`)return;let r=new DataView(e),i=new Float32Array(Math.floor(e.byteLength/2));for(let e=0;e<i.length;e+=1)i[e]=r.getInt16(e*2,!0)/32768;let a=this.context.createBuffer(1,i.length,n);a.copyToChannel(i,0);let o=this.context.createBufferSource();o.buffer=a,o.connect(this.output);let s=this.hasStartedAudio?.015:.02,c=Math.max(this.context.currentTime+s,this.nextStartTime);return o.start(c),this.hasStartedAudio=!0,this.nextStartTime=c+a.duration,this.sources.add(o),o.onended=()=>{this.sources.delete(o)&&(o.disconnect(),t())},Math.max(0,c-this.context.currentTime)*1e3}duck(e){clearTimeout(this.tentativeDuckTimer),this.tentativeDuckTimer=void 0,this.confirmedSpeech=e,this.setOutputGain(e?.15:1)}duckForVoiceOnset(){this.confirmedSpeech||this.tentativeDuckTimer!==void 0||!this.hasPendingAudio||(this.setOutputGain(.55),this.tentativeDuckTimer=setTimeout(()=>{this.tentativeDuckTimer=void 0,this.setOutputGain(1)},280))}setOutputGain(e){this.context.state!==`closed`&&(this.output.gain.cancelScheduledValues(this.context.currentTime),this.output.gain.setTargetAtTime(b*e,this.context.currentTime,.015))}clear(){for(let e of this.sources){e.onended=null;try{e.stop()}catch{}e.disconnect()}this.sources.clear(),this.nextStartTime=this.context.currentTime,this.hasStartedAudio=!1,this.duck(!1)}async close(){this.stopRingback(),this.clear(),this.output.disconnect(),this.ringbackOutput.disconnect(),this.limiter.disconnect(),this.context.state!==`closed`&&await this.context.close();for(let[e,t]of this.ringbackSources)e.onended=null,e.disconnect(),t.disconnect();this.ringbackSources.clear()}},x=`/assets/pcm-capture-worklet-CpXsv44v.js`,S=16e3;function C(e){if(e.length===0)return 0;let t=0;for(let n=0;n<e.length;n+=1)t+=e[n]*e[n];return Math.min(1,Math.sqrt(t/e.length))}function w(e){let t=e.reduce((e,t)=>e+t.length,0),n=new Float32Array(t),r=0;for(let t of e)n.set(t,r),r+=t.length;return n}function me(e,t,n=S){if(t===n)return e;let r=Math.max(1,Math.round(e.length*n/t)),i=new Float32Array(r),a=t/n;for(let t=0;t<r;t+=1){let n=t*a,r=Math.min(e.length-1,Math.floor(n)),o=Math.min(e.length-1,r+1),s=n-r;i[t]=e[r]*(1-s)+e[o]*s}return i}function he(e,t=S){let n=new ArrayBuffer(44+e.length*2),r=new DataView(n),i=(e,t)=>{for(let n=0;n<t.length;n+=1)r.setUint8(e+n,t.charCodeAt(n))};i(0,`RIFF`),r.setUint32(4,36+e.length*2,!0),i(8,`WAVE`),i(12,`fmt `),r.setUint32(16,16,!0),r.setUint16(20,1,!0),r.setUint16(22,1,!0),r.setUint32(24,t,!0),r.setUint32(28,t*2,!0),r.setUint16(32,2,!0),r.setUint16(34,16,!0),i(36,`data`),r.setUint32(40,e.length*2,!0);for(let t=0;t<e.length;t+=1){let n=Math.max(-1,Math.min(1,e[t]));r.setInt16(44+t*2,n<0?n*32768:n*32767,!0)}return n}function T(e){let t=new ArrayBuffer(e.length*2),n=new DataView(t);for(let t=0;t<e.length;t+=1){let r=Math.max(-1,Math.min(1,e[t]));n.setInt16(t*2,r<0?r*32768:r*32767,!0)}return t}var ge=class{sourceRate;targetRate;pending=new Float32Array;position=0;constructor(e,t=S){if(this.sourceRate=e,this.targetRate=t,e<=0||t<=0)throw Error(`PCM sample rates must be positive`)}push(e){if(e.length===0)return new ArrayBuffer(0);let t=new Float32Array(this.pending.length+e.length);t.set(this.pending),t.set(e,this.pending.length);let n=this.sourceRate/this.targetRate,r=[];for(;this.position+1<t.length;){let e=Math.floor(this.position),i=this.position-e;r.push(t[e]*(1-i)+t[e+1]*i),this.position+=n}let i=Math.min(t.length-1,Math.floor(this.position));return this.pending=t.slice(i),this.position-=i,T(Float32Array.from(r))}flush(){if(this.pending.length===0)return new ArrayBuffer(0);let e=this.pending[Math.min(this.pending.length-1,Math.floor(this.position))];return this.pending=new Float32Array,this.position=0,T(Float32Array.of(e))}},_e=`xopc-pcm-capture`,E=1e3,D=1e4,ve=class e{context;source;node;mutedOutput;options;sampleRate;paused=!1;accepting=!0;processorFailed=!1;stopPromise;flushResolve;constructor(e,t,n,r,i){this.context=e,this.source=t,this.node=n,this.mutedOutput=r,this.options=i,this.sampleRate=e.sampleRate,this.node.port.onmessage=e=>{if(e.data.type===`flushed`){this.flushResolve?.();return}if(!this.accepting||this.paused)return;let t=new Float32Array(e.data.buffer);if(this.options.onSamples(t),this.options.onAudioLevel){let e=C(t);this.options.onAudioLevel({level:e,speaking:e>=(this.options.speechThreshold??.015)})}},this.node.onprocessorerror=()=>{this.processorFailed=!0,this.flushResolve?.()}}static async start(t,n){if(typeof AudioWorkletNode>`u`)throw Error(`PCM audio recording is not supported in this browser`);let r=new AudioContext,i,a,o=new Promise((e,t)=>{a=setTimeout(()=>{t(new DOMException(`PCM audio capture startup timed out`,`TimeoutError`))},D)});try{await Promise.race([r.audioWorklet.addModule(x),o]);let a=r.createMediaStreamSource(t),s=n.frameDurationMs===void 0?void 0:Math.round(r.sampleRate*n.frameDurationMs/1e3),c=new AudioWorkletNode(r,_e,{processorOptions:{frameSamples:s}}),l=r.createGain();return l.gain.value=0,i=new e(r,a,c,l,n),a.connect(c),c.connect(l),l.connect(r.destination),await Promise.race([r.resume(),o]),i}catch(e){throw i?i.cancel():r.close().catch(()=>void 0),e}finally{clearTimeout(a)}}pause(){this.paused=!0}resume(){this.paused=!1}stop(){return this.stopPromise??=this.finish(),this.stopPromise}cancel(){this.accepting&&(this.accepting=!1,this.flushResolve?.(),this.flushResolve=void 0,this.disconnect(),this.context.close().catch(()=>void 0))}async finish(){this.accepting&&(this.processorFailed||await this.flushWorklet(),this.flushResolve=void 0,this.accepting&&(this.accepting=!1,this.disconnect(),await this.context.close().catch(()=>void 0)))}flushWorklet(){return new Promise(e=>{let t=!1,n=()=>{t||(t=!0,globalThis.clearTimeout(r),e())},r=globalThis.setTimeout(n,E);this.flushResolve=n;try{this.node.port.postMessage(`flush`)}catch{n()}})}disconnect(){this.node.port.onmessage=null,this.node.onprocessorerror=null,this.source.disconnect(),this.node.disconnect(),this.mutedOutput.disconnect()}},ye=class e{capture;chunks;stopped=!1;constructor(e,t){this.capture=e,this.chunks=t}static async start(t,n={}){let r=[],i=await ve.start(t,{...n,onSamples:e=>r.push(e)});return new e(i,r)}async stop(){if(this.stopped)return new Blob([],{type:`audio/wav`});this.stopped=!0,await this.capture.stop();let e=me(w(this.chunks),this.capture.sampleRate);return new Blob([he(e)],{type:`audio/wav`})}cancel(){this.stopped||(this.stopped=!0,this.capture.cancel(),this.chunks.length=0)}};function O(e){return e.includes(`ogg`)?`ogg`:e.includes(`mp4`)||e.includes(`m4a`)?`m4a`:e.includes(`mpeg`)||e.includes(`mp3`)?`mp3`:e.includes(`wav`)?`wav`:`webm`}async function k(e,t,i,a){let o=e.type||t||`audio/webm`,s=e.type?e:new Blob([e],{type:o}),c=new FormData;c.append(`audio`,s,`recording.${O(o)}`),a&&c.append(`expectedProvider`,a);let l=await r(n(`/api/voice/transcriptions`),{method:`POST`,body:c,...i?{signal:i}:{}});if(!l.payload)throw Error(`Missing transcription payload`);return l.payload}async function be(e){let t=await r(n(`/api/status`),{signal:e});if(!t.voice?.dictation)throw Error(`Missing dictation status`);return t.voice.dictation}function A(){}typeof window<`u`&&(window.addEventListener(`voice-config-changed`,A),window.addEventListener(`config-reload`,A));var j=null;function xe(e){return j&&j!==e?!1:(j=e,!0)}function M(e){j===e&&(j=null)}function Se(e){if(!(e instanceof Error))return!1;let t=e.body,n=typeof t?.error==`object`?t.error.code:void 0;return n===`VOICE_DISABLED`||n===`PROVIDER_UNAVAILABLE`}function Ce(e){if(!Number.isFinite(e)||e<0)return`0:00`;let t=Math.floor(e%60);return`${Math.floor(e/60)}:${t.toString().padStart(2,`0`)}`}function we(e){return e===`requesting`||e===`connecting`||e===`starting`}async function Te(){if(!navigator.permissions?.query)return null;try{return(await navigator.permissions.query({name:`microphone`})).state}catch{return null}}function Ee(e){return e instanceof DOMException||e instanceof Error?e.name:``}function De(e,t){if(e===`permission`)return`permission`;if(e===`recorder`)return`recorder`;if(e===`session`)return`session`;let n=Ee(t);return n===`NotAllowedError`||n===`SecurityError`?`permission`:`device`}function Oe(e){let{disabled:t,chat:i,onTranscript:o}=e,[s,c]=(0,d.useState)(`idle`),[l,ee]=(0,d.useState)(!1),f=(0,d.useRef)(null),p=(0,d.useRef)(null),ie=(0,d.useRef)(void 0),[ae,oe]=(0,d.useState)(0),[m,h]=(0,d.useState)(0),[g,_]=(0,d.useState)(``),[se,ce]=(0,d.useState)(``),[le,ue]=(0,d.useState)(``),[de,v]=(0,d.useState)([]),[y,b]=(0,d.useState)(null),[x,S]=(0,d.useState)(`idle`),[C,w]=(0,d.useState)(null),[me,he]=(0,d.useState)(!1),T=(0,d.useRef)(!1),[_e,E]=(0,d.useState)(null),[D,O]=(0,d.useState)(null),[A,j]=(0,d.useState)(!1),[Oe,ke]=(0,d.useState)(null),N=(0,d.useRef)(void 0),P=(0,d.useRef)(null),[Ae,je]=(0,d.useState)(`dictation`),Me=(0,d.useRef)(Symbol(`voice-capture`)),F=(0,d.useRef)(`idle`),I=(0,d.useRef)(0),L=(0,d.useRef)(null),Ne=(0,d.useRef)(null),R=(0,d.useRef)(null),Pe=(0,d.useRef)(void 0),Fe=(0,d.useRef)(void 0),Ie=(0,d.useRef)(void 0),z=(0,d.useRef)(null),Le=(0,d.useRef)(null),Re=(0,d.useRef)(null),B=(0,d.useRef)(new Map),V=(0,d.useRef)(!1),ze=(0,d.useRef)(()=>{}),Be=(0,d.useRef)(new Map),H=(0,d.useRef)(null),U=(0,d.useRef)(new Set),[Ve,He]=(0,d.useState)([]),Ue=(0,d.useRef)(!1),W=(0,d.useRef)(null),We=(0,d.useRef)(!1),G=(0,d.useRef)(new Set),Ge=(0,d.useRef)(0),Ke=(0,d.useRef)(6e5),qe=(0,d.useRef)(null),K=(0,d.useRef)(null),Je=(0,d.useRef)(o);Je.current=o;let Ye=(0,d.useRef)(e.onTestAudioPlayed);Ye.current=e.onTestAudioPlayed;let q=(0,d.useCallback)(e=>{F.current=e,c(e)},[]),J=(0,d.useCallback)(()=>{qe.current!=null&&(clearInterval(qe.current),qe.current=null)},[]),Y=(0,d.useCallback)(()=>{Le.current?.getTracks().forEach(e=>e.stop()),Le.current=null},[]),X=(0,d.useCallback)(()=>{M(Me.current),I.current+=1,P.current?.abort(),P.current=null,J(),K.current!==null&&clearTimeout(K.current),K.current=null,z.current?.stopRingback(),Y(),f.current?.cancel(),f.current=null,p.current=null,ie.current=void 0,ee(!1),L.current?.cancel(),L.current=null,Ne.current=null,R.current=null;let e=z.current;z.current=null,e?.close(),Re.current=null,oe(0),h(0),_(``),ce(``),ue(``),S(`idle`),w(null),v([]),b(null),W.current=null,G.current.clear(),T.current=!1,he(!1),j(!1),Be.current.clear(),B.current.clear(),V.current=!1,H.current=null,U.current.clear(),He([])},[Y,J]),Z=(0,d.useCallback)(()=>{X(),q(`idle`)},[X,q]),Xe=(0,d.useCallback)(()=>{R.current?.stop(`user_finished`),Z(),E(null),O(null),ke(null)},[Z]),Q=(0,d.useCallback)(async e=>{if(V.current)return;V.current=!0;let t=I.current,a=e??[...B.current.values()].join(` `).trim();if(Y(),J(),L.current?.cancel(),L.current=null,q(`transcribing`),!a){u(`warning`,i.voiceTranscribeEmpty),Z();return}let o=a;try{let e=await r(n(`/api/voice/transcriptions/refine`),{method:`POST`,body:JSON.stringify({text:a}),signal:AbortSignal.any([P.current.signal,AbortSignal.timeout(15e3)])});e.payload.text.trim()&&(o=e.payload.text)}catch{if(t!==I.current)return;u(`warning`,i.voiceRefinementFailed)}t===I.current&&(Je.current(o),Z())},[Z,i.voiceRefinementFailed,i.voiceTranscribeEmpty,Y,J,q]),Ze=(0,d.useCallback)(async()=>{if(V.current)return;V.current=!0;let e=I.current;J(),q(`transcribing`);try{let t=f.current;if(!p.current&&t){let n=await t.stop();if(e!==I.current)return;p.current=n}if(f.current=null,Y(),e!==I.current)return;let n=p.current;if(!n)throw Error(i.voiceTranscribeEmpty);let r=await k(n,n.type,AbortSignal.any([P.current.signal,AbortSignal.timeout(9e4)]),ie.current);if(e!==I.current)return;V.current=!1,await Q(r.text.trim())}catch(t){if(e!==I.current)return;Y(),V.current=!1,E(t instanceof Error?t.message:i.voiceTranscribeFailed),O(`session`),q(`error`)}},[Q,i.voiceTranscribeEmpty,i.voiceTranscribeFailed,Y,J,q]),Qe=(0,d.useCallback)(e=>{ke(e);let t=F.current;if(!(t===`idle`||t===`error`||V.current)){if(!N.current){if(t===`transcribing`&&e===`input_committed`){Q();return}J(),Y(),L.current?.cancel(),L.current=null,R.current=null,E(i.voiceTranscribeFailed),q(`error`);return}Z()}},[Q,Z,i.voiceTranscribeFailed,Y,J,q]),$e=(0,d.useCallback)(()=>{J(),qe.current=setInterval(()=>{let e=Re.current;if(e===null)return;let t=performance.now()-e;if(oe(Math.max(0,t/1e3)),t>=Ke.current&&F.current===`recording`){if(!N.current){ze.current();return}ke(`session_limit`),R.current?.stop(`user_finished`),Z()}},200)},[Z,J]),$=(0,d.useCallback)(async(e,n,r,o,s=!1,c)=>{if(t||F.current!==`idle`||e===`conversation`&&!r&&!c)return;if(!xe(Me.current)){E(i.callCaptureBusy),e===`dictation`&&u(`error`,i.callCaptureBusy);return}N.current=r;let l=new AbortController;P.current=l,E(null),O(null),ke(null);let d=++I.current,p=()=>d===I.current;je(e),w(e===`conversation`?`preparing`:null),(!s||!Pe.current)&&(Pe.current=crypto.randomUUID()),Fe.current=n,Ie.current=o,ue(``),q(`connecting`);let ae=performance.now(),m=(e,t,n)=>ne(e,l.signal,t,n),g=`permission`;try{if(e===`conversation`){g=`recorder`;let e=new pe;if(z.current=e,await m(e.start(),1e4),!p()){e.close();return}}g=`session`;let t=e===`dictation`?await m(be(l.signal),2e4):null;if(!p())return;if(t?.mode===`unavailable`){let e=Error(i.voiceSttNotConfigured);throw Object.assign(e,{body:{error:{code:`PROVIDER_UNAVAILABLE`}}}),e}let d=t?.mode===`recorded`,ne=e===`conversation`?{mode:n,...o?{naturalBackend:o}:{},...c?{testHiggsVoice:c}:{},conversationId:r}:{},ae=d?[]:await m(fe.preflight({purpose:e,...ne,signal:l.signal}),2e4),se=!1;if(!p())return;g=`permission`;let le=window.electronAPI?.system,de=await m(Te(),5e3);if(!p()||!we(F.current))return;if(le&&de!==`granted`){q(`requesting`);let e=await m(le.requestMicrophone(),6e4);if(!p())return;let t=window.electronAPI?.platform===`darwin`&&e.status!==`granted`;if(e.status===`denied`||t)throw Error(`Microphone permission denied`)}else!le&&de!==`granted`&&q(`requesting`);if(!p()||!we(F.current))return;q(`starting`),window.dispatchEvent(new Event(`xopc-voice-recording-start`)),g=`media`;let y=await m(navigator.mediaDevices.getUserMedia({audio:te()}),15e3,e=>e.getTracks().forEach(e=>e.stop()));if(!p()||!we(F.current)){y.getTracks().forEach(e=>e.stop());return}if(Le.current=y,d){g=`recorder`;let e=await m(ye.start(y,{onAudioLevel:({level:e})=>{p()&&h(Math.min(1,e*8))}}),15e3,e=>e.cancel());if(!p()){e.cancel();return}f.current=e,ie.current=t.provider,ee(!0),Ke.current=6e5,Re.current=performance.now(),oe(0),q(`recording`),$e();return}e===`conversation`&&(w(`dialing`),z.current?.startRingback(),K.current=setTimeout(()=>{p()&&(z.current?.stopRingback(),w(`slow`),K.current=null)},12e3)),g=`session`,q(`connecting`),B.current.clear();let x=await m(fe.connect({timingMetrics:ae,logicalCallId:Pe.current,recovery:s,language:a(),purpose:e,signal:l.signal,...ne,onEvent:t=>{if(p()&&!((t.type===`input.transcript.delta`||t.type===`input.transcript.final`)&&!re(Be.current,t.payload.utteranceId,t.payload.revision,t.type===`input.transcript.final`))){if(t.type===`input.transcript.delta`&&_(t.payload.text),t.type===`input.transcript.final`){let n=t.payload.text.trim();_(``),ce(n),n&&e===`dictation`&&(B.current.set(t.payload.utteranceId,n),[...B.current.values()].join(` `).length>=2e4&&F.current===`recording`&&ze.current(),ce([...B.current.values()].join(` `)))}if(t.type===`input.speech_started`&&!T.current&&R.current?.session.bargeIn&&H.current&&We.current&&(G.current.size<32&&G.current.add(t.payload.utteranceId),z.current?.duck(!0)),t.type===`input.speech_stopped`&&(W.current=performance.now(),G.current.delete(t.payload.utteranceId)&&G.current.size===0&&z.current?.duck(!1)),t.type===`response.created`){if(H.current){H.current!==t.payload.responseId&&R.current?.cancelResponse(t.payload.responseId);return}H.current=t.payload.responseId,G.current.clear(),z.current?.duck(!1),Ue.current=!1,We.current=!1,Ge.current=0,ue(``),U.current.size||(v([]),b(null)),S(`thinking`)}if(t.type===`task.created`&&(U.current.add(t.payload.taskId),He([...U.current])),t.type===`task.activity`&&U.current.has(t.payload.taskId)){let e={toolCallId:t.payload.toolCallId,toolName:t.payload.toolName,status:t.payload.status};v(t=>[...t.filter(t=>t.toolCallId!==e.toolCallId),e].slice(-8))}if(t.type===`task.done`&&(U.current.delete(t.payload.taskId),He([...U.current]),U.current.size||v([])),t.type===`response.clarification`&&b(t.payload),t.type===`response.text.delta`&&H.current===t.payload.responseId&&(S(`speaking`),ue(e=>e+t.payload.delta)),t.type===`response.audio.started`&&H.current===t.payload.responseId&&S(`speaking`),t.type===`response.done`&&H.current===t.payload.responseId&&(Ue.current=!0,z.current?.hasPendingAudio||(H.current=null,S(`idle`))),t.type===`response.cancelled`&&H.current===t.payload.responseId&&(G.current.clear(),H.current=null,S(`idle`),z.current?.clear()),t.type===`session.error`&&t.payload.recoverable&&t.payload.code===`RESPONSE_FAILED`&&u(`warning`,i.voiceResponseFailed),t.type===`session.error`&&t.payload.recoverable&&t.payload.code===`INPUT_DROPPED`&&u(`warning`,i.voiceInputDropped),t.type===`session.error`&&!t.payload.recoverable){let n=t.payload.code===`PROVIDER_UNAVAILABLE`,r=t.payload.code===`CONTEXT_CHANGED`?i.voiceContextChanged:n?i.voiceSttNotConfigured:t.payload.message;E(r),O(`session`),j(n),e===`dictation`&&u(`error`,r,void 0,n?{href:`/settings/capabilities/models?configure=transcription`}:void 0),R.current?.stop(`surface_closed`),e===`conversation`?X():(J(),Y(),L.current?.cancel(),L.current=null,R.current=null),q(`error`)}}},onAudio:(e,t)=>{if(!p())return;let n=H.current;if(!n||t!==n)return;let r=!We.current,i=W.current;r&&(We.current=!0,W.current!==null&&R.current?.reportMetric(n,`speech_end_to_audio_received`,performance.now()-W.current),W.current=null);let a=z.current?.enqueue(e,()=>{H.current===n&&(Ge.current+=e.byteLength,R.current?.acknowledgeAudio(n,Ge.current),c&&!se&&new Int16Array(e).some(e=>Math.abs(e)>96)&&(se=!0,Ye.current?.()),Ue.current&&!z.current?.hasPendingAudio&&(H.current=null,S(`idle`)))});r&&i!==null&&a!==void 0&&R.current?.reportMetric(n,`speech_end_to_audio_scheduled`,performance.now()-i+a)},onClose:e=>{p()&&Qe(e)}}),2e4,e=>e.stop(`surface_closed`));if(!p()){x.stop(`surface_closed`);return}z.current?.stopRingback(),K.current!==null&&clearTimeout(K.current),K.current=null,R.current=x,Ke.current=x.session.limits.maxSessionMs,g=`recorder`,q(`starting`);let C,me=[],he=e===`conversation`&&y.getAudioTracks()[0]?.getSettings?.().echoCancellation===!0,_e=.005,D=0,k=0,A=!1,xe=0,M=await m(ve.start(y,{frameDurationMs:20,onSamples:e=>{if(!p()||T.current)return;if(!C){me.push(e);return}let t=(Ne.current??C).push(e);t&&x.sendAudio(t)},onAudioLevel:({level:e})=>{if(p()){if(T.current){D=k=0,A=!1;return}if(xe++%2==0&&h(Math.min(1,e*8)),!(!he||!x.session.bargeIn)){if(!H.current||!We.current||!z.current?.hasPendingAudio){e<.02&&(_e+=(e-_e)*.05),D=k=0,A=!1;return}e>=Math.max(.022,_e*3)?(k=0,!A&&++D>=3&&(A=!0,z.current.duckForVoiceOnset())):(D=0,++k>=6&&(A=!1))}}}}),15e3,e=>e.cancel());if(!p()||!we(F.current)){M.cancel(),x.stop(`surface_closed`),y.getTracks().forEach(e=>e.stop());return}if(L.current=M,e===`conversation`&&(await m(z.current.start(),1e4),!p()))return;x.outputReady(),C=new ge(M.sampleRate,x.session.inputFormat.sampleRate),Ne.current=C;for(let e of me)x.sendAudio(C.push(e));Re.current=performance.now(),oe(0),q(`recording`),w(null),$e()}catch(t){if(!p())return;let n=De(g,t);console.error(`[chat:voice] realtime capture start failed`,{stage:g,durationMs:Math.round(performance.now()-ae),kind:n,errorName:Ee(t),errorMessage:t instanceof Error?t.message:String(t)}),R.current?.stop(`surface_closed`),X(),q(n===`session`?`error`:`idle`);let r=n===`session`&&Se(t),a=Ee(t)===`TimeoutError`?g===`session`?i.voiceConnectionTimeout:i.voiceMicrophoneTimeout:n===`permission`?i.voiceMicDenied:n===`device`?i.voiceMicUnavailable:n===`recorder`?i.voiceRecorderFailed:r?i.voiceSttNotConfigured:t instanceof Error?t.message:i.voiceSttNotConfigured;E(a),O(n),j(r),e===`dictation`&&u(`error`,a,void 0,r?{href:`/settings/capabilities/models?configure=transcription`}:void 0)}},[t,Qe,i,X,$e,Y,J,q]),et=(0,d.useCallback)(()=>{if(N.current)return;if(f.current||p.current){Ze();return}if(F.current===`error`&&B.current.size){Q();return}if(F.current!==`recording`)return;q(`transcribing`),J(),Y();let e=L.current,t=I.current;L.current=null,e?.stop().then(()=>{if(t!==I.current)return;let e=Ne.current?.flush();e&&R.current?.sendAudio(e),R.current?.commit()}).catch(()=>{t===I.current&&(u(`error`,i.voiceTranscribeFailed),R.current?.stop(`surface_closed`),X(),q(`error`))})},[Q,Ze,i.voiceTranscribeFailed,X,Y,J,q]);ze.current=et,(0,d.useEffect)(()=>()=>{M(Me.current),I.current+=1,P.current?.abort(),f.current?.cancel(),p.current=null,L.current?.cancel(),R.current?.stop(`surface_closed`),z.current?.close(),K.current!==null&&clearTimeout(K.current),Y(),J()},[Y,J]);let tt=(0,d.useCallback)(()=>{if(F.current===`error`){if(p.current){Ze();return}X(),q(`idle`),$(Ae,Fe.current,N.current,Ie.current,!0)}},[$,Ze,Ae,X,q]),nt=(0,d.useCallback)(()=>$(`dictation`),[$]),rt=(0,d.useCallback)((e,t,n)=>$(`conversation`,t,e,n),[$]),it=(0,d.useCallback)(e=>$(`conversation`,`natural`,void 0,void 0,!1,e),[$]),at=(0,d.useCallback)(()=>{let e=performance.now(),t=H.current;z.current?.clear(),G.current.clear(),H.current=null,S(`idle`),t&&(R.current?.reportMetric(t,`local_stop`,performance.now()-e),R.current?.cancelResponse(t))},[]),ot=(0,d.useCallback)(()=>{let e=!T.current;T.current=e,e&&(G.current.clear(),z.current?.duck(!1)),Le.current?.getAudioTracks().forEach(t=>{t.enabled=!e});let t=L.current,n=R.current;t&&n&&(Ne.current=new ge(t.sampleRate,n.session.inputFormat.sampleRate)),n?.setInputMuted(e),_(``),h(0),z.current?.duck(!1),he(e)},[]);return{phase:s,voiceActive:s!==`idle`,recordedDictation:l,elapsedLabel:Ce(ae),audioLevel:m,partialTranscript:g,finalTranscript:se,responseText:le,activeTaskIds:Ve,cancelTask:e=>{U.current.has(e)&&R.current?.cancelTask(e)},activities:de,clarification:y,dismissClarification:e=>b(t=>t?.requestId===e?null:t),responsePhase:x,callConnectionStage:C,muted:me,error:_e,failureKind:D,settingsRequired:A,endedReason:Oe,mode:Ae,startVoiceInput:nt,startVoiceConversation:rt,startHiggsTest:it,interruptResponse:at,toggleMute:ot,cancelVoiceInput:Xe,confirmVoiceInput:et,retryVoiceInput:tt}}export{ve as a,he as c,fe as d,ee as f,be as i,me as l,xe as n,ge as o,te as p,M as r,C as s,Oe as t,pe as u};
1
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t}from"./vendor-react-BOUWij0V.js";import{i as n,o as r,p as i,r as a}from"./locale-store-Cit_aHqC.js";import{a as o,r as s}from"./voice-CDlC6XMH.js";import{t as c}from"./session-manager-BVS3zxRZ.js";import{t as l}from"./middleware-Pd0e8Igk.js";import{t as u}from"./composer-notifications-B0IZsy8x.js";var d=e(t(),1),ee=i()(l(e=>({captions:!0,microphoneId:``,setCaptions:t=>e({captions:t}),setMicrophoneId:t=>e({microphoneId:t})}),{name:`xopc-voice-preferences`}));function te(){let e=ee.getState().microphoneId;return{echoCancellation:!0,noiseSuppression:!0,autoGainControl:!0,...e?{deviceId:{exact:e}}:{}}}function ne(e,t,n,r){return new Promise((i,a)=>{let o=!1,s=(e,n)=>{o||(o=!0,clearTimeout(l),t.removeEventListener(`abort`,c),e===void 0?i(n):a(e))},c=()=>s(t.reason??new DOMException(`Cancelled`,`AbortError`)),l=setTimeout(()=>s(new DOMException(`Voice startup timed out`,`TimeoutError`)),n);e.then(e=>{o?r?.(e):s(void 0,e)},e=>s(e)),t.addEventListener(`abort`,c,{once:!0}),t.aborted&&c()})}function re(e,t,n,r){let i=e.get(t);if(i&&(n<i.revision||i.final&&!r||n===i.revision&&(i.final||!r)))return!1;if(!e.has(t)&&e.size>=256){let t=e.keys().next().value;t!==void 0&&e.delete(t)}return e.set(t,{revision:n,final:r}),!0}var f=32,p=1481592883,ie=3,ae=1,oe=2,m=1,h=64*1024,g=new TextEncoder,_=new TextDecoder(`utf-8`,{fatal:!0});function se(e){let t=g.encode(e.id);if(!t.length||t.length>160||!Number.isInteger(e.connectionEpoch)||e.connectionEpoch<1||e.connectionEpoch>4294967295||!Number.isInteger(e.seq)||e.seq<1||e.seq>4294967295||!Number.isFinite(e.timestampMs)||e.timestampMs<0||e.durationMs!==20||e.flags<0||e.flags>3||!e.audio.length||e.audio.length%2||f+t.length+e.audio.length>h)throw Error(`Invalid voice media frame`);let n=new Uint8Array(f+t.length+e.audio.length),r=new DataView(n.buffer);return r.setUint32(0,p),r.setUint8(4,ie),r.setUint8(5,e.kind),r.setUint8(6,m),r.setUint8(7,e.flags),r.setUint32(8,e.connectionEpoch),r.setUint32(12,e.seq),r.setFloat64(16,e.timestampMs),r.setUint16(24,e.durationMs),r.setUint16(26,t.length),r.setUint32(28,e.audio.length),n.set(t,f),n.set(e.audio,f+t.length),n}function ce(e,t){if(e.length<=f||e.length>h)throw Error(`Invalid voice media frame`);let n=new DataView(e.buffer,e.byteOffset,e.byteLength),r=n.getUint8(5),i=n.getUint32(8),a=n.getUint32(12),o=n.getFloat64(16),s=n.getUint16(24),c=n.getUint16(26),l=n.getUint32(28),u=f+c,d=n.getUint8(7);if(n.getUint32(0)!==p||n.getUint8(4)!==ie||r!==t||n.getUint8(6)!==m||d>3||!i||!a||!Number.isFinite(o)||o<0||s!==20||!c||c>160||!l||l%2||u+l!==e.length)throw Error(`Invalid voice media header`);return{kind:r,connectionEpoch:i,id:_.decode(e.subarray(f,u)),seq:a,timestampMs:o,durationMs:s,flags:d,audio:e.slice(u)}}function le(e){let t=ce(e,oe);return{connectionEpoch:t.connectionEpoch,responseId:t.id,seq:t.seq,mediaTimestampMs:t.timestampMs,durationMs:t.durationMs,audio:t.audio}}function ue(e){return se({kind:ae,connectionEpoch:e.connectionEpoch,id:e.utteranceId,seq:e.audioSeq,timestampMs:e.capturedAtMonotonicMs,durationMs:e.durationMs,flags:!!e.start|(e.end?2:0),audio:e.audio})}var de=class{session;eventSeq=0;audioSeq=0;ready=!1;closed=!1;cancelled=new Set;constructor(e){this.session=e}event(e){if(this.closed)throw Error(`Voice session closed`);if(e.sessionId!==this.session.sessionId||e.seq!==this.eventSeq+1)throw Error(`Invalid voice event sequence`);if(this.eventSeq=e.seq,e.type===`session.ready`){if(this.ready||e.payload.connectionEpoch!==this.session.connectionEpoch||e.payload.purpose!==this.session.purpose||e.payload.inputMode!==this.session.inputMode||e.payload.inputFormat.sampleRate!==this.session.inputFormat.sampleRate||e.payload.mode!==this.session.mode||e.payload.route.engine!==this.session.route.engine)throw Error(`Voice session mismatch`);this.ready=!0}e.type===`response.cancelled`&&this.cancel(e.payload.responseId),e.type===`session.closed`&&(this.ready=!1,this.closed=!0)}audio(e){if(!this.ready||e.connectionEpoch!==this.session.connectionEpoch||e.seq!==this.audioSeq+1)throw Error(`Invalid voice audio sequence`);return this.audioSeq=e.seq,!this.cancelled.has(e.responseId)}cancel(e){if(!this.cancelled.has(e)){if(this.cancelled.size>=1e4)throw Error(`Voice response limit exceeded`);this.cancelled.add(e)}}};function v(e,t){return{protocolVersion:3,messageId:crypto.randomUUID(),type:e,sentAt:Date.now(),payload:t}}function y(e){let t=new URL(n(e));return t.protocol=t.protocol===`https:`?`wss:`:`ws:`,t.toString()}var fe=class e{socket;session;timingMetrics;receive;heartbeatId;inputRemainder=new Uint8Array;utteranceId=crypto.randomUUID();inputSeq=0;constructor(e,t,n=[]){this.socket=e,this.session=t,this.timingMetrics=n,this.receive=new de(t)}static async preflight(e){return e.purpose===`conversation`&&e.conversationId&&await new c().materialize(e.conversationId,`voice`),(await r(n(`/api/voice/realtime/preflight`),{method:`POST`,signal:e.signal,body:JSON.stringify({purpose:e.purpose,mode:e.mode,naturalBackend:e.naturalBackend,testHiggsVoice:e.testHiggsVoice,conversationId:e.conversationId,supportedProtocolVersions:[3],mediaPreferences:[`websocket-pcm`]})})).timingMetrics??[]}static async connect(t){t.signal?.throwIfAborted();let i=await r(n(`/api/voice/realtime/sessions`),{method:`POST`,signal:t.signal,body:JSON.stringify({purpose:t.purpose,...t.language?{language:t.language}:{},...t.purpose===`conversation`&&t.mode!==`natural`&&t.logicalCallId?{openingGreeting:{logicalCallId:t.logicalCallId,initiation:t.recovery?`recovery`:`user`,supportsOutputReady:!0}}:{},...t.mode?{mode:t.mode}:{},...t.naturalBackend?{naturalBackend:t.naturalBackend}:{},...t.testHiggsVoice?{testHiggsVoice:t.testHiggsVoice}:{},...t.conversationId?{conversationId:t.conversationId}:{},supportedProtocolVersions:[3],mediaPreferences:[`websocket-pcm`]})}),a=s.parse(i.payload);t.signal?.throwIfAborted();let c=new WebSocket(y(a.websocketPath));c.binaryType=`arraybuffer`;let l=new e(c,a,t.timingMetrics);return await new Promise((e,n)=>{let r=!1,i,s=e=>{r||(r=!0,i!==void 0&&window.clearTimeout(i),c.close(),n(e))};i=window.setTimeout(()=>s(Error(`Realtime voice connection timed out`)),15e3);let u=()=>{r?c.close():s(Error(`Realtime voice connection cancelled`))};if(t.signal?.addEventListener(`abort`,u,{once:!0}),c.addEventListener(`close`,()=>t.signal?.removeEventListener(`abort`,u),{once:!0}),t.signal?.aborted){u();return}c.onerror=()=>s(Error(`Realtime voice connection failed`)),c.onclose=e=>{r?t.onClose?.(e.reason):s(Error(e.reason||`Realtime voice connection closed`))},c.onopen=()=>{c.send(JSON.stringify(v(`session.start`,{sessionId:a.sessionId,ticket:a.ticket})))},c.onmessage=n=>{if(typeof n.data!=`string`){try{let e=le(new Uint8Array(n.data));l.receive.audio(e)&&t.onAudio?.(e.audio.slice().buffer,e.responseId)}catch{c.close(4400,`Invalid voice audio frame`)}return}try{let c=o(JSON.parse(n.data));if(l.receive.event(c),t.onEvent(c),c.type===`session.ready`&&!r){if(c.payload.connectionEpoch!==a.connectionEpoch||c.payload.mode!==a.mode)throw Error(`Voice session mismatch`);r=!0,window.clearTimeout(i),l.startHeartbeat(c.payload.heartbeatIntervalMs),e()}else c.type===`session.error`&&!c.payload.recoverable&&s(Error(c.payload.message))}catch(e){r?c.close(4400,`Invalid voice protocol frame`):s(e instanceof Error?e:Error(String(e)))}}}),l}outputReady(){this.session.openingGreeting?.accepted&&this.sendControl(`session.output_ready`,{connectionEpoch:this.session.connectionEpoch})}sendAudio(e){if(!e.byteLength||this.socket.readyState!==WebSocket.OPEN)return;let t=new Uint8Array(e),n=new Uint8Array(this.inputRemainder.byteLength+t.byteLength);n.set(this.inputRemainder),n.set(t,this.inputRemainder.byteLength);let r=0;for(;r+640<=n.byteLength;){let e=ue({connectionEpoch:this.session.connectionEpoch,utteranceId:this.utteranceId,audioSeq:++this.inputSeq,capturedAtMonotonicMs:performance.now(),durationMs:20,...this.inputSeq===1?{start:!0}:{},audio:n.slice(r,r+640)});this.socket.send(e.buffer),r+=640}this.inputRemainder=n.slice(r)}reportMetric(e,t,n){t===`speech_end_to_audio_scheduled`&&!this.timingMetrics.includes(t)||this.sendControl(`session.metric`,{responseId:e,metric:t,durationMs:Math.min(6e5,Math.max(0,n))})}setInputMuted(e){this.sendControl(`input.mute`,{muted:e}),this.inputRemainder=new Uint8Array,e||(this.utteranceId=crypto.randomUUID(),this.inputSeq=0)}commit(){this.sendControl(`input.commit`,{})}cancelResponse(e){this.sendControl(`response.stop_playback`,{responseId:e})}cancelTask(e){this.sendControl(`task.cancel`,{taskId:e})}acknowledgeAudio(e,t){this.sendControl(`response.audio.played`,{responseId:e,playedDurationMs:Math.floor(t/48)})}stop(e=`user_finished`){this.stopHeartbeat(),this.socket.readyState===WebSocket.OPEN?this.sendControl(`session.stop`,{reason:e}):this.socket.close()}sendControl(e,t){this.socket.readyState===WebSocket.OPEN&&(e===`response.stop_playback`&&`responseId`in t&&this.receive.cancel(t.responseId),this.socket.send(JSON.stringify(v(e,t))))}startHeartbeat(e){this.stopHeartbeat(),this.heartbeatId=window.setInterval(()=>this.sendControl(`session.ping`,{}),e),this.socket.addEventListener(`close`,()=>this.stopHeartbeat(),{once:!0})}stopHeartbeat(){this.heartbeatId!==void 0&&(window.clearInterval(this.heartbeatId),this.heartbeatId=void 0)}},b=1.7,pe=class{context=new AudioContext({sampleRate:24e3,latencyHint:`interactive`});output=this.context.createGain();ringbackOutput=this.context.createGain();limiter=this.context.createDynamicsCompressor();sources=new Set;ringbackSources=new Map;ringbackDelay=null;ringbackInterval=null;ringbackActive=!1;nextStartTime=0;hasStartedAudio=!1;confirmedSpeech=!1;tentativeDuckTimer;constructor(){this.output.gain.value=b,this.limiter.threshold.value=-6,this.limiter.knee.value=6,this.limiter.ratio.value=12,this.limiter.attack.value=.003,this.limiter.release.value=.12,this.output.connect(this.limiter),this.limiter.connect(this.context.destination),this.ringbackOutput.gain.value=0,this.ringbackOutput.connect(this.context.destination)}async start(){await this.context.resume()}get hasPendingAudio(){return this.sources.size>0}startRingback(){this.stopRingback(),this.context.state!==`closed`&&(this.ringbackActive=!0,this.ringbackDelay=setTimeout(()=>{this.ringbackDelay=null,!(!this.ringbackActive||this.context.state!==`running`)&&(this.ringbackOutput.gain.cancelScheduledValues(this.context.currentTime),this.ringbackOutput.gain.setValueAtTime(.14,this.context.currentTime),this.playRingbackPulse(),this.ringbackInterval=setInterval(()=>this.playRingbackPulse(),3e3))},500))}playRingbackPulse(){if(!this.ringbackActive||this.context.state!==`running`)return;let e=this.context.currentTime;for(let[t,n]of[392,494].entries()){let r=e+t*.4,i=this.context.createOscillator(),a=this.context.createGain();i.type=`sine`,i.frequency.value=n,a.gain.setValueAtTime(0,r),a.gain.linearRampToValueAtTime(.5,r+.04),a.gain.setValueAtTime(.5,r+.18),a.gain.linearRampToValueAtTime(0,r+.28),i.connect(a),a.connect(this.ringbackOutput),this.ringbackSources.set(i,a),i.onended=()=>{this.ringbackSources.delete(i),i.disconnect(),a.disconnect()},i.start(r),i.stop(r+.29)}}stopRingback(){if(this.ringbackActive=!1,this.ringbackDelay!==null&&clearTimeout(this.ringbackDelay),this.ringbackInterval!==null&&clearInterval(this.ringbackInterval),this.ringbackDelay=null,this.ringbackInterval=null,this.context.state!==`closed`){this.ringbackOutput.gain.cancelScheduledValues(this.context.currentTime),this.ringbackOutput.gain.setTargetAtTime(0,this.context.currentTime,.025);for(let[e,t]of this.ringbackSources){t.gain.cancelScheduledValues(this.context.currentTime),t.gain.setTargetAtTime(0,this.context.currentTime,.02);try{e.stop(this.context.currentTime+.12)}catch{}}}}enqueue(e,t,n=24e3){if(e.byteLength<2||this.context.state===`closed`)return;let r=new DataView(e),i=new Float32Array(Math.floor(e.byteLength/2));for(let e=0;e<i.length;e+=1)i[e]=r.getInt16(e*2,!0)/32768;let a=this.context.createBuffer(1,i.length,n);a.copyToChannel(i,0);let o=this.context.createBufferSource();o.buffer=a,o.connect(this.output);let s=this.hasStartedAudio?.015:.02,c=Math.max(this.context.currentTime+s,this.nextStartTime);return o.start(c),this.hasStartedAudio=!0,this.nextStartTime=c+a.duration,this.sources.add(o),o.onended=()=>{this.sources.delete(o)&&(o.disconnect(),t())},Math.max(0,c-this.context.currentTime)*1e3}duck(e){clearTimeout(this.tentativeDuckTimer),this.tentativeDuckTimer=void 0,this.confirmedSpeech=e,this.setOutputGain(e?.15:1)}duckForVoiceOnset(){this.confirmedSpeech||this.tentativeDuckTimer!==void 0||!this.hasPendingAudio||(this.setOutputGain(.55),this.tentativeDuckTimer=setTimeout(()=>{this.tentativeDuckTimer=void 0,this.setOutputGain(1)},280))}setOutputGain(e){this.context.state!==`closed`&&(this.output.gain.cancelScheduledValues(this.context.currentTime),this.output.gain.setTargetAtTime(b*e,this.context.currentTime,.015))}clear(){for(let e of this.sources){e.onended=null;try{e.stop()}catch{}e.disconnect()}this.sources.clear(),this.nextStartTime=this.context.currentTime,this.hasStartedAudio=!1,this.duck(!1)}async close(){this.stopRingback(),this.clear(),this.output.disconnect(),this.ringbackOutput.disconnect(),this.limiter.disconnect(),this.context.state!==`closed`&&await this.context.close();for(let[e,t]of this.ringbackSources)e.onended=null,e.disconnect(),t.disconnect();this.ringbackSources.clear()}},x=`/assets/pcm-capture-worklet-CpXsv44v.js`,S=16e3;function C(e){if(e.length===0)return 0;let t=0;for(let n=0;n<e.length;n+=1)t+=e[n]*e[n];return Math.min(1,Math.sqrt(t/e.length))}function w(e){let t=e.reduce((e,t)=>e+t.length,0),n=new Float32Array(t),r=0;for(let t of e)n.set(t,r),r+=t.length;return n}function me(e,t,n=S){if(t===n)return e;let r=Math.max(1,Math.round(e.length*n/t)),i=new Float32Array(r),a=t/n;for(let t=0;t<r;t+=1){let n=t*a,r=Math.min(e.length-1,Math.floor(n)),o=Math.min(e.length-1,r+1),s=n-r;i[t]=e[r]*(1-s)+e[o]*s}return i}function he(e,t=S){let n=new ArrayBuffer(44+e.length*2),r=new DataView(n),i=(e,t)=>{for(let n=0;n<t.length;n+=1)r.setUint8(e+n,t.charCodeAt(n))};i(0,`RIFF`),r.setUint32(4,36+e.length*2,!0),i(8,`WAVE`),i(12,`fmt `),r.setUint32(16,16,!0),r.setUint16(20,1,!0),r.setUint16(22,1,!0),r.setUint32(24,t,!0),r.setUint32(28,t*2,!0),r.setUint16(32,2,!0),r.setUint16(34,16,!0),i(36,`data`),r.setUint32(40,e.length*2,!0);for(let t=0;t<e.length;t+=1){let n=Math.max(-1,Math.min(1,e[t]));r.setInt16(44+t*2,n<0?n*32768:n*32767,!0)}return n}function T(e){let t=new ArrayBuffer(e.length*2),n=new DataView(t);for(let t=0;t<e.length;t+=1){let r=Math.max(-1,Math.min(1,e[t]));n.setInt16(t*2,r<0?r*32768:r*32767,!0)}return t}var ge=class{sourceRate;targetRate;pending=new Float32Array;position=0;constructor(e,t=S){if(this.sourceRate=e,this.targetRate=t,e<=0||t<=0)throw Error(`PCM sample rates must be positive`)}push(e){if(e.length===0)return new ArrayBuffer(0);let t=new Float32Array(this.pending.length+e.length);t.set(this.pending),t.set(e,this.pending.length);let n=this.sourceRate/this.targetRate,r=[];for(;this.position+1<t.length;){let e=Math.floor(this.position),i=this.position-e;r.push(t[e]*(1-i)+t[e+1]*i),this.position+=n}let i=Math.min(t.length-1,Math.floor(this.position));return this.pending=t.slice(i),this.position-=i,T(Float32Array.from(r))}flush(){if(this.pending.length===0)return new ArrayBuffer(0);let e=this.pending[Math.min(this.pending.length-1,Math.floor(this.position))];return this.pending=new Float32Array,this.position=0,T(Float32Array.of(e))}},_e=`xopc-pcm-capture`,E=1e3,D=1e4,ve=class e{context;source;node;mutedOutput;options;sampleRate;paused=!1;accepting=!0;processorFailed=!1;stopPromise;flushResolve;constructor(e,t,n,r,i){this.context=e,this.source=t,this.node=n,this.mutedOutput=r,this.options=i,this.sampleRate=e.sampleRate,this.node.port.onmessage=e=>{if(e.data.type===`flushed`){this.flushResolve?.();return}if(!this.accepting||this.paused)return;let t=new Float32Array(e.data.buffer);if(this.options.onSamples(t),this.options.onAudioLevel){let e=C(t);this.options.onAudioLevel({level:e,speaking:e>=(this.options.speechThreshold??.015)})}},this.node.onprocessorerror=()=>{this.processorFailed=!0,this.flushResolve?.()}}static async start(t,n){if(typeof AudioWorkletNode>`u`)throw Error(`PCM audio recording is not supported in this browser`);let r=new AudioContext,i,a,o=new Promise((e,t)=>{a=setTimeout(()=>{t(new DOMException(`PCM audio capture startup timed out`,`TimeoutError`))},D)});try{await Promise.race([r.audioWorklet.addModule(x),o]);let a=r.createMediaStreamSource(t),s=n.frameDurationMs===void 0?void 0:Math.round(r.sampleRate*n.frameDurationMs/1e3),c=new AudioWorkletNode(r,_e,{processorOptions:{frameSamples:s}}),l=r.createGain();return l.gain.value=0,i=new e(r,a,c,l,n),a.connect(c),c.connect(l),l.connect(r.destination),await Promise.race([r.resume(),o]),i}catch(e){throw i?i.cancel():r.close().catch(()=>void 0),e}finally{clearTimeout(a)}}pause(){this.paused=!0}resume(){this.paused=!1}stop(){return this.stopPromise??=this.finish(),this.stopPromise}cancel(){this.accepting&&(this.accepting=!1,this.flushResolve?.(),this.flushResolve=void 0,this.disconnect(),this.context.close().catch(()=>void 0))}async finish(){this.accepting&&(this.processorFailed||await this.flushWorklet(),this.flushResolve=void 0,this.accepting&&(this.accepting=!1,this.disconnect(),await this.context.close().catch(()=>void 0)))}flushWorklet(){return new Promise(e=>{let t=!1,n=()=>{t||(t=!0,globalThis.clearTimeout(r),e())},r=globalThis.setTimeout(n,E);this.flushResolve=n;try{this.node.port.postMessage(`flush`)}catch{n()}})}disconnect(){this.node.port.onmessage=null,this.node.onprocessorerror=null,this.source.disconnect(),this.node.disconnect(),this.mutedOutput.disconnect()}},ye=class e{capture;chunks;stopped=!1;constructor(e,t){this.capture=e,this.chunks=t}static async start(t,n={}){let r=[],i=await ve.start(t,{...n,onSamples:e=>r.push(e)});return new e(i,r)}async stop(){if(this.stopped)return new Blob([],{type:`audio/wav`});this.stopped=!0,await this.capture.stop();let e=me(w(this.chunks),this.capture.sampleRate);return new Blob([he(e)],{type:`audio/wav`})}cancel(){this.stopped||(this.stopped=!0,this.capture.cancel(),this.chunks.length=0)}};function O(e){return e.includes(`ogg`)?`ogg`:e.includes(`mp4`)||e.includes(`m4a`)?`m4a`:e.includes(`mpeg`)||e.includes(`mp3`)?`mp3`:e.includes(`wav`)?`wav`:`webm`}async function k(e,t,i,a){let o=e.type||t||`audio/webm`,s=e.type?e:new Blob([e],{type:o}),c=new FormData;c.append(`audio`,s,`recording.${O(o)}`),a&&c.append(`expectedProvider`,a);let l=await r(n(`/api/voice/transcriptions`),{method:`POST`,body:c,...i?{signal:i}:{}});if(!l.payload)throw Error(`Missing transcription payload`);return l.payload}async function be(e){let t=await r(n(`/api/status`),{signal:e});if(!t.voice?.dictation)throw Error(`Missing dictation status`);return t.voice.dictation}function A(){}typeof window<`u`&&(window.addEventListener(`voice-config-changed`,A),window.addEventListener(`config-reload`,A));var j=null;function xe(e){return j&&j!==e?!1:(j=e,!0)}function M(e){j===e&&(j=null)}function Se(e){if(!(e instanceof Error))return!1;let t=e.body,n=typeof t?.error==`object`?t.error.code:void 0;return n===`VOICE_DISABLED`||n===`PROVIDER_UNAVAILABLE`}function Ce(e){if(!Number.isFinite(e)||e<0)return`0:00`;let t=Math.floor(e%60);return`${Math.floor(e/60)}:${t.toString().padStart(2,`0`)}`}function we(e){return e===`requesting`||e===`connecting`||e===`starting`}async function Te(){if(!navigator.permissions?.query)return null;try{return(await navigator.permissions.query({name:`microphone`})).state}catch{return null}}function Ee(e){return e instanceof DOMException||e instanceof Error?e.name:``}function De(e,t){if(e===`permission`)return`permission`;if(e===`recorder`)return`recorder`;if(e===`session`)return`session`;let n=Ee(t);return n===`NotAllowedError`||n===`SecurityError`?`permission`:`device`}function Oe(e){let{disabled:t,chat:i,onTranscript:o}=e,[s,c]=(0,d.useState)(`idle`),[l,ee]=(0,d.useState)(!1),f=(0,d.useRef)(null),p=(0,d.useRef)(null),ie=(0,d.useRef)(void 0),[ae,oe]=(0,d.useState)(0),[m,h]=(0,d.useState)(0),[g,_]=(0,d.useState)(``),[se,ce]=(0,d.useState)(``),[le,ue]=(0,d.useState)(``),[de,v]=(0,d.useState)([]),[y,b]=(0,d.useState)(null),[x,S]=(0,d.useState)(`idle`),[C,w]=(0,d.useState)(null),[me,he]=(0,d.useState)(!1),T=(0,d.useRef)(!1),[_e,E]=(0,d.useState)(null),[D,O]=(0,d.useState)(null),[A,j]=(0,d.useState)(!1),[Oe,ke]=(0,d.useState)(null),N=(0,d.useRef)(void 0),P=(0,d.useRef)(null),[Ae,je]=(0,d.useState)(`dictation`),Me=(0,d.useRef)(Symbol(`voice-capture`)),F=(0,d.useRef)(`idle`),I=(0,d.useRef)(0),L=(0,d.useRef)(null),Ne=(0,d.useRef)(null),R=(0,d.useRef)(null),Pe=(0,d.useRef)(void 0),Fe=(0,d.useRef)(void 0),Ie=(0,d.useRef)(void 0),z=(0,d.useRef)(null),Le=(0,d.useRef)(null),Re=(0,d.useRef)(null),B=(0,d.useRef)(new Map),V=(0,d.useRef)(!1),ze=(0,d.useRef)(()=>{}),Be=(0,d.useRef)(new Map),H=(0,d.useRef)(null),U=(0,d.useRef)(new Set),[Ve,He]=(0,d.useState)([]),Ue=(0,d.useRef)(!1),W=(0,d.useRef)(null),We=(0,d.useRef)(!1),G=(0,d.useRef)(new Set),Ge=(0,d.useRef)(0),Ke=(0,d.useRef)(6e5),qe=(0,d.useRef)(null),K=(0,d.useRef)(null),Je=(0,d.useRef)(o);Je.current=o;let Ye=(0,d.useRef)(e.onTestAudioPlayed);Ye.current=e.onTestAudioPlayed;let q=(0,d.useCallback)(e=>{F.current=e,c(e)},[]),J=(0,d.useCallback)(()=>{qe.current!=null&&(clearInterval(qe.current),qe.current=null)},[]),Y=(0,d.useCallback)(()=>{Le.current?.getTracks().forEach(e=>e.stop()),Le.current=null},[]),X=(0,d.useCallback)(()=>{M(Me.current),I.current+=1,P.current?.abort(),P.current=null,J(),K.current!==null&&clearTimeout(K.current),K.current=null,z.current?.stopRingback(),Y(),f.current?.cancel(),f.current=null,p.current=null,ie.current=void 0,ee(!1),L.current?.cancel(),L.current=null,Ne.current=null,R.current=null;let e=z.current;z.current=null,e?.close(),Re.current=null,oe(0),h(0),_(``),ce(``),ue(``),S(`idle`),w(null),v([]),b(null),W.current=null,G.current.clear(),T.current=!1,he(!1),j(!1),Be.current.clear(),B.current.clear(),V.current=!1,H.current=null,U.current.clear(),He([])},[Y,J]),Z=(0,d.useCallback)(()=>{X(),q(`idle`)},[X,q]),Xe=(0,d.useCallback)(()=>{R.current?.stop(`user_finished`),Z(),E(null),O(null),ke(null)},[Z]),Q=(0,d.useCallback)(async e=>{if(V.current)return;V.current=!0;let t=I.current,a=e??[...B.current.values()].join(` `).trim();if(Y(),J(),L.current?.cancel(),L.current=null,q(`transcribing`),!a){u(`warning`,i.voiceTranscribeEmpty),Z();return}let o=a;try{let e=await r(n(`/api/voice/transcriptions/refine`),{method:`POST`,body:JSON.stringify({text:a}),signal:AbortSignal.any([P.current.signal,AbortSignal.timeout(15e3)])});e.payload.text.trim()&&(o=e.payload.text)}catch{if(t!==I.current)return;u(`warning`,i.voiceRefinementFailed)}t===I.current&&(Je.current(o),Z())},[Z,i.voiceRefinementFailed,i.voiceTranscribeEmpty,Y,J,q]),Ze=(0,d.useCallback)(async()=>{if(V.current)return;V.current=!0;let e=I.current;J(),q(`transcribing`);try{let t=f.current;if(!p.current&&t){let n=await t.stop();if(e!==I.current)return;p.current=n}if(f.current=null,Y(),e!==I.current)return;let n=p.current;if(!n)throw Error(i.voiceTranscribeEmpty);let r=await k(n,n.type,AbortSignal.any([P.current.signal,AbortSignal.timeout(9e4)]),ie.current);if(e!==I.current)return;V.current=!1,await Q(r.text.trim())}catch(t){if(e!==I.current)return;Y(),V.current=!1,E(t instanceof Error?t.message:i.voiceTranscribeFailed),O(`session`),q(`error`)}},[Q,i.voiceTranscribeEmpty,i.voiceTranscribeFailed,Y,J,q]),Qe=(0,d.useCallback)(e=>{ke(e);let t=F.current;if(!(t===`idle`||t===`error`||V.current)){if(!N.current){if(t===`transcribing`&&e===`input_committed`){Q();return}J(),Y(),L.current?.cancel(),L.current=null,R.current=null,E(i.voiceTranscribeFailed),q(`error`);return}Z()}},[Q,Z,i.voiceTranscribeFailed,Y,J,q]),$e=(0,d.useCallback)(()=>{J(),qe.current=setInterval(()=>{let e=Re.current;if(e===null)return;let t=performance.now()-e;if(oe(Math.max(0,t/1e3)),t>=Ke.current&&F.current===`recording`){if(!N.current){ze.current();return}ke(`session_limit`),R.current?.stop(`user_finished`),Z()}},200)},[Z,J]),$=(0,d.useCallback)(async(e,n,r,o,s=!1,c)=>{if(t||F.current!==`idle`||e===`conversation`&&!r&&!c)return;if(!xe(Me.current)){E(i.callCaptureBusy),e===`dictation`&&u(`error`,i.callCaptureBusy);return}N.current=r;let l=new AbortController;P.current=l,E(null),O(null),ke(null);let d=++I.current,p=()=>d===I.current;je(e),w(e===`conversation`?`preparing`:null),(!s||!Pe.current)&&(Pe.current=crypto.randomUUID()),Fe.current=n,Ie.current=o,ue(``),q(`connecting`);let ae=performance.now(),m=(e,t,n)=>ne(e,l.signal,t,n),g=`permission`;try{if(e===`conversation`){g=`recorder`;let e=new pe;if(z.current=e,await m(e.start(),1e4),!p()){e.close();return}}g=`session`;let t=e===`dictation`?await m(be(l.signal),2e4):null;if(!p())return;if(t?.mode===`unavailable`){let e=Error(i.voiceSttNotConfigured);throw Object.assign(e,{body:{error:{code:`PROVIDER_UNAVAILABLE`}}}),e}let d=t?.mode===`recorded`,ne=e===`conversation`?{mode:n,...o?{naturalBackend:o}:{},...c?{testHiggsVoice:c}:{},conversationId:r}:{},ae=d?[]:await m(fe.preflight({purpose:e,...ne,signal:l.signal}),2e4),se=!1;if(!p())return;g=`permission`;let le=window.electronAPI?.system,de=await m(Te(),5e3);if(!p()||!we(F.current))return;if(le&&de!==`granted`){q(`requesting`);let e=await m(le.requestMicrophone(),6e4);if(!p())return;let t=window.electronAPI?.platform===`darwin`&&e.status!==`granted`;if(e.status===`denied`||t)throw Error(`Microphone permission denied`)}else!le&&de!==`granted`&&q(`requesting`);if(!p()||!we(F.current))return;q(`starting`),window.dispatchEvent(new Event(`xopc-voice-recording-start`)),g=`media`;let y=await m(navigator.mediaDevices.getUserMedia({audio:te()}),15e3,e=>e.getTracks().forEach(e=>e.stop()));if(!p()||!we(F.current)){y.getTracks().forEach(e=>e.stop());return}if(Le.current=y,d){g=`recorder`;let e=await m(ye.start(y,{onAudioLevel:({level:e})=>{p()&&h(Math.min(1,e*8))}}),15e3,e=>e.cancel());if(!p()){e.cancel();return}f.current=e,ie.current=t.provider,ee(!0),Ke.current=6e5,Re.current=performance.now(),oe(0),q(`recording`),$e();return}e===`conversation`&&(w(`dialing`),z.current?.startRingback(),K.current=setTimeout(()=>{p()&&(z.current?.stopRingback(),w(`slow`),K.current=null)},12e3)),g=`session`,q(`connecting`),B.current.clear();let x=await m(fe.connect({timingMetrics:ae,logicalCallId:Pe.current,recovery:s,language:a(),purpose:e,signal:l.signal,...ne,onEvent:t=>{if(p()&&!((t.type===`input.transcript.delta`||t.type===`input.transcript.final`)&&!re(Be.current,t.payload.utteranceId,t.payload.revision,t.type===`input.transcript.final`))){if(t.type===`input.transcript.delta`&&_(t.payload.text),t.type===`input.transcript.final`){let n=t.payload.text.trim();_(``),ce(n),n&&e===`dictation`&&(B.current.set(t.payload.utteranceId,n),[...B.current.values()].join(` `).length>=2e4&&F.current===`recording`&&ze.current(),ce([...B.current.values()].join(` `)))}if(t.type===`input.speech_started`&&!T.current&&R.current?.session.bargeIn&&H.current&&We.current&&(G.current.size<32&&G.current.add(t.payload.utteranceId),z.current?.duck(!0)),t.type===`input.speech_stopped`&&(W.current=performance.now(),G.current.delete(t.payload.utteranceId)&&G.current.size===0&&z.current?.duck(!1)),t.type===`response.created`){if(H.current){H.current!==t.payload.responseId&&R.current?.cancelResponse(t.payload.responseId);return}H.current=t.payload.responseId,G.current.clear(),z.current?.duck(!1),Ue.current=!1,We.current=!1,Ge.current=0,ue(``),U.current.size||(v([]),b(null)),S(`thinking`)}if(t.type===`task.created`&&(U.current.add(t.payload.taskId),He([...U.current])),t.type===`task.activity`&&U.current.has(t.payload.taskId)){let e={toolCallId:t.payload.toolCallId,toolName:t.payload.toolName,status:t.payload.status};v(t=>[...t.filter(t=>t.toolCallId!==e.toolCallId),e].slice(-8))}if(t.type===`task.done`&&(U.current.delete(t.payload.taskId),He([...U.current]),U.current.size||v([])),t.type===`response.clarification`&&b(t.payload),t.type===`response.text.delta`&&H.current===t.payload.responseId&&(S(`speaking`),ue(e=>e+t.payload.delta)),t.type===`response.audio.started`&&H.current===t.payload.responseId&&S(`speaking`),t.type===`response.done`&&H.current===t.payload.responseId&&(Ue.current=!0,z.current?.hasPendingAudio||(H.current=null,S(`idle`))),t.type===`response.cancelled`&&H.current===t.payload.responseId&&(G.current.clear(),H.current=null,S(`idle`),z.current?.clear()),t.type===`session.error`&&t.payload.recoverable&&t.payload.code===`RESPONSE_FAILED`&&u(`warning`,i.voiceResponseFailed),t.type===`session.error`&&t.payload.recoverable&&t.payload.code===`INPUT_DROPPED`&&u(`warning`,i.voiceInputDropped),t.type===`session.error`&&!t.payload.recoverable){let n=t.payload.code===`PROVIDER_UNAVAILABLE`,r=t.payload.code===`CONTEXT_CHANGED`?i.voiceContextChanged:n?i.voiceSttNotConfigured:t.payload.message;E(r),O(`session`),j(n),e===`dictation`&&u(`error`,r,void 0,n?{href:`/settings/capabilities/models?configure=transcription`}:void 0),R.current?.stop(`surface_closed`),e===`conversation`?X():(J(),Y(),L.current?.cancel(),L.current=null,R.current=null),q(`error`)}}},onAudio:(e,t)=>{if(!p())return;let n=H.current;if(!n||t!==n)return;let r=!We.current,i=W.current;r&&(We.current=!0,W.current!==null&&R.current?.reportMetric(n,`speech_end_to_audio_received`,performance.now()-W.current),W.current=null);let a=z.current?.enqueue(e,()=>{H.current===n&&(Ge.current+=e.byteLength,R.current?.acknowledgeAudio(n,Ge.current),c&&!se&&new Int16Array(e).some(e=>Math.abs(e)>96)&&(se=!0,Ye.current?.()),Ue.current&&!z.current?.hasPendingAudio&&(H.current=null,S(`idle`)))});r&&i!==null&&a!==void 0&&R.current?.reportMetric(n,`speech_end_to_audio_scheduled`,performance.now()-i+a)},onClose:e=>{p()&&Qe(e)}}),2e4,e=>e.stop(`surface_closed`));if(!p()){x.stop(`surface_closed`);return}z.current?.stopRingback(),K.current!==null&&clearTimeout(K.current),K.current=null,R.current=x,Ke.current=x.session.limits.maxSessionMs,g=`recorder`,q(`starting`);let C,me=[],he=e===`conversation`&&y.getAudioTracks()[0]?.getSettings?.().echoCancellation===!0,_e=.005,D=0,k=0,A=!1,xe=0,M=await m(ve.start(y,{frameDurationMs:20,onSamples:e=>{if(!p()||T.current)return;if(!C){me.push(e);return}let t=(Ne.current??C).push(e);t&&x.sendAudio(t)},onAudioLevel:({level:e})=>{if(p()){if(T.current){D=k=0,A=!1;return}if(xe++%2==0&&h(Math.min(1,e*8)),!(!he||!x.session.bargeIn)){if(!H.current||!We.current||!z.current?.hasPendingAudio){e<.02&&(_e+=(e-_e)*.05),D=k=0,A=!1;return}e>=Math.max(.022,_e*3)?(k=0,!A&&++D>=3&&(A=!0,z.current.duckForVoiceOnset())):(D=0,++k>=6&&(A=!1))}}}}),15e3,e=>e.cancel());if(!p()||!we(F.current)){M.cancel(),x.stop(`surface_closed`),y.getTracks().forEach(e=>e.stop());return}if(L.current=M,e===`conversation`&&(await m(z.current.start(),1e4),!p()))return;x.outputReady(),C=new ge(M.sampleRate,x.session.inputFormat.sampleRate),Ne.current=C;for(let e of me)x.sendAudio(C.push(e));Re.current=performance.now(),oe(0),q(`recording`),w(null),$e()}catch(t){if(!p())return;let n=De(g,t);console.error(`[chat:voice] realtime capture start failed`,{stage:g,durationMs:Math.round(performance.now()-ae),kind:n,errorName:Ee(t),errorMessage:t instanceof Error?t.message:String(t)}),R.current?.stop(`surface_closed`),X(),q(n===`session`?`error`:`idle`);let r=n===`session`&&Se(t),a=Ee(t)===`TimeoutError`?g===`session`?i.voiceConnectionTimeout:i.voiceMicrophoneTimeout:n===`permission`?i.voiceMicDenied:n===`device`?i.voiceMicUnavailable:n===`recorder`?i.voiceRecorderFailed:r?i.voiceSttNotConfigured:t instanceof Error?t.message:i.voiceSttNotConfigured;E(a),O(n),j(r),e===`dictation`&&u(`error`,a,void 0,r?{href:`/settings/capabilities/models?configure=transcription`}:void 0)}},[t,Qe,i,X,$e,Y,J,q]),et=(0,d.useCallback)(()=>{if(N.current)return;if(f.current||p.current){Ze();return}if(F.current===`error`&&B.current.size){Q();return}if(F.current!==`recording`)return;q(`transcribing`),J(),Y();let e=L.current,t=I.current;L.current=null,e?.stop().then(()=>{if(t!==I.current)return;let e=Ne.current?.flush();e&&R.current?.sendAudio(e),R.current?.commit()}).catch(()=>{t===I.current&&(u(`error`,i.voiceTranscribeFailed),R.current?.stop(`surface_closed`),X(),q(`error`))})},[Q,Ze,i.voiceTranscribeFailed,X,Y,J,q]);ze.current=et,(0,d.useEffect)(()=>()=>{M(Me.current),I.current+=1,P.current?.abort(),f.current?.cancel(),p.current=null,L.current?.cancel(),R.current?.stop(`surface_closed`),z.current?.close(),K.current!==null&&clearTimeout(K.current),Y(),J()},[Y,J]);let tt=(0,d.useCallback)(()=>{if(F.current===`error`){if(p.current){Ze();return}X(),q(`idle`),$(Ae,Fe.current,N.current,Ie.current,!0)}},[$,Ze,Ae,X,q]),nt=(0,d.useCallback)(()=>$(`dictation`),[$]),rt=(0,d.useCallback)((e,t,n)=>$(`conversation`,t,e,n),[$]),it=(0,d.useCallback)(e=>$(`conversation`,`natural`,void 0,void 0,!1,e),[$]),at=(0,d.useCallback)(()=>{let e=performance.now(),t=H.current;z.current?.clear(),G.current.clear(),H.current=null,S(`idle`),t&&(R.current?.reportMetric(t,`local_stop`,performance.now()-e),R.current?.cancelResponse(t))},[]),ot=(0,d.useCallback)(()=>{let e=!T.current;T.current=e,e&&(G.current.clear(),z.current?.duck(!1)),Le.current?.getAudioTracks().forEach(t=>{t.enabled=!e});let t=L.current,n=R.current;t&&n&&(Ne.current=new ge(t.sampleRate,n.session.inputFormat.sampleRate)),n?.setInputMuted(e),_(``),h(0),z.current?.duck(!1),he(e)},[]);return{phase:s,voiceActive:s!==`idle`,recordedDictation:l,elapsedLabel:Ce(ae),audioLevel:m,partialTranscript:g,finalTranscript:se,responseText:le,activeTaskIds:Ve,cancelTask:e=>{U.current.has(e)&&R.current?.cancelTask(e)},activities:de,clarification:y,dismissClarification:e=>b(t=>t?.requestId===e?null:t),responsePhase:x,callConnectionStage:C,muted:me,error:_e,failureKind:D,settingsRequired:A,endedReason:Oe,mode:Ae,startVoiceInput:nt,startVoiceConversation:rt,startHiggsTest:it,interruptResponse:at,toggleMute:ot,cancelVoiceInput:Xe,confirmVoiceInput:et,retryVoiceInput:tt}}export{ve as a,he as c,fe as d,ee as f,be as i,me as l,xe as n,ge as o,te as p,M as r,C as s,Oe as t,pe as u};
@@ -1 +1 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t}from"./vendor-react-BOUWij0V.js";import{i as n,o as r,s as i}from"./workspace-api-CscTRODe.js";var a=e(t(),1);function o(e){return e.map(e=>({fileId:e.id,name:e.name,path:e.path,isDirectory:e.isDirectory,children:e.isDirectory?[]:void 0}))}function s(e,t,n){return e.map(e=>e.path===t?{...e,children:n}:e.isDirectory&&e.children?.length?{...e,children:s(e.children,t,n)}:e)}function c(e,t,c){let[l,u]=(0,a.useState)([]),[d,f]=(0,a.useState)(null),[p,m]=(0,a.useState)(!1),[h,g]=(0,a.useState)(null),_=(0,a.useRef)(new Set),v=e.trim(),y=t?.trim()??``,b=c?.trim()??``,x=b?``:y,S=!b&&!y?v:``,C=(0,a.useMemo)(()=>{if(b)return{projectId:b};if(x)return{conversationId:x};if(S)return{agentId:S}},[b,x,S]);return{tree:l,rootResource:d,loading:p,error:h,loadRoot:(0,a.useCallback)(async()=>{m(!0),g(null),_.current.clear();try{let[e,t]=await Promise.all([n(``,C),r(C)]);u(o(e.entries)),f(o([t])[0]??null),_.current.add(``)}catch(e){f(null),g(e instanceof Error?e.message:String(e))}finally{m(!1)}},[C]),loadChildren:(0,a.useCallback)(async e=>{if(!_.current.has(e)){_.current.add(e);try{let t=o(await i(e,C));u(n=>s(n,e,t))}catch{_.current.delete(e)}}},[C]),refreshDirectory:(0,a.useCallback)(async e=>{let t=o(await i(e,C));u(e?n=>s(n,e,t):t),_.current.add(e)},[C]),reset:(0,a.useCallback)(()=>{u([]),f(null),g(null),_.current.clear()},[])}}export{c as t};
1
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t}from"./vendor-react-BOUWij0V.js";import{i as n,o as r,s as i}from"./workspace-api-g-wCKoQU.js";var a=e(t(),1);function o(e){return e.map(e=>({fileId:e.id,name:e.name,path:e.path,isDirectory:e.isDirectory,children:e.isDirectory?[]:void 0}))}function s(e,t,n){return e.map(e=>e.path===t?{...e,children:n}:e.isDirectory&&e.children?.length?{...e,children:s(e.children,t,n)}:e)}function c(e,t,c){let[l,u]=(0,a.useState)([]),[d,f]=(0,a.useState)(null),[p,m]=(0,a.useState)(!1),[h,g]=(0,a.useState)(null),_=(0,a.useRef)(new Set),v=e.trim(),y=t?.trim()??``,b=c?.trim()??``,x=b?``:y,S=!b&&!y?v:``,C=(0,a.useMemo)(()=>{if(b)return{projectId:b};if(x)return{conversationId:x};if(S)return{agentId:S}},[b,x,S]);return{tree:l,rootResource:d,loading:p,error:h,loadRoot:(0,a.useCallback)(async()=>{m(!0),g(null),_.current.clear();try{let[e,t]=await Promise.all([n(``,C),r(C)]);u(o(e.entries)),f(o([t])[0]??null),_.current.add(``)}catch(e){f(null),g(e instanceof Error?e.message:String(e))}finally{m(!1)}},[C]),loadChildren:(0,a.useCallback)(async e=>{if(!_.current.has(e)){_.current.add(e);try{let t=o(await i(e,C));u(n=>s(n,e,t))}catch{_.current.delete(e)}}},[C]),refreshDirectory:(0,a.useCallback)(async e=>{let t=o(await i(e,C));u(e?n=>s(n,e,t):t),_.current.add(e)},[C]),reset:(0,a.useCallback)(()=>{u([]),f(null),g(null),_.current.clear()},[])}}export{c as t};